<?php
require "showshp.php";
session_start();
if(!isset($_SESSION['titles']) || !isset($_SESSION['positions'])|| !isset($_SESSION['usernames'])){
header("location:index.php");
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="rdsty.css">
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script src="datesps.js"></script>
<script src="jquery.min.js"></script>

<script language="javascript" type="text/javascript">
jQuery.expr[":"].containsNoCase = function(el, i, m) {
var search = m[3];
if (!search) return false;
return eval("/" + search + "/i").test($(el).text());
};

jQuery(document).ready(function() {
// used for the first example in the blog post
jQuery('li:contains(\'DotNetNuke\')').css('color', '#0000ff').css('font-weight', 'bold');
    
// hide the cancel search image
jQuery('#imgSearch').hide();
  
// reset the search when the cancel image is clicked
jQuery('#imgSearch').click(function() {
resetSearch();
});
  
// cancel the search if the user presses the ESC key
jQuery('#txtSearch').keyup(function(event) {
if (event.keyCode == 27) {
resetSearch();
}
});
    
// execute the search
jQuery('#txtSearch').keyup(function() {
// only search when there are 3 or more characters in the textbox
if (jQuery('#txtSearch').val().length > 2) {
// hide all rows
jQuery('#dtd tr').hide();
// show the header row
jQuery('#dtd tr:first').show();
// show the matching rows (using the containsNoCase from Rick Strahl)
jQuery('#dtd tr td:containsNoCase(\'' + jQuery('#txtSearch').val() + '\')').parent().show();
// show the cancel search image
jQuery('#imgSearch').show();
}
else if (jQuery('#txtSearch').val().length == 0) {
// if the user removed all of the text, reset the search
resetSearch();
}
    
// if there were no matching rows, tell the user
if (jQuery('#dtd tr:visible').length == 1) {
// remove the norecords row if it already exists
jQuery('.norecords').remove();
// add the norecords row
jQuery('#dtd').append('<tr class="norecords"><td colspan="5" class="Normal">No records were found</td></tr>');
}
});
});
function resetSearch() {
jQuery('#txtSearch').val('');
jQuery('#dtd tr').show();
jQuery('.norecords').remove();
jQuery('#imgSearch').hide();
jQuery('#txtSearch').focus();
}
</script>
</head>

<body style="font-family:calibri;font-size:small" onload="mnh('amnc','agentsb')">
<div class="hdn"></div>

<?php
printf("<div class='ses'>%s (%s)</div>",$_SESSION['titles'],$_SESSION['positions']);
?>

<div class="tops" align="center">Customer Database</div>
<div class="homes"><a href="index.php" style='color:#A9BCF5;'>Sign out</a></div>

</body>
</html>
<?php


showsrds();
printf("</div><div class='srg'></div>");
printf("<div class='mains' style='width:80%%;'>");


$conn=mysqli_connect("localhost","primarysales","S5L7lF01EQZvQrGK","primarysales_diana");
$sesqlst="select * from acs where user_names='".$_SESSION['usernames']."'";
$seqry=mysqli_query($conn,$sesqlst);

while($serst=mysqli_fetch_row($seqry)){
$agname=$serst[4];

printf("<form method='post' action='updatecus.php?%s'>",$rpsty);
printf("<div class='fra' align='left'><input type='text' id='txtSearch' name='txtSearch' placeholder='Type for details' style='width:200px'maxlength='100'/></div></form>",$starts,$ends);

printf("<div class='tdt'><br><table id='dtd' style='font-size:13'><th border='white' bgcolor='silver' colspan='10'><b>Customer Details</th>");
printf("<tr bgcolor='grey'  style='color:#E6E6E6;'><td width=75 align='center' style='border:1px solid white' >Id</td><td width=120 align='center' style='border:1px solid white'>Customer</td><td width=120 align='center'   style='border:1px solid white'>Type</td><td width=150 align='center' style='border:1px solid white'>Route</td>
<td style='border:1px solid white' width=80 align='center'>Territory</td><td width=80 style='border:1px solid white' align='center'>Address</td>
<td width=80 style='border:1px solid white' align='center'>Contact</td><td width=60 style='border:1px solid white' align='center'>Edit</td></tr>");

if($agname<>'All'){
$sqlst="select distinct id,custname,custtype,custroute,custarea,custaddres,custtp from customer where agent_name='$agname' order by id DESC";
$qry=mysqli_query($conn,$sqlst);
}
else
{
$sqlst="select distinct id,custname,custtype,custroute,custarea,custaddres,custtp from customer order by id DESC";
$qry=mysqli_query($conn,$sqlst);
}
while($rst=mysqli_fetch_row($qry)){
printf("<tr class='cls' bgcolor='white' onmouseover=\"this.style.backgroundColor='grey';\" onmouseout=\"this.style.backgroundColor='white';\"><td align='left'>%s</td>
<td>%s</td><td>%s</td><td align='left'>%s</td><td align='left'>%s</td><td align='left'>%s</td><td align='right'>%s</td><td align='right'><a href='#'>Edit</td></tr>",$rst[0],$rst[1],$rst[2],$rst[3],$rst[4],$rst[5],$rst[6],$rst[3],$rst[1],$rst[2],$rst[0]);
}
}

?>
