示例#1
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $category_name = db_prepare_input($_POST['category_name']);
     $sql_data_array = array('category_name' => db_prepare_input($_POST['category_name']), 'category_description' => db_prepare_input($_POST['category_description']), 'sort_order' => db_prepare_input($_POST['sort_order']));
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "category_id = " . $id);
         gen_add_audit_log(INV_TABS_LOG . TEXT_UPDATE, $category_name);
     } else {
         // Test for duplicates.
         $result = $db->Execute("select category_id from " . TABLE_INVENTORY_CATEGORIES . " where category_name = '" . $category_name . "'");
         if ($result->RecordCount() > 0) {
             $messageStack->add(INV_INFO_DELETE_ERROR, 'error');
             return false;
         }
         $sql_data_array['category_id'] = db_prepare_input($_POST['rowSeq']);
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(INV_TABS_LOG . TEXT_ADD, $category_name);
     }
     return true;
 }
示例#2
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 3) {
         $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $title = db_prepare_input($_POST['title']);
     $code = strtoupper(db_prepare_input($_POST['code']));
     $sql_data_array = array('title' => $title, 'code' => $code, 'symbol_left' => db_prepare_input($_POST['symbol_left']), 'symbol_right' => db_prepare_input($_POST['symbol_right']), 'decimal_point' => db_prepare_input($_POST['decimal_point']), 'thousands_point' => db_prepare_input($_POST['thousands_point']), 'decimal_places' => db_prepare_input($_POST['decimal_places']), 'decimal_precise' => db_prepare_input($_POST['decimal_precise']), 'value' => db_prepare_input($_POST['value']));
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "currencies_id = " . (int) $id);
         gen_add_audit_log(SETUP_LOG_CURRENCY . TEXT_UPDATE, $title);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_LOG_CURRENCY . TEXT_ADD, $title);
     }
     if (isset($_POST['default']) && $_POST['default'] == 'on') {
         // first check to see if there are any general ledger entries
         $result = $db->Execute("select id from " . TABLE_JOURNAL_MAIN . " limit 1");
         if ($result->RecordCount() > 0) {
             $messageStack->add_session(SETUP_ERROR_CANNOT_CHANGE_DEFAULT, 'error');
         } else {
             $db->Execute("update " . TABLE_CONFIGURATION . " set configuration_value = '" . db_input($code) . "'\r\n\t\t\twhere configuration_key = 'DEFAULT_CURRENCY'");
             $db->Execute("alter table " . TABLE_JOURNAL_MAIN . " \r\n\t\t\tchange `currencies_code` `currencies_code` CHAR(3) NOT NULL DEFAULT '" . db_input($code) . "'");
         }
     }
     return true;
 }
示例#3
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($_SESSION['admin_security'][SECURITY_ID_CONFIGURATION] < 2) {
         $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $tab_name = db_prepare_input($_POST['tab_name']);
     $sql_data_array = array('module_id' => 'assets', 'tab_name' => db_prepare_input($_POST['tab_name']), 'description' => db_prepare_input($_POST['description']), 'sort_order' => db_prepare_input($_POST['sort_order']));
     if ($id) {
         db_perform(TABLE_EXTRA_TABS, $sql_data_array, 'update', "id = " . $id);
         gen_add_audit_log(sprintf(EXTRA_TABS_LOG, TEXT_UPDATE), $tab_name);
     } else {
         // Test for duplicates.
         $result = $db->Execute("select id from " . TABLE_EXTRA_TABS . " where module_id='assets' and tab_name='" . $tab_name . "'");
         if ($result->RecordCount() > 0) {
             $messageStack->add(EXTRA_TABS_DELETE_ERROR, 'error');
             return false;
         }
         $sql_data_array['id'] = db_prepare_input($_POST['rowSeq']);
         db_perform(TABLE_EXTRA_TABS, $sql_data_array);
         gen_add_audit_log(sprintf(EXTRA_TABS_LOG, TEXT_ADD), $tab_name);
     }
     return true;
 }
示例#4
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     if ($_POST['subdepartment'] && !$_POST['primary_dept_id']) {
         $_POST['subdepartment'] = '0';
     }
     if (!$_POST['subdepartment']) {
         $_POST['primary_dept_id'] = '';
     }
     if ($_POST['primary_dept_id'] == $id) {
         $messageStack->add(HR_DEPARTMENT_REF_ERROR, 'error');
         $this->error = true;
         return false;
     }
     // OK to save
     $sql_data_array = array('description_short' => db_prepare_input($_POST['description_short']), 'description' => db_prepare_input($_POST['description']), 'subdepartment' => db_prepare_input($_POST['subdepartment']), 'primary_dept_id' => db_prepare_input($_POST['primary_dept_id']), 'department_type' => db_prepare_input($_POST['department_type']), 'department_inactive' => db_prepare_input($_POST['department_inactive'] ? '1' : '0'));
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "id = '" . $id . "'");
         gen_add_audit_log(HR_LOG_DEPARTMENTS . TEXT_UPDATE, $id);
     } else {
         $sql_data_array['id'] = db_prepare_input($_POST['id']);
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(HR_LOG_DEPARTMENTS . TEXT_ADD, $id);
     }
     return true;
 }
 function btn_save($id = '')
 {
     if (parent::btn_save($id = '')) {
         $sql_data_array['use_in_inventory_filter'] = db_prepare_input($_POST['use_in_inventory_filter']);
         db_perform(TABLE_EXTRA_FIELDS, $sql_data_array, 'update', "id = {$this->id}");
         return true;
     }
     return false;
 }
function validate_fiscal_year($next_fy, $next_period, $next_start_date, $num_periods = 12)
{
    global $db;
    for ($i = 0; $i < $num_periods; $i++) {
        $fy_array = array('period' => $next_period, 'fiscal_year' => $next_fy, 'start_date' => $next_start_date, 'end_date' => gen_specific_date($next_start_date, $day_offset = -1, $month_offset = 1), 'date_added' => date('Y-m-d'));
        db_perform(TABLE_ACCOUNTING_PERIODS, $fy_array, 'insert');
        $next_period++;
        $next_start_date = gen_specific_date($next_start_date, $day_offset = 0, $month_offset = 1);
    }
    return $next_period--;
}
示例#7
0
 function install($module)
 {
     global $db, $messageStack;
     $error = false;
     // load some default currency values
     $db->Execute("TRUNCATE TABLE " . TABLE_CURRENCIES);
     $currencies_list = array(array('title' => 'US Dollar', 'code' => 'USD', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2', 'decimal_precise' => '2', 'value' => 1.0, 'last_updated' => date('Y-m-d H:i:s')), array('title' => 'Euro', 'code' => 'EUR', 'symbol_left' => '', 'symbol_right' => 'EUR', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2', 'decimal_precise' => '2', 'value' => 0.75, 'last_updated' => date('Y-m-d H:i:s')));
     foreach ($currencies_list as $entry) {
         db_perform(TABLE_CURRENCIES, $entry, 'insert');
     }
     write_configure('DEFAULT_CURRENCY', 'USD');
     // Enter some data into table current status
     $db->Execute("TRUNCATE TABLE " . TABLE_CURRENT_STATUS);
     $db->Execute("insert into " . TABLE_CURRENT_STATUS . " set id = 1");
     return $error;
 }
