Display picking checkbox but change flag needs to be removed.
authorMaxime Bourget <bmx007@gmail.com>
Thu, 13 Jun 2013 17:59:22 +0000 (18:59 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Thu, 13 Jun 2013 17:59:22 +0000 (18:59 +0100)
includes/order_lines.inc
includes/picking.inc [new file with mode: 0644]
order_lines_view.php

index f0dd3751d156dd1184aece713da67a5278beb520..2acbfacd3fc9137a6cb4b06400f4f271a4516567 100644 (file)
@@ -118,6 +118,8 @@ function bulk_update_order_details() {
        commit_transaction();
 }
 
+
+
 function compute_input_name($row, $field) {
        $row_id = $row['id'];
        return "detail[$row_id][$field]";
@@ -223,14 +225,12 @@ function pick_checkbox($row)
 {
        $id = $row['debtor_no']."_".$row['branch_code'];
        $name = "chgpck" .$id;
-       $value = $row['type'] ? 1:0;
-       //$value = onpick($row['debtor_no'], $row['branch_code']);
+       $value = $row['quantity_to_pick'] > 0 ? 1:0;
 
 // save also in hidden field for testing during 'Update'
-
  return checkbox(null, $name, $value, true,
-       _('Set this order for picking'))
-       . hidden('last['.$id.']', $value, false);
+       _('Pick all possible item for this branch.'))
+       . hidden('pick['.$id.']', $value, false);
 }
 
 function get_order_details_extra($customer_id, $location, $item_like) {
diff --git a/includes/picking.inc b/includes/picking.inc
new file mode 100644 (file)
index 0000000..c92bd01
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+function process_picking_flag() {
+       $id = find_submit('_chgpck', false);
+       if ($id != -1 && isset($_POST['pick'])) {
+               $id = str_replace("_update", "", $id);
+               change_pck_flag($id, isset($_POST['pick'][$id]));
+       }
+}
+
+function change_pck_flag($id, $value=null)
+{
+display_warning("value $value");
+       if($value === null) $value = true;
+display_warning("value $value");
+       global  $Ajax;
+
+       $picker = new Picker();
+
+       // insert or remove pick order form pick table initial_quantity 
+       if(!$value) {
+               $picker->insertAllForBranch($id);
+       }
+       else {
+               $picker->deleteAllForBranch($id);
+       }
+       $Ajax->activate('order_line_view');
+}
+
+
+class Picker {
+       function insertAllForBranch($id) {
+               list($debtor_no, $branch_code) = $this->branchForId($id);
+               display_warning("inserting for $id");
+
+       }
+
+       function deleteAllForBranch($id) {
+               display_warning("inserting for $id");
+               list($debtor_no, $branch_code) = $this->branchForId($id);
+       }
+
+       function branchForId($id) {
+               return explode('_', $id);
+       }
+
+
+
+}
+
+
index 02ffdb22679fa10ba608aaa5debd14d4134ccf3c..f1dd3fb3a73362aedef023aab1fa7f85b630e06d 100644 (file)
@@ -19,6 +19,7 @@ include_once($path_to_root . "/reporting/includes/reporting.inc");
 include_once("includes/order_lines.inc");
 include_once("includes/splitter.inc");
 include_once("includes/bulk_updater.inc");
+include_once("includes/picking.inc");
 
 $page_security = 'SA_ORDERLINEX_EDIT';
 add_access_extensions();
@@ -31,6 +32,8 @@ update_extra_order_details();
 split_order_details();
 bulk_update_order_details();
 
+process_picking_flag();
+
 
 $js = "";
 if ($use_popup_windows)
@@ -41,6 +44,7 @@ page($_SESSION['page_title'], false, false, "", $js);
 
 //---------------------------------------------------------------------------------------------
 
+div_start('order_line_view');
 start_form();
 
 start_table(TABLESTYLE_NOBORDER);
@@ -123,7 +127,7 @@ _("Comments") => array('ord' => '', 'fun' => 'aggregate_comment'),
 _("comment 2 ") =>  'skip',
 _("Q to Pick") => array('ord' => '', 'type' => 'qty'),
 _("A to Pick") => array('ord' => '', 'type' => 'amount'),
-//_("Pick").'<input type="checkbox"/ onClick="toggleAllPick()"' => array('insert'=>true, 'fun'=>'pick_checkbox'),
+_("Pick")=> array('insert'=>true, 'fun'=>'pick_checkbox'),
        );
 }
 
@@ -169,8 +173,9 @@ br(1);
 submit_center_first('Update', _("Update"), '', 'default', false);
 submit_center_last('Cancel', _("Cancel"), '', 'cancel', false);
 
-       end_form();
-       end_page();
+end_form();
+div_end();
+end_page();
 ?>
 <style>
 span.tooltip{ display:none;}