Improved quick entries.
[fa-stable.git] / purchasing / includes / ui / invoice_ui.inc
index 67f63e82e053eb705fd491be63368d2168267d7a..2e2d17cc6d5d48fca0b3cd3ad769c00de8d80920 100644 (file)
@@ -195,7 +195,7 @@ function display_gl_controls(&$supp_trans, $k)
 
 function display_gl_items(&$supp_trans, $mode=0)
 {
-       global $table_style, $path_to_root;
+       global $table_style, $path_to_root, $Ajax;
 
     // if displaying in form, and no items, exit
     if (($mode == 2 || $mode == 3) && count($supp_trans->gl_codes) == 0)
@@ -212,18 +212,25 @@ function display_gl_items(&$supp_trans, $mode=0)
 
        if ($mode == 1)
        {
-               $qes = has_quick_entries(-1, 0);
+               $qes = has_quick_entries(QE_SUPPINV);
                if ($qes !== false)
                {
                        echo "<div style='float:right;'>";
                        echo _("Quick Entry:")."&nbsp;"; 
-                       quick_entries_list('qid', null, 0, 1);
-                       echo "&nbsp;"._("Amount")."&nbsp;";
-                       $amount = input_num('totamount');
+                       quick_entries_list('qid', null, QE_SUPPINV, true);
+                       $qid = get_quick_entry(get_post('qid'));
+                       if (list_updated('qid')) {
+                               unset($_POST['totamount']); // enable default
+                               $Ajax->activate('totamount');
+                       }
+                       echo "&nbsp;".$qid['base_desc'].":"."&nbsp;";
+
+                       $amount = input_num('totamount', $qid['base_amount']);
                        $dec = user_price_dec();
                        echo "<input class='amount' type='text' name='totamount' size='7' maxlength='12' dec='$dec' value='$amount'>&nbsp;";
                        submit('go', _("Go"), true, false, true);
                        echo "</div>";
+
                }       
        }
        display_heading($heading);
@@ -316,7 +323,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 +437,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();