2 include_once($path_to_root."/includes/ui/ui_input.inc");
4 function update_extra_order_details() {
5 if(!isset($_POST['Update']) || $_POST['Update'] != 'Update') return;
8 // update in database all field
9 foreach($_POST['detail'] as $detail_id => $values) {
11 if($comment = $values['comment']) array_push($set, " comment='$comment' ");
12 if(isset($values['required_date'])) {
13 $required_date = trim($values['required_date']);
14 if($required_date == "") {
15 array_push($set," required_date = NULL");
17 $date = date2sql($required_date);
18 array_push($set," required_date='$date' ");
23 $sql = "UPDATE ".TB_PREF."sales_order_details SET ".implode($set,', ')." WHERE id = $detail_id ";
26 display_error('Problem while updating order details. Try again');
34 display_notification('Order details updated');
38 function compute_input_name($row, $field) {
40 return "detail[$row_id][$field]";
43 function view_link($dummy, $order_no)
45 return get_customer_trans_view_str(ST_SALESORDER, $order_no);
49 function order_link($row)
51 return pager_link( _("Sales Order"),
52 "/sales/sales_order_entry.php?NewQuoteToSalesOrder=" .$row['order_no'], ICON_DOC);
55 function customer_link($row) {
56 return pager_link(_($row['debtor_ref']), "/modules/order_line_extra/order_lines_view.php?customer_id=${row['debtor_no']}");
60 function aggregate_comment($row) {
61 $comment = $row['order_comment'].$row['detail_comment'];
63 $comments = array_map('trim', explode(';', $comment));
64 $comments = array_filter($comments);
65 $first = array_shift($comments);
66 if(count($comments) == 0)
69 $tooltip = implode('<br>', $comments);
70 return "$first <span class='before-tooltip'>more</span><span class='tooltip'> $tooltip</span>";
76 function input_date_details($row, $date) {
78 $name = compute_input_name($row, 'required_date');
80 $_POST[$name] = sql2date($date);
83 date_cells (null, $name, 'title', null, 0,0,1001);
84 return end_extract_cell();
88 <input type='text' value='$date' name='$name'>
92 function input_comment_details($row, $comment) {
95 <input type='text' value='$comment' name='detail[$row_id][comment]'>
99 function get_order_details_extra($customer_id) {
100 $sql = "SELECT sod.id
103 , quantity - qty_sent
106 FROM ".TB_PREF."sales_order_details sod
107 JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no
108 AND so.trans_type = sod.trans_type
109 AND so.trans_type = ".ST_SALESORDER."
110 AND so.debtor_no = $customer_id
112 WHERE quantity > qty_sent
118 function get_order_summary() {
119 $sql = "SELECT debtor_no, debtor_ref, branch_ref
121 , sum(quantity - qty_sent) as quantity
122 , sum((quantity - qty_sent)*unit_price*(1-discount_percent/100)) as amount
124 , group_concat(distinct comments separator ';') as order_comment
125 , group_concat(distinct comment separator ';') as detail_comment
126 FROM ".TB_PREF."sales_order_details sod
127 JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no
128 AND so.trans_type = sod.trans_type
129 AND so.trans_type = ".ST_SALESORDER."
131 NATURAL JOIN ".TB_PREF."debtors_master
132 NATURAL JOIN ".TB_PREF."cust_branch
133 WHERE quantity > qty_sent AND ".ST_SALESORDER."
134 GROUP BY debtor_no, branch_code