Ejemplo n.º 1
0
function handle_submit(&$selected_id)
{
    global $path_to_root, $Ajax, $auto_create_branch;
    if (!can_process()) {
        return;
    }
    if ($selected_id) {
        update_customer($_POST['customer_id'], $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']);
        update_record_status($_POST['customer_id'], $_POST['inactive'], 'debtors_master', 'debtor_no');
        $Ajax->activate('customer_id');
        // in case of status change
        display_notification(_("Customer has been updated."));
    } else {
        //it is a new customer
        begin_transaction();
        add_customer($_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']);
        $selected_id = $_POST['customer_id'] = db_insert_id();
        if (isset($auto_create_branch) && $auto_create_branch == 1) {
            add_branch($selected_id, $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $_POST['location'], $_POST['address'], 0, 0, $_POST['ship_via'], $_POST['notes']);
            $selected_branch = db_insert_id();
            add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', '');
            add_crm_contact('cust_branch', 'general', $selected_branch, db_insert_id());
        }
        commit_transaction();
        display_notification(_("A new customer has been added."));
        if (isset($auto_create_branch) && $auto_create_branch == 1) {
            display_notification(_("A default Branch has been automatically created, please check default Branch values by using link below."));
        }
        $Ajax->activate('_page_body');
    }
}
Ejemplo n.º 2
0
function on_submit($selected_parent, $selected_id = -1)
{
    if (!check_num('quantity', 0)) {
        display_error(_("The quantity entered must be numeric and greater than zero."));
        set_focus('quantity');
        return;
    }
    if ($selected_id != -1) {
        update_bom($selected_parent, $selected_id, $_POST['workcentre_added'], $_POST['loc_code'], input_num('quantity'));
        display_notification(_('Selected component has been updated'));
        $Mode = 'RESET';
    } else {
        /*Selected component is null cos no item selected on first time round
        		so must be adding a record must be Submitting new entries in the new
        		component form */
        //need to check not recursive bom component of itself!
        if (!check_for_recursive_bom($selected_parent, $_POST['component'])) {
            /*Now check to see that the component is not already on the bom */
            if (!is_component_already_on_bom($_POST['component'], $_POST['workcentre_added'], $_POST['loc_code'], $selected_parent)) {
                add_bom($selected_parent, $_POST['component'], $_POST['workcentre_added'], $_POST['loc_code'], input_num('quantity'));
                display_notification(_("A new component part has been added to the bill of material for this item."));
                $Mode = 'RESET';
            } else {
                /*The component must already be on the bom */
                display_error(_("The selected component is already on this bom. You can modify it's quantity but it cannot appear more than once on the same bom."));
            }
        } else {
            display_error(_("The selected component is a parent of the current item. Recursive BOMs are not allowed."));
        }
    }
}
Ejemplo n.º 3
0
function check_data()
{
    global $check_price_charged_vs_order_price, $check_qty_charged_vs_del_qty;
    if (!check_num('this_quantity_inv', 0) || input_num('this_quantity_inv') == 0) {
        display_error(tr("The quantity to invoice must be numeric and greater than zero."));
        set_focus('this_quantity_inv');
        return false;
    }
    if (!check_num('ChgPrice')) {
        display_error(tr("The price is not numeric."));
        set_focus('ChgPrice');
        return false;
    }
    if ($check_price_charged_vs_order_price == True) {
        if ($_POST['order_price'] != input_num('ChgPrice')) {
            if ($_POST['order_price'] == 0 || input_num('ChgPrice') / $_POST['order_price'] > 1 + sys_prefs::over_charge_allowance() / 100) {
                display_error(tr("The price being invoiced is more than the purchase order price by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . tr("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
                set_focus('ChgPrice');
                return false;
            }
        }
    }
    if ($check_qty_charged_vs_del_qty == True) {
        if (input_num('this_quantity_inv') / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) > 1 + sys_prefs::over_charge_allowance() / 100) {
            display_error(tr("The quantity being invoiced is more than the outstanding quantity by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . tr("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
            set_focus('this_quantity_inv');
            return false;
        }
    }
    return true;
}
Ejemplo n.º 4
0
function handle_submit()
{
    global $selected_id;
    if (!check_data()) {
        return false;
    }
    if ($selected_id != "") {
        update_exchange_rate($_POST['curr_abrev'], $_POST['date_'], input_num('BuyRate'), input_num('BuyRate'));
    } else {
        add_exchange_rate($_POST['curr_abrev'], $_POST['date_'], input_num('BuyRate'), input_num('BuyRate'));
    }
    return true;
}
Ejemplo n.º 5
0
function can_process()
{
    if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) {
        display_error(tr("The entered date is invalid. Please enter a valid date for the payment."));
        set_focus('DateBanked');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) {
        display_error(tr("The entered date is not in fiscal year."));
        set_focus('DateBanked');
        return false;
    }
    if (!references::is_valid($_POST['ref'])) {
        display_error(tr("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!is_new_reference($_POST['ref'], 12)) {
        display_error(tr("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(tr("The entered amount is invalid or negative and cannot be processed."));
        set_focus('amount');
        return false;
    }
    if (!check_num('discount')) {
        display_error(tr("The entered discount is not a valid number."));
        set_focus('discount');
        return false;
    }
    if (input_num('amount') - input_num('discount') <= 0) {
        display_error(tr("The balance of the amount and discout is zero or negative. Please enter valid amounts."));
        set_focus('discount');
        return false;
    }
    return true;
}
Ejemplo n.º 6
0
function handle_submit()
{
    global $path_to_root;
    if (!can_process()) {
        return;
    }
    if (!isset($_POST['New'])) {
        $sql = "UPDATE debtors_master SET name=" . db_escape($_POST['CustName']) . ", \n\t\t\taddress=" . db_escape($_POST['address']) . ", \n\t\t\ttax_id=" . db_escape($_POST['tax_id']) . ", \n\t\t\tcurr_code=" . db_escape($_POST['curr_code']) . ", \n\t\t\temail=" . db_escape($_POST['email']) . ", \n\t\t\tdimension_id=" . db_escape($_POST['dimension_id']) . ", \n\t\t\tdimension2_id=" . db_escape($_POST['dimension2_id']) . ", \n            credit_status=" . db_escape($_POST['credit_status']) . ", \n            payment_terms=" . db_escape($_POST['payment_terms']) . ", \n            discount=" . input_num('discount') / 100 . ", \n            pymt_discount=" . input_num('pymt_discount') / 100 . ", \n            credit_limit=" . input_num('credit_limit') . ", \n            sales_type = " . db_escape($_POST['sales_type']) . " \n            WHERE debtor_no = '" . $_POST['customer_id'] . "'";
        db_query($sql, "The customer could not be updated");
        display_notification(tr("Customer has been updated."));
        clear_fields();
    } else {
        //it is a new customer
        begin_transaction();
        $sql = "INSERT INTO debtors_master (name, address, tax_id, email, dimension_id, dimension2_id,  \n\t\t\tcurr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit, \n\t\t\tsales_type) VALUES (" . db_escape($_POST['CustName']) . ", " . db_escape($_POST['address']) . ", " . db_escape($_POST['tax_id']) . "," . db_escape($_POST['email']) . ", " . db_escape($_POST['dimension_id']) . ", " . db_escape($_POST['dimension2_id']) . ", " . db_escape($_POST['curr_code']) . ", \n\t\t\t" . db_escape($_POST['credit_status']) . ", " . db_escape($_POST['payment_terms']) . ", " . input_num('discount') / 100 . ", \n\t\t\t" . input_num('pymt_discount') / 100 . ", " . input_num('credit_limit') . ", " . db_escape($_POST['sales_type']) . ")";
        db_query($sql, "The customer could not be added");
        $new_customer_id = db_insert_id();
        commit_transaction();
        display_notification(tr("A new customer has been added."));
        hyperlink_params($path_to_root . "/sales/manage/customer_branches.php", tr("Add branches for this customer"), "debtor_no={$new_customer_id}");
        clear_fields();
    }
}
    if (strlen($_POST['item_code']) == 0) {
        $input_error = 1;
        display_error(_("The item of use cannot be empty."));
        set_focus('name');
    }
    if (strlen($_POST['estimate_price']) == 0) {
        $input_error = 1;
        display_error(_("The estimated price be empty."));
        set_focus('rate');
    }
    if ($input_error != 1) {
        if ($selected_id != -1) {
            update_requisition_detail($selected_id, $_POST['item_code'], $_POST['purpose'], $_POST['order_quantity'], input_num('estimate_price'));
            display_notification(_('Selected requisition details has been updated.'));
        } else {
            add_requisition_detail($_POST['requisitionid'], $_POST['item_code'], $_POST['purpose'], $_POST['order_quantity'], input_num('estimate_price'));
            display_notification(_('New requisition details has been added'));
        }
        $Mode = 'RESET';
    }
}
//-----------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    delete_requisition_detail($selected_id);
    display_notification(_('Selected requisition detail has been deleted'));
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    $requisitionid = $_POST['requisitionid'];
Ejemplo n.º 8
0
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    if (!isset($_POST['std_cost'])) {
        $_POST['std_cost'] = 0;
    }
    add_to_order($_SESSION['transfer_items'], $_POST['stock_id'], input_num('qty'), $_POST['std_cost']);
    line_start_focus();
}
Ejemplo n.º 9
0
function can_process()
{
    global $Refs;
    if (!get_post('customer_id')) {
        display_error(_("There is no customer selected."));
        set_focus('customer_id');
        return false;
    }
    if (!get_post('BranchID')) {
        display_error(_("This customer has no branch defined."));
        set_focus('BranchID');
        return false;
    }
    if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) {
        display_error(_("The entered date is invalid. Please enter a valid date for the payment."));
        set_focus('DateBanked');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('DateBanked');
        return false;
    }
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    //Chaitanya : 13-OCT-2011 - To support Edit feature
    if (isset($_POST['trans_no']) && $_POST['trans_no'] == 0 && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    } elseif ($_POST['ref'] != $_POST['old_ref'] && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(_("The entered amount is invalid or negative and cannot be processed."));
        set_focus('amount');
        return false;
    }
    if (isset($_POST['charge']) && !check_num('charge', 0)) {
        display_error(_("The entered amount is invalid or negative and cannot be processed."));
        set_focus('charge');
        return false;
    }
    if (isset($_POST['charge']) && input_num('charge') > 0) {
        $charge_acct = get_company_pref('bank_charge_act');
        if (get_gl_account($charge_acct) == false) {
            display_error(_("The Bank Charge Account has not been set in System and General GL Setup."));
            set_focus('charge');
            return false;
        }
    }
    if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 1.0E-6)) {
        display_error(_("The exchange rate must be numeric and greater than zero."));
        set_focus('_ex_rate');
        return false;
    }
    if ($_POST['discount'] == "") {
        $_POST['discount'] = 0;
    }
    if (!check_num('discount')) {
        display_error(_("The entered discount is not a valid number."));
        set_focus('discount');
        return false;
    }
    //if ((input_num('amount') - input_num('discount') <= 0)) {
    if (input_num('amount') <= 0) {
        display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts."));
        set_focus('discount');
        return false;
    }
    if (!db_has_currency_rates(get_customer_currency($_POST['customer_id']), $_POST['DateBanked'], true)) {
        return false;
    }
    $_SESSION['alloc']->amount = input_num('amount');
    if (isset($_POST["TotalNumberOfAllocs"])) {
        return check_allocations();
    } else {
        return true;
    }
}
Ejemplo n.º 10
0
function handle_add_new_item()
{
    $allow_update = check_data();
    if ($allow_update == true) {
        if (count($_SESSION['PO']->line_items) > 0) {
            foreach ($_SESSION['PO']->line_items as $order_item) {
                /* do a loop round the items on the order to see that the item
                			is not already on this order */
                if ($order_item->stock_id == $_POST['stock_id'] && $order_item->Deleted == False) {
                    $allow_update = False;
                    display_error(tr("The selected item is already on this order."));
                }
            }
            /* end of the foreach loop to look for pre-existing items of the same code */
        }
        if ($allow_update == true) {
            $sql = "SELECT description, units, mb_flag\n\t\t\t\tFROM stock_master WHERE stock_id = '" . $_POST['stock_id'] . "'";
            $result = db_query($sql, "The stock details for " . $_POST['stock_id'] . " could not be retrieved");
            if (db_num_rows($result) == 0) {
                $allow_update = False;
            }
            if ($allow_update) {
                $myrow = db_fetch($result);
                $_SESSION['PO']->add_to_order($_POST['line_no'], $_POST['stock_id'], input_num('qty'), $myrow["description"], input_num('price'), $myrow["units"], $_POST['req_del_date'], 0, 0);
                unset_form_variables();
                $_POST['StockID2'] = $_POST['stock_id'] = "";
            } else {
                display_error(tr("The selected item does not exist or it is a kit part and therefore cannot be purchased."));
            }
        }
        /* end of if not already on the order and allow input was true*/
    }
}
Ejemplo n.º 11
0
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    add_to_order($_SESSION['adj_items'], $_POST['stock_id'], input_num('qty'), input_num('std_cost'));
    line_start_focus();
}
Ejemplo n.º 12
0
 $total = $btotal = $ltotal = 0;
 for ($i = 0, $date_ = $begin; date1_greater_date2($end, $date_); $i++) {
     start_row();
     $_POST['amount' . $i] = number_format2(get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0);
     label_cell($date_);
     if (!isset($_POST['amount' . $i])) {
         $_POST['amount' . $i] = '0';
     }
     amount_cells(null, 'amount' . $i, null, 15, null, 0);
     if ($showdims) {
         $d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']);
         label_cell(number_format2($d, 0), "nowrap align=right");
         $btotal += $d;
     }
     $lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']);
     $total += input_num('amount' . $i);
     $ltotal += $lamount;
     label_cell(number_format2($lamount, 0), "nowrap align=right");
     $date_ = add_months($date_, 1);
     end_row();
 }
 start_row();
 label_cell("<b>" . tr("Total") . "</b>");
 label_cell("<b>" . number_format2($total, 0) . "</b>", 'align=right');
 if ($showdims) {
     label_cell("<b>" . number_format2($btotal, 0) . "</b>", "nowrap align=right");
 }
 label_cell("<b>" . number_format2($ltotal, 0) . "</b>", "nowrap align=right");
 end_row();
 end_table(1);
 submit_center_first('add', tr("Save"));
Ejemplo n.º 13
0
        $input_error = 1;
        display_error(tr("Salesman provision cannot be less than 0 or more than 100%."));
        set_focus(!$pr1 ? 'provision' : 'provision2');
    }
    if (!check_num('break_pt', 0)) {
        $input_error = 1;
        display_error(tr("Salesman provision breakpoint must be numeric and not less than 0."));
        set_focus('break_pt');
    }
    if ($input_error != 1) {
        if (isset($selected_id)) {
            /*selected_id could also exist if submit had not been clicked this code would not run in this case cos submit is false of course  see the delete code below*/
            $sql = "UPDATE salesman SET salesman_name=" . db_escape($_POST['salesman_name']) . ",\n    \t\t\tsalesman_phone=" . db_escape($_POST['salesman_phone']) . ",\n    \t\t\tsalesman_fax=" . db_escape($_POST['salesman_fax']) . ",\n    \t\t\tsalesman_email=" . db_escape($_POST['salesman_email']) . ",\n    \t\t\tprovision=" . input_num('provision') . ",\n    \t\t\tbreak_pt=" . input_num('break_pt') . ",\n    \t\t\tprovision2=" . input_num('provision2') . "\n    \t\t\tWHERE salesman_code = '{$selected_id}'";
        } else {
            /*Selected group is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new Sales-person form */
            $sql = "INSERT INTO salesman (salesman_name, salesman_phone, salesman_fax, salesman_email,\n    \t\t\tprovision, break_pt, provision2)\n    \t\t\tVALUES (" . db_escape($_POST['salesman_name']) . ", " . db_escape($_POST['salesman_phone']) . ", " . db_escape($_POST['salesman_fax']) . ", " . db_escape($_POST['salesman_email']) . ", " . input_num('provision') . ", " . input_num('break_pt') . ", " . input_num('provision2') . ")";
        }
        //run the sql from either of the above possibilites
        db_query($sql, "The insert or update of the salesperson failed");
        meta_forward($_SERVER['PHP_SELF']);
    }
}
if (isset($_GET['delete'])) {
    //the link to delete a selected record was clicked instead of the submit button
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtors_master'
    $sql = "SELECT COUNT(*) FROM cust_branch WHERE salesman='{$selected_id}'";
    $result = db_query($sql, "check failed");
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        display_error("Cannot delete this sales-person because branches are set up referring to this sales-person - first alter the branches concerned.");
    } else {
Ejemplo n.º 14
0
function handle_add_payment()
{
    $payment_id = write_supp_payment(0, $_POST['supplier_id'], $_POST['bank_account'], $_POST['DatePaid'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_'], input_num('charge'), input_num('bank_amount', input_num('amount')));
    new_doc_date($_POST['DatePaid']);
    $_SESSION['alloc']->trans_no = $payment_id;
    $_SESSION['alloc']->date_ = $_POST['DatePaid'];
    $_SESSION['alloc']->write();
    unset($_POST['bank_account']);
    unset($_POST['DatePaid']);
    unset($_POST['currency']);
    unset($_POST['memo_']);
    unset($_POST['amount']);
    unset($_POST['discount']);
    unset($_POST['ProcessSuppPayment']);
    meta_forward($_SERVER['PHP_SELF'], "AddedID={$payment_id}&supplier_id=" . $_POST['supplier_id']);
}
function change_tpl_flag($reconcile_id)
{
    global $Ajax;
    if (!check_date() && check_value("rec_" . $reconcile_id)) {
        // temporary fix
        return false;
    }
    if (get_post('bank_date') == '') {
        // new reconciliation
        $Ajax->activate('bank_date');
    }
    $_POST['bank_date'] = date2sql(get_post('reconcile_date'));
    $reconcile_value = check_value("rec_" . $reconcile_id) ? "'" . $_POST['bank_date'] . "'" : 'NULL';
    update_reconciled_values($reconcile_id, $reconcile_value, $_POST['reconcile_date'], input_num('end_balance'), $_POST['bank_account']);
    $Ajax->activate('reconciled');
    $Ajax->activate('difference');
    return true;
}
Ejemplo n.º 16
0
function can_process()
{
    global $wo_details, $SysPrefs, $Refs;
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!is_new_reference($_POST['ref'], 29)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('quantity', 0)) {
        display_error(_("The quantity entered is not a valid number or less then zero."));
        set_focus('quantity');
        return false;
    }
    if (!is_date($_POST['date_'])) {
        display_error(_("The entered date is invalid."));
        set_focus('date_');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['date_'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('date_');
        return false;
    }
    if (date_diff2(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) {
        display_error(_("The production date cannot be before the release date of the work order."));
        set_focus('date_');
        return false;
    }
    // don't produce more that required. Otherwise change the Work Order.
    if (input_num('quantity') > $wo_details["units_reqd"] - $wo_details["units_issued"]) {
        display_error(_("The production exceeds the quantity needed. Please change the Work Order."));
        set_focus('quantity');
        return false;
    }
    // if unassembling we need to check the qoh
    if ($_POST['ProductionType'] == 0 && !$SysPrefs->allow_negative_stock()) {
        $wo_details = get_work_order($_POST['selected_id']);
        $qoh = get_qoh_on_date($wo_details["stock_id"], $wo_details["loc_code"], $_POST['date_']);
        if (-input_num('quantity') + $qoh < 0) {
            display_error(_("The unassembling cannot be processed because there is insufficient stock."));
            set_focus('quantity');
            return false;
        }
    }
    // if production we need to check the qoh of the wo requirements
    if ($_POST['ProductionType'] == 1 && !$SysPrefs->allow_negative_stock()) {
        $err = false;
        $result = get_wo_requirements($_POST['selected_id']);
        while ($row = db_fetch($result)) {
            if ($row['mb_flag'] == 'D') {
                // service, non stock
                continue;
            }
            $qoh = get_qoh_on_date($row["stock_id"], $row["loc_code"], $_POST['date_']);
            if ($qoh - $row['units_req'] * input_num('quantity') < 0) {
                display_error(_("The production cannot be processed because a required item would cause a negative inventory balance :") . " " . $row['stock_id'] . " - " . $row['description']);
                $err = true;
            }
        }
        if ($err) {
            set_focus('quantity');
            return false;
        }
    }
    return true;
}
Ejemplo n.º 17
0
    /*read in all the selected order into the Items cart  */
    read_po($_GET['PONumber'], $_SESSION['PO']);
}
//--------------------------------------------------------------------------------------------------
if (isset($_POST['Update']) || isset($_POST['ProcessGoodsReceived'])) {
    /* if update quantities button is hit page has been called and ${$line->line_no} would have be
     	set from the post to the quantity to be received in this receival*/
    foreach ($_SESSION['PO']->line_items as $line) {
        $_POST[$line->line_no] = max($_POST[$line->line_no], 0);
        if (!check_num($line->line_no)) {
            $_POST[$line->line_no] = qty_format(0);
        }
        if (!isset($_POST['DefaultReceivedDate']) || $_POST['DefaultReceivedDate'] == "") {
            $_POST['DefaultReceivedDate'] = Today();
        }
        $_SESSION['PO']->line_items[$line->line_no]->receive_qty = input_num($line->line_no);
        if (isset($_POST[$line->stock_id . "Desc"]) && strlen($_POST[$line->stock_id . "Desc"]) > 0) {
            $_SESSION['PO']->line_items[$line->line_no]->item_description = $_POST[$line->stock_id . "Desc"];
        }
    }
}
//--------------------------------------------------------------------------------------------------
if (isset($_POST['ProcessGoodsReceived'])) {
    process_receive_po();
}
//--------------------------------------------------------------------------------------------------
start_form(false, true);
display_grn_summary($_SESSION['PO'], true);
display_heading(tr("Items to Receive"));
display_po_receive_items();
echo "<br><center>";
Ejemplo n.º 18
0
function handle_add_new_item()
{
    $allow_update = check_data();
    if ($allow_update == true) {
        if (count($_SESSION['PO']->line_items) > 0) {
            foreach ($_SESSION['PO']->line_items as $order_item) {
                /* do a loop round the items on the order to see that the item
                			is not already on this order */
                if ($order_item->stock_id == $_POST['stock_id']) {
                    display_warning(_("The selected item is already on this order."));
                }
            }
            /* end of the foreach loop to look for pre-existing items of the same code */
        }
        if ($allow_update == true) {
            $result = get_short_info($_POST['stock_id']);
            if (db_num_rows($result) == 0) {
                $allow_update = false;
            }
            if ($allow_update) {
                $myrow = db_fetch($result);
                $_SESSION['PO']->add_to_order(count($_SESSION['PO']->line_items), $_POST['stock_id'], input_num('qty'), get_post('stock_id_text'), input_num('price'), '', $_SESSION['PO']->trans_type == ST_PURCHORDER ? $_POST['req_del_date'] : '', 0, 0);
                unset_form_variables();
                $_POST['stock_id'] = "";
            } else {
                display_error(_("The selected item does not exist or it is a kit part and therefore cannot be purchased."));
            }
        }
        /* end of if not already on the order and allow input was true*/
    }
    line_start_focus();
}
Ejemplo n.º 19
0
start_table(TABLESTYLE, "width=30%");
$th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"));
table_header($th);
$j = 1;
$k = 0;
//row colour counter
$result = get_loc_details($_POST['stock_id']);
if (@$_GET['popup']) {
    hidden('_tabs_sel', get_post('_tabs_sel'));
    hidden('popup', @$_GET['popup']);
}
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    if (isset($_POST['UpdateData']) && check_num($myrow["loc_code"])) {
        $myrow["reorder_level"] = input_num($myrow["loc_code"]);
        set_reorder_level($_POST['stock_id'], $myrow["loc_code"], input_num($myrow["loc_code"]));
        display_notification(_("Reorder levels has been updated."));
    }
    $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
    label_cell($myrow["location_name"]);
    $_POST[$myrow["loc_code"]] = qty_format($myrow["reorder_level"], $_POST['stock_id'], $dec);
    qty_cell($qoh, false, $dec);
    qty_cells(null, $myrow["loc_code"], null, null, null, $dec);
    end_row();
    $j++;
    if ($j == 12) {
        $j = 1;
        table_header($th);
    }
}
end_table(1);
Ejemplo n.º 20
0
function can_process()
{
    global $selected_id, $SysPrefs, $Refs;
    if (!isset($selected_id)) {
        if (!$Refs->is_valid($_POST['wo_ref'])) {
            display_error(_("You must enter a reference."));
            set_focus('wo_ref');
            return false;
        }
        if (!is_new_reference($_POST['wo_ref'], ST_WORKORDER)) {
            display_error(_("The entered reference is already in use."));
            set_focus('wo_ref');
            return false;
        }
    }
    if (!check_num('quantity', 0)) {
        display_error(_("The quantity entered is invalid or less than zero."));
        set_focus('quantity');
        return false;
    }
    if (!is_date($_POST['date_'])) {
        display_error(_("The date entered is in an invalid format."));
        set_focus('date_');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['date_'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('date_');
        return false;
    }
    // only check bom and quantites if quick assembly
    if (!($_POST['type'] == WO_ADVANCED)) {
        if (!has_bom($_POST['stock_id'])) {
            display_error(_("The selected item to manufacture does not have a bom."));
            set_focus('stock_id');
            return false;
        }
        if ($_POST['Labour'] == "") {
            $_POST['Labour'] = price_format(0);
        }
        if (!check_num('Labour', 0)) {
            display_error(_("The labour cost entered is invalid or less than zero."));
            set_focus('Labour');
            return false;
        }
        if ($_POST['Costs'] == "") {
            $_POST['Costs'] = price_format(0);
        }
        if (!check_num('Costs', 0)) {
            display_error(_("The cost entered is invalid or less than zero."));
            set_focus('Costs');
            return false;
        }
        if (!$SysPrefs->allow_negative_stock()) {
            if ($_POST['type'] == WO_ASSEMBLY) {
                // check bom if assembling
                $result = get_bom($_POST['stock_id']);
                while ($bom_item = db_fetch($result)) {
                    if (has_stock_holding($bom_item["ResourceType"])) {
                        $quantity = $bom_item["quantity"] * input_num('quantity');
                        if (check_negative_stock($bom_item["component"], -$quantity, $bom_item["loc_code"], $_POST['date_'])) {
                            display_error(_("The work order cannot be processed because there is an insufficient quantity for component:") . " " . $bom_item["component"] . " - " . $bom_item["description"] . ".  " . _("Location:") . " " . $bom_item["location_name"]);
                            set_focus('quantity');
                            return false;
                        }
                    }
                }
            } elseif ($_POST['type'] == WO_UNASSEMBLY) {
                // if unassembling, check item to unassemble
                if (check_negative_stock($_POST['stock_id'], -input_num('quantity'), $_POST['StockLocation'], $_POST['date_'])) {
                    display_error(_("The selected item cannot be unassembled because there is insufficient stock."));
                    return false;
                }
            }
        }
    } else {
        if (!is_date($_POST['RequDate'])) {
            set_focus('RequDate');
            display_error(_("The date entered is in an invalid format."));
            return false;
        }
        //elseif (!is_date_in_fiscalyear($_POST['RequDate']))
        //{
        //	display_error(_("The entered date is not in fiscal year."));
        //	return false;
        //}
        if (isset($selected_id)) {
            $myrow = get_work_order($selected_id, true);
            if ($_POST['units_issued'] > input_num('quantity')) {
                set_focus('quantity');
                display_error(_("The quantity cannot be changed to be less than the quantity already manufactured for this order."));
                return false;
            }
        }
    }
    return true;
}
Ejemplo n.º 21
0
function check_quantities()
{
    $ok = 1;
    // Update cart delivery quantities/descriptions
    foreach ($_SESSION['Items']->line_items as $line => $itm) {
        if (isset($_POST['Line' . $line])) {
            if ($_SESSION['Items']->trans_no) {
                $min = $itm->qty_done;
                $max = $itm->quantity;
            } else {
                $min = 0;
                $max = $itm->quantity - $itm->qty_done;
            }
            if (check_num('Line' . $line, $min, $max)) {
                $_SESSION['Items']->line_items[$line]->qty_dispatched = input_num('Line' . $line);
            } else {
                set_focus('Line' . $line);
                $ok = 0;
            }
        }
        if (isset($_POST['Line' . $line . 'Desc'])) {
            $line_desc = $_POST['Line' . $line . 'Desc'];
            if (strlen($line_desc) > 0) {
                $_SESSION['Items']->line_items[$line]->item_description = $line_desc;
            }
        }
    }
    // ...
    //	else
    //	  $_SESSION['Items']->freight_cost = input_num('ChargeFreightCost');
    return $ok;
}
Ejemplo n.º 22
0
        set_focus('price');
    } elseif (!check_num('conversion_factor')) {
        $input_error = 1;
        display_error(_("The conversion factor entered was not numeric. The conversion factor is the number by which the price must be divided by to get the unit price in our unit of measure."));
        set_focus('conversion_factor');
    } elseif ($Mode == 'ADD_ITEM' && get_item_purchasing_data($_POST['supplier_id'], $_POST['stock_id'])) {
        $input_error = 1;
        display_error(_("The purchasing data for this supplier has already been added."));
        set_focus('supplier_id');
    }
    if ($input_error == 0) {
        if ($Mode == 'ADD_ITEM') {
            add_item_purchasing_data($_POST['supplier_id'], $_POST['stock_id'], input_num('price', 0), $_POST['suppliers_uom'], input_num('conversion_factor'), $_POST['supplier_description']);
            display_notification(_("This supplier purchasing data has been added."));
        } else {
            update_item_purchasing_data($selected_id, $_POST['stock_id'], input_num('price', 0), $_POST['suppliers_uom'], input_num('conversion_factor'), $_POST['supplier_description']);
            display_notification(_("Supplier purchasing data has been updated."));
        }
        $Mode = 'RESET';
    }
}
//--------------------------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    delete_item_purchasing_data($selected_id, $_POST['stock_id']);
    display_notification(_("The purchasing data item has been sucessfully deleted."));
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
}
if (isset($_POST['_selected_id_update'])) {
Ejemplo n.º 23
0
 /**
  * 商品评价提交
  * 
  **/
 public function commentPost()
 {
     $user_id = $this->get_user_id(TRUE);
     $order_num = input_num($this->input->post('order'), 10000, FALSE, FALSE, '3001');
     $data['points'] = input_int($this->input->post('stars'), 1, 5, FALSE, '3011');
     $data['note'] = $this->input->post('note');
     $data['picture'] = rtrim($this->input->post('images'), ',');
     if (!$data['picture'] && !$data['note']) {
         response_code('3012');
     }
     $data['has_pic'] = $data['picture'] ? 1 : 0;
     $order = $this->model->get_order_detail_by_order_num($order_num, $user_id);
     if (!$order) {
         response_code('3001');
     }
     if ($order['commented']) {
         response_code('3013');
     }
     $data['user_id'] = $order['user_id'];
     $data['product_id'] = $order['product_id'];
     $rs = $this->model->add_product_comment($order_num, $data);
     if ($rs) {
         response_code('1');
     }
     response_code('4000');
 }
Ejemplo n.º 24
0
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    add_to_order($_SESSION['Items'], get_post('stock_id'), input_num('qty'), input_num('price'), input_num('Disc') / 100, get_post('stock_id_text'));
    unset($_POST['_stock_id_edit'], $_POST['stock_id']);
    page_modified();
    line_start_focus();
}
Ejemplo n.º 25
0
        set_focus('end');
    }
    if (isset($_POST['last_sent']) && !is_date($_POST['last_sent'])) {
        $input_error = 1;
        display_error(_("The entered date is invalid."));
        set_focus('last_sent');
    }
    if ($input_error != 1) {
        if ($selected_id != -1) {
            update_recurrent_invoice($selected_id, $_POST['description'], $_POST['order_no'], input_num('debtor_no'), input_num('group_no'), input_num('days', 0), input_num('monthly', 0), $_POST['begin'], $_POST['end']);
            if (isset($_POST['last_sent'])) {
                update_last_sent_recurrent_invoice($selected_id, $_POST['last_sent']);
            }
            $note = _('Selected recurrent invoice has been updated');
        } else {
            add_recurrent_invoice($_POST['description'], $_POST['order_no'], input_num('debtor_no'), input_num('group_no'), input_num('days', 0), input_num('monthly', 0), $_POST['begin'], $_POST['end']);
            $note = _('New recurrent invoice has been added');
        }
        display_notification($note);
        $Mode = 'RESET';
    }
}
if ($Mode == 'Delete') {
    $cancel_delete = 0;
    if ($cancel_delete == 0) {
        delete_recurrent_invoice($selected_id);
        display_notification(_('Selected recurrent invoice has been deleted'));
    }
    //end if Delete area
    $Mode = 'RESET';
}
Ejemplo n.º 26
0
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    if (input_num('AmountDebit') > 0) {
        $amount = input_num('AmountDebit');
    } else {
        $amount = -input_num('AmountCredit');
    }
    $_SESSION['journal_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']);
    line_start_focus();
}
Ejemplo n.º 27
0
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    $amount = ($_SESSION['pay_items']->trans_type == ST_BANKPAYMENT ? 1 : -1) * input_num('amount');
    $_SESSION['pay_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']);
    line_start_focus();
}
Ejemplo n.º 28
0
function edit_allocations_for_transaction($type, $trans_no)
{
    global $table_style;
    start_form(false, true);
    display_heading(sprintf(tr("Allocation of %s # %d"), systypes::name($_SESSION['alloc']->type), $_SESSION['alloc']->trans_no));
    display_heading($_SESSION['alloc']->person_name);
    display_heading2(tr("Date:") . " <b>" . $_SESSION['alloc']->date_ . "</b>");
    display_heading2(tr("Total:") . " <b>" . price_format($_SESSION['alloc']->amount) . "</b>");
    echo "<br>";
    if (count($_SESSION['alloc']->allocs) > 0) {
        start_table($table_style);
        $th = array(tr("Transaction Type"), tr("#"), tr("Date"), tr("Due Date"), tr("Amount"), tr("Other Allocations"), tr("This Allocation"), tr("Left to Allocate"), "", "");
        table_header($th);
        $k = $counter = $total_allocated = 0;
        foreach ($_SESSION['alloc']->allocs as $allocn_item) {
            alt_table_row_color($k);
            label_cell(systypes::name($allocn_item->type));
            label_cell(get_trans_view_str($allocn_item->type, $allocn_item->type_no));
            label_cell($allocn_item->date_, "align=right");
            label_cell($allocn_item->due_date, "align=right");
            amount_cell($allocn_item->amount);
            amount_cell($allocn_item->amount_allocated);
            if (!check_num('amount' . $counter)) {
                $_POST['amount' . $counter] = price_format($allocn_item->current_allocated);
            }
            amount_cells(null, 'amount' . $counter, $_POST['amount' . $counter]);
            $un_allocated = round($allocn_item->amount - $allocn_item->amount_allocated, 6);
            hidden("un_allocated" . $counter, $un_allocated);
            amount_cell($un_allocated);
            label_cell("<a href='#' name=Alloc{$counter} onclick='allocate_all(this.name.substr(5));return true;'>" . tr("All") . "</a>");
            label_cell("<a href='#' name=DeAll{$counter} onclick='allocate_none(this.name.substr(5));return true;'>" . tr("None") . "</a>");
            end_row();
            $total_allocated += input_num('amount' . $counter);
            $counter++;
        }
        label_row(tr("Total Allocated"), price_format($total_allocated), "colspan=6 align=right", "nowrap align=right id='total_allocated'");
        if ($_SESSION['alloc']->amount - $total_allocated < 0) {
            $font1 = "<font color=red>";
            $font2 = "</font>";
        } else {
            $font1 = $font2 = "";
        }
        $left_to_allocate = $_SESSION['alloc']->amount - $total_allocated;
        $left_to_allocate = price_format($left_to_allocate);
        label_row(tr("Left to Allocate"), $font1 . $left_to_allocate . $font2, "colspan=6 align=right ", "nowrap align=right id='left_to_allocate'");
        end_table(1);
        hidden('TotalNumberOfAllocs', $counter);
        //		hidden('left_to_allocate', $left_to_allocate);
        submit_center_first('UpdateDisplay', tr("Update"));
        submit('Process', tr("Process"));
    } else {
        display_note(tr("There are no unsettled transactions to allocate."), 0, 1);
    }
    submit_center_last('Cancel', tr("Back to Allocations"));
    end_form();
}
Ejemplo n.º 29
0
function handle_add_deposit()
{
    new_doc_date($_POST['DatePaid']);
    $trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'], input_num('amount'), $_POST['ref'], $_POST['memo_'], input_num('charge'), input_num('target_amount'));
    meta_forward($_SERVER['PHP_SELF'], "AddedID={$trans_no}");
}
Ejemplo n.º 30
0
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    add_to_order($_SESSION['Items'], $_POST['stock_id'], input_num('qty'), input_num('price'), input_num('Disc') / 100);
    line_start_focus();
}