X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Forder_lines.inc;h=54b2a7faec8eb4f309827d4492f7b8afe39f0f35;hb=fbf564796dcf1a6a077bf38ffd5727cfac167694;hp=71eebdd08be05be0d291d6a66417d2dd9414e5b8;hpb=b68aea1f67f561ea3d8873eed49b769a750117ae;p=order_line_extra.git diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 71eebdd..54b2a7f 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -1,5 +1,36 @@ and from a string + * generated by the above *_cell function. + * This is usefull to use the result of the function within a pager + * which already include the ... + * However, for function which doesn't return a string + * but echo, we need to capture the output of the echo first. + */ +function start_extract_cell() { + // We need + ob_start(); +} + +function end_extract_cell() { + $content = ob_get_contents(); + ob_end_clean(); + return extract_cell($content); +} + +function extract_cell($td) { + if(preg_match('/\s*(.*)<\/td>\s*/s', $td, $matches)) { + return $matches[1]; + } + else { +print_r('cacou'); + return $td; + } +} + +?> + + function update_extra_order_details() { if(!isset($_POST['Update']) || $_POST['Update'] != 'Update') return; @@ -45,12 +76,34 @@ function view_link($dummy, $order_no) return get_customer_trans_view_str(ST_SALESORDER, $order_no); } + function order_link($row) { return pager_link( _("Sales Order"), "/sales/sales_order_entry.php?NewQuoteToSalesOrder=" .$row['order_no'], ICON_DOC); } +function customer_link($row) { + return pager_link(_($row['debtor_ref']), "/modules/order_line_extra/order_lines_view.php?customer_id=${row['debtor_no']}"); + +} + +function aggregate_comment($row) { + $comment = $row['order_comment'].$row['detail_comment']; + if($comment) { + $comments = array_map('trim', explode(';', $comment)); + $comments = array_filter($comments); + $first = array_shift($comments); + if(count($comments) == 0) + return $first; + else { + $tooltip = implode('
', $comments); + return "$first more $tooltip"; + } + } + return ''; +} + function input_date_details($row, $date) { $row_id = $row['id']; $name = compute_input_name($row, 'required_date'); @@ -80,10 +133,11 @@ function get_order_details_extra($customer_id) { , stk_code , quantity - qty_sent , required_date - , comment + ,comment FROM ".TB_PREF."sales_order_details sod JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no AND so.trans_type = sod.trans_type + AND so.trans_type = ".ST_SALESORDER." AND so.debtor_no = $customer_id ) WHERE quantity > qty_sent @@ -91,4 +145,26 @@ function get_order_details_extra($customer_id) { return $sql; } + +function get_order_summary() { + $sql = "SELECT debtor_no, debtor_ref, branch_ref + , min(delivery_date) + , sum(quantity - qty_sent) as quantity + , sum((quantity - qty_sent)*unit_price*(1-discount_percent/100)) as amount + , min(required_date) + , group_concat(distinct comments separator ';') as order_comment + , group_concat(distinct comment separator ';') as detail_comment + FROM ".TB_PREF."sales_order_details sod + JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no + AND so.trans_type = sod.trans_type + AND so.trans_type = ".ST_SALESORDER." + ) + NATURAL JOIN ".TB_PREF."debtors_master + NATURAL JOIN ".TB_PREF."cust_branch + WHERE quantity > qty_sent AND ".ST_SALESORDER." + GROUP BY debtor_no, branch_code + "; + + return $sql; +} ?>