/** * Can add products to the category straight from the ProductCategory page * TODO remove this, its not useful. And change the direction of the many_many relation so that patched version of CTF not needed * * @see Page::getCMSFields() * @return FieldSet */ function getCMSFields() { $fields = parent::getCMSFields(); /* //Product categories $manager = new ManyManyComplexTableField( $this, 'Products', 'Product', array(), 'getCMSFields_forPopup' ); $manager->setPermissions(array()); $fields->addFieldToTab("Root.Content.Products", $manager); */ if (file_exists(BASE_PATH . '/swipestripe') && ShopSettings::get_license_key() == null) { $fields->addFieldToTab("Root.Content.Main", new LiteralField("SwipeStripeLicenseWarning", '<p class="message warning"> Warning: You have SwipeStripe installed without a license key. Please <a href="http://swipestripe.com" target="_blank">purchase a license key here</a> before this site goes live. </p>'), "Title"); } return $fields; }
/** * Tries to fix any database related problems * @return boolean false Always! * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { //die("Coupon::errorHandler(): Disabled"); // Coupon // Fix settings first ShopSettings::errorHandler(); $table_name = DBPREFIX . 'module_shop_discount_coupon'; $table_structure = array('code' => array('type' => 'varchar(20)', 'default' => '', 'primary' => true), 'customer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'start_time' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'end_time' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'uses' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'uses_available'), 'global' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0'), 'minimum_amount' => array('type' => 'decimal(9,2)', 'unsigned' => true, 'default' => '0.00'), 'discount_amount' => array('type' => 'decimal(9,2)', 'unsigned' => true, 'default' => '0.00'), 'discount_rate' => array('type' => 'decimal(3,0)', 'unsigned' => true, 'default' => '0')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_rel_customer_coupon'; $table_structure = array('code' => array('type' => 'varchar(20)', 'default' => '', 'primary' => true), 'customer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'count' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
/** * Handles database errors * * Also migrates old Shop Customers to the User accounts and adds * all new settings * @return boolean false Always! * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Customer $table_name_old = DBPREFIX . "module_shop_customers"; // If the old Customer table is missing, the migration has completed // successfully already if (!\Cx\Lib\UpdateUtil::table_exist($table_name_old)) { return false; } // Ensure that the ShopSettings (including \Cx\Core\Setting) and Order tables // are ready first! //DBG::log("Customer::errorHandler(): Adding settings"); ShopSettings::errorHandler(); // \Cx\Core\Country\Controller\Country::errorHandler(); // Called by Order::errorHandler(); Order::errorHandler(); Discount::errorHandler(); \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); $objUser = \FWUser::getFWUserObject()->objUser; // Create new User_Profile_Attributes $index_notes = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes', 'Shop'); if (!$index_notes) { //DBG::log("Customer::errorHandler(): Adding notes attribute..."); // $objProfileAttribute = new \User_Profile_Attribute(); $objProfileAttribute = $objUser->objAttribute->getById(0); //DBG::log("Customer::errorHandler(): NEW notes attribute: ".var_export($objProfileAttribute, true)); $objProfileAttribute->setNames(array(1 => 'Notizen', 2 => 'Notes', 3 => 'Notes', 4 => 'Notes', 5 => 'Notes', 6 => 'Notes')); $objProfileAttribute->setType('text'); $objProfileAttribute->setMultiline(true); $objProfileAttribute->setParent(0); $objProfileAttribute->setProtection(array(1)); //DBG::log("Customer::errorHandler(): Made notes attribute: ".var_export($objProfileAttribute, true)); if (!$objProfileAttribute->store()) { throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'"); } //Re initialize shop setting \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); //DBG::log("Customer::errorHandler(): Stored notes attribute, ID ".$objProfileAttribute->getId()); if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_notes', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_notes'))) { throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'notes' setting"); } //DBG::log("Customer::errorHandler(): Stored notes attribute ID setting"); } $index_group = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_group_id', 'Shop'); if (!$index_group) { // $objProfileAttribute = new \User_Profile_Attribute(); $objProfileAttribute = $objUser->objAttribute->getById(0); $objProfileAttribute->setNames(array(1 => 'Kundenrabattgruppe', 2 => 'Discount group', 3 => 'Kundenrabattgruppe', 4 => 'Kundenrabattgruppe', 5 => 'Kundenrabattgruppe', 6 => 'Kundenrabattgruppe')); $objProfileAttribute->setType('text'); $objProfileAttribute->setParent(0); $objProfileAttribute->setProtection(array(1)); if (!$objProfileAttribute->store()) { throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'"); } //Re initialize shop setting \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_customer_group_id', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_customer_group_id'))) { throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'customer_group_id' setting"); } } // For the migration, a temporary flag is needed in the orders table // in order to prevent mixing up old and new customer_id values. $table_order_name = DBPREFIX . "module_shop_orders"; if (!\Cx\Lib\UpdateUtil::column_exist($table_order_name, 'migrated')) { $query = "\n ALTER TABLE `{$table_order_name}`\n ADD `migrated` TINYINT(1) unsigned NOT NULL default 0"; \Cx\Lib\UpdateUtil::sql($query); } // Create missing UserGroups for customers and resellers $objGroup = null; $group_id_customer = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); if ($group_id_customer) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_customer); } if (!$objGroup || $objGroup->EOF) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Endkunden')); } if (!$objGroup || $objGroup->EOF) { $objGroup = new \UserGroup(); $objGroup->setActiveStatus(true); $objGroup->setDescription('Online Shop Endkunden'); $objGroup->setName('Shop Endkunden'); $objGroup->setType('frontend'); } //DBG::log("Group: ".var_export($objGroup, true)); if (!$objGroup) { throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for customers"); } //DBG::log("Customer::errorHandler(): Made customer usergroup: ".var_export($objGroup, true)); if (!$objGroup->store() || !$objGroup->getId()) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for customers"); } //DBG::log("Customer::errorHandler(): Stored customer usergroup, ID ".$objGroup->getId()); \Cx\Core\Setting\Controller\Setting::set('usergroup_id_customer', $objGroup->getId()); if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_customer')) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for customers"); } $group_id_customer = $objGroup->getId(); $objGroup = null; $group_id_reseller = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); if ($group_id_reseller) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_reseller); } if (!$objGroup || $objGroup->EOF) { $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Wiederverkäufer')); } if (!$objGroup || $objGroup->EOF) { $objGroup = new \UserGroup(); $objGroup->setActiveStatus(true); $objGroup->setDescription('Online Shop Wiederverkäufer'); $objGroup->setName('Shop Wiederverkäufer'); $objGroup->setType('frontend'); } if (!$objGroup) { throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for resellers"); } //DBG::log("Customer::errorHandler(): Made reseller usergroup: ".var_export($objGroup, true)); if (!$objGroup->store() || !$objGroup->getId()) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for resellers"); } \Cx\Core\Setting\Controller\Setting::set('usergroup_id_reseller', $objGroup->getId()); if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_reseller')) { throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for resellers"); } $group_id_reseller = $objGroup->getId(); $default_lang_id = \FWLanguage::getDefaultLangId(); $query = "\n SELECT `customer`.`customerid`,\n `customer`.`prefix`, `customer`.`firstname`,\n `customer`.`lastname`,\n `customer`.`company`, `customer`.`address`,\n `customer`.`city`, `customer`.`zip`,\n `customer`.`country_id`,\n `customer`.`phone`, `customer`.`fax`,\n `customer`.`email`,\n `customer`.`username`, `customer`.`password`,\n `customer`.`company_note`,\n `customer`.`is_reseller`,\n `customer`.`customer_status`, `customer`.`register_date`,\n `customer`.`group_id`\n FROM `{$table_name_old}` AS `customer`\n ORDER BY `customer`.`customerid` ASC"; $objResult = \Cx\Lib\UpdateUtil::sql($query); while (!$objResult->EOF) { $old_customer_id = $objResult->fields['customerid']; if (empty($objResult->fields['email'])) { $objResult->fields['email'] = $objResult->fields['username']; } $email = $objResult->fields['email']; $objUser = \FWUser::getFWUserObject()->objUser->getUsers(array('email' => array(0 => $email))); // TODO: See whether a User with that username (but different e-mail address) exists! $objUser_name = \FWUser::getFWUserObject()->objUser->getUsers(array('username' => array(0 => $objResult->fields['username']))); if ($objUser && $objUser_name) { $objUser = $objUser_name; } $objCustomer = null; if ($objUser) { $objCustomer = self::getById($objUser->getId()); } if (!$objCustomer) { $lang_id = Order::getLanguageIdByCustomerId($old_customer_id); $lang_id = \FWLanguage::getLangIdByIso639_1($lang_id); if (!$lang_id) { $lang_id = $default_lang_id; } $objCustomer = new Customer(); if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['prefix'])) { $objCustomer->gender('gender_female'); } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['prefix'])) { $objCustomer->gender('gender_male'); // } else { // Other "genders", like "family", "thing", or "it" won't be matched // and are left on "gender_unknown". //DBG::log("*** Prefix {$objResult->fields['prefix']}, UNKNOWN GENDER!"); } //DBG::log("Prefix {$objResult->fields['prefix']}, made gender ".$objCustomer->gender()); $objCustomer->company($objResult->fields['company']); $objCustomer->firstname($objResult->fields['firstname']); $objCustomer->lastname($objResult->fields['lastname']); $objCustomer->address($objResult->fields['address']); $objCustomer->city($objResult->fields['city']); $objCustomer->zip($objResult->fields['zip']); $objCustomer->country_id($objResult->fields['country_id']); $objCustomer->phone($objResult->fields['phone']); $objCustomer->fax($objResult->fields['fax']); $objCustomer->email($objResult->fields['email']); $objCustomer->companynote($objResult->fields['company_note']); $objCustomer->active($objResult->fields['customer_status']); // Handled by a UserGroup now, see below //$objCustomer->setResellerStatus($objResult->fields['is_reseller']); $objCustomer->register_date($objResult->fields['register_date']); $objCustomer->group_id($objResult->fields['group_id']); // NOTE: Mind that the User class has been modified to accept e-mail addresses // as usernames! $objCustomer->username($objResult->fields['username']); // Copy the md5 hash of the password! $objCustomer->password = $objResult->fields['password']; $objCustomer->setFrontendLanguage($lang_id); } if ($objResult->fields['is_reseller']) { $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_reseller)); //DBG::log("Customer::errorHandler(): Added reseller: ".$objCustomer->id()); } else { $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_customer)); //DBG::log("Customer::errorHandler(): Added customer: ".$objCustomer->id()); } if (!$objCustomer->store()) { //DBG::log(var_export($objCustomer, true)); throw new \Cx\Lib\Update_DatabaseException("Failed to migrate existing Customer ID " . $old_customer_id . " to Users (Messages: " . join(', ', $objCustomer->error_msg) . ")"); } // Update the Orders table with the new Customer ID. // Note that we use the ambiguous old customer ID that may // coincide with a new User ID, so to prevent inconsistencies, // migrated Orders are marked as such. $query = "\n UPDATE `{$table_order_name}`\n SET `customer_id`=" . $objCustomer->id() . ",\n `migrated`=1\n WHERE `customer_id`={$old_customer_id}\n AND `migrated`=0"; \Cx\Lib\UpdateUtil::sql($query); // Drop migrated $query = "\n DELETE FROM `{$table_name_old}`\n WHERE `customerid`={$old_customer_id}"; \Cx\Lib\UpdateUtil::sql($query); $objResult->MoveNext(); if (!checkMemoryLimit() || !checkTimeoutLimit()) { return false; } } // Remove the flag, it's no longer needed. // (You could also verify that all records have been migrated by // querying them with "[...] WHERE `migrated`=0", which *MUST* result // in an empty recordset. This is left as an exercise for the reader.) $query = "\n ALTER TABLE `{$table_order_name}`\n DROP `migrated`"; \Cx\Lib\UpdateUtil::sql($query); \Cx\Lib\UpdateUtil::drop_table($table_name_old); //DBG::log("Updated Customer table and related stuff"); // Always return false; }
/** * Sets up the Order list view * * Sets the $objTemplate parameter to the default backend template, * if empty. * @param \Cx\Core\Html\Sigma $objTemplate The Template, by reference * @param array $filter The optional filter * @return boolean True on success, * false otherwise */ static function view_list(&$objTemplate = null, $filter = NULL) { global $_ARRAYLANG, $objInit; $backend = $objInit->mode == 'backend'; if (!$objTemplate) { $objTemplate = new \Cx\Core\Html\Sigma(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/Shop/View/Template/Backend'); //DBG::log("Orders::view_list(): new Template: ".$objTemplate->get()); $objTemplate->loadTemplateFile('module_shop_orders.html'); //DBG::log("Orders::view_list(): loaded Template: ".$objTemplate->get()); } $uri = $backend ? \Html::getRelativeUri_entities() : \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'history', NULL); //DBG::log("Orders::view_list(): URI: $uri"); // TODO: Better use a redirect after doing stuff! \Html::stripUriParam($uri, 'act'); \Html::stripUriParam($uri, 'searchterm'); \Html::stripUriParam($uri, 'listletter'); \Html::stripUriParam($uri, 'customer_type'); \Html::stripUriParam($uri, 'status'); \Html::stripUriParam($uri, 'show_pending_orders'); \Html::stripUriParam($uri, 'order_id'); \Html::stripUriParam($uri, 'changeOrderStatus'); \Html::stripUriParam($uri, 'sendMail'); if (!is_array($filter)) { $filter = array(); } if (!empty($_REQUEST['searchterm'])) { $filter['term'] = trim(strip_tags(contrexx_input2raw($_REQUEST['searchterm']))); \Html::replaceUriParameter($uri, 'searchterm=' . $filter['term']); } elseif (!empty($_REQUEST['listletter'])) { $filter['letter'] = trim(strip_tags(contrexx_input2raw($_REQUEST['listletter']))); \Html::replaceUriParameter($uri, 'listletter=' . $filter['letter']); } $customer_type = $usergroup_id = null; // Ignore if (isset($_REQUEST['customer_type']) && $_REQUEST['customer_type'] !== '') { $customer_type = intval($_REQUEST['customer_type']); \Html::replaceUriParameter($uri, 'customer_type=' . $customer_type); if ($customer_type == 0) { $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); } if ($customer_type == 1) { $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); } $objFWUser = \FWUser::getFWUserObject(); $objGroup = $objFWUser->objGroup->getGroup($usergroup_id); if ($objGroup) { $filter['customer_id'] = $objGroup->getAssociatedUserIds(); // No customers of that type, so suppress all results if (empty($filter['customer_id'])) { $filter['customer_id'] = array(0); } //DBG::log("Orders::view_list(): Group ID $usergroup_id, Customers: ".var_export($filter['customer_id'], true)); } } $status = null; // Ignore $arrStatus = null; if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') { $status = intval($_REQUEST['status']); if ($status >= Order::STATUS_PENDING && $status < Order::STATUS_MAX) { $arrStatus = array($status => true); \Html::replaceUriParameter($uri, 'status=' . $status); if ($status == Order::STATUS_PENDING) { $_REQUEST['show_pending_orders'] = true; } } } // Let the user choose whether to see pending orders, too $show_pending_orders = false; if ($backend) { if (empty($_REQUEST['show_pending_orders'])) { if (empty($arrStatus)) { $arrStatus = self::getStatusArray(); unset($arrStatus[Order::STATUS_PENDING]); } } else { if ($arrStatus) { $arrStatus[Order::STATUS_PENDING] = true; } $show_pending_orders = true; \Html::replaceUriParameter($uri, 'show_pending_orders=1'); } } if ($arrStatus) { $filter['status'] = array_keys($arrStatus); } //DBG::log("Orders::view_list(): URI for Sorting: $uri, decoded ".html_entity_decode($uri)); $arrSorting = array('id' => $_ARRAYLANG['TXT_SHOP_ID'], 'date_time' => $_ARRAYLANG['TXT_SHOP_ORDER_DATE'], 'customer_name' => $_ARRAYLANG['TXT_SHOP_CUSTOMER'], 'sum' => $_ARRAYLANG['TXT_SHOP_ORDER_SUM'], 'status' => $_ARRAYLANG['TXT_SHOP_ORDER_STATUS']); $objSorting = new \Sorting($uri, $arrSorting, false, 'order_shop_orders'); $uri_search = $uri; \Html::stripUriParam($uri_search, 'searchterm'); \Html::stripUriParam($uri_search, 'customer_type'); \Html::stripUriParam($uri_search, 'status'); \Html::stripUriParam($uri_search, 'show_pending_orders'); $objTemplate->setGlobalVariable($_ARRAYLANG); if ($backend) { $txt_order_complete = sprintf($_ARRAYLANG['TXT_SEND_TEMPLATE_TO_CUSTOMER'], $_ARRAYLANG['TXT_ORDER_COMPLETE']); $objTemplate->setVariable(array('SHOP_SEND_TEMPLATE_TO_CUSTOMER' => $txt_order_complete, 'SHOP_CUSTOMER_TYPE_MENUOPTIONS' => Customers::getTypeMenuoptions($customer_type, true), 'SHOP_CUSTOMER_SORT_MENUOPTIONS' => Customers::getSortMenuoptions($objSorting->getOrderField()), 'SHOP_SHOW_PENDING_ORDERS_CHECKED' => $show_pending_orders ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_ORDER_STATUS_MENUOPTIONS' => self::getStatusMenuoptions($status, true))); } //DBG::log("Orders::view_list(): Order complete: $txt_order_complete"); //DBG::log("Orders::view_list(): URI: $uri"); $objTemplate->setGlobalVariable(array('SHOP_SEARCH_TERM' => isset($filter['term']) ? $filter['term'] : '', 'SHOP_ORDERS_ORDER_NAME' => $objSorting->getOrderParameterName(), 'SHOP_ORDERS_ORDER_VALUE' => $objSorting->getOrderUriEncoded(), 'SHOP_ACTION_URI_SEARCH_ENCODED' => $uri_search, 'SHOP_ACTION_URI_ENCODED' => $uri, 'SHOP_ACTION_URI' => html_entity_decode($uri), 'SHOP_CURRENCY', Currency::getDefaultCurrencySymbol())); $count = 0; $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_orders_per_page_backend', 'Shop'); // TODO: Obsolete ASAP if (!$limit) { ShopSettings::errorHandler(); $limit = 25; } $tries = 2; $arrOrders = null; //\DBG::activate(DBG_DB_FIREPHP); while ($tries-- && $count == 0) { $arrOrders = self::getArray($count, $objSorting->getOrder(), $filter, \Paging::getPosition(), $limit); if ($count > 0) { break; } \Paging::reset(); } //DBG::deactivate(DBG_DB); //\DBG::log("Orders: ".count($arrOrders)); $paging = \Paging::get($uri, $_ARRAYLANG['TXT_ORDERS'], $count, $limit, $count > 0); $objTemplate->setVariable(array('SHOP_ORDER_PAGING' => $paging, 'SHOP_CUSTOMER_LISTLETTER' => isset($filter['letter']) ? $filter['letter'] : '', 'SHOP_HEADER_ID' => $objSorting->getHeaderForField('id'), 'SHOP_HEADER_DATE_TIME' => $objSorting->getHeaderForField('date_time'), 'SHOP_HEADER_STATUS' => $objSorting->getHeaderForField('status'), 'SHOP_HEADER_CUSTOMER_NAME' => $objSorting->getHeaderForField('customer_name'), 'SHOP_HEADER_NOTES' => $_ARRAYLANG['TXT_SHOP_ORDER_NOTES'], 'SHOP_HEADER_SUM' => $objSorting->getHeaderForField('sum'), 'SHOP_LISTLETTER_LINKS' => self::getListletterLinks(isset($filter['letter']) ? $filter['letter'] : NULL))); if (empty($arrOrders)) { // $objTemplate->hideBlock('orderTable'); $objTemplate->setVariable('SHOP_ORDER_NONE_FOUND', $_ARRAYLANG['TXT_SHOP_ORDERS_NONE_FOUND']); //\DBG::log("NO Orders!"); return true; } $i = 0; // TODO: For Order export /* $min_date = '9999-00-00 00:00:00'; $max_date = '0000-00-00 00:00:00'; $min_id = 1e10; $max_id = 0;*/ foreach ($arrOrders as $objOrder) { $order_id = $objOrder->id(); // Custom order ID may be created and used as account name. // Adapt the method as needed. // $order_id_custom = ShopLibrary::getCustomOrderId( // $order_id, $objOrder->date_time() // ); // Take billing address from the Order. // No need to load the Customer. $customer_name = ''; $company = $objOrder->billing_company(); $customer_name = $company ? $company : $objOrder->billing_lastname() . ' ' . $objOrder->billing_firstname(); $tipNote = $objOrder->note(); $tipLink = empty($tipNote) ? '' : '<span class="tooltip-trigger icon-comment"></span>' . '<span class="tooltip-message">' . preg_replace('/[\\n\\r]+/', '<br />', nl2br(contrexx_raw2xhtml($tipNote))) . '</span>'; $status = $objOrder->status(); $objTemplate->setVariable(array('SHOP_ROWCLASS' => $status == 0 ? 'rowwarn' : 'row' . (++$i % 2 + 1), 'SHOP_ORDERID' => $order_id, 'SHOP_TIP_LINK' => $tipLink, 'SHOP_DATE' => date(ASCMS_DATE_FORMAT_DATETIME, strtotime($objOrder->date_time())), 'SHOP_NAME' => $customer_name, 'SHOP_ORDER_SUM' => Currency::getDefaultCurrencyPrice($objOrder->sum()), 'SHOP_ORDER_STATUS' => $backend ? self::getStatusMenu(intval($status), false, $order_id, 'changeOrderStatus(' . $order_id . ',' . $status . ',this.value)') : $_ARRAYLANG['TXT_SHOP_ORDER_STATUS_' . $status])); $objTemplate->parse('orderRow'); //\DBG::log("Parsed Order ID $order_id"); // TODO: Order export /* if ($objOrder->date_time() < $min_date) $min_date = $objOrder->date_time(); if ($objOrder->date_time() > $max_date) $max_date = $objOrder->date_time(); if ($objOrder->id() < $min_id) $min_id = $objOrder->id(); if ($objOrder->id() > $max_id) $max_id = $objOrder->id();*/ } $objTemplate->setVariable('SHOP_ORDER_PAGING', $paging); // TODO: Order export /* $arrId = range($min_id-1, $max_id); $arrId = array(0 => "0") + array_combine($arrId, $arrId); $objTemplate->setVariable(array( 'SHOP_ORDER_EXPORT_LAST_ID_MENUOPTIONS' => Html::getOptions($arrId), 'SHOP_ORDER_EXPORT_START_DATE' => Html::getDatepicker('start_date', array( 'defaultDate' => date(ASCMS_DATE_FORMAT_DATE, strtotime($min_date)), 'minDate' => '-7d', 'maxDate' => '+0d', )), 'SHOP_ORDER_EXPORT_END_DATE' => Html::getDatepicker('end_date', array( 'defaultDate' => date(ASCMS_DATE_FORMAT_DATE, strtotime($max_date)+86400), 'minDate' => '-6d', 'maxDate' => '+1d', )), )); //die("Template: ". nl2br(htmlentities(var_export($objTemplate, true)))); //die("Template: ". $objTemplate->get());*/ return true; }
/** * Set some CMS fields for managing Product images, Variations, Options, Attributes etc. * * @see Page::getCMSFields() * @return FieldSet */ public function getCMSFields() { $fields = parent::getCMSFields(); //Gallery $manager = new ComplexTableField($this, 'Images', 'ProductImage', array('SummaryOfImage' => 'Thumbnail', 'Caption' => 'Caption'), 'getCMSFields_forPopup'); $manager->setPopupSize(650, 400); $fields->addFieldToTab("Root.Content.Gallery", new HeaderField('GalleryHeading', 'Add images for this product, the first image will be used as a thumbnail', 3)); $fields->addFieldToTab("Root.Content.Gallery", $manager); //Product fields $amountField = new MoneyField('Amount', 'Amount'); $amountField->setAllowedCurrencies(self::$allowed_currency); $fields->addFieldToTab('Root.Content.Main', $amountField, 'Content'); //Stock level field $level = $this->StockLevel()->Level; $fields->addFieldToTab('Root.Content.Main', new StockField('Stock', null, $level, $this), 'Content'); //Product categories $fields->addFieldToTab("Root.Content.Categories", new HeaderField('CategoriesHeading', 'Select categories you would like this product to appear in', 3)); $categoryAlert = <<<EOS <p class="message good"> Please 'Save' after you have finished changing categories if you would like to set the order of this product in each category. </p> EOS; $fields->addFieldToTab("Root.Content.Categories", new LiteralField('CategoryAlert', $categoryAlert)); /* $manager = new BelongsManyManyComplexTableField( $this, 'ProductCategories', 'ProductCategory', array(), 'getCMSFields_forPopup', '', '"Title" ASC' ); $manager->setPageSize(20); $manager->setPermissions(array()); $fields->addFieldToTab("Root.Content.Categories", $manager); */ $categoriesField = new CategoriesField('ProductCategories', false, 'ProductCategory'); $fields->addFieldToTab("Root.Content.Categories", $categoriesField); //Attributes selection $anyAttribute = DataObject::get_one('Attribute'); if ($anyAttribute && $anyAttribute->exists()) { $tablefield = new ManyManyComplexTableField($this, 'Attributes', 'Attribute', array('Title' => 'Title', 'Label' => 'Label', 'Description' => 'Description'), 'getCMSFields'); $tablefield->setPermissions(array()); $fields->addFieldToTab("Root.Content.Attributes", new HeaderField('AttributeHeading', 'Select attributes for this product', 3)); $attributeHelp = <<<EOS <p class="ProductHelp"> Once attributes are selected don't forget to save. Always make sure there are options for each attribute and variations which are enabled and have an option selected for each attribute. </p> EOS; $fields->addFieldToTab("Root.Content.Attributes", new LiteralField('AttributeHelp', $attributeHelp)); $attributeAlert = <<<EOS <p id="AttributeAlert" class="message good"> Please 'Save' after you have finished changing attributes and check that product variations are correct. </p> EOS; $fields->addFieldToTab("Root.Content.Attributes", new LiteralField('AttributeAlert', $attributeAlert)); $fields->addFieldToTab("Root.Content.Attributes", $tablefield); } //Options selection $attributes = $this->Attributes(); if ($attributes && $attributes->exists()) { //Remove the stock level field if there are variations, each variation has a stock field $fields->removeByName('Stock'); $variationFieldList = array(); $fields->addFieldToTab("Root.Content", new TabSet('Options')); $fields->addFieldToTab("Root.Content", new Tab('Variations')); foreach ($attributes as $attribute) { $variationFieldList['AttributeValue_' . $attribute->ID] = $attribute->Title; //TODO refactor, this is a really dumb place to be writing default options probably //If there aren't any existing options for this attribute on this product, //populate with the default options $defaultOptions = DataObject::get('Option', "ProductID = 0 AND AttributeID = {$attribute->ID}"); $existingOptions = DataObject::get('Option', "ProductID = {$this->ID} AND AttributeID = {$attribute->ID}"); if (!$existingOptions || !$existingOptions->exists()) { if ($defaultOptions && $defaultOptions->exists()) { foreach ($defaultOptions as $option) { $newOption = $option->duplicate(false); $newOption->ProductID = $this->ID; $newOption->write(); } } } $attributeTabName = str_replace(' ', '', $attribute->Title); $fields->addFieldToTab("Root.Content.Options", new Tab($attributeTabName)); $manager = new OptionComplexTableField($this, $attribute->Title, 'Option', array('Title' => 'Title'), 'getCMSFields_forPopup', "AttributeID = {$attribute->ID}"); $manager->setAttributeID($attribute->ID); $fields->addFieldToTab("Root.Content.Options." . $attributeTabName, $manager); } $variationFieldList = array_merge($variationFieldList, singleton('Variation')->summaryFields()); $manager = new VariationComplexTableField($this, 'Variations', 'Variation', $variationFieldList, 'getCMSFields_forPopup'); if (class_exists('SWS_Xero_Item_Decorator')) { $manager->setPopupSize(500, 650); } $fields->addFieldToTab("Root.Content.Variations", $manager); } //Product ordering $categories = $this->ProductCategories(); if ($categories && $categories->exists()) { $fields->addFieldToTab("Root.Content", new Tab('Order')); $fields->addFieldToTab("Root.Content.Order", new HeaderField('OrderHeading', 'Set the order of this product in each of it\'s categories', 3)); $orderHelp = <<<EOS <p class="ProductHelp"> Products with higher order numbers in each category will appear further at the front of that category. </p> EOS; $fields->addFieldToTab("Root.Content.Order", new LiteralField('OrderHelp', $orderHelp)); foreach ($categories as $category) { $categoryTitle = $category->Title; $categoryID = $category->ID; $productID = $this->ID; $sql = <<<EOS SELECT "ProductOrder" FROM "ProductCategory_Products" WHERE "ProductCategoryID" = {$categoryID} AND "ProductID" = {$productID} EOS; $query = DB::query($sql); $order = $query->value(); $val = $order ? $order : 0; $fields->addFieldToTab('Root.Content.Order', new TextField("CategoryOrder[{$categoryID}]", "Order in {$categoryTitle} Category", $val)); } } //Ability to edit fields added to CMS here $this->extend('updateProductCMSFields', $fields); if (file_exists(BASE_PATH . '/swipestripe') && ShopSettings::get_license_key() == null) { $fields->addFieldToTab("Root.Content.Main", new LiteralField("SwipeStripeLicenseWarning", '<p class="message warning"> Warning: You have SwipeStripe installed without a license key. Please <a href="http://swipestripe.com" target="_blank">purchase a license key here</a> before this site goes live. </p>'), "Title"); } return $fields; }
/** * Handles any kind of database error * @throws Cx\Lib\Update_DatabaseException * @return boolean False. Always. */ static function errorHandler() { // ShopCategory // Fix the Text and Settings table first \Text::errorHandler(); ShopSettings::errorHandler(); $default_lang_id = \FWLanguage::getDefaultLangId(); $table_name = DBPREFIX . 'module_shop_categories'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'catid'), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'parentid'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'catsorting'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'catstatus'), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''), 'flags' => array('type' => 'VARCHAR(255)', 'default' => '')); $table_index = array('flags' => array('fields' => 'flags', 'type' => 'FULLTEXT')); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'catname')) { // Migrate all ShopCategory names to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); \Text::deleteByKey('Shop', self::TEXT_DESCRIPTION); $query = "\n SELECT `catid`, `catname`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query ShopCategory names"); } while (!$objResult->EOF) { $id = $objResult->fields['catid']; $name = $objResult->fields['catname']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate ShopCategory name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
/** * Output license keys in XML format * * @see Page_Controller::init() */ public function init() { $data = array(); $data['Key'] = ShopSettings::get_license_key(); //Find folders that start with swipestripe_, get their license keys $base = Director::baseFolder() . '/swipestripe_'; $dirs = glob($base . '*', GLOB_ONLYDIR); $extensionLicenseKeys = ShopSettings::get_extension_license_keys(); if ($dirs && is_array($dirs)) { $data['Extensions'] = array(); foreach ($dirs as $dir) { $extensionName = str_replace($base, '', $dir); if ($extensionName) { $data['Extensions'][]['Extension'] = array('Name' => $extensionName, 'Key' => $extensionLicenseKeys[$extensionName]); } } } $xml = new SimpleXMLElement("<?xml version=\"1.0\"?><SwipeStripe></SwipeStripe>"); $this->array_to_xml($data, $xml); header("content-type: text/xml"); print $xml->asXML(); exit; }
/** * Handles database errors * * Also migrates the old database structure to the new one * @return boolean False. Always. */ static function errorHandler() { // Order ShopSettings::errorHandler(); \Cx\Core\Country\Controller\Country::errorHandler(); $table_name = DBPREFIX . 'module_shop_order_items'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'order_items_id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'orderid'), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'productid'), 'product_name' => array('type' => 'VARCHAR(255)', 'default' => ''), 'price' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00'), 'quantity' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'vat_rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'vat_percent'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0')); $table_index = array('order' => array('fields' => array('order_id'))); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_order_attributes'; if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) { $table_name_old = DBPREFIX . 'module_shop_order_items_attributes'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'orders_items_attributes_id'), 'item_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'order_items_id'), 'attribute_name' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'product_option_name'), 'option_name' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'product_option_value'), 'price' => array('type' => 'DECIMAL(9,2)', 'unsigned' => false, 'default' => '0.00', 'renamefrom' => 'product_option_values_price')); $table_index = array('item_id' => array('fields' => array('item_id'))); \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name); } // LSV $table_name = DBPREFIX . 'module_shop_lsv'; $table_structure = array('order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'id'), 'holder' => array('type' => 'tinytext', 'default' => ''), 'bank' => array('type' => 'tinytext', 'default' => ''), 'blz' => array('type' => 'tinytext', 'default' => '')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_orders'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'orderid'), 'customer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'customerid'), 'currency_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'selected_currency_id'), 'shipment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'shipping_id'), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'customer_lang'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'order_status'), 'sum' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_order_sum'), 'vat_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'tax_price'), 'shipment_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_ship_price'), 'payment_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_payment_price'), 'billing_gender' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null), 'billing_company' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null), 'billing_firstname' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null), 'billing_lastname' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null), 'billing_address' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null), 'billing_city' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null), 'billing_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'default' => null), 'billing_country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'billing_phone' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null), 'billing_fax' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null), 'billing_email' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'default' => null), 'gender' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_prefix'), 'company' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_company'), 'firstname' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_firstname'), 'lastname' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_lastname'), 'address' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_address'), 'city' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_city'), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_zip'), 'country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_country_id'), 'phone' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_phone'), 'ip' => array('type' => 'VARCHAR(50)', 'default' => '', 'renamefrom' => 'customer_ip'), 'host' => array('type' => 'VARCHAR(100)', 'default' => '', 'renamefrom' => 'customer_host'), 'browser' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'customer_browser'), 'note' => array('type' => 'TEXT', 'default' => '', 'renamefrom' => 'customer_note'), 'date_time' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'order_date'), 'modified_on' => array('type' => 'TIMESTAMP', 'default' => null, 'notnull' => false, 'renamefrom' => 'last_modified'), 'modified_by' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null)); $table_index = array('status' => array('fields' => array('status'))); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // TODO: TEST // Migrate present Customer addresses to the new billing address fields. // Note that this method is also called in Customer::errorHandler() *before* // any Customer is modified. Thus, we can safely depend on the old // Customer table in one way -- if it doesn't exist, all Orders and Customers // have been successfully migrated already. $table_name_customer = DBPREFIX . "module_shop_customers"; if (\Cx\Lib\UpdateUtil::table_exist($table_name_customer)) { // On the other hand, there may have been an error somewhere in between // altering the Orders table and moving Customers to the Users table. // So, to be on the safe side, we will only update Orders where the billing // address fields are all NULL, as is the case just after the alteration // of the Orders table above. // Also note that any inconsistencies involving missing Customer records will // be left over as-is and may later be handled in the backend. $objResult = \Cx\Lib\UpdateUtil::sql("\n SELECT DISTINCT `customer_id`,\n `customer`.`prefix`,\n `customer`.`firstname`, `customer`.`lastname`,\n `customer`.`company`, `customer`.`address`,\n `customer`.`city`, `customer`.`zip`,\n `customer`.`country_id`,\n `customer`.`phone`, `customer`.`fax`,\n `customer`.`email`\n FROM `{$table_name}`\n JOIN `{$table_name_customer}` AS `customer`\n ON `customerid`=`customer_id`\n WHERE `billing_gender` IS NULL\n AND `billing_company` IS NULL\n AND `billing_firstname` IS NULL\n AND `billing_lastname` IS NULL\n AND `billing_address` IS NULL\n AND `billing_city` IS NULL\n AND `billing_zip` IS NULL\n AND `billing_country_id` IS NULL\n AND `billing_phone` IS NULL\n AND `billing_fax` IS NULL\n AND `billing_email` IS NULL"); while ($objResult && !$objResult->EOF) { $customer_id = $objResult->fields['customer_id']; $gender = 'gender_unknown'; if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['prefix'])) { $gender = 'gender_female'; } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['prefix'])) { $gender = 'gender_male'; } \Cx\Lib\UpdateUtil::sql("\n UPDATE `{$table_name}`\n SET `billing_gender`='" . addslashes($gender) . "',\n `billing_company`='" . addslashes($objResult->fields['company']) . "',\n `billing_firstname`='" . addslashes($objResult->fields['firstname']) . "',\n `billing_lastname`='" . addslashes($objResult->fields['lastname']) . "',\n `billing_address`='" . addslashes($objResult->fields['address']) . "',\n `billing_city`='" . addslashes($objResult->fields['city']) . "',\n `billing_zip`='" . addslashes($objResult->fields['zip']) . "',\n `billing_country_id`=" . intval($objResult->fields['country_id']) . ",\n `billing_phone`='" . addslashes($objResult->fields['phone']) . "',\n `billing_fax`='" . addslashes($objResult->fields['fax']) . "',\n `billing_email`='" . addslashes($objResult->fields['email']) . "'\n WHERE `customer_id`={$customer_id}\n AND `billing_gender` IS NULL\n AND `billing_company` IS NULL\n AND `billing_firstname` IS NULL\n AND `billing_lastname` IS NULL\n AND `billing_address` IS NULL\n AND `billing_city` IS NULL\n AND `billing_zip` IS NULL\n AND `billing_country_id` IS NULL\n AND `billing_phone` IS NULL\n AND `billing_fax` IS NULL\n AND `billing_email` IS NULL"); $objResult->MoveNext(); } } // Finally, update the migrated Order records with the proper gender // strings as used in the User class hierarchy as well $objResult = \Cx\Lib\UpdateUtil::sql("\n SELECT `id`, `gender`\n FROM `{$table_name}`\n WHERE `gender` NOT IN\n ('gender_male', 'gender_female', 'gender_undefined')"); while ($objResult && !$objResult->EOF) { $gender = 'gender_unknown'; if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['gender'])) { $gender = 'gender_female'; } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['gender'])) { $gender = 'gender_male'; } \Cx\Lib\UpdateUtil::sql("\n UPDATE `{$table_name}`\n SET `gender`='" . addslashes($gender) . "'\n WHERE `id`=" . $objResult->fields['id']); $objResult->MoveNext(); } // Always return false; }
static function view_settings_general() { // General settings self::$objTemplate->addBlockfile('SHOP_SETTINGS_FILE', 'settings_block', 'module_shop_settings_general.html'); // TODO: Temporary. Remove in release with working update // Returns NULL on missing entries even when other settings are properly loaded $test = \Cx\Core\Setting\Controller\Setting::getValue('shopnavbar_on_all_pages', 'Shop'); if ($test === NULL) { ShopSettings::errorHandler(); \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); } self::$objTemplate->setVariable(array('SHOP_CONFIRMATION_EMAILS' => \Cx\Core\Setting\Controller\Setting::getValue('email_confirmation', 'Shop'), 'SHOP_CONTACT_EMAIL' => \Cx\Core\Setting\Controller\Setting::getValue('email', 'Shop'), 'SHOP_CONTACT_COMPANY' => \Cx\Core\Setting\Controller\Setting::getValue('company', 'Shop'), 'SHOP_CONTACT_ADDRESS' => \Cx\Core\Setting\Controller\Setting::getValue('address', 'Shop'), 'SHOP_CONTACT_TEL' => \Cx\Core\Setting\Controller\Setting::getValue('telephone', 'Shop'), 'SHOP_CONTACT_FAX' => \Cx\Core\Setting\Controller\Setting::getValue('fax', 'Shop'), 'SHOP_GENERAL_COUNTRY_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions(\Cx\Core\Setting\Controller\Setting::getValue('country_id', 'Shop')), 'SHOP_THUMBNAIL_MAX_WIDTH' => \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_width', 'Shop'), 'SHOP_THUMBNAIL_MAX_HEIGHT' => \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_height', 'Shop'), 'SHOP_THUMBNAIL_QUALITY' => \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_quality', 'Shop'), 'SHOP_WEIGHT_ENABLE_CHECKED' => \Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop') ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_SHOW_PRODUCTS_DEFAULT_OPTIONS' => Products::getDefaultViewMenuoptions(\Cx\Core\Setting\Controller\Setting::getValue('show_products_default', 'Shop')), 'SHOP_PRODUCT_SORTING_MENUOPTIONS' => Products::getProductSortingMenuoptions(), 'SHOP_ORDERITEMS_AMOUNT_MAX' => Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop')), 'SHOP_ORDERITEMS_AMOUNT_MIN' => Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop')), 'SHOP_CURRENCY_CODE' => Currency::getCurrencyCodeById(Currency::getDefaultCurrencyId()), 'SHOP_SETTING_CART_USE_JS' => \Html::getCheckbox('use_js_cart', 1, false, \Cx\Core\Setting\Controller\Setting::getValue('use_js_cart', 'Shop')), 'SHOP_SETTING_SHOPNAVBAR_ON_ALL_PAGES' => \Html::getCheckbox('shopnavbar_on_all_pages', 1, false, \Cx\Core\Setting\Controller\Setting::getValue('shopnavbar_on_all_pages', 'Shop')), 'SHOP_SETTING_REGISTER' => \Html::getSelectCustom('register', ShopLibrary::getRegisterMenuoptions(\Cx\Core\Setting\Controller\Setting::getValue('register', 'Shop')), false, '', 'style="width: 270px;"'), 'SHOP_SETTING_NUMOF_PRODUCTS_PER_PAGE_BACKEND' => \Cx\Core\Setting\Controller\Setting::getValue('numof_products_per_page_backend', 'Shop'), 'SHOP_SETTING_NUMOF_ORDERS_PER_PAGE_BACKEND' => \Cx\Core\Setting\Controller\Setting::getValue('numof_orders_per_page_backend', 'Shop'), 'SHOP_SETTING_NUMOF_CUSTOMERS_PER_PAGE_BACKEND' => \Cx\Core\Setting\Controller\Setting::getValue('numof_customers_per_page_backend', 'Shop'), 'SHOP_SETTING_NUMOF_MANUFACTURERS_PER_PAGE_BACKEND' => \Cx\Core\Setting\Controller\Setting::getValue('numof_manufacturers_per_page_backend', 'Shop'), 'SHOP_SETTING_NUMOF_MAILTEMPLATE_PER_PAGE_BACKEND' => \Cx\Core\Setting\Controller\Setting::getValue('numof_mailtemplate_per_page_backend', 'Shop'), 'SHOP_SETTING_NUMOF_COUPON_PER_PAGE_BACKEND' => \Cx\Core\Setting\Controller\Setting::getValue('numof_coupon_per_page_backend', 'Shop'), 'SHOP_SETTING_NUMOF_PRODUCTS_PER_PAGE_FRONTEND' => \Cx\Core\Setting\Controller\Setting::getValue('numof_products_per_page_frontend', 'Shop'), 'SHOP_SETTING_USERGROUP_ID_CUSTOMER' => \Html::getSelect('usergroup_id_customer', \UserGroup::getNameArray(), \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'), '', '', 'tabindex="0" style="width: 270px;"'), 'SHOP_SETTING_USERGROUP_ID_RESELLER' => \Html::getSelect('usergroup_id_reseller', \UserGroup::getNameArray(), \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'), '', '', 'tabindex="0" style="width: 270px;"'), 'SHOP_SETTING_USER_PROFILE_ATTRIBUTE_CUSTOMER_GROUP_ID' => \Html::getSelect('user_profile_attribute_customer_group_id', \User_Profile_Attribute::getCustomAttributeNameArray(), \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_group_id', 'Shop'), '', '', 'tabindex="0" style="width: 270px;"'), 'SHOP_SETTING_USER_PROFILE_ATTRIBUTE_NOTES' => \Html::getSelect('user_profile_attribute_notes', \User_Profile_Attribute::getCustomAttributeNameArray(), \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes', 'Shop'), '', '', 'tabindex="0" style="width: 270px;"'))); }