Exemple #1
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();
}
Exemple #2
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();
}
Exemple #3
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();
}
Exemple #4
0
    $tagids = array();
    while ($tag = db_fetch($tags_result)) {
        $tagids[] = $tag['id'];
    }
    $_POST['account_tags'] = $tagids;
    hidden('account_code', $_POST['account_code']);
    hidden('selected_account', $selected_account);
    label_row(_("Account Code:"), $_POST['account_code']);
} else {
    if (!isset($_POST['account_code'])) {
        $_POST['account_tags'] = array();
        $_POST['account_code'] = $_POST['account_code2'] = '';
        $_POST['account_name'] = $_POST['account_type'] = '';
        $_POST['inactive'] = 0;
    }
    text_row_ex(_("Account Code:"), 'account_code', 15);
}
text_row_ex(_("Account Code 2:"), 'account_code2', 15);
text_row_ex(_("Account Name:"), 'account_name', 60);
gl_account_types_list_row(_("Account Group:"), 'account_type', null);
tag_list_row(_("Account Tags:"), 'account_tags', 5, TAG_ACCOUNT, true);
record_status_list_row(_("Account status:"), 'inactive');
end_table(1);
if ($selected_account == "") {
    submit_center('add', _("Add Account"), true, '', 'default');
} else {
    submit_center_first('update', _("Update Account"), '', 'default');
    submit_center_last('delete', _("Delete account"), '', true);
}
end_form();
end_page();
end_row();
end_table();
echo "<hr>";
if (get_post('_show_inactive_update')) {
    $Ajax->activate('role');
    set_focus('role');
}
if (find_submit('_Section')) {
    $Ajax->activate('details');
}
//-----------------------------------------------------------------------------------------------
div_start('details');
start_table(TABLESTYLE2);
text_row(_("Role name:"), 'name', null, 20, 22);
text_row(_("Role description:"), 'description', null, 50, 52);
record_status_list_row(_("Current status:"), 'inactive');
end_table(1);
start_table(TABLESTYLE, "width=40%");
$k = $j = 0;
//row colour counter
$ext = $sec = $m = -1;
foreach (sort_areas($security_areas) as $area => $parms) {
    // system setup areas are accessable only for site admins i.e.
    // admins of first registered company
    if (user_company() && ($parms[0] & 0xff00) == SS_SADMIN) {
        continue;
    }
    $newsec = $parms[0] >> 8 & 0xff;
    $newext = $parms[0] >> 16;
    if ($newsec != $sec || $newext != $ext && $newsec > 99) {
        // features set selection