custom query case when sql phprunner

<?php
ini_set("display_errors","0");

set_magic_quotes_runtime(0);

header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");
header("Pragma: no-cache");
header("Cache-Control: no-cache");



include("include/dbcommon.php");
if(!@$_SESSION["UserID"])

{
        header("Location: login.php");
        return;
}
?>


<?php




   $idb = $_REQUEST['idb'];
 
 
   $sql = "

SELECT

(CASE
   WHEN Status IS NULL  > '' THEN 'Not Review'

             WHEN Status = 1 THEN 'Printed'
             WHEN Status = 2 THEN 'Reject'
           
       END) AS Status,
IF(Status IS NULL, 'N/A', Status) AS Status1,
DocNumber
FROM badge
WHERE

 idb='".$idb."'";


$results = CustomQuery($sql);
$data = db_fetch_array($results);
$Status = $data['Status'];
$Idb = $data['Idb'];
$Payment = $data['Payment'];
$Amount = $data['Amount'];
$DocNumber = $data['DocNumber'];
$Name = $data['Person Name'];
$Prof = $data['Profession'];
   $Comp = $data['Comp name'];
$Issue = $data['Issuing Date'];
$Exp = $data['ExpDate'];
$Photo = $data['Photo'];
$PhotoCam = $data['PhotoCam'];

//$newViews =  $data['views']+1;
// CustomQuery("update url_redirects set views = ".$newViews." where short='".$short."'");

// echo file_get_contents($url);
 // CustomQuery("update url_redirects set views = ".$newViews." where short='".$short."'");



  ///  if(!empty($data)) {
  //    header("Location: ".$data['url']."");
  //  } else {
 //    $html = "Error: cannot find short URL";
  //  }
 
?>







  <style id="compiled-css" type="text/css">
      .A4 {
  background: white;
  width: 21cm;
  height: 29.7cm;
  display: block;
  margin: 0 auto;
  padding: 15px 5px;
  margin-bottom: 0.5cm;
  box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5);
  overflow-y: initial;
  box-sizing: border-box;
  font-size: 12pt;
}

@media print {
  .page-break {
    display: block;
    page-break-before: always;
  }
  size: A4 portrait;
}

@media print {
  body {
    margin: 0;
    padding: 0;
  }
  .A4 {
    box-shadow: none;
    margin: 0;
    width: auto;
    height: auto;
  }
  .noprint {
    display: none;
  }
  .enable-print {
    display: block;
  }
}

  .style1 {font-weight: bold}
.style2 {font-weight: bold}
  .style3 {
font-weight: bold;
color: #FF0000;
}
  .style4 {
color: #3366CC;
font-weight: bold;
}
  </style>















    <div class="A4">



