예제 #1
0
 function getLocationTable($jobID)
 {
     global $objDatabase, $_ARRAYLANG;
     $query = "\n            SELECT `value`\n              FROM `" . DBPREFIX . "module_jobs_settings`\n             WHERE name='show_location_fe'";
     $objResult = $objDatabase->Execute($query);
     //return if location fields are not activated in the backend
     if ($objResult && !$objResult->EOF) {
         if (intval($objResult->fields['value']) == 0) {
             $this->_objTpl->hideBlock('modify_location');
             return;
         }
     }
     $AssociatedLocations = '';
     $notAssociatedLocations = '';
     $this->_objTpl->setVariable(array('TXT_GENERAL' => $_ARRAYLANG['TXT_JOBS_GENERAL'], 'TXT_LOCATION' => $_ARRAYLANG['TXT_LOCATION'], 'TXT_AVAILABLE_LOCATIONS' => $_ARRAYLANG['TXT_JOBS_AVAILABLE_LOCATIONS'], 'TXT_ASSOCIATED_LOCATIONS' => $_ARRAYLANG['TXT_JOBS_ASSOCIATED_LOCATIONS'], 'TXT_CHECK_ALL' => $_ARRAYLANG['TXT_CHECK_ALL'], 'TXT_UNCHECK_ALL' => $_ARRAYLANG['TXT_REMOVE_SELECTION'], 'FORM_ONSUBMIT' => "onsubmit=\"SelectAllLocations(document.getElementById('associated_locations'))\""));
     if (empty($jobID)) {
         $query = "SELECT DISTINCT l.name as name,\n                      l.id as id\n                      FROM `" . DBPREFIX . "module_jobs_location` l\n                      WHERE 1;";
     } else {
         $query = "SELECT DISTINCT l.name as name,\n                      l.id as id,\n                      j.job as jobid ,\n                      j.location as location\n                      FROM `" . DBPREFIX . "module_jobs_location` l\n                      LEFT JOIN `" . DBPREFIX . "module_jobs_rel_loc_jobs` as j on j.location=l.id\n                      AND j.job = {$jobID}";
     }
     $objResult = $objDatabase->Execute($query);
     while ($objResult !== false && !$objResult->EOF) {
         if (empty($jobID) or $objResult->fields['jobid'] != $jobID) {
             $notAssociatedLocations .= "<option value=\"" . $objResult->fields['id'] . "\">" . htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET) . "</option>\n";
         } else {
             $AssociatedLocations .= "<option value=\"" . $objResult->fields['id'] . "\">" . htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET) . "</option>\n";
         }
         $objResult->MoveNext();
     }
     $this->_objTpl->setVariable('ASSOCIATED_LOCATIONS', $AssociatedLocations);
     $this->_objTpl->setVariable('NOT_ASSOCIATED_LOCATIONS', $notAssociatedLocations);
 }
예제 #2
0
 /**
  * Show the shadowbox
  */
 function shadowbox()
 {
     global $objDatabase, $_ARRAYLANG, $objInit;
     $id = intval($_GET['id']);
     $lang = intval($_GET['lang']);
     $entries = $this->createEntryArray();
     $entry = $entries[$id];
     $settings = $this->createSettingsArray();
     $title = $entry['translation'][$lang]['subject'];
     $content = $entry['translation'][$lang]['content'];
     $picture = !empty($entry['translation'][$lang]['image']) ? $entry['translation'][$lang]['image'] : "none";
     $this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_THEMES_PATH);
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setCurrentBlock("shadowbox");
     $objResult = $objDatabase->SelectLimit("\n            SELECT foldername\n              FROM " . DBPREFIX . "skins\n             WHERE id='{$objInit->currentThemesId}'", 1);
     if ($objResult !== false) {
         $themesPath = $objResult->fields['foldername'];
     }
     $template = preg_replace('/\\[\\[([A-Z_]+)\\]\\]/', '{$1}', $settings['data_template_shadowbox']);
     $this->_objTpl->setTemplate($template);
     if ($entry['translation'][$lang]['attachment']) {
         $this->_objTpl->setVariable(array("HREF" => $entry['translation'][$lang]['attachment'], "TXT_DOWNLOAD" => empty($entry['translation'][$lang]['attachment_desc']) ? $_ARRAYLANG['TXT_DATA_DOWNLOAD_ATTACHMENT'] : $entry['translation'][$lang]['attachment_desc']));
         $this->_objTpl->parse("attachment");
     }
     $this->_objTpl->setVariable(array("TITLE" => $title, "CONTENT" => $content, "PICTURE" => $picture, "THEMES_PATH" => $themesPath));
     if ($picture != "none") {
         $this->_objTpl->parse("image");
     } else {
         $this->_objTpl->hideBlock("image");
     }
     $this->_objTpl->parse("shadowbox");
     $this->_objTpl->show();
     die;
 }
예제 #3
0
 /**
  * Parse a user's newsletter-list subscription interface
  * @param User  User object of whoem the newsletter-list subscriptions shall be parsed
  */
 protected function parseNewsletterLists($objUser)
 {
     global $_CONFIG, $objDatabase, $objInit;
     if (!$this->_objTpl->blockExists('access_newsletter')) {
         return;
     }
     if (\Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase)->isInLegalComponents('Newsletter')) {
         $arrSubscribedNewsletterListIDs = $objUser->getSubscribedNewsletterListIDs();
         $arrNewsletterLists = \Cx\Modules\Newsletter\Controller\NewsletterLib::getLists();
         if (!count($arrNewsletterLists)) {
             $this->_objTpl->hideBlock('access_newsletter_list');
             return;
         }
         $row = 0;
         foreach ($arrNewsletterLists as $listId => $arrList) {
             if ($objInit->mode != 'backend' && !$arrList['status'] && !in_array($listId, $arrSubscribedNewsletterListIDs)) {
                 continue;
             }
             $this->_objTpl->setVariable(array($this->modulePrefix . 'NEWSLETTER_ID' => $listId, $this->modulePrefix . 'NEWSLETTER_NAME' => contrexx_raw2xhtml($arrList['name']), $this->modulePrefix . 'NEWSLETTER_SELECTED' => in_array($listId, $arrSubscribedNewsletterListIDs) ? 'checked="checked"' : '', $this->modulePrefix . 'NEWSLETTER_ROW_CLASS' => $row++ % 2 + 1));
             $this->_objTpl->parse('access_newsletter_list');
         }
         $this->_objTpl->touchBlock('access_newsletter');
         if ($this->_objTpl->blockExists('access_newsletter_tab')) {
             $this->_objTpl->touchBlock('access_newsletter_tab');
         }
     } else {
         $this->_objTpl->hideBlock('access_newsletter');
         if ($this->_objTpl->blockExists('access_newsletter_tab')) {
             $this->_objTpl->hideBlock('access_newsletter_tab');
         }
     }
 }
예제 #4
0
 /**
  * Render the option in the frontend.
  *
  * @param Sigma $template
  */
 public function renderTheme($template)
 {
     $blockName = strtolower('TEMPLATE_EDITOR_' . $this->name);
     if (!$template->blockExists($blockName)) {
         return;
     }
     if ($this->active) {
         $template->touchBlock($blockName);
     } else {
         $template->hideBlock($blockName);
     }
 }
예제 #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
 function chooseReservationProduct()
 {
     global $objDatabase, $_ARRAYLANG;
     $this->objTemplate->loadTemplateFile('module_gov_choose_product.html');
     $this->_pageTitle = $_ARRAYLANG['TXT_EGOV_PRODUCT_FOR_RESERVATION'];
     $this->objTemplate->setVariable(array('TXT_PRODUCT' => $_ARRAYLANG['TXT_PRODUCT'], 'TXT_EGOV_CHOOSE_PRODUCT_FOR_RESERVATION' => $_ARRAYLANG['TXT_EGOV_CHOOSE_PRODUCT_FOR_RESERVATION']));
     $query = "\n            SELECT *\n              FROM " . DBPREFIX . "module_egov_products\n             ORDER BY product_orderby, product_name\n        ";
     $objResult = $objDatabase->Execute($query);
     $i = 0;
     while (!$objResult->EOF) {
         $StatusImg = '<img src="../core/Core/View/Media/icons/status_green.gif" width="10" height="10" border="0" alt="" />';
         if ($objResult->fields["product_status"] != 1) {
             $StatusImg = '<img src="../core/Core/View/Media/icons/status_red.gif" width="10" height="10" border="0" alt="" />';
         }
         $this->objTemplate->setVariable(array('ROWCLASS' => ++$i % 2 ? 'row2' : 'row1', 'PRODUCT_ID' => $objResult->fields['product_id'], 'PRODUCT_NAME' => $objResult->fields['product_name'], 'PRODUCT_STATUS' => $StatusImg));
         $this->objTemplate->parse('products_list');
         $objResult->MoveNext();
     }
     if ($i == 0) {
         $this->objTemplate->hideBlock('products_list');
     }
 }
 /**
  * Parse the current navigation item
  * 
  * @global array $_ARRAYLANG
  * 
  * @param \Cx\Core\Html\Sigma $navigation
  * @param string              $blockName
  * @param string              $currentCmd
  * @param string              $mainCmd
  * @param boolean             $isActiveNav
  * @param boolean             $isSubNav
  */
 protected function parseCurrentNavItem(\Cx\Core\Html\Sigma $navigation, $blockName, $currentCmd, $mainCmd, $isActiveNav, $isSubNav)
 {
     global $_ARRAYLANG;
     if (empty($blockName)) {
         return;
     }
     $isActiveNav ? $navigation->touchBlock($blockName . '_active') : $navigation->hideBlock($blockName . '_active');
     if (empty($isSubNav)) {
         $act = empty($currentCmd) ? '' : '&amp;act=' . $currentCmd;
         $txt = empty($currentCmd) ? 'DEFAULT' : $currentCmd;
     } else {
         $act = '&amp;act=' . $mainCmd . '/' . $currentCmd;
         $txt = (empty($mainCmd) ? 'DEFAULT' : $mainCmd) . '_';
         $txt .= empty($currentCmd) ? 'DEFAULT' : strtoupper($currentCmd);
     }
     $actTxtKey = 'TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt);
     $actTitle = isset($_ARRAYLANG[$actTxtKey]) ? $_ARRAYLANG[$actTxtKey] : $actTxtKey;
     $navigation->setVariable(array('HREF' => 'index.php?cmd=' . $this->getName() . $act, 'TITLE' => $actTitle));
     $navigation->parse($blockName . '_entry');
 }