示例#8
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $sql_data_array = array('type' => $this->type, 'description_short' => $this->description_short, 'description_long' => $this->description_long, 'account_id' => $this->account_id, 'vendor_id' => $this->vendor_id, 'tax_rate' => $this->tax_rate);
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "tax_auth_id = '" . $id . "'");
         gen_add_audit_log(SETUP_TAX_AUTHS_LOG . TEXT_UPDATE, $this->description_short);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_TAX_AUTHS_LOG . TEXT_ADD, $this->description_short);
     }
     return true;
 }
 function btn_save($id = '')
 {
     global $db, $messageStack, $coa_types_list;
     if ($this->security_id < 2) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $this->heading_only = $this->heading_only == 1 ? '1' : '0';
     $this->account_inactive = $this->account_inactive == 1 ? '1' : '0';
     if ($this->account_type == '') {
         $messageStack->add(ERROR_ACCT_TYPE_REQ, 'error');
         $this->error = true;
         return false;
     }
     if (!$this->primary_acct_id == '') {
         $result = $db->Execute("select account_type from " . $this->db_table . " where id = '" . $this->primary_acct_id . "'");
         if ($result->fields['account_type'] != $this->account_type) {
             $messageStack->add('set account_type to ' . $coa_types_list[$result->fields['account_type']]['text'] . ' this is the same as the parent', 'error');
             $this->error = true;
             return false;
         }
     }
     if ($this->heading_only == 1 && $this->rowSeq != 0) {
         // see if this was a non-heading account converted to a heading account
         $sql = "select max(debit_amount) as debit, max(credit_amount) as credit, max(beginning_balance) as beg_bal \n\t\tfrom " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " where account_id = '" . $this->id . "'";
         $result = $db->Execute($sql);
         if ($result->fields['debit'] != 0 || $result->fields['credit'] != 0 || $result->fields['beg_bal'] != 0) {
             $messageStack->add(GL_ERROR_CANT_MAKE_HEADING, 'error');
             $this->error = true;
             return false;
         }
     }
     $sql_data_array = array('description' => $this->description, 'heading_only' => $this->heading_only, 'primary_acct_id' => $this->primary_acct_id, 'account_type' => $this->account_type, 'account_inactive' => $this->account_inactive);
     if ($this->rowSeq != 0) {
         db_perform($this->db_table, $sql_data_array, 'update', "id = '" . $this->id . "'");
         gen_add_audit_log(GL_LOG_CHART_OF_ACCOUNTS . TEXT_UPDATE, $this->id);
     } else {
         $sql_data_array['id'] = $this->id;
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(GL_LOG_CHART_OF_ACCOUNTS . TEXT_ADD, $this->id);
     }
     build_and_check_account_history_records();
     // add/modify account to history table
     return true;
 }
示例#10
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $countries_name = db_prepare_input($_POST['countries_name']);
     $sql_data_array = array('countries_name' => $countries_name, 'countries_iso_code_2' => db_prepare_input($_POST['countries_iso_code_2']), 'countries_iso_code_3' => db_prepare_input($_POST['countries_iso_code_3']), 'address_format_id' => db_prepare_input($_POST['address_format_id']));
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "countries_id = " . (int) $id);
         gen_add_audit_log(SETUP_LOG_COUNTRIES . TEXT_UPDATE, $countries_name);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_LOG_COUNTRIES . TEXT_ADD, $countries_name);
     }
     return true;
 }
示例#11
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $zone_name = db_prepare_input($_POST['zone_name']);
     $sql_data_array = array('countries_iso_code_3' => db_prepare_input($_POST['countries_iso_code_3']), 'zone_code' => db_prepare_input($_POST['zone_code']), 'zone_name' => $zone_name);
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "zone_id = '" . (int) $id . "'");
         gen_add_audit_log(SETUP_ZONES_LOG . TEXT_UPDATE, $zone_name);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_ZONES_LOG . TEXT_ADD, $zone_name);
     }
     return true;
 }
示例#12
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $description_short = db_prepare_input($_POST['description_short']);
     $sql_data_array = array('description_short' => $description_short, 'description_long' => db_prepare_input($_POST['description_long']), 'cost_type' => db_prepare_input($_POST['cost_type']), 'inactive' => isset($_POST['inactive']) ? '1' : '0');
     if (!$this->id == '') {
         db_perform($this->db_table, $sql_data_array, 'update', "cost_id = '" . $this->id . "'");
         gen_add_audit_log(SETUP_PROJECT_COSTS_LOG . TEXT_UPDATE, $description_short);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_PROJECT_COSTS_LOG . TEXT_ADD, $description_short);
     }
     return true;
 }
 function btn_save($id = '')
 {
     global $db, $messageStack, $currencies;
     validate_security($this->security_id, 2);
     if ($this->gl_acct_id == '') {
         $messageStack->add(GL_SELECT_STD_CHART, 'error');
         return false;
     }
     $sql_data_array = array('description' => $this->description, 'gl_acct_id' => $this->gl_acct_id, 'bank_account' => $this->bank_account);
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "kt_id = '" . $id . "'");
         gen_add_audit_log(SETUP_TAX_AUTHS_LOG . TEXT_UPDATE, $this->description);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_TAX_AUTHS_LOG . TEXT_ADD, $this->description);
     }
     return true;
 }
示例#14
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $this->combine_rates();
     $sql_data_array = array('type' => $this->type, 'description_short' => $this->description_short, 'description_long' => $this->description_long, 'rate_accounts' => $this->rate_accounts, 'freight_taxable' => $this->freight_taxable);
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "tax_rate_id = '" . $id . "'");
         gen_add_audit_log(SETUP_TAX_RATES_LOG . TEXT_UPDATE, $this->description_short);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_TAX_RATES_LOG . TEXT_ADD, $this->description_short);
     }
     return true;
 }
示例#15
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $description = db_prepare_input($_POST['description']);
     $sql_data_array = array('description' => $description);
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "id = '" . (int) $id . "'");
         gen_add_audit_log(SETUP_DEPT_TYPES_LOG . TEXT_UPDATE, $description);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_DEPT_TYPES_LOG . TEXT_ADD, $description);
     }
     return true;
 }
