예제 #1
0
 /**
  * Show the customer and article group discounts for editing.
  *
  * Handles storing of the discounts as well.
  * @return    boolean             True on success, false otherwise
  * @author    Reto Kohli <*****@*****.**>
  */
 function view_customer_discounts()
 {
     if (!empty($_POST['store'])) {
         $this->store_discount_customer();
     }
     self::$objTemplate->loadTemplateFile("module_shop_discount_customer.html");
     // Discounts overview
     $arrCustomerGroups = Discount::getCustomerGroupArray();
     $arrArticleGroups = Discount::getArticleGroupArray();
     $arrRate = null;
     $arrRate = Discount::getDiscountRateCustomerArray();
     $i = 0;
     // Set up the customer groups header
     self::$objTemplate->setVariable(array('SHOP_CUSTOMER_GROUP_COUNT' => count($arrCustomerGroups), 'SHOP_DISCOUNT_ROW_STYLE' => 'row' . (++$i % 2 + 1)));
     foreach ($arrCustomerGroups as $id => $arrCustomerGroup) {
         self::$objTemplate->setVariable(array('SHOP_CUSTOMER_GROUP_ID' => $id, 'SHOP_CUSTOMER_GROUP_NAME' => $arrCustomerGroup['name']));
         self::$objTemplate->parse('customer_group_header_column');
         self::$objTemplate->touchBlock('article_group_header_column');
         self::$objTemplate->parse('article_group_header_column');
     }
     foreach ($arrArticleGroups as $groupArticleId => $arrArticleGroup) {
         //DBG::log("Article group ID $groupArticleId");
         foreach ($arrCustomerGroups as $groupCustomerId => $arrCustomerGroup) {
             $rate = isset($arrRate[$groupCustomerId][$groupArticleId]) ? $arrRate[$groupCustomerId][$groupArticleId] : 0;
             self::$objTemplate->setVariable(array('SHOP_CUSTOMER_GROUP_ID' => $groupCustomerId, 'SHOP_DISCOUNT_RATE' => sprintf('%2.2f', $rate)));
             self::$objTemplate->parse('discount_column');
         }
         self::$objTemplate->setVariable(array('SHOP_ARTICLE_GROUP_ID' => $groupArticleId, 'SHOP_ARTICLE_GROUP_NAME' => $arrArticleGroup['name'], 'SHOP_DISCOUNT_ROW_STYLE' => 'row' . (++$i % 2 + 1)));
         self::$objTemplate->parse('article_group_row');
     }
     self::$objTemplate->setGlobalVariable('SHOP_DISCOUNT_ROW_STYLE', 'row' . (++$i % 2 + 1));
     //        self::$objTemplate->touchBlock('article_group_header_row');
     //        self::$objTemplate->parse('article_group_header_row');
     return true;
 }
예제 #2
0
 /**
  * Render the option field in the backend.
  *
  * @param Sigma $template
  */
 public function renderOptionField($template)
 {
     global $_ARRAYLANG;
     $subTemplate = new Sigma();
     $subTemplate->loadTemplateFile($this->cx->getCodeBaseCoreModulePath() . '/TemplateEditor/View/Template/Backend/ImagesSeriesOption.html');
     $subTemplate->setGlobalVariable($_ARRAYLANG);
     foreach ($this->urls as $id => $url) {
         $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_VALUE', $url);
         $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_ID', $id);
         $subTemplate->parse('images');
     }
     $mediaBrowser = new MediaBrowser();
     $mediaBrowserId = $this->name . '_mediabrowser';
     $mediaBrowser->setOptions(array('id' => $mediaBrowserId));
     $mediaBrowser->setOptions(array('views' => 'uploader,filebrowser', 'startview' => 'filebrowser'));
     $mediaBrowser->setCallback('callback_' . $this->name);
     $subTemplate->setVariable('MEDIABROWSER_BUTTON', $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_MODULE_TEMPLATEEDITOR_ADD_PICTURE']));
     $subTemplate->setVariable('MEDIABROWSER_ID', $mediaBrowserId);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_NAME', $this->name);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_HUMAN_NAME', $this->humanName);
     //Get last key
     end($this->urls);
     $key = key($this->urls);
     $key = $key != null ? $key : '0';
     $subTemplate->setVariable('TEMPLATEEDITOR_LASTID', $key);
     $template->setVariable('TEMPLATEEDITOR_OPTION', $subTemplate->get());
     $template->setVariable('TEMPLATEEDITOR_OPTION_TYPE', 'img series');
     $template->parse('option');
 }