예제 #8
0
 private function parseRelatedDownloads($objDownload, $currentCategoryId)
 {
     global $_LANGID, $_ARRAYLANG;
     if (!$this->objTemplate->blockExists('downloads_related_file_list')) {
         return;
     }
     $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']];
     $objRelatedDownload = $objDownload->getDownloads(array('download_id' => $objDownload->getId()), null, $sortOrder);
     if ($objRelatedDownload) {
         $row = 1;
         while (!$objRelatedDownload->EOF) {
             $description = $objRelatedDownload->getDescription($_LANGID);
             if (strlen($description) > 100) {
                 $shortDescription = substr($description, 0, 97) . '...';
             } else {
                 $shortDescription = $description;
             }
             $imageSrc = $objRelatedDownload->getImage();
             if (!empty($imageSrc) && file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $imageSrc)) {
                 $thumb_name = \ImageManager::getThumbnailFilename($imageSrc);
                 if (file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $thumb_name)) {
                     $thumbnailSrc = $thumb_name;
                 } else {
                     $thumbnailSrc = \ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']);
                 }
                 $image = $this->getHtmlImageTag($imageSrc, htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET));
                 $thumbnail = $this->getHtmlImageTag($thumbnailSrc, htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET));
             } else {
                 $imageSrc = $this->defaultCategoryImage['src'];
                 $thumbnailSrc = \ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']);
                 $image = '';
                 $thumbnail = '';
             }
             $arrAssociatedCategories = $objRelatedDownload->getAssociatedCategoryIds();
             if (in_array($currentCategoryId, $arrAssociatedCategories)) {
                 $categoryId = $currentCategoryId;
             } else {
                 $arrPublicCategories = array();
                 $arrProtectedCategories = array();
                 foreach ($arrAssociatedCategories as $categoryId) {
                     $objCategory = Category::getCategory($categoryId);
                     if (!$objCategory->EOF) {
                         if ($objCategory->getVisibility() || \Permission::checkAccess($objCategory->getReadAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $this->userId) {
                             $arrPublicCategories[] = $categoryId;
                             break;
                         } else {
                             $arrProtectedCategories[] = $categoryId;
                         }
                     }
                 }
                 if (count($arrPublicCategories)) {
                     $categoryId = $arrPublicCategories[0];
                 } elseif (count($arrProtectedCategories)) {
                     $categoryId = $arrProtectedCategories[0];
                 } else {
                     $objRelatedDownload->next();
                     continue;
                 }
             }
             $this->objTemplate->setVariable(array('DOWNLOADS_RELATED_FILE_ID' => $objRelatedDownload->getId(), 'DOWNLOADS_RELATED_FILE_DETAIL_SRC' => CONTREXX_SCRIPT_PATH . $this->moduleParamsHtml . '&amp;category=' . $categoryId . '&amp;id=' . $objRelatedDownload->getId(), 'DOWNLOADS_RELATED_FILE_NAME' => htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_RELATED_FILE_DESCRIPTION' => nl2br(htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_RELATED_FILE_SHORT_DESCRIPTION' => htmlentities($shortDescription, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_RELATED_FILE_IMAGE' => $image, 'DOWNLOADS_RELATED_FILE_IMAGE_SRC' => $imageSrc, 'DOWNLOADS_RELATED_FILE_THUMBNAIL' => $thumbnail, 'DOWNLOADS_RELATED_FILE_THUMBNAIL_SRC' => $thumbnailSrc, 'DOWNLOADS_RELATED_FILE_ICON' => $this->getHtmlImageTag($objRelatedDownload->getIcon(), htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_RELATED_FILE_ROW_CLASS' => 'row' . ($row++ % 2 + 1)));
             $this->objTemplate->parse('downloads_related_file');
             $objRelatedDownload->next();
         }
         $this->objTemplate->setVariable('TXT_DOWNLOADS_RELATED_DOWNLOADS', $_ARRAYLANG['TXT_DOWNLOADS_RELATED_DOWNLOADS']);
         $this->objTemplate->parse('downloads_related_file_list');
     } else {
         $this->objTemplate->hideBlock('downloads_related_file_list');
     }
 }
