<?php
session_start();
if (!isset($_SESSION['reusername'])) { echo 'Sorry You Dont Have permissions to View this Page!'; exit();}
include 'includes/database.php';
include 'includes/display.php';
include 'includes/funcs.php';
echo  $htmlheaders;
echo $jquery;
echo $recss;	
echo '<link rel="stylesheet" href="css/m.css" type="text/css" /> ';
?>

<script type="text/javascript">

 var perm = <?php echo $_SESSION['reusergroup']; ?>;

</script>

<style>
.ui-autocomplete {
            max-height: 300px;
            overflow-y: auto;
            /* prevent horizontal scrollbar */
            overflow-x: hidden;
            /* add padding to account for vertical scrollbar */
            padding-right: 10px;
        } 
		
</style>

<?php 
echo '<head><title>QoolPoint Information System &nbsp;|&nbsp; QPL QIS</title>';
echo '</head><body>';
echo '<div id="form">';
//later set variable to session
$admin = $_SESSION['reusername']; 

echo '<table id="dskfullbox" style="font-family:"Trebuchet MS"; font-size:12px; font-weight:bold; text-align:left;">
<tr> <td valign="top" style="width:700px;">'.str_repeat("&nbsp;", 5).$logopath.'<span id="licbox">QOOLPOINT INFORMATION SYSTEM</span></td>';
//echo '<td>'. str_repeat("&nbsp;", 5).'</td> ';
echo '<td align="right" valign="bottom"><h2><div id="loggedin">'.$loggedin.'|'.$admin.'|'.$clock.'   '.$time.'   '.$userlogd.'</h2></td>'; 
echo '</tr>';
echo '<tr><td colspan="2" valign="top">';
echo '<center>
<div class="line_1">
<div class="drop_container">
  <div class="always_visible" onclick="searchbxf();">Search Docs</div>
</div>
<div class="drop_container">
  <div class="always_visible" onclick="cusf();">Customers</div>
</div>
 <div class="drop_container">
  <div class="always_visible">Tracking</div>
  <div class="hidden_container">
  <a href="#" id="ea1" onclick="trajcf();" class="link">Tracker Job Card</a>
  <a href="#" id="ea2"  onclick="trainvf();" class="link">Tracker Invoice</a>
  <a href="#" onclick="trackf();" class="link">Trackers</a>
  </div>
</div>

<div class="drop_container">
  <div class="always_visible">Insurance</div>
  <div class="hidden_container">
  <a href="#" id="m1"  onclick="insaff();" class="link">Insurance Sale</a>
  <a href="#" id="m2"  onclick="insdetf();" class="link">Provider Info</a>
  </div>
</div>

<div class="drop_container">
  <div class="always_visible">Reposession</div>
  <div class="hidden_container">
  <a href="#" onclick="repoof();" class="link">Reposession Orders</a>
  <a href="#" onclick="repoexpf();" class="link">Reposession Expenses</a>
  </div>
</div>
<div class="drop_container">
  <div class="always_visible" onclick="othersf();">Others</div>
</div>
<div class="drop_container">
  <div class="always_visible" onclick="recpmf();">Receipts</div>
</div>
<div class="drop_container">
  <div class="always_visible" onclick="paymf();">Payments</div>
</div>
<div class="drop_container">
  <div class="always_visible"  onclick="accsmf();">Accounts</div>
</div>
<div class="drop_container">
  <div class="always_visible" onclick="samf();">Masters</div>
</div>
<div class="drop_container">
  <div class="always_visible" onclick="logoff();">Logout</div>
</div>
<div style="clear:both;"></div>
</div>
</center>';		
echo '</td></tr>';

echo '<tr> <td colspan="2" valign="top" align="center" style="width:800px;height:500px;margin:5px;">';

	echo '<div id=scrblok>';
	echo '<table cellspacing="5px" id="searchbox">';
    echo '<tr>Search Records</tr>'.
		'<tr><td align="left"> <img style="vertical-align:middle" class="iconbtn" onclick="searchres();" src="images/searchic.png">&nbsp;&nbsp;</img> <label for="schtid"> Search Vehicle &nbsp;&nbsp;</label> <input type="text" id="schtid" name="schtid" value="" size="70"/></td></tr>';
	echo '<tr><td><span style="float:middle;background-color:beige;padding: 0 10px 0 10px;" onclick="searchclr();">Clear</span></td></tr>';
	echo '</table> </div>';
	
    echo '<div id=propblok>';
    echo '</div>';	
	
echo '';
echo '</td></tr></table>';
echo '</div>';

echo '</body></html>';

?>
<script type="text/javascript">
$('#schtid').autocomplete({ source: "allsearchrecs.php?str="+$('#schtid').val(), minLength: 3  });

                                                                        /* Customer Form		*/
function cusf(){  	
	 var selbox = 'Customer Operations <br/><br/><input type="radio"  id="cusel" name="added" value="add" onclick ="cusaddf();"/><b>Add</b>&nbsp;&nbsp;&nbsp;'+
              '<input type="radio"  id="addsel" name="added" value="edit" onclick="cusmodself();"/><b>Edit</b>&nbsp;&nbsp;&nbsp;';
	$('#scrblok').html(selbox); 
	$('#propblok').html('');
};

function cusaddf(){ 
	$('#propblok').html('');
	window.open("cusops.php?e=0","Customer Operations","width=500px,height=400px;scrollbar=1");
};

function cusmodself(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/custsel.png">&nbsp;&nbsp;</img> <label for="mcid"> Customer &nbsp;&nbsp;</label> <input type="text" id="mcid" name="mcid" value="" onchange="cusmodf();" size="40"/>';
	$('#propblok').html(modsel);
	$('#mcid').autocomplete({ source: "allcustomers.php", minLength: 2  });
};

function cusmodf(){ 
if((parseInt(perm) <= 2) || (parseInt(perm) === 4)){ 
	window.open("cusops.php?e=1"+"&cname="+$('#mcid').val(),"Customer Operations","width=500px,height=400px;scrollbar=1");
}	
};

                                                                       /* Tracker JobCard Form		*/
function trajcf(){  
if((parseInt(perm) <= 4)){	
	 var selbox = 'Jobcard Operations <br/><br/><input type="radio"  id="jcadd" name="jc" value="add" onclick ="jcaddf();"/><b>Add</b>&nbsp;&nbsp;&nbsp;'+
              '<input type="radio"  id="jcsel" name="jc" value="edit" onclick="jcmodself();"/><b>Edit</b>&nbsp;&nbsp;&nbsp;'+
              '<input type="radio"  id="jcdel" name="jc" value="dele" onclick="jcdelself();"/><b>Delete</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="jclist" name="jc" value="edit" onclick="jclistf();"/><b>JobCards List</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="trackexpi"  name="jc" value="expi" onclick="trackexpif();"/><b>Expirey List</b>&nbsp;&nbsp;&nbsp;<br>'; 
	$('#scrblok').html(selbox); 
	$('#propblok').html('');
}	
};
                                                                       /* Add JC		*/
function jcaddf(){  
	$('#propblok').html('');
	window.open("jcops.php?e=0","JC Operations","width=500px,height=530px;scrollbar=1");
};
																// Select JC to Modify
function jcmodself(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/jcmodsel.png" onclick="jcmodf();">&nbsp;&nbsp;</img> <label for="jcno"> JobCard No. &nbsp;&nbsp;</label> <input type="text" id="jcno" name="jcno" size="40"/>';
	$('#propblok').html(modsel);
	$('#jcno').autocomplete({ source: "alljcards.php", minLength: 2  });
};
																	// Modify JC
