58 lines
2.4 KiB
PHP
58 lines
2.4 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('log_entry.php');
|
|
include('includes/functions.php');
|
|
$indent_id = $_REQUEST['indent_id'];
|
|
$data = array();
|
|
$count=0;
|
|
$rate=array();
|
|
$query = "select e.form_name,d.unit_name,c.indent_subject,c.remarks,c.status as ind_status,c.sor_no,c.program_id, c.indent_ref_no,c.indent_date,b.indent_id,b.indent_qty,a.max_indent_level,a.min_indent_level,a.item_id,a.unit_id,a.make,a.specifications,a.item_name,a.reorder_store_level,a.min_store_level,a.indent_percent_reorderlevel,ifnull(sum(i.stock_qty),0) as item_stock_qty
|
|
from tbl_items a left join indent_items b on a.item_id = b.item_id left join item_stock i on a.item_id = i.item_id
|
|
left join indent_master c on c.indent_id = b.indent_id left join unit_master d on d.unit_id = a.unit_id left join medicine_form e on e.form_id=a.item_form_id where b.indent_id = '" . $indent_id . "' group by a.item_id ";
|
|
error_log("select dipak" . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
while ($row = @mysqli_fetch_assoc($result)) {
|
|
$item_rate=getTableFieldValue('item_rate','item_rate',"item_id",$row['item_id']);
|
|
$item_unit=getTableFieldValue('item_rate','unit',"item_id",$row['item_id']);
|
|
$date=date_create($row['indent_date']);
|
|
$indent_date=date_format($date,'d/m/Y');
|
|
|
|
|
|
|
|
|
|
$indent_ohc_id = getTableFieldValue('indent_master', 'ohc_type_id', 'indent_id', $indent_id);
|
|
$ohc_cc_mails = getTableFieldValue('ohc_type', 'primary_email', 'ohc_type_id', $indent_ohc_id);
|
|
error_log("check mail".$indent_id." - ".$indent_ohc_id." - ".$ohc_cc_mails);
|
|
|
|
|
|
|
|
$yearly_budget = 0;
|
|
$sql_yearly = "SELECT a.total_cost as yearly_budget, b.total_budget FROM participate_csr_program a left join csr_plan b on a.csr_project_id= b.plan_id where a.participate_csr_program_id= '" . $row['program_id'] . "'";
|
|
// echo('$sql_yearly'.$sql_yearly) ;
|
|
$result_yearly = mysqli_query($conn, $sql_yearly);
|
|
// $num_rows = @mysqli_num_rows($result_yearly);
|
|
while ($row_yearly = @mysqli_fetch_array($result_yearly)) {
|
|
|
|
$yearly_budget = $row_yearly['yearly_budget'];
|
|
}
|
|
$row['yearly_budget']=$yearly_budget;
|
|
|
|
|
|
if($item_unit=='' || $item_unit==null){$item_perUnit_rate=0;}
|
|
else{$item_perUnit_rate=round(($item_rate/$item_unit),2);}
|
|
|
|
|
|
$count++;
|
|
array_push($rate,$item_perUnit_rate);
|
|
$row['indent_date']=$indent_date;
|
|
$data[] = $row;
|
|
}
|
|
$data['count']=$count;
|
|
$data['perunitRate']=$rate;
|
|
$data['ohc_cc_mails'] = $ohc_cc_mails;
|
|
|
|
error_log(print_r($data, true));
|
|
echo json_encode($data); |