示例#16
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $description_short = db_prepare_input($_POST['description_short']);
     $rate_accounts = db_prepare_input($_POST['rate_accounts']);
     $tax_auth_id_add = db_prepare_input($_POST['tax_auth_id_add']);
     $tax_auth_id_delete = db_prepare_input($_POST['tax_auth_id_delete']);
     $rate_accounts = $this->combine_rates($rate_accounts, $tax_auth_id_add, $tax_auth_id_delete);
     $sql_data_array = array('type' => $this->type, 'description_short' => $description_short, 'description_long' => db_prepare_input($_POST['description_long']), 'rate_accounts' => $rate_accounts, 'freight_taxable' => db_prepare_input($_POST['freight_taxable']));
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "tax_rate_id = '" . (int) $id . "'");
         gen_add_audit_log(SETUP_TAX_RATES_LOG . TEXT_UPDATE, $description_short);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_TAX_RATES_LOG . TEXT_ADD, $description_short);
     }
     return true;
 }
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 2) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $description = db_prepare_input($_POST['description']);
     $heading_only = isset($_POST['heading_only']) ? '1' : '0';
     $primary_acct_id = db_prepare_input($_POST['primary_acct_id']);
     $account_type = db_prepare_input($_POST['account_type']);
     $account_inactive = isset($_POST['account_inactive']) ? '1' : '0';
     if ($account_type == '') {
         $messageStack->add(ERROR_ACCT_TYPE_REQ, 'error');
         return false;
     }
     if ($heading_only && $id) {
         // see if this was a non-heading account converted to a heading account
         $sql = "select max(debit_amount) as debit, max(credit_amount) as credit, max(beginning_balance) as beg_bal \r\n\t\tfrom " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " where account_id = '" . $id . "'";
         $result = $db->Execute($sql);
         if ($result->fields['debit'] != 0 || $result->fields['credit'] != 0 || $result->fields['beg_bal'] != 0) {
             $messageStack->add(GL_ERROR_CANT_MAKE_HEADING, 'error');
             return false;
         }
     }
     $sql_data_array = array('description' => $description, 'heading_only' => $heading_only, 'primary_acct_id' => $primary_acct_id, 'account_type' => $account_type, 'account_inactive' => $account_inactive);
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "id = '" . $id . "'");
         gen_add_audit_log(GL_LOG_CHART_OF_ACCOUNTS . TEXT_UPDATE, $id);
     } else {
         $sql_data_array['id'] = db_prepare_input($_POST['id']);
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(GL_LOG_CHART_OF_ACCOUNTS . TEXT_ADD, $id);
     }
     build_and_check_account_history_records();
     // add/modify account to history table
     return true;
 }
示例#18
0
 function install($module)
 {
     global $db;
     // add field amazon_confirm
     if (!db_field_exists(TABLE_SHIPPING_LOG, 'amazon_confirm')) {
         $db->Execute("ALTER TABLE " . TABLE_SHIPPING_LOG . " ADD amazon_confirm ENUM('0', '1') NOT NULL DEFAULT '0'");
     }
     if (!db_field_exists(TABLE_INVENTORY, 'amazon')) {
         // setup new tab in table inventory
         $result = $db->Execute("SELECT id FROM " . TABLE_EXTRA_TABS . " WHERE tab_name='Amazon'");
         if ($result->RecordCount() == 0) {
             $sql_data_array = array('module_id' => 'inventory', 'tab_name' => 'Amazon', 'description' => 'Amazon Inventory Settings', 'sort_order' => '49');
             db_perform(TABLE_EXTRA_TABS, $sql_data_array);
             $tab_id = db_insert_id();
         } else {
             $tab_id = $result->fields['id'];
         }
         // setup extra fields for inventory
         $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'check_box', 'field_name' => 'amazon', 'description' => 'Add to Amazon prduct upload feed.', 'sort_order' => 50, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'check_box', 'select' => '0', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:')));
         db_perform(TABLE_EXTRA_FIELDS, $sql_data_array);
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD COLUMN amazon enum('0','1') DEFAULT '0'");
     }
 }
示例#19
0
 function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($this->security_id < 3) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $title = db_prepare_input($_POST['title']);
     $code = strtoupper(db_prepare_input($_POST['code']));
     if ($_POST['decimal_precise'] == '') {
         $_POST['decimal_precise'] = $_POST['decimal_places'];
     }
     $sql_data_array = array('title' => $title, 'code' => $code, 'symbol_left' => db_prepare_input($_POST['symbol_left']), 'symbol_right' => db_prepare_input($_POST['symbol_right']), 'decimal_point' => db_prepare_input($_POST['decimal_point']), 'thousands_point' => db_prepare_input($_POST['thousands_point']), 'decimal_places' => db_prepare_input($_POST['decimal_places']), 'decimal_precise' => db_prepare_input($_POST['decimal_precise']), 'value' => db_prepare_input($_POST['value']));
     if ($id) {
         db_perform($this->db_table, $sql_data_array, 'update', "currencies_id = " . (int) $id);
         gen_add_audit_log(SETUP_LOG_CURRENCY . TEXT_UPDATE, $title);
     } else {
         db_perform($this->db_table, $sql_data_array);
         gen_add_audit_log(SETUP_LOG_CURRENCY . TEXT_ADD, $title);
     }
     if (isset($_POST['default']) && $_POST['default'] == 'on') {
         // first check to see if there are any general ledger entries
         $result = $db->Execute("SELECT id FROM " . TABLE_JOURNAL_MAIN . " LIMIT 1");
         if ($result->RecordCount() > 0) {
             $messageStack->add(SETUP_ERROR_CANNOT_CHANGE_DEFAULT, 'error');
         } else {
             write_configure('DEFAULT_CURRENCY', db_input($code));
             db_perform($this->db_table, array('value' => 1), 'update', "code='{$code}'");
             // change default exc rate to 1
             $db->Execute("alter table " . TABLE_JOURNAL_MAIN . " \n\t\t\tchange currencies_code currencies_code CHAR(3) NOT NULL DEFAULT '" . db_input($code) . "'");
             $this->def_currency = db_input($code);
             $this->btn_update();
         }
     }
     return true;
 }