function jcmodf(){ 
if(parseInt(perm) <= 4){
	var jno = $('#jcno').val();
	var myjcno = jno.slice(0, (jno.indexOf("-"))-1); 
	window.open("jcops.php?e=1"+"&jc="+myjcno,"JC Edit Operations","width=500px,height=530px;scrollbar=1");
}	
};	
																// Select JC to Delete
function jcdelself(){ 
if((parseInt(perm) === 1) || (parseInt(perm) === 4)){
   var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/jcdel.png" onclick="jcdelf();">&nbsp;&nbsp;</img> <label for="djcno"> JobCard No. &nbsp;&nbsp;</label> <input type="text" id="djcno" name="djcno" size="40"/>';
	$('#propblok').html(modsel);
	$('#djcno').autocomplete({ source: "alljcards.php", minLength: 2  });
}	
};
																	// Delete JC
function jcdelf(){ 
if((parseInt(perm) === 1) || (parseInt(perm) === 4)){
	var jno = $('#djcno').val();
	var myjcno = jno.slice(0, (jno.indexOf("-"))-1);  
	window.location.replace("deljc.php?j="+myjcno);
}	
};	
																//  JC List date selection
function jclistf(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/jclist.png" onclick="jclist();">&nbsp;&nbsp;</img> <label for="jsd"> Start Date &nbsp;&nbsp;</label> <input type="text" id="jsd" name="jsd" value="<?php echo date('d-m-Y');?>" size="10"/> <label for="jed"> End Date &nbsp;&nbsp;</label> <input type="text" id="jed" name="jed" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#jsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#jed').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
};	
                                                                       /* JC List		*/
function jclist(){  
if(	$('#jsd').val() !=='' && $('#jed').val() !==''){
	window.open("jclist.php?s="+$('#jsd').val()+"&e="+$('#jed').val(),"JC Operations","width=1000px,height=800px;scrollbar=1");
}	
};	
																		// trackers expirey list
