/**
  *
  * "          ".
  *
  *           .
  *
  * @param unknown_type $uid
  */
 function intstallModule($uid)
 {
     global $application;
     $tables = TransactionTracking::getTables();
     //                                             .
     $table = 'transaction_tracking_modules';
     $columns = $tables[$table]['columns'];
     $obj =& $application->getInstance('MessageResources', modApiFunc("Modules_Manager", "getResFileByShortName", 'TT'), 'AdminZone');
     $module_name = $obj->getMessage($uid . '_name');
     $query = new DB_Insert($table);
     $query->addInsertValue($uid, $columns['module_id']);
     $query->addInsertValue($module_name, $columns['module_name']);
     $query->addInsertValue(DB_FALSE, $columns['status_active']);
     $application->db->getDB_Result($query);
     //
     $module_default_settings = TransactionTrackingInstaller::getModuleDefaultSettings($uid);
     $table = 'transaction_tracking_modules_settings';
     $columns = $tables[$table]['columns'];
     foreach ($module_default_settings as $key_name => $value) {
         $query = new DB_Insert($table);
         $query->addInsertValue($uid, $columns['module_id']);
         $query->addInsertValue($key_name, $columns['key_name']);
         $query->addInsertValue($value, $columns['value']);
         $application->db->getDB_Result($query);
     }
 }
 function install()
 {
     global $application;
     $tables = Configuration::getTables();
     $columns = $tables['store_settings']['columns'];
     $query = new DB_Insert('store_settings');
     $query->addInsertValue('enable_error_document', $columns['name']);
     $query->addInsertValue('boolean', $columns['type']);
     $query->addInsertValue('0', $columns['value']);
     $application->db->getDB_Result($query);
 }
 /**
  *                    DB_Table_Clone
  *
  * @return
  * @param array $tables
  * @
  */
 function DB_Table_Clone($APIClassName, $TableName, $NewTableName = "")
 {
     global $application;
     if (!$NewTableName) {
         $NewTableName = $TableName . "_copy";
     }
     $tables = modApiFunc($APIClassName, "getTables");
     $table = array();
     $table[$NewTableName] = $tables[$TableName];
     $query = new DB_Table_Create($table);
     $query = new DB_Insert($NewTableName);
     $query->setCopyFromTable($TableName);
     $application->db->getDB_Result($query);
 }
 function install()
 {
     global $application;
     loadCoreFile('csv_parser.php');
     $csv_parser = new CSV_Parser();
     $tables = Mod_Rewrite::getTables();
     $query = new DB_Table_Create($tables);
     $def_scheme_id = 0;
     $table = 'mr_schemes';
     $columns = $tables[$table]['columns'];
     list($flt, $Default_Schemes) = $csv_parser->parse_file(dirname(__FILE__) . "/includes/default_rewrite_schemes.csv");
     if (count($Default_Schemes) > 0) {
         foreach ($Default_Schemes as $key => $scheme) {
             $query = new DB_Insert($table);
             $query->addInsertValue($scheme["scheme_name"], $columns['scheme_name']);
             $query->addInsertValue($scheme["cat_rule_tpl"], $columns['cat_rule_tpl']);
             $query->addInsertValue($scheme["prod_rule_tpl"], $columns['prod_rule_tpl']);
             $query->addInsertValue($scheme["cms_rule_tpl"], $columns['cms_rule_tpl']);
             $application->db->getDB_Result($query);
             if ($key == 0) {
                 $def_scheme_id = $application->db->DB_Insert_Id();
             }
         }
     }
     $table = 'mr_settings';
     $columns = $tables[$table]['columns'];
     list($flt, $Default_Settings) = $csv_parser->parse_file(dirname(__FILE__) . "/includes/default_settings.csv");
     if (count($Default_Settings) > 0) {
         foreach ($Default_Settings as $key => $setting) {
             if ($setting['key'] == 'REWRITE_SCHEME') {
                 $setting['value'] = $def_scheme_id;
             }
             $query = new DB_Insert($table);
             $query->addInsertValue($setting["key"], $columns['setting_key']);
             $query->addInsertValue($setting["value"], $columns['setting_value']);
             $application->db->getDB_Result($query);
         }
     }
 }
 function addManufacturer($image_id, $manufacturer_name, $manufacturer_site_url, $manufacturer_descr, $manufacturer_status)
 {
     global $application;
     $tables = $this->getTables();
     $mnf_table = $tables['manufacturers']['columns'];
     $query = new DB_Insert('manufacturers');
     $query->addInsertValue($manufacturer_name, $mnf_table['manufacturer_name']);
     $query->addInsertValue($manufacturer_site_url, $mnf_table['manufacturer_site_url']);
     $query->addInsertValue($manufacturer_descr, $mnf_table['manufacturer_descr']);
     $query->addInsertValue($image_id, $mnf_table['manufacturer_image_id']);
     $query->addInsertValue($manufacturer_status, $mnf_table['manufacturer_active']);
     $query->addInsertValue($this->__getMaxSortOrderOfManufacturers() + 1, $mnf_table['sort_order']);
     $application->db->PrepareSQL($query);
     $application->db->DB_Exec();
     $file_id = $application->db->DB_Insert_Id();
     modApiFunc('EventsManager', 'throwEvent', 'ManufacturerAdded', $file_id);
     return $file_id;
 }
Exemplo n.º 6
0
 function INSERT_CMS_NEW_MENU_ITEM()
 {
     parent::DB_Insert('cms_menu_items');
 }
Exemplo n.º 7
0
 /**
  *
  *
  * @
  * @param
  * @return
  */
 function addAdmin($firs_name, $last_name, $e_mail, $password, $options, $need_update)
 {
     global $application;
     $tables = $this->getTables();
     $a = $tables['admin']['columns'];
     $query = new DB_Insert('admin');
     $query->addInsertValue($firs_name, $a['firstname']);
     $query->addInsertValue($last_name, $a['lastname']);
     $query->addInsertValue($e_mail, $a['email']);
     $query->addInsertValue($password, $a['password']);
     if ($need_update) {
         $query->addInsertValue(md5(""), $a['old_pass']);
     } else {
         $query->addInsertValue($password, $a['old_pass']);
     }
     $query->addInsertExpression($query->fNow(), $a['created']);
     //        $query->addInsertValue('0000-00-00', $a['modified']);
     //        $query->addInsertValue('0000-00-00', $a['logdate']);
     $query->addInsertValue('0', $a['lognum']);
     $query->addInsertValue('false', $a['remember_email']);
     $admin_options = 0;
     for ($i = 1; $i <= sizeof($options); $i++) {
         $admin_options += $options[$i] ? pow(2, $i - 1) : 0;
     }
     $query->addInsertValue($admin_options, $a['options']);
     $application->db->getDB_Result($query);
     return $application->db->DB_Insert_Id();
 }