예제 #9
0
 /**
  * Processes the Order
  *
  * Verifies all data, updates and stores it in the database, and
  * initializes payment
  * @return  boolean         True on successs, false otherwise
  */
 static function process()
 {
     global $objDatabase, $_ARRAYLANG;
     // FOR TESTING ONLY (repeatedly process/store the order, also disable self::destroyCart())
     //$_SESSION['shop']['order_id'] = NULL;
     // Verify that the order hasn't yet been saved
     // (and has thus not yet been confirmed)
     if (isset($_SESSION['shop']['order_id'])) {
         return \Message::error($_ARRAYLANG['TXT_ORDER_ALREADY_PLACED']);
     }
     // No more confirmation
     self::$objTemplate->hideBlock('shopConfirm');
     // Store the customer, register the order
     $customer_ip = $_SERVER['REMOTE_ADDR'];
     $customer_host = substr(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 0, 100);
     $customer_browser = substr(getenv('HTTP_USER_AGENT'), 0, 100);
     $new_customer = false;
     //\DBG::log("Shop::process(): E-Mail: ".$_SESSION['shop']['email']);
     if (self::$objCustomer) {
         //\DBG::log("Shop::process(): Existing User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']);
     } else {
         // Registered Customers are required to be logged in!
         self::$objCustomer = Customer::getRegisteredByEmail($_SESSION['shop']['email']);
         if (self::$objCustomer) {
             \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_REGISTERED_EMAIL']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'confirm')));
         }
         // Unregistered Customers are stored as well, as their information is needed
         // nevertheless.  Their active status, however, is set to false.
         self::$objCustomer = Customer::getUnregisteredByEmail($_SESSION['shop']['email']);
         if (!self::$objCustomer) {
             self::$objCustomer = new Customer();
             // Currently, the e-mail address is set as the user name
             $_SESSION['shop']['username'] = $_SESSION['shop']['email'];
             //\DBG::log("Shop::process(): New User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']);
             self::$objCustomer->username($_SESSION['shop']['username']);
             self::$objCustomer->email($_SESSION['shop']['email']);
             // Note that the password is unset when the Customer chooses
             // to order without registration.  The generated one
             // defaults to length 8, fulfilling the requirements for
             // complex passwords.  And it's kept absolutely secret.
             $password = empty($_SESSION['shop']['password']) ? \User::make_password() : $_SESSION['shop']['password'];
             //\DBG::log("Password: $password (session: {$_SESSION['shop']['password']})");
             if (!self::$objCustomer->password($password)) {
                 \Message::error($_ARRAYLANG['TXT_INVALID_PASSWORD']);
                 \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'account'));
             }
             self::$objCustomer->active(empty($_SESSION['shop']['dont_register']));
             $new_customer = true;
         }
     }
     // Update the Customer object from the session array
     // (whether new or not -- it may have been edited)
     self::$objCustomer->gender($_SESSION['shop']['gender']);
     self::$objCustomer->firstname($_SESSION['shop']['firstname']);
     self::$objCustomer->lastname($_SESSION['shop']['lastname']);
     self::$objCustomer->company($_SESSION['shop']['company']);
     self::$objCustomer->address($_SESSION['shop']['address']);
     self::$objCustomer->city($_SESSION['shop']['city']);
     self::$objCustomer->zip($_SESSION['shop']['zip']);
     self::$objCustomer->country_id($_SESSION['shop']['countryId']);
     self::$objCustomer->phone($_SESSION['shop']['phone']);
     self::$objCustomer->fax($_SESSION['shop']['fax']);
     $arrGroups = self::$objCustomer->getAssociatedGroupIds();
     $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop');
     if (empty($usergroup_id)) {
         //\DBG::log("Shop::process(): ERROR: Missing reseller group");
         \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']);
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', ''));
     }
     if (!in_array($usergroup_id, $arrGroups)) {
         //\DBG::log("Shop::process(): Customer is not in Reseller group (ID $usergroup_id)");
         // Not a reseller.  See if she's a final customer
         $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop');
         if (empty($usergroup_id)) {
             //\DBG::log("Shop::process(): ERROR: Missing final customer group");
             \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', ''));
         }
         if (!in_array($usergroup_id, $arrGroups)) {
             //\DBG::log("Shop::process(): Customer is not in final customer group (ID $usergroup_id), either");
             // Neither one, add to the final customer group (default)
             $arrGroups[] = $usergroup_id;
             self::$objCustomer->setGroups($arrGroups);
             //\DBG::log("Shop::process(): Added Customer to final customer group (ID $usergroup_id): ".var_export(self::$objCustomer->getAssociatedGroupIds(), true));
         } else {
             //\DBG::log("Shop::process(): Customer is a final customer (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true));
         }
     } else {
         //\DBG::log("Shop::process(): Customer is a Reseller (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true));
     }
     // Insert or update the customer
     //\DBG::log("Shop::process(): Storing Customer: ".var_export(self::$objCustomer, true));
     if (!self::$objCustomer->store()) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']);
     }
     // Authenticate new Customer
     if ($new_customer) {
         // Fails for "unregistered" Customers!
         if (self::$objCustomer->auth($_SESSION['shop']['username'], $_SESSION['shop']['password'], false, true)) {
             if (!self::_authenticate()) {
                 return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']);
             }
         }
     }
     //die();
     // Clear the ship-to country if there is no shipping
     if (!Cart::needs_shipment()) {
         $_SESSION['shop']['countryId2'] = 0;
     }
     $shipper_id = empty($_SESSION['shop']['shipperId']) ? null : $_SESSION['shop']['shipperId'];
     $payment_id = empty($_SESSION['shop']['paymentId']) ? null : $_SESSION['shop']['paymentId'];
     $objOrder = new Order();
     $objOrder->customer_id(self::$objCustomer->id());
     $objOrder->billing_gender($_SESSION['shop']['gender']);
     $objOrder->billing_firstname($_SESSION['shop']['firstname']);
     $objOrder->billing_lastname($_SESSION['shop']['lastname']);
     $objOrder->billing_company($_SESSION['shop']['company']);
     $objOrder->billing_address($_SESSION['shop']['address']);
     $objOrder->billing_city($_SESSION['shop']['city']);
     $objOrder->billing_zip($_SESSION['shop']['zip']);
     $objOrder->billing_country_id($_SESSION['shop']['countryId']);
     $objOrder->billing_phone($_SESSION['shop']['phone']);
     $objOrder->billing_fax($_SESSION['shop']['fax']);
     $objOrder->billing_email($_SESSION['shop']['email']);
     $objOrder->currency_id($_SESSION['shop']['currencyId']);
     $objOrder->sum($_SESSION['shop']['grand_total_price']);
     $objOrder->date_time(date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME));
     $objOrder->status(0);
     $objOrder->company($_SESSION['shop']['company2']);
     $objOrder->gender($_SESSION['shop']['gender2']);
     $objOrder->firstname($_SESSION['shop']['firstname2']);
     $objOrder->lastname($_SESSION['shop']['lastname2']);
     $objOrder->address($_SESSION['shop']['address2']);
     $objOrder->city($_SESSION['shop']['city2']);
     $objOrder->zip($_SESSION['shop']['zip2']);
     $objOrder->country_id($_SESSION['shop']['countryId2']);
     $objOrder->phone($_SESSION['shop']['phone2']);
     $objOrder->vat_amount($_SESSION['shop']['vat_price']);
     $objOrder->shipment_amount($_SESSION['shop']['shipment_price']);
     $objOrder->shipment_id($shipper_id);
     $objOrder->payment_id($payment_id);
     $objOrder->payment_amount($_SESSION['shop']['payment_price']);
     $objOrder->ip($customer_ip);
     $objOrder->host($customer_host);
     $objOrder->lang_id(FRONTEND_LANG_ID);
     $objOrder->browser($customer_browser);
     $objOrder->note($_SESSION['shop']['note']);
     if (!$objOrder->insert()) {
         // $order_id is unset!
         return \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_STORING']);
     }
     $order_id = $objOrder->id();
     $_SESSION['shop']['order_id'] = $order_id;
     // The products will be tested one by one below.
     // If any single one of them requires delivery, this
     // flag will be set to true.
     // This is used to determine the order status at the
     // end of the shopping process.
     $_SESSION['shop']['isDelivery'] = false;
     // Try to redeem the Coupon, if any
     $coupon_code = isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : null;
     //\DBG::log("Cart::update(): Coupon Code: $coupon_code");
     $items_total = 0;
     // Suppress Coupon messages (see Coupon::available())
     \Message::save();
     foreach (Cart::get_products_array() as $arrProduct) {
         $objProduct = Product::getById($arrProduct['id']);
         if (!$objProduct) {
             unset($_SESSION['shop']['order_id']);
             return \Message::error($_ARRAYLANG['TXT_ERROR_LOOKING_UP_ORDER']);
         }
         $product_id = $arrProduct['id'];
         $name = $objProduct->name();
         $priceOptions = !empty($arrProduct['optionPrice']) ? $arrProduct['optionPrice'] : 0;
         $quantity = $arrProduct['quantity'];
         $price = $objProduct->get_custom_price(self::$objCustomer, $priceOptions, $quantity);
         $item_total = $price * $quantity;
         $items_total += $item_total;
         $productVatId = $objProduct->vat_id();
         $vat_rate = $productVatId && Vat::getRate($productVatId) ? Vat::getRate($productVatId) : '0.00';
         // Test the distribution method for delivery
         $productDistribution = $objProduct->distribution();
         if ($productDistribution == 'delivery') {
             $_SESSION['shop']['isDelivery'] = true;
         }
         $weight = $productDistribution == 'delivery' ? $objProduct->weight() : 0;
         // grams
         if ($weight == '') {
             $weight = 0;
         }
         // Add to order items table
         $result = $objOrder->insertItem($order_id, $product_id, $name, $price, $quantity, $vat_rate, $weight, $arrProduct['options']);
         if (!$result) {
             unset($_SESSION['shop']['order_id']);
             // TODO: Verify error message set by Order::insertItem()
             return false;
         }
         // Store the Product Coupon, if applicable.
         // Note that it is not redeemed yet (uses=0)!
         if ($coupon_code) {
             $objCoupon = Coupon::available($coupon_code, $item_total, self::$objCustomer->id(), $product_id, $payment_id);
             if ($objCoupon) {
                 //\DBG::log("Shop::process(): Got Coupon for Product ID $product_id: ".var_export($objCoupon, true));
                 if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $price * $quantity, 0)) {
                     // TODO: Do something if the Coupon does not work
                     \DBG::log("Shop::process(): ERROR: Failed to store Coupon for Product ID {$product_id}");
                 }
                 $coupon_code = null;
             }
         }
     }
     // foreach product in cart
     // Store the Global Coupon, if applicable.
     // Note that it is not redeemed yet (uses=0)!
     //\DBG::log("Shop::process(): Looking for global Coupon $coupon_code");
     if ($coupon_code) {
         $objCoupon = Coupon::available($coupon_code, $items_total, self::$objCustomer->id(), null, $payment_id);
         if ($objCoupon) {
             //\DBG::log("Shop::process(): Got global Coupon: ".var_export($objCoupon, true));
             if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $items_total, 0)) {
                 \DBG::log("Shop::process(): ERROR: Failed to store global Coupon");
             }
         }
     }
     \Message::restore();
     $processor_id = Payment::getProperty($_SESSION['shop']['paymentId'], 'processor_id');
     $processor_name = PaymentProcessing::getPaymentProcessorName($processor_id);
     // other payment methods
     PaymentProcessing::initProcessor($processor_id);
     // TODO: These arguments are no longer valid.  Set them up later?
     //            Currency::getActiveCurrencyCode(),
     //            FWLanguage::getLanguageParameter(FRONTEND_LANG_ID, 'lang'));
     // if the processor is Internal_LSV, and there is account information,
     // store the information.
     if ($processor_name == 'internal_lsv') {
         if (!self::lsv_complete()) {
             // Missing mandatory data; return to payment
             unset($_SESSION['shop']['order_id']);
             \Message::error($_ARRAYLANG['TXT_ERROR_ACCOUNT_INFORMATION_NOT_AVAILABLE']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment'));
         }
         $query = "\n                INSERT INTO " . DBPREFIX . "module_shop" . MODULE_INDEX . "_lsv (\n                    order_id, holder, bank, blz\n                ) VALUES (\n                    {$order_id},\n                    '" . contrexx_raw2db($_SESSION['shop']['account_holder']) . "',\n                    '" . contrexx_raw2db($_SESSION['shop']['account_bank']) . "',\n                    '" . contrexx_raw2db($_SESSION['shop']['account_blz']) . "'\n                )";
         $objResult = $objDatabase->Execute($query);
         if (!$objResult) {
             // Return to payment
             unset($_SESSION['shop']['order_id']);
             \Message::error($_ARRAYLANG['TXT_ERROR_INSERTING_ACCOUNT_INFORMATION']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment'));
         }
     }
     $_SESSION['shop']['order_id_checkin'] = $order_id;
     $strProcessorType = PaymentProcessing::getCurrentPaymentProcessorType();
     // Test whether the selected payment method can be
     // considered an instant or deferred one.
     // This is used to set the order status at the end
     // of the shopping process.
     // TODO: Invert this flag, as it may no longer be present after paying
     // online using one of the external payment methods!  Ensure that it is set
     // instead when paying "deferred".
     $_SESSION['shop']['isInstantPayment'] = false;
     if ($strProcessorType == 'external') {
         // For the sake of simplicity, all external payment
         // methods are considered to be 'instant'.
         // All currently implemented internal methods require
         // further action from the merchant, and thus are
         // considered to be 'deferred'.
         $_SESSION['shop']['isInstantPayment'] = true;
     }
     // Send the Customer login separately, as the password possibly
     // won't be available later
     if (!empty($_SESSION['shop']['password'])) {
         self::sendLogin(self::$objCustomer->email(), $_SESSION['shop']['password']);
     }
     // Show payment processing page.
     // Note that some internal payments are redirected away
     // from this page in checkOut():
     // 'internal', 'internal_lsv'
     self::$objTemplate->setVariable('SHOP_PAYMENT_PROCESSING', PaymentProcessing::checkOut());
     // Clear the order ID.
     // The order may be resubmitted and the payment retried.
     unset($_SESSION['shop']['order_id']);
     // Custom.
     // Enable if Discount class is customized and in use.
     //self::showCustomerDiscount(Cart::get_price());
     return true;
 }
 /**
  * Parse the registration related palceholders
  * $hostUri and $hostTarget should be set before calling this method
  *
  * @param \Cx\Core\Html\Sigma                           $objTpl         Template instance
  * @param \Cx\Modules\Calendar\Controller\CalendarEvent $event          Event instance
  * @param string                                        $hostUri        Host uri of the event(internal/external)
  * @param string                                        $hostTarget     Host uri target type (_blank/null)
  *
  * @return null
  */
 public function parseRegistrationPlaceholders(\Cx\Core\Html\Sigma $objTpl, CalendarEvent $event, $hostUri = '', $hostTarget = '')
 {
     global $_ARRAYLANG;
     $numRegistrations = contrexx_input2int($event->getRegistrationCount());
     $numDeregistration = contrexx_input2int($event->getCancellationCount());
     $objEscortManager = new \Cx\Modules\Calendar\Controller\CalendarRegistrationManager($event, true, false);
     $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_COUNT_REG' => $numRegistrations, $this->moduleLangVar . '_EVENT_COUNT_SIGNOFF' => $numDeregistration, $this->moduleLangVar . '_EVENT_COUNT_SUBSCRIBER' => $objEscortManager->getEscortData(), $this->moduleLangVar . '_REGISTRATIONS_SUBSCRIBER' => $event->numSubscriber));
     // Only link to registration form if event registration is set up and event lies in the future
     if (!$event->registration || time() > $event->startDate->getTimestamp()) {
         $objTpl->hideBlock('calendarEventRegistration');
         return;
     }
     // Only show registration form if event accepts registrations.
     // Event accepts registrations, if
     //     - no attendee limit is set
     //     - or if there are still free places available
     $registrationOpen = true;
     $regLinkTarget = '_self';
     if ($event->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL && !$event->registrationExternalFullyBooked || $event->registration == CalendarEvent::EVENT_REGISTRATION_INTERNAL && (empty($event->numSubscriber) || !\FWValidator::isEmpty($event->getFreePlaces()))) {
         if ($event->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL) {
             $regLinkSrc = \FWValidator::getUrl($event->registrationExternalLink);
             $regLinkTarget = '_blank';
         } elseif ($hostUri) {
             $regLinkSrc = $hostUri . '/' . CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '&amp;cmd=register&amp;id=' . $event->id . '&amp;date=' . $event->startDate->getTimestamp();
         } else {
             $params = array('id' => $event->id, 'date' => $event->startDate->getTimestamp());
             $regLinkSrc = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'register', FRONTEND_LANG_ID, $params)->toString();
         }
         $regLink = '<a href="' . $regLinkSrc . '" ' . $hostTarget . '>' . $_ARRAYLANG['TXT_CALENDAR_REGISTRATION'] . '</a>';
     } else {
         $regLink = '<i>' . $_ARRAYLANG['TXT_CALENDAR_EVENT_FULLY_BLOCKED'] . '</i>';
         $regLinkSrc = '';
         $registrationOpen = false;
     }
     $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_REGISTRATION_LINK' => $regLink, $this->moduleLangVar . '_EVENT_REGISTRATION_LINK_SRC' => $regLinkSrc, $this->moduleLangVar . '_EVENT_REGISTRATION_LINK_TARGET' => $regLinkTarget));
     if ($objTpl->blockExists('calendarEventRegistrationOpen')) {
         if ($registrationOpen) {
             $objTpl->touchBlock('calendarEventRegistrationOpen');
         } else {
             $objTpl->hideBlock('calendarEventRegistrationOpen');
         }
     }
     if ($objTpl->blockExists('calendarEventRegistrationClosed')) {
         if (!$registrationOpen) {
             $objTpl->touchBlock('calendarEventRegistrationClosed');
         } else {
             $objTpl->hideBlock('calendarEventRegistrationClosed');
         }
     }
     $objTpl->parse('calendarEventRegistration');
 }
예제 #11
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']);
     }
 }
