function _renameShippingMethod($method_id, $method_name)
 {
     if ($method_name == "") {
         return false;
     }
     global $application;
     $tables = $this->getTables();
     $table = 'sm_dsr_methods';
     $columns = $tables[$table]['columns'];
     $query = new DB_Update($table);
     $query->addMultiLangUpdateValue($columns['method_name'], $method_name, $columns['id'], $method_id, 'Shipping_Module_DSR');
     $query->Where($columns['id'], DB_EQ, $method_id);
     $application->db->getDB_Result($query);
     return true;
 }
 function updateImagesOfProduct($images_data)
 {
     if (empty($images_data)) {
         return;
     }
     global $application;
     $tables = $this->getTables();
     $images_table = $tables['pi_images']['columns'];
     foreach ($images_data as $image_id => $image_info) {
         $query = new DB_Update('pi_images');
         $query->addMultiLangUpdateValue($images_table['alt_text'], $image_info['alt_text'], $images_table['image_id'], $image_id, 'Product_Images');
         $query->WhereValue($images_table['image_id'], DB_EQ, $image_id);
         $application->db->getDB_Result($query);
     }
     return;
 }
 /**
  * Saves a list of fields for the Person Info attribute. If it saves fields
  * for the Country attribute and it is invisible, then the State attribute,
  * associated with it, should be invisible too.
  *
  * @author Oleg Vlasenko
  * @param integer $fields - the array of new values of the fields
  * @return void
  */
 function setPersonInfoFieldList($fields)
 {
     global $application;
     $tables = $this->getTables();
     $columns = $tables['person_info_variants_to_attributes']['columns'];
     $variant_id = $fields['variant_id'];
     $attribute_id = $fields['attribute_id'];
     $fields_original = $this->getPersonInfoFieldsList($variant_id, $attribute_id);
     $fields['unremovable'] = $fields_original['unremovable'];
     if ($fields_original['unremovable'] != 0) {
         $fields['visible'] = '1';
         $fields['required'] = '1';
     }
     if ($fields_original['variant_id'] == 4) {
         $fields['unremovable'] = '1';
         $fields['required'] = '0';
     }
     $query = new DB_Update('person_info_variants_to_attributes');
     if ($fields['name'] != null) {
         $query->addMultiLangUpdateValue($columns['name'], $fields['name'], $columns['id'], '', 'Checkout');
     }
     if ($fields['descr'] != null) {
         $query->addMultiLangUpdateValue($columns['descr'], $fields['descr'], $columns['id'], '', 'Checkout');
     }
     $query->addUpdateValue($columns['unremovable'], $fields['unremovable']);
     $query->addUpdateValue($columns['visible'], $fields['visible']);
     $query->addUpdateValue($columns['required'], $fields['required']);
     $query->WhereValue($columns['variant_id'], DB_EQ, $variant_id);
     $query->WhereAnd();
     $query->WhereValue($columns['attribute_id'], DB_EQ, $attribute_id);
     $application->db->getDB_Result($query);
     // Correct the State field visibility if the Country field vsibility is changed
     if ($attribute_id == 9) {
         $country_visible = $fields['visible'];
         $states_attribute_id = 7;
         // get the State attribute state
         $query = new DB_Select();
         $query->addSelectField($columns['visible'], 'visible');
         $query->WhereValue($columns['variant_id'], DB_EQ, $variant_id);
         $query->WhereAnd();
         $query->WhereValue($columns['attribute_id'], DB_EQ, $states_attribute_id);
         // States
         $result = $application->db->getDB_Result($query);
         $state_visible = $result[0]['visible'];
         // If State is visible and Country is invisible, then hide State
         if (!$country_visible && $state_visible) {
             $query = new DB_Update('person_info_variants_to_attributes');
             $query->addUpdateValue($columns['visible'], 0);
             $query->addUpdateValue($columns['required'], 0);
             $query->WhereValue($columns['variant_id'], DB_EQ, $variant_id);
             $query->WhereAnd();
             $query->WhereValue($columns['attribute_id'], DB_EQ, $states_attribute_id);
             $application->db->getDB_Result($query);
         }
     }
     modApiFunc('EventsManager', 'throwEvent', 'CheckoutPersonInfoFieldUpdated', $fields);
 }
 function updateGroupAttrsInfo($group_name, $attrs)
 {
     global $application;
     $tables = $this->getTables();
     $atg_table = $tables['ca_attrs_to_groups']['columns'];
     $group_info = $this->getPersonInfoGroupInfoByName($group_name);
     $group_attrs = $this->getPersonInfoGroupAttrs($group_info['group_id']);
     foreach ($group_attrs as $group_attr_info) {
         if (array_key_exists($group_attr_info['attr_name'], $attrs)) {
             $a_info = $attrs[$group_attr_info['attr_name']];
             if (array_diff(array_keys($a_info), array_keys($atg_table)) == array_keys($a_info)) {
                 continue;
             }
             $query = new DB_Update('ca_attrs_to_groups');
             foreach ($a_info as $prop => $val) {
                 if ($prop == 'visible_name') {
                     $query->addMultiLangUpdateValue($atg_table[$prop], $val, $atg_table['ag_id'], '', 'Customer_Account');
                 } else {
                     $query->addUpdateValue($atg_table[$prop], $val);
                 }
             }
             $query->WhereValue($atg_table['group_id'], DB_EQ, $group_info['group_id']);
             $query->WhereAND();
             $query->WhereValue($atg_table['attr_id'], DB_EQ, $group_attr_info['attr_id']);
             $application->db->getDB_Result($query);
         }
     }
     return;
 }
 /**
  * Update notification info in the database.
  *
  *@param array $data - the array of features taken from the form
  *
  *@return
  */
 function updateNotification($data)
 {
     global $application;
     $tables = $this->getTables();
     $n = $tables['notifications']['columns'];
     $query = new DB_Update('notifications');
     $query->addUpdateValue($n['na_id'], $data['Action']);
     $query->addMultiLangUpdateValue($n['name'], $data['Name'], $n['id'], '', 'Notifications');
     $query->addMultiLangUpdateValue($n['subject'], $data['Subject'], $n['id'], '', 'Notifications');
     $query->addMultiLangUpdateValue($n['body'], $data['Body'], $n['id'], '', 'Notifications');
     if (key($data['SendFrom']) === 'EMAIL_ADMINISTRATOR') {
         $query->addUpdateValue($n['from_email_admin_id'], $data['SendFrom'][key($data['SendFrom'])]);
         $query->addUpdateValue($n['from_email_custom_address'], "");
     } else {
         $query->addUpdateValue($n['from_email_admin_id'], DB_NULL);
         $query->addUpdateValue($n['from_email_custom_address'], $data['SendFrom'][key($data['SendFrom'])]);
     }
     $query->addUpdateValue($n['from_email_code'], key($data['SendFrom']));
     $query->addUpdateValue($n['active'], $data['Active']);
     $query->WhereValue($n['id'], DB_EQ, $data['Id']);
     $application->db->getDB_Result($query);
     $nst = $tables['notification_send_to']['columns'];
     $query = new DB_Delete('notification_send_to');
     $query->WhereValue($nst['n_id'], DB_EQ, $data['Id']);
     $application->db->getDB_Result($query);
     foreach ($data['SendTo'] as $email) {
         $query = new DB_Insert('notification_send_to');
         $query->addInsertValue($data['Id'], $nst['n_id']);
         $query->addInsertValue($email[key($email)], $nst['email']);
         $query->addInsertValue(key($email), $nst['code']);
         $application->db->getDB_Result($query);
     }
     if ($data['OptionsValues']) {
         $ov2n = $tables['option_values_to_notification']['columns'];
         $query = new DB_Delete('option_values_to_notification');
         $query->WhereValue($ov2n['n_id'], DB_EQ, $data['Id']);
         $application->db->getDB_Result($query);
         foreach ($data['OptionsValues'] as $key => $val) {
             $query = new DB_Insert('option_values_to_notification');
             $query->addInsertValue($key, $ov2n['naov_id']);
             $query->addInsertValue($data['Id'], $ov2n['n_id']);
             $query->addInsertValue('true', $ov2n['value']);
             $application->db->getDB_Result($query);
         }
     }
     if ($data['BlockBodies']) {
         $nbb = $tables['notification_blocktag_bodies']['columns'];
         foreach ($data['BlockBodies'] as $block_id => $body) {
             $query = new DB_Update('notification_blocktag_bodies');
             $query->addMultiLangUpdateValue($nbb['body'], $body, $nbb['id'], '', 'Notifications');
             $query->WhereValue($nbb['nb_id'], DB_EQ, $block_id);
             $query->WhereAnd();
             $query->WhereValue($nbb['n_id'], DB_EQ, $data['Id']);
             $application->db->getDB_Result($query);
         }
     }
 }
 /**
  * Updates the values of the option.
  *
  * For the $data array format see the comment to the function addValueToOption,
  * for all that the parameter option_id shouldn't exist in this array.
  *
  * @param int $value_id - value ID
  * @param array $data - data to update, checked by the function checkDataFor()
  * @return TRUE - if it is updated, FALSE otherwise
  */
 function updateValueOfOption($value_id, $data)
 {
     global $application;
     $tables = $this->getTables();
     $values = $tables['po_options_values']['columns'];
     $query = new DB_Update('po_options_values');
     foreach ($data as $key => $data_value) {
         if ($key == 'value_name') {
             $query->addMultiLangUpdateValue($values[$key], $data_value, $values['value_id'], $value_id, 'Product_Options');
         } else {
             $query->addUpdateValue($values[$key], $data_value);
         }
     }
     $query->WhereValue($values['value_id'], DB_EQ, $value_id);
     $application->db->getDB_Result($query);
     return $application->db->QueryResult;
 }
 /**
  * Updates Display Option.
  *
  * @param
  * @return
  */
 function updateTaxDisplayOption($id, $formula, $option_id, $display_view)
 {
     global $application;
     $tables = $this->getTables();
     $td = $tables['tax_display']['columns'];
     $query = new DB_Update('tax_display');
     $query->addUpdateValue($td['formula'], $formula);
     $query->addUpdateValue($td['tdo_id'], $option_id);
     $query->addMultiLangUpdateValue($td['view'], $display_view, $td['id'], $id, 'Taxes');
     $query->WhereValue($td['id'], DB_EQ, $id);
     $application->db->getDB_Result($query);
 }