function trackexpif(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/trackexpi.png" onclick="trackexpi();">&nbsp;&nbsp;</img> <label for="trackexpil"> Renewal Date &nbsp;&nbsp;</label> <input type="text" id="trackexpil" name="trackexpil" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#trackexpil').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};

function trackexpi(){ 
	window.open("trackexpi.php?a="+$('#trackexpil').val(),"Track Expirey Summary","width=900px,height=800px;scrollbar=1");
};

$('#cname').autocomplete({ source: "allcustomers.php", minLength: 2  }); 
                                                                       /* Tracker Invoices Form		*/
function trainvf(){  
if((parseInt(perm) <= 4) ){	
	 var selbox = 'Tracker Invoice Operations <br/><br/><input type="radio"  id="invadd" name="trinv" value="add" onclick ="trainvaddf();"/><b>Add</b>&nbsp;&nbsp;&nbsp;'+
				  '<input type="radio"  id="trainvdel" name="trinv" value="invdel" onclick="trainvdelf();"/><b>Invoice Edit/Delete</b>&nbsp;&nbsp;&nbsp;'+
				  '<input type="radio"  id="trainvlist" name="trinv" value="list" onclick="trainvlistf();"/><b>Invoices List</br>'+
				  '<input type="radio"  id="cussel" name="trinv" value="acc" onclick="cusaccf();"/><b>Account</b>&nbsp;&nbsp;&nbsp;'+
				  '<input type="radio"  id="cussel" name="trinv" value="acc" onclick="cusstmtf();"/><b>Statement</b>&nbsp;&nbsp;&nbsp;'+
				  '<input type="radio"  id="agesel" name="trinv" value="age" onclick="cusagef();"/><b>Aged Summary</b>&nbsp;&nbsp;&nbsp;';
	$('#scrblok').html(selbox); 
}	
};
                                                                       /* Add JC invoice		*/
function trainvaddf(){ 
if(parseInt(perm) < 3){ 
	$('#propblok').html('');
	window.open("invadd.php?e=0","Invoice Operations","width=600px,height=530px;scrollbar=1");
}	
};
                                                                       /* Delete Tracker invoice		*/
function trainvdelf(){ 
if(parseInt(perm) < 3){ 
	$('#propblok').html('<img style="vertical-align:middle;margin:3px;" class="iconbtn" onclick="invdelf();" src="images/invdel.png">&nbsp;&nbsp;</img><label for="invnodel"> Invoice No. &nbsp;&nbsp;</label> <input type="text" id="invnodel" name="invnodel" value="" size="10"/> &nbsp; <input type="button" id="edinv" name="edinv" onclick="edinvno();" value="Edit"/>');
		$('#invnodel').autocomplete({ source: "allinvnos.php", minLength: 2  }); 
}	
};
function invdelf(){ 
if(parseInt(perm) < 3){ 
	var ino = $('#invnodel').val(); 
	var myi = ino.slice(0,(ino.indexOf("-"))-1);
	var confdeli = confirm("Delete Invoice"+myi+" ?");
	if(confdeli) { window.location.replace("delinv.php?i="+myi); }
}	
};
function edinvno(){ 
if(parseInt(perm) < 3){ 
	var ino = $('#invnodel').val();
	var myi = ino.slice(0,(ino.indexOf("-"))-1);
	window.open("invadd.php?e=1&i="+myi,"Invoice Edit","width=600px,height=530px;scrollbar=1");
}	
};
																//  Tracker Invoice date selection
function trainvlistf(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/invlist.png" onclick="trainvlist();">&nbsp;&nbsp;</img> <label for="trisd"> Start Date &nbsp;&nbsp;</label> <input type="text" id="trisd" name="trisd" value="<?php echo date('d-m-Y');?>" size="10"/> <label for="tried"> End Date &nbsp;&nbsp;</label> <input type="text" id="tried" name="tried" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#trisd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#tried').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
};	
                                                                       /* Tracker Invoices List		*/
function trainvlist(){  
if(	$('#trisd').val() !=='' && $('#tried').val() !==''){
	window.open("trinvlist.php?s="+$('#trisd').val()+"&e="+$('#tried').val(),"Invoice List","width=900px,height=800px;scrollbar=1");
}	
};
																				// customer account
function cusaccf(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" onclick="cusacc();" src="images/cusacc.png">&nbsp;&nbsp;</img>'+
'<label for="cusd"> Start Date &nbsp;&nbsp;</label> <input type="text" id="cusd" name="cusd" value="<?php echo date('d-m-Y');?>" size="10"/> <label for="cued"> End Date &nbsp;&nbsp;</label> <input type="text" id="cued" name="cued" value="<?php echo date('d-m-Y');?>" size="10"/><br>'+
'<label for="cusa"> Customer &nbsp;&nbsp;</label> <select id="cusa" name="cusa" value=""><?php echo selcus();?></select> <br/><br/> ';
	$('#propblok').html(modsel);
//	$('#cusa').autocomplete({ source: "allcustomers.php", minLength: 2  });
	$('#cusd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#cued').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
};

function cusacc(){ 
	window.open("cusacc.php?c="+$('#cusa').val()+"&s="+$('#cusd').val()+"&e="+$('#cued').val(),"Customer Account","width=900px,height=800px;scrollbar=1");
	
};

function cusstmtf(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" onclick="custmt();" src="images/cusacc.png">&nbsp;&nbsp;</img>'+
'<label for="cusmtsd"> Start Date &nbsp;&nbsp;</label> <input type="text" id="cusmtsd" name="cusmtsd" value="<?php echo date('d-m-Y');?>" size="10"/> <label for="cusmted"> End Date &nbsp;&nbsp;</label> <input type="text" id="cusmted" name="cusmted" value="<?php echo date('d-m-Y');?>" size="10"/><br>'+
'<label for="cusa"> Customer &nbsp;&nbsp;</label> <select id="cuss" name="cuss" value=""><?php echo selcus();?></select> <br/><br/> ';
	$('#propblok').html(modsel);
	$('#cusa').autocomplete({ source: "allcustomers.php", minLength: 2  });
	$('#cusmtsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#cusmted').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
};

function cusagef(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/cusage.png" onclick="cusaged();">&nbsp;&nbsp;</img> <label for="aged"> Inquiry Date &nbsp;&nbsp;</label> <input type="text" id="aged" name="aged" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#aged').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};

function custmt(){ 
	window.open("cusstmt.php?c="+$('#cuss').val()+"&s="+$('#cusmtsd').val()+"&e="+$('#cusmted').val(),"Customer Statement","width=900px,height=800px;scrollbar=1");
	
};
function cusaged(){ 
	window.open("cusaged.php?a="+$('#aged').val(),"Customer Aged Summary","width=900px,height=800px;scrollbar=1");
	
};

                                                                       /* Tracker  Ops		*/
function trackf(){  
if((parseInt(perm) <= 4)){	
	 var selbox = 'Tracker Operations <br/><br/><input type="radio"  id="trackin" name="list" value="new" onclick ="trackinf();"/><b>Edit Trackers</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="trackl" name="list" value="list" onclick="tracklistf();"/><b>Tracker Lists</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="tracksale" name="list" value="sales" onclick="tracksalef();"/><b>Tracker Sales</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="trackinfo" name="list" value="email" onclick="trackemail();"/><b>Tracker Followup</b>&nbsp;&nbsp;&nbsp;<br>';
	$('#scrblok').html(selbox); 
	$('#propblok').html('');
}	
}; 
																//  Tracker Lists Date selection
function tracklistf(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/tracklist.png" onclick="tracklist();">&nbsp;&nbsp;</img> <label for="custd"> Customer &nbsp;&nbsp;</label><select id="custd" name="custd" value=""><option value=""></option> <?php echo selcus();?></select> <br/>'+
									'<label for="trlsd"> Start Date &nbsp;</label> <input type="text" id="trlsd" name="trlsd" value="<?php echo date('d-m-Y');?>" size="10"/> &nbsp;<label for="trled"> End Date &nbsp;</label> <input type="text" id="trled" name="trled" value="<?php echo date('d-m-Y');?>" size="10"/><p></p>';
	$('#propblok').html(modsel);
	$('#trlsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#trled').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#custd').autocomplete({ source: "allcustomers.php", minLength: 2  });
}; 
																//  Tracker Sales Date selection
function tracksalef(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/tracklist.png" onclick="tracksales();">&nbsp;&nbsp;</img> <label for="trksd"> Start Date &nbsp;</label> <input type="text" id="trksd" name="trksd" value="<?php echo date('d-m-Y');?>" size="10"/> &nbsp;<label for="trked"> End Date &nbsp;</label> <input type="text" id="trked" name="trked" value="<?php echo date('d-m-Y');?>" size="10"/><p></p>';
	$('#propblok').html(modsel);
	$('#trksd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#trked').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
};
                                                                // Trackers List
function tracklist(){       
   window.open('tracklist.php?s='+$("#trlsd").val()+'&e='+$("#trled").val()+'&c='+$("#custd").val(),"Tracker List","width=900px,height=750px");       
};
                                                                // Trackers Sales List
function tracksales(){       
if($("#custd").val() !== ''){                  
           window.open('tracksales.php?s='+$("#trksd").val()+'&e='+$("#trked").val(),"Tracker Sales","width=900px,height=750px");            
}    
};

                                                                //Tracker Input
 function trackinf(){ 
if(parseInt(perm) <= 4){   
           window.open('trackedit.php',"Edit Trackers","width=700px,height=600px,scrollbar=1"); 
}		   
 };
																//  Tracker email
function trackemail(){ var modsel = '<p><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/trackem.png" onclick="trackem();">&nbsp;&nbsp;</img> <label for="emregno"> Reg. No. &nbsp;&nbsp;</label> &nbsp;<input type="text" id="emregno" name="emregno" value=""/>&nbsp;&nbsp;'+
									'<label for="emimei"> IMEI No. &nbsp;&nbsp;</label> &nbsp;<input type="text" id="emimei" name="emimei" value=""/>&nbsp;<br>'+
									'<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/tracksh.png" onclick="trackshrel();">&nbsp;&nbsp;</img> <label for="shrel"> Tracker Status List &nbsp;</label> &nbsp;&nbsp; <label for="shrsd"> Start Date</label> &nbsp;<input type="text" id="shrsd" name="shrsd" value="<?php echo date('d-m-Y'); ?>" size="8"/>&nbsp;&nbsp;'+
									'<label for="shred"> End Date</label> &nbsp;<input type="text" id="shred" name="shred" value="<?php echo date('d-m-Y'); ?>" size="8"/>&nbsp;&nbsp;<select id="selshr"><option value="SHARED">SHARED</option><option value="RELEASED">RELEASED</option></select></p>';
	$('#propblok').html(modsel);
	$('#emimei').autocomplete({ source: "allimeinos.php?str="+$('#emimei').val(), minLength: 2  });
	$('#emregno').autocomplete({ source: "allregnos.php", minLength: 3  });
	$('#shrsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#shred').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
}; 
                                                                //Tracker Email Info Input
function trackem(){ 
if(parseInt(perm) <= 4){   
           window.open('trackerem.php?i='+$('#emimei').val()+'&r='+$('#emregno').val(),"Edit Tracker Email","width=600px,height=500px,scrollbar=1"); 
 }		   
};
                                                                //Tracker status list
function trackshrel(){ 
if((parseInt(perm) <= 4) && ($('#shrsd').val() !== '') && ($('#shred').val() !== '')){   
           window.open('trackshrlist.php?s='+$('#shrsd').val()+'&e='+$('#shred').val()+'&st='+$('#selshr').val(),"Tracker Status List","width=900px,height=800px,scrollbar=1"); 
 }		   
};

																// Insurance Sale
function insaff(){ 
if((parseInt(perm) === 1) || (parseInt(perm) === 5) || (parseInt(perm) === 4)){  
	var selbox = 'Customer Insurance Operations <br/><br/><input type="radio"  id="insadd" name="inssale" value="add" onclick ="insaddf();"/><b>New Insurance</b>&nbsp;&nbsp;&nbsp;'+
              '<input type="radio"  id="inssel" name="inssale" value="edit" onclick="insmodself();"/><b>Edit Insurance</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="insac"  name="inssale" value="acc" onclick="cusinsaccf();"/><b>Insurance Customer Accounts</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="agesel" name="inssale" value="age" onclick="cusinsagef();"/><b>Aged Summary</b>&nbsp;&nbsp;&nbsp<br/>'+
			  '<input type="radio"  id="insinvlist" name="inssale" value="insinvlist" onclick="insinvlistf();"/><b>Invoices List</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="expi"  name="inssale" value="expi" onclick="cusinsexpif();"/><b>Expirey List</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="expi"  name="inssale" value="expi" onclick="cusinsstatf();"/><b>Status List</b>&nbsp;&nbsp;&nbsp;<br>';
	$('#scrblok').html(selbox); 
	$('#propblok').html('');
}	
};
	
function insaddf(){ 
	$('#propblok').html('');
	window.open("insops.php?e=0","Insurance Operations","width=850px,height=770px;scrollbar=1");
};
																// Select Insurance Invoice to Modify
function insmodself(){ var modsel = '<p align="left"><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insmodsel.png" onclick="insmodf();">&nbsp;&nbsp;</img> <label for="insbkno"> Booking No. &nbsp;&nbsp;</label> <input type="text" id="insbkno" name="insbkno" size="40"/> &nbsp; &nbsp; <input type="button" id="insdel" name="insdel" value=" Delete " onclick="delins();"/></p>'+
									'<p align="left"><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/inscred.png" onclick="inscuscred();">&nbsp;&nbsp;</img> <label for="inscuscred"> Customer Credit &nbsp;&nbsp;</label>&nbsp; <input type="text" id="icredno" name="icredno" size="40"/></p>'+
									'<p align="left"><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/inscert.png" onclick="inscertprn();">&nbsp;&nbsp;</img> <label for="inscertprn"> Certificate &nbsp;&nbsp;</label> &nbsp; &nbsp; <select id="certno" name="certno"><?php echo selcuscert(); ?></select> </p>'+
									'<p align="left"><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insendo.png" onclick="insendo();">&nbsp;&nbsp;</img> <label for="insendono"> Endorsement &nbsp;&nbsp; Booking No. </label> <input type="text" id="insendono" name="insendono" size="40"/>&nbsp; &nbsp; <input type="button" id="endoprn" name="endoprn" value=" Print " onclick="endoprn();"/>'+
									'<p align="left"><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insrenew.png" onclick="insrenew();">&nbsp;&nbsp;</img> <label for="insrenno"> Renewal &nbsp;&nbsp; Booking No. </label> <input type="text" id="insrenno" name="insrenno" size="40"/>&nbsp; &nbsp; <input type="button" id="renewprn" name="renewprn" value=" Print " onclick="renewprn();"/>';
	$('#propblok').html(modsel);
	$('#insbkno').autocomplete({ source: "allinsbooks.php", minLength: 2  });
	$('#insrenno').autocomplete({ source: "allinsbooks.php", minLength: 2  });
	$('#insendono').autocomplete({ source: "allinsbooks.php", minLength: 2  });
	$('#icredno').autocomplete({ source: "allinscreds.php", minLength: 2  });
};
																	// Modify Insurance Invoice
function insmodf(){ 
	var insinvno = ($('#insbkno').val());
	var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1); 
	window.open("insops.php?e=1"+"&insno="+myino,"Insurance Edit Operations","width=850px,height=700px;scrollbar=1");
};

																	// Delete Insurance
function delins(){ 
if($('#insbkno').val() !==''){
	var insinvno = ($('#insbkno').val());
	var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1);  
	var confdel = confirm("Delete All Transactions for this Insurance ?");
	if(confdel){ var deldone = $.get("delinsu.php?d="+myino, function(data){
					alert(data);
			   });}
}	
};
																	// Customer Insurance Credit
