예제 #1
0
 function update($module)
 {
     global $db, $messageStack;
     $error = false;
     if (MODULE_CONTACTS_STATUS < 3.3) {
         $db->Execute("ALTER TABLE " . TABLE_CONTACTS . " CHANGE short_name short_name VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''");
         if (!db_table_exists(TABLE_CONTACTS_LOG)) {
             foreach ($this->tables as $table => $sql) {
                 if ($table == TABLE_CONTACTS_LOG) {
                     admin_install_tables(array($table => $sql));
                 }
             }
         }
         if (db_table_exists(DB_PREFIX . 'contacts_extra_fields')) {
             // first create a new tab
             if (!defined('SETUP_TITLE_EXTRA_FIELDS')) {
                 define('SETUP_TITLE_EXTRA_FIELDS', 'New Tab');
             }
             $updateDB = $db->Execute("insert into " . TABLE_EXTRA_TABS . " set\n\t\t  module_id = 'contacts',\n\t\t  tab_name = '" . SETUP_TITLE_EXTRA_FIELDS . "',\n\t\t  description = '" . SETUP_TITLE_EXTRA_FIELDS . "',\n\t\t  sort_order = '20'");
             $tab_id = db_insert_id();
             $result = $db->Execute("select * from " . DB_PREFIX . 'contacts_extra_fields');
             while (!$result->EOF) {
                 $params = unserialize($result->fields['params']);
                 // need to insert contact_type
                 $params['contact_type'] = $result->fields['contact_type'];
                 $updateDB = $db->Execute("insert into " . TABLE_EXTRA_FIELDS . " set\n\t\t    module_id = 'contacts',\n\t\t    tab_id = '" . $tab_id . "',\n\t\t    entry_type = '" . $result->fields['entry_type'] . "',\n\t\t    field_name = '" . $result->fields['field_name'] . "',\n\t\t    description = '" . $result->fields['description'] . "',\n\t\t    params = '" . serialize($params) . "'");
                 $result->MoveNext();
             }
             $db->Execute("DROP TABLE " . DB_PREFIX . "contacts_extra_fields");
         }
         xtra_field_sync_list('contacts', TABLE_CONTACTS);
     }
     if (MODULE_CONTACTS_STATUS < 3.5) {
         if (db_field_exists(TABLE_CURRENT_STATUS, 'next_cust_id_desc')) {
             $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_cust_id_desc");
         }
         if (db_field_exists(TABLE_CURRENT_STATUS, 'next_vend_id_desc')) {
             $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_vend_id_desc");
         }
         if (!db_field_exists(TABLE_CONTACTS, 'attachments')) {
             $db->Execute("ALTER TABLE " . TABLE_CONTACTS . " ADD attachments TEXT NOT NULL AFTER tax_id");
         }
     }
     if (MODULE_CONTACTS_STATUS < 3.7) {
         if (!db_field_exists(TABLE_CONTACTS_LOG, 'entered_by')) {
             $db->Execute("ALTER TABLE " . TABLE_CONTACTS_LOG . " ADD entered_by INT(11) NOT NULL DEFAULT '0' AFTER contact_id");
         }
     }
     if (MODULE_CONTACTS_STATUS < 3.72) {
         $db->Execute("ALTER TABLE " . TABLE_CONTACTS . " CHANGE tax_id tax_id INT(11) NOT NULL DEFAULT '-1';");
     }
     if (MODULE_CONTACTS_STATUS < 3.73) {
         if (!db_field_exists(TABLE_CONTACTS, 'contacts_level')) {
             $db->Execute("ALTER TABLE " . TABLE_CONTACTS . " ADD contacts_level CHAR(1) NOT NULL DEFAULT 'r' AFTER type;");
         }
         xtra_field_sync_list('contacts', TABLE_CONTACTS);
     }
     if (!db_field_exists(TABLE_CURRENT_STATUS, 'next_crm_id_num')) {
         $result = $db->Execute("Select MAX(short_name + 1) AS new  FROM " . TABLE_CONTACTS . " WHERE TYPE = 'i'");
         $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " ADD next_crm_id_num VARCHAR( 16 ) NOT NULL DEFAULT '" . $result->fields['new'] . "';");
     }
     if (!$error) {
         write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION'));
         $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success');
     }
     return $error;
 }