Exemplo n.º 8
0
 function INSERT_CUSTOMER_GROUP()
 {
     parent::DB_Insert('ca_customer_groups');
 }
 /**
  * Sets up module attributes and logs it to the database.
  *
  * @param array $Settings - module settings array.
  */
 function setSettings($Settings)
 {
     global $application;
     $this->clearSettingsInDB();
     $tables = $this->getTables();
     $columns = $tables['pm_paypal_settings']['columns'];
     foreach ($Settings as $key => $value) {
         $query = new DB_Insert('pm_paypal_settings');
         $query->addInsertValue($key, $columns['key']);
         $query->addInsertValue(serialize($value), $columns['value']);
         $application->db->getDB_Result($query);
         $inserted_id = $application->db->DB_Insert_Id();
     }
 }
 function addImageToProduct($product_id, $image_path, $alt_text, $thumb_path = null)
 {
     global $application;
     $tables = $this->getTables();
     $imgs_table = $tables['pi_images']['columns'];
     // detailed image resizing
     $piSettings = modApiFunc('Product_Images', 'getSettings');
     if ($piSettings['RESIZE_DETAILED_LARGE_IMAGE'] == 'Y' && function_exists('gd_info')) {
         $image_path = modApiFunc('Product_Images', 'resizeImage', $image_path, $piSettings['DETAILED_LARGE_IMAGE_SIZE']);
     }
     $_is = getimagesize($image_path);
     $img_sizes = array('width' => $_is[0], 'height' => $_is[1], 'filesize' => filesize($image_path));
     $image_path = str_replace($application->getAppIni('PATH_IMAGES_DIR'), '', $image_path);
     $query = new DB_Insert('pi_images');
     $query->addInsertValue($product_id, $imgs_table['product_id']);
     $query->addInsertValue($image_path, $imgs_table['image_path']);
     $query->addInsertValue(serialize($img_sizes), $imgs_table['image_sizes']);
     $query->addInsertValue($_is['mime'], $imgs_table['image_mime_type']);
     $query->addMultiLangInsertValue($alt_text, $imgs_table['alt_text'], $imgs_table['image_id'], 'Product_Images');
     $query->addInsertValue($this->__getMaxSortOrderOfProductImages($product_id) + 1, $imgs_table['sort_order']);
     if ($thumb_path != null) {
         $_ts = getimagesize($thumb_path);
         $thumb_sizes = array('width' => $_ts[0], 'height' => $_ts[1], 'filesize' => filesize($thumb_path));
         $thumb_path = str_replace($application->getAppIni('PATH_IMAGES_DIR'), '', $thumb_path);
         $query->addInsertValue($thumb_path, $imgs_table['thumb_path']);
         $query->addInsertValue(serialize($thumb_sizes), $imgs_table['thumb_sizes']);
     }
     $application->db->getDB_Result($query);
     $file_id = $application->db->DB_Insert_Id();
     return $file_id;
 }
Exemplo n.º 11
0
 function addMetaToDB($params)
 {
     global $application;
     $tables = $this->getTables();
     $table = 'resource_meta';
     $columns = $tables[$table]['columns'];
     $query = new DB_Insert($table);
     $query->addInsertValue($params['shortname'], $columns['shortname']);
     $query->addInsertValue($params['filename'], $columns['filename']);
     $query->addInsertValue($params['module'], $columns['module']);
     $query->addInsertValue($params['flag'], $columns['flag']);
     $query->addInsertValue($params['md5'], $columns['md5']);
     $application->db->getDB_Result($query);
     return $application->db->DB_Insert_Id();
 }
Exemplo n.º 12
0
 function NLT_INSERT_MESSAGE()
 {
     parent::DB_Insert('newsletter_letters');
 }
Exemplo n.º 13
0
 function INSERT_INPUT_TYPE_VALUE()
 {
     parent::DB_Insert('input_type_values');
 }
Exemplo n.º 14
0
 function INSERT_REPORT_PAGE_URL()
 {
     parent::DB_Insert('reports_page_urls');
 }
 function __install_ProcessNotifications($xml_tag)
 {
     global $application;
     foreach ($xml_tag->children as $child) {
         if ($child->name == 'NOTIFICATION') {
             $_txt_content = array_map("rtrim", file(NOTIFICATIONS_INSTALL_DATA_NOTIFICATIONS_DIR . $child->attributes['TEXTFILE']));
             $ntf_action_name = $child->attributes['ACTION'];
             $ntf_action_id = $this->actions[$ntf_action_name]['id'];
             $ntf_name = array_shift($_txt_content);
             $ntf_subject = array_shift($_txt_content);
             $ntf_body = implode("\n", $_txt_content);
             //+ :             xml
             $ntf_from_email_custom_address = '';
             $ntf_from_email_code = 'EMAIL_STORE_OWNER';
             $ntf_active = 'checked';
             //-
             $query = new DB_Insert('notifications');
             $query->addInsertValue($ntf_action_id, 'notification_action_id');
             $query->addInsertValue($ntf_name, 'notification_name');
             $query->addInsertValue($ntf_subject, 'notification_subject');
             $query->addInsertValue($ntf_body, 'notification_body');
             $query->addInsertValue($ntf_from_email_custom_address, 'notification_from_email_custom_address');
             $query->addInsertValue($ntf_from_email_code, 'notification_from_email_code');
             $query->addInsertValue($ntf_active, 'notification_active');
             $application->db->PrepareSQL($query);
             $application->db->DB_Exec();
             $notification_id = $application->db->DB_Insert_Id();
             foreach ($child->children as $ntf_child) {
                 if ($ntf_child->name == 'RECIPIENTS') {
                     $query = new DB_Multiple_Insert('notification_send_to');
                     $query->setInsertFields(array('notification_id', 'email', 'email_code'));
                     $insert_array = array('notification_id' => $notification_id, 'email' => '', 'email_code' => '');
                     foreach ($ntf_child->children as $rec_child) {
                         if ($rec_child->name == 'RECIPIENT') {
                             $insert_array['email_code'] = $rec_child->attributes['CODE'];
                             $query->addInsertValuesArray($insert_array);
                         }
                     }
                     $application->db->PrepareSQL($query);
                     $application->db->DB_Exec();
                 } elseif ($ntf_child->name == 'OPTIONS') {
                     foreach ($ntf_child->children as $options_child) {
                         if ($options_child->name == 'OPTION') {
                             $option_name = $options_child->attributes['NAME'];
                             $default_value = $options_child->attributes['DEFAULT_VALUE'];
                             $option_values = $this->actions[$ntf_action_name]['options'][$option_name]['values'];
                             $query = new DB_Multiple_Insert('option_values_to_notification');
                             $query->setInsertFields(array('notification_action_option_value_id', 'notification_id', 'value'));
                             $insert_array = array('notification_action_option_value_id' => 0, 'notification_id' => $notification_id, 'value' => $default_value);
                             $_values = array();
                             foreach ($options_child->children as $option_child) {
                                 if ($option_child->name == 'VALUE') {
                                     $value_name = $option_child->attributes['NAME'];
                                     $value_value = $option_child->attributes['VALUE'];
                                     $_values[$value_name] = $value_value;
                                 }
                             }
                             foreach ($option_values as $value_name => $value_id) {
                                 $_arr = $insert_array;
                                 $_arr['notification_action_option_value_id'] = $value_id;
                                 if (array_key_exists($value_name, $_values)) {
                                     $_arr['value'] = $_values[$value_name];
                                 }
                                 $query->addInsertValuesArray($_arr);
                             }
                             $application->db->PrepareSQL($query);
                             $application->db->DB_Exec();
                         }
                     }
                 }
             }
             //                 blocktags
             $ntf_blocktags = array();
             if (array_key_exists('blocktags', $this->actions[$ntf_action_name])) {
                 $ntf_blocktags = $this->actions[$ntf_action_name]['blocktags'];
             }
             if (!empty($ntf_blocktags)) {
                 $insert_array = array('notification_blocktag_id' => 0, 'notification_id' => $notification_id, 'blocktag_body' => '');
                 $query = new DB_Multiple_Insert('notification_blocktag_bodies');
                 $query->setInsertFields(array_keys($insert_array));
                 foreach ($ntf_blocktags as $blocktag_name) {
                     $blocktag_id = $this->blocktags[$blocktag_name]['id'];
                     $blocktag_txt = $this->blocktags[$blocktag_name]['textfile'];
                     $blocktag_body = file_get_contents(NOTIFICATIONS_INSTALL_DATA_BLOCKTAGS_DIR . $blocktag_txt);
                     $_arr = $insert_array;
                     $_arr['notification_blocktag_id'] = $blocktag_id;
                     $_arr['blocktag_body'] = $blocktag_body;
                     $query->addInsertValuesArray($_arr);
                 }
                 $application->db->PrepareSQL($query);
                 $application->db->DB_Exec();
             }
         }
     }
     return;
 }