示例#20
0
 public function btn_save($id = '')
 {
     global $db, $messageStack;
     if ($_SESSION['admin_security'][SECURITY_ID_CONFIGURATION] < 2) {
         $messageStack->add(ERROR_NO_PERMISSION, 'error');
         return false;
     }
     $sql_data_array = array('module_id' => $this->module, 'tab_name' => $this->tab_name, 'description' => $this->description, 'sort_order' => $this->sort_order);
     if (!$this->id == 0) {
         db_perform(TABLE_EXTRA_TABS, $sql_data_array, 'update', "id = " . $this->id);
         gen_add_audit_log(sprintf(EXTRA_TABS_LOG, TEXT_UPDATE), $this->tab_name);
     } else {
         // Test for duplicates.
         $result = $db->Execute("select id from " . TABLE_EXTRA_TABS . " where module_id='" . $this->module . "' and tab_name='" . $this->tab_name . "'");
         if ($result->RecordCount() > 0) {
             $messageStack->add(EXTRA_TABS_DELETE_ERROR, 'error');
             $this->error = true;
             return false;
         }
         db_perform(TABLE_EXTRA_TABS, $sql_data_array);
         gen_add_audit_log(sprintf(EXTRA_TABS_LOG, TEXT_ADD), $this->tab_name);
     }
     return true;
 }
示例#21
0
 function install($module)
 {
     global $db, $messageStack;
     $error = false;
     if (!db_field_exists(TABLE_CONTACTS, 'bank_account_1')) {
         $sql = "select id from " . TABLE_EXTRA_FIELDS . " where module_id = 'contacts' and field_name = 'bank_account'";
         $result = $db->Execute($sql);
         if ($result->RecordCount() == 0) {
             $result = $db->Execute("select id from " . TABLE_EXTRA_TABS . " where module_id='contacts' and tab_name = 'import_banking'");
             if ($result->RecordCount() == 0) {
                 $entry = array('module_id' => 'contacts', 'tab_name' => 'import_banking', 'sort_order' => '100');
                 db_perform(TABLE_EXTRA_TABS, $entry, 'insert');
                 $tab_id = $db->insert_ID();
             } else {
                 $tab_id = $result->fields['id'];
             }
             $entry = array('module_id' => 'contacts', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'bank_account_1', 'description' => 'Bank Account', 'params' => 'a:4:{s:4:"type";s:4:"text";s:12:"contact_type";s:16:"customer:vendor:";s:6:"length";i:32;s:7:"default";s:0:"";}');
             db_perform(TABLE_EXTRA_FIELDS, $entry, 'insert');
             //$db->Execute("INSERT INTO " . TABLE_EXTRA_FIELDS . " VALUES ('', 'contacts', ". $tab_id .",'text', 'bank_account', 'Bank Account','c:v:', );");
             $db->Execute("ALTER TABLE " . TABLE_CONTACTS . " ADD bank_account_1 varchar(32) default NULL");
         }
     }
     return $error;
 }
示例#22
0
if ($_GET['action'] == 'process') {
    $admin_username = db_prepare_input(trim($_POST['admin_username']));
    $admin_contactname = db_prepare_input(trim($_POST['admin_contactname']));
    $admin_email = db_prepare_input($_POST['admin_email']);
    $admin_password = db_prepare_input(trim($_POST['admin_password']));
    $confirm_password = db_prepare_input(trim($_POST['confirm_password']));
    if ($validator->validateGeneral(ERROR_FIELD_ADMIN_USERNAME, $admin_username, _ERROR_FIELD_EMPTY)) {
        // check if the email avaible
        $sql_username = "******" . _TABLE_ADMINS . " WHERE admin_username='******'";
        if (db_num_rows(db_query($sql_username)) > 0) {
            // email existed
            $validator->addError(ERROR_FIELD_ADMIN_USERNAME, ERROR_ADMIN_USERNAME_NOT_AVAIABLE);
        }
    }
    $validator->validateGeneral(ERROR_FIELD_ADMIN_CONTACTNAME, $admin_contactname, _ERROR_FIELD_EMPTY);
    $validator->validateEmail(ERROR_FIELD_ADMIN_EMAIL, $admin_email, _ERROR_EMAIL_ADDRESS);
    if ($validator->validateMinLength(ERROR_FIELD_ADMIN_PASSWORD, $admin_password, 5, sprintf(_ERROR_MIN_LENGTH, 5, strlen($admin_password)))) {
        $validator->validateEqual(ERROR_FIELD_ADMIN_CONFIRM_PASSWORD, $admin_password, $confirm_password, ERROR_CONFIRM_PASSWORD);
    }
    if (count($validator->errors) == 0) {
        // create new member
        // create new admin info
        $admin_data_array = array('admin_username' => $admin_username, 'admin_contactname' => $admin_contactname, 'admin_email' => $admin_email, 'admin_password' => encrypt_password($admin_password));
        db_perform(_TABLE_ADMINS, $admin_data_array);
        tep_redirect(get_admin_link(PAGE_ADMIN_ACCOUNTS, 'pg=' . $pg));
    } else {
        postAssign($smarty);
        $smarty->assign('validerrors', $validator->errors);
    }
}
$_html_main_content = $smarty->fetch('admins/new.html');
示例#23
0
         tep_session_register('login_account_number');
         tep_session_register('login_useremail');
         // set cookies for autologin
         if ($_POST['remember_me']) {
             tep_setcookie("account_number", $account_number, time() + 60 * 60 * 24 * 100, HTTP_COOKIE_PATH, HTTP_COOKIE_DOMAIN);
             tep_setcookie("password", $login_password, time() + 60 * 60 * 24 * 100, HTTP_COOKIE_PATH, HTTP_COOKIE_DOMAIN);
         }
         $current_ip = get_client_ip();
         $mss_flag = false;
         if ($user_info['verification_status'] == 1 && $current_ip != $user_info['verification_ip']) {
             $mss_flag = true;
         }
         if ($mss_flag) {
             $verification_key = tep_create_random_value(10, 'digits');
             $signup_data_array['verification_key'] = $verification_key;
             db_perform(_TABLE_USERS, $signup_data_array, 'update', " user_id='" . $user_info['user_id'] . "' ");
             $email_info = get_email_template('VERIFYCATION_KEY');
             $msg_subject = $email_info['emailtemplate_subject'];
             $msg_content = str_replace(array('[firstname]', '[verification_key]'), array($user_info['firstname'], $verification_key), $email_info['emailtemplate_content']);
             $msg_content = html_entity_decode($msg_content);
             tep_mail($user_info['firstname'] . ' ' . $user_info['lastname'], $user_info['email'], $msg_subject, $msg_content, SITE_NAME, SITE_CONTACT_EMAIL);
         }
         if (sizeof($navigation->snapshot) > 0) {
             $origin_href = get_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
             $navigation->clear_snapshot();
             tep_redirect($origin_href, '', 'SSL');
         } else {
             tep_redirect(get_href_link(PAGE_LOGIN_CONFIRM, '', 'SSL'));
         }
     }
 } else {
示例#24
0
             $image_id = 0;
             while (true) {
                 if (!file_exists(CONTACTS_DIR_ATTACHMENTS . 'contacts_' . $cInfo->id . '_' . $image_id . '.zip')) {
                     break;
                 }
                 $image_id++;
             }
             saveUploadZip('file_name', CONTACTS_DIR_ATTACHMENTS, 'contacts_' . $cInfo->id . '_' . $image_id . '.zip');
             $attachments[$image_id] = $_FILES['file_name']['name'];
         }
         $sql_data_array = array('attachments' => sizeof($attachments) > 0 ? serialize($attachments) : '');
         db_perform(TABLE_CONTACTS, $sql_data_array, 'update', 'id = ' . $cInfo->id);
         // check for crm notes
         if ($_POST['crm_action'] != '' || $_POST['crm_note'] != '') {
             $sql_data_array = array('contact_id' => $cInfo->id, 'log_date' => $_POST['crm_date'], 'entered_by' => $_POST['crm_rep_id'], 'action' => $_POST['crm_action'], 'notes' => db_prepare_input($_POST['crm_note']));
             db_perform(TABLE_CONTACTS_LOG, $sql_data_array, 'insert');
         }
         $_REQUEST['action'] = 'main';
         break;
     }
     $_REQUEST['action'] = 'edit';
     break;
 case 'edit':
 case 'properties':
     $cInfo->getContact();
     break;
 case 'delete':
 case 'crm_delete':
     validate_security($security_level, 4);
     $short_name = gen_get_contact_name($cInfo->id);
     $temp = $cInfo->delete();