예제 #3
0
 function setMotives()
 {
     global $objDatabase, $_ARRAYLANG;
     \JS::activate('shadowbox');
     $this->_objTpl->loadTemplateFile('module_ecard_overview.html', true, true);
     $this->_pageTitle = $_ARRAYLANG['TXT_MOTIVE_SELECTION'];
     $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
     $mediaBrowser->setCallback('mbCallback');
     $mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => 'filebrowser', 'id' => 'mediabrowser_button', 'style' => 'display: none;'));
     /* Update progress */
     if (!empty($_POST['saveMotives'])) {
         $i = 0;
         $motiveInputArray = $_POST['motiveInputArray'];
         while ($i < 9) {
             $filepath = $motiveInputArray[$i];
             $filename = basename($filepath);
             $query = "\n                    UPDATE " . DBPREFIX . "module_ecard_settings\n                       SET setting_value='" . contrexx_addslashes($filename) . "'\n                     WHERE setting_name='motive_{$i}'";
             $objResult = $objDatabase->Execute($query);
             /* Create optimized picture for e-card dispatch */
             if ($filepath != '' && file_exists(\Env::get('cx')->getWebsitePath() . $filepath)) {
                 $this->resizeMotive(2, \Env::get('cx')->getWebsitePath() . $filepath, ASCMS_ECARD_OPTIMIZED_PATH . '/');
                 $this->resizeMotive(1, \Env::get('cx')->getWebsitePath() . $filepath, ASCMS_ECARD_THUMBNAIL_PATH . '/');
             }
             ++$i;
         }
         $this->_objTpl->setVariable(array('CONTENT_OK_MESSAGE' => $this->strOkMessage = $_ARRAYLANG['TXT_DATA_SAVED']));
     }
     $this->_objTpl->setGlobalVariable(array('TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_DELETE_MOTIVE' => $_ARRAYLANG['TXT_DELETE_MOTIVE'], 'TXT_PICTURE' => $_ARRAYLANG['TXT_PICTURE'], 'TXT_PATH' => $_ARRAYLANG['TXT_PATH'], 'TXT_BROWSE' => $_ARRAYLANG['TXT_BROWSE'], 'TXT_CHOOSE' => $_ARRAYLANG['TXT_CHOOSE'], 'TXT_DELETE' => $_ARRAYLANG['TXT_DELETE'], 'TXT_ECARD_IMAGES' => $_ARRAYLANG['TXT_ECARD_IMAGES'], 'MEDIABROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
     /* Display progress */
     $query = "\n            SELECT `setting_value`\n              FROM " . DBPREFIX . "module_ecard_settings\n             WHERE setting_name LIKE 'motive_%'\n             ORDER BY setting_name ASC";
     $objResult = $objDatabase->Execute($query);
     $i = 0;
     /* Create thumbnails */
     while (!$objResult->EOF) {
         $motiveFilename = $objResult->fields['setting_value'];
         $thumbnail = ASCMS_ECARD_THUMBNAIL_WEB_PATH . '/' . "no_picture.gif";
         $sourcePath = '';
         if ($motiveFilename != '') {
             $sourcePath = ASCMS_ECARD_OPTIMIZED_WEB_PATH . '/' . $motiveFilename;
             $thumbnail = ASCMS_ECARD_THUMBNAIL_WEB_PATH . '/' . $motiveFilename;
         }
         /* Initialize DATA placeholder */
         $this->_objTpl->setVariable(array('MOTIVE_PATH' => $sourcePath, 'MOTIVE_THUMB_PATH' => $thumbnail, 'MOTIVE_ID' => $i++));
         $this->_objTpl->parse('motiveBlock');
         $objResult->MoveNext();
     }
     $this->_objTpl->replaceBlock('motiveBlock', '', true);
 }
예제 #4
0
 function _orders()
 {
     global $objDatabase, $_ARRAYLANG;
     $this->objTemplate->loadTemplateFile('module_gov_orders_overview.html');
     $this->_pageTitle = $_ARRAYLANG['TXT_ORDERS'];
     if (isset($_REQUEST['err'])) {
         $this->_strErrMessage = $_REQUEST['err'];
     }
     // delete orders
     if (isset($_REQUEST['delete'])) {
         if (isset($_REQUEST['multi'])) {
             if (is_array($_POST['selectedOrderId'])) {
                 foreach ($_POST['selectedOrderId'] as $GSOrderID) {
                     $objDatabase->Execute("\n                            DELETE\n                              FROM " . DBPREFIX . "module_egov_orders\n                             WHERE order_id=" . intval($GSOrderID));
                     $objDatabase->Execute("\n                            DELETE\n                              FROM " . DBPREFIX . "module_egov_product_calendar\n                             WHERE calendar_order=" . intval($GSOrderID));
                 }
             }
         } else {
             $objDatabase->Execute("\n                    DELETE\n                      FROM " . DBPREFIX . "module_egov_orders\n                     WHERE order_id=" . intval($_REQUEST['id']));
             $objDatabase->Execute("\n                    DELETE\n                      FROM " . DBPREFIX . "module_egov_product_calendar\n                     WHERE calendar_order=" . intval($_REQUEST['id']));
         }
     }
     $this->objTemplate->setGlobalVariable($_ARRAYLANG);
     $query = "\n            SELECT *\n              FROM " . DBPREFIX . "module_egov_orders" . (!empty($_REQUEST['product']) ? ' WHERE order_product=' . $_REQUEST["product"] : '') . "\n             ORDER BY order_id DESC";
     $objResult = $objDatabase->Execute($query);
     $i = 0;
     while (!$objResult->EOF) {
         $stateImg = 'status_yellow.gif';
         switch ($objResult->fields['order_state']) {
             case 1:
                 $stateImg = 'status_green.gif';
                 break;
             case 2:
                 $stateImg = 'status_red.gif';
                 break;
             case 0:
             case 3:
             default:
                 break;
         }
         $this->objTemplate->setVariable(array('ORDERS_ROWCLASS' => ++$i % 2 ? 'row2' : 'row1', 'ORDER_ID' => $objResult->fields['order_id'], 'ORDER_DATE' => $objResult->fields['order_date'], 'ORDER_ID' => $objResult->fields['order_id'], 'ORDER_STATE' => EgovLibrary::MaskState($objResult->fields['order_state']), 'ORDER_PRODUCT' => EgovLibrary::GetProduktValue('product_name', $objResult->fields['order_product']), 'ORDER_NAME' => $this->ParseFormValues('Vorname', $objResult->fields['order_values']) . ' ' . $this->ParseFormValues('Nachname', $objResult->fields['order_values']), 'ORDER_STATE_IMG' => $stateImg, 'ORDER_IP' => $objResult->fields['order_ip']));
         $this->objTemplate->parse('orders_row');
         $objResult->MoveNext();
     }
     if ($i == 0) {
         $this->objTemplate->hideBlock('orders_row');
     }
 }
예제 #5
0
 /**
  * Show NewsML categories page
  * @access private
  * @global object $objDatabase
  */
 function _newsMLOverview()
 {
     global $_ARRAYLANG;
     $this->_objTpl->loadTemplateFile('module_feed_newsml_overview.html');
     $this->pageTitle = 'NewsML';
     $rowNr = 0;
     $this->_objTpl->setVariable(array('TXT_FEED_MARKED' => $_ARRAYLANG['TXT_FEED_MARKED'], 'TXT_FEED_MARK_ALL' => $_ARRAYLANG['TXT_FEED_MARK_ALL'], 'TXT_FEED_REMOVE_CHOICE' => $_ARRAYLANG['TXT_FEED_REMOVE_CHOICE'], 'TXT_FEED_DELETE_MARKED' => $_ARRAYLANG['TXT_FEED_DELETE_MARKED'], 'TXT_FEED_NEWSML_CATEGORIES' => $_ARRAYLANG['TXT_FEED_NEWSML_CATEGORIES'], 'TXT_FEED_CATEGORY' => $_ARRAYLANG['TXT_FEED_CATEGORY'], 'TXT_FEED_TEMPLATE_PLACEHOLDER' => $_ARRAYLANG['TXT_FEED_TEMPLATE_PLACEHOLDER'], 'TXT_FEED_NEWSML_PROVIDER' => $_ARRAYLANG['TXT_FEED_NEWSML_PROVIDER'], 'TXT_FEED_FUNCTIONS' => $_ARRAYLANG['TXT_FEED_FUNCTIONS'], 'TXT_FEED_SHOW_DETAILS' => $_ARRAYLANG['TXT_FEED_SHOW_DETAILS'], 'TXT_FEED_EDIT_CATEGORY' => $_ARRAYLANG['TXT_FEED_EDIT_CATEGORY'], 'TXT_FEED_INSERT_CATEGORY' => $_ARRAYLANG['TXT_FEED_INSERT_CATEGORY'], 'TXT_FEED_INFO' => $_ARRAYLANG['TXT_FEED_INFO'], 'TXT_FEED_WHAT_IS_NEWSML' => $_ARRAYLANG['TXT_FEED_WHAT_IS_NEWSML'], 'TXT_FEED_NEWSML_DESCRIPTION' => $_ARRAYLANG['TXT_FEED_NEWSML_DESCRIPTION'], 'TXT_FEED_CONFIRM_DELETE_CATEGORY' => $_ARRAYLANG['TXT_FEED_CONFIRM_DELETE_CATEGORY'], 'TXT_FEED_CONFIRM_DELETE_CATEGORIES' => $_ARRAYLANG['TXT_FEED_CONFIRM_DELETE_CATEGORIES'], 'TXT_FEED_ACTION_COULD_NOT_BE_UNDONE' => $_ARRAYLANG['TXT_FEED_ACTION_COULD_NOT_BE_UNDONE']));
     $this->_objTpl->setGlobalVariable(array('TXT_FEED_SHOW_DETAILS' => $_ARRAYLANG['TXT_FEED_SHOW_DETAILS'], 'TXT_FEED_EDIT_CATEGORY' => $_ARRAYLANG['TXT_FEED_EDIT_CATEGORY'], 'TXT_FEED_DELETE_CATEGORY' => $_ARRAYLANG['TXT_FEED_DELETE_CATEGORY']));
     if (empty($this->_objNewsML->arrCategories)) {
         $this->_objTpl->hideBlock('feed_newsml_list');
         return;
     }
     foreach ($this->_objNewsML->arrCategories as $newsMLProviderId => $arrNewsMLProvider) {
         $this->_objTpl->setVariable(array('FEED_NEWSML_CATEGORY_ID' => $newsMLProviderId, 'FEED_NEWSML_ID' => $newsMLProviderId, 'FEED_NEWSML_LIST_ROW_CLASS' => ++$rowNr % 2 ? 'row1' : 'row2', 'FEED_NEWSML_NAME' => $arrNewsMLProvider['name'], 'FEED_NEWSML_PLACEHOLDER' => 'NEWSML_' . strtoupper(preg_replace('/\\s/', '_', $arrNewsMLProvider['name'])), 'FEED_NEWSML_PROVIDER' => $arrNewsMLProvider['providerName']));
         $this->_objTpl->parse('feed_newsml_list');
     }
 }
예제 #6
0
 /**
  * Render the option field in the backend.
  *
  * @param Sigma $template
  */
 public function renderOptionField($template)
 {
     global $_ARRAYLANG;
     $subTemplate = new Sigma();
     $subTemplate->loadTemplateFile($this->cx->getCodeBaseCoreModulePath() . '/TemplateEditor/View/Template/Backend/ImageOption.html');
     $subTemplate->setGlobalVariable($_ARRAYLANG);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_VALUE', $this->url);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_NAME', $this->name);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_HUMAN_NAME', $this->humanName);
     $mediaBrowser = new MediaBrowser();
     $mediaBrowser->setOptions(array('views' => 'uploader,filebrowser', 'startView' => 'filebrowser'));
     $mediaBrowser->setCallback('callback_' . $this->name);
     $subTemplate->setVariable('MEDIABROWSER_BUTTON', $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_MODULE_TEMPLATEEDITOR_CHOOSE_PICTURE']));
     $template->setVariable('TEMPLATEEDITOR_OPTION', $subTemplate->get());
     $template->setVariable('TEMPLATEEDITOR_OPTION_TYPE', 'img');
     $template->parse('option');
 }
예제 #7
0
 /**
  * Add or edit the jobs Locations
  * @global    object     $objDatabase
  * @global    array      $_ARRAYLANG
  * @param     string     $pageContent
  */
 function manageLocations()
 {
     global $objDatabase, $_ARRAYLANG;
     $this->pageTitle = $_ARRAYLANG['TXT_LOCATION_MANAGER'];
     $this->_objTpl->loadTemplateFile('module_jobs_location.html', true, true);
     $this->_objTpl->setVariable(array('TXT_ADD_NEW_LOCATION' => $_ARRAYLANG['TXT_ADD_NEW_LOCATION'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_ADD' => $_ARRAYLANG['TXT_ADD'], 'TXT_SELECT_ALL' => $_ARRAYLANG['TXT_SELECT_ALL'], 'TXT_REMOVE_SELECTION' => $_ARRAYLANG['TXT_REMOVE_SELECTION'], 'TXT_LOCATION_LIST' => $_ARRAYLANG['TXT_LOCATION_LIST'], 'TXT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_ACTION' => $_ARRAYLANG['TXT_ACTION'], 'TXT_ACCEPT_CHANGES' => $_ARRAYLANG['TXT_ACCEPT_CHANGES'], 'TXT_CONFIRM_DELETE_DATA' => $_ARRAYLANG['TXT_CONFIRM_DELETE_DATA'], 'TXT_ACTION_IS_IRREVERSIBLE' => $_ARRAYLANG['TXT_ACTION_IS_IRREVERSIBLE'], 'TXT_ATTENTION_SYSTEM_FUNCTIONALITY_AT_RISK' => $_ARRAYLANG['TXT_ATTENTION_SYSTEM_FUNCTIONALITY_AT_RISK'], 'TXT_JOBS_SORTING' => $_ARRAYLANG['TXT_JOBS_SORTING'], 'TXT_JOBS_SORTTYPE' => $_ARRAYLANG['TXT_JOBS_SORTTYPE']));
     $this->_objTpl->setGlobalVariable(array('TXT_DELETE' => $_ARRAYLANG['TXT_DELETE']));
     // Add a new category
     if (isset($_POST['addLoc']) and $_POST['addLoc'] == true) {
         $locName = get_magic_quotes_gpc() ? strip_tags($_POST['newLocName']) : addslashes(strip_tags($_POST['newLocName']));
         if ($objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_jobs_location (name)\n                                 VALUES ('{$locName}')")) {
             $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_ADDED_SUCCESSFUL'];
         } else {
             $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'];
         }
     }
     // Modify a new category
     if (isset($_POST['modLoc']) and $_POST['modLoc'] == true) {
         foreach ($_POST['locName'] as $id => $name) {
             $name = get_magic_quotes_gpc() ? strip_tags($name) : addslashes(strip_tags($name));
             $id = intval($id);
             // Unused
             //                $sorting = !empty($_REQUEST['sortStyle'][$id]) ? contrexx_addslashes($_REQUEST['sortStyle'][$id]) : 'alpha';
             if ($objDatabase->Execute("UPDATE " . DBPREFIX . "module_jobs_location\n                                  SET name='{$name}'\n                                WHERE id={$id}")) {
                 $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL'];
             } else {
                 $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'];
             }
         }
     }
     $query = "SELECT `id`,\n                           `name`\n                      FROM `" . DBPREFIX . "module_jobs_location`\n                  ORDER BY `id` asc";
     $objResult = $objDatabase->Execute($query);
     $this->_objTpl->setCurrentBlock('row');
     $i = 0;
     while ($objResult !== false && !$objResult->EOF) {
         $class = $i % 2 == 0 ? "row1" : "row2";
         // Unused
         //            $sorting = $objResult->fields['sort_style'];
         $this->_objTpl->setVariable(array('JOBS_ROWCLASS' => $class, 'JOBS_LOC_ID' => $objResult->fields['id'], 'JOBS_LOC_NAME' => stripslashes($objResult->fields['name'])));
         $this->_objTpl->parseCurrentBlock('row');
         $i++;
         $objResult->MoveNext();
     }
 }
예제 #8
0
 /**
  * Set up the template block with the shipment terms and conditions
  *
  * Please *DO NOT* remove this method, despite the site terms and
  * conditions have been removed from the Shop!
  * This has been requested by some shopkeepers and may be used at will.
  * @global    array   $_ARRAYLANG     Language array
  * @author    Reto Kohli <*****@*****.**>
  */
 static function showShipmentTerms()
 {
     if (self::$objTemplate->blockExists('shopShipper')) {
         // TODO: Should be set by the calling view, if any
         global $_ARRAYLANG;
         self::$objTemplate->setGlobalVariable($_ARRAYLANG + array('SHOP_CURRENCY_SYMBOL' => Currency::getActiveCurrencySymbol(), 'SHOP_CURRENCY_CODE' => Currency::getActiveCurrencyCode()));
         $arrShipment = Shipment::getShipmentConditions();
         foreach ($arrShipment as $strShipperName => $arrContent) {
             $strCountries = join(', ', $arrContent['countries']);
             $arrConditions = $arrContent['conditions'];
             self::$objTemplate->setCurrentBlock('shopShipment');
             foreach ($arrConditions as $arrData) {
                 self::$objTemplate->setVariable(array('SHOP_MAX_WEIGHT' => $arrData['max_weight'], 'SHOP_COST_FREE' => $arrData['free_from'], 'SHOP_COST' => $arrData['fee']));
                 self::$objTemplate->parse('shopShipment');
             }
             self::$objTemplate->setVariable(array('SHOP_SHIPPER' => $strShipperName, 'SHOP_COUNTRIES' => $strCountries));
             self::$objTemplate->parse('shopShipper');
         }
     }
 }
예제 #9
0
 /**
  * Edit coupons
  * @param   \Cx\Core\Html\Sigma   $objTemplate    The Template
  */
 static function edit($objTemplate)
 {
     global $_ARRAYLANG;
     //DBG::activate(DBG_ADODB|DBG_LOG_FIREPHP|DBG_PHP);
     $result = true;
     if (isset($_GET['delete'])) {
         list($code, $customer_id) = explode('-', $_GET['delete']);
         $result &= self::delete(contrexx_input2raw($code), intval($customer_id));
     }
     $edit = isset($_REQUEST['edit']) ? contrexx_input2raw($_REQUEST['edit']) : null;
     //DBG::log("Edit: ".($edit ? $edit : 'NULL'));
     $code = isset($_POST['code']) ? contrexx_input2raw($_POST['code']) : null;
     $payment_id = empty($_POST['payment_id']) ? 0 : intval($_POST['payment_id']);
     $start_time = empty($_POST['start_date']) ? 0 : strtotime(contrexx_input2raw($_POST['start_date']));
     $end_time = empty($_POST['end_date_unlimited']) ? empty($_POST['end_date']) ? 0 : strtotime(contrexx_input2raw($_POST['end_date'])) : 0;
     $coupon_type = empty($_POST['coupon_type']) ? null : contrexx_input2raw($_POST['coupon_type']);
     $discount_rate = intval(empty($_POST['discount_rate']) ? 0 : floatval($_POST['discount_rate']));
     $discount_amount = Currency::formatPrice(empty($_POST['discount_amount']) ? 0 : floatval($_POST['discount_amount']));
     if ($coupon_type == 'rate') {
         $discount_amount = 0;
     }
     if ($coupon_type == 'amount') {
         $discount_rate = 0;
     }
     $minimum_amount = Currency::formatPrice(empty($_POST['minimum_amount']) ? 0 : floatval($_POST['minimum_amount']));
     $uses = empty($_POST['unlimited']) ? empty($_POST['uses']) ? 1 : intval($_POST['uses']) : self::USES_UNLIMITED;
     $customer_id = empty($_POST['customer_id']) ? 0 : intval($_POST['customer_id']);
     $product_id = empty($_POST['product_id']) ? 0 : intval($_POST['product_id']);
     $global = !empty($_POST['global_or_customer']);
     //DBG::log("code $code, start_time $start_time, end_time $end_time, minimum amount $minimum_amount, discount_rate $discount_rate, discount_amount $discount_amount, uses $uses, customer_id $customer_id");
     if (isset($code)) {
         $result &= self::storeCode($code, $payment_id, $minimum_amount, $discount_rate, $discount_amount, $start_time, $end_time, $uses, $global, $customer_id, $product_id, $edit);
         if ($result) {
             $code = $edit = null;
         } else {
             if (empty($edit)) {
                 $edit = "{$code}-{$customer_id}";
             }
         }
     }
     // Reset the end time if it's in the past
     if ($end_time < time()) {
         $end_time = 0;
     }
     $uri = \Html::getRelativeUri();
     \Html::stripUriParam($uri, 'view');
     \Html::stripUriParam($uri, 'edit');
     \Html::stripUriParam($uri, 'order_coupon');
     $arrSortingFields = array('code' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE'], 'start_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_START_TIME'], 'end_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME'], 'minimum_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'discount_rate' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_RATE'], 'discount_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'uses' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES'], 'global' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_SCOPE'], 'customer_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CUSTOMER'], 'product_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT'], 'payment_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT']);
     $objSorting = new \Sorting($uri, $arrSortingFields, true, 'order_coupon');
     $objTemplate->setGlobalVariable($_ARRAYLANG + array('TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_ADD_OR_EDIT' => $_ARRAYLANG[$edit ? 'TXT_SHOP_DISCOUNT_COUPON_EDIT' : 'TXT_SHOP_DISCOUNT_COUPON_ADD'], 'SHOP_DISCOUNT_COUPON_VIEW_ACTIVE' => $edit ? '' : 'active', 'SHOP_DISCOUNT_COUPON_EDIT_ACTIVE' => $edit ? 'active' : '', 'SHOP_DISCOUNT_COUPON_VIEW_DISPLAY' => $edit ? 'none' : 'block', 'SHOP_DISCOUNT_COUPON_EDIT_DISPLAY' => $edit ? 'block' : 'none', 'HEADER_SHOP_DISCOUNT_COUPON_CODE' => $objSorting->getHeaderForField('code'), 'HEADER_SHOP_DISCOUNT_COUPON_START_TIME' => $objSorting->getHeaderForField('start_time'), 'HEADER_SHOP_DISCOUNT_COUPON_END_TIME' => $objSorting->getHeaderForField('end_time'), 'HEADER_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('minimum_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_RATE' => $objSorting->getHeaderForField('discount_rate'), 'HEADER_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('discount_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_USES' => $objSorting->getHeaderForField('uses'), 'HEADER_SHOP_DISCOUNT_COUPON_SCOPE' => $objSorting->getHeaderForField('global'), 'HEADER_SHOP_DISCOUNT_COUPON_CUSTOMER' => $objSorting->getHeaderForField('customer_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PRODUCT' => $objSorting->getHeaderForField('product_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PAYMENT' => $objSorting->getHeaderForField('payment_id')));
     $count = 0;
     $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_coupon_per_page_backend', 'Shop');
     if (empty($limit)) {
         self::errorHandler();
     }
     $arrCoupons = self::getArray(\Paging::getPosition(), $limit, $count, $objSorting->getOrder());
     $arrProductName = Products::getNameArray(true, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_FORMAT']);
     $arrPaymentName = Payment::getNameArray();
     $i = 0;
     $row = 0;
     $objCouponEdit = new Coupon();
     $objCouponEdit->code($code);
     $objCouponEdit->payment_id($payment_id);
     $objCouponEdit->minimum_amount($minimum_amount);
     $objCouponEdit->discount_rate($discount_rate);
     $objCouponEdit->discount_amount($discount_amount);
     $objCouponEdit->start_time($start_time);
     $objCouponEdit->end_time($end_time);
     $objCouponEdit->uses($uses);
     $objCouponEdit->is_global($global);
     $objCouponEdit->customer_id($customer_id);
     $objCouponEdit->product_id($product_id);
     global $_CONFIG;
     foreach ($arrCoupons as $index => $objCoupon) {
         $coupon_uri_id = 'coupon_uri_' . $index;
         $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$row % 2 + 1), 'SHOP_DISCOUNT_COUPON_CODE' => $objCoupon->code, 'SHOP_DISCOUNT_COUPON_URI_ICON' => '<div class="icon_url"' . '>&nbsp;</div>', 'SHOP_DISCOUNT_COUPON_URI_INPUT' => '<div class="layer_url" id="' . $coupon_uri_id . '">' . \Html::getInputText('dummy', 'http://' . $_CONFIG['domainUrl'] . \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . '/' . CONTREXX_DIRECTORY_INDEX . '?section=Shop' . MODULE_INDEX . '&coupon_code=' . $objCoupon->code, false, 'readonly="readonly"' . ' style="width: 200px;"' . ' onfocus="this.select();"' . ' onblur="cx.jQuery(\'#' . $coupon_uri_id . '\').hide();"') . '</div>', 'SHOP_DISCOUNT_COUPON_START_TIME' => $objCoupon->start_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->start_time) : $_ARRAYLANG['TXT_SHOP_DATE_NONE'], 'SHOP_DISCOUNT_COUPON_END_TIME' => $objCoupon->end_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->end_time) : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED'], 'SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT' => $objCoupon->minimum_amount > 0 ? $objCoupon->minimum_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_RATE' => $objCoupon->discount_rate > 0 ? $objCoupon->discount_rate : $_ARRAYLANG['TXT_SHOP_RATE_NONE'], 'SHOP_DISCOUNT_COUPON_AMOUNT' => $objCoupon->discount_amount > 0 ? $objCoupon->discount_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_USES' => sprintf($_ARRAYLANG['TXT_SHOP_COUPON_USES_FORMAT'], $objCoupon->used, $objCoupon->uses < 1000000000.0 ? $objCoupon->uses : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_SCOPE' => $objCoupon->global ? $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_GLOBALLY'] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PER_CUSTOMER'], 'SHOP_DISCOUNT_COUPON_PER_CUSTOMER' => !$objCoupon->global ? \Html::getRadio('foo_' . ++$i, '', false, true, '', \Html::ATTRIBUTE_DISABLED) : '&nbsp;', 'SHOP_DISCOUNT_COUPON_CUSTOMER' => $objCoupon->customer_id ? Customers::getNameById($objCoupon->customer_id, '%4$s (%3$u)') : $_ARRAYLANG['TXT_SHOP_CUSTOMER_ANY'], 'SHOP_DISCOUNT_COUPON_PRODUCT' => $objCoupon->product_id ? isset($arrProductName[$objCoupon->product_id]) ? $arrProductName[$objCoupon->product_id] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_INVALID'] : $_ARRAYLANG['TXT_SHOP_PRODUCT_ANY'], 'SHOP_DISCOUNT_COUPON_PAYMENT' => $objCoupon->payment_id ? sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT_FORMAT'], $objCoupon->payment_id, $arrPaymentName[$objCoupon->payment_id]) : $_ARRAYLANG['TXT_SHOP_PAYMENT_ANY'], 'SHOP_DISCOUNT_COUPON_FUNCTIONS' => \Html::getBackendFunctions(array('edit' => ADMIN_SCRIPT_PATH . '?cmd=Shop&amp;act=settings&amp;tpl=coupon&amp;edit=' . urlencode($index), 'delete' => "javascript:delete_coupon('" . urlencode($index) . "');"))));
         $objTemplate->parse('shopDiscountCouponView');
         if ($index === $edit) {
             $objCouponEdit = $objCoupon;
         }
     }
     $objTemplate->replaceBlock('shopDiscountCouponView', '', true);
     $paging = \Paging::get($uri, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODES'], $count, $limit);
     //DBG::log("Paging: $paging");
     $objTemplate->setVariable('SHOP_PAGING', $paging);
     $attribute_code = 'style="width: 230px; text-align: left;" maxlength="20"';
     $attribute_time = 'style="width: 230px; text-align: left;" maxlength="10"';
     $attribute_discount_rate = 'style="width: 230px; text-align: right;" maxlength="3"';
     $attribute_discount_amount = 'style="width: 230px; text-align: right;" maxlength="9"';
     $attribute_minimum_amount = 'style="width: 230px; text-align: right;" maxlength="9"';
     $attribute_uses = 'style="width: 230px; text-align: right;" maxlength="6"';
     // Superseded by the widget, see below
     //        $attribute_customer = 'style="width: 230px;"';
     $attribute_product = 'style="width: 230px;"';
     $attribute_payment = 'style="width: 230px;"';
     $type = $objCouponEdit->discount_rate > 0 ? 'rate' : 'amount';
     $customer_name = '';
     //reset the add view
     if (!$edit) {
         $objCouponEdit = new Coupon();
     }
     if ($objCouponEdit->customer_id) {
         $customer_name = Customers::getNameById($objCouponEdit->customer_id, '%4$s (%3$u)');
         //DBG::log("Customer ID ".$objCouponEdit->customer_id.": name $customer_name");
     }
     $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$row % 2 + 1), 'SHOP_DISCOUNT_COUPON_INDEX' => $objCouponEdit->getIndex(), 'SHOP_DISCOUNT_COUPON_CODE' => \Html::getInputText('code', $objCouponEdit->code, '', $attribute_code), 'SHOP_DISCOUNT_COUPON_CODE_CREATE' => \Html::getInputButton('code_create', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE_NEW'], 'button', false, 'onclick="cx.jQuery(\'#code\').val(\'' . Coupon::getNewCode() . '\');' . 'cx.jQuery(this).css(\'display\', \'none\');"'), 'SHOP_DISCOUNT_COUPON_START_TIME' => \Html::getDatepicker('start_date', array('defaultDate' => date(ASCMS_DATE_FORMAT_DATE, $objCouponEdit->start_time ? $objCouponEdit->start_time : time())), $attribute_time), 'SHOP_DISCOUNT_COUPON_END_TIME' => \Html::getDatepicker('end_date', array('defaultDate' => $objCouponEdit->end_time ? date(ASCMS_DATE_FORMAT_DATE, $objCouponEdit->end_time) : ''), $attribute_time), 'SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED' => \Html::getCheckbox('end_time_unlimited', 1, '', $objCouponEdit->end_time ? '' : \Html::ATTRIBUTE_CHECKED) . \Html::getLabel('end_time_unlimited', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT' => \Html::getInputText('minimum_amount', $objCouponEdit->minimum_amount, false, $attribute_minimum_amount), 'SHOP_DISCOUNT_COUPON_TYPE' => \Html::getRadioGroup('coupon_type', array('rate' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_TYPE_RATE'], 'amount' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_TYPE_AMOUNT']), $type), 'SHOP_DISCOUNT_COUPON_TYPE_SELECTED' => $type, 'SHOP_DISCOUNT_COUPON_RATE' => \Html::getInputText('discount_rate', $objCouponEdit->discount_rate, false, $attribute_discount_rate), 'SHOP_DISCOUNT_COUPON_AMOUNT' => \Html::getInputText('discount_amount', number_format($objCouponEdit->discount_amount, 2, '.', ''), false, $attribute_discount_amount), 'SHOP_DISCOUNT_COUPON_USES' => \Html::getInputText('uses', $objCouponEdit->uses < 1000000000.0 ? $objCouponEdit->uses : '', 'uses', $attribute_uses), 'SHOP_DISCOUNT_COUPON_USES_UNLIMITED' => \Html::getCheckbox('unlimited', 1, 'unlimited', $objCouponEdit->uses > 1000000000.0) . \Html::getLabel('unlimited', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_GLOBALLY' => \Html::getRadio('global_or_customer', '1', 'global', $objCouponEdit->global) . \Html::getLabel('global', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_GLOBALLY']), 'SHOP_DISCOUNT_COUPON_PER_CUSTOMER' => \Html::getRadio('global_or_customer', '0', 'customer', !$objCouponEdit->global) . \Html::getLabel('customer', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PER_CUSTOMER']), 'SHOP_DISCOUNT_COUPON_CUSTOMER_ID' => $objCouponEdit->customer_id, 'SHOP_DISCOUNT_COUPON_CUSTOMER_NAME' => $customer_name, 'SHOP_DISCOUNT_COUPON_PRODUCT' => \Html::getSelect('product_id', array(0 => $_ARRAYLANG['TXT_SHOP_PRODUCT_ANY']) + $arrProductName, $objCouponEdit->product_id, false, '', $attribute_product), 'SHOP_DISCOUNT_COUPON_PAYMENT' => \Html::getSelect('payment_id', array(0 => $_ARRAYLANG['TXT_SHOP_PAYMENT_ANY']) + $arrPaymentName, $objCouponEdit->payment_id, false, '', $attribute_payment), 'SHOP_DISCOUNT_COUPON_CUSTOMER_WIDGET_DISPLAY' => $objCouponEdit->global ? \Html::CSS_DISPLAY_NONE : \Html::CSS_DISPLAY_INLINE));
     $objTemplate->parse('shopDiscountCouponEdit');
     // Depends on, and thus implies loading jQuery as well!
     \FWUser::getUserLiveSearch(array('minLength' => 3, 'canCancel' => true, 'canClear' => true));
     return $result;
 }