function inscuscred(){ 
var credno = ($('#icredno').val());
	var credno = credno.slice(0, (credno.indexOf("-"))-1); 
	window.open("inscuscred.php?c="+credno,"Insurance Credit Operations","width=600px,height=530px;scrollbar=1");
};
																	// Customer Certificate
function inscertprn(){ 
var certfno = $('#certno').val();
var myino = certfno.slice(0, certfno.indexOf("-"));		var myi = certfno.slice((certfno.indexOf("-"))+1); 		
var ttt = $.get("certwrite.php?insno="+myino+"&i="+myi, function(data){
				if(data.trim()==="OK"){ alert("Please Upload Data to Certificator!"); }
				});
};
																	// ins endorsement
function insendo(){ 
	var insinvno = ($('#insendono').val());
	var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1); 
	window.open("insendo.php?insno="+myino,"Insurance Endorsement Operations","width=700px,height=700px;scrollbar=1");
};
																	// ins endorsement Print
function endoprn(){ 
	var insinvno = ($('#insendono').val());
	var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1); 
	window.open("endoprn.php?insno="+myino,"Insurance Endorsement Print","width=700px,height=700px;scrollbar=1");
};
																	// ins renewal
function insrenew(){ 
	var insinvno = ($('#insrenno').val());
	var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1); 
	window.open("insrenew.php?insno="+myino,"Insurance Renewal Operations","width=700px,height=700px;scrollbar=1");
};
																	// ins renewal Print
function renewprn(){ 
	var insinvno = ($('#insrenno').val());
	var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1); 
	window.open("renewprn.php?insno="+myino,"Insurance Renewal Print","width=700px,height=700px;scrollbar=1");
};
																// Insurance Customer Account selection
function cusinsaccf(){ 
	var cuss = $.get("selcus.php", function(cusdata){
		var modsel = '<p align="center"><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insproacc.png" onclick="inscusaccdet();">&nbsp;&nbsp;</img> <label for="inscussd"> Start Date &nbsp;</label> <input type="text" id="inscussd" name="inscussd" value="<?php echo date('d-m-Y');?>" size="10"/> &nbsp;<label for="inscused"> End Date &nbsp;</label> <input type="text" id="inscused" name="inscused" value="<?php echo date('d-m-Y');?>" size="10"/></p>'+
								   '<p align="center"><label for="inscust"> Customer &nbsp;&nbsp;</label> <select id="inscust" name="inscust"><option value=""></option>'+cusdata+'</select>&nbsp;&nbsp; <label for="cusaccbk"> Booking No.</label>&nbsp; <input type="text" id="cusaccbk" name="cusaccbk" size="35"/><br/></p>'+
								   '<p><img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/inscusstmt.png" onclick="inscusstmt();">&nbsp;&nbsp;</img> <label for="inscusstmt"> Statement &nbsp;</label> &nbsp;&nbsp; <label for="pend"> Pending ? &nbsp;</label><input type="checkbox" name="pend" id="pend"/></p>';
	$('#propblok').html(modsel);
	$('#inscussd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#inscused').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#cusaccbk').autocomplete({ source: "allinsbooks.php", minLength: 2  });
	});
};
															// insurance customer report
function inscusaccdet(){  
var insinvno = $('#cusaccbk').val(); 	
var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1); 
if (myino===''){ 
		window.open("inscusacc.php?s="+$('#inscussd').val()+"&e="+$('#inscused').val()+"&cus="+$('#inscust').val(),"insurance Customer Account","width=800px,height=800px;scrollbar=1");
	}
	else { window.open("inscusacc.php?s="+$('#inscussd').val()+"&e="+$('#inscused').val()+"&cus="+$('#inscust').val()+"&insno="+myino,"insurance Customer Account","width=800px,height=800px;scrollbar=1"); } 
};