示例#25
0
 function Update()
 {
     global $db;
     $my_note = db_prepare_input($_POST['my_notes_field_0']);
     $remove_id = db_prepare_input($_POST['my_notes_rId']);
     // do nothing if no title or url entered
     if (!$remove_id && $my_note == '') {
         return;
     }
     // fetch the current params
     $result = $db->Execute("select params from " . TABLE_USERS_PROFILES . "\n\t\t  where user_id = " . $_SESSION['admin_id'] . " and menu_id = '" . $this->menu_id . "' \n\t\t  and dashboard_id = '" . $this->dashboard_id . "'");
     if ($remove_id) {
         // remove element
         $this->params = unserialize($result->fields['params']);
         $first_part = array_slice($this->params, 0, $remove_id - 1);
         $last_part = array_slice($this->params, $remove_id);
         $this->params = array_merge($first_part, $last_part);
     } elseif ($result->fields['params']) {
         // append new note and sort
         $this->params = unserialize($result->fields['params']);
         $this->params[] = $my_note;
     } else {
         // first entry
         $this->params[] = $my_note;
     }
     ksort($this->params);
     db_perform(TABLE_USERS_PROFILES, array('params' => serialize($this->params)), "update", "user_id = " . $_SESSION['admin_id'] . " and menu_id = '" . $this->menu_id . "' and dashboard_id = '" . $this->dashboard_id . "'");
 }
示例#26
0
<?php

