Пример #1
0
 function install($pref, $force)
 {
     global $db_version, $dflt_lang;
     $this->preconf = $this->fix_extensions();
     if (!$this->preconf) {
         return false;
     }
     if (!$this->beta) {
         // all specials below are already done on 2.3beta
         $sql = "SELECT debtor_no, payment_terms FROM {$pref}debtors_master";
         $result = db_query($sql);
         if (!$result) {
             display_error("Cannot read customers" . ':<br>' . db_error_msg($db));
             return false;
         }
         // update all sales orders and transactions with customer std payment terms
         while ($cust = db_fetch($result)) {
             $sql = "UPDATE {$pref}debtor_trans SET " . "payment_terms = '" . $cust['payment_terms'] . "' WHERE debtor_no='" . $cust['debtor_no'] . "'";
             if (db_query($sql) == false) {
                 display_error("Cannot update cust trans payment" . ':<br>' . db_error_msg($db));
                 return false;
             }
             $sql = "UPDATE {$pref}sales_orders SET " . "payment_terms = '" . $cust['payment_terms'] . "' WHERE debtor_no='" . $cust['debtor_no'] . "'";
             if (db_query($sql) == false) {
                 display_error("Cannot update sales order payment" . ':<br>' . db_error_msg($db));
                 return false;
             }
         }
         if (!$this->update_totals($pref)) {
             display_error("Cannot update order totals");
             return false;
         }
         if (!$this->update_line_relations($pref)) {
             display_error("Cannot update sales document links");
             return false;
         }
         //remove obsolete and temporary columns.
         // this have to be done here as db_import rearranges alter query order
         $dropcol = array('crm_persons' => array('tmp_id', 'tmp_class'), 'debtors_master' => array('email'), 'cust_branch' => array('phone', 'phone2', 'fax', 'email'), 'suppliers' => array('phone', 'phone2', 'fax', 'email'), 'debtor_trans' => array('trans_link'));
         foreach ($dropcol as $table => $columns) {
             foreach ($columns as $col) {
                 if (db_query("ALTER TABLE `{$pref}{$table}` DROP `{$col}`") == false) {
                     display_error("Cannot drop {$table}.{$col} column:<br>" . db_error_msg($db));
                     return false;
                 }
             }
         }
         // remove old preferences table after upgrade script has been executed
         $sql = "DROP TABLE IF EXISTS `{$pref}company`";
         if (!db_query($sql)) {
             return false;
         }
     }
     $this->update_lang_cfg();
     return update_company_prefs(array('version_id' => $db_version), $pref);
 }
