<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
include ('../inc/cartfunctions.php');
$body='';
$foot='';
$s=0;
$totamo=0;
if(isset($_SESSION['axes_reqitem'])){
if(is_array($_SESSION['axes_reqitem'])){
$max=count($_SESSION['axes_reqitem']);
for($i=($max-1);$i>=0;$i=$i-1){
$reqid=$_SESSION['axes_reqitem'][$i]['reqid'];
$headid=preg_replace('/[^0-9]/', '', $reqid);
$type=preg_replace('/[^a-zA-Z]/', '', $reqid);

if($type=='CO'){
    $name=get_fild_data('tbl_contractor',$headid,'name'); 
}elseif($type=='PO'){
     $name=get_fild_data('tbl_item',$headid,'name'); 
}else{
     $name=get_fild_data('tbl_acledger',$headid,'name'); 
}
   
$amount=$_SESSION['axes_reqitem'][$i]['amount'];
$qty=$_SESSION['axes_reqitem'][$i]['qty'];
$mtype=$_SESSION['axes_reqitem'][$i]['mtype'];
if($mtype=='1'){
$etype='Civil Work';    
}elseif($mtype=='2'){
$etype='Power Work';    
}else{
$etype='';    
}    
$s+=1;
$body.='<tr>';
$body.='<td style="text-align:center">'.$s.'</td>';
$body.='<td>'.$name.'</td>';
$body.='<td>'.$etype.'</td>';   
$body.='<td>'.$qty.'</td>'; 
$body.='<th class="text-right">'.number_format($amount,2).'</th>';
$body.='<td style="text-align:center"><a id="'.$i.'" class="remove"><span style="cursor: pointer;" class="fa fa-times"></span></a></td>';    
$body.='</tr>';     
}
$foot.='<tr>';
$foot.='<th colspan="4" class="text-right">TOTAL</th>';
$foot.='<th class="text-right">'.number_format(total_reqvalue(),2).'</th>';    
$foot.='<th colspan="2"></th>';    
$foot.='</tr>';    
}else{
$body.='<tr>';
$body.='<td colspan="6" class="text-center">There are no items in your requisition list!</td>';
$body.='</tr>'; 
} 
}else{
$body.='<tr>';
$body.='<td colspan="6" class="text-center">There are no items in your requisition list!</td>';
$body.='</tr>';
}
            
if(isset($_POST['body'])){
echo $body;
}elseif(isset($_POST['foot'])){
echo $foot;	
}
exit;    
?>    