46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('log_entry.php');
|
|
if( $_REQUEST['year']==''||$_REQUEST['year']==null)
|
|
{
|
|
$month=date("m");
|
|
|
|
if($month<=3)$year=(date("Y")-1);
|
|
else $year=date("Y");
|
|
}
|
|
else $year=$_REQUEST['year'];
|
|
|
|
|
|
$query = "SELECT a.item_id ,a.indent_qty,c.item_rate,c.unit FROM `indent_items`a LEFT JOIN indent_master b on a.`indent_id`=b.indent_id left join item_rate c on c.item_id=a.item_id where year(b.indent_date)='".$year."' and b.status='APPROVED' and a.indent_qty !=0; ";
|
|
error_log("year: ".$query);
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
$data = array();
|
|
$total=0;
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = @mysqli_fetch_assoc($result)) {
|
|
$net_value= (float)$row['item_rate'];
|
|
// error_log('net_value'.$net_value);
|
|
$qty= (float)$row['unit'];
|
|
// error_log('qty'.$qty);
|
|
$indent_qty= (float)$row['indent_qty'];
|
|
if( $qty!=0){
|
|
$item_price = (float)($net_value/$qty);
|
|
|
|
$total+= (float)($item_price*$indent_qty);
|
|
error_log('indent item :'.$row['item_id'].' unit price :'.$item_price.' current budget req :'.$total);
|
|
}}
|
|
|
|
}
|
|
else
|
|
{
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
|
|
$data['year']=$year;
|
|
$data['total_pending_indent_budget']=round($total,2);
|
|
|
|
echo json_encode($data);
|
|
?>
|