Пример #2
0
function do_install()
{
    global $path_to_root, $db_connections, $def_coy, $installed_extensions, $tb_pref_counter, $dflt_lang, $installed_languages;
    $coa = $_SESSION['inst_set']['coa'];
    if (install_connect_db() && db_import($path_to_root . '/sql/' . $coa, $_SESSION['inst_set'])) {
        $con = $_SESSION['inst_set'];
        $table_prefix = $con['tbpref'];
        $def_coy = 0;
        $tb_pref_counter = 0;
        $db_connections = array(0 => array('name' => $con['name'], 'host' => $con['host'], 'dbuser' => $con['dbuser'], 'dbpassword' => $con['dbpassword'], 'dbname' => $con['dbname'], 'tbpref' => $table_prefix));
        $_SESSION['wa_current_user']->cur_con = 0;
        update_company_prefs(array('coy_name' => $con['name']));
        $admin = get_user_by_login('admin');
        update_user_prefs($admin['id'], array('language' => $con['lang'], 'password' => md5($con['pass']), 'user_id' => $con['admin']));
        if (!copy($path_to_root . "/config.default.php", $path_to_root . "/config.php")) {
            display_error(_("Cannot save system configuration file 'config.php'."));
            return false;
        }
        $err = write_config_db($table_prefix != "");
        if ($err == -1) {
            display_error(_("Cannot open 'config_db.php' configuration file."));
            return false;
        } else {
            if ($err == -2) {
                display_error(_("Cannot write to the 'config_db.php' configuration file."));
                return false;
            } else {
                if ($err == -3) {
                    display_error(_("Configuration file 'config_db.php' is not writable. Change its permissions so it is, then re-run installation step."));
                    return false;
                }
            }
        }
        // update default language
        if (file_exists($path_to_root . "/lang/installed_languages.inc")) {
            include_once $path_to_root . "/lang/installed_languages.inc";
        }
        $dflt_lang = $_POST['lang'];
        write_lang();
        return true;
    }
    return false;
}
Пример #3
0
    $grn_act = get_company_pref('grn_clearing_act');
    if (get_post('grn_clearing_act') != $grn_act && db_num_rows(get_grn_items(0, '', true))) {
        display_error(_("Before GRN Clearing Account can be changed all GRNs have to be invoiced"));
        $_POST['grn_clearing_act'] = $grn_act;
        set_focus('grn_clearing_account');
        return false;
    }
    if (!is_account_balancesheet(get_post('retained_earnings_act')) || is_account_balancesheet(get_post('profit_loss_year_act'))) {
        display_error(_("The Retained Earnings Account should be a Balance Account or the Profit and Loss Year Account should be an Expense Account (preferred the last one in the Expense Class)"));
        return false;
    }
    return true;
}
//-------------------------------------------------------------------------------------------------
if (isset($_POST['submit']) && can_process()) {
    update_company_prefs(get_post(array('retained_earnings_act', 'profit_loss_year_act', 'debtors_act', 'pyt_discount_act', 'creditors_act', 'freight_act', 'exchange_diff_act', 'bank_charge_act', 'default_sales_act', 'default_sales_discount_act', 'default_prompt_payment_act', 'default_inventory_act', 'default_cogs_act', 'default_adj_act', 'default_inv_sales_act', 'default_assembly_act', 'legal_text', 'past_due_days', 'default_workorder_required', 'default_dim_required', 'default_delivery_required', 'grn_clearing_act', 'allow_negative_stock' => 0, 'accumulate_shipping' => 0, 'po_over_receive' => 0.0, 'po_over_charge' => 0.0, 'default_credit_limit' => 0.0)));
    display_notification(_("The general GL setup has been updated."));
}
/* end of if submit */
//-------------------------------------------------------------------------------------------------
start_form();
start_outer_table(TABLESTYLE2);
table_section(1);
if (get_company_pref('grn_clearing_act') === null) {
    // available from 2.3.1, can be not defined on pre-2.4 installations
    set_company_pref('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, 0);
    refresh_sys_prefs();
}
$myrow = get_company_prefs();
$_POST['retained_earnings_act'] = $myrow["retained_earnings_act"];
$_POST['profit_loss_year_act'] = $myrow["profit_loss_year_act"];
Пример #4
0
            $result = unlink($filename);
            if (!$result) {
                display_error(_('The existing image could not be removed'));
                $input_error = 1;
            }
        }
        $_POST['coy_logo'] = "";
    }
    if ($_POST['add_pct'] == "") {
        $_POST['add_pct'] = -1;
    }
    if ($_POST['round_to'] <= 0) {
        $_POST['round_to'] = 1;
    }
    if ($input_error != 1) {
        update_company_prefs(get_post(array('coy_name', 'coy_no', 'gst_no', 'tax_prd', 'tax_last', 'postal_address', 'phone', 'fax', 'email', 'coy_logo', 'domicile', 'use_dimension', 'curr_default', 'f_year', 'no_item_list' => 0, 'no_customer_list' => 0, 'no_supplier_list' => 0, 'base_sales', 'time_zone' => 0, 'add_pct', 'round_to', 'login_tout', 'auto_curr_reval', 'bcc_email')));
        $_SESSION['wa_current_user']->timeout = $_POST['login_tout'];
        display_notification_centered(_("Company setup has been updated."));
    }
    set_focus('coy_name');
    $Ajax->activate('_page_body');
}
/* end of if submit */
//---------------------------------------------------------------------------------------------
if (get_company_pref('bcc_email') === null) {
    // available from 2.3.14, can be not defined on pre-2.4 installations
    set_company_pref('bcc_email', 'setup.company', 'varchar', 100, '');
    refresh_sys_prefs();
}
start_form(true);
$myrow = get_company_prefs();
Пример #5
0
$path_to_root = "../..";
include $path_to_root . "/includes/session.inc";
add_access_extensions();
page(_($help_context = "Paypal Import Setup"));
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/includes/ui.inc";
include_once $path_to_root . "/includes/data_checks.inc";
include_once $path_to_root . "/admin/db/company_db.inc";
//-------------------------------------------------------------------------------------------------
function can_process()
{
    return true;
}
//-------------------------------------------------------------------------------------------------
if (isset($_POST['submit']) && can_process()) {
    update_company_prefs(get_post(array('paypal_bank_id', 'paypal_create_invoices', 'paypal_sales_act', 'paypal_sales_tax_act', 'paypal_fee_act', 'paypal_shipping_act', 'paypal_insurance_act', 'paypal_withdraw_id', 'use_paypal_trn_id', 'paypal_sales_type_id', 'paypal_add_tax', 'paypal_recpt_today', 'paypal_tax_group_id', 'paypal_item_tax_id', 'paypal_tax_type_id', 'paypal_tax_included', 'paypal_name_col', 'paypal_salesman', 'paypal_area', 'paypal_location', 'paypal_shipper', 'paypal_credit_status')));
    display_notification(_("The Paypal setup has been updated."));
}
/* end of if submit */
//-------------------------------------------------------------------------------------------------
start_form();
start_outer_table(TABLESTYLE2);
table_section(1);
if (get_company_pref('paypal_bank_id') === null) {
    set_company_pref('paypal_bank_id', 'paypal.setup', 'int', 11, 0);
    refresh_sys_prefs();
}
if (get_company_pref('paypal_create_invoices') === null) {
    set_company_pref('paypal_create_invoices', 'paypal.setup', 'tinyint', 1, 0);
    refresh_sys_prefs();
}
        $errors++;
        display_error(_("The SMTP port must be a positive number."));
    }
    if (empty($_POST['smtp_username']) && $_POST['mail_type'] == 'SMTP') {
        $errors++;
        display_error(_("The SMTP username must be entered."));
    }
    if (empty($_POST['smtp_password']) && $_POST['mail_type'] == 'SMTP') {
        $errors++;
        display_error(_("The SMTP password must be entered."));
    }
    return $errors == 0;
}
//-------------------------------------------------------------------------------------------------
if (isset($_POST['submit']) && can_process()) {
    update_company_prefs(get_post(array('mail_type', 'smtp_host', 'smtp_port', 'smtp_auth', 'smtp_secure', 'smtp_username', 'smtp_password')));
    display_notification(_("The mail sending settings has been updated."));
}
/* end of if submit */
if (list_updated('mail_type')) {
    $Ajax->activate('details');
}
$prefs = get_company_prefs();
if (!isset($_POST['mail_type'])) {
    $_POST['mail_type'] = $prefs['mail_type'];
}
$_POST['smtp_host'] = $prefs['smtp_host'];
$_POST['smtp_port'] = $prefs['smtp_port'];
$_POST['smtp_secure'] = $prefs['smtp_secure'];
$_POST['smtp_username'] = $prefs['smtp_username'];
$_POST['smtp_password'] = $prefs['smtp_password'];