function cusinsagef(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/cusage.png" onclick="cusinsaged();">&nbsp;&nbsp;</img> <label for="insaged"> Inquiry Date &nbsp;&nbsp;</label> <input type="text" id="insaged" name="insaged" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#insaged').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};


function cusinsaged(){ 
	window.open("cusinsaged.php?a="+$('#insaged').val(),"Ins Customer Aged Summary","width=900px,height=800px;scrollbar=1");
	
};
																		// Customer INS statement
function inscusstmt(){ 
var pp = document.getElementById('pend').checked;
if(pp){ var pending = 1; }
else { var pending = 0; }
	window.open("inscusstmt.php?s="+$('#inscussd').val()+"&e="+$('#inscused').val()+"&cus="+$('#inscust').val()+"&pend="+pending,"Ins Customer Statement","width=900px,height=800px;scrollbar=1");
	
};
		// Pending Customer INS statement
function inscuspend(){ 
	window.open("inscusstmt.php?s="+$('#inscussd').val()+"&e="+$('#inscused').val()+"&cus="+$('#inscust').val()+"&pend=1","Ins Customer Statement","width=900px,height=800px;scrollbar=1");
	
};
																		// insurance invoices list
function insinvlistf(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insinvl.png" onclick="insinvrep();">&nbsp;&nbsp;</img> <label for="insil"> Invoices List &nbsp;&nbsp;</label> <label for="insinvsd"> Start Date &nbsp;</label> <input type="text" id="insinvsd" name="insinvsd" value="<?php echo date('d-m-Y');?>" size="8"/>&nbsp;&nbsp; <label for="insinved"> End Date &nbsp;</label> <input type="text" id="insinved" name="insinved" value="<?php echo date('d-m-Y');?>" size="8"/>';
	$('#propblok').html(modsel);
	$('#insinvsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
	$('#insinved').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};

function insinvrep(){ 
	window.open("insinvlist.php?s="+$('#insinvsd').val()+"&e="+$('#insinved').val(),"Insurance Invoices","width=900px,height=800px;scrollbar=1");
};		
																// insurance expirey list
function cusinsexpif(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insexpi.png" onclick="cusinsexpi();">&nbsp;&nbsp;</img> <label for="cusinsexpil"> Expiry Date &nbsp;&nbsp;</label> <label for="cusinssd"> Start Date &nbsp;</label> <input type="text" id="cusinsexpsd" name="cusinsexpsd" value="<?php echo date('d-m-Y');?>" size="8"/>&nbsp;&nbsp; <label for="cusinsed"> End Date &nbsp;</label> <input type="text" id="cusinsexped" name="cusinsexped" value="<?php echo date('d-m-Y');?>" size="8"/>';
	$('#propblok').html(modsel);
	$('#cusinsexpsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
	$('#cusinsexped').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};

function cusinsexpi(){ 
	window.open("insexpi.php?s="+$('#cusinsexpsd').val()+"&e="+$('#cusinsexped').val(),"Ins Expirey Summary","width=900px,height=800px;scrollbar=1");
};
																		// insurance status list
function cusinsstatf(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/instat.png" onclick="cusinsstat();">&nbsp;&nbsp;</img> <label for="instatsd"> Start Date &nbsp;</label> <input type="text" id="instatsd" name="instatsd" value="<?php echo date('d-m-Y');?>" size="10"/> &nbsp;<label for="instated"> End Date &nbsp;</label> <input type="text" id="instated" name="instated" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#instatsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
	$('#instated').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};

function cusinsstat(){ 
	window.open("instat.php?s="+$('#instatsd').val()+"&e="+$('#instated').val(),"Ins staus List","width=900px,height=800px;scrollbar=1");
};

																// Provider info
function insdetf(){ 
if((parseInt(perm) === 1) || (parseInt(perm) === 5) || (parseInt(perm) === 4)){
	var selbox = 'Provider Operations <br/><br/><input type="radio"  id="inspro" name="insprov" value="insdet" onclick="insprof();"/><b>Insurance Billing</b>&nbsp;&nbsp;&nbsp;'+
				 '<input type="radio"  id="inscr"  name="insprov" value="inscr" onclick="inscred();"/><b> Provider Credit</b>&nbsp;&nbsp;&nbsp;'+
				 '<input type="radio"  id="insac"  name="insprov" value="acc" onclick="insproacc();"/><b> Provider Account</b>&nbsp;&nbsp;&nbsp;'+
				 '<input type="radio"  id="inslist"  name="insprov" value="list" onclick="inslist();"/><b> Insurance List</b>&nbsp;&nbsp;&nbsp;'+
				 '<input type="radio"  id="agesel" name="insprov" value="age" onclick="proagef();"/><b>Aged Summary</b>&nbsp;&nbsp;&nbsp';
	$('#scrblok').html(selbox); 
	$('#propblok').html('');
 }	
};
																// Provider details selection
function insprof(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insprodet.png" onclick="insprodet();">&nbsp;&nbsp;</img> <label for="insproaa"> Booking No. &nbsp;&nbsp;</label> <input type="text" id="insproaa" name="insproaa" size="45"/> <br>'
								+ '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/riskn.png" onclick="insrisk();">&nbsp;&nbsp;</img> <label for="insrisk"> Edit Risk Note &nbsp;&nbsp;</label> <input type="text" id="riskn" name="riskn" size="45"/> &nbsp;&nbsp;<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/riskprn.png" onclick="riskprn();">&nbsp;&nbsp;</img>';
	$('#propblok').html(modsel);
	$('#insproaa').autocomplete({ source: "allinsbooks.php", minLength: 2  });
	$('#riskn').autocomplete({ source: "allinsbooks.php", minLength: 2  });
};
																	// Modify provider dets
function insprodet(){ 
	var insinvno = $('#insproaa').val();
	var myino = insinvno.slice(0, (insinvno.indexOf("-"))-1); 
	window.open("insprodet.php?insno="+myino,"Provider Account","width=1100px,height=750px;scrollbar=1");
};
																		// Edit Risk Note
function insrisk(){ 
	var riskno = $('#riskn').val();
	var riskno = riskno.slice(0, (riskno.indexOf("-"))-1); 
	window.open("risknote.php?insno="+riskno,"Risk Note","width=900px,height=800px;scrollbar=1");
};
																		// Print Risk Note
function riskprn(){ 
	var riskno = $('#riskn').val();
	var riskno = riskno.slice(0, (riskno.indexOf("-"))-1); 
	window.open("riskprn.php?insno="+riskno,"Print Risk Note","width=800px,height=800px;scrollbar=1");
};
																	// Provider Credit Note
function inscred(){ 
	window.open("inscred.php","Provider Credit","width=600px,height=600px;scrollbar=1");
};
																// Provider details
function insproacc(){ 
var cuss = $.get("selcus.php", function(cusdata){
var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/insproacc.png" onclick="insproaccdet();">&nbsp;&nbsp;</img> <label for="supacsd"> Start Date &nbsp;</label> <input type="text" id="supacsd" name="supacsd" value="<?php echo date('d-m-Y');?>" size="10"/> &nbsp;<label for="supaced"> End Date &nbsp;</label> <input type="text" id="supaced" name="supaced" value="<?php echo date('d-m-Y');?>" size="10"/>'+
		'<br/><label for="inspro"> Provider &nbsp;&nbsp;</label>&nbsp;&nbsp; <select id="insprone" name="insprone"><?php echo selsupplier();?> </select><br/>'+
		'<br/><label for="insprocus"> Customer &nbsp;&nbsp;</label>&nbsp;&nbsp; <select id="insprocus" name="insprocus"><option value=""></option> '+cusdata+' </select><br/><br/>';
	$('#propblok').html(modsel);
	$('#supacsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#supaced').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	});
};
																// Insurance List
function inslist(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/inslist.png" onclick="insflist();">&nbsp;&nbsp;</img> <label for="inslisd"> Start Date &nbsp;</label> <input type="text" id="inslisd" name="inslisd" value="<?php echo date('d-m-Y');?>" size="10"/> &nbsp;<label for="inslied"> End Date &nbsp;</label> <input type="text" id="inslied" name="inslied" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#inslisd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#inslied').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
};
																				// insurance List
function insflist(){  
if(($('#inslisd').val() !=="") && ($('#inslied').val() !=="" )){
	window.open("inslist.php?s="+$('#inslisd').val()+"&e="+$('#inslied').val(),"Insurance List","width=800px,height=800px;scrollbar=1");
}
};
																	//  provider account dets
function insproaccdet(){  
if($('#insprone').val() !=="" ){
	window.open("supacc.php?e=1&supp="+$('#insprone').val()+"&s="+$('#supacsd').val()+"&e="+$('#supaced').val()+"&cus="+$('#insprocus').val(),"Provider Customer Account","width=800px,height=800px;scrollbar=1");
}
};
																		// provider aged date selection
function proagef(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/proage.png" onclick="proaged();">&nbsp;&nbsp;</img> <label for="proaged"> Inquiry Date &nbsp;&nbsp;</label> <input type="text" id="proaged" name="proaged" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#proaged').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};

function proaged(){ 
	window.open("proaged.php?a="+$('#proaged').val(),"Ins Supplier Aged Summary","width=900px,height=800px;scrollbar=1");
	
};
													//Reposession orders menu
function repoof(){ 
if((parseInt(perm) === 1) || (parseInt(perm) === 4)){  
	var selbox = 'Reposession Operations <br/><br/><input type="radio"  id="repoadd" name="repord" value="add" onclick ="repoaddf();"/><b>Reposession Order</b>&nbsp;&nbsp;&nbsp;'+
              '<input type="radio"  id="inssel" name="repord" value="edit" onclick="repomodself();"/><b>Edit Order</b>&nbsp;&nbsp;&nbsp;'+
			  '<input type="radio"  id="insac"  name="repord" value="acc" onclick="repoaccf();"/><b>Reposession Customer Accounts</b>&nbsp;&nbsp;&nbsp;<br>'+
			  '<input type="radio"  id="agesel" name="repord" value="age" onclick="repoacagef();"/><b>Aged Summary</b>&nbsp;&nbsp;&nbsp';
	$('#scrblok').html(selbox); 
	$('#propblok').html('');
}	
};
															// reposession order add
function repoaddf(){ 
	$('#propblok').html('');
	window.open("repoops.php?e=0","Reposession Operations","width=600px,height=550px;scrollbar=1");
};
																// Select Repo Order to Modify
function repomodself(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/repomodsel.png" onclick="repomodf();">&nbsp;&nbsp;</img> <label for="repon"> Order No. &nbsp;&nbsp;</label> <input type="text" id="repon" name="repon" size="40"/> &nbsp;&nbsp; <input type="button" id="delrepo" name="delrepo" value=" Delete " onclick="delrepof();"/>';
	$('#propblok').html(modsel);
	$('#repon').autocomplete({ source: "allreponos.php", minLength: 2  });
};
																// modify repo order
function repomodf(){ 
	var repono = $('#repon').val();
	var myno = repono.slice(0, (repono.indexOf("-"))-1); 
	window.open("repoops.php?e=1"+"&repono="+myno,"Repo Edit Operations","width=600px,height=530px;scrollbar=1");
};

																// del repo order
function delrepof(){ 
if($('#repon').val() !==''){
	var repono = $('#repon').val();
	var myno = repono.slice(0, (repono.indexOf("-"))-1); 
	var confdel = confirm("Delete All Transactions for this Reposession Order ?");
	if(confdel){ var deldone = $.get("delrepo.php?d="+myno, function(data){
					alert(data);
			   });}
}	
};

																// Reposession Customer Account selection
function repoaccf(){ 
var cuss = $.get("selcus.php",function(cusdata){
	var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/repoacc.png" onclick="repoaccdet();">&nbsp;&nbsp;</img> <label for="repoacsd"> Start Date &nbsp;</label> <input type="text" id="repoacsd" name="repoacsd" value="<?php echo date('d-m-Y');?>" size="10"/> &nbsp;<label for="repoaced"> End Date &nbsp;</label> <input type="text" id="repoaced" name="repoaced" value="<?php echo date('d-m-Y');?>" size="10"/>'+
								   '<br/><label for="repocust"> Customer &nbsp;&nbsp;</label>&nbsp;&nbsp; <select id="repocust" name="repocust"><option value=""></option> '+ cusdata +' </select><br/><br/>';						   
	$('#propblok').html(modsel);	
	$('#repoacsd').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#repoaced').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	});	
};
															// Reposession customer report
function repoaccdet(){  
	window.open("repoacc.php?s="+$('#repoacsd').val()+"&e="+$('#repoaced').val()+"&c="+$('#repocust').val(),"Reposession Customer Account","width=800px,height=800px;scrollbar=1");
};

function repoacagef(){ var modsel = '<img style="vertical-align:middle;margin:3px;" class="iconbtn" src="images/repoage.png" onclick="repoaged();">&nbsp;&nbsp;</img> <label for="repoaged"> Inquiry Date &nbsp;&nbsp;</label> <input type="text" id="repoaged" name="repoaged" value="<?php echo date('d-m-Y');?>" size="10"/>';
	$('#propblok').html(modsel);
	$('#repoaged').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
};

function repoaged(){ 
	window.open("repoaged.php?a="+$('#repoaged').val(),"Reposession Aged Summary","width=900px,height=800px;scrollbar=1");
	
};
																	// Reposession expense menu
function repoexpf(){  
if((parseInt(perm) === 1) || (parseInt(perm) === 4)){  	
	var cuss = $.get("selcus.php", function(cusdata){
	 var selbox = 'Reposession Reports <br/><br/><img style="vertical-align:middle" class="iconbtn" src="images/repoexlist.png" onclick="repoexlist();">&nbsp;&nbsp;</img><label for="repoexlist">Expenses List &nbsp;&nbsp;</label><label for="repoexsdate"> Start Date</label>&nbsp;&nbsp;<input type="text" id="repoexsdate" name="repoexsdate" value="<?php echo date('d-m-Y'); ?>" size="10">&nbsp;&nbsp;'+
	 '<label for="repoexedate"> End Date</label>&nbsp;&nbsp;<input type="text" id="repoexedate" name="repoexedate" value="<?php echo date('d-m-Y'); ?>" size="10"/><br/>'+
	 '<br/><label for="repoexcust"> Customer &nbsp;&nbsp;</label>&nbsp;&nbsp; <select id="repoexcust" name="repoexcust"><option value=""></option>'+ cusdata +' </select><br/><br/>'+
	 '<img style="vertical-align:middle" class="iconbtn" src="images/repordlist.png" onclick="repordlist();">&nbsp;&nbsp;</img><label for="repordlist">Orders List &nbsp;&nbsp;</label><label for="repordsdate"> Start Date</label>&nbsp;&nbsp;<input type="text" id="repordsdate" name="repordsdate" value="<?php echo date('d-m-Y'); ?>" size="10">&nbsp;&nbsp;'+
	 '<label for="repordedate"> End Date</label>&nbsp;&nbsp;<input type="text" id="repordedate" name="repordedate" value="<?php echo date('d-m-Y'); ?>" size="10"><br/>'+
	 '<label for="auctsel"> Auctioneer</label>&nbsp;&nbsp;<input type="text" id="auctsel" name="auctsel" value="" size="20"/>&nbsp;&nbsp; <label for="filt"> Filter </label>&nbsp;&nbsp;<select id="filt" name="filt"><option value="ALL">ALL</option> <option value="PENDING">PENDING</option> </select><br/><br/>';
	$('#scrblok').html(selbox); 
	$('#propblok').html('');
	$('#repordsdate').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
	$('#repordedate').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
	$('#repoexsdate').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
	$('#repoexedate').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"});
	$('#auctsel').autocomplete({ source: <?php echo allauctioneers(); ?>, minLength: 2  });
	});
 }	
};

function repoexlist(){ 
	$('#propblok').html('');
	window.open("repoexlist.php?s="+$('#repoexsdate').val()+"&e="+$('#repoexedate').val()+"&c="+$('#repoexcust').val(),"Repoex List","width=800px,height=700px;scrollbar=1");
};

function repordlist(){ 
	$('#propblok').html('');
	window.open("repordlist.php?s="+$('#repordsdate').val()+"&e="+$('#repordedate').val()+"&a="+$('#auctsel').val()+"&f="+$('#filt').val(),"Repo Orders List","width=800px,height=700px;scrollbar=1");
};



																	// Receipts Menu
function recpmf(){ 
if(parseInt(perm) < 2){  
    $('#scrblok').load('recpfrm.php');  
    $('#propblok').html('');
}
};  
                                                                //  Make Receipt
 function setrecpadd(){ 
 if($("#recpmod").val() !== ''){ 
           window.open('recpadd.php?e=1&recpno='+$("#recpmod").val(),"Edit Receipt","width=500px,height=500px,scrollbar=yes"); 
 }
 else { 
           window.open('recpadd.php?e=0',"New Receipt","width=500px,height=500px,scrollbar=yes"); 
 }
}; 
                                                                // Receipt List
function setrecplist(){       
//if((parseInt(perm) === 1) || (parseInt(perm) === 3)){                  
           window.open('recplist.php?s='+$("#rsdate").val()+'&e='+$("#redate").val(),"Receipt List","width=900px,height=750px");            
//}    
 };

                                                            // Receipt Reversal
function setrecprev(){ 
if((parseInt(perm) === 1) || (parseInt(perm) === 2)){    
	$( "#propblok" ).after('<div id="confdiag" title="Receipt Reversal Confirmation"></div>'); 
	var recpno = $("#recprev").val();				
	var rno = recpno.slice(0, recpno.indexOf("-"));
	$( "#confdiag" ).dialog({
                        autoOpen: true,
			modal: true,
			width: 470,
			buttons: [{text:"OK", click: function(){ $.get('recprev.php?r='+rno,function(data){  $( "#confdiag" ).dialog( "close" );}); }},
                                  {text:"Close", click: function(){ window.location.replace("desktop.php");}}]
                        });   
}                       
};

 																	// Payments Menu
function paymf(){  
if(parseInt(perm) < 2){   
    $('#scrblok').load('payfrm.php');  
    $('#propblok').html('');
}
};  
                                                                //  Make Payment
function setpayadd(){ 
if($("#paymod").val() === ''){  
           window.open('payadd.php?e=0',"New Payment","width=600px,height=800px,scrollbar=yes"); 
}
else{	var pno = $('#paymod').val();
		window.open('payadd.php?e=1&payno='+pno,"New Payment","width=600px,height=800px,scrollbar=yes");	  } 
 };
                                                                //  Payment voucher reprint
 function setpayvpr(){     
 	var pno = $('#payvpr').val();
	var mypno = pno.slice(0, pno.indexOf("-"));
    window.open('payprint.php?r=1&p='+mypno,"Payment voucher","width=600px,height=550px,scrollbar=yes"); 
 }; 
                                                                // Payment List
function setpaylist(){                        
           window.open('paylist.php?s='+$("#psdate").val()+'&e='+$("#pedate").val(),"Payment List","width=900px,height=750px");              
 }; 


                                                                    // Accountant Menu
function accsmf(){ 
if(parseInt(perm) < 3){      
 var selbox = '<form id="accform" method="post" enctype="multipart/form-data" action="#" ><center>'+
    '<table cellspacing="5px" id="accbox">'+
    '<tr>Accounts Operations</tr>'+
	'<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/cnote.png" onclick="cuscr();">&nbsp;&nbsp;</img><label for="expv">Credit Note &nbsp;&nbsp;</label></td></tr>'+
	'<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/expv.png" onclick="setexpvouch();">&nbsp;&nbsp;</img><label for="expv">Expense Voucher &nbsp;&nbsp;</label>&nbsp;<label for="dexpvch">Exp. Vch. No. &nbsp;&nbsp;</label>&nbsp;&nbsp;<select id="dexpvch" name="dexpvch" style="width:220px; height:20px;"><?php echo selexpvouchs();?></select> </td></tr>'+
	'<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/expvr.png" onclick="revexpvouch();">&nbsp;&nbsp;</img><label for="expvr">Expense Voucher Reversal&nbsp;&nbsp;</label>&nbsp;<select id="exprev" name="exprev"> <?php selexpvouchs(); ?> </select></td></tr>'+
    '<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/explist.png" onclick="setexpvchlist();">&nbsp;&nbsp;</img><label for="explist">Expenses List &nbsp;&nbsp;</label><label for="sedate"> Start Date</label>&nbsp;&nbsp;<input type="text" id="sedate" name="sedate" value="<?php echo date('d-m-Y'); ?>" size="10">&nbsp;&nbsp; <label for="edate"> End Date</label>&nbsp;&nbsp;<input type="text" id="eedate" name="ebdldate" value="<?php echo date('d-m-Y'); ?>" size="10"></td></tr>'+
    '<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/bankjv.png" onclick="setbankjv();">&nbsp;&nbsp;</img><label for="bankjv">Bank Journal Voucher &nbsp;&nbsp;</label>&nbsp;&nbsp;<label for="baccv">JV No. &nbsp;&nbsp;</label>&nbsp;&nbsp;<select id="baccv" name="baccv" style="width:220px; height:20px;"><?php echo selbankjvs();?></select></td></tr>'+
	'<tr><td align="middle"> <label for="bank">Bank &nbsp;&nbsp;</label>&nbsp;&nbsp;<select id="bacc" name="bacc" style="width:220px; height:20px;"><?php echo selallbanks();?></select></td></tr>'+
    '<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/bankledge.png" onclick="setbankledge();">&nbsp;&nbsp;</img><label for="explist">Bank Ledger &nbsp;&nbsp;</label><label for="sbdldate"> Start Date</label>&nbsp;&nbsp;<input type="text" class="dpicker" id="sbdldate" name="sbdldate" value="<?php echo date('d-m-Y'); ?>" size="10">&nbsp;&nbsp; <label for="ebdldate"> End Date</label>&nbsp;&nbsp;<input type="text" class="dpicker" id="ebdldate" name="ebdldate" value="<?php echo date('d-m-Y'); ?>" size="10"></td></tr>'+
	'<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/cashlist.png" onclick="setcashlist();">&nbsp;&nbsp;</img><label for="cashlist">Cash Flow &nbsp;&nbsp;</label><label for="cfsdate"> Start Date</label>&nbsp;&nbsp;<input type="text" class="dpicker" id="cfsdate" name="cfsdate" value="<?php echo date('d-m-Y'); ?>" size="10">&nbsp;&nbsp; <label for="cfedate"> End Date</label>&nbsp;&nbsp;<input type="text" class="dpicker" id="cfedate" name="cfedate" value="<?php echo date('d-m-Y'); ?>" size="10"></td></tr>'+
	'</table></center></form>';
 $('#scrblok').html(selbox);  
 $('#propblok').html('<p></p>');
 $('#sbdldate').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy' });
 $('#ebdldate').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy' }); 
 $('#cfsdate').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy' });
 $('#cfedate').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy' }); 
 $('#sedate').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy' });
 $('#eedate').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy' });
 }
};
																// Credit Note
function cuscr(){ 
	$('#propblok').html('');
	window.open("credops.php","Insurance Credit","width=600px,height=550px;scrollbar=1");
};
                                                                   //  Expense Voucher
function setexpvouch(){   
if((parseInt(perm) === 1) || (parseInt(perm) === 2)){      
if($("#dexpvch").val() !== ''){  window.open('expvchadd.php?e=1&dexpno='+$("#dexpvch").val(),"Expense Voucher","width=620px,height=500px"); }
else { window.open('expvchadd.php?e=0',"Expense Voucher","width=620px,height=500px"); };           
} 
}; 

																	//  Expense Voucher Reversal
function revexpvouch(){  
 if((parseInt(perm) === 1) || (parseInt(perm) === 2)){     
    $( "#propblok" ).after('<div id="confexprevdiag" title="Expense Voucher Reversal Confirmation"></div>');  
	$( "#confexprevdiag" ).dialog({
            autoOpen: true,
			modal: true,
			width: 550,
			buttons: [{text:"OK", click: function(){ $.get('expvchrev.php?r='+$("#exprev").val(),function(data){  $( "#confexprevdiag" ).dialog( "close" );}); }},
                      {text:"Close", click: function(){ window.location.replace("desktop.php");}}]
                        });             
 }
 }; 
 
function setexpvchlist(){   
 if($("#sedate").val() !=='' && $("#eedate").val() !==''){
           window.open('explist.php?sdate='+$("#sedate").val()+'&edate='+$("#eedate").val(),"Expenses List","width=950px,height=800px,scrollbar=1");            
 }
 }; 
                                                                   //  Make Bank JV
function setbankjv(){ 
if((parseInt(perm) === 1) ){ 
	
	if($("#baccv").val() !== ''){ window.open('bankjvadd.php?e=1&jvno='+$('#baccv').val(),"Modify Bank JV","width=620px,height=500px"); 
									}
	else {  window.open('bankjvadd.php?e=0',"New Bank JV","width=620px,height=500px");   }
}           
 }; 
                                                                   //  bank Ledger
 function setbankledge(){ 
 if((parseInt(perm) === 1)){     
	if($("#sbldate").val() !=='' && $("#ebldate").val() !==''){
           window.open('bankledger.php?bacc='+$("#bacc").val()+'&sbldate='+$("#sbdldate").val()+'&ebldate='+$("#ebdldate").val(),"Bank Ledger","width=900px,height=700px,scrollbar=1");            
	}
 }
 }; 
																			// Cash Flow Report
function setcashlist(){ 
if((parseInt(perm) === 1)){     
 if($("#cfsdate").val() !=='' && $("#cfedate").val() !==''){
           window.open('cashlist.php?sdate='+$("#cfsdate").val()+'&edate='+$("#cfedate").val(),"Cash Flow","width=950px,height=800px,scrollbar=1");            
 }
 }
 }; 

                                                                    // System Admin Menu
function samf(){ 
 if((parseInt(perm) === 1)){     
 var selbox = '<form id="saform" method="post" enctype="multipart/form-data" action="#" ><center>'+
    '<table cellspacing="5px" id="sabox">'+
    '<tr>Master File Operations</tr>'+
	'<tr><td align="left"> <img style="vertical-align:middle" class="iconbtn" src="images/modsupp.png" onclick="modsupps();">&nbsp;&nbsp;</img> <label for="pharspri"> Modify Suppliers &nbsp;&nbsp;</label> </td></tr>'+
    '<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/modexps.png" onclick="modexps();">&nbsp;&nbsp;</img><label for="mexpacc">Modify Expense Accounts &nbsp;&nbsp;</label>&nbsp;&nbsp;</td></tr>'+
	'<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/modbks.png" onclick="modbanks();">&nbsp;&nbsp;</img><label for="mbanks">Modify Banks &nbsp;&nbsp;</label>&nbsp;&nbsp;</td></tr>'+
	'<tr><td align="left"><img style="vertical-align:middle" class="iconbtn" src="images/modpass.png" onclick="modpawd();">&nbsp;&nbsp;</img><label for="bankjv">Modify Passwords &nbsp;&nbsp;</label>&nbsp;&nbsp;</td></tr>'+
    '</table></center></form>';
 $('#scrblok').html(selbox);  
 $('#propblok').html('<p></p>');
 } 
 }; 
                                                                  //  Modify Passwords
function modpawd(){ 
if((parseInt(perm) === 1)){     
           window.open('modpss.php',"Modify Passwords","width=600px,height=600px,scrollbar=yes");            
       } 
}; 
                                                                  //  Modify Providers
function modsupps(){ 
if((parseInt(perm) === 1)){     
           window.open('modsups.php',"Modify Provider Accounts","width=800px,height=900px,scrollbar=yes");            
       } 
};
                                                                  //  Modify Expense accounts
function modexps(){ 
if((parseInt(perm) === 1)){     
           window.open('modexps.php',"Modify Expense Accounts","width=800px,height=900px,scrollbar=yes");            
       } 
};
                                                                  //  Modify Banks
function modbanks(){ 
if((parseInt(perm) === 1)){     
           window.open('modbanks.php',"Modify Bank Accounts","width=800px,height=900px,scrollbar=yes");            
       } 
};

															// searcher
function searchres(){ 
var sch= $('#schtid').val();
sch = sch.replace(/(^\s+|\s+$)/g,'');
if(( sch !== '')  ){
	 var str = $.get("showvehdet.php?schtid="+sch, function(data){ 	
			$('#propblok').html(data);		
			});		
}
};
																	// Clears search box
function searchclr(){ $('#propblok').html('<p></p>');
					  document.getElementById('schtid').value="";
};

                                                                     // Search Screen
function searchbxf(){  
    $('#scrblok').html('<table cellspacing="5px" id="searchbox"> <tr>Search Records</tr> <tr><td align="left"> <img style="vertical-align:middle" onclick="searchres();" class="iconbtn" src="images/searchic.png">&nbsp;&nbsp;</img>'+
		'<label for="schtid"> Search Vehicle &nbsp;&nbsp;</label> <input type="text" id="schtid" name="schtid" value="" size="70"/></td></tr>'+
		'<tr><td><span style="float:middle;background-color:beige;padding: 0 10px 0 10px;" onclick="searchclr();">Clear</span></td></tr> </table>');  
    $('#propblok').html('<p></p>');
	$('#schtid').autocomplete({ source: "allsearchrecs.php", minLength: 3  });
}; 

function logoff(){  
	window.location.replace("index.php");
};


function userslogd(){  
	var str = $.get("showusers.php", function(data){ 	
			$('#propblok').html(data);		
			});
};
 </script>
  