Added two new helpers date_comp, sql_date_comp.
[fa-stable.git] / manufacturing / work_order_entry.php
index 5c27369bbe1846796f821b36cddaed9930a8af88..a1280391c4b4438d1f2a8d139a76a3272137faed 100644 (file)
@@ -275,7 +275,8 @@ if (isset($_POST['UPDATE_ITEM']) && can_process())
 {
 
        update_work_order($selected_id, $_POST['StockLocation'], input_num('quantity'),
-               $_POST['stock_id'],  $_POST['date_'], $_POST['RequDate'], $_POST['memo_']);
+               $_POST['stock_id'],  $_POST['date_'], $_POST['RequDate'], $_POST['memo_'],
+               $_POST['old_stk_id'], $_POST['old_qty']);
        new_doc_date($_POST['date_']);
        meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$selected_id");
 }
@@ -301,7 +302,7 @@ if (isset($_POST['delete']))
        { //ie not cancelled the delete as a result of above tests
 
                // delete the actual work order
-               delete_work_order($selected_id);
+               delete_work_order($selected_id, $_POST['stock_id'], $_POST['quantity'], $_POST['date_']);
                meta_forward($_SERVER['PHP_SELF'], "DeletedID=$selected_id");
        }
 }
@@ -423,24 +424,23 @@ else
     date_row(_("Date") . ":", 'date_', '', true);
        hidden('RequDate', '');
 
-       $sql = "SELECT DISTINCT account_code FROM ".TB_PREF."bank_accounts";
-       $rs = db_query($sql,"could not get bank accounts");
-       $r = db_fetch_row($rs);
+       $bank_act = get_default_bank_account();
        if (!isset($_POST['Labour']))
        {
                $_POST['Labour'] = price_format(0);
-               $_POST['cr_lab_acc'] = $r[0];
+               $_POST['cr_lab_acc'] = $bank_act['account_code'];
        }
+
        amount_row($wo_cost_types[WO_LABOUR], 'Labour');
        gl_all_accounts_list_row(_("Credit Labour Account"), 'cr_lab_acc', null);
        if (!isset($_POST['Costs']))
        {
                $_POST['Costs'] = price_format(0);
-               $_POST['cr_acc'] = $r[0];
+               $_POST['cr_acc'] = $bank_act['account_code'];
        }
        amount_row($wo_cost_types[WO_OVERHEAD], 'Costs');
        gl_all_accounts_list_row(_("Credit Overhead Account"), 'cr_acc', null);
-       
+
 }
 
 if (get_post('released'))
@@ -471,4 +471,3 @@ else
 end_form();
 end_page();
 
-?>
\ No newline at end of file