예제 #10
0
 /**
  * The Cart view
  *
  * Mind that the Cart needs to be {@see update()}d before calling this
  * method.
  * @global  array $_ARRAYLANG   Language array
  * @param   \Cx\Core\Html\Sigma $objTemplate  The optional Template
  */
 static function view($objTemplate = null)
 {
     global $_ARRAYLANG;
     if (!$objTemplate) {
         // TODO: Handle missing or empty Template, load one
         die("Cart::view(): ERROR: No template");
         //            return false;
     }
     $objTemplate->setGlobalVariable($_ARRAYLANG);
     $i = 0;
     if (count(self::$products)) {
         foreach (self::$products as $arrProduct) {
             $groupCountId = $arrProduct['group_id'];
             $groupArticleId = $arrProduct['article_id'];
             $groupCustomerId = 0;
             if (Shop::customer()) {
                 $groupCustomerId = Shop::customer()->group_id();
             }
             Shop::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $arrProduct['quantity']);
             // product image
             $arrProductImg = Products::get_image_array_from_base64($arrProduct['product_images']);
             $shopImagesWebPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesWebPath() . '/Shop/';
             $thumbnailPath = $shopImagesWebPath . ShopLibrary::noPictureName;
             foreach ($arrProductImg as $productImg) {
                 if (!empty($productImg['img']) && $productImg['img'] != ShopLibrary::noPictureName) {
                     $thumbnailPath = $shopImagesWebPath . \ImageManager::getThumbnailFilename($productImg['img']);
                     break;
                 }
             }
             /* UNUSED (and possibly obsolete, too)
                             if (isset($arrProduct['discount_string'])) {
             //DBG::log("Shop::view_cart(): Product ID ".$arrProduct['id'].": ".$arrProduct['discount_string']);
                                 $objTemplate->setVariable(
                                     'SHOP_DISCOUNT_COUPON_STRING',
                                         $arrProduct['coupon_string']
                                 );
                             }*/
             // The fields that don't apply have been set to ''
             // (empty string) already -- see update().
             $objTemplate->setVariable(array('SHOP_PRODUCT_ROW' => 'row' . (++$i % 2 + 1), 'SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CODE' => $arrProduct['product_id'], 'SHOP_PRODUCT_THUMBNAIL' => $thumbnailPath, 'SHOP_PRODUCT_CART_ID' => $arrProduct['cart_id'], 'SHOP_PRODUCT_TITLE' => str_replace('"', '&quot;', contrexx_raw2xhtml($arrProduct['title'])), 'SHOP_PRODUCT_PRICE' => $arrProduct['price'], 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => $arrProduct['itemprice'], 'SHOP_PRODUCT_ITEMPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_REMOVE_PRODUCT' => $_ARRAYLANG['TXT_SHOP_REMOVE_ITEM']));
             //DBG::log("Attributes String: {$arrProduct['options_long']}");
             if ($arrProduct['options_long']) {
                 $objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $arrProduct['options_long']);
             }
             if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($arrProduct['weight']), 'TXT_WEIGHT' => $_ARRAYLANG['TXT_TOTAL_WEIGHT']));
             }
             if (Vat::isEnabled()) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $arrProduct['vat_rate'] ? Vat::format($arrProduct['vat_rate']) : '', 'SHOP_PRODUCT_TAX_AMOUNT' => $arrProduct['vat_amount'] . '&nbsp;' . Currency::getActiveCurrencySymbol()));
             }
             if (intval($arrProduct['minimum_order_quantity']) > 0) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY' => $arrProduct['minimum_order_quantity']));
             } else {
                 if ($objTemplate->blockExists('orderQuantity')) {
                     $objTemplate->hideBlock('orderQuantity');
                 }
                 if ($objTemplate->blockExists('minimumOrderQuantity')) {
                     $objTemplate->hideBlock('minimumOrderQuantity');
                 }
             }
             $objTemplate->parse('shopCartRow');
         }
     } else {
         $objTemplate->hideBlock('shopCart');
         if ($objTemplate->blockExists('shopCartEmpty')) {
             $objTemplate->touchBlock('shopCartEmpty');
             $objTemplate->parse('shopCartEmpty');
         }
         if ($_SESSION['shop']['previous_product_ids']) {
             $ids = $_SESSION['shop']['previous_product_ids']->toArray();
             Shop::view_product_overview($ids);
         }
     }
     $objTemplate->setGlobalVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'SHOP_PRODUCT_TOTALITEM' => self::get_item_count(), 'SHOP_PRODUCT_TOTALPRICE' => Currency::formatPrice(self::get_price()), 'SHOP_PRODUCT_TOTALPRICE_PLUS_VAT' => Currency::formatPrice(self::get_price() + (Vat::isEnabled() && !Vat::isIncluded() ? self::get_vat_amount() : 0)), 'SHOP_PRODUCT_TOTALPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString(self::get_weight()), 'SHOP_PRICE_UNIT' => Currency::getActiveCurrencySymbol()));
     // Show the Coupon code field only if there is at least one defined
     if (Coupon::count_available()) {
         //DBG::log("Coupons available");
         $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_CODE' => isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : ''));
         if ($objTemplate->blockExists('shopCoupon')) {
             $objTemplate->parse('shopCoupon');
         }
         if (self::get_discount_amount()) {
             $total_discount_amount = self::get_discount_amount();
             //DBG::log("Shop::view_cart(): Total: Amount $total_discount_amount");
             $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
         }
     }
     if (Vat::isEnabled()) {
         $objTemplate->setVariable(array('TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_TOTAL_TAX_AMOUNT' => self::get_vat_amount() . '&nbsp;' . Currency::getActiveCurrencySymbol()));
         if (Vat::isIncluded()) {
             $objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice(self::get_price() - self::get_vat_amount()) . '&nbsp;' . Currency::getActiveCurrencySymbol()));
         }
     }
     if (self::needs_shipment()) {
         $objTemplate->setVariable(array('TXT_SHIP_COUNTRY' => $_ARRAYLANG['TXT_SHIP_COUNTRY'], 'SHOP_COUNTRIES_MENU' => \Cx\Core\Country\Controller\Country::getMenu('countryId2', $_SESSION['shop']['countryId2'], true, "document.forms['shopForm'].submit()"), 'SHOP_COUNTRIES_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($_SESSION['shop']['countryId2'])));
     }
     if (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MIN'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop')), Currency::getActiveCurrencySymbol()));
     } elseif (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') < self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MAX'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop')), Currency::getActiveCurrencySymbol()));
     } else {
         $objTemplate->setVariable('TXT_NEXT', $_ARRAYLANG['TXT_NEXT']);
     }
 }
