Ejemplo n.º 1
0
function check_can_delete($curr)
{
    if ($curr == "") {
        return false;
    }
    // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master
    if (key_in_foreign_table($curr, 'debtors_master', 'curr_code')) {
        display_error(_("Cannot delete this currency, because customer accounts have been created referring to this currency."));
        return false;
    }
    if (key_in_foreign_table($curr, 'suppliers', 'curr_code')) {
        display_error(_("Cannot delete this currency, because supplier accounts have been created referring to this currency."));
        return false;
    }
    if ($curr == get_company_pref('curr_default')) {
        display_error(_("Cannot delete this currency, because the company preferences uses this currency."));
        return false;
    }
    // see if there are any bank accounts that use this currency
    if (key_in_foreign_table($curr, 'bank_accounts', 'bank_curr_code')) {
        display_error(_("Cannot delete this currency, because thre are bank accounts that use this currency."));
        return false;
    }
    return true;
}
Ejemplo n.º 2
0
function can_delete($selected_id)
{
    if (key_in_foreign_table($selected_id, 'tax_group_items', 'tax_type_id')) {
        display_error(_("Cannot delete this tax type because tax groups been created referring to it."));
        return false;
    }
    return true;
}
Ejemplo n.º 3
0
function can_delete($selected_id)
{
    if (key_in_foreign_table($selected_id, 'debtors_master', 'credit_status')) {
        display_error(_("Cannot delete this credit status because customer accounts have been created referring to it."));
        return false;
    }
    return true;
}
Ejemplo n.º 4
0
function check_delete($name)
{
    // check if selected profile is used by any user
    if ($name == '') {
        return 0;
    }
    // cannot delete system default profile
    return key_in_foreign_table($name, 'users', 'print_profile');
}
Ejemplo n.º 5
0
function can_delete($selected_id)
{
    if ($selected_id == "") {
        return false;
    }
    if (key_in_foreign_table($selected_id, 'chart_types', 'class_id')) {
        display_error(_("Cannot delete this account class because GL account types have been created referring to it."));
        return false;
    }
    return true;
}
Ejemplo n.º 6
0
function can_delete($selected_id)
{
    if (key_in_foreign_table($selected_id, 'stock_master', 'tax_type_id')) {
        display_error(_("Cannot delete this item tax type because items have been created referring to it."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'stock_category', 'dflt_tax_type')) {
        display_error(_("Cannot delete this item tax type because item categories have been created referring to it."));
        return false;
    }
    return true;
}
Ejemplo n.º 7
0
function can_delete($selected_id)
{
    if (key_in_foreign_table($selected_id, 'bom', 'workcentre_added')) {
        display_error(_("Cannot delete this work centre because BOMs have been created referring to it."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'wo_requirements', 'workcentre')) {
        display_error(_("Cannot delete this work centre because work order requirements have been created referring to it."));
        return false;
    }
    return true;
}
Ejemplo n.º 8
0
function can_delete($selected_id)
{
    if ($selected_id == -1) {
        return false;
    }
    if (key_in_foreign_table($selected_id, 'cust_branch', 'tax_group_id')) {
        display_error(_("Cannot delete this tax group because customer branches been created referring to it."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'suppliers', 'tax_group_id')) {
        display_error(_("Cannot delete this tax group because suppliers been created referring to it."));
        return false;
    }
    return true;
}
Ejemplo n.º 9
0
function can_delete($type)
{
    if ($type == "") {
        return false;
    }
    if (key_in_foreign_table($type, 'chart_master', 'account_type')) {
        display_error(_("Cannot delete this account group because GL accounts have been created referring to it."));
        return false;
    }
    if (key_in_foreign_table($type, 'chart_types', 'parent')) {
        display_error(_("Cannot delete this account group because GL account groups have been created referring to it."));
        return false;
    }
    return true;
}
Ejemplo n.º 10
0
function can_delete($selected_account)
{
    if ($selected_account == "") {
        return false;
    }
    if (key_in_foreign_table($selected_account, 'gl_trans', 'account')) {
        display_error(_("Cannot delete this account because transactions have been created using this account."));
        return false;
    }
    if (gl_account_in_company_defaults($selected_account)) {
        display_error(_("Cannot delete this account because it is used as one of the company default GL accounts."));
        return false;
    }
    if (key_in_foreign_table($selected_account, 'bank_accounts', 'account_code')) {
        display_error(_("Cannot delete this account because it is used by a bank account."));
        return false;
    }
    if (gl_account_in_stock_category($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more Item Categories."));
        return false;
    }
    if (gl_account_in_stock_master($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more Items."));
        return false;
    }
    if (gl_account_in_tax_types($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more Taxes."));
        return false;
    }
    if (gl_account_in_cust_branch($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more Customer Branches."));
        return false;
    }
    if (gl_account_in_suppliers($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more suppliers."));
        return false;
    }
    if (gl_account_in_quick_entry_lines($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more Quick Entry Lines."));
        return false;
    }
    return true;
}
Ejemplo n.º 11
0
function can_delete($selected_id)
{
    if (key_in_foreign_table($selected_id, 'stock_moves', 'loc_code')) {
        display_error(_("Cannot delete this location because item movements have been created using this location."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'workorders', 'loc_code')) {
        display_error(_("Cannot delete this location because it is used by some work orders records."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'cust_branch', 'default_location')) {
        display_error(_("Cannot delete this location because it is used by some branch records as the default location to deliver from."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'bom', 'loc_code')) {
        display_error(_("Cannot delete this location because it is used by some related records in other tables."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'grn_batch', 'loc_code')) {
        display_error(_("Cannot delete this location because it is used by some related records in other tables."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'purch_orders', 'into_stock_location')) {
        display_error(_("Cannot delete this location because it is used by some related records in other tables."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'sales_orders', 'from_stk_loc')) {
        display_error(_("Cannot delete this location because it is used by some related records in other tables."));
        return false;
    }
    if (key_in_foreign_table($selected_id, 'sales_pos', 'pos_location')) {
        display_error(_("Cannot delete this location because it is used by some related records in other tables."));
        return false;
    }
    return true;
}
Ejemplo n.º 12
0
    }
    if ($input_error != 1) {
        if ($selected_id != -1) {
            update_crm_category($selected_id, get_post('type'), get_post('subtype'), get_post('name'), get_post('description'));
            $note = _('Selected contact category has been updated');
        } else {
            add_crm_category(get_post('type'), get_post('subtype'), get_post('name'), get_post('description'));
            $note = _('New contact category has been added');
        }
        display_notification($note);
        $Mode = 'RESET';
    }
}
if ($Mode == 'Delete') {
    $cancel_delete = 0;
    if (key_in_foreign_table($selected_id, 'crm_relations', 'category_id')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this category because there are contacts related to it."));
    }
    if ($cancel_delete == 0) {
        delete_crm_category($selected_id);
        display_notification(_('Category has been deleted'));
    }
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
}
Ejemplo n.º 13
0
}
//----------------------------------------------------------------------------------------------
if ($Mode == 'UPDATE_ITEM' && can_process()) {
    update_shipper($selected_id, $_POST['shipper_name'], $_POST['contact'], $_POST['phone'], $_POST['phone2'], $_POST['address']);
    display_notification(_('Selected shipping company has been updated'));
    $Mode = 'RESET';
}
//----------------------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'sales_orders'
    if (key_in_foreign_table($selected_id, 'sales_orders', 'ship_via')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this shipping company because sales orders have been created using this shipper."));
    } else {
        // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtor_trans'
        if (key_in_foreign_table($selected_id, 'debtor_trans', 'ship_via')) {
            $cancel_delete = 1;
            display_error(_("Cannot delete this shipping company because invoices have been created using this shipping company."));
        } else {
            delete_shipper($selected_id);
            display_notification(_('Selected shipping company has been deleted'));
        }
    }
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
}
Ejemplo n.º 14
0
            display_notification_centered(_("The selected user has been updated."));
        } else {
            add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']), $_POST['phone'], $_POST['email'], $_POST['role_id'], $_POST['language'], $_POST['print_profile'], check_value('rep_popup'), $_POST['pos']);
            $id = db_insert_id();
            // use current user display preferences as start point for new user
            $prefs = $_SESSION['wa_current_user']->prefs->get_all();
            update_user_prefs($id, array_merge($prefs, get_post(array('print_profile', 'rep_popup' => 0, 'language'))));
            display_notification_centered(_("A new user has been added."));
        }
        $Mode = 'RESET';
    }
}
//-------------------------------------------------------------------------------------------------
if ($Mode == 'Delete' && check_csrf_token()) {
    $cancel_delete = 0;
    if (key_in_foreign_table($selected_id, 'audit_trail', 'user')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this user because entries are associated with this user."));
    }
    if ($cancel_delete == 0) {
        delete_user($selected_id);
        display_notification_centered(_("User has been deleted."));
    }
    //end if Delete group
    $Mode = 'RESET';
}
//-------------------------------------------------------------------------------------------------
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive', null);
    unset($_POST);
Ejemplo n.º 15
0
        } 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 */
            add_salesman($_POST['salesman_name'], $_POST['salesman_phone'], $_POST['salesman_fax'], $_POST['salesman_email'], input_num('provision'), input_num('break_pt'), input_num('provision2'));
        }
        if ($selected_id != -1) {
            display_notification(_('Selected sales person data have been updated'));
        } else {
            display_notification(_('New sales person data have been added'));
        }
        $Mode = 'RESET';
    }
}
if ($Mode == 'Delete') {
    //the link to delete a selected record was clicked instead of the submit button
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtors_master'
    if (key_in_foreign_table($selected_id, 'cust_branch', 'salesman')) {
        display_error(_("Cannot delete this sales-person because branches are set up referring to this sales-person - first alter the branches concerned."));
    } else {
        delete_salesman($selected_id);
        display_notification(_('Selected sales person data have been deleted'));
    }
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
}
//------------------------------------------------------------------------------------------------
$result = get_salesmen(check_value('show_inactive'));
Ejemplo n.º 16
0
            $note = _('Selected payment terms have been updated');
        } else {
            add_payment_terms($from_now, $_POST['terms'], $days);
            $note = _('New payment terms have been added');
        }
        //run the sql from either of the above possibilites
        display_notification($note);
        $Mode = 'RESET';
    }
}
if ($Mode == 'Delete') {
    // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master
    if (key_in_foreign_table($selected_id, 'debtors_master', 'payment_terms')) {
        display_error(_("Cannot delete this payment term, because customer accounts have been created referring to this term."));
    } else {
        if (key_in_foreign_table($selected_id, 'suppliers', 'payment_terms')) {
            display_error(_("Cannot delete this payment term, because supplier accounts have been created referring to this term"));
        } else {
            //only delete if used in neither customer or supplier accounts
            delete_payment_terms($selected_id);
            display_notification(_('Selected payment terms have been deleted'));
        }
    }
    //end if payment terms used in customer or supplier accounts
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
Ejemplo n.º 17
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();
}
Ejemplo n.º 18
0
    if ($input_error != 1) {
        if ($selected_id != -1) {
            update_sales_area($selected_id, $_POST['description']);
            $note = _('Selected sales area has been updated');
        } else {
            add_sales_area($_POST['description']);
            $note = _('New sales area has been added');
        }
        display_notification($note);
        $Mode = 'RESET';
    }
}
if ($Mode == 'Delete') {
    $cancel_delete = 0;
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtors_master'
    if (key_in_foreign_table($selected_id, 'cust_branch', 'area')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this area because customer branches have been created using this area."));
    }
    if ($cancel_delete == 0) {
        delete_sales_area($selected_id);
        display_notification(_('Selected sales area has been deleted'));
    }
    //end if Delete area
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
Ejemplo n.º 19
0
            add_crm_person($_POST['supp_ref'], $_POST['contact'], '', $_POST['address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], $_POST['rep_lang'], '');
            add_crm_contact('supplier', 'general', $supplier_id, db_insert_id());
            display_notification(_("A new supplier has been added."));
            $Ajax->activate('_page_body');
        }
        commit_transaction();
    }
} elseif (isset($_POST['delete']) && $_POST['delete'] != "") {
    //the link to delete a selected record was clicked instead of the submit button
    $cancel_delete = 0;
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'supp_trans' , purch_orders
    if (key_in_foreign_table($_POST['supplier_id'], 'supp_trans', 'supplier_id')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this supplier because there are transactions that refer to this supplier."));
    } else {
        if (key_in_foreign_table($_POST['supplier_id'], 'purch_orders', 'supplier_id')) {
            $cancel_delete = 1;
            display_error(_("Cannot delete the supplier record because purchase orders have been created against this supplier."));
        }
    }
    if ($cancel_delete == 0) {
        delete_supplier($_POST['supplier_id']);
        unset($_SESSION['supplier_id']);
        $supplier_id = '';
        $Ajax->activate('_page_body');
    }
    //end if Delete supplier
}
start_form();
if (db_has_suppliers()) {
    start_table(false, "", 3);
Ejemplo n.º 20
0
    display_notification(_('New sales type has been added'));
    $Mode = 'RESET';
}
//----------------------------------------------------------------------------------------------------
if ($Mode == 'UPDATE_ITEM' && can_process()) {
    update_sales_type($selected_id, $_POST['sales_type'], isset($_POST['tax_included']) ? 1 : 0, input_num('factor'));
    display_notification(_('Selected sales type has been updated'));
    $Mode = 'RESET';
}
//----------------------------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtor_trans'
    if (key_in_foreign_table($selected_id, 'debtor_trans', 'tpe')) {
        display_error(_("Cannot delete this sale type because customer transactions have been created using this sales type."));
    } else {
        if (key_in_foreign_table($selected_id, 'debtors_master', 'sales_type')) {
            display_error(_("Cannot delete this sale type because customers are currently set up to use this sales type."));
        } else {
            delete_sales_type($selected_id);
            display_notification(_('Selected sales type has been deleted'));
        }
    }
    //end if sales type used in debtor transactions or in customers set up
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
}
Ejemplo n.º 21
0
    }
    if ($input_error != 1) {
        if ($selected_id != -1) {
            update_item_category($selected_id, $_POST['description'], $_POST['tax_type_id'], $_POST['sales_account'], $_POST['cogs_account'], $_POST['inventory_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['units'], $_POST['mb_flag'], $_POST['dim1'], $_POST['dim2'], check_value('no_sale'));
            display_notification(_('Selected item category has been updated'));
        } else {
            add_item_category($_POST['description'], $_POST['tax_type_id'], $_POST['sales_account'], $_POST['cogs_account'], $_POST['inventory_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['units'], $_POST['mb_flag'], $_POST['dim1'], $_POST['dim2'], check_value('no_sale'));
            display_notification(_('New item category has been added'));
        }
        $Mode = 'RESET';
    }
}
//----------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'stock_master'
    if (key_in_foreign_table($selected_id, 'stock_master', 'category_id')) {
        display_error(_("Cannot delete this item category because items have been created using this item category."));
    } else {
        delete_item_category($selected_id);
        display_notification(_('Selected item category has been deleted'));
    }
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
}
if (list_updated('mb_flag')) {
    $Ajax->activate('details');
Ejemplo n.º 22
0
if (isset($_POST['submit'])) {
    handle_submit($selected_id);
}
//--------------------------------------------------------------------------------------------
if (isset($_POST['delete'])) {
    $cancel_delete = 0;
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtor_trans'
    if (key_in_foreign_table($selected_id, 'debtor_trans', 'debtor_no')) {
        $cancel_delete = 1;
        display_error(_("This customer cannot be deleted because there are transactions that refer to it."));
    } else {
        if (key_in_foreign_table($selected_id, 'sales_orders', 'debtor_no')) {
            $cancel_delete = 1;
            display_error(_("Cannot delete the customer record because orders have been created against it."));
        } else {
            if (key_in_foreign_table($selected_id, 'cust_branch', 'debtor_no')) {
                $cancel_delete = 1;
                display_error(_("Cannot delete this customer because there are branch records set up against it."));
                //echo "<br> There are " . $myrow[0] . " branch records relating to this customer";
            }
        }
    }
    if ($cancel_delete == 0) {
        //ie not cancelled the delete as a result of above tests
        delete_customer($selected_id);
        display_notification(_("Selected customer has been deleted."));
        unset($_POST['customer_id']);
        $selected_id = '';
        $Ajax->activate('_page_body');
    }
    //end if Delete Customer
Ejemplo n.º 23
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) || !key_in_foreign_table($selected_id, 'debtor_trans', 'debtor_no') && !key_in_foreign_table($selected_id, 'sales_orders', 'debtor_no')) {
        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();
}
Ejemplo n.º 24
0
    label_cell($myrow["bank_name"], "nowrap");
    label_cell($myrow["bank_account_number"], "nowrap");
    label_cell($myrow["bank_address"]);
    if ($myrow["dflt_curr_act"]) {
        label_cell(_("Yes"));
    } else {
        label_cell(_("No"));
    }
    inactive_control_cell($myrow["id"], $myrow["inactive"], 'bank_accounts', 'id');
    edit_button_cell("Edit" . $myrow["id"], _("Edit"));
    delete_button_cell("Delete" . $myrow["id"], _("Delete"));
    end_row();
}
inactive_control_row($th);
end_table(1);
$is_used = $selected_id != -1 && key_in_foreign_table($selected_id, 'bank_trans', 'bank_act');
start_table(TABLESTYLE2);
if ($selected_id != -1) {
    if ($Mode == 'Edit') {
        $myrow = get_bank_account($selected_id);
        $_POST['account_code'] = $myrow["account_code"];
        $_POST['account_type'] = $myrow["account_type"];
        $_POST['bank_name'] = $myrow["bank_name"];
        $_POST['bank_account_name'] = $myrow["bank_account_name"];
        $_POST['bank_account_number'] = $myrow["bank_account_number"];
        $_POST['bank_address'] = $myrow["bank_address"];
        $_POST['BankAccountCurrency'] = $myrow["bank_curr_code"];
        $_POST['dflt_curr_act'] = $myrow["dflt_curr_act"];
    }
    hidden('selected_id', $selected_id);
    hidden('account_code');
Ejemplo n.º 25
0
    } elseif (empty($_POST['host'])) {
        display_notification_centered(_("You have selected printing to server at user IP."));
    } elseif (!check_num('tout', 0, 60)) {
        $error = 1;
        display_error(_("Timeout cannot be less than zero nor longer than 60 (sec)."));
        set_focus('tout');
    }
    if ($error != 1) {
        write_printer_def($selected_id, get_post('name'), get_post('descr'), get_post('queue'), get_post('host'), input_num('port', 0), input_num('tout', 0));
        display_notification_centered($selected_id == -1 ? _('New printer definition has been created') : _('Selected printer definition has been updated'));
        $Mode = 'RESET';
    }
}
if ($Mode == 'Delete') {
    // PREVENT DELETES IF DEPENDENT RECORDS IN print_profiles
    if (key_in_foreign_table($selected_id, 'print_profiles', 'printer')) {
        display_error(_("Cannot delete this printer definition, because print profile have been created using it."));
    } else {
        delete_printer($selected_id);
        display_notification(_('Selected printer definition has been deleted'));
    }
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    unset($_POST);
}
//-------------------------------------------------------------------------------------------------
$result = get_all_printers();
start_form();
start_table(TABLESTYLE);
Ejemplo n.º 26
0
    if ($input_error != 1) {
        if ($selected_id != -1) {
            update_sales_group($selected_id, $_POST['description']);
            $note = _('Selected sales group has been updated');
        } else {
            add_sales_group($_POST['description']);
            $note = _('New sales group has been added');
        }
        display_notification($note);
        $Mode = 'RESET';
    }
}
if ($Mode == 'Delete') {
    $cancel_delete = 0;
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtors_master'
    if (key_in_foreign_table($selected_id, 'cust_branch', 'group_no')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this group because customers have been created using this group."));
    }
    if ($cancel_delete == 0) {
        delete_sales_group($selected_id);
        display_notification(_('Selected sales group has been deleted'));
    }
    //end if Delete group
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    if ($sav) {
Ejemplo n.º 27
0
}
//----------------------------------------------------------------------------------------------------
if ($Mode == 'ADD_ITEM' && can_process()) {
    add_sales_point($_POST['name'], $_POST['location'], $_POST['account'], check_value('cash'), check_value('credit'));
    display_notification(_('New point of sale has been added'));
    $Mode = 'RESET';
}
//----------------------------------------------------------------------------------------------------
if ($Mode == 'UPDATE_ITEM' && can_process()) {
    update_sales_point($selected_id, $_POST['name'], $_POST['location'], $_POST['account'], check_value('cash'), check_value('credit'));
    display_notification(_('Selected point of sale has been updated'));
    $Mode = 'RESET';
}
//----------------------------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    if (key_in_foreign_table($selected_id, 'users', 'pos')) {
        display_error(_("Cannot delete this POS because it is used in users setup."));
    } else {
        delete_sales_point($selected_id);
        display_notification(_('Selected point of sale has been deleted'));
        $Mode = 'RESET';
    }
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
}
//----------------------------------------------------------------------------------------------------
$result = get_all_sales_points(check_value('show_inactive'));