Exemplo n.º 16
0
 function insertPromoCode($PromoCodeCampaignName, $PromoCodePromoCode, $PromoCodeBIgnoreOtherDiscounts, $PromoCodeStatus, $PromoCodeMinSubtotal, $PromoCodeDiscountCost, $PromoCodeDiscountCostTypeId, $PromoCodeStartDateFYear, $PromoCodeStartDateMonth, $PromoCodeStartDateDay, $PromoCodeEndDateFYear, $PromoCodeEndDateMonth, $PromoCodeEndDateDay, $PromoCodeTimesToUse, $PromoCodeFreeShipping, $PromoCodeFreeHandling, $PromoCodeStrictCart)
 {
     global $application;
     $tables = $this->getTables();
     $tr = $tables['promo_codes_coupons_table']['columns'];
     $query = new DB_Insert('promo_codes_coupons_table');
     $PromoCodeStartDate = date("Y-m-d", mktime(0, 0, 0, $PromoCodeStartDateMonth, $PromoCodeStartDateDay, $PromoCodeStartDateFYear));
     $PromoCodeEndDate = date("Y-m-d", mktime(0, 0, 0, $PromoCodeEndDateMonth, $PromoCodeEndDateDay, $PromoCodeEndDateFYear));
     $query->addInsertValue($PromoCodeMinSubtotal, $tr['min_subtotal']);
     $query->addInsertValue($PromoCodePromoCode, $tr['promo_code']);
     $query->addInsertValue($PromoCodeCampaignName, $tr['campaign_name']);
     $query->addInsertValue($PromoCodeBIgnoreOtherDiscounts, $tr['b_ignore_other_discounts']);
     $query->addInsertValue($PromoCodeStatus, $tr['status']);
     $query->addInsertValue($PromoCodeDiscountCost, $tr['discount_cost']);
     $query->addInsertValue($PromoCodeDiscountCostTypeId, $tr['discount_cost_type_id']);
     $query->addInsertValue($PromoCodeStartDate, $tr['start_date']);
     $query->addInsertValue($PromoCodeEndDate, $tr['end_date']);
     $query->addInsertValue($PromoCodeTimesToUse, $tr['times_to_use']);
     $query->addInsertValue($PromoCodeFreeShipping, $tr['free_shipping']);
     $query->addInsertValue($PromoCodeFreeHandling, $tr['free_handling']);
     $query->addInsertValue($PromoCodeStrictCart, $tr['strict_cart']);
     $query->addInsertValue('1', $tr['categories_affected']);
     $result = $application->db->getDB_Result($query);
     return $application->db->DB_Insert_Id();
 }
 function addFsRuleInfo($params)
 {
     global $application;
     $tables = $this->getTables();
     $tr = $tables['scc_fs_rules']['columns'];
     $query = new DB_Insert('scc_fs_rules');
     $query->addInsertValue($params['FsRuleName'], $tr['rule_name']);
     $query->addInsertValue($params['FsRuleMinSubtotal'], $tr['min_subtotal']);
     $query->addInsertValue($params['FsRuleStrictCart'], $tr['dirty_cart']);
     $query->addInsertValue('1', $tr['cats']);
     $result = $application->db->getDB_Result($query);
     return $application->db->DB_Insert_Id();
 }
 /**
  * Installs the specified module in the system.
  *
  * The install() method is called statically.
  * To call other methods of this class from this method,
  * the static call is used, for example,
  * Payment_Module_Offline_CC::getTables() instead of $this->getTables()
  */
 function install()
 {
     global $application;
     $obj =& $application->getInstance('MessageResources', "payment-module-offline-messages", "AdminZone");
     $tables = Payment_Module_Offline_CC::getTables();
     $query = new DB_Table_Create($tables);
     $table = 'pm_offline_cc_settings';
     #the name of the filled table
     $columns = $tables[$table]['columns'];
     #the array of field names of the table
     $query = new DB_Insert($table);
     $query->addInsertValue(1, $columns['id']);
     $query->addInsertValue("MODULE_NAME", $columns['key']);
     $query->addInsertValue('s:' . _ml_strlen($obj->getMessage('MODULE_NAME')) . ':"' . $obj->getMessage('MODULE_NAME') . '";', $columns['value']);
     $application->db->getDB_Result($query);
     $query = new DB_Insert($table);
     $query->addInsertValue(2, $columns['id']);
     $query->addInsertValue("RSA_PUBLIC_KEY_ASC_FORMAT", $columns['key']);
     $query->addInsertValue('s:' . _ml_strlen("") . ':"' . "" . '";', $columns['value']);
     $application->db->getDB_Result($query);
     //                                RemovePersonInfoType
     //                   ,          -     CheckoutEditor
     //             PersonInfoType,         , BillingInfo, ShippingInfo,
     //  CustomerInfo, CreditCardInfo, BankAccountInfo, PaymentMethodInfo (
     //             ), ShippingMethodInfo (              ).
     //       PaymentModule'                                                 ,
     //                                     .
     //                    ,                 PersonInfoType          .
     //
     //  PersonInfoType.
     modApiFunc('EventsManager', 'addEventHandler', 'RemovePersonInfoTypeEvent', 'Payment_Module_Offline_CC', 'OnRemovePersonInfoType');
 }
 /**
  * @param $s_info shipping info of the destination
  * @param $weight weight of the package
  * @param $rates array of the shipping rates for saving
  */
 function saveRatesToCache($s_info, $weight, $rates)
 {
     if ($s_info["isMet"] == false or empty($rates)) {
         return;
     }
     $s_country = modApiFunc("Location", "getCountry", $s_info["validatedData"]["Country"]["value"]);
     $s_zipcode = $s_info["validatedData"]["Postcode"]["value"];
     $s_name = isset($s_info["validatedData"]["Firstname"]["value"]) ? $s_info["validatedData"]["Firstname"]["value"] : '';
     $s_name .= isset($s_info["validatedData"]["Lastname"]["value"]) ? $s_info["validatedData"]["Lastname"]["value"] : '';
     $hash = md5($s_country . $s_name . $s_zipcode . $weight);
     $tables = $this->getTables();
     $rc_table = $tables['sm_dsr_rates_cache']['columns'];
     global $application;
     $query = new DB_Delete('sm_dsr_rates_cache');
     $query->Where($rc_table['hash'], DB_EQ, "'{$hash}'");
     $application->db->getDB_Result($query);
     $query = new DB_Delete('sm_dsr_rates_cache');
     $query->Where($rc_table['expire'], DB_LT, time());
     $application->db->getDB_Result($query);
     foreach ($rates as $key => $rate_info) {
         $query = new DB_Insert('sm_dsr_rates_cache');
         $query->addInsertValue($hash, $rc_table["hash"]);
         $query->addInsertValue($rate_info["id"], $rc_table["method_id"]);
         $query->addInsertValue($rate_info["cost"], $rc_table["rate"]);
         $query->addInsertValue(time() + 18000, $rc_table["expire"]);
         $application->db->getDB_Result($query);
     }
     return;
 }