include 'includes/admin_login_check.php';
$smarty->assign('link_new_language', get_admin_link(PAGE_LANGUAGE_NEW, tep_get_all_get_params(array('action', 'module', 'page'))));
$smarty->assign('back_link', get_admin_link(PAGE_LANGUAGES, tep_get_all_get_params(array('action', 'module', 'page'))));
$status_options = array(0 => TEXT_INACTIVE, 1 => TEXT_ACTIVE);
$smarty->assign('status_options', $status_options);
if ($_POST['action'] == 'process') {
    $language_code = db_prepare_input($_POST['language_code']);
    $validator->validateGeneral('Language Name', $language_name, _ERROR_FIELD_EMPTY);
    $validator->validateGeneral('Language Code', $language_code, _ERROR_FIELD_EMPTY);
    $validator->validateGeneral('Language Directory', $language_directory, _ERROR_FIELD_EMPTY);
    $validator->validateGeneral('Language Icon', $language_image, _ERROR_FIELD_EMPTY);
    if (count($validator->errors) == 0) {
        // create new member
        $language_data_array = array('language_code' => $language_code, 'language_name' => $language_name, 'language_directory' => $language_directory, 'language_image' => $language_image, 'language_status' => $language_status, 'sort_order' => $sort_order);
        db_perform(_TABLE_LANGUAGES, $language_data_array);
        tep_redirect(get_admin_link(PAGE_LANGUAGES, tep_get_all_get_params(array('action', 'module', 'page'))));
    } else {
        postAssign($smarty);
        $smarty->assign('validerrors', $validator->errors);
    }
}
$_html_main_content = $smarty->fetch('langs/new.html');
示例#27
0
$cID = (int) $_GET['cID'];
$smarty->assign('link_edit_currency', get_admin_link(PAGE_CURRENCY_EDIT, tep_get_all_get_params(array('action', 'module', 'page'))));
$smarty->assign('back_link', get_admin_link(PAGE_CURRENCIES, tep_get_all_get_params(array('action', 'module', 'page'))));
$status_options = array(0 => TEXT_INACTIVE, 1 => TEXT_ACTIVE);
$smarty->assign('status_options', $status_options);
if ($_POST['action'] == 'process') {
    $code = db_prepare_input($_POST['code']);
    $title = db_prepare_input($_POST['title']);
    $symbol_left = db_prepare_input($_POST['symbol_left']);
    $symbol_right = db_prepare_input($_POST['symbol_right']);
    $decimal_point = db_prepare_input($_POST['decimal_point']);
    $thousands_point = db_prepare_input($_POST['thousands_point']);
    $decimal_places = (int) $_POST['decimal_places'];
    $sort_order = (int) $_POST['sort_order'];
    $status = (int) $_POST['status'];
    $validator->validateGeneral('Currency Name', $title, _ERROR_FIELD_EMPTY);
    $validator->validateGeneral('Currency Code', $code, _ERROR_FIELD_EMPTY);
    if (count($validator->errors) == 0) {
        // create new member
        $currency_data_array = array('code' => $code, 'title' => $title, 'status' => $status, 'sort_order' => $sort_order, 'symbol_left' => $symbol_left, 'symbol_right' => $symbol_right, 'decimal_point' => $decimal_point, 'thousands_point' => $thousands_point, 'decimal_places' => $decimal_places);
        db_perform(_TABLE_CURRENCIES, $currency_data_array, 'update', "currencies_id='" . $cID . "'");
        tep_redirect(get_admin_link(PAGE_CURRENCIES, tep_get_all_get_params(array('action', 'module', 'page'))));
    } else {
        postAssign($smarty);
        $smarty->assign('validerrors', $validator->errors);
    }
} else {
    $currency_info = db_fetch_array(db_query("SELECT * FROM " . _TABLE_CURRENCIES . " WHERE currencies_id='" . $cID . "'"));
    postAssign($smarty, $currency_info);
}
$_html_main_content = $smarty->fetch('currencies/edit.html');
示例#28
0
 function buildJournalEntry()
 {
     global $messageStack, $currencies;
     // set some preliminary information
     switch (strtoupper($this->order['function'])) {
         case 'SALESINVOICEENTRY':
             define('JOURNAL_ID', 12);
             define('GL_TYPE', 'sos');
             break;
         case 'SALESORDERENTRY':
         default:
             define('JOURNAL_ID', 10);
             define('GL_TYPE', 'soo');
     }
     if ($this->order['receivables_gl_acct'] != '') {
         // see if requestor specifies a AR account else use default
         define('DEF_GL_ACCT', $this->order['receivables_gl_acct']);
     } else {
         define('DEF_GL_ACCT', AR_DEFAULT_GL_ACCT);
     }
     $account_type = 'c';
     $psOrd = new orders();
     // make the received string look like a form submission then post as usual
     $psOrd->account_type = $account_type;
     $psOrd->id = '';
     // should be null unless opening an existing purchase/receive
     $psOrd->journal_id = JOURNAL_ID;
     $psOrd->post_date = $this->order['post_date'];
     // date format should already be YYYY-MM-DD
     $psOrd->terminal_date = $this->order['post_date'];
     // make same as order date for now
     $psOrd->period = gen_calculate_period($psOrd->post_date);
     $psOrd->store_id = $this->get_account_id($this->order['store_id'], 'b');
     $psOrd->admin_id = $this->get_user_id($this->username);
     $psOrd->description = SOAP_XML_SUBMITTED_SO;
     $psOrd->gl_acct_id = DEF_GL_ACCT;
     $psOrd->freight = $currencies->clean_value(db_prepare_input($this->order['freight_total']), DEFAULT_CURRENCY);
     $psOrd->discount = $currencies->clean_value(db_prepare_input($this->order['discount_total']), DEFAULT_CURRENCY);
     $psOrd->sales_tax = db_prepare_input($this->order['tax_total']);
     $psOrd->total_amount = db_prepare_input($this->order['order_total']);
     // The order ID should be set by the submitter
     $psOrd->purchase_invoice_id = db_prepare_input($this->order['order_id']);
     $psOrd->purch_order_id = db_prepare_input($this->order['purch_order_id']);
     $psOrd->shipper_code = db_prepare_input($this->order['freight_carrier']);
     // BOF - Added by PhreeSoft for Portable Power Systems to map the shipping codes to PhreeBooks Codes
     $psOrd->shipper_code = substr($psOrd->shipper_code, 0, 16);
     switch ($psOrd->shipper_code) {
         default:
         case 'FedEx (Ground):':
             $psOrd->shipper_code = 'fedex_v7:GND';
             break;
         case 'FedEx (Ground LT':
             $psOrd->shipper_code = 'fedex_v7:GndFrt';
             break;
         case 'FedEx (Home Deli':
             $psOrd->shipper_code = 'fedex_v7:GDR';
             break;
         case 'FedEx (Express S':
             $psOrd->shipper_code = 'fedex_v7:3Dpm';
             break;
         case 'FedEx (Express 2':
             $psOrd->shipper_code = 'fedex_v7:2Dpm';
             break;
         case 'FedEx (Standard ':
             $psOrd->shipper_code = 'fedex_v7:1Dpm';
             break;
         case 'FedEx (Priority ':
             $psOrd->shipper_code = 'fedex_v7:1Dam';
             break;
         case 'UPS (Ground):':
         case 'UPS (Ground Resi':
             $psOrd->shipper_code = 'ups:GND';
             break;
         case 'UPS (3 Day Selec':
             $psOrd->shipper_code = 'ups:3Dpm';
             break;
         case 'UPS (2 Day Air):':
             $psOrd->shipper_code = 'ups:2Dpm';
             break;
         case 'UPS (Next Day PM':
             $psOrd->shipper_code = 'ups:1Dpm';
             break;
         case 'UPS (Next Day):':
             $psOrd->shipper_code = 'ups:1Dam';
             break;
         case 'FREE SHIPPING! (':
             $psOrd->shipper_code = 'usps:3Dpm';
             break;
         case 'Flat (Best Way):':
             $psOrd->shipper_code = 'usps:2Dpm';
             break;
     }
     // EOF - Added by PhreeSoft for PPS
     /* Values below are not used at this time
     		$psOrd->sales_tax_auths
     		$psOrd->terms
     		$psOrd->drop_ship = 0;
     		$psOrd->waiting = 0;
     		$psOrd->closed = 0;
     		$psOrd->subtotal
     		*/
     $psOrd->bill_add_update = 1;
     // force an address book update
     // see if the customer record exists
     $psOrd->short_name = db_prepare_input($this->order['customer']['customer_id']);
     $psOrd->ship_short_name = $psOrd->short_name;
     $result = $this->checkForCustomerExists($psOrd);
     if (!$result) {
         return false;
     }
     $psOrd->ship_add_update = $result['ship_add_update'];
     $psOrd->bill_acct_id = $result['bill_acct_id'];
     $psOrd->bill_address_id = $result['bill_address_id'];
     $psOrd->ship_acct_id = $result['ship_acct_id'];
     $psOrd->ship_address_id = $result['ship_address_id'];
     // Phreebooks requires a primary name or the order is not valid, use company name if exists, else contact name
     if ($this->order['billing']['primary_name'] == '') {
         $psOrd->bill_primary_name = $this->order['billing']['contact'];
         $psOrd->bill_contact = '';
     } else {
         $psOrd->bill_primary_name = $this->order['billing']['primary_name'];
         $psOrd->bill_contact = $this->order['billing']['contact'];
     }
     $psOrd->bill_address1 = $this->order['billing']['address1'];
     $psOrd->bill_address2 = $this->order['billing']['address2'];
     $psOrd->bill_city_town = $this->order['billing']['city_town'];
     $psOrd->bill_state_province = $this->order['billing']['state_province'];
     $psOrd->bill_postal_code = $this->order['billing']['postal_code'];
     $psOrd->bill_country_code = gen_get_country_iso_3_from_2($this->order['billing']['country_code']);
     $psOrd->bill_telephone1 = $this->order['customer']['telephone'];
     $psOrd->bill_email = $this->order['customer']['email'];
     if ($this->order['shipping']['primary_name'] == '') {
         $psOrd->ship_primary_name = $this->order['shipping']['contact'];
         $psOrd->ship_contact = '';
     } else {
         $psOrd->ship_primary_name = $this->order['shipping']['primary_name'];
         $psOrd->ship_contact = $this->order['shipping']['contact'];
     }
     $psOrd->ship_address1 = $this->order['shipping']['address1'];
     $psOrd->ship_address2 = $this->order['shipping']['address2'];
     $psOrd->ship_city_town = $this->order['shipping']['city_town'];
     $psOrd->ship_state_province = $this->order['shipping']['state_province'];
     $psOrd->ship_postal_code = $this->order['shipping']['postal_code'];
     $psOrd->ship_country_code = gen_get_country_iso_3_from_2($this->order['shipping']['country_code']);
     $psOrd->ship_telephone1 = $this->order['customer']['telephone'];
     $psOrd->ship_email = $this->order['customer']['email'];
     // check for truncation of addresses
     if (strlen($psOrd->bill_primary_name) > 32 || strlen($psOrd->bill_address1) > 32 || strlen($psOrd->ship_primary_name) > 32 || strlen($psOrd->ship_address1) > 32) {
         $messageStack->add('Either the Primary Name or Address has been truncated to fit in the PhreeBooks database field sizes. Please check source information.', 'caution');
     }
     // load the item rows
     switch (JOURNAL_ID) {
         case 12:
             $index = 'pstd';
             break;
         case 10:
         default:
             $index = 'qty';
             break;
     }
     for ($i = 0; $i < count($this->order['items']); $i++) {
         $psOrd->item_rows[] = array('gl_type' => GL_TYPE, $index => db_prepare_input($this->order['items'][$i]['quantity']), 'sku' => db_prepare_input($this->order['items'][$i]['sku']), 'desc' => db_prepare_input($this->order['items'][$i]['description']), 'price' => db_prepare_input($this->order['items'][$i]['unit_price']), 'acct' => db_prepare_input($this->order['items'][$i]['gl_acct']), 'tax' => db_prepare_input($this->order['items'][$i]['taxable']), 'total' => db_prepare_input($this->order['items'][$i]['total_price']));
     }
     // error check input
     if (!$psOrd->short_name) {
         return $this->responseXML('18', SOAP_NO_CUSTOMER_ID, 'error');
     }
     if (!$psOrd->post_date) {
         return $this->responseXML('20', SOAP_NO_POST_DATE, 'error');
     }
     if (!$psOrd->period) {
         return $this->responseXML('21', SOAP_BAD_POST_DATE, 'error');
     }
     if (!$psOrd->bill_primary_name) {
         return $this->responseXML('30', SOAP_NO_BILLING_PRIMARY_NAME, 'error');
     }
     if (ADDRESS_BOOK_CONTACT_REQUIRED && !$psOrd->bill_contact) {
         return $this->responseXML('31', SOAP_NO_BILLING_CONTACT, 'error');
     }
     if (ADDRESS_BOOK_ADDRESS1_REQUIRED && !$psOrd->bill_address1) {
         return $this->responseXML('32', SOAP_NO_BILLING_ADDRESS1, 'error');
     }
     if (ADDRESS_BOOK_ADDRESS2_REQUIRED && !$psOrd->bill_address2) {
         return $this->responseXML('33', SOAP_NO_BILLING_ADDRESS2, 'error');
     }
     if (ADDRESS_BOOK_CITY_TOWN_REQUIRED && !$psOrd->bill_city_town) {
         return $this->responseXML('34', SOAP_NO_BILLING_CITY_TOWN, 'error');
     }
     if (ADDRESS_BOOK_STATE_PROVINCE_REQUIRED && !$psOrd->bill_state_province) {
         return $this->responseXML('35', SOAP_NO_BILLING_STATE_PROVINCE, 'error');
     }
     if (ADDRESS_BOOK_POSTAL_CODE_REQUIRED && !$psOrd->bill_postal_code) {
         return $this->responseXML('36', SOAP_NO_BILLING_POSTAL_CODE, 'error');
     }
     if (!$psOrd->bill_country_code) {
         return $this->responseXML('37', SOAP_NO_BILLING_COUNTRY_CODE, 'error');
     }
     if (!$psOrd->ship_primary_name) {
         return $this->responseXML('40', SOAP_NO_SHIPPING_PRIMARY_NAME, 'error');
     }
     if (ADDRESS_BOOK_CONTACT_REQUIRED && !$psOrd->ship_contact) {
         return $this->responseXML('41', SOAP_NO_SHIPPING_CONTACT, 'error');
     }
     if (ADDRESS_BOOK_ADDRESS1_REQUIRED && !$psOrd->ship_address1) {
         return $this->responseXML('42', SOAP_NO_SHIPPING_ADDRESS1, 'error');
     }
     if (ADDRESS_BOOK_ADDRESS2_REQUIRED && !$psOrd->ship_address2) {
         return $this->responseXML('43', SOAP_NO_SHIPPING_ADDRESS2, 'error');
     }
     if (ADDRESS_BOOK_CITY_TOWN_REQUIRED && !$psOrd->ship_city_town) {
         return $this->responseXML('44', SOAP_NO_SHIPPING_CITY_TOWN, 'error');
     }
     if (ADDRESS_BOOK_STATE_PROVINCE_REQUIRED && !$psOrd->ship_state_province) {
         return $this->responseXML('45', SOAP_NO_SHIPPING_STATE_PROVINCE, 'error');
     }
     if (ADDRESS_BOOK_POSTAL_CODE_REQUIRED && !$psOrd->ship_postal_code) {
         return $this->responseXML('46', SOAP_NO_SHIPPING_POSTAL_CODE, 'error');
     }
     if (!$psOrd->ship_country_code) {
         return $this->responseXML('47', SOAP_NO_SHIPPING_COUNTRY_CODE, 'error');
     }
     // post the sales order
     //echo 'ready to post =><br />'; echo 'psOrd object = '; print_r($psOrd); echo '<br />';
     $post_success = $psOrd->post_ordr($action);
     if (!$post_success) {
         // extract the error message from the messageStack and return with error
         $text = strip_tags($messageStack->output());
         $text = preg_replace('/&nbsp;/', '', $text);
         // the &nbsp; messes up the response XML
         return $this->responseXML('90', SOAP_SO_POST_ERROR . $text, 'error');
     }
     // Begin - additional operations added by PhreeSoft for PPS
     global $db;
     if ($this->order['payment']['encval']) {
         $sql_array = array('module' => 'contacts', 'ref_1' => $psOrd->bill_acct_id, 'ref_2' => $psOrd->bill_address_id, 'hint' => $this->order['payment']['hint'], 'enc_value' => $this->order['payment']['encval']);
         $result = $db->Execute("select id from " . TABLE_DATA_SECURITY . " \r\n\t\t\t\twhere module = 'contacts' \r\n\t\t\t\tand ref_1 = '" . $psOrd->bill_acct_id . "' \r\n\t\t\t\tand ref_2 = '" . $psOrd->bill_address_id . "' \r\n\t\t\t\tand hint  = '" . $this->order['payment']['hint'] . "'");
         if ($result->RecordCount() > 0) {
             db_perform(TABLE_DATA_SECURITY, $sql_array, 'update', 'id = ' . $result->fields['id']);
         } else {
             db_perform(TABLE_DATA_SECURITY, $sql_array, 'insert');
         }
     }
     // End - additional operations added by PhreeSoft for PPS
     gen_add_audit_log(constant('AUDIT_LOG_SOAP_' . JOURNAL_ID . '_ADDED'), $psOrd->purchase_invoice_id, $psOrd->total_amount);
     $this->responseXML('0', sprintf(constant('SOAP_' . JOURNAL_ID . '_SUCCESS'), $psOrd->purchase_invoice_id), 'success');
     return true;
 }
