5 include($path_to_root . "/includes/db_pager.inc");
6 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/includes/date_functions.inc");
9 include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
11 if ($use_popup_windows)
12 $js .= get_js_open_window(800, 500);
13 if (isset($_GET['outstanding_only']) && ($_GET['outstanding_only'] == true))
15 // curently outstanding simply means not closed
16 $outstanding_only = 1;
17 page(_("Search Outstanding Work Orders"), false, false, "", $js);
21 $outstanding_only = 0;
22 page(_("Search Work Orders"), false, false, "", $js);
24 //-----------------------------------------------------------------------------------
27 if (get_post('SearchOrders'))
29 $Ajax->activate('orders_tbl');
30 } elseif (get_post('_OrderNumber_changed'))
32 $disable = get_post('OrderNumber') !== '';
34 $Ajax->addDisable(true, 'StockLocation', $disable);
35 $Ajax->addDisable(true, 'OverdueOnly', $disable);
36 $Ajax->addDisable(true, 'OpenOnly', $disable);
37 $Ajax->addDisable(true, 'SelectedStockItem', $disable);
40 set_focus('OrderNumber');
42 set_focus('StockLocation');
44 $Ajax->activate('orders_tbl');
47 //--------------------------------------------------------------------------------------
49 if (isset($_GET["stock_id"]))
50 $_POST['SelectedStockItem'] = $_GET["stock_id"];
52 //--------------------------------------------------------------------------------------
54 start_form(false, false, $_SERVER['PHP_SELF'] ."?outstanding_only=" . $outstanding_only .SID);
56 start_table("class='tablestyle_noborder'");
58 ref_cells(_("Reference:"), 'OrderNumber', '',null, '', true);
60 locations_list_cells(_("at Location:"), 'StockLocation', null, true);
62 check_cells( _("Only Overdue:"), 'OverdueOnly', null);
64 if ($outstanding_only==0)
65 check_cells( _("Only Open:"), 'OpenOnly', null);
67 stock_manufactured_items_list_cells(_("for item:"), 'SelectedStockItem', null, true);
69 submit_cells('SearchOrders', _("Search"),'',_('Select documents'), true);
75 //-----------------------------------------------------------------------------
76 function check_overdue($row)
78 return (!$row["closed"]
79 && date_diff(Today(), sql2date($row["required_by"]), "d") > 0);
82 function view_link($dummy, $order_no)
84 return get_trans_view_str(systypes::work_order(), $order_no);
87 function view_stock($row)
89 return view_stock_status($row["stock_id"], $row["description"], false);
92 function wo_type_name($dummy, $type)
94 return wo_types::name($type);
97 function edit_link($row)
99 return $row['closed'] ? '<i>'._('Closed').'</i>' :
100 pager_link(_("Edit"),
101 "/manufacturing/work_order_entry.php?trans_no=" . $row["id"]);
104 function release_link($row)
106 return $row["closed"] ? '' :
107 ($row["released"]==0 ?
108 pager_link(_('Release'),
109 "/manufacturing/work_order_release.php?trans_no=" . $row["id"])
111 pager_link(_('Issue'),
112 "/manufacturing/work_order_issue.php?trans_no=" .$row["id"]));
115 function produce_link($row)
117 return $row["closed"] || !$row["released"] ? '' :
118 pager_link(_('Produce'),
119 "/manufacturing/work_order_add_finished.php?trans_no=" .$row["id"]);
122 function costs_link($row)
124 return $row["closed"] || !$row["released"] ? '' :
125 pager_link(_('Costs'),
126 "/gl/gl_bank.php?NewPayment=1&PayType="
127 .payment_person_types::WorkOrder(). "&PayPerson=" .$row["id"]);
130 function dec_amount($row, $amount)
132 return number_format2($amount, $row['decimals']);
139 location.location_name,
141 workorder.units_reqd,
142 workorder.units_issued,
144 workorder.required_by,
145 workorder.released_date,
150 FROM ".TB_PREF."workorders as workorder,"
151 .TB_PREF."stock_master as item,"
152 .TB_PREF."item_units as unit,"
153 .TB_PREF."locations as location
154 WHERE workorder.stock_id=item.stock_id
155 AND workorder.loc_code=location.loc_code
156 AND item.units=unit.abbr";
158 if (check_value('OpenOnly') || $outstanding_only != 0)
160 $sql .= " AND workorder.closed=0";
163 if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != $all_items)
165 $sql .= " AND workorder.loc_code='" . $_POST['StockLocation'] . "' ";
168 if (isset($_POST['OrderNumber']) && $_POST['OrderNumber'] != "")
170 $sql .= " AND workorder.wo_ref LIKE '%". $_POST['OrderNumber'] . "%'";
173 if (isset($_POST['SelectedStockItem']) && $_POST['SelectedStockItem'] != $all_items)
175 $sql .= " AND workorder.stock_id='". $_POST['SelectedStockItem'] . "'";
178 if (check_value('OverdueOnly'))
180 $Today = date2sql(Today());
182 $sql .= " AND workorder.required_by < '$Today' ";
186 _("#") => array('fun'=>'view_link'),
187 _("Reference"), // viewlink 2 ?
188 _("Type") => array('fun'=>'wo_type_name'),
190 _("Item") => array('fun'=>'view_stock'),
191 _("Required") => array('fun'=>'dec_amount', 'align'=>'right'),
192 _("Manufactured") => array('fun'=>'dec_amount', 'align'=>'right'),
194 _("Required By") => array('type'=>'date', 'ord'=>''),
195 array('insert'=>true, 'fun'=> 'edit_link'),
196 array('insert'=>true, 'fun'=> 'release_link'),
197 array('insert'=>true, 'fun'=> 'produce_link'),
198 array('insert'=>true, 'fun'=> 'costs_link')
201 $table =& new_db_pager('orders_tbl', $sql, $cols);
202 $table->set_marker('check_overdue', _("Marked orders are overdue."));
206 display_db_pager($table);