
PK 
<?php
include "conn.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]'";
mysqli_query($conn, $sql) or die(mysqli_error($conn));
$sql="UPDATE invoices set cancel='$_GET[sts]' where certid='$_GET[id]'";
mysqli_query($conn, $sql) or die(mysqli_error($conn));
}
?>
<div class="dataGrid">
<h2><?php echo($_GET['typ']=="sub"?"Sub":"")?> Certificates</h2>
<form method="get" action="">
<input type="hidden" name="typ" value="<?php echo $_GET['typ']?>" />
Search:
<select name="type">
<option value="">Type</option>
<option value="a" <?php echo ($_GET['type']=="a"?"selected":"")?>>NSPM</option>
<option value="b" <?php echo ($_GET['type']=="b"?"selected":"")?>>AUS</option>
<option value="c" <?php echo ($_GET['type']=="c"?"selected":"")?>>ALP</option>
<option value="d" <?php echo ($_GET['type']=="d"?"selected":"")?>>NSPM-AMB</option>
<option value="e" <?php echo ($_GET['type']=="e"?"selected":"")?>>ALP-AMB</option>
<option value="f" <?php echo ($_GET['type']=="f"?"selected":"")?>>AUS-AMB</option>
</select>
<input type="text" name="certno" value="<?php echo $_GET['certno']?>" placeholder="Certificate No"/>
<input type="text" name="container" value="<?php echo $_GET['container']?>" placeholder="Container No"/>
<select style="width:250px;" name="clntid">
<option value="">All Exporters</option>
<?php
$rs = mysqli_query($conn,'SELECT headid, headname, headaddress from parties where status="active" && headname like "'. mysqli_real_escape_string($conn,$_REQUEST['term']) .'%" order by headname ');
$data = array();
if ( $rs && mysqli_num_rows($rs) ){
while( $row = mysqli_fetch_array($rs, MYSQLI_ASSOC) ){
$headid = strip_tags($row['headid']);
$headname = strip_tags($row['headname']);
$headaddress = $row['headaddress'];
if($_GET['clntid']==$headid){
$sel="selected";
}else{
$sel="";
}
?>
<option <?php echo $sel?> value="<?php echo $headid?>"><?php echo $headname?> <?php echo $headaddress?></option>
<?php
}
}
?>
</select>
<input type="submit" value="Search"/>
</form>
<table>
<thead>
<tr>
<th>#</th>
<th>Date of Issue</th>
<th>Certificate Type</th>
<th>Department of Goods</th>
<th>Quantity Declared</th>
<th style="width:20px;">Name of Country</th>
<th>Place of Fumigant</th>
<th>Party</th>
<th> </th>
</tr>
</thead>
<tbody>
<?php
//$whr=1;
if($_GET['typ']=="bk"){
$whr.=" and (certypo='d' or certypo='e' or certypo='f') ";
}else{
if($_GET['type']!=""){
$whr.=" and certypo='$_GET[type]' ";
}else{
$whr.=" and (certypo='a' or certypo='b' or certypo='c' or certypo='g') ";
}
}
if($_GET['certno']!=""){
$whr.=" and certno='$_GET[certno]' ";
}
if($_GET['container']!=""){
$whr.=" and conslinkno='$_GET[container]' ";
}
if($_GET['clntid']!=""){
$whr.=" and nameaddress='$_GET[clntid]' ";
}
if($_GET['typ']=="sub"){
$sql="SELECT * from certificates where parent_cert!='' order by certno DESC ";
}else{
$sql="SELECT * from certificates where parent_cert=0 $whr order by certno DESC ";
}
//echo "$sql <br>";
$result=mysqli_query($conn,$sql) or die(mysqli_error($conn).' - Error in getting Certificates');
$totl_rows=mysqli_num_rows($result);
if($totl_rows == 0) {
echo "<tr><td colspan='9' align=center colour=black><br>No Result found in Certificates, try again later.<br></td></tr>";
}
$cnt=$totl_rows+1;
while($row=mysqli_fetch_array($result)){
$cnt--;
if($row['cancel']){
$sts=0;
$can="Active";
}else{
$sts=1;
$can="Cancel";
}
if($row['certypo']=="a"){
$ctype="NSPM";
}elseif($row['certypo']=="b"){
$ctype="AUS";
}elseif($row['certypo']=="c"){
$ctype="ALP";
}elseif($row['certypo']=="d"){
$ctype="NSPM-AMB";
}elseif($row['certypo']=="e"){
$ctype="ALP-AMB";
}elseif($row['certypo']=="f"){
$ctype="AUS-AMB";
}elseif($row['certypo']=="g"){
$ctype="PPQ";
}
if($_GET[typ]=="sub"){
$certificateno=getColumn("certificates","certificateno", $row['parent_cert'],"certno");
}else{
$certificateno=$row['certno'];
}
if($row['sub_certno']==1){
$sub_certno="/A";
}elseif($row['sub_certno']==2){
$sub_certno="/B";
}elseif($row['sub_certno']==3){
$sub_certno="/C";
}elseif($row['sub_certno']==4){
$sub_certno="/D";
}elseif($row['sub_certno']==5){
$sub_certno="/E";
}elseif($row['sub_certno']==6){
$sub_certno="/F";
}elseif($row['sub_certno']==7){
$sub_certno="/G";
}elseif($row['sub_certno']==8){
$sub_certno="/H";
}
echo "
<tr>
<td nowrap><b>{$cnt}</b></td>
<td>".date("d-m-Y", strtotime($row['issuedate']))."</td>
<td>{$ctype}-{$certificateno}{$sub_certno}</td>
<td>{$row['desgood']}</td>
<td>{$row['quantitydeclared']}</td>
<td>{$row['countrydes']}</td>
<td>{$row['placefumigantion']}</td>
";
?>
<td>
<?php
$qc="select headid, headname, headaddress from parties where headid='$row[nameaddress]' ";
$rsp = mysqli_query($conn,$qc) or die(mysql_erorr());
if( $rp = mysqli_fetch_array($rsp, MYSQLI_ASSOC) ){
echo "<b>$rp[headname]</b><br>$rp[headaddresszzzzz]";
}
?>
</td>
<td nowrap>
<a title='Edit' href="certificate-form.php?cert_id=<?php echo $row['certificateno']?>"><img src='./img/edit.png' alt='Edit' /></a>
<a target='_blank' href="./print/form_print.php?id=<?php echo $row['certificateno']?>"><img src='./img/printer.png' alt='Print' /></a>
</td>
<td><a target='_blank' href="./print/cretid_report.php?id=<?php echo $row['certificateno']?>">Print Report</a></td>
<td>
<a href="certificates.php?id=<?php echo $row['certificateno'];?>&sts=<?php echo $sts;?>"><?php echo $can;?></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php
include "templatic/footer.php";
?>


PK 99