Example #1
0
function gl_payment_controls()
{
    global $Refs;
    $home_currency = get_company_currency();
    start_form();
    start_outer_table(TABLESTYLE2);
    table_section(1);
    bank_accounts_list_row(_("From Account:"), 'FromBankAccount', null, true);
    bank_balance_row($_POST['FromBankAccount']);
    bank_accounts_list_row(_("To Account:"), 'ToBankAccount', null, true);
    if (!isset($_POST['DatePaid'])) {
        // init page
        $_POST['DatePaid'] = new_doc_date();
        if (!is_date_in_fiscalyear($_POST['DatePaid'])) {
            $_POST['DatePaid'] = end_fiscalyear();
        }
    }
    date_row(_("Transfer Date:"), 'DatePaid', '', true, 0, 0, 0, null, true);
    ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_BANKTRANSFER));
    table_section(2);
    $from_currency = get_bank_account_currency($_POST['FromBankAccount']);
    $to_currency = get_bank_account_currency($_POST['ToBankAccount']);
    if ($from_currency != "" && $to_currency != "" && $from_currency != $to_currency) {
        amount_row(_("Amount:"), 'amount', null, null, $from_currency);
        amount_row(_("Bank Charge:"), 'charge', null, null, $from_currency);
        amount_row(_("Incoming Amount:"), 'target_amount', null, '', $to_currency, 2);
    } else {
        amount_row(_("Amount:"), 'amount');
        amount_row(_("Bank Charge:"), 'charge');
    }
    textarea_row(_("Memo:"), 'memo_', null, 40, 4);
    end_outer_table(1);
    // outer table
    submit_center('AddPayment', _("Enter Transfer"), true, '', 'default');
    end_form();
}
 hidden('total_ded', $total_ded);
 hidden('total_net', $total_net);
 start_outer_table(TABLESTYLE2);
 table_section(1);
 table_section_title(_("Earning Details"));
 if (db_has_employee_payslip($_POST['year'], $_POST['month'], $_POST['empl_id'])) {
     label_row(_(" Date of Paid :"), $date_of_paid);
 }
 label_row(_(" Basic:"), $basic_pay, null, 30, 30);
 label_row(_(" DA:"), $da_pay, null, 30, 30);
 label_row(_(" HRA:"), $hra_pay, null, 30, 30);
 label_row(_(" Conveyance:"), $convey_allow, null, 30, 30);
 label_row(_(" Education/ Other Allowance:"), $edu_other_allow, null, 30, 30);
 table_section_title(_(""));
 label_row(_(" Gross Earning"), $gross, 'style="color:#A86A0B; background-color:#F2F6D5;"', 'style="color:#A86A0B; background-color:#F2F6D5;"');
 table_section(2);
 table_section_title(_("Deduction"));
 label_row(_(" Provident Fund:"), $pf, null, 30, 30);
 label_row(_(" LOP Amount:"), $lop_amount, null, 30, 30);
 label_row(_(" Monthly Amount:"), $staff_loan, null, 30, 30);
 label_row(_(" Other Deduction:"), $tds, null, 30, 30);
 label_row(_(" Total Deductions"), $total_ded, 'style="color:#f55; background-color:#fed;"', 'style="color:#f55; background-color:#fed;"');
 label_row(_(" "), '', null, 30, 30);
 label_row(_(" Net Salary Payable:"), $total_net, 'style="color:#107B0F; background-color:#B7DBC1;"', 'style="color:#107B0F; background-color:#B7DBC1;"');
 end_outer_table(1);
 if (!db_has_employee_payslip($_POST['year'], $_POST['month'], $_POST['empl_id'])) {
     start_table(TABLESTYLE2);
     echo '<tr>';
     $from = Today();
     $from = add_days($from, 1);
     $bal = get_balance_before_for_bank_account(1, $from);
Example #3
0
}
read_customer_data();
set_global_customer($_POST['customer_id']);
if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) {
    display_warning(_("This customer account is on hold."));
}
$display_discount_percent = percent_format($_POST['pymt_discount'] * 100) . "%";
table_section(2);
if (!list_updated('bank_account')) {
    $_POST['bank_account'] = get_default_customer_bank_account($_POST['customer_id']);
}
//Chaitanya : 13-OCT-2011 - Is AJAX call really needed ???
//bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true);
bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, false);
text_row(_("Reference:"), 'ref', null, 20, 40);
table_section(3);
date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true);
$comp_currency = get_company_currency();
$cust_currency = get_customer_currency($_POST['customer_id']);
$bank_currency = get_bank_account_currency($_POST['bank_account']);
if ($cust_currency != $bank_currency) {
    exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], $bank_currency == $comp_currency);
}
amount_row(_("Bank Charge:"), 'charge');
end_outer_table(1);
if ($cust_currency == $bank_currency) {
    div_start('alloc_tbl');
    show_allocatable(false);
    div_end();
}
start_table(TABLESTYLE, "width=60%");
Example #4
0
function customer_settings($selected_id)
{
    global $SysPrefs, $path_to_root, $auto_create_branch;
    if (!$selected_id) {
        if (list_updated('customer_id') || !isset($_POST['CustName'])) {
            $_POST['CustName'] = $_POST['cust_ref'] = $_POST['address'] = $_POST['tax_id'] = '';
            $_POST['dimension_id'] = 0;
            $_POST['dimension2_id'] = 0;
            $_POST['sales_type'] = -1;
            $_POST['curr_code'] = get_company_currency();
            $_POST['credit_status'] = -1;
            $_POST['payment_terms'] = $_POST['notes'] = '';
            $_POST['discount'] = $_POST['pymt_discount'] = percent_format(0);
            $_POST['credit_limit'] = price_format($SysPrefs->default_credit_limit());
        }
    } else {
        $myrow = get_customer($selected_id);
        $_POST['CustName'] = $myrow["name"];
        $_POST['cust_ref'] = $myrow["debtor_ref"];
        $_POST['address'] = $myrow["address"];
        $_POST['tax_id'] = $myrow["tax_id"];
        $_POST['dimension_id'] = $myrow["dimension_id"];
        $_POST['dimension2_id'] = $myrow["dimension2_id"];
        $_POST['sales_type'] = $myrow["sales_type"];
        $_POST['curr_code'] = $myrow["curr_code"];
        $_POST['credit_status'] = $myrow["credit_status"];
        $_POST['payment_terms'] = $myrow["payment_terms"];
        $_POST['discount'] = percent_format($myrow["discount"] * 100);
        $_POST['pymt_discount'] = percent_format($myrow["pymt_discount"] * 100);
        $_POST['credit_limit'] = price_format($myrow["credit_limit"]);
        $_POST['notes'] = $myrow["notes"];
        $_POST['inactive'] = $myrow["inactive"];
    }
    start_outer_table(TABLESTYLE2);
    table_section(1);
    table_section_title(_("Name and Address"));
    text_row(_("Customer Name:"), 'CustName', $_POST['CustName'], 40, 80);
    text_row(_("Customer Short Name:"), 'cust_ref', null, 30, 30);
    textarea_row(_("Address:"), 'address', $_POST['address'], 35, 5);
    text_row(_("GSTNo:"), 'tax_id', null, 40, 40);
    if (!$selected_id || is_new_customer($selected_id)) {
        currencies_list_row(_("Customer's Currency:"), 'curr_code', $_POST['curr_code']);
    } else {
        label_row(_("Customer's Currency:"), $_POST['curr_code']);
        hidden('curr_code', $_POST['curr_code']);
    }
    sales_types_list_row(_("Sales Type/Price List:"), 'sales_type', $_POST['sales_type']);
    if ($selected_id) {
        record_status_list_row(_("Customer status:"), 'inactive');
    } elseif (isset($auto_create_branch) && $auto_create_branch == 1) {
        table_section_title(_("Branch"));
        text_row(_("Phone:"), 'phone', null, 32, 30);
        text_row(_("Secondary Phone Number:"), 'phone2', null, 32, 30);
        text_row(_("Fax Number:"), 'fax', null, 32, 30);
        email_row(_("E-mail:"), 'email', null, 35, 55);
        sales_persons_list_row(_("Sales Person:"), 'salesman', null);
    }
    table_section(2);
    table_section_title(_("Sales"));
    percent_row(_("Discount Percent:"), 'discount', $_POST['discount']);
    percent_row(_("Prompt Payment Discount Percent:"), 'pymt_discount', $_POST['pymt_discount']);
    amount_row(_("Credit Limit:"), 'credit_limit', $_POST['credit_limit']);
    payment_terms_list_row(_("Payment Terms:"), 'payment_terms', $_POST['payment_terms']);
    credit_status_list_row(_("Credit Status:"), 'credit_status', $_POST['credit_status']);
    $dim = get_company_pref('use_dimension');
    if ($dim >= 1) {
        dimensions_list_row(_("Dimension") . " 1:", 'dimension_id', $_POST['dimension_id'], true, " ", false, 1);
    }
    if ($dim > 1) {
        dimensions_list_row(_("Dimension") . " 2:", 'dimension2_id', $_POST['dimension2_id'], true, " ", false, 2);
    }
    if ($dim < 1) {
        hidden('dimension_id', 0);
    }
    if ($dim < 2) {
        hidden('dimension2_id', 0);
    }
    if ($selected_id) {
        start_row();
        echo '<td class="label">' . _('Customer branches') . ':</td>';
        hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php", '<b>' . (@$_REQUEST['popup'] ? _("Select or &Add") : _("&Add or Edit ")) . '</b>', "debtor_no=" . $selected_id . (@$_REQUEST['popup'] ? '&popup=1' : ''));
        end_row();
    }
    textarea_row(_("General Notes:"), 'notes', null, 35, 5);
    if (!$selected_id && isset($auto_create_branch) && $auto_create_branch == 1) {
        table_section_title(_("Branch"));
        locations_list_row(_("Default Inventory Location:"), 'location');
        shippers_list_row(_("Default Shipping Company:"), 'ship_via');
        sales_areas_list_row(_("Sales Area:"), 'area', null);
        tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
    }
    end_outer_table(1);
    div_start('controls');
    if (!$selected_id) {
        submit_center('submit', _("Add New Customer"), true, '', 'default');
    } else {
        submit_center_first('submit', _("Update Customer"), _('Update customer data'), @$_REQUEST['popup'] ? true : 'default');
        submit_return('select', $selected_id, _("Select this customer and return to document entry."));
        submit_center_last('delete', _("Delete Customer"), _('Delete customer data if have been never used'), true);
    }
    div_end();
}
Example #5
0
function supplier_settings(&$supplier_id)
{
    start_outer_table(TABLESTYLE2);
    table_section(1);
    if ($supplier_id) {
        //SupplierID exists - either passed when calling the form or from the form itself
        $myrow = get_supplier($_POST['supplier_id']);
        $_POST['supp_name'] = $myrow["supp_name"];
        $_POST['supp_ref'] = $myrow["supp_ref"];
        $_POST['address'] = $myrow["address"];
        $_POST['supp_address'] = $myrow["supp_address"];
        $_POST['gst_no'] = $myrow["gst_no"];
        $_POST['website'] = $myrow["website"];
        $_POST['supp_account_no'] = $myrow["supp_account_no"];
        $_POST['bank_account'] = $myrow["bank_account"];
        $_POST['dimension_id'] = $myrow["dimension_id"];
        $_POST['dimension2_id'] = $myrow["dimension2_id"];
        $_POST['curr_code'] = $myrow["curr_code"];
        $_POST['payment_terms'] = $myrow["payment_terms"];
        $_POST['credit_limit'] = price_format($myrow["credit_limit"]);
        $_POST['tax_group_id'] = $myrow["tax_group_id"];
        $_POST['tax_included'] = $myrow["tax_included"];
        $_POST['payable_account'] = $myrow["payable_account"];
        $_POST['purchase_account'] = $myrow["purchase_account"];
        $_POST['payment_discount_account'] = $myrow["payment_discount_account"];
        $_POST['notes'] = $myrow["notes"];
        $_POST['inactive'] = $myrow["inactive"];
    } else {
        $_POST['supp_name'] = $_POST['supp_ref'] = $_POST['address'] = $_POST['supp_address'] = $_POST['tax_group_id'] = $_POST['website'] = $_POST['supp_account_no'] = $_POST['notes'] = '';
        $_POST['dimension_id'] = 0;
        $_POST['dimension2_id'] = 0;
        $_POST['tax_included'] = 0;
        $_POST['sales_type'] = -1;
        $_POST['gst_no'] = $_POST['bank_account'] = '';
        $_POST['payment_terms'] = '';
        $_POST['credit_limit'] = price_format(0);
        $company_record = get_company_prefs();
        $_POST['curr_code'] = $company_record["curr_default"];
        $_POST['payable_account'] = $company_record["creditors_act"];
        $_POST['purchase_account'] = '';
        // default/item's cogs account
        $_POST['payment_discount_account'] = $company_record['pyt_discount_act'];
    }
    table_section_title(_("Basic Data"));
    text_row(_("Supplier Name:"), 'supp_name', null, 42, 40);
    text_row(_("Supplier Short Name:"), 'supp_ref', null, 30, 30);
    text_row(_("GSTNo:"), 'gst_no', null, 42, 40);
    link_row(_("Website:"), 'website', null, 35, 55);
    if ($supplier_id && !is_new_supplier($supplier_id) && (key_in_foreign_table($_POST['supplier_id'], 'supp_trans', 'supplier_id') || key_in_foreign_table($_POST['supplier_id'], 'purch_orders', 'supplier_id'))) {
        label_row(_("Supplier's Currency:"), $_POST['curr_code']);
        hidden('curr_code', $_POST['curr_code']);
    } else {
        currencies_list_row(_("Supplier's Currency:"), 'curr_code', null);
    }
    tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
    text_row(_("Our Customer No:"), 'supp_account_no', null, 42, 40);
    table_section_title(_("Purchasing"));
    text_row(_("Bank Name/Account:"), 'bank_account', null, 42, 40);
    amount_row(_("Credit Limit:"), 'credit_limit', null);
    payment_terms_list_row(_("Payment Terms:"), 'payment_terms', null);
    //
    // tax_included option from supplier record is used directly in update_average_cost() function,
    // therefore we can't edit the option after any transaction waas done for the supplier.
    //
    if (is_new_supplier($supplier_id)) {
        check_row(_("Prices contain tax included:"), 'tax_included');
    } else {
        hidden('tax_included');
        label_row(_("Prices contain tax included:"), $_POST['tax_included'] ? _('Yes') : _('No'));
    }
    table_section_title(_("Accounts"));
    gl_all_accounts_list_row(_("Accounts Payable Account:"), 'payable_account', $_POST['payable_account']);
    gl_all_accounts_list_row(_("Purchase Account:"), 'purchase_account', $_POST['purchase_account'], false, false, _("Use Item Inventory/COGS Account"));
    gl_all_accounts_list_row(_("Purchase Discount Account:"), 'payment_discount_account', $_POST['payment_discount_account']);
    if (!$supplier_id) {
        table_section_title(_("Contact Data"));
        text_row(_("Phone Number:"), 'phone', null, 32, 30);
        text_row(_("Secondary Phone Number:"), 'phone2', null, 32, 30);
    }
    table_section(2);
    $dim = get_company_pref('use_dimension');
    if ($dim >= 1) {
        table_section_title(_("Dimension"));
        dimensions_list_row(_("Dimension") . " 1:", 'dimension_id', null, true, " ", false, 1);
        if ($dim > 1) {
            dimensions_list_row(_("Dimension") . " 2:", 'dimension2_id', null, true, " ", false, 2);
        }
    }
    if ($dim < 1) {
        hidden('dimension_id', 0);
    }
    if ($dim < 2) {
        hidden('dimension2_id', 0);
    }
    table_section_title(_("Addresses"));
    textarea_row(_("Mailing Address:"), 'address', null, 35, 5);
    textarea_row(_("Physical Address:"), 'supp_address', null, 35, 5);
    table_section_title(_("General"));
    textarea_row(_("General Notes:"), 'notes', null, 35, 5);
    if ($supplier_id) {
        record_status_list_row(_("Supplier status:"), 'inactive');
    } else {
        table_section_title(_("Contact Data"));
        text_row(_("Contact Person:"), 'contact', null, 42, 40);
        text_row(_("Fax Number:"), 'fax', null, 32, 30);
        email_row(_("E-mail:"), 'email', null, 35, 55);
        languages_list_row(_("Document Language:"), 'rep_lang', null, _('System default'));
    }
    end_outer_table(1);
    div_start('controls');
    if ($supplier_id) {
        submit_center_first('submit', _("Update Supplier"), _('Update supplier data'), @$_REQUEST['popup'] ? true : 'default');
        submit_return('select', get_post('supplier_id'), _("Select this supplier and return to document entry."));
        submit_center_last('delete', _("Delete Supplier"), _('Delete supplier data if have been never used'), true);
    } else {
        submit_center('submit', _("Add New Supplier Details"), true, '', 'default');
    }
    div_end();
}
Example #6
0
function item_settings(&$stock_id)
{
    global $SysPrefs, $path_to_root, $new_item, $pic_height;
    start_outer_table(TABLESTYLE2);
    table_section(1);
    table_section_title(_("Item"));
    //------------------------------------------------------------------------------------
    if ($new_item) {
        text_row(_("Item Code/ISBN:"), 'NewStockID', null, 21, 20);
        $_POST['inactive'] = 0;
    } else {
        // Must be modifying an existing item
        if (get_post('NewStockID') != get_post('stock_id') || get_post('addupdate')) {
            // first item display
            $_POST['NewStockID'] = $_POST['stock_id'];
            $myrow = get_item($_POST['NewStockID']);
            $_POST['long_description'] = $myrow["long_description"];
            $_POST['description'] = $myrow["description"];
            $_POST['category_id'] = $myrow["category_id"];
            /*==============MOODLEARNING=============*/
            $_POST['level_id'] = $myrow["level_id"];
            /*=======================================*/
            $_POST['tax_type_id'] = $myrow["tax_type_id"];
            $_POST['units'] = $myrow["units"];
            $_POST['mb_flag'] = $myrow["mb_flag"];
            $_POST['sales_account'] = $myrow['sales_account'];
            $_POST['inventory_account'] = $myrow['inventory_account'];
            $_POST['cogs_account'] = $myrow['cogs_account'];
            $_POST['adjustment_account'] = $myrow['adjustment_account'];
            $_POST['assembly_account'] = $myrow['assembly_account'];
            $_POST['dimension_id'] = $myrow['dimension_id'];
            $_POST['dimension2_id'] = $myrow['dimension2_id'];
            $_POST['no_sale'] = $myrow['no_sale'];
            $_POST['del_image'] = 0;
            $_POST['inactive'] = $myrow["inactive"];
            $_POST['editable'] = $myrow["editable"];
        }
        label_row(_("Item Code/ISBN:"), $_POST['NewStockID']);
        hidden('NewStockID', $_POST['NewStockID']);
        set_focus('description');
    }
    /*=================MOODLEARNING====================*/
    level_list_row(_("Level:"), 'level_id', null);
    /*=================================================*/
    text_row(_("Name:"), 'description', null, 52, 200);
    textarea_row(_('Description:'), 'long_description', null, 42, 3);
    stock_categories_list_row(_("Category/Subject:"), 'category_id', null, false, $new_item);
    if ($new_item && (list_updated('category_id') || !isset($_POST['units']))) {
        $category_record = get_item_category($_POST['category_id']);
        $_POST['level_id'] = $category_record["level_id"];
        // moodlearning edit
        $_POST['subject_id'] = $category_record["level_id"];
        $_POST['tax_type_id'] = $category_record["dflt_tax_type"];
        $_POST['units'] = $category_record["dflt_units"];
        $_POST['mb_flag'] = $category_record["dflt_mb_flag"];
        $_POST['inventory_account'] = $category_record["dflt_inventory_act"];
        $_POST['cogs_account'] = $category_record["dflt_cogs_act"];
        $_POST['sales_account'] = $category_record["dflt_sales_act"];
        $_POST['adjustment_account'] = $category_record["dflt_adjustment_act"];
        $_POST['assembly_account'] = $category_record["dflt_assembly_act"];
        $_POST['dimension_id'] = $category_record["dflt_dim1"];
        $_POST['dimension2_id'] = $category_record["dflt_dim2"];
        $_POST['no_sale'] = $category_record["dflt_no_sale"];
        $_POST['editable'] = 0;
    }
    $fresh_item = !isset($_POST['NewStockID']) || $new_item || check_usage($_POST['stock_id'], false);
    item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null);
    stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item);
    stock_units_list_row(_('Units of Measure:'), 'units', null, $fresh_item);
    check_row(_("Editable description:"), 'editable');
    check_row(_("Exclude from sales:"), 'no_sale');
    table_section(2);
    $dim = get_company_pref('use_dimension');
    if ($dim >= 1) {
        table_section_title(_("Dimensions"));
        dimensions_list_row(_("Dimension") . " 1", 'dimension_id', null, true, " ", false, 1);
        if ($dim > 1) {
            dimensions_list_row(_("Dimension") . " 2", 'dimension2_id', null, true, " ", false, 2);
        }
    }
    if ($dim < 1) {
        hidden('dimension_id', 0);
    }
    if ($dim < 2) {
        hidden('dimension2_id', 0);
    }
    table_section_title(_("GL Accounts"));
    gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
    if (!is_service($_POST['mb_flag'])) {
        gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
        gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
        gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
    } else {
        gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
        hidden('inventory_account', $_POST['inventory_account']);
        hidden('adjustment_account', $_POST['adjustment_account']);
    }
    if (is_manufactured($_POST['mb_flag'])) {
        gl_all_accounts_list_row(_("Item Assembly Costs Account:"), 'assembly_account', $_POST['assembly_account']);
    } else {
        hidden('assembly_account', $_POST['assembly_account']);
    }
    table_section_title(_("Other"));
    // Add image upload for New Item  - by Joe
    file_row(_("Image File (.jpg)") . ":", 'pic', 'pic');
    // Add Image upload for New Item  - by Joe
    $stock_img_link = "";
    $check_remove_image = false;
    if (isset($_POST['NewStockID']) && file_exists(company_path() . '/images/' . item_img_name($_POST['NewStockID']) . ".jpg")) {
        // 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D.
        $stock_img_link .= "<img id='item_img' alt = '[" . $_POST['NewStockID'] . ".jpg" . "]' src='" . company_path() . '/images/' . item_img_name($_POST['NewStockID']) . ".jpg?nocache=" . rand() . "'" . " height='{$pic_height}' border='0'>";
        $check_remove_image = true;
    } else {
        $stock_img_link .= _("No image");
    }
    label_row("&nbsp;", $stock_img_link);
    if ($check_remove_image) {
        check_row(_("Delete Image:"), 'del_image');
    }
    record_status_list_row(_("Item status:"), 'inactive');
    end_outer_table(1);
    div_start('controls');
    if (!isset($_POST['NewStockID']) || $new_item) {
        submit_center('addupdate', _("Insert New Item"), true, '', 'default');
    } else {
        submit_center_first('addupdate', _("Update Item"), '', @$_REQUEST['popup'] ? true : 'default');
        submit_return('select', get_post('stock_id'), _("Select this items and return to document entry."), 'default');
        submit('clone', _("Clone This Item"), true, '', true);
        submit('delete', _("Delete This Item"), true, '', true);
        submit_center_last('cancel', _("Cancel"), _("Cancel Edition"), 'cancel');
    }
    div_end();
}
Example #7
0
function branch_settings($selected_id)
{
    global $Mode, $num_branches;
    start_outer_table(TABLESTYLE2);
    table_section(1);
    $_POST['email'] = "";
    if ($selected_id != -1) {
        if ($Mode == 'Edit' || !isset($_POST['br_name'])) {
            //editing an existing branch
            $myrow = get_cust_branch($_POST['customer_id'], $_POST['branch_code']);
            set_focus('br_name');
            $_POST['branch_code'] = $myrow["branch_code"];
            $_POST['br_name'] = $myrow["br_name"];
            $_POST['br_ref'] = $myrow["branch_ref"];
            $_POST['br_address'] = $myrow["br_address"];
            $_POST['br_post_address'] = $myrow["br_post_address"];
            //		    $_POST['contact_name'] = $myrow["contact_name"];
            $_POST['salesman'] = $myrow["salesman"];
            $_POST['area'] = $myrow["area"];
            //		    $_POST['rep_lang'] =$myrow["rep_lang"];
            //		    $_POST['phone'] =$myrow["phone"];
            //		    $_POST['phone2'] =$myrow["phone2"];
            //		    $_POST['fax'] =$myrow["fax"];
            //		    $_POST['email'] =$myrow["email"];
            $_POST['tax_group_id'] = $myrow["tax_group_id"];
            $_POST['disable_trans'] = $myrow['disable_trans'];
            $_POST['default_location'] = $myrow["default_location"];
            $_POST['default_ship_via'] = $myrow['default_ship_via'];
            $_POST['sales_account'] = $myrow["sales_account"];
            $_POST['sales_discount_account'] = $myrow['sales_discount_account'];
            $_POST['receivables_account'] = $myrow['receivables_account'];
            $_POST['payment_discount_account'] = $myrow['payment_discount_account'];
            $_POST['group_no'] = $myrow["group_no"];
            $_POST['notes'] = $myrow["notes"];
        }
    } elseif ($Mode != 'ADD_ITEM') {
        //end of if $SelectedBranch only do the else when a new record is being entered
        $myrow = get_default_info_for_branch($_POST['customer_id']);
        //		$_POST['rep_lang'] = $myrow['rep_lang'];
        if (!$num_branches) {
            $_POST['br_name'] = $myrow["name"];
            $_POST['br_ref'] = $myrow["debtor_ref"];
            $_POST['contact_name'] = _('Main Branch');
            $_POST['br_address'] = $_POST['br_post_address'] = $myrow["address"];
        }
        $_POST['branch_code'] = "";
        if (!isset($_POST['sales_account']) || !isset($_POST['sales_discount_account'])) {
            $company_record = get_company_prefs();
            // We use the Item Sales Account as default!
            // $_POST['sales_account'] = $company_record["default_sales_act"];
            $_POST['sales_account'] = $_POST['notes'] = '';
            $_POST['sales_discount_account'] = $company_record['default_sales_discount_act'];
            $_POST['receivables_account'] = $company_record['debtors_act'];
            $_POST['payment_discount_account'] = $company_record['default_prompt_payment_act'];
        }
    }
    hidden('popup', @$_REQUEST['popup']);
    table_section_title(_("Name and Contact"));
    text_row(_("Branch Name:"), 'br_name', null, 35, 40);
    text_row(_("Branch Short Name:"), 'br_ref', null, 30, 30);
    table_section_title(_("Sales"));
    sales_persons_list_row(_("Sales Person:"), 'salesman', null);
    sales_areas_list_row(_("Sales Area:"), 'area', null);
    sales_groups_list_row(_("Sales Group:"), 'group_no', null, true);
    locations_list_row(_("Default Inventory Location:"), 'default_location', null);
    shippers_list_row(_("Default Shipping Company:"), 'default_ship_via', null);
    tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
    table_section_title(_("GL Accounts"));
    // 2006-06-14. Changed gl_al_accounts_list to have an optional all_option 'Use Item Sales Accounts'
    gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', null, false, false, true);
    gl_all_accounts_list_row(_("Sales Discount Account:"), 'sales_discount_account');
    gl_all_accounts_list_row(_("Accounts Receivable Account:"), 'receivables_account', null, true);
    gl_all_accounts_list_row(_("Prompt Payment Discount Account:"), 'payment_discount_account');
    table_section(2);
    if ($selected_id == -1) {
        table_section_title(_("General contact data"));
        text_row(_("Contact Person:"), 'contact_name', null, 35, 40);
        text_row(_("Phone Number:"), 'phone', null, 32, 30);
        text_row(_("Secondary Phone Number:"), 'phone2', null, 32, 30);
        text_row(_("Fax Number:"), 'fax', null, 32, 30);
        email_row(_("E-mail:"), 'email', null, 35, 55);
        languages_list_row(_("Document Language:"), 'rep_lang', null, _("Customer default"));
    }
    table_section_title(_("Addresses"));
    textarea_row(_("Mailing Address:"), 'br_post_address', null, 35, 4);
    textarea_row(_("Billing Address:"), 'br_address', null, 35, 4);
    textarea_row(_("General Notes:"), 'notes', null, 35, 4);
    if ($selected_id != -1) {
        yesno_list_row(_("Disable this Branch:"), 'disable_trans', null);
    }
    end_outer_table(1);
    submit_add_or_update_center($selected_id == -1, '', 'both');
}
function voucher_details($id)
{
    div_start('voucher_table');
    br();
    if (!isset($_POST['imc']) || list_updated($_POST['imc'])) {
        $imc = get_post('imc');
        $row = get_salesman_trans($imc);
        $_POST['sales'] = $row['salesman_name'];
        $_POST['invoice_no'] = $row['customized_no'];
        $_POST['client'] = $row['br_name'];
        $_POST['provision'] = $row['provision'];
        $_POST['total'] = $row['InvoiceTotal'];
    }
    div_start('detail_table');
    start_outer_table(TABLESTYLE2);
    table_section(1);
    date_row(_("Date:"), 'date');
    text_row(_("IMC: "), 'sales');
    text_row(_("Invoice No."), 'invoice_no');
    text_row(_("Client: "), 'client');
    hidden('gross', $_POST['gross']);
    table_section(2);
    amount_row(_("Commission %: "), 'provision');
    label_row(_("Gross Commission: "), price_format($_POST['netsales']));
    label_row(_("W/Tax: "), price_format($_POST['tax']));
    label_row(_("Net Commission: "), price_format($_POST['total']));
    hidden('netsales', $_POST['netsales']);
    hidden('tax', $_POST['tax']);
    hidden('total', $_POST['total']);
    submit_row('Compute', _("Compute"), '', 'default');
    hidden('br_id', $_POST['br_id']);
    hidden('discount', $_POST['discount']);
    hidden('returns', $_POST['returns']);
    end_outer_table(1);
    div_start('controls');
    if (isset($_POST['Compute'])) {
        submit_center_first('Submit', _("Create Commission Voucher"), '', 'default');
    }
    div_end();
    br();
    start_table(TABLESTYLE, "width=90%");
    $th = array(_('IMC'), _('Invoice #'), _('Date'), _('Client'), '');
    table_header($th);
    $k = 0;
    $res = get_salesman_trans($_POST['imc'], $_POST['customNum']);
    while ($myrow = db_fetch($res)) {
        alt_table_row_color($k);
        if (checkvouchexists($myrow['customized_no']) == 0) {
            if ($myrow['Voided'] == '') {
                label_cell($myrow['salesman_name']);
                label_cell($myrow['customized_no']);
                label_cell($myrow['tran_date']);
                label_cell($myrow['br_name']);
                edit_button_cell("Edit" . $myrow['customized_no'], _("Select"));
            }
        }
        end_row();
    }
    end_table(1);
    div_end();
    div_end();
    br();
}
        $cart->add_gl_item($row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']);
    }
}
$customer_error = false;
div_start('pmt_header');
start_outer_table(TABLESTYLE2, "width=80%");
// outer table
table_section(1);
date_row(_("Date:"), 'date_', '', true, 0, 0, 0, null, true);
ref_row(_("Reference:"), 'ref', '');
/*===============================MOODLEARNING===============================*/
text_row(_("Check Voucher No."), 'cv_no');
text_row(_("Check No."), 'check_num');
hidden('tno', $_GET['trans_no']);
/*======================================================================================================*/
table_section(2, "50%");
if (!isset($_POST['PayType'])) {
    if (isset($_GET['PayType'])) {
        $_POST['PayType'] = $_GET['PayType'];
    } else {
        $_POST['PayType'] = "";
    }
}
if (!isset($_POST['person_id'])) {
    if (isset($_GET['PayPerson'])) {
        $_POST['person_id'] = $_GET['PayPerson'];
    } else {
        $_POST['person_id'] = "";
    }
}
if (isset($_POST['_PayType_update'])) {