예제 #2
0
 function update($module)
 {
     global $db, $messageStack;
     foreach ($this->keys as $key => $value) {
         if (!defined($key)) {
             write_configure($key, $value);
         }
     }
     $sql = "select id from " . TABLE_EXTRA_FIELDS . " where module_id = 'contacts' and (field_name like '%bank_account%' or field_name like '%iban%')";
     $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) {
             $db->Execute("INSERT INTO " . TABLE_EXTRA_TABS . " (module_id, tab_name, sort_order) VALUES( 'contacts','import_banking','100')");
             $tab_id = $db->insert_ID();
         } else {
             $tab_id = $result->fields['id'];
         }
         $db->Execute("INSERT INTO " . TABLE_EXTRA_FIELDS . " (module_id, tab_id, entry_type, field_name, description, params) VALUES ('contacts', {$tab_id}, 'text', 'iban', 'IBAN', 'a:4:{s:4:\"type\";s:4:\"text\";s:12:\"contact_type\";s:4:\"c:v:\";s:6:\"length\";i:32;s:7:\"default\";s:0:\"\";}')");
     }
     foreach ($this->tables as $table => $sql) {
         if ($table == TABLE_IMPORT_BANK) {
             admin_install_tables(array($table => $sql));
         }
     }
     $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success');
     write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION'));
 }