예제 #12
0
 /**
  * Parses the main template in order to finish request
  * @todo Remove usage of globals
  * @global type $themesPages
  * @global null $moduleStyleFile
  * @global array $_CONFIG
  * @global type $subMenuTitle
  * @global type $_CORELANG
  * @global type $plainCmd
  * @global type $cmd
  */
 protected function finalize()
 {
     global $themesPages, $moduleStyleFile, $_CONFIG, $subMenuTitle, $_CORELANG, $plainCmd, $cmd;
     if ($this->mode == self::MODE_FRONTEND) {
         // parse system
         $parsingTime = $this->stopTimer();
         $this->template->setVariable('PARSING_TIME', $parsingTime);
         $this->parseGlobalPlaceholders($themesPages['sidebar']);
         $this->template->setVariable(array('SIDEBAR_FILE' => $themesPages['sidebar'], 'JAVASCRIPT_FILE' => $themesPages['javascript'], 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'DATE_YEAR' => date('Y'), 'DATE_MONTH' => date('m'), 'DATE_DAY' => date('d'), 'DATE_TIME' => date('H:i'), 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'JAVASCRIPT_LIGHTBOX' => '<script type="text/javascript" src="lib/lightbox/javascript/mootools.js"></script>
                 <script type="text/javascript" src="lib/lightbox/javascript/slimbox.js"></script>', 'JAVASCRIPT_MOBILE_DETECTOR' => '<script type="text/javascript" src="lib/mobiledetector.js"></script>'));
         if (!empty($moduleStyleFile)) {
             $this->template->setVariable('STYLE_FILE', "<link rel=\"stylesheet\" href=\"{$moduleStyleFile}\" type=\"text/css\" media=\"screen, projection\" />");
         }
         if (!$this->resolvedPage->getUseSkinForAllChannels() && isset($_GET['pdfview']) && intval($_GET['pdfview']) == 1) {
             $pageTitle = $this->resolvedPage->getTitle();
             $extenstion = empty($pageTitle) ? null : '.pdf';
             $objPDF = new \Cx\Core_Modules\Pdf\Model\Entity\PdfDocument();
             $objPDF->SetTitle($pageTitle . $extenstion);
             $objPDF->setContent($this->template->get());
             $objPDF->Create();
             exit;
         }
         // fetch the parsed webpage
         $this->template->setVariable('JAVASCRIPT', 'javascript_inserting_here');
         $endcode = $this->template->get();
         /**
          * Get all javascripts in the code, replace them with nothing, and register the js file
          * to the javascript lib. This is because we don't want something twice, and there could be
          * a theme that requires a javascript, which then could be used by a module too and therefore would
          * be loaded twice.
          */
         /* Finds all uncommented script tags, strips them out of the HTML and
          * stores them internally so we can put them in the placeholder later
          * (see JS::getCode() below)
          */
         \JS::findJavascripts($endcode);
         /*
          * Proposal:  Use this
          *     $endcode = preg_replace_callback('/<script\s.*?src=(["\'])(.*?)(\1).*?\/?>(?:<\/script>)?/i', array('JS', 'registerFromRegex'), $endcode);
          * and change JS::registerFromRegex to use index 2
          */
         // i know this is ugly, but is there another way
         $endcode = str_replace('javascript_inserting_here', \JS::getCode(), $endcode);
         // do a final replacement of all those node-urls ({NODE_<ID>_<LANG>}- placeholders) that haven't been captured earlier
         $endcode = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $endcode);
         \LinkGenerator::parseTemplate($endcode);
         // remove the meta tag X-UA-Compatible if the user agent ist neighter internet explorer nor chromeframe
         if (!preg_match('/(msie|chromeframe)/i', $_SERVER['HTTP_USER_AGENT'])) {
             $endcode = preg_replace('/<meta.*?X-UA-Compatible.*?>/i', '', $endcode);
         }
         // replace links from before contrexx 3
         $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . \Env::get('virtualLanguageDirectory') . '/', $endcode);
         $this->endcode = $ls->replace();
     } else {
         // backend meta navigation
         if ($this->template->blockExists('backend_metanavigation')) {
             // parse language navigation
             if ($this->template->blockExists('backend_language_navigation') && $this->template->blockExists('backend_language_navigation_item')) {
                 $backendLanguage = \FWLanguage::getActiveBackendLanguages();
                 if (count($backendLanguage) > 1) {
                     $this->template->setVariable('TXT_LANGUAGE', $_CORELANG['TXT_LANGUAGE']);
                     foreach ($backendLanguage as $language) {
                         $languageUrl = \Env::get('init')->getUriBy('setLang', $language['id']);
                         $this->template->setVariable(array('LANGUAGE_URL' => contrexx_raw2xhtml($languageUrl), 'LANGUAGE_NAME' => $language['name'], 'LANGUAGE_CSS' => \Env::get('init')->getBackendLangId() == $language['id'] ? 'active' : ''));
                         $this->template->parse('backend_language_navigation_item');
                     }
                     $this->template->parse('backend_language_navigation');
                 } else {
                     $this->template->hideBlock('backend_language_navigation');
                 }
             }
             $this->template->touchBlock('backend_metanavigation');
         }
         // page parsing
         $parsingTime = $this->stopTimer();
         //                var_dump($parsingTime);
         /*echo ($finishTime[0] - $startTime[0]) . '<br />';
           if (!isset($_SESSION['asdf1']) || isset($_GET['reset'])) {
               $_SESSION['asdf1'] = 0;
               $_SESSION['asdf2'] = 0;
           }
           echo $_SESSION['asdf1'] . '<br />';
           if ($_SESSION['asdf1'] > 0) {
               echo $_SESSION['asdf2'] / $_SESSION['asdf1'];
           }
           $_SESSION['asdf1']++;
           $_SESSION['asdf2'] += ($finishTime[0] - $startTime[0]);//*/
         $objAdminNav = new \adminMenu($plainCmd);
         $objAdminNav->getAdminNavbar();
         $this->template->setVariable(array('SUB_MENU_TITLE' => $subMenuTitle, 'FRONTEND_LANG_MENU' => \Env::get('init')->getUserFrontendLangMenu(), 'TXT_GENERATED_IN' => $_CORELANG['TXT_GENERATED_IN'], 'TXT_SECONDS' => $_CORELANG['TXT_SECONDS'], 'TXT_LOGOUT_WARNING' => $_CORELANG['TXT_LOGOUT_WARNING'], 'PARSING_TIME' => $parsingTime, 'LOGGED_NAME' => htmlentities($this->getUser()->objUser->getProfileAttribute('firstname') . ' ' . $this->getUser()->objUser->getProfileAttribute('lastname'), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_LOGGED_IN_AS' => $_CORELANG['TXT_LOGGED_IN_AS'], 'TXT_LOG_OUT' => $_CORELANG['TXT_LOG_OUT'], 'MODULE_INDEX' => MODULE_INDEX, 'JAVASCRIPT' => \JS::getCode(), 'CX_EDITION' => $_CONFIG['coreCmsEdition'], 'CX_VERSION' => $_CONFIG['coreCmsVersion'], 'CX_CODE_NAME' => $_CONFIG['coreCmsCodeName'], 'CX_STATUS' => $_CONFIG['coreCmsStatus'], 'CX_RELEASE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $_CONFIG['coreCmsReleaseDate']), 'CX_NAME' => $_CONFIG['coreCmsName']));
         // Style parsing
         if (file_exists($this->codeBaseAdminTemplatePath . '/css/' . $cmd . '.css')) {
             // check if there's a css file in the core section
             $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseAdminTemplateWebPath . '/css/' . $cmd . '.css');
             $this->template->parse('additional_style');
         } elseif (file_exists($this->codeBaseModulePath . '/' . $cmd . '/template/backend.css')) {
             // of maybe in the current module directory
             $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseModuleWebPath . '/' . $cmd . '/template/backend.css');
             $this->template->parse('additional_style');
         } elseif (file_exists($this->codeBaseCoreModulePath . '/' . $cmd . '/template/backend.css')) {
             // or in the core module directory
             $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseCoreModuleWebPath . '/' . $cmd . '/template/backend.css');
             $this->template->parse('additional_style');
         } else {
             $this->template->hideBlock('additional_style');
         }
         /*echo '<pre>';
           print_r($_SESSION);
           /*echo '<b>Overall time: ' . (microtime(true) - $timeAtStart) . 's<br />';
           echo 'Max RAM usage: ' . formatBytes(memory_get_peak_usage()) . '<br />';
           echo 'End RAM usage: ' . formatBytes(memory_get_usage()) . '<br /></b>';*/
         $endcode = $this->template->get();
         // replace links from before contrexx 3
         $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . $this->getBackendFolderName() . '/', $endcode);
         $this->endcode = $ls->replace();
     }
     \DBG::log("(Cx: {$this->id}) Request parsing completed after {$parsingTime}");
 }
