
PK 
<?php
include "templatic/head.php";
include "templatic/header.php";
if($_GET[id] && ($_GET[sts]=="0" || $_GET[sts]=="1")){
$sql="update certificates set cancel='$_GET[sts]' where certificateno='$_GET[id]'";
mysql_query($sql) or die(mysql_error());
$sql="update invoices set cancel='$_GET[sts]' where certid='$_GET[id]'";
mysql_query($sql) or die(mysql_error());
}
?>
<div class="dataGrid">
<form method="get" action="">
<input type="hidden" name="typ"value="<?php echo $_GET[typ]?>" />
Search:
<input type="text" name="invno" size="12" value="<?php echo $_GET[invno]?>" placeholder="Invoice No"/>
<input type="text" name="container" value="<?php echo $_GET[container]?>" placeholder="Container No"/>
Date:
<input type="text" id="invdt" name="invdt" size="12" class="datepicker" value="<?php echo $_GET[invdt]; ?>" />
<script>
$(".datepicker").datepicker({
dateFormat: 'yy-mm-dd'
});
</script>
<select style="width:180px;" name="agent_id">
<option value="">Select Agent</option>
<?php
$rs = mysql_query('select * from agents where status="active" order by ajname ', $dblink) or die(mysql_error());
while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) ){
if($_GET['agent_id']==$row[ajid]){
$sel="selected";
}else{
$sel="";
}
?>
<option <?php echo $sel?> value="<?php echo $row[ajid]?>"><?php //echo $row[ajname]?><?php echo $row[ajcomp]?></option>
<?php
}
?>
</select>
<select style="width:180px;" name="client_id">
<option value="">Select Client</option>
<?php
$rs = mysql_query('select * from parties where status="active" order by headname ', $dblink) or die(mysql_error());
while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) ){
if($_GET['client_id']==$row[headid]){
$sel="selected";
}else{
$sel="";
}
?>
<option <?php echo $sel?> value="<?php echo $row[headid]?>"><?php echo $row[headname]?><?php //echo $row[ajcomp]?></option>
<?php
}
?>
</select>
<input type="submit" value="Search"/>
</form>
<table>
<thead>
<tr>
<td>Invoice No.</td>
<td>Certificate No.</td>
<td>Date of Issue</td>
<td>Party / Agent</td>
<!-- <td>GST</td> -->
<td>Amount</td>
<td>Print Invoice</td>
</tr>
</thead>
<tbody>
<?php
if($_GET[invno]!=""){
$whr.=" and invid='$_GET[invno]' ";
}
if($_GET[container]!=""){
$whr.=" and container like '%$_GET[container]%' ";
}
if($_GET[invdt]!=""){
$whr.=" and dtd='$_GET[invdt]' ";
}
if($_GET[agent_id]!=""){
$whr.=" and ajtid='$_GET[agent_id]' ";
}
if($_GET[client_id]!=""){
$sqlu1="SELECT * FROM certificates WHERE clnid='$_GET[client_id]' ";
$resultu1=mysql_query($sqlu1) or die(mysql_error().' - error in fetch');
while($cert_row=mysql_fetch_array($resultu1)){
$cert.=" certid='$cert_row[certificateno]' or ";
}
$cert=rtrim($cert,"or ");
$whr.=" and ($cert) and ajtid='' ";
}
$sql="SELECT * From invoices where 1 $whr order by invid DESC";
$result=mysql_query($sql) or die(mysql_error().' - Error in getting Invoices');
if(mysql_num_rows($result) == 0) {
echo "<tr><td colspan='9' align=center colour=black><br>No Result found, try again later.<br></td></tr>";
}
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
$round=round($row['grandtotal']-$row['amount']);
if($row['ajtid']){
$row['clnid']=$row['ajtid'];
}
echo "<tr><td><b>{$row['invid']}</b></td> ";
?>
<td>
<?php
$whr="";
$arr=explode(",",$row[certid]);
foreach($arr as $k=>$v){
$whr.=" certificateno='$v' or ";
}
$whr=substr($whr,0,-3);
$sqlu1="SELECT * FROM certificates WHERE $whr";
$resultu1=mysql_query($sqlu1) or die(mysql_error().' - error in fetch');
$party=$certno="";
while($cert_row=mysql_fetch_array($resultu1)){
$certid.=$cert_row[certificateno].",";
if($cert_row['certypo']=="a"){
$ctype="AQIS";
}elseif($cert_row['certypo']=="b"){
$ctype="AUS";
}elseif($cert_row['certypo']=="c"){
$ctype="PPQ";
}elseif($cert_row['certypo']=="d"){
$ctype="AUS-BK";
}elseif($cert_row['certypo']=="e"){
$ctype="PPQ-BK";
}elseif($cert_row['certypo']=="f"){
$ctype="NSPM";
}elseif($cert_row['certypo']=="g"){
$ctype="NSPM-BK";
}
$certno.=$ctype."/".$cert_row[certno]." | ";
$party.=$cert_row[nameaddress]." | ";
//$party=$parr[0].",".$parr[1].",".$parr[2]." ".$parr[3]." ".$parr[4]." ".$parr[3];
}
$certno=substr($certno,0,-3);
echo $certno;
?>
</td>
<?php
echo "<td>".date("d-m-Y",strtotime($row['dtd']))."</td>
";
?>
<td>
<?php
if($row[ajtid]){
$qc="select * from agents where ajid='$row[ajtid]' ";
$rsp = mysql_query($qc) or die(mysql_erorr());
if( $rp = mysql_fetch_array($rsp, MYSQL_ASSOC) ){
echo "[A] <b>$rp[ajcomp]</b> $rp[headaddresszzzzz]";
}
}else{
$whr="";
$arr=explode(",",$row[certid]);
foreach($arr as $k=>$v){
$whr.=" certificateno='$v' or ";
}
$whr=substr($whr,0,-3);
$sqlu1="SELECT * FROM certificates WHERE $whr";
$resultu1=mysql_query($sqlu1) or die(mysql_error().' - error in fetch');
$party="";
while($cert_row=mysql_fetch_array($resultu1)){
$certid.=$cert_row[certificateno].",";
if($cert_row['certypo']=="a"){
$ctype="AQIS";
}elseif($cert_row['certypo']=="b"){
$ctype="AUS";
}elseif($cert_row['certypo']=="c"){
$ctype="PPQ";
}
$certno.=$ctype."/".$cert_row[certno]." | ";
$party.=$cert_row[nameaddress]." | ";
//$party=$parr[0].",".$parr[1].",".$parr[2]." ".$parr[3]." ".$parr[4]." ".$parr[3];
$qc="select headid, headname, headaddress from parties where headid='$party' ";
$rsp = mysql_query($qc) or die(mysql_erorr());
if( $rp = mysql_fetch_array($rsp, MYSQL_ASSOC) ){
echo "<b>$rp[headname]</b><br>$rp[headaddresszzzzz]";
}
}
}
?>
</td>
<?php
echo "<!-- <td>{$row['servicetax']}</td> -->
<td>{$row['amount']}</td>
<td><a target='_blank' href=./print/invoice_print.php?id={$row['invid']}>Print Invoice</a> </td>
<td><a href='create_invoice.php?invid={$row['invid']}'><img src='img/page_edit.png'></a></td>
</tr>
";
}
?>
</tbody>
</table>
</div>
<?php
include "templatic/footer.php";
?>


PK 99