Exemplo n.º 20
0
 /**
  *
  *
  * @param array $cost_array -
  */
 function insertGlobalDiscountRates($rate_value_from, $rate_value_to, $rate_cost_type_id, $rate_cost)
 {
     global $application;
     $tables = $this->getTables();
     $tr = $tables['discounts_global_discount_rates_table']['columns'];
     $query = new DB_Insert('discounts_global_discount_rates_table');
     $query->addInsertValue($rate_value_from, $tr['rv_from']);
     $query->addInsertValue($rate_value_to, $tr['rv_to']);
     $query->addInsertValue($rate_cost_type_id, $tr['cost_type_id']);
     $query->addInsertValue($rate_cost, $tr['cost']);
     //        $query->addInsertValue(1 /* YES */, $tr['b_active']);
     $result = $application->db->getDB_Result($query);
 }
Exemplo n.º 21
0
/**
 * Add a new option.
 *
 * You do not need to serialize values. If the value needs to be serialized, then
 * it will be serialized before it is inserted into the database. Remember,
 * resources can not be serialized or added as an option.
 *
 * You can create options without values and then update the values later.
 * Existing options will not be updated and checks are performed
 *
 * @package Avactis
 * @subpackage Option
 * @since 4.7.5
 *
 *
 * @param string $option Name of option to add.
 * @param mixed $value Optional. Option value, can be anything.
 * @param mixed $deprecated Optional. Description. Not used anymore.
 */
function asc_add_option($option, $value = '', $deprecated = '', $autoload = 'yes')
{
    global $application;
    $option = trim($option);
    if (empty($option)) {
        return false;
    }
    $serializeVal = serialize($value);
    $result = asc_get_option($option);
    if ($result) {
        return '';
    } else {
        $tables = Configuration::getTables();
        $tr = $tables['options']['columns'];
        $query = new DB_Insert('options');
        $query->addInsertValue($option, $tr['option_name']);
        $query->addInsertValue($serializeVal, $tr['option_value']);
        $query->addInsertValue($autoload, $tr['autoload']);
        $application->db->PrepareSQL($query);
        $application->db->DB_Exec();
        /**
         * Fires after a specific option has been added.
         *
         * @since 2.5.0 As "add_option_{$name}"
         * @since 3.0.0
         *
         * @param string $option Name of the option to add.
         * @param mixed  $value  Value of the option.
         */
        do_action("asc_add_option_{$option}", $option, $value);
        return true;
    }
}
Exemplo n.º 22
0
 function INSERT_NEW_LANGUAGE()
 {
     parent::DB_Insert('multilang_active_languages');
 }
 /**
  *
  *
  * @param array $cost_array -
  */
 function insertQuantityDiscountRates($product_id, $rate_value_from, $rate_cost_type_id, $rate_cost, $membership)
 {
     global $application;
     $tables = $this->getTables();
     $tr = $tables['quantity_discounts_rates_table']['columns'];
     $query = new DB_Insert('quantity_discounts_rates_table');
     $query->addInsertValue($product_id, $tr['product_id']);
     $query->addInsertValue($rate_value_from, $tr['rv_from']);
     $query->addInsertValue($rate_cost_type_id, $tr['cost_type_id']);
     $query->addInsertValue($rate_cost, $tr['cost']);
     $query->addInsertValue($membership, $tr['customer_group_id']);
     //        $query->addInsertValue(1 /* YES */, $tr['b_active']);
     $result = $application->db->getDB_Result($query);
 }
Exemplo n.º 24
0
 function __install_ProcessSettings($tag)
 {
     global $application;
     $tables = Customer_Account::getTables();
     $settings_table = $tables['ca_settings']['columns'];
     foreach ($tag->children as $s_child) {
         if ($s_child->name == 'SETTING') {
             $key = $s_child->attributes['KEY'];
             $value = $s_child->attributes['VALUE'];
             if (preg_match("/^const\\((.+)\\)/i", $value, $matches)) {
                 $value = constant($matches[1]);
             }
             $query = new DB_Insert('ca_settings');
             $query->addInsertValue($key, $settings_table['setting_key']);
             $query->addInsertValue($value, $settings_table['setting_value']);
             $application->db->PrepareSQL($query);
             $application->db->DB_Exec();
         }
     }
 }
Exemplo n.º 25
0
 function INSERT_COLOR_SWATCH_RECORD()
 {
     parent::DB_Insert('color_swatch');
 }
Exemplo n.º 26
0
 /**
  *
  *
  * @param
  * @return
  */
 function encrypt($name, $string)
 {
     if (!$name && !$string) {
         return $string;
     }
     global $application;
     $session_id = session_id();
     $key = md5($session_id . $this->uuid());
     $tables = $this->getTables();
     $table = 'crypto_keys';
     $k = $tables[$table]['columns'];
     $query = new DB_Select();
     $query->addSelectField($k["key"], "crypto_key");
     $query->WhereValue($k["id"], DB_EQ, $session_id);
     $query->WhereAnd();
     $query->WhereValue($k["name"], DB_EQ, $name);
     $result = $application->db->getDB_Result($query);
     if (isset($result[0]['crypto_key']) && $result[0]['crypto_key']) {
         $query = new DB_Update($table);
         $query->addUpdateValue($k["key"], $key);
         $query->addUpdateValue($k['lifetime'], time() + 600);
         $query->WhereValue($k["id"], DB_EQ, $session_id);
         $query->WhereAnd();
         $query->WhereValue($k["name"], DB_EQ, $name);
         $application->db->getDB_Result($query);
     } else {
         $query = new DB_Insert($table);
         $query->addInsertValue($session_id, $k['id']);
         $query->addInsertValue($name, $k['name']);
         $query->addInsertValue($key, $k['key']);
         $query->addInsertValue(time() + 600, $k['lifetime']);
         $application->db->getDB_Result($query);
     }
     $blowfish = new Crypt_Blowfish($key);
     $encrypted_string = $blowfish->encrypt($string);
     return $encrypted_string;
 }
 function addCreditCardType($new_credit_card_type_name)
 {
     global $application;
     $short_name = preg_replace("/[^a-zA-Z0-9]/", "", $new_credit_card_type_name);
     //                            .
     $new_credit_card_type_tag = "without_validation_" . $short_name . "_" . time();
     $new_credit_card_type_sort_order = $this->generateCreditCardTypeSortOrder();
     $tables = $this->getTables();
     $table = 'credit_card_settings';
     $columns = $tables[$table]['columns'];
     $query = new DB_Insert($table);
     $query->addInsertValue($new_credit_card_type_name, $columns['name']);
     $query->addInsertValue($new_credit_card_type_tag, $columns['tag']);
     $query->addInsertValue($new_credit_card_type_sort_order, $columns['sort_order']);
     $application->db->getDB_Result($query);
 }
 function addAccount($account, $password, $aff_id = "")
 {
     global $application;
     $tables = $this->getTables();
     $customers_table = $tables['ca_customers']['columns'];
     $query = new DB_Insert('ca_customers');
     $query->addInsertValue($account, $customers_table['customer_account']);
     $query->addInsertValue(md5($password), $customers_table['customer_password']);
     $query->addInsertValue($aff_id, $customers_table['affiliate_id']);
     $query->addInsertValue(modApiFunc('MultiLang', 'getLanguage'), $customers_table['customer_lng']);
     $query->addInsertValue(modApiFunc('MultiLang', 'getLanguage'), $customers_table['notification_lng']);
     $application->db->PrepareSQL($query);
     return $application->db->DB_Exec();
 }
