Changed supplier credit note to only show items for a period, default 30 days back.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 7 Jan 2009 16:26:12 +0000 (16:26 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 7 Jan 2009 16:26:12 +0000 (16:26 +0000)
CHANGELOG.txt
purchasing/includes/db/grn_db.inc
purchasing/includes/ui/invoice_ui.inc
purchasing/supplier_credit.php

index 66ef3df9ced632b320bc28f34ef4eb4537eb1182..695dd346eaa1422d6f72537b7af30bca7204fcc3 100644 (file)
@@ -19,6 +19,12 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+07-Jan-2009 Joe Hunt
+! Changed supplier credit note to only show items for a period, default 30 days back.
+$ /purchasing/includes/db/grn_db.inc
+  /purchasing/includes/invoice_ui.inc
+  /purchasing/supplier_credit.php
+  
 07-Jan-2009 Janusz Dobrowolski
 # [0000105] Not initialized user pos numbers after upgrade, fixed some new table fields.
 $ /sql/alter2.1.sql
index 10e0d1cff3d2676e864b3878311d4880b8e515a4..0008af168ea94f60179d3d8638558b54c6960a89 100644 (file)
@@ -175,7 +175,7 @@ function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date)
 }
 
 function get_grn_items($grn_batch_id=0, $supplier_id="", $outstanding_only=false,
-       $is_invoiced_only=false, $invoice_no=0)
+       $is_invoiced_only=false, $invoice_no=0, $begin="", $end="")
 {
     $sql = "SELECT ".TB_PREF."grn_batch.*, ".TB_PREF."grn_items.*, ".TB_PREF."purch_order_details.unit_price,
                ".TB_PREF."purch_order_details.std_cost_unit, units
@@ -190,6 +190,10 @@ function get_grn_items($grn_batch_id=0, $supplier_id="", $outstanding_only=false
                        ".TB_PREF."grn_items.id=".TB_PREF."supp_invoice_items.grn_item_id";
        $sql .= " AND ".TB_PREF."stock_master.stock_id=".TB_PREF."grn_items.item_code ";
 
+       if ($begin != "")
+               $sql .= " AND ".TB_PREF."grn_batch.delivery_date>='".date2sql($begin)."'";
+       if ($end != "")
+               $sql .= " AND ".TB_PREF."grn_batch.delivery_date<='".date2sql($end)."'";
        if ($grn_batch_id != 0)
                $sql .= " AND ".TB_PREF."grn_batch.id=$grn_batch_id AND ".TB_PREF."grn_items.grn_batch_id=$grn_batch_id ";
 
index 67f63e82e053eb705fd491be63368d2168267d7a..116dee3c4df33a092ba6a97b64a48227fc339a4d 100644 (file)
@@ -316,7 +316,9 @@ function display_grn_items_for_selection(&$supp_trans, $k)
                $result = get_grn_items(0, $supp_trans->supplier_id, true);
        else
        {
-               if (isset($_POST['invoice_no']))
+               if (isset($_POST['receive_begin']) && isset($_POST['receive_end']))
+                       $result = get_grn_items(0, $supp_trans->supplier_id, false, true, 0, $_POST['receive_begin'], $_POST['receive_end']);
+               else if (isset($_POST['invoice_no']))
                        $result = get_grn_items(0, $supp_trans->supplier_id, false, true, $_POST['invoice_no']);
                else    
                        $result = get_grn_items(0, $supp_trans->supplier_id, false, true);
@@ -428,6 +430,15 @@ function display_grn_items(&$supp_trans, $mode=0)
 
        if ($mode == 1)
        {
+               if (!$supp_trans->is_invoice && !isset($_POST['invoice_no']))
+               {
+                       echo "</td>";
+                       date_cells(_("Received between"), 'receive_begin', "", null, -30);
+                       date_cells(_("and"), 'receive_end', '', null, 1);
+                       submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
+                       echo "<td>";
+               }       
+                       
                if ($heading2 != "")
                {
                        //br();
index e6c83e64fb286f937e239f5db004a72509456369..00a8cd5eaac2e321083c103440dea82a72de4021 100644 (file)
@@ -302,6 +302,11 @@ if ($id4 != -1)
        $Ajax->activate('gl_items');
        $Ajax->activate('inv_tot');
 }
+if (isset($_POST['RefreshInquiry']))
+{
+       $Ajax->activate('grn_items');
+       $Ajax->activate('inv_tot');
+}
 
 if (isset($_POST['go']))
 {