/* Decoded by unphp.net */ session_start(); include("./includes/connection.php"); if(isset($_GET['Sponsor_ID'])){ $Sponsor_ID = $_GET['Sponsor_ID']; }else{ $Sponsor_ID = 0; } if(isset($_GET['Start_Date'])){ $Start_Date = $_GET['Start_Date']; }else{ $Start_Date = ''; } if(isset($_GET['End_Date'])){ $End_Date = $_GET['End_Date']; }else{ $End_Date = ''; } ;echo 'SPECTACLES SALES REPORT '; if($Sponsor_ID == 0){ $select = mysqli_query($conn,"SELECT i.Item_ID, i.Product_Name from tbl_items i, tbl_patient_payments pp, tbl_patient_payment_item_list ppl,tbl_item_list_cache ilc where i.Item_ID = ppl.Item_ID and pp.Patient_Payment_ID = ppl.Patient_Payment_ID and i.Consultation_Type = 'Optical' and ilc.Patient_Payment_ID=pp.Patient_Payment_ID and ilc.Status='dispensed' and pp.Transaction_status <> 'cancelled' and pp.Payment_Date_And_Time between '$Start_Date' and '$End_Date' group by i.Item_ID order by i.Product_Name") or die(mysqli_error($conn)); }else{ $select = mysqli_query($conn,"SELECT i.Item_ID, i.Product_Name from tbl_items i, tbl_patient_payments pp, tbl_patient_payment_item_list ppl,tbl_item_list_cache ilc where i.Item_ID = ppl.Item_ID and pp.Patient_Payment_ID = ppl.Patient_Payment_ID and pp.Sponsor_ID = '$Sponsor_ID' and i.Consultation_Type = 'Optical' and ilc.Patient_Payment_ID=pp.Patient_Payment_ID and ilc.Status='dispensed' and pp.Transaction_status <> 'cancelled' and pp.Payment_Date_And_Time between '$Start_Date' and '$End_Date' group by i.Item_ID order by i.Product_Name") or die(mysqli_error($conn)); } $num = mysqli_num_rows($select); if($num >0){ $temp = 0; $Grand_Total_Quantity_Cash = 0; $Grand_Total_Quantity_Credit = 0; $Grand_Total_Value_Cash = 0; $Grand_Total_Value_Credit = 0; while ($data = mysqli_fetch_array($select)) { $Total_Quantity_Cash = 0; $Total_Quantity_Credit = 0; $Total_Value_Cash = 0; $Total_Value_Credit = 0; $Item_ID = $data['Item_ID']; if($Sponsor_ID == 0){ $select_details = mysqli_query($conn,"select ppl.Price, ppl.Quantity, ppl.Discount, pp.Billing_Type, pp.payment_type from tbl_items i, tbl_patient_payments pp, tbl_patient_payment_item_list ppl where i.Item_ID = ppl.Item_ID and i.Item_ID = '$Item_ID' and pp.Patient_Payment_ID = ppl.Patient_Payment_ID and i.Consultation_Type = 'Optical' and pp.Transaction_status <> 'cancelled' and pp.Payment_Date_And_Time between '$Start_Date' and '$End_Date'") or die(mysqli_error($conn)); }else{ $select_details = mysqli_query($conn,"select ppl.Price, ppl.Quantity, ppl.Discount, pp.Billing_Type, pp.payment_type from tbl_items i, tbl_patient_payments pp, tbl_patient_payment_item_list ppl where i.Item_ID = ppl.Item_ID and i.Item_ID = '$Item_ID' and pp.Patient_Payment_ID = ppl.Patient_Payment_ID and pp.Sponsor_ID = '$Sponsor_ID' and i.Consultation_Type = 'Optical' and pp.Transaction_status <> 'cancelled' and pp.Payment_Date_And_Time between '$Start_Date' and '$End_Date'") or die(mysqli_error($conn)); } $no = mysqli_num_rows($select_details); if($no >0){ while ($row = mysqli_fetch_array($select_details)) { if(strtolower($row['Billing_Type']) == 'outpatient cash'||(strtolower($row['Billing_Type']) == 'inpatient cash'&&strtolower($row['payment_type']) == 'pre')){ $Total_Quantity_Cash += $row['Quantity']; $Total_Value_Cash += (($row['Price'] -$row['Discount']) * $row['Quantity']); $Grand_Total_Quantity_Cash += $row['Quantity']; $Grand_Total_Value_Cash += (($row['Price'] -$row['Discount']) * $row['Quantity']); }else if(strtolower($row['Billing_Type']) == 'outpatient credit'||strtolower($row['Billing_Type']) == 'inpatient credit'||(strtolower($row['Billing_Type']) == 'inpatient cash'&&strtolower($row['payment_type']) == 'post')){ $Total_Quantity_Credit += $row['Quantity']; $Total_Value_Credit += (($row['Price'] -$row['Discount']) * $row['Quantity']); $Grand_Total_Quantity_Credit += $row['Quantity']; $Grand_Total_Value_Credit += (($row['Price'] -$row['Discount']) * $row['Quantity']); } } } ;echo ' '; } ;echo ' '; } ;echo '
SN PARTICULARS CASH QTY CASH VALUE     CREDIT QTY CREDIT VALUE     TOTAL QTY TOTAL VALUE    

';echo ++$temp;;echo ' ';echo $data['Product_Name'];;echo ' ';echo number_format($Total_Quantity_Cash);;echo ' ';echo number_format($Total_Value_Cash);;echo '     ';echo number_format($Total_Quantity_Credit);;echo ' ';echo number_format($Total_Value_Credit);;echo '     ';echo number_format($Total_Quantity_Credit +$Total_Quantity_Cash);;echo ' ';echo number_format($Total_Value_Credit +$Total_Value_Cash);;echo '    

TOTAL ';echo $Grand_Total_Quantity_Cash;;echo ' ';echo number_format($Grand_Total_Value_Cash);;echo '     ';echo $Grand_Total_Quantity_Credit;;echo ' ';echo number_format($Grand_Total_Value_Credit);;echo '     ';echo ($Grand_Total_Quantity_Credit +$Grand_Total_Quantity_Cash);;echo ' ';echo number_format($Grand_Total_Value_Credit +$Grand_Total_Value_Cash);;echo '    



';;