예제 #13
0
 private function parseCategoryDownloads($objCategory, $downloadOrderBy, $downloadOrderDirection, $downloadLimitOffset, $categoryOrderBy, $categoryOrderDirection, $categoryLimitOffset, $searchTerm)
 {
     global $_ARRAYLANG, $_LANGID, $_CONFIG;
     $nr = 0;
     $arrDownloadOrder = $objCategory->getAssociatedDownloadIds();
     $objFWUser = \FWUser::getFWUserObject();
     $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']];
     $arrSort = empty($downloadOrderBy) ? $sortOrder : array_merge(array($downloadOrderBy => $downloadOrderDirection), $sortOrder);
     $objDownload = new Download();
     $objDownload->loadDownloads(array('category_id' => $objCategory->getId()), $searchTerm, $arrSort, null, $_CONFIG['corePagingLimit'], $downloadLimitOffset, true);
     $downloadsAvailable = $objDownload->EOF ? false : true;
     while (!$objDownload->EOF) {
         //            if (!\Permission::checkAccess(143, 'static', true) && !$objDownload->getVisibility() && $objDownload->getOwnerId() != $objFWUser->objUser->getId()) {
         //                $objDownload->next();
         //                continue;
         //            }
         // parse select checkbox & order box
         if ((\Permission::checkAccess(143, 'static', true) || !$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $objFWUser->objUser->getId()) && $objCategory->getId()) {
             // select checkbox
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ID', $objDownload->getId());
             $this->objTemplate->parse('downloads_download_checkbox');
             // order box
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_ORDER' => $arrDownloadOrder[$objDownload->getId()]));
             $this->objTemplate->parse('downloads_download_orderbox');
             $this->objTemplate->hideBlock('downloads_download_no_orderbox');
             $this->objTemplate->parse('downloads_download_no_save_button');
         } else {
             // select checkbox
             $this->objTemplate->hideBlock('downloads_download_checkbox');
             $this->objTemplate->hideBlock('downloads_download_action_dropdown');
             // order box
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ORDER', $objCategory->getId() ? $arrDownloadOrder[$objDownload->getId()] : $objDownload->getOrder());
             $this->objTemplate->parse('downloads_download_no_orderbox');
             $this->objTemplate->hideBlock('downloads_download_orderbox');
             $this->objTemplate->hideBlock('downloads_download_no_save_button');
         }
         // parse status link and modify button
         if (\Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getModifyAccessByOwner() && $objCategory->getOwnerId() == $objFWUser->objUser->getId()) || $objDownload->getOwnerId() == $objFWUser->objUser->getId()) {
             $this->objTemplate->setVariable(array('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, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId(), 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_DEACTIVATE_DOWNLOAD_DESC'] : $_ARRAYLANG['TXT_DOWNLOADS_ACTIVATE_DOWNLOAD_DESC'], 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_IMG_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_DEACTIVATE_DOWNLOAD_DESC'] : $_ARRAYLANG['TXT_DOWNLOADS_ACTIVATE_DOWNLOAD_DESC']));
             $this->objTemplate->parse('downloads_download_status_link_open');
             $this->objTemplate->touchBlock('downloads_download_status_link_close');
             // parse modify icon
             $this->objTemplate->setVariable(array('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, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId()));
             $this->objTemplate->parse('downloads_download_function_modify_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_modify_link');
             // parse modify link on name attribute
             $this->objTemplate->setVariable(array('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, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId()));
             $this->objTemplate->parse('downloads_download_modify_link_open');
             $this->objTemplate->touchBlock('downloads_download_modify_link_close');
         } else {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_SWITCH_STATUS_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'] : $_ARRAYLANG['TXT_DOWNLOADS_INACTIVE'], 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_IMG_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'] : $_ARRAYLANG['TXT_DOWNLOADS_INACTIVE']));
             $this->objTemplate->hideBlock('downloads_download_status_link_open');
             $this->objTemplate->hideBlock('downloads_download_status_link_close');
             // hide modify icon
             $this->objTemplate->touchBlock('downloads_download_function_no_modify_link');
             $this->objTemplate->hideBlock('downloads_download_function_modify_link');
             // hide modify linke on name attribute
             $this->objTemplate->hideBlock('downloads_download_modify_link_open');
             $this->objTemplate->hideBlock('downloads_download_modify_link_close');
         }
         // parse download link
         if (!$objDownload->getAccessId() || $objDownload->getOwnerId() == $objFWUser->objUser->getId() || \Permission::checkAccess($objDownload->getAccessId(), 'dynamic', true) || \Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getModifyAccessByOwner() && $objCategory->getOwnerId() == $objFWUser->objUser->getId())) {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_DOWNLOAD_ICON' => $objDownload->getIcon(true), 'DOWNLOADS_DOWNLOAD_SOURCE' => htmlentities($objDownload->getSource(), ENT_QUOTES, CONTREXX_CHARSET)));
             $this->objTemplate->parse('downloads_download_function_download_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_download_link');
         } else {
             $this->objTemplate->hideBlock('downloads_download_function_download_link');
             $this->objTemplate->touchBlock('downloads_download_function_no_download_link');
         }
         // parse unlink button
         if (\Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $objFWUser->objUser->getId()) || $objDownload->getOwnerId() == $objFWUser->objUser->getId()) {
             $this->objTemplate->setVariable(array('TXT_DOWNLOADS_UNLINK' => $_ARRAYLANG['TXT_DOWNLOADS_UNLINK'], 'DOWNLOADS_DOWNLOAD_NAME_JS' => htmlspecialchars($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET)));
             // parse delete icon
             $this->objTemplate->parse('downloads_download_function_unlink_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_unlink_link');
         } else {
             // hide delete icon
             $this->objTemplate->touchBlock('downloads_download_function_no_unlink_link');
             $this->objTemplate->hideBlock('downloads_download_function_unlink_link');
         }
         $description = $objDownload->getDescription();
         if (strlen($description) > 100) {
             $description = substr($description, 0, 97) . '...';
         }
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_NAME' => htmlentities($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_DESCRIPTION' => htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_OWNER' => $this->getParsedUsername($objDownload->getOwnerId()), 'DOWNLOADS_DOWNLOAD_DOWNLOADED' => $objDownload->getDownloadCount(), 'DOWNLOADS_DOWNLOAD_VIEWED' => $objDownload->getViewCount(), 'DOWNLOADS_DOWNLOAD_STATUS_LED' => $objDownload->getActiveStatus() ? 'led_green.gif' : 'led_red.gif', 'DOWNLOADS_DOWNLOAD_ROW_CLASS' => $nr++ % 2 ? 'row1' : 'row2'));
         $this->objTemplate->parse('downloads_download_list');
         $objDownload->next();
     }
     if ($downloadsAvailable && !empty($this->parentCategoryId)) {
         $this->objTemplate->setVariable('TXT_DOWNLOADS_OF_CATEGORY', sprintf($_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADS_OF_CATEGORY'], '&bdquo;' . htmlentities($objCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . '&ldquo;'));
     } else {
         $this->objTemplate->setVariable('TXT_DOWNLOADS_ALL_DOWNLOADS', $_ARRAYLANG['TXT_DOWNLOADS_ALL_DOWNLOADS']);
     }
     if ($downloadsAvailable) {
         $this->objTemplate->setVariable(array('DOWNLOADS_CONFIRM_UNLINK_DOWNLOADS_TXT' => preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_DOWNLOADS_CONFIRM_UNLINK_DOWNLOADS'])), 'TXT_SAVE_CHANGES_DOWNLOADS' => $_ARRAYLANG['TXT_SAVE_CHANGES'], 'TXT_DOWNLOADS_CHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_CHECK_ALL'], 'TXT_DOWNLOADS_UNCHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_UNCHECK_ALL'], 'TXT_DOWNLOADS_SELECT_ACTION' => $_ARRAYLANG['TXT_DOWNLOADS_SELECT_ACTION'], 'TXT_DOWNLOADS_ORDER' => $_ARRAYLANG['TXT_DOWNLOADS_ORDER'], 'TXT_DOWNLOADS_UNLINK_MULTI' => $_ARRAYLANG['TXT_DOWNLOADS_UNLINK_MULTI']));
         $this->objTemplate->setVariable(array('TXT_DOWNLOADS_OWNER' => $_ARRAYLANG['TXT_DOWNLOADS_OWNER'], 'TXT_DOWNLOADS_FUNCTIONS' => $_ARRAYLANG['TXT_DOWNLOADS_FUNCTIONS'], 'DOWNLOADS_DOWNLOAD_CATEGORY_ID' => $objCategory->getId(), 'DOWNLOADS_DOWNLOAD_SORT_DIRECTION' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_SORT_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_SORT_ID' => $downloadOrderBy == 'id' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_STATUS' => $downloadOrderBy == 'is_active' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_ORDER' => $downloadOrderBy == 'order' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_NAME' => $downloadOrderBy == 'name' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_DESCRIPTION' => $downloadOrderBy == 'description' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_DOWNLOADED' => $downloadOrderBy == 'download_count' && $downloadOrderDirection == 'desc' ? 'asc' : 'desc', 'DOWNLOADS_DOWNLOAD_SORT_VIEWED' => $downloadOrderBy == 'views' && $downloadOrderDirection == 'desc' ? 'asc' : 'desc', 'DOWNLOADS_DOWNLOAD_SORT_ID_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_ID'] . ($downloadOrderBy == 'id' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_STATUS_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_STATUS'] . ($downloadOrderBy == 'is_active' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_ORDER_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_ORDER'] . ($downloadOrderBy == 'order' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_NAME_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_NAME'] . ($downloadOrderBy == 'name' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_DESCRIPTION_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_DESCRIPTION'] . ($downloadOrderBy == 'description' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_DOWNLOADED_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADED'] . ($downloadOrderBy == 'download_count' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_VIEWED_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_VIEWED'] . ($downloadOrderBy == 'views' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset));
         // parse paging
         $downloadCount = $objDownload->getFilteredSearchDownloadCount();
         if ($downloadCount > $_CONFIG['corePagingLimit']) {
             $pagingLink = "&cmd=Downloads&act=categories&parent_id=" . $objCategory->getId() . "&category_sort=" . htmlspecialchars($categoryOrderDirection) . "&category_by=" . htmlspecialchars($categoryOrderBy) . "&download_sort=" . htmlspecialchars($downloadOrderDirection) . "&download_by=" . htmlspecialchars($downloadOrderBy) . "&category_pos=" . $categoryLimitOffset;
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_PAGING', getPaging($downloadCount, $downloadLimitOffset, $pagingLink, "<b>" . $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADS'] . "</b>") . '<br />');
         }
         $this->objTemplate->hideBlock('downloads_no_data');
         $this->objTemplate->parse('downloads_category_downloads');
         $this->objTemplate->parse('downloads_download_action_dropdown');
     } else {
         $this->objTemplate->hideBlock('downloads_category_downloads');
         $this->objTemplate->hideBlock('downloads_download_action_dropdown');
         $this->objTemplate->parse('downloads_no_data');
     }
 }
예제 #14
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;
 }