示例#29
0
$error = false;
$sInfo = new shipment();
// load defaults
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
/***************   Act on the action request   *************************/
switch ($action) {
    case 'save':
        $sInfo->purchase_invoice_id = db_prepare_input($_POST['purchase_invoice_id']);
        $sInfo->ship_method = db_prepare_input($_POST['ship_method']);
        $sInfo->ship_date = gen_db_date_short($_POST['ship_date']);
        $sInfo->deliver_date = gen_db_date_short($_POST['deliver_date']);
        $sInfo->tracking_id = db_prepare_input($_POST['tracking_id']);
        $sInfo->cost = $currencies->clean_value($_POST['cost']);
        $temp = $db->Execute("select next_shipment_num from " . TABLE_CURRENT_STATUS);
        $sql_array = array('ref_id' => $sInfo->purchase_invoice_id, 'shipment_id' => $temp->fields['next_shipment_num'], 'carrier' => $shipping_module, 'method' => $sInfo->ship_method, 'ship_date' => $sInfo->ship_date, 'deliver_date' => $sInfo->deliver_date, 'tracking_id' => $sInfo->tracking_id, 'cost' => $sInfo->cost);
        db_perform(TABLE_SHIPPING_LOG, $sql_array, 'insert');
        $db->Execute("update " . TABLE_CURRENT_STATUS . " set next_shipment_num = next_shipment_num + 1");
        gen_add_audit_log(SHIPPING_LOG_FEDEX_LABEL_PRINTED, $sInfo->purchase_invoice_id);
        break;
    case 'delete':
        $shipment_id = db_prepare_input($_GET['sID']);
        $result = $db->Execute("select method, ship_date from " . TABLE_SHIPPING_LOG . " where shipment_id = " . (int) $shipment_id);
        $ship_method = $result->fields['method'];
        if ($result->RecordCount() == 0 || !$shipment_id) {
            $messageStack->add(SHIPPING_FEDEX_DELETE_ERROR, 'error');
            $error = true;
            break;
        }
        if ($result->fields['ship_date'] < date('Y-m-d', time())) {
            // only allow delete if shipped today or in future
            $messageStack->add(SHIPPING_FEDEX_CANNOT_DELETE, 'error');
示例#30
0
 function processInventory($upload_name)
 {
     global $coa, $db, $currencies, $messageStack;
     if (!$this->cyberParse($upload_name)) {
         return false;
     }
     $post_date = gen_specific_date(date('Y-m-d'), $day_offset = -1);
     $glEntry = new journal();
     $sku_list = array();
     $coa_list = array();
     $affected_accounts = array();
     for ($row_id = 0, $j = 2; $row_id < count($this->records); $row_id++, $j++) {
         $row = $this->records[$row_id];
         $total_amount = $currencies->clean_value($row['total_amount']);
         $qty = $currencies->clean_value($row['quantity']);
         // check for errors and report/exit if error found
         if (!gen_validate_sku($row['sku'])) {
             $messageStack->add(GL_ERROR_UPDATING_INVENTORY_STATUS . $row['sku'] . GL_BEG_BAL_ERROR_0 . $j, 'error');
             return false;
         }
         if (!in_array($row['inv_gl_acct'], $coa) || !in_array($row['gl_acct'], $coa)) {
             $messageStack->add(GL_BEG_BAL_ERROR_6 . $j, 'error');
             return false;
         }
         if ($qty == 0) {
             $messageStack->add(GL_BEG_BAL_ERROR_7 . $j, 'caution');
         } else {
             $affected_accounts[$row['inv_gl_acct']] = true;
             // need list of accounts to update history
             $affected_accounts[$row['gl_acct']] = true;
             // both credit and debit
             $sku_list[$row['sku']]['qty'] += $qty;
             // load quantity indexed by sku
             $sku_list[$row['sku']]['total'] += $total_amount;
             // load total_value indexed by sku
             $coa_list[$row['inv_gl_acct']] += $total_amount;
             // add to debit total by coa
             $coa_list[$row['gl_acct']] -= $total_amount;
             // add to credit total by coa
         }
     }
     if (is_array($sku_list)) {
         $glEntry->affected_accounts = $affected_accounts;
         // *************** START TRANSACTION *************************
         $db->transStart();
         // update inventory balances on hand
         foreach ($sku_list as $sku => $details) {
             $sql = "update " . TABLE_INVENTORY . " set quantity_on_hand = quantity_on_hand + {$details['qty']} where sku = '{$sku}'";
             $result = $db->Execute($sql);
             if ($result->AffectedRows() != 1) {
                 $messageStack->add(sprintf(GL_BEG_BAL_ERROR_8, $sku), 'error');
                 $db->transRollback();
                 return false;
             }
             $history_array = array('ref_id' => 0, 'sku' => $sku, 'qty' => $details['qty'], 'remaining' => $details['qty'], 'unit_cost' => $details['total'] / $details['qty'], 'avg_cost' => $details['total'] / $details['qty'], 'post_date' => $post_date);
             $result = db_perform(TABLE_INVENTORY_HISTORY, $history_array, 'insert');
         }
         // update chart of account beginning balances for period 1
         foreach ($coa_list as $account => $amount) {
             $sql = "update " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " set beginning_balance = beginning_balance + {$amount}\n\t\t\twhere account_id = '{$account}' and period = 1";
             $result = $db->Execute($sql);
             if ($result->AffectedRows() != 1) {
                 $messageStack->add(sprintf(GL_BEG_BAL_ERROR_9, $account), 'error');
                 $db->transRollback();
                 return false;
             }
         }
         // update the chart of accounts history through the existing periods
         if (!$glEntry->update_chart_history_periods($period = 1)) {
             if (DEBUG) {
                 $messageStack->write_debug();
             }
             return $glEntry->fail_message(GL_ERROR_UPDATE_COA_HISTORY);
         }
         $db->transCommit();
         // post the chart of account values
         if (DEBUG) {
             $messageStack->write_debug();
         }
         // *************** END TRANSACTION *************************
     }
     $this->line_count = $row_id;
     return true;
 }