begin_transaction();
// update in database all field
+ $date_fields = array('hold_until_date', 'required_date', 'expiry_date', 'priority');
foreach($_POST['detail'] as $detail_id => $values) {
$set = array();
if($comment = $values['comment']) array_push($set, " comment='$comment' ");
- if(isset($values['required_date'])) {
- $required_date = trim($values['required_date']);
- if($required_date == "") {
- array_push($set," required_date = NULL");
- } else {
- $date = date2sql($required_date);
- array_push($set," required_date='$date' ");
+ foreach($date_fields as $date_field) {
+ if(isset($values[$date_field])) {
+ $input_date = trim($values[$date_field]);
+ if($input_date == "") {
+ array_push($set," $date_field = NULL");
+ } else {
+ $date = date2sql($input_date);
+ array_push($set," $date_field='$date' ");
+ }
}
}
if(!empty($set)) {
$sql = "UPDATE ".TB_PREF."sales_order_details SET ".implode($set,', ')." WHERE id = $detail_id ";
-
+
if(!db_query($sql)) {
display_error('Problem while updating order details. Try again');
cancel_transaction();
return;
}
}
-
+commit_transaction();
+
}
display_notification('Order details updated');
function item_link($dummy, $stock_id)
{
- return pager_link( _($stock_id),
+ return pager_link( _($stock_id),
"/modules/order_line_extra/item_schedule.php?stock_id=" .$stock_id);
}
function order_link($row)
{
- return pager_link( _("Sales Order"),
+ return pager_link( _("Sales Order"),
"/sales/sales_order_entry.php?NewQuoteToSalesOrder=" .$row['order_no'], ICON_DOC);
}
function customer_link2($name, $id) {
return pager_link(_($name), "/modules/order_line_extra/order_lines_view.php?customer_id=${id}");
-
+
}
function aggregate_comment($row) {
return "<span class='$class'>$available<span>";
}
-function input_date_details($row, $date) {
+function input_date_details($row, $field_name, $date) {
$row_id = $row['id'];
- $name = compute_input_name($row, 'required_date');
+ $name = compute_input_name($row, $field_name);
$_POST[$name] = sql2date($date);
";
}
+function input_priority_date_details($row, $date) {
+ return input_date_details($row, 'priority', $date);
+}
+
+function input_hold_until_date_details($row, $date) {
+ return input_date_details($row, 'hold_until_date', $date);
+}
+
+function input_required_date_details($row, $date) {
+ return input_date_details($row, 'required_date', $date);
+}
+
+function input_expiry_date_details($row, $date) {
+ return input_date_details($row, 'expiry_date', $date);
+}
+
function input_comment_details($row, $comment) {
$row_id = $row['id'];
return "
,_("Quantity") => array('type' => 'qty', 'dec' => 0)
,_("Available") => array('fun' => 'available_quantity', 'dec' => 0, 'ord' => '')
,_("Before") => 'skip'
- ,_("Priority") => array('fun' => 'input_date_details', 'ord' => '')
- ,_("Hold Until") => array('fun' => 'input_date_details', 'ord' => '')
- ,_("Require By") => array('fun' => 'input_date_details', 'ord' => '')
- ,_("Expiry Date") => array('fun' => 'input_date_details', 'ord' => '')
+ ,_("Priority") => array('fun' => 'input_priority_date_details', 'ord' => '')
+ ,_("Hold Until") => array('fun' => 'input_hold_until_date_details', 'ord' => '')
+ ,_("Require By") => array('fun' => 'input_required_date_details', 'ord' => '')
+ ,_("Expiry Date") => array('fun' => 'input_expiry_date_details', 'ord' => '')
,_("Comment") => array('fun' => 'input_comment_details', 'ord' => '')
);
}