4 // ----------------------------------------------------------------
8 // Title: Outstanding GRNs Report
9 // ----------------------------------------------------------------
12 include_once($path_to_root . "includes/session.inc");
13 include_once($path_to_root . "includes/date_functions.inc");
14 include_once($path_to_root . "includes/data_checks.inc");
15 include_once($path_to_root . "gl/includes/gl_db.inc");
17 //----------------------------------------------------------------------------------------------------
19 // trial_inquiry_controls();
20 print_outstanding_GRN();
22 function getTransactions($fromsupp)
24 $sql = "SELECT ".TB_PREF."grn_batch.id,
26 ".TB_PREF."grn_batch.supplier_id,
27 ".TB_PREF."suppliers.supp_name,
28 ".TB_PREF."grn_items.item_code,
29 ".TB_PREF."grn_items.description,
35 FROM ".TB_PREF."grn_items,
37 ".TB_PREF."purch_order_details,
39 WHERE ".TB_PREF."grn_batch.supplier_id=".TB_PREF."suppliers.supplier_id
40 AND ".TB_PREF."grn_batch.id = ".TB_PREF."grn_items.grn_batch_id
41 AND ".TB_PREF."grn_items.po_detail_item = ".TB_PREF."purch_order_details.po_detail_item
42 AND qty_recd-quantity_inv <>0 ";
43 if ($fromsupp != reserved_words::get_all_numeric())
44 $sql .= "AND ".TB_PREF."grn_batch.supplier_id ='" . $fromsupp . "' ";
45 $sql .= "ORDER BY ".TB_PREF."grn_batch.supplier_id,
46 ".TB_PREF."grn_batch.id";
48 return db_query($sql, "No transactions were returned");
51 //----------------------------------------------------------------------------------------------------
53 function print_outstanding_GRN()
57 include_once($path_to_root . "reporting/includes/pdf_report.inc");
59 $fromsupp = $_POST['PARAM_0'];
60 $comments = $_POST['PARAM_1'];
62 if ($fromsupp == reserved_words::get_all_numeric())
65 $from = get_supplier_name($fromsupp);
66 $dec = user_price_dec();
68 $cols = array(0, 40, 80, 190, 250, 320, 385, 450, 515);
70 $headers = array(_('GRN'), _('Order'), _('Item') . '/' . _('Description'), _('Qty Recd'), _('qty Inv'), _('Balance'),
71 _('Std Cost'), _('Value'));
73 $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
75 $params = array( 0 => $comments,
76 1 => array('text' => _('Supplier'), 'from' => $from, 'to' => ''));
78 $rep = new FrontReport(_('Outstanding GRNs Report'), "OutstandingGRN.pdf", user_pagesize());
81 $rep->Info($params, $cols, $headers, $aligns);
87 $res = getTransactions($fromsupp);
89 While ($GRNs = db_fetch($res))
91 $dec2 = get_qty_dec($GRNs['item_code']);
92 if ($Supplier != $GRNs['supplier_id'])
97 $rep->TextCol(0, 7, _('Total'));
98 $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec));
99 $rep->Line($rep->row - 2);
103 $rep->TextCol(0, 6, $GRNs['supp_name']);
104 $Supplier = $GRNs['supplier_id'];
107 $rep->TextCol(0, 1, $GRNs['id']);
108 $rep->TextCol(1, 2, $GRNs['order_no']);
109 $rep->TextCol(2, 3, $GRNs['item_code'] . '-' . $GRNs['description']);
110 $rep->TextCol(3, 4, number_format2($GRNs['qty_recd'], $dec2));
111 $rep->TextCol(4, 5, number_format2($GRNs['quantity_inv'], $dec2));
112 $QtyOstg = $GRNs['qty_recd'] - $GRNs['quantity_inv'];
113 $Value = ($GRNs['qty_recd'] - $GRNs['quantity_inv']) * $GRNs['std_cost_unit'];
114 $rep->TextCol(5, 6, number_format2($QtyOstg, $dec2));
115 $rep->TextCol(6, 7, number_format2($GRNs['std_cost_unit'], $dec));
116 $rep->TextCol(7, 8, number_format2($Value, $dec));
118 $SuppTot_Val += $Value;
125 $rep->TextCol(0, 7, _('Total'));
126 $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec));
127 $rep->Line($rep->row - 2);
132 $rep->TextCol(0, 7, _('Grand Total'));
133 $rep->TextCol(7, 8, number_format2($Tot_Val, $dec));
134 $rep->Line($rep->row - 2);