Exemplo n.º 29
0
 /**
  * Sets up "is_selected" in false, and also "is_active" in false in all
  * modules, except the passed in ones. It sets "is_selected" in true in all
  * passed modules,that exist in the database. It adds the modules, that don't
  * exist in the table. So that it should be specified in the inputted data
  * which data should be added as "active", and which of them shouldn't.
  *
  * Parameters have a complicated structure, because words Selected and Active
  * for modules depend: if a module is not Selected, it can't be Active.
  * And also because the status Selected/non-Selected is usually changed for
  * several modules at once. Administrator choses, which modules should be
  * Selected, which of them are non-Selected and then presses the button:
  * save the changes.
  */
 function setSelectedModules($modules, $modulesType, $b_settings_table_is_empty = false)
 {
     global $application;
     //The list of modules,which should become selected.
     $selected_modules_ids = array();
     foreach ($modules as $module_id => $module_settings) {
         $selected_modules_ids[] = "'" . $module_id . "'";
     }
     $tables = Checkout::getTables();
     $columns = $tables['checkout_pm_sm_settings']['columns'];
     $YES = "1";
     $NO = "2";
     //Sets up "is_selected" in false, and also "is_active" in false in all modules, except the passed in ones.
     if (count($selected_modules_ids) != 0) {
         $query = new DB_Update('checkout_pm_sm_settings');
         $query->addUpdateExpression($columns['status_selected_value_id'], $NO);
         $query->addUpdateExpression($columns['status_active_value_id'], $NO);
         $query->WhereField($columns['module_id'], DB_NIN, "(" . implode(",", $selected_modules_ids) . ")");
         $query->WhereAnd();
         $query->WhereValue($columns['module_group'], DB_EQ, $modulesType);
         $application->db->getDB_Result($query);
     }
     //Set "is_selected" in true, and also sort_order in all passed modules that exist in the database.
     //It adds the modules, that don't exist in the table. So that it should be specified in the inputted data
     //which data should be added as "active", and which of them shouldn't.
     //First get the list of modules, entered to the database:
     //_print($selected_modules_ids);die("full stop");
     if ($b_settings_table_is_empty === true) {
         $modules_already_in_db = array();
     } else {
         $modules_already_in_db = $this->getSelectedModules($modulesType);
     }
     foreach ($modules as $module_id => $module_settings) {
         if (!array_key_exists($module_id, $modules_already_in_db)) {
             //The module doesn't exist in the database.
             //Add module settings to the database.
             //        Checkout::getPaymentModuleInfo()       ,
             //                                   ,           isActive()
             //                      ,                               checkout_pm_sm_settings.
             $mm_info = Checkout::getInstalledModulesListData($modulesType, NULL, true);
             $m_name = "";
             foreach ($mm_info as $key => $info) {
                 if ($info->UUID == $module_settings['module_id']) {
                     $m_name = $info->name;
                     break;
                 }
             }
             $db_insert = new DB_Insert('checkout_pm_sm_settings');
             $db_insert->addInsertValue($module_settings['module_id'], $columns['module_id']);
             $db_insert->addInsertValue($m_name, $columns['module_class_name']);
             $db_insert->addInsertValue($module_settings['module_group'], $columns['module_group']);
             $db_insert->addInsertValue($NO, $columns['status_active_value_id']);
             $db_insert->addInsertValue($module_settings['b_is_selected'] === true ? $YES : $NO, $columns['status_selected_value_id']);
             $db_insert->addInsertValue($module_settings['sort_order'], $columns['sort_order']);
             $application->db->PrepareSQL($db_insert);
             //_print($modules);_print($module_settings);_print($application->db->QueryString);die;
             $application->db->DB_Exec();
             Checkout::update_pm_sm_currency_settings($module_settings['module_id'], modApiStaticFunc($m_name, "getInitialCurrencySettings"));
         } else {
             //The module exists in the database. Update sort_order and is_selected.
             $query = new DB_Update('checkout_pm_sm_settings');
             $query->addUpdateExpression($columns['status_selected_value_id'], $YES);
             $query->addUpdateExpression($columns['sort_order'], $module_settings['sort_order']);
             $query->WhereValue($columns['module_id'], DB_EQ, $module_id);
             $application->db->getDB_Result($query);
         }
     }
 }
