From 70d9e30ad313226497c8cb88ad295de681510476 Mon Sep 17 00:00:00 2001 From: Rod Roark Date: Mon, 1 Nov 2010 16:28:01 -0700 Subject: [PATCH] Added Inventory Transactions report. --- interface/main/left_nav.php | 1 + interface/reports/inventory_transactions.php | 417 +++++++++++++++++++++++++++ 2 files changed, 418 insertions(+) create mode 100644 interface/reports/inventory_transactions.php diff --git a/interface/main/left_nav.php b/interface/main/left_nav.php index eac5b78e2..455201d17 100644 --- a/interface/main/left_nav.php +++ b/interface/main/left_nav.php @@ -1040,6 +1040,7 @@ if (!empty($reg)) { diff --git a/interface/reports/inventory_transactions.php b/interface/reports/inventory_transactions.php new file mode 100644 index 000000000..cbe4709d9 --- /dev/null +++ b/interface/reports/inventory_transactions.php @@ -0,0 +1,417 @@ + +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This is an inventory transactions list. + +require_once("../globals.php"); +require_once("$srcdir/patient.inc"); +require_once("$srcdir/acl.inc"); +require_once("$srcdir/formatting.inc.php"); +require_once("$srcdir/formdata.inc.php"); + +function bucks($amount) { + if ($amount != 0) return oeFormatMoney($amount); + return ''; +} + +function esc4Export($str) { + return str_replace('"', '\\"', $str); +} + +function thisLineItem($row, $xfer=false) { + global $grandtotal, $grandqty, $encount; + + $invnumber = ''; + $dpname = ''; + + if (!empty($row['pid'])) { + $ttype = xl('Sale'); + $dpname = $row['plname']; + if (!empty($row['pfname'])) { + $dpname .= ', ' . $row['pfname']; + if (!empty($row['pmname'])) $dpname .= ' ' . $row['pmname']; + } + $invnumber = empty($row['invoice_refno']) ? + "{$row['pid']}.{$row['encounter']}" : $row['invoice_refno']; + } + else if (!empty($row['distributor_id'])) { + $ttype = xl('Distribution'); + if (!empty($row['organization'])) { + $dpname = $row['organization']; + } + else { + $dpname = $row['dlname']; + if (!empty($row['dfname'])) { + $dpname .= ', ' . $row['dfname']; + if (!empty($row['dmname'])) $dpname .= ' ' . $row['dmname']; + } + } + } + else if (!empty($row['xfer_inventory_id']) || $xfer) { + $ttype = xl('Transfer'); + } + else if ($row['fee'] != 0) { + $ttype = xl('Purchase'); + } + else { + $ttype = xl('Adjustment'); + } + + if ($_POST['form_csvexport']) { + echo '"' . oeFormatShortDate($row['sale_date']) . '",'; + echo '"' . $ttype . '",'; + echo '"' . esc4Export($row['name']) . '",'; + echo '"' . esc4Export($row['lot_number']) . '",'; + echo '"' . esc4Export($row['warehouse']) . '",'; + echo '"' . esc4Export($dpname) . '",'; + echo '"' . (0 - $row['quantity']) . '",'; + echo '"' . bucks($row['fee']) . '",'; + echo '"' . $row['billed'] . '",'; + echo '"' . esc4Export($row['notes']) . '"' . "\n"; + } + else { + $bgcolor = (++$encount & 1) ? "#ddddff" : "#ffdddd"; +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<?php xl('Inventory Transactions','e') ?> + + + + + + + + + + + + + + +
+ +

+ +
+ +
+ + + + + + + +
+ + + + + + + + + +
+ : + + + + : + + + [?]'> + + : + + + [?]'> +
+
+ + + + +
+ + + + + + + + + + + +
+
+
+ + + +
+ + + + + + + + + + + + + += '$from_date' AND s.sale_date <= '$to_date' "; + if ($form_trans_type == 2) { // purchase/return + $query .= "AND s.pid = 0 AND s.distributor_id = 0 AND s.xfer_inventory_id = 0 AND s.fee != 0 "; + } + else if ($form_trans_type == 4) { // transfer + $query .= "AND s.xfer_inventory_id != 0 "; + } + else if ($form_trans_type == 5) { // adjustment + $query .= "AND s.pid = 0 AND s.distributor_id = 0 AND s.xfer_inventory_id = 0 AND s.fee = 0 "; + } + else if ($form_trans_type == 6) { // distribution + $query .= "AND s.distributor_id != 0 "; + } + else if ($form_trans_type == 1) { // sale + $query .= "AND s.pid != 0 "; + } + $query .= "ORDER BY s.sale_date, s.sale_id"; + // + $res = sqlStatement($query); + while ($row = sqlFetchArray($res)) { + thisLineItem($row); + } + + if ($form_action != 'export') { +?> + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + + +
+
+ + + + + + + -- 2.11.4.GIT