<style type="text/css">
<!--
.style1 {color: #999999}
.style2 {color: #FF0000}
.style3 {color: #666666; }
.style5 {color: #FF0000; font-weight: bold; }
.style9 {
font-size: x-large;
color: #000099;
font-style: italic;
}
-->
</style>



  <table width="720" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th width="284" scope="col"><div align="left"><span class="style5">Sharjah Cooperative Society</span> </div></th>
    <th width="444" rowspan="5" scope="col">&nbsp;</th>
    <th width="108" rowspan="5" scope="col"><img src="images/logo.png" /></th>
  </tr>
  <tr>
    <th scope="col"><div align="left"><span class="style3">Ministry Approval No 16/1977 </span></div></th>
    </tr>
  <tr>
    <th scope="col"><div align="left"><span class="style3">Tel : +97165164555 </span></div></th>
    </tr>
  <tr>
    <th scope="col"><div align="left"><span class="style3">Fax : +97165164500 </span></div></th>
    </tr>
  <tr>
    <th scope="col"><div align="left"><span class="style3">P.O.Box :5435 Sharjah, UAE </span></div></th>
    </tr>
</table>


<h1 align="center" class="style3">Receiving Form</h1>
<center><svg height="10" width="720">
  <line x1="0" y1="0" x2="720" y2="000" style="stroke:rgb(164, 155, 155);stroke-width:5" />
  Sorry, your browser does not support inline SVG.
</svg></center>
<table width="720" border="0" align="center" cellspacing="0">
  <tr>
    <th width="24%" height="85" scope="col"><div align="left">
      <h3 class="style1 style2">COMPANY NAME: </h3>
    </div></th>
    <th width="47%" scope="col"><h3 align="left"><div align="left"><?php echo $Comp;?>
      </h3>    </th>
    <th width="29%" scope="col">&nbsp;</th>
  </tr>
</table>

<table width="720" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#666666">
  <tr>
    <th width="10%" bgcolor="#CCCCCC" scope="col">RefNo</th>
    <th width="16%" bgcolor="#CCCCCC" scope="col">Type Of Badge</th>
    <th width="28%" bgcolor="#CCCCCC" scope="col">Name</th>
    <th width="14%" bgcolor="#CCCCCC" scope="col">Issuing Date </th>
    <th width="14%" bgcolor="#CCCCCC" scope="col">Expiry Date </th>
    <th width="18%" bgcolor="#CCCCCC" scope="col">Photo</th>
  </tr>
  <tr>
    <td><div align="center" class="style3"><?php echo $Idb;?></div></td>
    <td><div align="center"><?php echo $Prof;?></div></td>
    <td><div align="center"><?php echo $Name;?></div></td>
    <td><div align="center"><?php echo $Issue = date("d-m-Y", strtotime($Issue));?></div></td>
    <td><div align="center"><?php echo $Issue = date("d-m-Y", strtotime($Exp));?></div></td>
    <td> 
  <div align="center">
    <?php if($data['Photo'] != ""): ?>
    <img src="https://example.com/<?php $test = json_decode($Photo, true);  echo $test[0]["name"]; ?>" width="80" height="93" style="left:0px;margin-left: -0px;margin-top: 0px;border: 1px solid transparent;padding: 0px;border-color: black;border-radius: 1px;">
    <?php endif; ?>
      </div></td>
  </tr>
</table>




<table width="720" border="0" align="center" cellpadding="5" cellspacing="0" bordercolor="#666666">
 
  <tr>
    <th height="71" colspan="4" scope="col">&nbsp;</th>
    </tr>
  <tr>
    <th width="154" scope="col"><div align="left"><span class="style5"><strong>Type Of Payment</strong></span><strong> :</strong></div></th>
    <th width="210" scope="col"><div align="left"><strong><?php echo $Payment;?></strong></div></th>
    <th width="217" scope="col"><div align="right"><span class="style5">Amount:</span></div></th>
    <th width="99" scope="col"><div align="left"><strong>AED <?php echo $Amount;?></strong></div></th>
  </tr>
  <tr>
    <td><div align="left"><strong><span class="style5">Document Number :</span></strong></div></td>
    <td><div align="left"><strong><?php echo $DocNumber;?></strong></div></td>
    <td><div align="right"><span class="style5">Status:</span></div></td>
    <td><div align="left" class="style4"><?php echo $Status;?></div></td>
  </tr>
</table>

<center><svg height="10" width="720">
  <line x1="0" y1="0" x2="720" y2="000" style="stroke:rgb(164, 155, 155);stroke-width:5" />
  Sorry, your browser does not support inline SVG.
</svg></center>
<table width="720" height="172" align="center" cellpadding="5" cellspacing="2">
  <tr>
    <th width="763" height="166" scope="col"><div align="left"><span class="style9">The Undersigned hereby acknowledges:
     
    The Receipt of the Merchandiser & Sales Badges listed above</span></div></th>
  </tr>
</table>

<p>&nbsp;</p>
<table width="720" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#999999">
  <tr>
    <th width="88" scope="col"><div align="left">Name:</div></th>
    <th width="659" scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td><strong>Mobile No: </strong></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="63"><strong>Signature:</strong></td>
    <td>&nbsp;</td>
  </tr>
</table>

  <!-- TODO: Missing CoffeeScript 2 -->

  <script type="text/javascript">//<![CDATA[

    window.onload=function(){
     
var max_pages = 100;
var page_count = 0;

function snipMe() {
  page_count++;
  if (page_count > max_pages) {
    return;
  }
  var long = $(this)[0].scrollHeight - Math.ceil($(this).innerHeight());
  var children = $(this).children().toArray();
  var removed = [];
  while (long > 0 && children.length > 0) {
    var child = children.pop();
    $(child).detach();
    removed.unshift(child);
    long = $(this)[0].scrollHeight - Math.ceil($(this).innerHeight());
  }
  if (removed.length > 0) {
    var a4 = $('<div class="A4"></div>');
    a4.append(removed);
    $(this).after(a4);
    snipMe.call(a4[0]);
  }
}

$(document).ready(function() {
  $('.A4').each(function() {
    snipMe.call(this);
  });
});


    }

  //]]></script>
</div>

Comments