Exemplo n.º 30
0
 /**
  * Updates order info.
  */
 function updateOrder($data)
 {
     global $application;
     $history = array();
     if (!is_array($data)) {
         return;
     }
     $tables = $this->getTables();
     $o = $tables['orders']['columns'];
     $on = $tables['order_notes']['columns'];
     $opd = $tables['order_person_data']['columns'];
     $statusChanged = array("order_status" => array(), "payment_status" => array());
     foreach ($data as $order) {
         $order_id = $order['order_id'];
         $status_id = $order['status_id'];
         $payment_status_id = $order['payment_status_id'];
         $track_id = $order['track_id'];
         $comment = $order['comment'];
         $processor_order_id = $order['processor_order_id'];
         $payment_method = $order['payment_method'];
         $shipping_method = $order['shipping_method'];
         $customer_info = $order['customer_info'];
         $billing_info = $order['billing_info'];
         $shipping_info = $order['shipping_info'];
         $bank_account_info = $order['bank_account_info'];
         $credit_card_info = $order['credit_card_info'];
         $tax_exemption = $order["tax_exemption"];
         $product_names = $order["product_names"];
         $product_prices = $order["product_prices"];
         $product_qty = $order["product_qty"];
         $product_options = $order["product_options"];
         $taxes = $order["taxes"];
         $totals = $order["order_totals"];
         # advanced order editing flag
         $adv_order_edit = false;
         if (!$this->isCorrectOrderId($order_id)) {
             continue;
         }
         # get current order info
         if (isset($order["order_totals"])) {
             $order_view_currency = $this->getOrderInfo($order_id, $totals["order_currency"]);
         }
         $order = $this->getOrderInfo($order_id, modApiFunc("Localization", "whichCurrencyToDisplayOrderIn", $order_id));
         # check if it is necessary to update status
         $update_status_id = $status_id != $order['StatusId'];
         $update_payment_status_id = $payment_status_id != $order['PaymentStatusId'];
         $update_track_id = $track_id != null && $track_id != $order['TrackId'];
         $update_processor_order_id = $processor_order_id != null && $processor_order_id != $order['PaymentProcessorOrderId'];
         $update_payment_method = $payment_method != null && $payment_method != $order['PaymentMethod'];
         $update_shipping_method = $shipping_method != null && $shipping_method != $order['ShippingMethod'];
         if ($update_status_id) {
             $statusChanged["order_status"][$order_id] = array("old_status" => $order['StatusId'], "new_status" => $status_id);
         }
         if ($update_payment_status_id) {
             $statusChanged["payment_status"][$order_id] = array("old_status" => $order['PaymentStatusId'], "new_status" => $payment_status_id);
         }
         if ($update_status_id || $update_payment_status_id || $update_track_id || $update_processor_order_id || $update_payment_method || $update_shipping_method) {
             $db_update = new DB_Update('orders');
             $db_update->addUpdateValue($o['status_id'], $status_id);
             $db_update->addUpdateValue($o['payment_status_id'], $payment_status_id);
             if ($update_track_id) {
                 $db_update->addUpdateValue($o['track_id'], $track_id);
             }
             if ($update_processor_order_id) {
                 $db_update->addUpdateValue($o['payment_processor_order_id'], $processor_order_id);
             }
             if ($update_payment_method) {
                 $db_update->addUpdateValue($o['payment_method'], $payment_method);
             }
             if ($update_shipping_method) {
                 $db_update->addUpdateValue($o['shipping_method'], $shipping_method);
             }
             $db_update->WhereValue($o['id'], DB_EQ, $order_id);
             $application->db->PrepareSQL($db_update);
             $application->db->DB_Exec();
         }
         #  check if it is necessary to update Customer Info
         $update_customer_info = false;
         if (is_array($customer_info)) {
             foreach ($order['Customer']['attr'] as $tag => $attr) {
                 if (array_key_exists($tag, $customer_info) && trim($attr['value']) != trim($customer_info[$tag])) {
                     $update_customer_info = true;
                     $db_update = new DB_Update('order_person_data');
                     $db_update->addUpdateValue($opd['value'], $customer_info[$tag]);
                     $db_update->WhereValue($opd['id'], DB_EQ, $attr['id']);
                     $application->db->PrepareSQL($db_update);
                     $application->db->DB_Exec();
                 }
             }
         }
         #  check if it is necessary to update Billing Info
         $update_billing_info = false;
         if (is_array($billing_info)) {
             foreach ($order['Billing']['attr'] as $tag => $attr) {
                 if (array_key_exists($tag, $billing_info) && trim($attr['value']) != trim($billing_info[$tag])) {
                     $update_billing_info = true;
                     $db_update = new DB_Update('order_person_data');
                     $db_update->addUpdateValue($opd['value'], $billing_info[$tag]);
                     $db_update->WhereValue($opd['id'], DB_EQ, $attr['id']);
                     $application->db->PrepareSQL($db_update);
                     $application->db->DB_Exec();
                 }
             }
         }
         #      check if it is necessary to update Shipping Info
         $update_shipping_info = false;
         if (is_array($shipping_info)) {
             foreach ($order['Shipping']['attr'] as $tag => $attr) {
                 if (array_key_exists($tag, $shipping_info) && trim($attr['value']) != trim($shipping_info[$tag])) {
                     $update_shipping_info = true;
                     $db_update = new DB_Update('order_person_data');
                     $db_update->addUpdateValue($opd['value'], $shipping_info[$tag]);
                     $db_update->WhereValue($opd['id'], DB_EQ, $attr['id']);
                     $application->db->PrepareSQL($db_update);
                     $application->db->DB_Exec();
                 }
             }
         }
         #      check if it is necessary to update Bank Account Info
         $update_bank_account_info = false;
         if (is_array($bank_account_info)) {
             foreach ($order['BankAccount']['attr'] as $tag => $attr) {
                 if (array_key_exists($tag, $bank_account_info) && trim($attr['value']) != trim($bank_account_info[$tag])) {
                     $update_bank_account_info = true;
                     $db_update = new DB_Update('order_person_data');
                     $db_update->addUpdateValue($opd['value'], $bank_account_info[$tag]);
                     $db_update->WhereValue($opd['id'], DB_EQ, $attr['id']);
                     $application->db->PrepareSQL($db_update);
                     $application->db->DB_Exec();
                 }
             }
         }
         #      check if it is necessary to update Credit Card Info
         $update_credit_card_info = false;
         if (is_array($credit_card_info)) {
             //Credit card info is ALWAYS encrypted.
             //Prepare the encrypting keys.
             $symmetric_secret_key = modApiFunc("Crypto", "blowfish_gen_blowfish_key");
             $rsa_public_key = modApiFunc("Payment_Module_Offline_CC", "getRSAPublicKeyInCryptRSAFormat");
             $rsa_public_key_asc_format = modApiFunc("Payment_Module_Offline_CC", "getRSAPublicKeyInASCFormat");
             $rsa_obj = new Crypt_RSA();
             $encrypted_symmetric_secret_key = $rsa_obj->encrypt($symmetric_secret_key, $rsa_public_key);
             $person_info_variant_id = $order['CreditCard']['person_info_variant_id'];
             foreach ($order['CreditCard']['attr'] as $tag => $attr) {
                 if (array_key_exists($tag, $credit_card_info)) {
                     $update_credit_card_info = true;
                     //Not encrypted obfuscated value
                     $b_encrypted = false;
                     $db_update = new DB_Update('order_person_data');
                     $db_update->addUpdateValue($opd['value'], $this->get_public_view_of_secured_data($credit_card_info[$tag], $attr['person_attribute_id']));
                     $db_update->addUpdateValue($opd['encrypted_secret_key'], $encrypted_symmetric_secret_key);
                     $db_update->addUpdateValue($opd['rsa_public_key_asc_format'], $rsa_public_key_asc_format);
                     $db_update->WhereValue($opd['order_id'], DB_EQ, $order_id);
                     $db_update->WhereAND();
                     $db_update->WhereValue($opd['variant_id'], DB_EQ, $person_info_variant_id);
                     $db_update->WhereAND();
                     $db_update->WhereValue($opd['attribute_id'], DB_EQ, $attr['person_attribute_id']);
                     $db_update->WhereAND();
                     $db_update->WhereValue($opd['b_encrypted'], DB_EQ, "0");
                     $application->db->PrepareSQL($db_update);
                     $application->db->DB_Exec();
                     //  encrypted not obfuscated value
                     $b_encrypted = true;
                     $db_update = new DB_Update('order_person_data');
                     $db_update->addUpdateValue($opd['value'], base64_encode($this->encryptOrderPersonAttribute($credit_card_info[$tag], $symmetric_secret_key)));
                     $db_update->addUpdateValue($opd['encrypted_secret_key'], $encrypted_symmetric_secret_key);
                     $db_update->addUpdateValue($opd['rsa_public_key_asc_format'], $rsa_public_key_asc_format);
                     $db_update->WhereValue($opd['order_id'], DB_EQ, $order_id);
                     $db_update->WhereAND();
                     $db_update->WhereValue($opd['variant_id'], DB_EQ, $person_info_variant_id);
                     $db_update->WhereAND();
                     $db_update->WhereValue($opd['attribute_id'], DB_EQ, $attr['person_attribute_id']);
                     $db_update->WhereAND();
                     $db_update->WhereValue($opd['b_encrypted'], DB_EQ, "1");
                     $application->db->PrepareSQL($db_update);
                     $application->db->DB_Exec();
                 }
             }
         }
         // @
         // update product options
         if (is_array($product_options)) {
             $cols = $tables["order_product_options"]['columns'];
             foreach ($product_options as $key => $value) {
                 $db_update = new DB_Update('order_product_options');
                 $db_update->addUpdateValue($cols['option_value'], $value);
                 $db_update->WhereValue($cols["product_option_id"], DB_EQ, $key);
                 $application->db->PrepareSQL($db_update);
                 $application->db->DB_Exec();
                 foreach ($order_view_currency["Products"] as $pid => $product) {
                     foreach ($product["options"] as $oid => $option) {
                         if ($option["product_option_id"] == $key && $option["option_value"] != $value) {
                             $history[] = new ActionMessage(array('ORDERS_HISTORY_PRODUCT_OPTION_UPDATED', $option["option_value"], $value));
                             $adv_order_edit = true;
                         }
                     }
                 }
             }
         }
         // update order product names
         if (is_array($product_names)) {
             $cols = $tables["order_product"]['columns'];
             foreach ($product_names as $key => $value) {
                 $db_update = new DB_Update("order_product");
                 $db_update->addUpdateValue($cols["name"], $value);
                 $db_update->WhereValue($cols["id"], DB_EQ, $key);
                 $application->db->PrepareSQL($db_update);
                 $application->db->DB_Exec();
                 foreach ($order_view_currency["Products"] as $pid => $product) {
                     if ($product["id"] == $key && $product["name"] != $value) {
                         $history[] = new ActionMessage(array('ORDERS_HISTORY_PRODUCT_NAME_UPDATED', $product["name"], $value));
                         $adv_order_edit = true;
                     }
                 }
             }
         }
         // update prices
         $arePricesUpdated = false;
         if ($totals["arePricesEdited"] == "true") {
             $order_view_currency["taxExemption"] = modApiFunc("TaxExempts", "getOrderFullTaxExempts", intval($order_id), false);
             $totals["taxes"] = $taxes;
             $totals["products"]["names"] = $product_names;
             $totals["products"]["prices"] = $product_prices;
             $totals["products"]["qty"] = $product_qty;
             // get order's currencies
             $currencies = $this->getOrderCurrencyList($order_id);
             // get editor's currency
             $edited_currency = modApiFunc("Localization", "getCurrencyCodeById", $totals["order_currency"]);
             $history[] = new ActionMessage(array('ORDERS_HISTORY_PRICES_UPDATED', $edited_currency));
             // find currency rates
             foreach ($currencies as $cur) {
                 $current_prices[$cur["currency_code"]] = execQuery('SELECT_ORDER_PRICES', array('order_id' => $order_id, 'currency_code' => $cur["currency_code"]));
             }
             $rates = array();
             foreach ($currencies as $cur) {
                 if ($cur["currency_code"] === $edited_currency) {
                     $rates[$cur["currency_code"]] = 1;
                 } else {
                     $rates[$cur["currency_code"]] = $current_prices[$cur["currency_code"]][0]["order_total"] / $current_prices[$edited_currency][0]["order_total"];
                 }
             }
             // subtotal
             $totals["subtotal"] = 0;
             foreach ($product_prices as $prod_id => $prod) {
                 $totals["subtotal"] += $prod * $product_qty[$prod_id];
             }
             // discounted subtotal
             $totals["discounted_subtotal"] = $totals["subtotal"] - $totals["global_discount"] - $totals["promocode_discount"] - $totals["qty_discount"];
             // total, taxes
             $totals["tax_total"] = 0;
             $totals["tax_total_wo_included"] = 0;
             $totals["total"] = $totals["discounted_subtotal"] + $totals["shipping_handling"];
             if (is_array($taxes)) {
                 foreach ($taxes as $key => $value) {
                     if ($value["value"] == PRICE_N_A) {
                         continue;
                     }
                     if ($order_view_currency["DisplayIncludedTax"] == true) {
                         if ($value["is_included"] == "1") {
                             if ($tax_exemption == "true") {
                                 $totals["total"] -= $value["value"];
                             }
                         } else {
                             if ($value["is_included"] == "0") {
                                 if ($tax_exemption == "false") {
                                     $totals["total"] += $value["value"];
                                 }
                                 $totals["tax_total_wo_included"] += $value["value"];
                             }
                         }
                     } else {
                         if ($tax_exemption == "false") {
                             $totals["total"] += $value["value"];
                         }
                         $totals["tax_total_wo_included"] += $value["value"];
                     }
                     $totals["tax_total"] += $value["value"];
                 }
             }
             // update tax exemption mark
             if ($tax_exemption != null) {
                 $tax_tables = modApiFunc("TaxExempts", "getTables");
                 $col = $tax_tables['order_full_tax_exempts']['columns'];
                 $db_update = new DB_Update('order_full_tax_exempts');
                 $db_update->addUpdateValue($col['exempt_status'], $tax_exemption);
                 $db_update->WhereValue($col['order_id'], DB_EQ, intval($order_id));
                 $application->db->PrepareSQL($db_update);
                 $application->db->DB_Exec();
                 if (is_array($order_view_currency["taxExemption"]) && isset($order_view_currency["taxExemption"][0]["exempt_status"]) && $order_view_currency["taxExemption"][0]["order_id"] == intval($order_id) && $order_view_currency["taxExemption"][0]["exempt_status"] != $tax_exemption) {
                     $old_value = $order_view_currency["taxExemption"][0]["exempt_status"] == "true" ? "Yes" : "No";
                     $new_value = $tax_exemption == "true" ? "Yes" : "No";
                     $history[] = new ActionMessage(array('ORDERS_HISTORY_TAX_EXEMPTION_UPDATED', $old_value, $new_value));
                     $arePricesUpdated = true;
                     $adv_order_edit = true;
                 }
             }
             // update order product quantities
             if (is_array($product_qty)) {
                 $cols = $tables["order_product"]['columns'];
                 foreach ($product_qty as $key => $value) {
                     $db_update = new DB_Update("order_product");
                     $db_update->addUpdateValue($cols["qty"], $value);
                     $db_update->WhereValue($cols["id"], DB_EQ, $key);
                     $application->db->PrepareSQL($db_update);
                     $application->db->DB_Exec();
                     foreach ($order_view_currency["Products"] as $pid => $product) {
                         if ($product["id"] == $key && $product["qty"] != $value) {
                             $history[] = new ActionMessage(array('ORDERS_HISTORY_PRODUCT_QUANTITY_UPDATED', $product["qty"], $value));
                             $arePricesUpdated = true;
                             $adv_order_edit = true;
                         }
                     }
                 }
             }
             // update order prices
             $cols = $tables["order_prices"]['columns'];
             foreach ($rates as $code => $rate) {
                 $db_update = new DB_Update("order_prices");
                 $db_update->addUpdateValue($cols["order_total"], $totals["total"] * $rate);
                 $db_update->addUpdateValue($cols["order_subtotal"], $totals["subtotal"] * $rate);
                 $db_update->addUpdateValue($cols["total_shipping_and_handling_cost"], $totals["shipping_handling"] * $rate);
                 $db_update->addUpdateValue($cols["order_tax_total"], $totals["tax_total"] * $rate);
                 $db_update->addUpdateValue($cols["subtotal_global_discount"], $totals["global_discount"] * $rate);
                 $db_update->addUpdateValue($cols["subtotal_promo_code_discount"], $totals["promocode_discount"] * $rate);
                 $db_update->addUpdateValue($cols["quantity_discount"], $totals["qty_discount"] * $rate);
                 $db_update->addUpdateValue($cols["discounted_subtotal"], $totals["discounted_subtotal"] * $rate);
                 $db_update->addUpdateValue($cols["order_not_included_tax_total"], $totals["tax_total_wo_included"] * $rate);
                 $db_update->WhereValue($cols["order_id"], DB_EQ, intval($order_id));
                 $db_update->WhereAND();
                 $db_update->WhereValue($cols["currency_code"], DB_EQ, $code);
                 $application->db->PrepareSQL($db_update);
                 $application->db->DB_Exec();
             }
             if ($order_view_currency["Price"]["SubtotalGlobalDiscount"] != $totals["global_discount"]) {
                 $history[] = new ActionMessage(array('ORDERS_HISTORY_GLOBAL_DISCOUNT_UPDATED', $order_view_currency["Price"]["SubtotalGlobalDiscount"], $totals["global_discount"]));
                 $arePricesUpdated = true;
             }
             if ($order_view_currency["Price"]["SubtotalPromoCodeDiscount"] != $totals["promocode_discount"]) {
                 $history[] = new ActionMessage(array('ORDERS_HISTORY_PROMOCODE_DISCOUNT_UPDATED', $order_view_currency["Price"]["SubtotalPromoCodeDiscount"], $totals["promocode_discount"]));
                 $arePricesUpdated = true;
             }
             if ($order_view_currency["Price"]["QuantityDiscount"] != $totals["qty_discount"]) {
                 $history[] = new ActionMessage(array('ORDERS_HISTORY_QUANTITY_DISCOUNT_UPDATED', $order_view_currency["Price"]["QuantityDiscount"], $totals["qty_discount"]));
                 $arePricesUpdated = true;
             }
             if ($order_view_currency["Price"]["TotalShippingAndHandlingCost"] != $totals["shipping_handling"]) {
                 $history[] = new ActionMessage(array('ORDERS_HISTORY_SHIPPING_HANDLING_UPDATED', $order_view_currency["Price"]["TotalShippingAndHandlingCost"], $totals["shipping_handling"]));
                 $arePricesUpdated = true;
             }
             // update order product prices
             if (is_array($product_prices)) {
                 $cols = $tables["order_product_to_attributes"]['columns'];
                 foreach ($product_prices as $key => $value) {
                     foreach ($order_view_currency["Products"] as $pid => $product) {
                         if ($product["id"] == $key && $product["SalePrice"] != $value) {
                             $history[] = new ActionMessage(array('ORDERS_HISTORY_PRODUCT_SALEPRICE_UPDATED', $product["SalePrice"], $value));
                             $arePricesUpdated = true;
                         }
                     }
                     foreach ($rates as $code => $rate) {
                         $db_update = new DB_Update("order_product_to_attributes");
                         $db_update->addUpdateValue($cols["value"], $value * $rate);
                         $db_update->WhereValue($cols["attribute_id"], DB_EQ, "1");
                         $db_update->WhereAND();
                         $db_update->WhereValue($cols["currency_code"], DB_EQ, $code);
                         $db_update->WhereAND();
                         $db_update->WhereValue($cols["product_id"], DB_EQ, $key);
                         $application->db->PrepareSQL($db_update);
                         $application->db->DB_Exec();
                     }
                 }
             }
             if (is_array($taxes)) {
                 // update order taxes
                 $current_taxes = execQuery('SELECT_ORDER_TAXES', array('order_id' => $order_id, 'currency_code' => $edited_currency));
                 $cols = $tables["order_taxes"]['columns'];
                 foreach ($current_taxes as $tax) {
                     if ($order_view_currency["Price"]["taxes"][$tax["id"]]["value"] != $taxes[$tax["id"]]["value"]) {
                         $history[] = new ActionMessage(array('ORDERS_HISTORY_TAX_UPDATED', $order_view_currency["Price"]["taxes"][$tax["id"]]["name"], $order_view_currency["Price"]["taxes"][$tax["id"]]["value"], $taxes[$tax["id"]]["value"]));
                         $arePricesUpdated = true;
                     }
                     foreach ($rates as $code => $rate) {
                         $db_update = new DB_Update("order_taxes");
                         $db_update->addUpdateValue($cols["value"], $taxes[$tax["id"]]["value"] * $rate);
                         $db_update->WhereValue($cols["order_id"], DB_EQ, intval($order_id));
                         $db_update->WhereAND();
                         $db_update->WhereValue($cols["currency_code"], DB_EQ, $code);
                         $db_update->WhereAND();
                         $db_update->WhereValue($cols["type"], DB_EQ, $tax["type"]);
                         $application->db->PrepareSQL($db_update);
                         $application->db->DB_Exec();
                     }
                 }
                 // update order tax display options
                 $current_tdo = execQuery('SELECT_ORDER_TAX_DISPLAY_OPTIONS', array('order_id' => $order_id, 'currency_code' => $edited_currency));
                 $cols = $tables["order_tax_display_options"]['columns'];
                 foreach ($current_tdo as $tdo) {
                     $new_amount = 0;
                     $formula = explode(',', $tdo["formula"]);
                     foreach ($formula as $sign) {
                         if ($taxes[$sign]["value"] != PRICE_N_A) {
                             $new_amount += $taxes[$sign]["value"];
                         }
                     }
                     // @ a strange error here: (float(6.39) != float(6.39)) === true
                     if (floatval($new_amount) != floatval($order_view_currency["Price"]["tax_dops"][$tdo["id"]]["value"])) {
                         $history[] = new ActionMessage(array('ORDERS_HISTORY_TDO_UPDATED', $tdo["name"], $order_view_currency["Price"]["tax_dops"][$tdo["id"]]["value"], $new_amount));
                         $arePricesUpdated = true;
                     }
                     foreach ($rates as $code => $rate) {
                         $db_update = new DB_Update("order_tax_display_options");
                         $db_update->addUpdateValue($cols["value"], $new_amount * $rate);
                         $db_update->WhereValue($cols["name"], DB_EQ, $tdo["name"]);
                         $db_update->WhereAND();
                         $db_update->WhereValue($cols["order_id"], DB_EQ, intval($order_id));
                         $db_update->WhereAND();
                         $db_update->WhereValue($cols["currency_code"], DB_EQ, $code);
                         $application->db->PrepareSQL($db_update);
                         $application->db->DB_Exec();
                     }
                 }
             }
             // update odrers "was_manually_edited" flag
             $cols = $tables["orders"]['columns'];
             $db_update = new DB_Update('orders');
             $db_update->addUpdateValue($cols['edited'], 1);
             $db_update->WhereValue($cols["id"], DB_EQ, intval($order_id));
             $application->db->PrepareSQL($db_update);
             $application->db->DB_Exec();
         }
         // if ($totals["arePricesEdited"] == "true")
         # add comment, if it is defined
         if (!empty($comment)) {
             $query = new DB_Insert('order_notes');
             $query->addInsertValue($order_id, $on['order_id']);
             $query->addInsertValue(date('Y-m-d H:i:s', time()), $on['date']);
             $query->addInsertValue($comment, $on['content']);
             $query->addInsertValue('comment', $on['type']);
             $application->db->getDB_Result($query);
         }
         # generate records for the order history
         $status_list = $this->getOrderStatusList();
         $payment_status_list = $this->getOrderPaymentStatusList();
         if ($update_status_id) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_STATUS_UPDATED', $status_list[$order['StatusId']]['name'], $status_list[$status_id]['name']));
         }
         if ($update_payment_status_id) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_PAYMENT_STATUS_UPDATED', $payment_status_list[$order['PaymentStatusId']]['name'], $payment_status_list[$payment_status_id]['name']));
         }
         if ($update_track_id) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_TRACKING_NUMBER_UPDATED', $order['TrackId'], $track_id));
         }
         if ($update_processor_order_id) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_PAYMENT_PROCESSOR_ORDER_ID_UPDATED', $order['PaymentProcessorOrderId'], $processor_order_id));
         }
         if ($update_payment_method) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_PAYMENT_METHOD_UPDATED', $order['PaymentMethod'], $payment_method));
         }
         if ($update_shipping_method) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_SHIPPING_METHOD_UPDATED', $order['ShippingMethod'], $shipping_method));
         }
         if ($update_customer_info) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_CUSTOMER_INFO_UPDATED'));
         }
         if ($update_billing_info) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_BILLING_INFO_UPDATED'));
         }
         if ($update_shipping_info) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_SHIPPING_INFO_UPDATED'));
         }
         if ($update_bank_account_info) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_BANK_ACCOUNT_INFO_UPDATED'));
         }
         if ($update_credit_card_info) {
             $history[] = new ActionMessage(array('ORDERS_HISTORY_CREDIT_CARD_INFO_UPDATED'));
         }
         if ($arePricesUpdated === true) {
             foreach ($rates as $code => $rate) {
                 $history[] = new ActionMessage(array('ORDERS_HISTORY_TOTAL_UPDATED', $code));
             }
         } else {
             if ($totals["arePricesEdited"] == "true") {
                 $history[] = new ActionMessage(array('ORDERS_HISTORY_PRICES_INTACT'));
             }
         }
         $messageResources =& $application->getInstance('MessageResources');
         $history_text = "";
         foreach ($history as $record) {
             $history_text .= $messageResources->getMessage($record) . "\n";
         }
         if (!empty($history_text)) {
             $this->addOrderHistory($order_id, $history_text);
         }
     }
     if (!empty($statusChanged['order_status']) or !empty($statusChanged['payment_status'])) {
         modApiFunc('EventsManager', 'throwEvent', 'OrdersWereUpdated', $statusChanged);
     }
     if (!isset($arePricesUpdated)) {
         $arePricesUpdated = false;
     }
     if ($adv_order_edit == true || $arePricesUpdated == true) {
         $event_data = (int) $order_id;
         modApiFunc('EventsManager', 'throwEvent', 'OrderDataEdited', $event_data);
     }
     modApiFunc('EventsManager', 'throwEvent', 'OrderStatusUpdated', $statusChanged);
     return $statusChanged;
 }