예제 #15
0
 /**
  * Set up the detail view of the selected order
  * @access  public
  * @param   \Cx\Core\Html\Sigma $objTemplate    The Template, by reference
  * @param   boolean             $edit           Edit if true, view otherwise
  * @global  ADONewConnection    $objDatabase    Database connection object
  * @global  array               $_ARRAYLANG     Language array
  * @return  boolean                             True on success,
  *                                              false otherwise
  * @static
  * @author  Reto Kohli <*****@*****.**> (parts)
  * @version 3.1.0
  */
 static function view_detail(&$objTemplate = null, $edit = false)
 {
     global $objDatabase, $_ARRAYLANG, $objInit;
     $backend = $objInit->mode == 'backend';
     if ($objTemplate->blockExists('order_list')) {
         $objTemplate->hideBlock('order_list');
     }
     $have_option = false;
     // The order total -- in the currency chosen by the customer
     $order_sum = 0;
     // recalculated VAT total
     $total_vat_amount = 0;
     $order_id = intval($_REQUEST['order_id']);
     if (!$order_id) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_INVALID_ORDER_ID']);
     }
     if (!$objTemplate) {
         $template_name = $edit ? 'module_shop_order_edit.html' : 'module_shop_order_details.html';
         $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($template_name);
         //DBG::log("Orders::view_list(): loaded Template: ".$objTemplate->get());
     }
     $objOrder = Order::getById($order_id);
     if (!$objOrder) {
         //DBG::log("Shop::shopShowOrderdetails(): Failed to find Order ID $order_id");
         return \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ORDER_NOT_FOUND'], $order_id));
     }
     // lsv data
     $query = "\n            SELECT `holder`, `bank`, `blz`\n              FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_lsv\n             WHERE order_id={$order_id}";
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return self::errorHandler();
     }
     if ($objResult->RecordCount() == 1) {
         $objTemplate->setVariable(array('SHOP_ACCOUNT_HOLDER' => contrexx_raw2xhtml($objResult->fields['holder']), 'SHOP_ACCOUNT_BANK' => contrexx_raw2xhtml($objResult->fields['bank']), 'SHOP_ACCOUNT_BLZ' => contrexx_raw2xhtml($objResult->fields['blz'])));
     }
     $customer_id = $objOrder->customer_id();
     if (!$customer_id) {
         //DBG::log("Shop::shopShowOrderdetails(): Invalid Customer ID $customer_id");
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_INVALID_CUSTOMER_ID'], $customer_id));
     }
     $objCustomer = Customer::getById($customer_id);
     if (!$objCustomer) {
         //DBG::log("Shop::shopShowOrderdetails(): Failed to find Customer ID $customer_id");
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_CUSTOMER_NOT_FOUND'], $customer_id));
         $objCustomer = new Customer();
         // No editing allowed!
         $have_option = true;
     }
     Vat::is_reseller($objCustomer->is_reseller());
     Vat::is_home_country(\Cx\Core\Setting\Controller\Setting::getValue('country_id', 'Shop') == $objOrder->country_id());
     $objTemplate->setGlobalVariable($_ARRAYLANG + array('SHOP_CURRENCY' => Currency::getCurrencySymbolById($objOrder->currency_id())));
     //DBG::log("Order sum: ".Currency::formatPrice($objOrder->sum()));
     $objTemplate->setVariable(array('SHOP_CUSTOMER_ID' => $customer_id, 'SHOP_ORDERID' => $order_id, 'SHOP_DATE' => date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME, strtotime($objOrder->date_time())), 'SHOP_ORDER_STATUS' => $edit ? Orders::getStatusMenu($objOrder->status(), false, null, 'swapSendToStatus(this.value)') : $_ARRAYLANG['TXT_SHOP_ORDER_STATUS_' . $objOrder->status()], 'SHOP_SEND_MAIL_STYLE' => $objOrder->status() == Order::STATUS_CONFIRMED ? 'display: inline;' : 'display: none;', 'SHOP_SEND_MAIL_STATUS' => $edit ? $objOrder->status() != Order::STATUS_CONFIRMED ? \Html::ATTRIBUTE_CHECKED : '' : '', 'SHOP_ORDER_SUM' => Currency::formatPrice($objOrder->sum()), 'SHOP_DEFAULT_CURRENCY' => Currency::getDefaultCurrencySymbol(), 'SHOP_GENDER' => $edit ? Customer::getGenderMenu($objOrder->billing_gender(), 'billing_gender') : $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->billing_gender())], 'SHOP_COMPANY' => $objOrder->billing_company(), 'SHOP_FIRSTNAME' => $objOrder->billing_firstname(), 'SHOP_LASTNAME' => $objOrder->billing_lastname(), 'SHOP_ADDRESS' => $objOrder->billing_address(), 'SHOP_ZIP' => $objOrder->billing_zip(), 'SHOP_CITY' => $objOrder->billing_city(), 'SHOP_COUNTRY' => $edit ? \Cx\Core\Country\Controller\Country::getMenu('billing_country_id', $objOrder->billing_country_id()) : \Cx\Core\Country\Controller\Country::getNameById($objOrder->billing_country_id()), 'SHOP_PHONE' => $objOrder->billing_phone(), 'SHOP_FAX' => $objOrder->billing_fax(), 'SHOP_EMAIL' => $objOrder->billing_email(), 'SHOP_SHIP_GENDER' => $edit ? Customer::getGenderMenu($objOrder->gender(), 'shipPrefix') : $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->gender())], 'SHOP_SHIP_COMPANY' => $objOrder->company(), 'SHOP_SHIP_FIRSTNAME' => $objOrder->firstname(), 'SHOP_SHIP_LASTNAME' => $objOrder->lastname(), 'SHOP_SHIP_ADDRESS' => $objOrder->address(), 'SHOP_SHIP_ZIP' => $objOrder->zip(), 'SHOP_SHIP_CITY' => $objOrder->city(), 'SHOP_SHIP_COUNTRY' => $edit ? \Cx\Core\Country\Controller\Country::getMenu('shipCountry', $objOrder->country_id()) : \Cx\Core\Country\Controller\Country::getNameById($objOrder->country_id()), 'SHOP_SHIP_PHONE' => $objOrder->phone(), 'SHOP_PAYMENTTYPE' => Payment::getProperty($objOrder->payment_id(), 'name'), 'SHOP_CUSTOMER_NOTE' => $objOrder->note(), 'SHOP_COMPANY_NOTE' => $objCustomer->companynote(), 'SHOP_SHIPPING_TYPE' => $objOrder->shipment_id() ? Shipment::getShipperName($objOrder->shipment_id()) : '&nbsp;'));
     if ($backend) {
         $objTemplate->setVariable(array('SHOP_CUSTOMER_IP' => $objOrder->ip() ? '<a href="index.php?cmd=NetTools&amp;tpl=whois&amp;address=' . $objOrder->ip() . '" title="' . $_ARRAYLANG['TXT_SHOW_DETAILS'] . '">' . $objOrder->ip() . '</a>' : '&nbsp;', 'SHOP_CUSTOMER_HOST' => $objOrder->host() ? '<a href="index.php?cmd=NetTools&amp;tpl=whois&amp;address=' . $objOrder->host() . '" title="' . $_ARRAYLANG['TXT_SHOW_DETAILS'] . '">' . $objOrder->host() . '</a>' : '&nbsp;', 'SHOP_CUSTOMER_LANG' => \FWLanguage::getLanguageParameter($objOrder->lang_id(), 'name'), 'SHOP_CUSTOMER_BROWSER' => $objOrder->browser() ? $objOrder->browser() : '&nbsp;', 'SHOP_LAST_MODIFIED' => $objOrder->modified_on() && $objOrder->modified_on() != '0000-00-00 00:00:00' ? $objOrder->modified_on() . '&nbsp;' . $_ARRAYLANG['TXT_EDITED_BY'] . '&nbsp;' . $objOrder->modified_by() : $_ARRAYLANG['TXT_ORDER_WASNT_YET_EDITED']));
     } else {
         // Frontend: Order history ONLY.  Repeat the Order, go to cart
         $objTemplate->setVariable(array('SHOP_ACTION_URI_ENCODED' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'cart')));
     }
     $ppName = '';
     $psp_id = Payment::getPaymentProcessorId($objOrder->payment_id());
     if ($psp_id) {
         $ppName = PaymentProcessing::getPaymentProcessorName($psp_id);
     }
     $objTemplate->setVariable(array('SHOP_SHIPPING_PRICE' => $objOrder->shipment_amount(), 'SHOP_PAYMENT_PRICE' => $objOrder->payment_amount(), 'SHOP_PAYMENT_HANDLER' => $ppName, 'SHOP_LAST_MODIFIED_DATE' => $objOrder->modified_on()));
     if ($edit) {
         // edit order
         $strJsArrShipment = Shipment::getJSArrays();
         $objTemplate->setVariable(array('SHOP_SEND_TEMPLATE_TO_CUSTOMER' => sprintf($_ARRAYLANG['TXT_SEND_TEMPLATE_TO_CUSTOMER'], $_ARRAYLANG['TXT_ORDER_COMPLETE']), 'SHOP_SHIPPING_TYP_MENU' => Shipment::getShipperMenu($objOrder->country_id(), $objOrder->shipment_id(), "calcPrice(0);"), 'SHOP_JS_ARR_SHIPMENT' => $strJsArrShipment, 'SHOP_PRODUCT_IDS_MENU_NEW' => Products::getMenuoptions(null, null, $_ARRAYLANG['TXT_SHOP_PRODUCT_MENU_FORMAT']), 'SHOP_JS_ARR_PRODUCT' => Products::getJavascriptArray($objCustomer->group_id(), $objCustomer->is_reseller())));
     }
     $options = $objOrder->getOptionArray();
     if (!empty($options[$order_id])) {
         $have_option = true;
     }
     // Order items
     $total_weight = $i = 0;
     $total_net_price = $objOrder->view_items($objTemplate, $edit, $total_weight, $i);
     // Show VAT with the individual products:
     // If VAT is enabled, and we're both in the same country
     // ($total_vat_amount has been set above if both conditions are met)
     // show the VAT rate.
     // If there is no VAT, the amount is 0 (zero).
     //if ($total_vat_amount) {
     // distinguish between included VAT, and additional VAT added to sum
     $tax_part_percentaged = Vat::isIncluded() ? $_ARRAYLANG['TXT_TAX_PREFIX_INCL'] : $_ARRAYLANG['TXT_TAX_PREFIX_EXCL'];
     $objTemplate->setVariable(array('SHOP_TAX_PRICE' => Currency::formatPrice($total_vat_amount), 'SHOP_PART_TAX_PROCENTUAL' => $tax_part_percentaged));
     //} else {
     // No VAT otherwise
     // remove it from the details overview if empty
     //$objTemplate->hideBlock('taxprice');
     //$tax_part_percentaged = $_ARRAYLANG['TXT_NO_TAX'];
     //}
     // Parse Coupon if applicable to this product
     // Coupon
     $objCoupon = Coupon::getByOrderId($order_id);
     if ($objCoupon) {
         $discount = $objCoupon->discount_amount() != 0 ? $objCoupon->discount_amount() : $total_net_price / 100 * $objCoupon->discount_rate();
         $objTemplate->setVariable(array('SHOP_COUPON_NAME' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE'], 'SHOP_COUPON_CODE' => $objCoupon->code(), 'SHOP_COUPON_AMOUNT' => Currency::formatPrice(-$discount)));
         $total_net_price -= $discount;
         //DBG::log("Order::view_detail(): Coupon: ".var_export($objCoupon, true));
     }
     $objTemplate->setVariable(array('SHOP_ROWCLASS_NEW' => 'row' . (++$i % 2 + 1), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString($total_weight), 'SHOP_NET_PRICE' => Currency::formatPrice($total_net_price)));
     $objTemplate->setVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_TAX_RATE' => Vat::isIncluded() ? $_ARRAYLANG['TXT_TAX_PREFIX_INCL'] : $_ARRAYLANG['TXT_TAX_PREFIX_EXCL'], 'TXT_SHOP_ACCOUNT_VALIDITY' => $_ARRAYLANG['TXT_SHOP_VALIDITY']));
     // Disable the "edit" button when there are Attributes
     if ($backend && !$edit) {
         if ($have_option) {
             if ($objTemplate->blockExists('order_no_edit')) {
                 $objTemplate->touchBlock('order_no_edit');
             }
         } else {
             if ($objTemplate->blockExists('order_edit')) {
                 $objTemplate->touchBlock('order_edit');
             }
         }
     }
     return true;
 }
예제 #16
0
 /**
  * Import and Export data from/to csv
  * @author  Reto Kohli <*****@*****.**> (parts)
  */
 function _import()
 {
     global $_ARRAYLANG, $objDatabase;
     self::$pageTitle = $_ARRAYLANG['TXT_SHOP_IMPORT_TITLE'];
     self::$objTemplate->loadTemplateFile('module_shop_import.html');
     self::$objTemplate->setGlobalVariable(array('TXT_SHOP_IMPORT_CATEGORIES_TIPS' => contrexx_raw2xhtml($_ARRAYLANG['TXT_SHOP_IMPORT_CATEGORIES_TIPS']), 'TXT_SHOP_IMPORT_CHOOSE_TEMPLATE_TIPS' => contrexx_raw2xhtml($_ARRAYLANG['TXT_SHOP_IMPORT_CHOOSE_TEMPLATE_TIPS'])));
     $objCSVimport = new CsvImport();
     // Delete template
     if (isset($_REQUEST['deleteImg'])) {
         $query = "\n                DELETE FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_importimg\n                 WHERE img_id=" . $_REQUEST['img'];
         if ($objDatabase->Execute($query)) {
             \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_DELETED']);
         } else {
             \Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_ERROR_DELETE']);
         }
     }
     // Save template
     if (isset($_REQUEST['SaveImg'])) {
         $query = "\n                INSERT INTO " . DBPREFIX . "module_shop" . MODULE_INDEX . "_importimg (\n                    img_name, img_cats, img_fields_file, img_fields_db\n                ) VALUES (\n                    '" . $_REQUEST['ImgName'] . "',\n                    '" . $_REQUEST['category'] . "',\n                    '" . $_REQUEST['pairs_left_keys'] . "',\n                    '" . $_REQUEST['pairs_right_keys'] . "'\n                )";
         if ($objDatabase->Execute($query)) {
             \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_SAVED']);
         } else {
             \Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_ERROR_SAVE']);
         }
     }
     $objCSVimport->initTemplateArray();
     $fileExists = false;
     $fileName = isset($_POST['csvFile']) ? contrexx_input2raw($_POST['csvFile']) : '';
     $uploaderId = isset($_POST['importCsvUploaderId']) ? contrexx_input2raw($_POST['importCsvUploaderId']) : '';
     if (!empty($fileName) && !empty($uploaderId)) {
         $objSession = \cmsSession::getInstance();
         $tmpFile = $objSession->getTempPath() . '/' . $uploaderId . '/' . $fileName;
         $fileExists = \Cx\Lib\FileSystem\FileSystem::exists($tmpFile);
     }
     // Import Categories
     // This is not subject to change, so it's hardcoded
     if (isset($_REQUEST['ImportCategories']) && $fileExists) {
         // delete existing categories on request only!
         // mind that this necessarily also clears all products and
         // their associated attributes!
         if (!empty($_POST['clearCategories'])) {
             Products::deleteByShopCategory(0, false, true);
             ShopCategories::deleteAll();
             // NOTE: Removing Attributes is now disabled.  Optionally enable this.
             //                Attributes::deleteAll();
         }
         $objCsv = new CsvBv($tmpFile);
         $importedLines = 0;
         $arrCategoryLevel = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
         $line = $objCsv->NextLine();
         while ($line) {
             $level = 0;
             foreach ($line as $catName) {
                 ++$level;
                 if (!empty($catName)) {
                     $parentCatId = $objCSVimport->getCategoryId($catName, $arrCategoryLevel[$level - 1]);
                     $arrCategoryLevel[$level] = $parentCatId;
                 }
             }
             ++$importedLines;
             $line = $objCsv->NextLine();
         }
         \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_IMPORTED_CATEGORIES'] . ': ' . $importedLines);
     }
     // Import
     if (isset($_REQUEST['importFileProducts']) && $fileExists) {
         if (isset($_POST['clearProducts']) && $_POST['clearProducts']) {
             Products::deleteByShopCategory(0, false, true);
             // The categories need not be removed, but it is done by design!
             ShopCategories::deleteAll();
             // NOTE: Removing Attributes is now disabled.  Optionally enable this.
             //                Attributes::deleteAll();
         }
         $arrFileContent = $objCSVimport->GetFileContent($tmpFile);
         $query = '
             SELECT img_id, img_name, img_cats, img_fields_file, img_fields_db
               FROM ' . DBPREFIX . 'module_shop' . MODULE_INDEX . '_importimg
              WHERE img_id=' . $_REQUEST['ImportImage'];
         $objResult = $objDatabase->Execute($query);
         $arrCategoryName = preg_split('/;/', $objResult->fields['img_cats'], null, PREG_SPLIT_NO_EMPTY);
         $arrFirstLine = $arrFileContent[0];
         $arrCategoryColumnIndex = array();
         for ($x = 0; $x < count($arrCategoryName); ++$x) {
             foreach ($arrFirstLine as $index => $strColumnName) {
                 if ($strColumnName == $arrCategoryName[$x]) {
                     $arrCategoryColumnIndex[] = $index;
                 }
             }
         }
         $arrTemplateFieldName = preg_split('/;/', $objResult->fields['img_fields_file'], null, PREG_SPLIT_NO_EMPTY);
         $arrDatabaseFieldIndex = array();
         for ($x = 0; $x < count($arrTemplateFieldName); ++$x) {
             foreach ($arrFirstLine as $index => $strColumnName) {
                 if ($strColumnName == $arrTemplateFieldName[$x]) {
                     $arrDatabaseFieldIndex[] = $index;
                 }
             }
         }
         $arrProductFieldName = preg_split('/;/', $objResult->fields['img_fields_db'], null, PREG_SPLIT_NO_EMPTY);
         $arrProductDatabaseFieldName = array();
         for ($x = 0; $x < count($arrProductFieldName); ++$x) {
             $dbname = $objCSVimport->DBfieldsName($arrProductFieldName[$x]);
             $arrProductDatabaseFieldName[$dbname] = (isset($arrProductDatabaseFieldName[$dbname]) ? $arrProductDatabaseFieldName[$dbname] . ';' : '') . $x;
         }
         $importedLines = 0;
         $errorLines = 0;
         // Array of IDs of newly inserted records
         $arrId = array();
         for ($x = 1; $x < count($arrFileContent); ++$x) {
             $category_id = false;
             for ($cat = 0; $cat < count($arrCategoryColumnIndex); ++$cat) {
                 $catName = $arrFileContent[$x][$arrCategoryColumnIndex[$cat]];
                 if (empty($catName) && !empty($category_id)) {
                     break;
                 }
                 if (empty($catName)) {
                     $category_id = $objCSVimport->GetFirstCat();
                 } else {
                     $category_id = $objCSVimport->getCategoryId($catName, $category_id);
                 }
             }
             if ($category_id == 0) {
                 $category_id = $objCSVimport->GetFirstCat();
             }
             $objProduct = new Product('', $category_id, '', Distribution::TYPE_DELIVERY, 0, 1, 0, 0, 0);
             foreach ($arrProductDatabaseFieldName as $index => $strFieldIndex) {
                 $value = '';
                 if (strpos($strFieldIndex, ';')) {
                     $prod2line = explode(';', $strFieldIndex);
                     for ($z = 0; $z < count($prod2line); ++$z) {
                         $value .= $arrFileContent[$x][$arrDatabaseFieldIndex[$prod2line[$z]]] . '<br />';
                     }
                 } else {
                     $value = $arrFileContent[$x][$arrDatabaseFieldIndex[$strFieldIndex]];
                 }
                 $objProduct->{$index}($value);
             }
             if ($objProduct->store()) {
                 $arrId[] = $objProduct->id();
                 ++$importedLines;
             } else {
                 ++$errorLines;
             }
         }
         // Fix picture field and create thumbnails
         Products::makeThumbnailsById($arrId);
         if ($importedLines) {
             \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_IMPORTED_PRODUCTS'] . ': ' . $importedLines);
         }
         if ($errorLines) {
             \Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_NOT_SUCCESSFULLY_IMPORTED_PRODUCTS'] . ': ' . $errorLines);
         }
     }
     // end import
     $jsnofiles = '';
     $fileFields = $dblist = null;
     $arrTemplateArray = $objCSVimport->getTemplateArray();
     if (isset($_REQUEST['mode']) && $_REQUEST['mode'] != 'ImportImg') {
         if (count($arrTemplateArray) == 0) {
             self::$objTemplate->hideBlock('import_products');
             self::$objTemplate->touchBlock('import_products_no_template');
         } else {
             $imageChoice = $objCSVimport->GetImageChoice();
             self::$objTemplate->setVariable(array('IMAGE_CHOICE' => $imageChoice));
         }
     } else {
         if (!isset($_REQUEST['SelectFields'])) {
             $jsnofiles = "selectTab('import1');";
         } else {
             if (isset($_POST['mode']) && $_POST['csvFile'] == '') {
                 $jsnofiles = "selectTab('import4');";
             } else {
                 $jsnofiles = "selectTab('import2');";
                 if ($fileExists) {
                     $fileFields = '
                         <select name="FileFields" id="file_field" style="width: 200px;" size="10">
                             ' . $objCSVimport->getFilefieldMenuOptions($tmpFile) . '
                         </select>' . "\n";
                 }
                 $dblist = '
                     <select name="DbFields" id="given_field" style="width: 200px;" size="10">
                         ' . $objCSVimport->getAvailableNamesMenuOptions() . '
                     </select>' . "\n";
             }
         }
     }
     $jsSelectLayer = 'selectTab("import1");';
     if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'ImportImg') {
         $jsSelectLayer = 'selectTab("import2");';
     }
     $arrTemplateArray = $objCSVimport->getTemplateArray();
     if ($arrTemplateArray) {
         $arrName = $objCSVimport->getNameArray();
         self::$objTemplate->setVariable('SHOP_IMPORT_TEMPLATE_MENU', \Html::getSelect('ImportImage', $arrName));
     } else {
         self::$objTemplate->touchBlock('import_products_no_template');
     }
     for ($x = 0; $x < count($arrTemplateArray); ++$x) {
         self::$objTemplate->setVariable(array('IMG_NAME' => $arrTemplateArray[$x]['name'], 'IMG_ID' => $arrTemplateArray[$x]['id'], 'CLASS_NAME' => 'row' . ($x % 2 + 1), 'SHOP_CMS_OFFSET' => \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath()));
         self::$objTemplate->parse('imgRow');
     }
     //initialize the uploader
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     //create an uploader
     $uploader->setCallback('importUploaderCallback');
     $uploader->setOptions(array('id' => 'importCsvUploader', 'allowed-extensions' => array('csv', 'xls'), 'data-upload-limit' => 1, 'style' => 'display:none'));
     self::$objTemplate->setVariable(array('SELECT_LAYER_ONLOAD' => $jsSelectLayer, 'NO_FILES' => isset($jsnofiles) ? $jsnofiles : '', 'FILE_FIELDS_LIST' => isset($fileFields) ? $fileFields : '', 'DB_FIELDS_LIST' => isset($dblist) ? $dblist : '', 'SHOP_IMPORT_CSV_UPLOADER_CODE' => $uploader->getXHtml(), 'SHOP_IMPORT_CSV_UPLOADER_ID' => $uploader->getId()));
     // TODO: !!! CSV EXPORT IS OBSOLETE AND DYSFUNCT !!!
     /*
             // Export groups -- hardcoded
             $content_location = '';
             if (isset($_REQUEST['group'])) {
                 $query = $fieldNames = $content_location = '';
                 $arrPictures = null;
                 switch ($_REQUEST['group']) {
                     // products - plain fields:
                     case 'tproduct':
                         $content_location = "ProdukteTabelle.csv";
                         $fieldNames = array(
                             'id', 'product_id', 'picture', 'title', 'catid', 'distribution',
                             'normalprice', 'resellerprice', 'short', 'long',
                             'stock', 'stock_visible', 'discountprice', 'discount_active',
                             'active', 'b2b', 'b2c', 'date_start', 'date_end',
                             'manufacturer', 'manufacturer_url', 'external_link',
                             'ord', 'vat_id', 'weight',
                             'flags', 'group_id', 'article_id', 'keywords', );
                         $query = "
                             SELECT id, product_id, picture, title, catid, distribution,
                                    normalprice, resellerprice, short, long,
                                    stock, stock_visible, discountprice, discount_active,
                                    active, b2b, b2c, date_start, date_end,
                                    manufacturer, manufacturer_url, external_link,
                                    sort_order, vat_id, weight,
                                    flags, group_id, article_id, keywords
                               FROM ".DBPREFIX."module_shop_products
                              ORDER BY id ASC";
                         break;
                     // products - custom:
                     case 'rproduct':
                         $content_location = "ProdukteRelationen.csv";
                         $fieldNames = array(
                             'id', 'product_id', 'picture', 'title',
                             'catid', 'category', 'parentcategory', 'distribution',
                             'normalprice', 'resellerprice', 'discountprice', 'discount_active',
                             'short', 'long',
                             'stock', 'stock_visible',
                             'active', 'b2b', 'b2c',
                             'date_start', 'date_end',
                             'manufacturer_name', 'manufacturer_website',
                             'manufacturer_url', 'external_link',
                             'ord',
                             'vat_percent', 'weight',
                             'discount_group', 'article_group', 'keywords', );
                         // c1.catid *MUST NOT* be NULL
                         // c2.catid *MAY* be NULL (if c1.catid is root)
                         // vat_id *MAY* be NULL
                         $query = "
                             SELECT p.id, p.product_id, p.picture, p.title,
                                    p.catid, c1.catname as category, c2.catname as parentcategory, p.distribution,
                                    p.normalprice, p.resellerprice, p.discountprice, p.discount_active,
                                    p.short, p.long, p.stock, p.stock_visible,
                                    p.active, p.b2b, p.b2c, p.date_start, p.date_end,
                                    m.name as manufacturer_name,
                                    m.url as manufacturer_website,
                                    p.manufacturer_url, p.external_link,
                                    p.ord,
                                    v.percent as vat_percent, p.weight,
                                    d.name AS discount_group,
                                    a.name AS article_group,
                                    p.keywords
                               FROM ".DBPREFIX."module_shop_products p
                              INNER JOIN ".DBPREFIX."module_shop_categories c1 ON p.catid=c1.catid
                               LEFT JOIN ".DBPREFIX."module_shop_categories c2 ON c1.parentid=c2.catid
                               LEFT JOIN ".DBPREFIX."module_shop_vat v ON vat_id=v.id
                               LEFT JOIN ".DBPREFIX."module_shop_manufacturer as m ON m.id = p.manufacturer
                               LEFT JOIN ".DBPREFIX."module_shop_discountgroup_count_name as d ON d.id = p.group_id
                               LEFT JOIN ".DBPREFIX."module_shop_article_group as a ON a.id = p.article_id
                              ORDER BY catid ASC, product_id ASC";
                         break;
                     // customer - plain fields:
     // TODO: Use Customer class!
                     case 'tcustomer':
                         $content_location = "KundenTabelle.csv";
                         $fieldNames = array(
                             'customerid', 'username', 'password', 'prefix', 'company', 'firstname', 'lastname',
                             'address', 'city', 'zip', 'country_id', 'phone', 'fax', 'email',
                             'ccnumber', 'ccdate', 'ccname', 'cvc_code', 'company_note',
                             'is_reseller', 'register_date', 'customer_status', 'group_id', );
                         $query = "
                             SELECT customerid, username, password, prefix, company, firstname, lastname,
                                    address, city, zip, country_id, phone, fax, email,
                                    ccnumber, ccdate, ccname, cvc_code, company_note,
                                    is_reseller, register_date, customer_status,
                                    group_id
                               FROM ".DBPREFIX."module_shop_customers
                              ORDER BY lastname ASC, firstname ASC";
                         break;
                     // customer - custom:
     // TODO: Use Customer class!
                     case 'rcustomer':
                         $content_location = "KundenRelationen.csv";
                         $fieldNames = array(
                             'customerid', 'username', 'firstname', 'lastname', 'prefix', 'company',
                             'address', 'zip', 'city', 'countries_name',
                             'phone', 'fax', 'email', 'is_reseller', 'register_date', 'group_name', );
                         $query = "
                             SELECT c.customerid, c.username, c.firstname, c.lastname, c.prefix, c.company,
                                    c.address, c.zip, c.city, n.countries_name,
                                    c.phone, c.fax, c.email, c.is_reseller, c.register_date,
                                    d.name AS group_name
                               FROM ".DBPREFIX."module_shop_customers c
                              INNER JOIN ".DBPREFIX."module_shop_countries n ON c.country_id=n.countries_id
                               LEFT JOIN ".DBPREFIX."module_shop_customer_group d ON c.group_id=d.id
                              ORDER BY c.lastname ASC, c.firstname ASC";
                         break;
                     // orders - plain fields:
                     case 'torder':
                         $content_location = "BestellungenTabelle.csv";
                         $fieldNames = array(
                             'id', 'customer_id', 'currency_id', 'order_sum', 'sum',
                             'date_time', 'status', 'ship_prefix', 'ship_company', 'ship_firstname', 'ship_lastname',
                             'ship_address', 'ship_city', 'ship_zip', 'ship_country_id', 'ship_phone',
                             'vat_amount', 'currency_ship_price', 'shipment_id', 'payment_id', 'currency_payment_price',
                             'ip', 'host', 'lang_id', 'browser', 'note',
                             'last_modified', 'modified_by');
                         $query = "
                             SELECT id, customer_id, currency_id, order_sum, sum,
                                    date_time, status, ship_prefix, ship_company, ship_firstname, ship_lastname,
                                    ship_address, ship_city, ship_zip, ship_country_id, ship_phone,
                                    vat_amount, currency_ship_price, shipment_id, payment_id, currency_payment_price,
                                    ip, host, lang_id, browser, note,
                                    last_modified, modified_by
                               FROM ".DBPREFIX."module_shop".MODULE_INDEX."_orders
                              ORDER BY id ASC";
                         break;
                     // orders - custom:
                     case 'rorder':
     // TODO: Use Customer class!
                         $content_location = "BestellungenRelationen.csv";
                         $fieldNames = array(
                             'id', 'order_sum', 'vat_amount', 'currency_ship_price', 'currency_payment_price',
                             'sum', 'date_time', 'status', 'ship_prefix', 'ship_company',
                             'ship_firstname', 'ship_lastname', 'ship_address', 'ship_city', 'ship_zip',
                             'ship_phone', 'note',
                             'customer_id', 'username', 'firstname', 'lastname', 'prefix', 'company',
                             'address', 'zip', 'city', 'countries_name',
                             'phone', 'fax', 'email', 'is_reseller', 'register_date',
                             'currency_code', 'shipper_name', 'payment_name',
                             'account_number', 'bank_name', 'bank_code');
                         $query = "
                             SELECT o.id, o.order_sum, o.vat_amount, o.currency_ship_price, o.currency_payment_price,
                                    o.sum, o.date_time, o.status, o.ship_prefix, o.ship_company,
                                    o.ship_firstname, o.ship_lastname, o.ship_address, o.ship_city, o.ship_zip,
                                    o.ship_phone, o.note,
                                    o.customer_id,
                                    c.username, c.firstname, c.lastname, c.prefix, c.company,
                                    c.address, c.zip, c.city, n.countries_name,
                                    c.phone, c.fax, c.email, c.is_reseller, c.register_date,
                                    u.code AS currency_code, s.name AS shipper_name, p.name AS payment_name,
                                    l.holder, l.bank, l.blz
                               FROM ".DBPREFIX."module_shop_orders o
                              INNER JOIN ".DBPREFIX."module_shop_customers c ON o.customer_id=c.customerid
                              INNER JOIN ".DBPREFIX."module_shop_countries n ON c.country_id=n.countries_id
                              INNER JOIN ".DBPREFIX."module_shop_currencies u ON o.currency_id=u.id
                               LEFT JOIN ".DBPREFIX."module_shop_shipper s ON o.shipment_id=s.id
                               LEFT JOIN ".DBPREFIX."module_shop_payment p ON o.payment_id=p.id
                               LEFT JOIN ".DBPREFIX."module_shop_lsv l ON o.id=l.order_id
                              ORDER BY o.id ASC";
                         break;
                 } // switch
     
                 if ($query && $objResult = $objDatabase->Execute($query)) {
                     // field names
                     $fileContent = '"'.join('";"', $fieldNames)."\"\n";
                     while (!$objResult->EOF) {
                         $arrRow = $objResult->FetchRow();
                         $arrReplaced = array();
                         // Decode the pictures
                         foreach ($arrRow as $index => $field) {
                             if ($index == 'picture') {
                                 $arrPictures = Products::get_image_array_from_base64($field);
                                 $field =
                                     'http://'.
                                     $_SERVER['HTTP_HOST'].'/'.
                                     ASCMS_SHOP_IMAGES_WEB_PATH.'/'.
                                     $arrPictures[1]['img'];
                             }
                             $arrReplaced[] = str_replace('"', '""', $field);
                         }
                         $fileContent .= '"'.join('";"', $arrReplaced)."\"\n";
                     }
                     // Test the output for UTF8!
                     if (strtoupper(CONTREXX_CHARSET) == 'UTF-8') {
                         $fileContent = utf8_decode($fileContent);
                     }
     // TODO: Add success message?
                     // set content to filename and -type for download
                     header("Content-Disposition: inline; filename=$content_location");
                     header("Content-Type: text/comma-separated-values");
                     echo($fileContent);
                     exit();
                 }
                 \Message::error($_ARRAYLANG['TXT_SHOP_EXPORT_ERROR']);
             } else {
                 // can't submit without a group selection
             } // if/else group
             // end export
     
             // make sure that language entries exist for all of
             // TXT_SHOP_EXPORT_GROUP_*, TXT_SHOP_EXPORT_GROUP_*_TIP !!
             $arrGroups = array('tproduct', 'rproduct', 'tcustomer', 'rcustomer', 'torder', 'rorder');
             $tipText = '';
             for ($i = 0; $i < count($arrGroups); ++$i) {
                 self::$objTemplate->setCurrentBlock('groupRow');
                 self::$objTemplate->setVariable(array(
                     'SHOP_EXPORT_GROUP' => $_ARRAYLANG['TXT_SHOP_EXPORT_GROUP_'.strtoupper($arrGroups[$i])],
                     'SHOP_EXPORT_GROUP_CODE' => $arrGroups[$i],
                     'SHOP_EXPORT_INDEX' => $i,
                     'CLASS_NAME' => 'row'.($i % 2 + 1),
                 ));
                 self::$objTemplate->parse('groupRow');
                 $tipText .= 'Text['.$i.']=["","'.$_ARRAYLANG['TXT_SHOP_EXPORT_GROUP_'.strtoupper($arrGroups[$i]).'_TIP'].'"];';
             }
     */
 }