예제 #11
0
        /**
         * Set main template placeholders required after content parsing
         * @todo Remove usage of globals
         * @global array $_CONFIG
         * @global type $themesPages
         * @global type $objBanner
         * @global type $_CORELANG
         * @return type
         */
        protected function setPostContentLoadPlaceholders()
        {
            global $_CONFIG, $themesPages, $objBanner, $_CORELANG;
            if ($this->mode == self::MODE_BACKEND) {
                $formattedVersion = htmlentities($_CONFIG['coreCmsName'], ENT_QUOTES, CONTREXX_CHARSET) . ' ' . htmlentities(str_replace(' Service Pack 0', '', preg_replace('#^(\\d+\\.\\d+)\\.(\\d+)$#', '$1 Service Pack $2', $_CONFIG['coreCmsVersion'])), ENT_QUOTES, CONTREXX_CHARSET) . ' ' . htmlentities($_CONFIG['coreCmsEdition'], ENT_QUOTES, CONTREXX_CHARSET) . ' ' . htmlentities($_CONFIG['coreCmsStatus'], ENT_QUOTES, CONTREXX_CHARSET);
                $this->template->setGlobalVariable(array('TXT_FRONTEND' => $_CORELANG['TXT_FRONTEND'], 'TXT_UPGRADE' => $_CORELANG['TXT_UPGRADE'], 'TXT_FEEDBACK_AND_HELP' => $_CORELANG['TXT_FEEDBACK_AND_HELP'], 'CONTREXX_VERSION' => $formattedVersion));
                $this->template->setVariable(array('TXT_LOGOUT' => $_CORELANG['TXT_LOGOUT'], 'TXT_PAGE_ID' => $_CORELANG['TXT_PAGE_ID'], 'CONTAINER_BACKEND_CLASS' => 'backend', 'CONTREXX_CHARSET' => CONTREXX_CHARSET));
                //show Feedback and help block
                \Permission::checkAccess(192, 'static', true) ? $this->template->touchBlock('feedback_help') : $this->template->hideBlock('feedback_help');
                return;
            }
            $objCounter = null;
            $componentRepo = $this->getDb()->getEntityManager()->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent');
            $statsComponentContoller = $componentRepo->findOneBy(array('name' => 'Stats'));
            if ($statsComponentContoller) {
                $objCounter = $statsComponentContoller->getCounterInstance();
            }
            // set global template variables
            $boolShop = \Cx\Modules\Shop\Controller\Shop::isInitialized();
            $objNavbar = new \Navigation($this->resolvedPage->getId(), $this->resolvedPage);
            $objNavbar->setLanguagePlaceholders($this->resolvedPage, $this->request->getUrl(), $this->template);
            $metarobots = $this->resolvedPage->getMetarobots();
            $this->template->setVariable(array('CHARSET' => \Env::get('init')->getFrontendLangCharset(), 'TITLE' => contrexx_raw2xhtml($this->resolvedPage->getTitle()), 'METATITLE' => contrexx_raw2xhtml($this->resolvedPage->getMetatitle()), 'NAVTITLE' => contrexx_raw2xhtml($this->resolvedPage->getTitle()), 'GLOBAL_TITLE' => $_CONFIG['coreGlobalPageTitle'], 'DOMAIN_URL' => $_CONFIG['domainUrl'], 'PATH_OFFSET' => $this->codeBaseOffsetPath, 'BASE_URL' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . $this->codeBaseOffsetPath, 'METAKEYS' => $metarobots ? contrexx_raw2xhtml($this->resolvedPage->getMetakeys()) : '', 'METADESC' => $metarobots ? contrexx_raw2xhtml($this->resolvedPage->getMetadesc()) : '', 'METAROBOTS' => $metarobots ? 'all' : 'none', 'METAIMAGE' => $metarobots ? contrexx_raw2xhtml($this->resolvedPage->getMetaimage()) : '', 'CONTENT_TITLE' => $this->resolvedPage->getContentTitle(), 'CONTENT_TEXT' => $this->resolvedPage->getContent(), 'CSS_NAME' => contrexx_raw2xhtml($this->resolvedPage->getCssName()), 'STANDARD_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('smallscreen', 0)), 'MOBILE_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('smallscreen', 1)), 'PRINT_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('printview', 1)), 'PDF_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('pdfview', 1)), 'APP_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('appview', 1)), 'LOGOUT_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('section', 'logout')), 'PAGE_URL' => htmlspecialchars(\Env::get('init')->getPageUri()), 'PAGE_URL_ENCODED' => urlencode(\Env::get('init')->getPageUri()->toString()), 'CURRENT_URL' => contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()), 'DATE' => showFormattedDate(), 'TIME' => date('H:i', time()), 'NAVTREE' => $objNavbar->getTrail(), 'SUBNAVBAR_FILE' => $objNavbar->getSubnavigation($themesPages['subnavbar'], $this->license, $boolShop), 'SUBNAVBAR2_FILE' => $objNavbar->getSubnavigation($themesPages['subnavbar2'], $this->license, $boolShop), 'SUBNAVBAR3_FILE' => $objNavbar->getSubnavigation($themesPages['subnavbar3'], $this->license, $boolShop), 'NAVBAR_FILE' => $objNavbar->getNavigation($themesPages['navbar'], $this->license, $boolShop), 'NAVBAR2_FILE' => $objNavbar->getNavigation($themesPages['navbar2'], $this->license, $boolShop), 'NAVBAR3_FILE' => $objNavbar->getNavigation($themesPages['navbar3'], $this->license, $boolShop), 'ONLINE_USERS' => $objCounter ? $objCounter->getOnlineUsers() : '', 'VISITOR_NUMBER' => $objCounter ? $objCounter->getVisitorNumber() : '', 'COUNTER' => $objCounter ? $objCounter->getCounterTag() : '', 'BANNER' => isset($objBanner) ? $objBanner->getBannerJS() : '', 'VERSION' => contrexx_raw2xhtml($_CONFIG['coreCmsName']), 'LANGUAGE_NAVBAR' => $objNavbar->getFrontendLangNavigation($this->resolvedPage, $this->request->getUrl()), 'LANGUAGE_NAVBAR_SHORT' => $objNavbar->getFrontendLangNavigation($this->resolvedPage, $this->request->getUrl(), true), 'ACTIVE_LANGUAGE_NAME' => \Env::get('init')->getFrontendLangName(), 'RANDOM' => md5(microtime()), 'TXT_SEARCH' => $_CORELANG['TXT_SEARCH'], 'MODULE_INDEX' => MODULE_INDEX, 'LOGIN_URL' => '<a href="' . contrexx_raw2xhtml(\Env::get('init')->getUriBy('section', 'Login')) . '" class="start-frontend-editing">' . $_CORELANG['TXT_FRONTEND_EDITING_LOGIN'] . '</a>', 'TXT_CORE_LAST_MODIFIED_PAGE' => $_CORELANG['TXT_CORE_LAST_MODIFIED_PAGE'], 'LAST_MODIFIED_PAGE' => date(ASCMS_DATE_FORMAT_DATE, $this->resolvedPage->getUpdatedAt()->getTimestamp()), 'CONTACT_EMAIL' => isset($_CONFIG['contactFormEmail']) ? contrexx_raw2xhtml($_CONFIG['contactFormEmail']) : '', 'CONTACT_NAME' => isset($_CONFIG['coreAdminName']) ? contrexx_raw2xhtml($_CONFIG['coreAdminName']) : '', 'CONTACT_COMPANY' => isset($_CONFIG['contactCompany']) ? contrexx_raw2xhtml($_CONFIG['contactCompany']) : '', 'CONTACT_ADDRESS' => isset($_CONFIG['contactAddress']) ? contrexx_raw2xhtml($_CONFIG['contactAddress']) : '', 'CONTACT_ZIP' => isset($_CONFIG['contactZip']) ? contrexx_raw2xhtml($_CONFIG['contactZip']) : '', 'CONTACT_PLACE' => isset($_CONFIG['contactPlace']) ? contrexx_raw2xhtml($_CONFIG['contactPlace']) : '', 'CONTACT_COUNTRY' => isset($_CONFIG['contactCountry']) ? contrexx_raw2xhtml($_CONFIG['contactCountry']) : '', 'CONTACT_PHONE' => isset($_CONFIG['contactPhone']) ? contrexx_raw2xhtml($_CONFIG['contactPhone']) : '', 'CONTACT_FAX' => isset($_CONFIG['contactFax']) ? contrexx_raw2xhtml($_CONFIG['contactFax']) : '', 'GOOGLE_MAPS_API_KEY' => isset($_CONFIG['googleMapsAPIKey']) ? contrexx_raw2xhtml($_CONFIG['googleMapsAPIKey']) : '', 'FACEBOOK_LIKE_IFRAME' => '<div id="fb-root"></div>
                                                    <script type="text/javascript">
                                                        (function(d, s, id) {
                                                            var js, fjs = d.getElementsByTagName(s)[0];
                                                            if (d.getElementById(id)) return;
                                                            js = d.createElement(s); js.id = id;
                                                            js.src = "//connect.facebook.net/' . \FWLanguage::getLanguageCodeById(LANG_ID) . '_' . strtoupper(\FWLanguage::getLanguageCodeById(LANG_ID)) . '/all.js#xfbml=1";
                                                            fjs.parentNode.insertBefore(js, fjs);
                                                        }(document, \'script\', \'facebook-jssdk\'));
                                                    </script>
                                                    <div class="fb-like" data-href="' . ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()) . '" data-send="false" data-layout="button_count" data-show-faces="false" data-font="segoe ui"></div>', 'GOOGLE_PLUSONE' => '<div class="g-plusone" data-href="' . ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()) . '"></div>
                                                    <script type="text/javascript">
                                                        window.___gcfg = {lang: \'' . \FWLanguage::getLanguageCodeById(LANG_ID) . '\'};

                                                        (function() {
                                                            var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true;
                                                            po.src = \'https://apis.google.com/js/plusone.js\';
                                                            var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);
                                                        })();
                                                    </script>', 'TWITTER_SHARE' => '<a href="https://twitter.com/share" class="twitter-share-button"
                                                    data-url="' . ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()) . '" data-lang="' . \FWLanguage::getLanguageCodeById(LANG_ID) . '">Twittern</a>
                                                    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>', 'XING_SHARE' => '<div data-type="XING/Share" data-counter="right" data-lang="' . \FWLanguage::getLanguageCodeById(LANG_ID) . '"></div>
                                                    <script>
                                                        ;(function (d, s) {
                                                            var x = d.createElement(s),
                                                                s = d.getElementsByTagName(s)[0];
                                                            x.src = "https://www.xing-share.com/js/external/share.js";
                                                            s.parentNode.insertBefore(x, s);
                                                        })(document, "script");
                                                    </script>', 'GOOGLE_ANALYTICS' => '<script type="text/javascript">
                                                        var _gaq = _gaq || [];
                                                        _gaq.push([\'_setAccount\', \'' . (isset($_CONFIG['googleAnalyticsTrackingId']) ? contrexx_raw2xhtml($_CONFIG['googleAnalyticsTrackingId']) : '') . '\']);
                                                        _gaq.push([\'_trackPageview\']);

                                                        (function() {
                                                            var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
                                                            ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
                                                            var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
                                                        })();
                                                    </script>'));
        }
예제 #12
0
 /**
  * categories list
  * @global array
  * @global integer
  * @global array
  * @global object
  * @global object
  */
 private function categories()
 {
     global $_ARRAYLANG, $_LANGID, $_CONFIG, $objInit;
     $objCategory = Category::getCategory($this->parentCategoryId);
     $objFWUser = \FWUser::getFWUserObject();
     $this->_pageTitle = $_ARRAYLANG['TXT_DOWNLOADS_CATEGORIES'];
     $this->objTemplate->addBlockFile('DOWNLOADS_CATEGORY_TEMPLATE', 'module_downloads_categories', 'module_downloads_categories.html');
     // check access permission
     if (!\Permission::checkAccess(143, 'static', true) && $objCategory->getReadAccessId() && !\Permission::checkAccess($objCategory->getReadAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $objFWUser->objUser->getId()) {
         return \Permission::noAccess();
     }
     // get passed parameters
     $pos = isset($_GET['pos']) ? intval($_GET['pos']) : 0;
     $categoryLimitOffset = isset($_GET['category_pos']) ? intval($_GET['category_pos']) : $pos;
     $categoryOrderDirection = !empty($_GET['category_sort']) ? $_GET['category_sort'] : 'asc';
     $categoryOrderBy = !empty($_GET['category_by']) ? $_GET['category_by'] : '';
     $downloadLimitOffset = isset($_GET['download_pos']) ? intval($_GET['download_pos']) : $pos;
     $downloadOrderDirection = !empty($_GET['download_sort']) ? $_GET['download_sort'] : 'asc';
     $downloadOrderBy = !empty($_GET['download_by']) ? $_GET['download_by'] : '';
     $searchTerm = !empty($_GET['search_term']) ? $_GET['search_term'] : '';
     $searchTerm = $searchTerm == $_ARRAYLANG['TXT_DOWNLOADS_SEARCH_DOWNLOAD'] ? '' : $searchTerm;
     // parse categories multi action
     if (isset($_POST['downloads_category_select_action'])) {
         switch ($_POST['downloads_category_select_action']) {
             case 'order':
                 $this->updateCategoryOrder(isset($_POST['downloads_category_order']) && is_array($_POST['downloads_category_order']) ? $_POST['downloads_category_order'] : array());
                 break;
             case 'delete':
                 $this->deleteCategories(isset($_POST['downloads_category_id']) && is_array($_POST['downloads_category_id']) ? $_POST['downloads_category_id'] : array(), isset($_POST['downloads_category_delete_recursive']) && $_POST['downloads_category_delete_recursive']);
                 break;
         }
     }
     // process downloads multi action
     if (isset($_POST['downloads_download_select_action'])) {
         if (!\Permission::checkAccess(143, 'static', true) && $objCategory->getManageFilesAccessId() && !\Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $objFWUser->objUser->getId()) {
             return \Permission::noAccess();
         }
         switch ($_POST['downloads_download_select_action']) {
             case 'order':
                 if ($objCategory->updateDownloadOrder(isset($_POST['downloads_download_order']) && is_array($_POST['downloads_download_order']) ? $_POST['downloads_download_order'] : array())) {
                     $this->arrStatusMsg['ok'][] = $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_ORDER_SET_SUCCESS'];
                 } else {
                     $this->arrStatusMsg['error'] = array_merge($this->arrStatusMsg['error'], $objCategory->getErrorMsg());
                 }
                 break;
             case 'unlink':
                 $this->unlinkDownloadsFromCategory($objCategory, isset($_POST['downloads_download_id']) && is_array($_POST['downloads_download_id']) ? $_POST['downloads_download_id'] : array());
                 break;
         }
     }
     $this->objTemplate->setGlobalVariable(array('TXT_DOWNLOADS_EDIT' => $_ARRAYLANG['TXT_DOWNLOADS_EDIT'], 'TXT_DOWNLOADS_DELETE' => $_ARRAYLANG['TXT_DOWNLOADS_DELETE']));
     //        // check if user is allowed to add a subcategory
     //        if (// managers are allowed to add subcategories
     //            \Permission::checkAccess(143, 'static', true)
     //            // the selected category must be valid to proceed future permission checks.
     //            // this is required to protect the overview section from non-admins
     //            || $objCategory->getId() && (
     //                // the category isn't protected => everyone is allowed to add subcategories
     //                !$objCategory->getAddSubcategoriesAccessId()
     //                // the category is protected => only those who have the sufficent permissions are allowed to add subcategories
     //                || \Permission::checkAccess($objCategory->getAddSubcategoriesAccessId(), 'dynamic', true)
     //                // the owner is allowed to add subcategories
     //                || ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() && $objCategory->getOwnerId() == $objFWUser->objUser->getId()
     //            )
     //        ) {
     //            $this->objTemplate->setVariable(array(
     //                'DOWNLOADS_CATEGORY_ID' => $objCategory->getId(),
     //                // TODO: rename
     //                //'TXT_ADD_CATEGORY'      => $_ARRAYLANG['TXT_ADD_CATEGORY']
     //            ));
     //            $this->objTemplate->parse('downloads_category_add_buttom');
     //        } else {
     //            $this->objTemplate->hideBlock('downloads_category_add_buttom');
     //        }
     // parse categories
     $this->parseCategories($objCategory, $downloadOrderBy, $downloadOrderDirection, $downloadLimitOffset, $categoryOrderBy, $categoryOrderDirection, $categoryLimitOffset);
     if (!$objCategory->getId()) {
         $this->objTemplate->setVariable('TXT_DOWNLOADS_ALL_CATEGORIES', $_ARRAYLANG['TXT_DOWNLOADS_ALL_CATEGORIES']);
     }
     // parse frontend preview link
     if ($objCategory->getId()) {
         $categoryFrontendURI = ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID) . '/' . CONTREXX_DIRECTORY_INDEX . '?section=Downloads&amp;category=' . $objCategory->getId();
         $this->objTemplate->setVariable(array('TXT_DOWNLOADS_OPEN_CATEGORY_FRONTEND' => $_ARRAYLANG['TXT_DOWNLOADS_OPEN_CATEGORY_FRONTEND'], 'DOWNLOADS_CATEGORY_FRONTEND_URI' => $categoryFrontendURI));
         $this->objTemplate->parse('downloads_category_frontend_link');
     } else {
         $this->objTemplate->hideBlock('downloads_category_frontend_link');
     }
     // parse downloads
     $this->parseCategoryDownloads($objCategory, $downloadOrderBy, $downloadOrderDirection, $downloadLimitOffset, $categoryOrderBy, $categoryOrderDirection, $categoryLimitOffset, $searchTerm);
     $this->objTemplate->setVariable(array('DOWNLOADS_CONFIRM_UNLINK_DOWNLOAD_TXT' => preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_DOWNLOADS_CONFIRM_UNLINK_DOWNLOAD']))));
     // parse add downloads buttons
     if ($objCategory->getId() && (\Permission::checkAccess(143, 'static', true) || !$objCategory->getAddFilesAccessId() || \Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true))) {
         $this->objTemplate->setVariable(array('DOWNLOADS_CATEGORY_ID' => $objCategory->getId(), 'TXT_DOWNLOADS_ADD_NEW_DOWNLOAD_TO_CATEGORY' => sprintf($_ARRAYLANG['TXT_DOWNLOADS_ADD_NEW_DOWNLOAD_TO_CATEGORY'], htmlentities($objCategory->getName(LANG_ID), ENT_QUOTES, CONTREXX_CHARSET)), 'TXT_DOWNLOADS_ADD_DOWNLOADS_TO_CATEGORY' => sprintf($_ARRAYLANG['TXT_DOWNLOADS_ADD_DOWNLOADS_TO_CATEGORY'], htmlentities($objCategory->getName(LANG_ID), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset));
         $this->objTemplate->parse('downloads_add_downloads_button');
     } else {
         $this->objTemplate->hideBlock('downloads_add_downloads_button');
     }
     // parse category menu
     // parse category id (will be used as the parent_id when creating a new directory
     $this->objTemplate->setVariable(array('TXT_DOWNLOADS_CATEGORY' => $_ARRAYLANG['TXT_DOWNLOADS_CATEGORY'], 'DOWNLOADS_CATEGORY_ID' => $objCategory->getId(), 'DOWNLOADS_CATEGORY_MENU' => $this->getCategoryMenu('read', $objCategory->getId(), $_ARRAYLANG['TXT_DOWNLOADS_ALL_CATEGORIES']), 'DOWNLOADS_SEARCH_TERM' => !empty($_GET['search_term']) ? $_GET['search_term'] : $_ARRAYLANG['TXT_DOWNLOADS_SEARCH_DOWNLOAD'], 'TXT_DOWNLOADS_SEARCH_DOWNLOAD' => $_ARRAYLANG['TXT_DOWNLOADS_SEARCH_DOWNLOAD'], 'TXT_DOWNLOADS_FILTER' => $_ARRAYLANG['TXT_DOWNLOADS_FILTER'], 'TXT_DOWNLOADS_SEARCH' => $_ARRAYLANG['TXT_DOWNLOADS_SEARCH']));
     return true;
 }
예제 #13
0
 /**
  * shows the list of objects, also handles search requests
  * @return void
  */
 function _showImmoList()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     //TODO
     //handle last step of quickSeach and DetailSearch here
     $this->_objTpl->setGlobalVariable(array('TXT_IMMO_BACK' => $_ARRAYLANG['TXT_IMMO_BACK'], 'TXT_IMMO_CURRENCY_PREFIX' => $this->arrSettings['currency_lang_' . $this->frontLang], 'TXT_IMMO_CURRENCY_SUFFIX' => $this->_currencySuffix, 'TXT_IMMO_MORE_INFOS' => $_ARRAYLANG['TXT_IMMO_MORE_INFOS']));
     $locations = contrexx_addslashes(strip_tags($_REQUEST['locations']));
     $obj_type = contrexx_addslashes(strip_tags($_REQUEST['obj_type']));
     $property_type = contrexx_addslashes(strip_tags($_REQUEST['property_type']));
     $new_building = contrexx_addslashes(strip_tags($_REQUEST['new_building']));
     $logo = contrexx_addslashes(strip_tags($_REQUEST['logo']));
     if (!empty($_REQUEST['foreigner_auth'])) {
         $foreigner_auth = intval($_REQUEST['foreigner_auth']) > 0 ? $_ARRAYLANG['TXT_IMMO_YES'] : $_ARRAYLANG['TXT_IMMO_NO'];
     }
     $fprice = contrexx_addslashes(strip_tags($_REQUEST['fprice']));
     $tprice = contrexx_addslashes(strip_tags($_REQUEST['tprice']));
     $frooms = contrexx_addslashes(strip_tags($_REQUEST['frooms']));
     $trooms = contrexx_addslashes(strip_tags($_REQUEST['trooms']));
     //show all
     $orderBy = !empty($_REQUEST['order_by']) ? contrexx_addslashes($_REQUEST['order_by']) : 'location';
     $query = 'SELECT     immo.id AS immo_id, reference, visibility,
                         a.fieldvalue AS location,
                         CAST(b.fieldvalue AS UNSIGNED) AS price,
                         c.fieldvalue AS header,
                         d.fieldvalue AS headline,
                         e.fieldvalue AS rooms,
                         f.fieldvalue AS address,
                         img.uri      AS imgsrc
                 FROM ' . DBPREFIX . 'module_immo AS immo
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS a ON ( immo.id = a.immo_id
                                                             AND a.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "ort"
                                                                 AND lang_id = 1 )
                                                             AND a.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS b ON ( immo.id = b.immo_id
                                                             AND b.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "preis"
                                                                 AND lang_id = 1 )
                                                             AND b.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS c ON ( immo.id = c.immo_id
                                                             AND c.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "kopfzeile"
                                                                 AND lang_id = 1 )
                                                             AND c.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS d ON ( immo.id = d.immo_id
                                                             AND d.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "headline"
                                                                 AND lang_id = 1 )
                                                             AND d.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS e ON ( immo.id = e.immo_id
                                                             AND e.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "anzahl zimmer"
                                                                 AND lang_id = 1 )
                                                             AND e.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS f ON ( immo.id = f.immo_id
                                                             AND f.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "adresse"
                                                                 AND lang_id = 1 )
                                                             AND f.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_image AS img ON ( immo.id = img.immo_id
                                                             AND img.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "übersichtsbild" )
                                                             )
                 WHERE  ( visibility = "listing"';
     if (!empty($_REQUEST['ref_nr'])) {
         $query .= " OR visibility = 'reference' ) ";
     } else {
         $query .= ") ORDER BY {$orderBy} ASC";
     }
     //request from search form?
     if (empty($_REQUEST['ref_nr'])) {
         //fulltext search
         $keys1 = array_filter(array_keys($_ARRAYLANG), array(&$this, "filterImmoType"));
         foreach ($keys1 as $key) {
             $keys[$key] = $_ARRAYLANG[$key];
         }
         array_walk($keys, array(&$this, 'arrStrToLower'));
         $searchterm = contrexx_addslashes($_REQUEST['search']);
         if (!empty($searchterm) && strlen($searchterm) <= 3) {
             $this->_objTpl->setVariable("TXT_IMMO_SEARCHTERM_TOO_SHORT", $_ARRAYLANG['TXT_IMMO_SEARCHTERM_TOO_SHORT']);
             return false;
         }
         $query = "  SELECT immo.id AS `immo_id`, immo.reference AS `reference`, immo.object_type AS otype, immo.new_building AS `new`, immo.property_type AS ptype, logo,\n                        a.fieldvalue as headline,\n                        CAST(b.fieldvalue AS UNSIGNED) as price,\n                        c.fieldvalue as header,\n                        d.fieldvalue as location,\n                        e.fieldvalue as rooms,\n                        f.fieldvalue as foreigner_authorization,\n                        g.fieldvalue as address,\n                        img.uri AS imgsrc\n                        FROM " . DBPREFIX . "module_immo AS immo";
         if (!empty($searchterm)) {
             $query .= " LEFT JOIN " . DBPREFIX . "module_immo_content AS content on ( content.immo_id = immo.id ) ";
         }
         $query .= " LEFT JOIN " . DBPREFIX . "module_immo_content AS a ON ( immo.id = a.immo_id\n                                                                AND a.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'headline'\n                                                                    AND lang_id = 1 )\n                                                                AND a.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS b ON ( immo.id = b.immo_id\n                                                                AND b.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'preis'\n                                                                    AND lang_id = 1 )\n                                                                AND b.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS c ON ( immo.id = c.immo_id\n                                                                AND c.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'kopfzeile'\n                                                                    AND lang_id = 1 )\n                                                                AND c.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS d ON ( immo.id = d.immo_id\n                                                                AND d.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'ort'\n                                                                    AND lang_id = 1 )\n                                                                AND d.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS e ON ( immo.id = e.immo_id\n                                                                AND e.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'anzahl zimmer'\n                                                                    AND lang_id = 1 )\n                                                                AND e.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS f ON ( immo.id = f.immo_id\n                                                                AND f.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'ausl�nder-bewilligung'\n                                                                    AND lang_id = 1 )\n                                                                AND f.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS g ON ( immo.id = g.immo_id\n                                                                AND g.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'adresse'\n                                                                    AND lang_id = 1 )\n                                                                AND g.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_image AS img ON ( immo.id = img.immo_id\n                                                                AND img.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'übersichtsbild' )\n                                                                )\n                        WHERE TRUE\n                        ";
         if (!empty($searchterm)) {
             $query .= " AND content.fieldvalue LIKE '%" . $searchterm . "%' ";
         }
         $query .= " AND immo.visibility != 'disabled' ";
         if (!intval($_REQUEST['refnr'])) {
             $query .= " AND immo.visibility != 'reference' ";
         }
         if (!empty($locations) || !empty($obj_type) || !empty($property_type)) {
             if (!empty($locations)) {
                 $query .= " AND d.fieldvalue = '" . $locations . "'";
             }
             if (!empty($property_type)) {
                 $query .= " AND immo.property_type = '" . $property_type . "'";
             }
             if (!empty($obj_type)) {
                 $query .= " AND immo.object_type = '" . $obj_type . "'";
             }
             if (!empty($new_building)) {
                 $query .= " AND immo.new_building = '" . $new_building . "'";
             }
             if (!empty($foreigner_auth)) {
                 //max rooms
                 $query .= " AND f.fieldvalue = '" . $foreigner_auth . "' ";
             }
             if (!empty($fprice)) {
                 //min price
                 $query .= " AND b.fieldvalue >= " . $fprice . " ";
             }
             if (!empty($tprice)) {
                 //max price
                 $query .= " AND b.fieldvalue <= " . $tprice . " ";
             }
             if (!empty($frooms)) {
                 //min rooms
                 $query .= " AND e.fieldvalue >= '" . $frooms . "' ";
             }
             if (!empty($trooms)) {
                 //max rooms
                 $query .= " AND e.fieldvalue <= '" . $trooms . "' ";
             }
             if (!empty($logo)) {
                 //max rooms
                 $query .= " AND logo = '" . $logo . "' ";
             }
             $query .= ' GROUP BY immo.id ORDER BY ' . $orderBy . ' ASC';
         }
     } elseif (!empty($_REQUEST['ref_nr'])) {
         //advanced search
         $orderBy = !empty($_REQUEST['order_by']) ? contrexx_addslashes($_REQUEST['order_by']) : 'immo.id';
         $refnr = intval($_REQUEST['ref_nr']);
         $query .= ' AND reference = ' . $refnr . " GROUP BY immo.id ORDER BY {$orderBy} ASC";
     }
     //else { //no where clause => show all }
     $objRS = $objDatabase->Execute($query);
     if (!$objRS) {
         echo "DB error. file: " . __FILE__ . " line: " . __LINE__;
         return false;
     }
     if ($objRS->RecordCount() == 0) {
         if ($this->_objTpl->blockExists("no_results")) {
             $this->_objTpl->touchBlock("no_results");
             $this->_objTpl->parse("no_results");
         }
         return false;
     }
     while (!$objRS->EOF) {
         $imgdim = '';
         $img = $objRS->fields['imgsrc'];
         $imgdim = $this->_getImageDim($img, 80);
         $this->_objTpl->setVariable(array('IMMO_HEADER' => $objRS->fields['header'], 'IMMO_LOCATION' => $objRS->fields['location'], 'IMMO_PRICE' => $objRS->fields['price'], 'IMMO_REF_NR' => $objRS->fields['reference'], 'IMMO_HEADLINE' => $objRS->fields['headline'], 'IMMO_IMG_PREVIEW_DIM' => $imgdim[0], 'IMMO_IMG_PREVIEW_SRC' => $img, 'IMMO_ID' => $objRS->fields['immo_id']));
         if (!empty($objRS->fields['imgsrc'])) {
             $this->_objTpl->parse("previewImage");
         } else {
             $this->_objTpl->hideBlock("previewImage");
         }
         $this->_objTpl->setVariable('IMMO_HEADER', $objRS->fields['header']);
         $this->_objTpl->parse("objectRow");
         $objRS->MoveNext();
     }
     // TODO: Never used
     //        $limit = $_CONFIG['corePagingLimit'];
     $count = '';
     $pos = intval($_GET['pos']);
     $this->_objTpl->setVariable('IMMO_PAGING', getPaging($count, $pos, '&amp;search=' . $_REQUEST['search'], '', true));
     return true;
 }