Moving 2.0 development version to main trunk.
[fa-stable.git] / purchasing / inquiry / po_search.php
index e460d53e121ef31745ffd4cdb1d0942e5867cf41..b4bac8022719dd13c91c8c3e2247d67a38ff2612 100644 (file)
@@ -5,6 +5,7 @@ $path_to_root="../..";
 include($path_to_root . "/includes/session.inc");
 
 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
+include_once($path_to_root . "/reporting/includes/reporting.inc");
 
 $js = "";
 if ($use_popup_windows)
@@ -17,6 +18,30 @@ if (isset($_GET['order_number']))
 {
        $_POST['order_number'] = $_GET['order_number'];
 }
+//-----------------------------------------------------------------------------------
+// Ajax updates
+//
+if (get_post('SearchOrders')) 
+{
+       $Ajax->activate('orders_tbl');
+} elseif (get_post('_order_number_changed')) 
+{
+       $disable = get_post('order_number') !== '';
+
+       $Ajax->addDisable(true, 'OrdersAfterDate', $disable);
+       $Ajax->addDisable(true, 'OrdersToDate', $disable);
+       $Ajax->addDisable(true, 'StockLocation', $disable);
+       $Ajax->addDisable(true, '_SelectStockFromList_edit', $disable);
+       $Ajax->addDisable(true, 'SelectStockFromList', $disable);
+
+       if ($disable) {
+               $Ajax->addFocus(true, 'order_number');
+       } else
+               $Ajax->addFocus(true, 'OrdersAfterDate');
+
+       $Ajax->activate('orders_tbl');
+}
+
 
 //---------------------------------------------------------------------------------------------
 
@@ -24,16 +49,16 @@ start_form(false, true);
 
 start_table("class='tablestyle_noborder'");
 start_row();
-ref_cells(_("#:"), 'order_number');
+ref_cells(_("#:"), 'order_number', '',null, '', true);
 
-date_cells(_("from:"), 'OrdersAfterDate', null, -30);
+date_cells(_("from:"), 'OrdersAfterDate', '', null, -30);
 date_cells(_("to:"), 'OrdersToDate');
 
 locations_list_cells(_("Location:"), 'StockLocation', null, true);
 
 stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true);
 
-submit_cells('SearchOrders', _("Search"));
+submit_cells('SearchOrders', _("Search"),'',_('Select documents'), true);
 end_row();
 end_table();
 
@@ -50,8 +75,8 @@ if (isset($_POST['SelectStockFromList']) && ($_POST['SelectStockFromList'] != ""
        ($_POST['SelectStockFromList'] != $all_items))
 {
        $selected_stock_item = $_POST['SelectStockFromList'];
-} 
-else 
+}
+else
 {
        unset($selected_stock_item);
 }
@@ -71,11 +96,11 @@ $sql = "SELECT ".TB_PREF."purch_orders.order_no, ".TB_PREF."suppliers.supp_name,
        AND ".TB_PREF."locations.loc_code = ".TB_PREF."purch_orders.into_stock_location
        AND (".TB_PREF."purch_order_details.quantity_ordered > ".TB_PREF."purch_order_details.quantity_received) ";
 
-if (isset($order_number) && $order_number != "") 
+if (isset($order_number) && $order_number != "")
 {
        $sql .= "AND ".TB_PREF."purch_orders.reference LIKE '%". $order_number . "%'";
-} 
-else 
+}
+else
 {
 
        $data_after = date2sql($_POST['OrdersAfterDate']);
@@ -84,12 +109,12 @@ else
        $sql .= "  AND ".TB_PREF."purch_orders.ord_date >= '$data_after'";
        $sql .= "  AND ".TB_PREF."purch_orders.ord_date <= '$data_before'";
 
-       if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != $all_items) 
+       if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != $all_items)
        {
                $sql .= " AND ".TB_PREF."purch_orders.into_stock_location = '". $_POST['StockLocation'] . "' ";
        }
 
-       if (isset($selected_stock_item)) 
+       if (isset($selected_stock_item))
        {
                $sql .= " AND ".TB_PREF."purch_order_details.item_code='". $selected_stock_item ."' ";
        }
@@ -99,31 +124,34 @@ $sql .= " GROUP BY ".TB_PREF."purch_orders.order_no";
 
 $result = db_query($sql,"No orders were returned");
 
+print_hidden_script(18);
+
 /*show a table of the orders returned by the sql */
 
+div_start('orders_tbl');
 start_table("$table_style colspan=7 width=80%");
 
 if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == $all_items)
        $th = array(_("#"), _("Reference"), _("Supplier"), _("Location"),
-               _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"));
-else           
+               _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"),"","","");
+else
        $th = array(_("#"), _("Reference"), _("Supplier"),
-               _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"));
+               _("Supplier's Reference"), _("Order Date"), _("Currency"), _("Order Total"),"","","");
 
 table_header($th);
 
 $j = 1;
 $k = 0; //row colour counter
 $overdue_items = false;
-while ($myrow = db_fetch($result)) 
+while ($myrow = db_fetch($result))
 {
 
        if ($myrow["OverDue"] == 1)
        {
                 start_row("class='overduebg'");
                 $overdue_items = true;
-       } 
-       else 
+       }
+       else
        {
                alt_table_row_color($k);
        }
@@ -143,6 +171,7 @@ while ($myrow = db_fetch($result))
        label_cell($myrow["curr_code"]);
        amount_cell($myrow["OrderValue"]);
        label_cell("<a href=$modify>" . _("Edit") . "</a>");
+       label_cell(print_document_link($myrow['order_no'], _("Print")));
        label_cell("<a href=$receive>" . _("Receive") . "</a>");
        end_row();
 
@@ -160,6 +189,6 @@ end_table();
 
 if ($overdue_items)
        display_note(_("Marked orders have overdue items."), 0, 1, "class='overduefg'");
-
+div_end();
 end_page();
 ?>