예제 #3
0
    write_configure('MODULE_SHIPPING_TABLE_STATUS', '0.1');
}
if (defined('MODULE_SHIPPING_UPS_SORT_ORDER')) {
    write_configure('MODULE_SHIPPING_UPS_STATUS', '0.1');
}
if (defined('MODULE_SHIPPING_USPS_SORT_ORDER')) {
    write_configure('MODULE_SHIPPING_USPS_STATUS', '0.1');
}
// load the phreeform module
gen_pull_language('phreeform', 'admin');
require_once DIR_FS_MODULES . 'phreeform/config.php';
require_once DIR_FS_MODULES . 'phreeform/defaults.php';
require_once DIR_FS_MODULES . 'phreeform/classes/install.php';
$mInstall = new phreeform_admin();
admin_install_dirs($mInstall->dirlist, DIR_FS_MY_FILES . $_SESSION['company'] . '/');
admin_install_tables($mInstall->tables);
write_configure('MODULE_PHREEFORM_STATUS', constant('MODULE_PHREEFORM_VERSION'));
foreach ($mInstall->keys as $key => $value) {
    write_configure($key, $value);
}
$mInstall->load_reports('phreeform');
admin_add_reports('phreeform');
$mInstall->install('phreeform');
// load installed modules and build report folders
$contents = scandir(DIR_FS_MODULES);
foreach ($contents as $entry) {
    // load the configuration files to load version info
    if ($entry != '.' && $entry != '..' && is_dir(DIR_FS_MODULES . $entry)) {
        if (defined('MODULE_' . strtoupper($entry) . '_STATUS') && $entry != 'phreeform') {
            // build the directories
            gen_pull_language($entry, 'admin');
예제 #4
0
 function update($module)
 {
     global $db, $messageStack, $currencies;
     $error = false;
     if (MODULE_INVENTORY_STATUS < 3.1) {
         $tab_map = array('0' => '0');
         if (db_table_exists(DB_PREFIX . 'inventory_categories')) {
             $result = $db->Execute("select * from " . DB_PREFIX . 'inventory_categories');
             while (!$result->EOF) {
                 $updateDB = $db->Execute("insert into " . TABLE_EXTRA_TABS . " set\n\t\t\t  module_id = 'inventory',\n\t\t\t  tab_name = '" . $result->fields['category_name'] . "',\n\t\t\t  description = '" . $result->fields['category_description'] . "',\n\t\t\t  sort_order = '" . $result->fields['sort_order'] . "'");
                 $tab_map[$result->fields['category_id']] = db_insert_id();
                 $result->MoveNext();
             }
             $db->Execute("DROP TABLE " . DB_PREFIX . "inventory_categories");
         }
         if (db_table_exists(DB_PREFIX . 'inventory_categories')) {
             $result = $db->Execute("select * from " . DB_PREFIX . 'inventory_fields');
             while (!$result->EOF) {
                 $updateDB = $db->Execute("insert into " . TABLE_EXTRA_FIELDS . " set\n\t\t\t  module_id = 'inventory',\n\t\t\t  tab_id = '" . $tab_map[$result->fields['category_id']] . "',\n\t\t\t  entry_type = '" . $result->fields['entry_type'] . "',\n\t\t\t  field_name = '" . $result->fields['field_name'] . "',\n\t\t\t  description = '" . $result->fields['description'] . "',\n\t\t\t  params = '" . $result->fields['params'] . "'");
                 $result->MoveNext();
             }
             $db->Execute("DROP TABLE " . DB_PREFIX . "inventory_fields");
         }
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
     }
     if (MODULE_INVENTORY_STATUS < 3.2) {
         if (!db_field_exists(TABLE_PRICE_SHEETS, 'type')) {
             $db->Execute("ALTER TABLE " . TABLE_PRICE_SHEETS . " ADD type char(1) NOT NULL default 'c' AFTER sheet_name");
         }
         if (!db_field_exists(TABLE_INVENTORY, 'price_sheet_v')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD price_sheet_v varchar(32) default NULL AFTER price_sheet");
         }
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
     }
     if (MODULE_INVENTORY_STATUS < 3.6) {
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD INDEX ( sku )");
         if (!db_field_exists(TABLE_INVENTORY, 'attachments')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD attachments text AFTER last_journal_date");
         }
         if (!db_field_exists(TABLE_INVENTORY, 'full_price_with_tax')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD full_price_with_tax FLOAT NOT NULL DEFAULT '0' AFTER full_price");
         }
         if (!db_field_exists(TABLE_INVENTORY, 'product_margin')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD product_margin FLOAT NOT NULL DEFAULT '0' AFTER full_price_with_tax");
         }
         if (!db_field_exists(TABLE_EXTRA_FIELDS, 'use_in_inventory_filter')) {
             $db->Execute("ALTER TABLE " . TABLE_EXTRA_FIELDS . " ADD use_in_inventory_filter ENUM( '0', '1' ) NOT NULL DEFAULT '0'");
         }
         $db->Execute("alter table " . TABLE_INVENTORY . " CHANGE inactive inactive ENUM( '0', '1' ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
         $db->Execute("update " . TABLE_INVENTORY . " set inventory_type = 'ma' where inventory_type = 'as'");
         $result = $db->Execute("select * from " . TABLE_EXTRA_FIELDS . " where module_id = 'inventory'");
         while (!$result->EOF) {
             $temp = unserialize($result->fields['params']);
             switch ($result->fields['field_name']) {
                 case 'serialize':
                     $temp['inventory_type'] = 'sa:sr';
                     break;
                 case 'item_taxable':
                 case 'purch_taxable':
                 case 'item_cost':
                 case 'price_sheet':
                 case 'price_sheet_v':
                 case 'full_price':
                 case 'full_price_with_tax':
                 case 'product_margin':
                     $temp['inventory_type'] = 'ci:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
                     break;
                 case 'image_with_path':
                     $temp['inventory_type'] = 'ia:ma:mb:mi:ms:ns:sa:si:sr';
                     break;
                 case 'account_cost_of_sales':
                     $temp['inventory_type'] = 'ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
                     break;
                 case 'cost_method':
                     $temp['inventory_type'] = 'ia:ma:mb:mi:ms:ns:si';
                     break;
                 case 'item_weight':
                     $temp['inventory_type'] = 'ia:ma:mb:mi:ms:ns:sa:si:sr';
                     break;
                 case 'quantity_on_hand':
                 case 'minimum_stock_level':
                 case 'reorder_quantity':
                     $temp['inventory_type'] = 'ia:ma:mi:ns:sa:si:sr';
                     break;
                 case 'quantity_on_order':
                 case 'quantity_on_allocation':
                     $temp['inventory_type'] = 'ia:mi:sa:si:sr';
                     break;
                 case 'quantity_on_sales_order':
                     $temp['inventory_type'] = 'ia:ma:mi:sa:si:sr';
                     break;
                 case 'lead_time':
                     $temp['inventory_type'] = 'ai:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
                     break;
                 case 'upc_code':
                     $temp['inventory_type'] = 'ia:ma:mi:ns:sa:si:sr';
                     break;
                 default:
                     $temp['inventory_type'] = 'ai:ci:ds:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
             }
             $updateDB = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set params = '" . serialize($temp) . "' where id = '" . $result->fields['id'] . "'");
             $result->MoveNext();
         }
         $haystack = array('attachments', 'account_sales_income', 'item_taxable', 'purch_taxable', 'image_with_path', 'account_inventory_wage', 'account_cost_of_sales', 'cost_method', 'lead_time');
         $result = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set entry_type = 'check_box' where field_name = 'inactive'");
         $result = $db->Execute("select * from " . TABLE_EXTRA_FIELDS . " where module_id = 'inventory'");
         while (!$result->EOF) {
             $use_in_inventory_filter = '1';
             if (in_array($result->fields['field_name'], $haystack)) {
                 $use_in_inventory_filter = '0';
             }
             $updateDB = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set use_in_inventory_filter = '" . $use_in_inventory_filter . "' where id = '" . $result->fields['id'] . "'");
             $result->MoveNext();
         }
         if (!db_table_exists(TABLE_INVENTORY_PURCHASE)) {
             foreach ($this->tables as $table => $sql) {
                 if ($table == TABLE_INVENTORY_PURCHASE) {
                     admin_install_tables(array($table => $sql));
                 }
             }
             if (db_field_exists(TABLE_INVENTORY, 'purch_package_quantity')) {
                 $result = $db->Execute("insert into " . TABLE_INVENTORY_PURCHASE . " ( sku, vendor_id, description_purchase, purch_package_quantity, purch_taxable, item_cost, price_sheet_v ) select sku, vendor_id, description_purchase, purch_package_quantity, purch_taxable, item_cost, price_sheet_v  from " . TABLE_INVENTORY);
                 $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " DROP purch_package_quantity");
             } else {
                 $result = $db->Execute("insert into " . TABLE_INVENTORY_PURCHASE . " ( sku, vendor_id, description_purchase, purch_package_quantity, purch_taxable, item_cost, price_sheet_v ) select sku, vendor_id, description_purchase, 1, purch_taxable, item_cost, price_sheet_v  from " . TABLE_INVENTORY);
             }
         }
         require_once DIR_FS_MODULES . 'phreebooks/functions/phreebooks.php';
         $tax_rates = ord_calculate_tax_drop_down('c');
         $result = $db->Execute("SELECT id, item_taxable, full_price, item_cost FROM " . TABLE_INVENTORY);
         while (!$result->EOF) {
             $sql_data_array = array();
             $sql_data_array['full_price_with_tax'] = round((1 + $tax_rates[$result->fields['item_taxable']]['rate'] / 100) * $result->fields['full_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
             if ($result->fields['item_cost'] != '' && $result->fields['item_cost'] > 0) {
                 $sql_data_array['product_margin'] = round($sql_data_array['full_price_with_tax'] / $result->fields['item_cost'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
             }
             db_perform(TABLE_INVENTORY, $sql_data_array, 'update', "id = " . $result->fields['id']);
             $result->MoveNext();
         }
         mkdir(DIR_FS_MY_FILES . $_SESSION['company'] . '/inventory/attachments/', 0755, true);
     }
     if (MODULE_INVENTORY_STATUS < 3.7) {
         if (!db_field_exists(TABLE_INVENTORY_HISTORY, 'avg_cost')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY_HISTORY . " ADD avg_cost FLOAT NOT NULL DEFAULT '0' AFTER unit_cost");
             $db->Execute("UPDATE " . TABLE_INVENTORY_HISTORY . " SET avg_cost = unit_cost");
         }
         $result = $db->Execute("select id, params from " . TABLE_EXTRA_FIELDS . " where module_id = 'inventory' AND field_name = 'account_cost_of_sales'");
         $temp = unserialize($result->fields['params']);
         $temp['inventory_type'] = 'ai:ci:ds:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
         $updateDB = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set params='" . serialize($temp) . "' where id='" . $result->fields['id'] . "'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY . "\n\t\t\tCHANGE item_cost item_cost DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE full_price full_price DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE full_price_with_tax full_price_with_tax DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE product_margin product_margin DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE item_weight item_weight DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_hand quantity_on_hand DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_order quantity_on_order DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_sales_order quantity_on_sales_order DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_allocation quantity_on_allocation DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE minimum_stock_level minimum_stock_level DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE reorder_quantity reorder_quantity DOUBLE NOT NULL DEFAULT '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_ASSY_LIST . " CHANGE qty qty double NOT NULL default '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_COGS_OWED . " CHANGE qty qty double NOT NULL default '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_COGS_USAGE . " CHANGE qty qty double NOT NULL default '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_HISTORY . "\n\t\t\tCHANGE qty qty DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE remaining remaining DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE unit_cost unit_cost DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE avg_cost avg_cost DOUBLE NOT NULL DEFAULT '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_PURCHASE . "\n\t\t\tCHANGE purch_package_quantity purch_package_quantity DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE item_cost item_cost DOUBLE NOT NULL DEFAULT '0'");
     }
     if (version_compare(MODULE_INVENTORY_STATUS, '3.7.4', '<')) {
         if (!db_field_exists(TABLE_INVENTORY, 'product_markup')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " CHANGE product_margin product_markup DOUBLE NOT NULL DEFAULT '0'");
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD product_margin DOUBLE NOT NULL DEFAULT '0' AFTER product_markup");
             $db->Execute("insert into " . TABLE_EXTRA_FIELDS . " set module_id = 'inventory', tab_id = '0', entry_type = 'decimal', field_name = 'product_markup',\n\t\t\t\tdescription = 'product_markup', params = 'a:2:{s:4:\"type\";N;s:14:\"inventory_type\";s:39:\"lb:ma:ia:mb:ms:ci:ns:sa:sr:sv:mi:sf:si:\";}'");
         }
         $result = $db->Execute("SELECT i.id, i.full_price, i.item_cost, max(p.item_cost) as purchase_cost FROM " . TABLE_INVENTORY . " i left join " . TABLE_INVENTORY_PURCHASE . " p on (p.sku = i.sku) ");
         while (!$result->EOF) {
             $sql_data_array = array();
             if ($result->fields['purchase_cost'] > $result->fields['item_cost']) {
                 $sql_data_array['product_margin'] = round(($result->fields['full_price'] - $result->fields['purchase_cost']) / $result->fields['full_price'] * 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
                 db_perform(TABLE_INVENTORY, $sql_data_array, 'update', "id = " . $result->fields['id']);
             } else {
                 $sql_data_array['product_margin'] = round(($result->fields['full_price'] - $result->fields['item_cost']) / $result->fields['full_price'] * 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
                 db_perform(TABLE_INVENTORY, $sql_data_array, 'update', "id = " . $result->fields['id']);
             }
             $result->MoveNext();
         }
     }
     if (!$error) {
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
         write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION'));
         $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success');
     }
     return $error;
 }
예제 #5
0
 }
 foreach ($copy_modules as $entry) {
     require_once DIR_FS_MODULES . $entry . '/classes/install.php';
     $classname = $entry . '_admin';
     $install_mod = new $classname();
     $task = $_POST[$entry . '_action'];
     if ($entry == 'phreedom') {
         $task = 'data';
     }
     // force complete copy of phreedom module
     switch ($task) {
         case 'core':
         case 'demo':
             if (admin_install_dirs($install_mod->dirlist, DIR_FS_MY_FILES . $db_name . '/')) {
                 $error = true;
             } elseif (admin_install_tables($install_mod->tables)) {
                 // Create the tables
                 $error = true;
             } else {
                 // Load the installed module version into db
                 write_configure('MODULE_' . strtoupper($entry) . '_STATUS', constant('MODULE_' . strtoupper($entry) . '_VERSION'));
                 // Load the remaining configuration constants
                 foreach ($install_mod->keys as $key => $value) {
                     write_configure($key, $value);
                 }
                 if ($task == 'demo') {
                     if ($install_mod->load_demo()) {
                         $error = true;
                     }
                 }
                 // load demo data
예제 #6
0
 function update($module)
 {
     global $db, $messageStack;
     $error = false;
     if (MODULE_PHREEPOS_STATUS < 3.2) {
         if (!defined('PHREEPOS_RECEIPT_PRINTER_STARTING_LINE')) {
             write_configure('PHREEPOS_RECEIPT_PRINTER_STARTING_LINE', '');
         }
         if (!defined('PHREEPOS_RECEIPT_PRINTER_CLOSING_LINE')) {
             write_configure('PHREEPOS_RECEIPT_PRINTER_CLOSING_LINE', '');
         }
     }
     if (MODULE_PHREEPOS_STATUS < 3.3) {
         if (!defined('PHREEPOS_RECEIPT_PRINTER_OPEN_DRAWER')) {
             write_configure('PHREEPOS_RECEIPT_PRINTER_OPEN_DRAWER', '');
         }
         if (!defined('PHREEPOS_DISPLAY_WITH_TAX')) {
             write_configure('PHREEPOS_DISPLAY_WITH_TAX', '1');
         }
         if (!defined('PHREEPOS_DISCOUNT_OF')) {
             write_configure('PHREEPOS_DISCOUNT_OF', '0');
         }
         if (!defined('PHREEPOS_ROUNDING')) {
             write_configure('PHREEPOS_ROUNDING', '0');
         }
     }
     if (!db_table_exists(TABLE_PHREEPOS_TILLS)) {
         foreach ($this->tables as $table => $sql) {
             if ($table == TABLE_PHREEPOS_TILLS) {
                 admin_install_tables(array($table => $sql));
             }
             foreach (gen_get_store_ids() as $store) {
                 $sql_data_array = array('store_id' => $store['id'], 'gl_acct_id' => AR_SALES_RECEIPTS_ACCOUNT, 'description' => $store['text'], 'rounding_gl_acct_id' => AR_SALES_RECEIPTS_ACCOUNT, 'dif_gl_acct_id' => AR_SALES_RECEIPTS_ACCOUNT, 'printer_name' => PHREEPOS_RECEIPT_PRINTER_NAME, 'printer_starting_line' => PHREEPOS_RECEIPT_PRINTER_STARTING_LINE, 'printer_closing_line' => PHREEPOS_RECEIPT_PRINTER_CLOSING_LINE, 'printer_open_drawer' => '');
                 db_perform(TABLE_PHREEPOS_TILLS, $sql_data_array);
             }
             if (defined('PHREEPOS_RECEIPT_PRINTER_NAME')) {
                 remove_configure('PHREEPOS_RECEIPT_PRINTER_NAME');
             }
             if (defined('PHREEPOS_RECEIPT_PRINTER_STARTING_LINE')) {
                 remove_configure('PHREEPOS_RECEIPT_PRINTER_STARTING_LINE');
             }
             if (defined('PHREEPOS_RECEIPT_PRINTER_CLOSING_LINE')) {
                 remove_configure('PHREEPOS_RECEIPT_PRINTER_CLOSING_LINE');
             }
         }
     }
     foreach ($this->tables as $table => $sql) {
         if ($table == TABLE_PHREEPOS_OTHER_TRANSACTIONS) {
             admin_install_tables(array($table => $sql));
         }
     }
     if (!defined('PHREEPOS_ENABLE_DIRECT_PRINTING')) {
         write_configure('PHREEPOS_ENABLE_DIRECT_PRINTING', 0);
     }
     if (!db_field_exists(TABLE_PHREEPOS_TILLS, 'tax_id')) {
         $db->Execute("ALTER TABLE " . TABLE_PHREEPOS_TILLS . " ADD tax_id INT(11) default '-1' AFTER max_discount");
     }
     if (!$error) {
         write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION'));
         $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success');
     }
     return $error;
 }