コード例 #1
0
 function modifyEntry()
 {
     global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID;
     \JS::activate('cx');
     \JS::activate('jqueryui');
     $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_modify_entry.html', true, true);
     $this->pageTitle = $_ARRAYLANG['TXT_MEDIADIR_ENTRIES'];
     //get seting values
     parent::getSettings();
     $intEntryDourationAlways = '';
     $intEntryDourationPeriod = '';
     $intEntryDourationShowPeriod = 'none';
     $intEntryDourationEnd = 0;
     $intEntryDourationStart = 0;
     $strOnSubmit = '';
     if (!empty($_GET['id'])) {
         \Permission::checkAccess(MediaDirectoryAccessIDs::ModifyEntry, 'static');
         $pageTitle = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_EDIT'];
         $intEntryId = intval($_GET['id']);
     } else {
         \Permission::checkAccess(MediaDirectoryAccessIDs::AddEntry, 'static');
         $pageTitle = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_ADD'];
         $intEntryId = null;
     }
     //count forms
     $objForms = new MediaDirectoryForm(null, $this->moduleName);
     $arrActiveForms = array();
     foreach ($objForms->arrForms as $intFormId => $arrForm) {
         if ($arrForm['formActive'] == 1) {
             $arrActiveForms[] = $intFormId;
         }
     }
     $intCountForms = count($arrActiveForms);
     if ($intCountForms > 0) {
         if (intval($intEntryId) == 0 && (empty($_POST['selectedFormId']) && empty($_POST['formId'])) && $intCountForms > 1) {
             $intFormId = null;
             //get form selector
             $objForms->listForms($this->_objTpl, 2, $intFormId);
             //parse blocks
             $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryStatus');
             $this->_objTpl->hideBlock($this->moduleNameLC . 'InputfieldList');
             $this->_objTpl->hideBlock($this->moduleNameLC . 'SpezfieldList');
         } else {
             //save entry data
             if (isset($_POST['submitEntryModfyForm']) && !empty($_POST['formId'])) {
                 $objEntry = new MediaDirectoryEntry($this->moduleName);
                 $intEntryId = intval($_POST['entryId']);
                 $intEntryId = $objEntry->saveEntry($_POST, $intEntryId);
                 if (!empty($_POST['entryId'])) {
                     if ($intEntryId) {
                         $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_EDITED'];
                     } else {
                         $intEntryId = intval($_POST['entryId']);
                         $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_EDITED'];
                     }
                 } else {
                     if ($intEntryId) {
                         $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_ADDED'];
                     } else {
                         $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_ADDED'];
                     }
                 }
             }
             //get form id
             if (intval($intEntryId) != 0) {
                 //get entry data
                 $objEntry = new MediaDirectoryEntry($this->moduleName);
                 $objEntry->getEntries($intEntryId, null, null, null, null, false, false);
                 if (empty($objEntry->arrEntries)) {
                     $objEntry->getEntries($intEntryId, null, null, null, null, true, false);
                 }
                 $intFormId = $objEntry->arrEntries[$intEntryId]['entryFormId'];
             } else {
                 //set form id
                 if ($intCountForms == 1) {
                     $intFormId = intval($arrActiveForms[0]);
                 } else {
                     $intFormId = intval($_POST['selectedFormId']);
                 }
                 if (!empty($_POST['formId'])) {
                     $intFormId = intval($_POST['formId']);
                 }
             }
             //get inputfield object
             $objInputfields = new MediaDirectoryInputfield($intFormId, false, null, $this->moduleName);
             //list inputfields
             $objInputfields->listInputfields($this->_objTpl, 2, $intEntryId);
             //get translation status date
             if ($this->arrSettings['settingsTranslationStatus'] == 1) {
                 $ownerRowClass = "row1";
                 foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                     $strLangStatus = '';
                     if ($intEntryId != 0) {
                         if (in_array($arrLang['id'], $objEntry->arrEntries[$intEntryId]['entryTranslationStatus'])) {
                             $strLangStatus = 'checked="checked"';
                         }
                     }
                     $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_TRANSLATION_LANG_NAME' => htmlspecialchars($arrLang['name'], ENT_QUOTES, CONTREXX_CHARSET), $this->moduleLangVar . '_TRANSLATION_LANG_ID' => intval($arrLang['id']), $this->moduleLangVar . '_TRANSLATION_LANG_STATUS' => $strLangStatus));
                     $this->_objTpl->parse($this->moduleNameLC . 'TranslationLangList');
                 }
                 $this->_objTpl->parse($this->moduleNameLC . 'TranslationStatus');
             } else {
                 $ownerRowClass = "row2";
                 $this->_objTpl->hideBlock($this->moduleNameLC . 'TranslationStatus');
             }
             //get user data
             $objFWUser = \FWUser::getFWUserObject();
             $addedBy = isset($objEntry) ? $objEntry->arrEntries[$intEntryId]['entryAddedBy'] : '';
             if (!empty($addedBy) && ($objUser = $objFWUser->objUser->getUser($addedBy))) {
                 $userId = $objUser->getId();
             } else {
                 $userId = $objFWUser->objUser->getId();
             }
             $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_OWNER' => $_ARRAYLANG['TXT_MEDIADIR_OWNER'], $this->moduleLangVar . '_OWNER_ROW' => $ownerRowClass, $this->moduleLangVar . '_OWNER_ID' => $userId));
             \FWUser::getUserLiveSearch();
             if ($intEntryId != 0) {
                 $intEntryDourationStart = 1;
                 $intEntryDourationEnd = 2;
                 //parse contact data
                 $objUser = $objFWUser->objUser;
                 $intUserId = intval($objUser->getId());
                 $strUserMail = '<a href="mailto:' . contrexx_raw2xhtml($objUser->getEmail()) . '">' . contrexx_raw2xhtml($objUser->getEmail()) . '</a>';
                 $intUserLang = intval($objUser->getFrontendLanguage());
                 if ($objUser = $objUser->getUser($id = $intUserId)) {
                     //get lang
                     foreach ($this->arrFrontendLanguages as $intKey => $arrLang) {
                         if ($arrLang['id'] == $intUserLang) {
                             $strUserLang = $arrLang['name'];
                         }
                     }
                     //get country
                     $arrCountry = \Cx\Core\Country\Controller\Country::getById(intval($objUser->getProfileAttribute('country')));
                     $strCountry = $arrCountry['name'];
                     //get title
                     $objTitle = $objDatabase->Execute("SELECT `title` FROM " . DBPREFIX . "access_user_title WHERE id = '" . intval($objUser->getProfileAttribute('title')) . "' LIMIT 1");
                     $strTitle = $objTitle->fields['title'];
                     $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_CONTACT_DATA' => "Kontaktangaben", $this->moduleLangVar . '_CONTACT_ATTRIBUT_TITLE' => contrexx_raw2xhtml($strTitle), $this->moduleLangVar . '_CONTACT_ATTRIBUT_FIRSTNAME' => contrexx_raw2xhtml($objUser->getProfileAttribute('firstname')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_LASTNAME' => contrexx_raw2xhtml($objUser->getProfileAttribute('lastname')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_COMPANY' => contrexx_raw2xhtml($objUser->getProfileAttribute('company')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_ADRESS' => contrexx_raw2xhtml($objUser->getProfileAttribute('address')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_CITY' => contrexx_raw2xhtml($objUser->getProfileAttribute('city')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_ZIP' => contrexx_raw2xhtml($objUser->getProfileAttribute('zip')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_COUNTRY' => contrexx_raw2xhtml($strCountry), $this->moduleLangVar . '_CONTACT_ATTRIBUT_PHONE' => contrexx_raw2xhtml($objUser->getProfileAttribute('phone_office')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_FAX' => contrexx_raw2xhtml($objUser->getProfileAttribute('phone_fax')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_WEBSITE' => '<a href="' . contrexx_raw2xhtml($objUser->getProfileAttribute('website')) . '" target="_blank">' . contrexx_raw2xhtml($objUser->getProfileAttribute('website')) . '</a>', $this->moduleLangVar . '_CONTACT_ATTRIBUT_MAIL' => $strUserMail, $this->moduleLangVar . '_CONTACT_ATTRIBUT_LANG' => $strUserLang));
                 }
                 $this->_objTpl->parse($this->moduleNameLC . 'ContactData');
             } else {
                 $intEntryDourationStart = 1;
                 $intEntryDourationEnd = 2;
                 $this->_objTpl->hideBlock($this->moduleNameLC . 'ContactData');
             }
             //get display duration  data
             switch ($this->arrSettings['settingsEntryDisplaydurationValueType']) {
                 case 1:
                     $intDiffDay = $this->arrSettings['settingsEntryDisplaydurationValue'];
                     $intDiffMonth = 0;
                     $intDiffYear = 0;
                     break;
                 case 2:
                     $intDiffDay = 0;
                     $intDiffMonth = $this->arrSettings['settingsEntryDisplaydurationValue'];
                     $intDiffYear = 0;
                     break;
                 case 3:
                     $intDiffDay = 0;
                     $intDiffMonth = 0;
                     $intDiffYear = $this->arrSettings['settingsEntryDisplaydurationValue'];
                     break;
             }
             if ($intEntryId != 0) {
                 if (intval($objEntry->arrEntries[$intEntryId]['entryDurationType']) == 1) {
                     $intEntryDourationAlways = 'selected="selected"';
                     $intEntryDourationStart = date("d.m.Y", mktime());
                     $intEntryDourationEnd = date("d.m.Y", mktime(0, 0, 0, date("m") + $intDiffMonth, date("d") + $intDiffDay, date("Y") + $intDiffYear));
                 } else {
                     $intEntryDourationPeriod = 'selected="selected"';
                     $intEntryDourationShowPeriod = 'inline';
                     $intEntryDourationStart = date("d.m.Y", $objEntry->arrEntries[$intEntryId]['entryDurationStart']);
                     $intEntryDourationEnd = date("d.m.Y", $objEntry->arrEntries[$intEntryId]['entryDurationEnd']);
                 }
                 if (intval($objEntry->arrEntries[$intEntryId]['entryDurationNotification']) == 1) {
                     $this->_objTpl->setVariable(array($this->moduleLangVar . '_DISPLAYDURATION_RESET_NOTIFICATION_STATUS' => '<br /><input type="checkbox" name="durationResetNotification" value="1" />&nbsp;' . $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION_RESET_NOTIFICATION_STATUS']));
                 }
             } else {
                 if (intval($this->arrSettings['settingsEntryDisplaydurationType']) == 1) {
                     $intEntryDourationAlways = 'selected="selected"';
                 } else {
                     $intEntryDourationPeriod = 'selected="selected"';
                     $intEntryDourationShowPeriod = 'inline';
                 }
                 $intEntryDourationStart = date("d.m.Y", mktime());
                 $intEntryDourationEnd = date("d.m.Y", mktime(0, 0, 0, date("m") + $intDiffMonth, date("d") + $intDiffDay, date("Y") + $intDiffYear));
             }
             //parse spez fields
             $this->_objTpl->touchBlock($this->moduleNameLC . 'SpezfieldList');
             //generate javascript
             parent::setJavascript($this->getSelectorJavascript());
             parent::setJavascript($objInputfields->getInputfieldJavascript());
             //get form onsubmit
             $strOnSubmit = parent::getFormOnSubmit($objInputfields->arrJavascriptFormOnSubmit);
             $this->_objTpl->setVariable(array($this->moduleLangVar . '_ENTRY_STATUS' => $intEntryId && intval($objEntry->arrEntries[$intEntryId]['entryActive']) ? 'checked="checked"' : '', $this->moduleLangVar . '_MEDIABROWSER_BUTTON' => $this->getMediaBrowserButton($_ARRAYLANG['TXT_BROWSE'], array('type' => 'button', 'id' => 'mediabrowser_button', 'style' => 'display:none;'))));
             //parse blocks
             $this->_objTpl->hideBlock($this->moduleNameLC . 'FormList');
         }
         //parse global variables
         $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_PAGE_TITLE' => $pageTitle, $this->moduleLangVar . '_ENTRY_ID' => $intEntryId, $this->moduleLangVar . '_FORM_ID' => $intFormId, 'TXT_' . $this->moduleLangVar . '_SUBMIT' => $_ARRAYLANG['TXT_' . $this->moduleLangVar . '_SUBMIT'], $this->moduleLangVar . '_JAVASCRIPT' => $this->getJavascript(), $this->moduleLangVar . '_FORM_ONSUBMIT' => $strOnSubmit, 'TXT_' . $this->moduleLangVar . '_PLEASE_CHECK_INPUT' => $_ARRAYLANG['TXT_MEDIADIR_PLEASE_CHECK_INPUT'], $this->moduleLangVar . '_DEFAULT_LANG_ID' => $_LANGID, 'TXT_' . $this->moduleLangVar . '_SPEZ_FIELDS' => $_ARRAYLANG['TXT_MEDIADIR_SPEZ_FIELDS'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION' => $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_ALWAYS' => $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION_ALWAYS'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_PERIOD' => $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION_PERIOD'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_FROM' => $_CORELANG['TXT_FROM'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_TO' => $_CORELANG['TXT_TO'], $this->moduleLangVar . '_DISPLAYDURATION_START' => $intEntryDourationStart, $this->moduleLangVar . '_DISPLAYDURATION_END' => $intEntryDourationEnd, $this->moduleLangVar . '_DISPLAYDURATION_SELECT_ALWAYS' => $intEntryDourationAlways, $this->moduleLangVar . '_DISPLAYDURATION_SELECT_PERIOD' => $intEntryDourationPeriod, $this->moduleLangVar . '_DISPLAYDURATION_SHOW_PERIOD' => $intEntryDourationShowPeriod, 'TXT_' . $this->moduleLangVar . '_TRANSLATION_STATUS' => $_ARRAYLANG['TXT_MEDIADIR_TRANSLATION_STATUS'], 'TXT_' . $this->moduleLangVar . '_ENTRY_STATUS' => $_ARRAYLANG['TXT_MEDIADIR_ACTIVE']));
     } else {
         \Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?cmd=" . $this->moduleName . "&act=settings&tpl=forms");
         exit;
     }
 }
コード例 #2
0
ファイル: Coupon.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Edit coupons
  * @param   \Cx\Core\Html\Sigma   $objTemplate    The Template
  */
 static function edit($objTemplate)
 {
     global $_ARRAYLANG;
     //DBG::activate(DBG_ADODB|DBG_LOG_FIREPHP|DBG_PHP);
     $result = true;
     if (isset($_GET['delete'])) {
         list($code, $customer_id) = explode('-', $_GET['delete']);
         $result &= self::delete(contrexx_input2raw($code), intval($customer_id));
     }
     $edit = isset($_REQUEST['edit']) ? contrexx_input2raw($_REQUEST['edit']) : null;
     //DBG::log("Edit: ".($edit ? $edit : 'NULL'));
     $code = isset($_POST['code']) ? contrexx_input2raw($_POST['code']) : null;
     $payment_id = empty($_POST['payment_id']) ? 0 : intval($_POST['payment_id']);
     $start_time = empty($_POST['start_date']) ? 0 : strtotime(contrexx_input2raw($_POST['start_date']));
     $end_time = empty($_POST['end_date_unlimited']) ? empty($_POST['end_date']) ? 0 : strtotime(contrexx_input2raw($_POST['end_date'])) : 0;
     $coupon_type = empty($_POST['coupon_type']) ? null : contrexx_input2raw($_POST['coupon_type']);
     $discount_rate = intval(empty($_POST['discount_rate']) ? 0 : floatval($_POST['discount_rate']));
     $discount_amount = Currency::formatPrice(empty($_POST['discount_amount']) ? 0 : floatval($_POST['discount_amount']));
     if ($coupon_type == 'rate') {
         $discount_amount = 0;
     }
     if ($coupon_type == 'amount') {
         $discount_rate = 0;
     }
     $minimum_amount = Currency::formatPrice(empty($_POST['minimum_amount']) ? 0 : floatval($_POST['minimum_amount']));
     $uses = empty($_POST['unlimited']) ? empty($_POST['uses']) ? 1 : intval($_POST['uses']) : self::USES_UNLIMITED;
     $customer_id = empty($_POST['customer_id']) ? 0 : intval($_POST['customer_id']);
     $product_id = empty($_POST['product_id']) ? 0 : intval($_POST['product_id']);
     $global = !empty($_POST['global_or_customer']);
     //DBG::log("code $code, start_time $start_time, end_time $end_time, minimum amount $minimum_amount, discount_rate $discount_rate, discount_amount $discount_amount, uses $uses, customer_id $customer_id");
     if (isset($code)) {
         $result &= self::storeCode($code, $payment_id, $minimum_amount, $discount_rate, $discount_amount, $start_time, $end_time, $uses, $global, $customer_id, $product_id, $edit);
         if ($result) {
             $code = $edit = null;
         } else {
             if (empty($edit)) {
                 $edit = "{$code}-{$customer_id}";
             }
         }
     }
     // Reset the end time if it's in the past
     if ($end_time < time()) {
         $end_time = 0;
     }
     $uri = \Html::getRelativeUri();
     \Html::stripUriParam($uri, 'view');
     \Html::stripUriParam($uri, 'edit');
     \Html::stripUriParam($uri, 'order_coupon');
     $arrSortingFields = array('code' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE'], 'start_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_START_TIME'], 'end_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME'], 'minimum_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'discount_rate' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_RATE'], 'discount_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'uses' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES'], 'global' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_SCOPE'], 'customer_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CUSTOMER'], 'product_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT'], 'payment_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT']);
     $objSorting = new \Sorting($uri, $arrSortingFields, true, 'order_coupon');
     $objTemplate->setGlobalVariable($_ARRAYLANG + array('TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_ADD_OR_EDIT' => $_ARRAYLANG[$edit ? 'TXT_SHOP_DISCOUNT_COUPON_EDIT' : 'TXT_SHOP_DISCOUNT_COUPON_ADD'], 'SHOP_DISCOUNT_COUPON_VIEW_ACTIVE' => $edit ? '' : 'active', 'SHOP_DISCOUNT_COUPON_EDIT_ACTIVE' => $edit ? 'active' : '', 'SHOP_DISCOUNT_COUPON_VIEW_DISPLAY' => $edit ? 'none' : 'block', 'SHOP_DISCOUNT_COUPON_EDIT_DISPLAY' => $edit ? 'block' : 'none', 'HEADER_SHOP_DISCOUNT_COUPON_CODE' => $objSorting->getHeaderForField('code'), 'HEADER_SHOP_DISCOUNT_COUPON_START_TIME' => $objSorting->getHeaderForField('start_time'), 'HEADER_SHOP_DISCOUNT_COUPON_END_TIME' => $objSorting->getHeaderForField('end_time'), 'HEADER_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('minimum_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_RATE' => $objSorting->getHeaderForField('discount_rate'), 'HEADER_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('discount_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_USES' => $objSorting->getHeaderForField('uses'), 'HEADER_SHOP_DISCOUNT_COUPON_SCOPE' => $objSorting->getHeaderForField('global'), 'HEADER_SHOP_DISCOUNT_COUPON_CUSTOMER' => $objSorting->getHeaderForField('customer_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PRODUCT' => $objSorting->getHeaderForField('product_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PAYMENT' => $objSorting->getHeaderForField('payment_id')));
     $count = 0;
     $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_coupon_per_page_backend', 'Shop');
     if (empty($limit)) {
         self::errorHandler();
     }
     $arrCoupons = self::getArray(\Paging::getPosition(), $limit, $count, $objSorting->getOrder());
     $arrProductName = Products::getNameArray(true, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_FORMAT']);
     $arrPaymentName = Payment::getNameArray();
     $i = 0;
     $row = 0;
     $objCouponEdit = new Coupon();
     $objCouponEdit->code($code);
     $objCouponEdit->payment_id($payment_id);
     $objCouponEdit->minimum_amount($minimum_amount);
     $objCouponEdit->discount_rate($discount_rate);
     $objCouponEdit->discount_amount($discount_amount);
     $objCouponEdit->start_time($start_time);
     $objCouponEdit->end_time($end_time);
     $objCouponEdit->uses($uses);
     $objCouponEdit->is_global($global);
     $objCouponEdit->customer_id($customer_id);
     $objCouponEdit->product_id($product_id);
     global $_CONFIG;
     foreach ($arrCoupons as $index => $objCoupon) {
         $coupon_uri_id = 'coupon_uri_' . $index;
         $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$row % 2 + 1), 'SHOP_DISCOUNT_COUPON_CODE' => $objCoupon->code, 'SHOP_DISCOUNT_COUPON_URI_ICON' => '<div class="icon_url"' . '>&nbsp;</div>', 'SHOP_DISCOUNT_COUPON_URI_INPUT' => '<div class="layer_url" id="' . $coupon_uri_id . '">' . \Html::getInputText('dummy', 'http://' . $_CONFIG['domainUrl'] . \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . '/' . CONTREXX_DIRECTORY_INDEX . '?section=Shop' . MODULE_INDEX . '&coupon_code=' . $objCoupon->code, false, 'readonly="readonly"' . ' style="width: 200px;"' . ' onfocus="this.select();"' . ' onblur="cx.jQuery(\'#' . $coupon_uri_id . '\').hide();"') . '</div>', 'SHOP_DISCOUNT_COUPON_START_TIME' => $objCoupon->start_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->start_time) : $_ARRAYLANG['TXT_SHOP_DATE_NONE'], 'SHOP_DISCOUNT_COUPON_END_TIME' => $objCoupon->end_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->end_time) : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED'], 'SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT' => $objCoupon->minimum_amount > 0 ? $objCoupon->minimum_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_RATE' => $objCoupon->discount_rate > 0 ? $objCoupon->discount_rate : $_ARRAYLANG['TXT_SHOP_RATE_NONE'], 'SHOP_DISCOUNT_COUPON_AMOUNT' => $objCoupon->discount_amount > 0 ? $objCoupon->discount_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_USES' => sprintf($_ARRAYLANG['TXT_SHOP_COUPON_USES_FORMAT'], $objCoupon->used, $objCoupon->uses < 1000000000.0 ? $objCoupon->uses : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_SCOPE' => $objCoupon->global ? $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_GLOBALLY'] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PER_CUSTOMER'], 'SHOP_DISCOUNT_COUPON_PER_CUSTOMER' => !$objCoupon->global ? \Html::getRadio('foo_' . ++$i, '', false, true, '', \Html::ATTRIBUTE_DISABLED) : '&nbsp;', 'SHOP_DISCOUNT_COUPON_CUSTOMER' => $objCoupon->customer_id ? Customers::getNameById($objCoupon->customer_id, '%4$s (%3$u)') : $_ARRAYLANG['TXT_SHOP_CUSTOMER_ANY'], 'SHOP_DISCOUNT_COUPON_PRODUCT' => $objCoupon->product_id ? isset($arrProductName[$objCoupon->product_id]) ? $arrProductName[$objCoupon->product_id] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_INVALID'] : $_ARRAYLANG['TXT_SHOP_PRODUCT_ANY'], 'SHOP_DISCOUNT_COUPON_PAYMENT' => $objCoupon->payment_id ? sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT_FORMAT'], $objCoupon->payment_id, $arrPaymentName[$objCoupon->payment_id]) : $_ARRAYLANG['TXT_SHOP_PAYMENT_ANY'], 'SHOP_DISCOUNT_COUPON_FUNCTIONS' => \Html::getBackendFunctions(array('edit' => ADMIN_SCRIPT_PATH . '?cmd=Shop&amp;act=settings&amp;tpl=coupon&amp;edit=' . urlencode($index), 'delete' => "javascript:delete_coupon('" . urlencode($index) . "');"))));
         $objTemplate->parse('shopDiscountCouponView');
         if ($index === $edit) {
             $objCouponEdit = $objCoupon;
         }
     }
     $objTemplate->replaceBlock('shopDiscountCouponView', '', true);
     $paging = \Paging::get($uri, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODES'], $count, $limit);
     //DBG::log("Paging: $paging");
     $objTemplate->setVariable('SHOP_PAGING', $paging);
     $attribute_code = 'style="width: 230px; text-align: left;" maxlength="20"';
     $attribute_time = 'style="width: 230px; text-align: left;" maxlength="10"';
     $attribute_discount_rate = 'style="width: 230px; text-align: right;" maxlength="3"';
     $attribute_discount_amount = 'style="width: 230px; text-align: right;" maxlength="9"';
     $attribute_minimum_amount = 'style="width: 230px; text-align: right;" maxlength="9"';
     $attribute_uses = 'style="width: 230px; text-align: right;" maxlength="6"';
     // Superseded by the widget, see below
     //        $attribute_customer = 'style="width: 230px;"';
     $attribute_product = 'style="width: 230px;"';
     $attribute_payment = 'style="width: 230px;"';
     $type = $objCouponEdit->discount_rate > 0 ? 'rate' : 'amount';
     $customer_name = '';
     //reset the add view
     if (!$edit) {
         $objCouponEdit = new Coupon();
     }
     if ($objCouponEdit->customer_id) {
         $customer_name = Customers::getNameById($objCouponEdit->customer_id, '%4$s (%3$u)');
         //DBG::log("Customer ID ".$objCouponEdit->customer_id.": name $customer_name");
     }
     $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$row % 2 + 1), 'SHOP_DISCOUNT_COUPON_INDEX' => $objCouponEdit->getIndex(), 'SHOP_DISCOUNT_COUPON_CODE' => \Html::getInputText('code', $objCouponEdit->code, '', $attribute_code), 'SHOP_DISCOUNT_COUPON_CODE_CREATE' => \Html::getInputButton('code_create', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE_NEW'], 'button', false, 'onclick="cx.jQuery(\'#code\').val(\'' . Coupon::getNewCode() . '\');' . 'cx.jQuery(this).css(\'display\', \'none\');"'), 'SHOP_DISCOUNT_COUPON_START_TIME' => \Html::getDatepicker('start_date', array('defaultDate' => date(ASCMS_DATE_FORMAT_DATE, $objCouponEdit->start_time ? $objCouponEdit->start_time : time())), $attribute_time), 'SHOP_DISCOUNT_COUPON_END_TIME' => \Html::getDatepicker('end_date', array('defaultDate' => $objCouponEdit->end_time ? date(ASCMS_DATE_FORMAT_DATE, $objCouponEdit->end_time) : ''), $attribute_time), 'SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED' => \Html::getCheckbox('end_time_unlimited', 1, '', $objCouponEdit->end_time ? '' : \Html::ATTRIBUTE_CHECKED) . \Html::getLabel('end_time_unlimited', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT' => \Html::getInputText('minimum_amount', $objCouponEdit->minimum_amount, false, $attribute_minimum_amount), 'SHOP_DISCOUNT_COUPON_TYPE' => \Html::getRadioGroup('coupon_type', array('rate' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_TYPE_RATE'], 'amount' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_TYPE_AMOUNT']), $type), 'SHOP_DISCOUNT_COUPON_TYPE_SELECTED' => $type, 'SHOP_DISCOUNT_COUPON_RATE' => \Html::getInputText('discount_rate', $objCouponEdit->discount_rate, false, $attribute_discount_rate), 'SHOP_DISCOUNT_COUPON_AMOUNT' => \Html::getInputText('discount_amount', number_format($objCouponEdit->discount_amount, 2, '.', ''), false, $attribute_discount_amount), 'SHOP_DISCOUNT_COUPON_USES' => \Html::getInputText('uses', $objCouponEdit->uses < 1000000000.0 ? $objCouponEdit->uses : '', 'uses', $attribute_uses), 'SHOP_DISCOUNT_COUPON_USES_UNLIMITED' => \Html::getCheckbox('unlimited', 1, 'unlimited', $objCouponEdit->uses > 1000000000.0) . \Html::getLabel('unlimited', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_GLOBALLY' => \Html::getRadio('global_or_customer', '1', 'global', $objCouponEdit->global) . \Html::getLabel('global', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_GLOBALLY']), 'SHOP_DISCOUNT_COUPON_PER_CUSTOMER' => \Html::getRadio('global_or_customer', '0', 'customer', !$objCouponEdit->global) . \Html::getLabel('customer', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PER_CUSTOMER']), 'SHOP_DISCOUNT_COUPON_CUSTOMER_ID' => $objCouponEdit->customer_id, 'SHOP_DISCOUNT_COUPON_CUSTOMER_NAME' => $customer_name, 'SHOP_DISCOUNT_COUPON_PRODUCT' => \Html::getSelect('product_id', array(0 => $_ARRAYLANG['TXT_SHOP_PRODUCT_ANY']) + $arrProductName, $objCouponEdit->product_id, false, '', $attribute_product), 'SHOP_DISCOUNT_COUPON_PAYMENT' => \Html::getSelect('payment_id', array(0 => $_ARRAYLANG['TXT_SHOP_PAYMENT_ANY']) + $arrPaymentName, $objCouponEdit->payment_id, false, '', $attribute_payment), 'SHOP_DISCOUNT_COUPON_CUSTOMER_WIDGET_DISPLAY' => $objCouponEdit->global ? \Html::CSS_DISPLAY_NONE : \Html::CSS_DISPLAY_INLINE));
     $objTemplate->parse('shopDiscountCouponEdit');
     // Depends on, and thus implies loading jQuery as well!
     \FWUser::getUserLiveSearch(array('minLength' => 3, 'canCancel' => true, 'canClear' => true));
     return $result;
 }
コード例 #3
0
 /**
  * Edit the news, or if $copy is true, it copies an entry
  *
  * @global    ADONewConnection
  * @global    array
  * @global    array
  * @param     string     $pageContent
  */
 function edit($copy = false)
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     \JS::activate('cx');
     if (!empty($this->arrSettings['news_use_tags'])) {
         \JS::registerJS('lib/javascript/tag-it/js/tag-it.min.js');
         \JS::registerCss('lib/javascript/tag-it/css/tag-it.css');
     }
     $newsTagId = 'newsTags';
     \FWUser::getUserLiveSearch();
     if (!$this->hasCategories()) {
         return $this->manageCategories();
     }
     $objFWUser = \FWUser::getFWUserObject();
     $status = '';
     $this->_objTpl->loadTemplateFile('module_news_modify.html', true, true);
     $this->pageTitle = $copy ? $_ARRAYLANG['TXT_CREATE_NEWS'] : $_ARRAYLANG['TXT_EDIT_NEWS_CONTENT'];
     $catrow = 'row2';
     if ($this->arrSettings['news_use_types'] == 1) {
         $catrow = 'row1';
     }
     $this->_objTpl->setGlobalVariable(array('TXT_CATEGORY_SELECT' => $_ARRAYLANG['TXT_CATEGORY_SELECT'], 'TXT_COPY' => $_ARRAYLANG['TXT_NEWS_COPY'], 'TXT_NEWS_MESSAGE' => $_ARRAYLANG['TXT_NEWS_MESSAGE'], 'TXT_TITLE' => $_ARRAYLANG['TXT_TITLE'], 'TXT_CATEGORY' => $_ARRAYLANG['TXT_CATEGORY'], 'TXT_NEWS_AUTHOR' => $_ARRAYLANG['TXT_NEWS_AUTHOR'], 'TXT_NEWS_PUBLISHER' => $_ARRAYLANG['TXT_NEWS_PUBLISHER'], 'TXT_CORE_SEARCH_USER' => $_ARRAYLANG['TXT_CORE_SEARCH_USER'], 'NEWS_FORM_CAT_ROW' => $catrow, 'TXT_NEWS_TYPE' => $_ARRAYLANG['TXT_NEWS_TYPE'], 'TXT_EXTERNAL_SOURCE' => $_ARRAYLANG['TXT_EXTERNAL_SOURCE'], 'TXT_LINK' => $_ARRAYLANG['TXT_LINK'], 'TXT_NEWS_NEWS_CONTENT' => $_ARRAYLANG['TXT_NEWS_NEWS_CONTENT'], 'TXT_PUBLISHING' => $_ARRAYLANG['TXT_PUBLISHING'], 'TXT_STARTDATE' => $_ARRAYLANG['TXT_STARTDATE'], 'TXT_ENDDATE' => $_ARRAYLANG['TXT_ENDDATE'], 'TXT_OPTIONAL' => $_ARRAYLANG['TXT_OPTIONAL'], 'TXT_ACTIVE' => $_ARRAYLANG['TXT_ACTIVE'], 'TXT_SCHEDULED_PUBLICATION' => $_ARRAYLANG['TXT_SCHEDULED_PUBLICATION'], 'TXT_DATE' => $_ARRAYLANG['TXT_DATE'], 'TXT_HEADLINES' => $_ARRAYLANG['TXT_HEADLINES'], 'TXT_TOPNEWS' => $_ARRAYLANG['TXT_TOPNEWS'], 'TXT_TEASERS' => $_ARRAYLANG['TXT_TEASERS'], 'TXT_NEWS_TEASER_TEXT' => $_ARRAYLANG['TXT_NEWS_TEASER_TEXT'], 'TXT_IMAGE' => $_ARRAYLANG['TXT_IMAGE'], 'TXT_NEWS_THUMBNAIL' => $_ARRAYLANG['TXT_NEWS_THUMBNAIL'], 'TXT_BROWSE' => $_ARRAYLANG['TXT_BROWSE'], 'TXT_NUMBER_OF_CHARS' => $_ARRAYLANG['TXT_NUMBER_OF_CHARS'], 'TXT_TEASER_SHOW_NEWS_LINK' => $_ARRAYLANG['TXT_TEASER_SHOW_NEWS_LINK'], 'TXT_NEWS_DEFINE_LINK_ALT_TEXT' => $_ARRAYLANG['TXT_NEWS_DEFINE_LINK_ALT_TEXT'], 'TXT_NEWS_INSERT_LINK' => $_ARRAYLANG['TXT_NEWS_INSERT_LINK'], 'TXT_NEWS_REDIRECT_TITLE' => $_ARRAYLANG['TXT_NEWS_REDIRECT_TITLE'], 'TXT_NEWS_MESSAGE_TYPE' => $_ARRAYLANG['TXT_NEWS_MESSAGE_TYPE'], 'TXT_NEWS_TYPE_REDIRECT' => $_ARRAYLANG['TXT_NEWS_REDIRECT_TITLE'], 'TXT_NEWS_TYPE_REDIRECT_HELP' => $_ARRAYLANG['TXT_NEWS_TYPE_REDIRECT_HELP'], 'TXT_NEWS_TYPE_DEFAULT' => $_ARRAYLANG['TXT_NEWS_TYPE_DEFAULT'], 'TXT_NEWS_BASIC_DATA' => $_ARRAYLANG['TXT_BASIC_DATA'], 'TXT_NEWS_MORE_OPTIONS' => $_ARRAYLANG['TXT_MORE_OPTIONS'], 'TXT_NEWS_PERMISSIONS' => $_ARRAYLANG['TXT_NEWS_PERMISSIONS'], 'TXT_NEWS_READ_ACCESS' => $_ARRAYLANG['TXT_NEWS_READ_ACCESS'], 'TXT_NEWS_MODIFY_ACCESS' => $_ARRAYLANG['TXT_NEWS_MODIFY_ACCESS'], 'TXT_NEWS_AVAILABLE_USER_GROUPS' => $_ARRAYLANG['TXT_NEWS_AVAILABLE_USER_GROUPS'], 'TXT_NEWS_ASSIGNED_USER_GROUPS' => $_ARRAYLANG['TXT_NEWS_ASSIGNED_USER_GROUPS'], 'TXT_NEWS_CHECK_ALL' => $_ARRAYLANG['TXT_NEWS_CHECK_ALL'], 'TXT_NEWS_UNCHECK_ALL' => $_ARRAYLANG['TXT_NEWS_UNCHECK_ALL'], 'TXT_NEWS_READ_ALL_ACCESS_DESC' => $_ARRAYLANG['TXT_NEWS_READ_ALL_ACCESS_DESC'], 'TXT_NEWS_RELATED_NEWS' => $_ARRAYLANG['TXT_NEWS_RELATED_NEWS'], 'TXT_NEWS_INCLUDE_NEWS' => $_ARRAYLANG['TXT_NEWS_INCLUDE_NEWS'], 'TXT_NEWS_INCLUDE_RELATED_NEWS_DESC' => $_ARRAYLANG['TXT_NEWS_INCLUDE_RELATED_NEWS_DESC'], 'TXT_NEWS_SEARCH_INFO' => $_ARRAYLANG['TXT_NEWS_SEARCH_INFO'], 'TXT_NEWS_SEARCH_PLACEHOLDER' => $_ARRAYLANG['TXT_NEWS_SEARCH_PLACEHOLDER'], 'TXT_NEWS_READ_SELECTED_ACCESS_DESC' => $_ARRAYLANG['TXT_NEWS_READ_SELECTED_ACCESS_DESC'], 'TXT_NEWS_AVAILABLE_USER_GROUPS' => $_ARRAYLANG['TXT_NEWS_AVAILABLE_USER_GROUPS'], 'TXT_NEWS_ASSIGNED_USER_GROUPS' => $_ARRAYLANG['TXT_NEWS_ASSIGNED_USER_GROUPS'], 'TXT_NEWS_MODIFY_ALL_ACCESS_DESC' => $_ARRAYLANG['TXT_NEWS_MODIFY_ALL_ACCESS_DESC'], 'TXT_NEWS_MODIFY_SELECTED_ACCESS_DESC' => $_ARRAYLANG['TXT_NEWS_MODIFY_SELECTED_ACCESS_DESC'], 'TXT_NEWS_TAGS' => $_ARRAYLANG['TXT_NEWS_TAGS'], 'TXT_NEWS_TAGS_ENABLE' => $_ARRAYLANG['TXT_NEWS_TAGS_ENABLE'], 'NEWS_TAG_ID' => $newsTagId));
     $newsid = intval($_REQUEST['newsId']);
     $objResult = $objDatabase->SelectLimit("SELECT  typeid,\n                                                        date,\n                                                        id,\n                                                        redirect,\n                                                        source,\n                                                        url1,\n                                                        url2,\n                                                        publisher,\n                                                        publisher_id,\n                                                        author,\n                                                        author_id,\n                                                        startdate,\n                                                        enddate,\n                                                        status,\n                                                        userid,\n                                                        frontend_access_id,\n                                                        backend_access_id,\n                                                        teaser_only,\n                                                        teaser_show_link,\n                                                        teaser_image_path,\n                                                        teaser_image_thumbnail_path,\n                                                        allow_comments,\n                                                        enable_related_news,\n                                                        enable_tags\n                                                FROM    " . DBPREFIX . "module_news\n                                                WHERE   id = '" . $newsid . "'", 1);
     if ($objResult !== false && !$objResult->EOF && ($this->arrSettings['news_message_protection'] != '1' || \Permission::hasAllAccess() || !$objResult->fields['backend_access_id'] || \Permission::checkAccess($objResult->fields['backend_access_id'], 'dynamic', true) || $objResult->fields['userid'] == $objFWUser->objUser->getId())) {
         $newsType = $objResult->fields['typeid'];
         $id = $objResult->fields['id'];
         $arrLanguages = \FWLanguage::getLanguageArray();
         $langData = $this->getLangData($id);
         $newsComment = $objResult->fields['allow_comments'];
         $newsAuthorName = $objResult->fields['author'];
         $newsAuthorId = $objResult->fields['author_id'];
         $newsPublisherName = $objResult->fields['publisher'];
         $newsPublisherId = $objResult->fields['publisher_id'];
         if ($newsPublisherId != 0 && ($objUser = $objFWUser->objUser->getUser($newsPublisherId))) {
             $newsPublisherName = \FWUser::getParsedUserTitle($objUser);
         } else {
             $newsPublisherId = 0;
         }
         if ($newsAuthorId != 0 && ($objUser = $objFWUser->objUser->getUser($newsAuthorId))) {
             $newsAuthorName = \FWUser::getParsedUserTitle($objUser);
         } else {
             $newsAuthorId = 0;
         }
         $active_lang = array();
         $activeLanguage = null;
         if (isset($_GET['langId']) && in_array($_GET['langId'], \FWLanguage::getIdArray())) {
             if (!in_array($_GET['langId'], $active_lang)) {
                 $active_lang[] = contrexx_input2raw($_GET['langId']);
             }
             $activeLanguage = contrexx_input2raw($_GET['langId']);
         }
         if (count($arrLanguages) > 0) {
             $intLanguageCounter = 0;
             $arrActiveLang = array(0 => '', 1 => '', 2 => '');
             $strJsTabToDiv = '';
             $query = "SELECT `lang_id` FROM `" . DBPREFIX . "module_news_locale`\n                                WHERE `news_id` = " . $newsid . "\n                                AND `is_active` = '1'";
             $activeLangResult = $objDatabase->Execute($query);
             while (!$activeLangResult->EOF) {
                 $active_lang[] = $activeLangResult->fields['lang_id'];
                 $activeLangResult->MoveNext();
             }
             if (isset($_POST['newsManagerLanguages'])) {
                 $active_lang = array_keys($_POST['newsManagerLanguages']);
             }
             foreach ($arrLanguages as $intId => $arrLanguage) {
                 if ($arrLanguage['frontend'] == 1) {
                     $intLanguageId = $arrLanguage['id'];
                     $arrActiveLang[$intLanguageCounter % 3] .= '<input id="languagebar_' . $intLanguageId . '" class="langCheckboxes" ' . (in_array($intLanguageId, $active_lang) ? 'checked="checked"' : '') . ' type="checkbox" name="newsManagerLanguages[' . $intLanguageId . ']" value="1" onclick="switchBoxAndTab(this, \'news_lang_tab_' . $intLanguageId . '\');" /><label for="languagebar_' . $intLanguageId . '">' . $arrLanguage['name'] . ' [' . $arrLanguage['lang'] . ']</label><br />';
                     ++$intLanguageCounter;
                 }
             }
             $this->_objTpl->setVariable(array('TXT_LANGUAGE' => $_ARRAYLANG['TXT_LANGUAGE'], 'EDIT_LANGUAGES_1' => $arrActiveLang[0], 'EDIT_LANGUAGES_2' => $arrActiveLang[1], 'EDIT_LANGUAGES_3' => $arrActiveLang[2]));
         }
         $first = true;
         if (!$activeLanguage) {
             $activeLanguage = current($active_lang);
         }
         foreach ($arrLanguages as $langId => $arrLanguage) {
             if ($arrLanguage['frontend'] == 1) {
                 $isActive = isset($langData[$langId]) && $langData[$langId]['active'] == 1;
                 $display = $langId == $activeLanguage;
                 // parse tabs
                 $this->_objTpl->setVariable(array('NEWS_LANG_ID' => $langId, 'NEWS_LANG_DISPLAY_STATUS' => $display ? 'active' : 'inactive', 'NEWS_LANG_DISPLAY_STYLE' => in_array($arrLanguage['id'], $active_lang) ? 'inline' : 'none', 'NEWS_LANG_NAME' => contrexx_raw2xhtml($arrLanguage['name'])));
                 $this->_objTpl->parse('news_lang_list');
                 // parse title
                 $title = isset($_POST['newsTitle'][$langId]) ? contrexx_input2raw($_POST['newsTitle'][$langId]) : '';
                 if (empty($title)) {
                     $title = isset($langData[$langId]['title']) ? $langData[$langId]['title'] : '';
                 }
                 $this->_objTpl->setVariable(array('NEWS_LANG_ID' => $langId, 'NEWS_TITLE' => contrexx_raw2xhtml($title), 'NEWS_TITLE_DISPLAY' => $display ? 'block' : 'none'));
                 $this->_objTpl->parse('news_title_list');
                 // parse teaser text
                 $teaserText = isset($_POST['newsTeaserText'][$langId]) ? contrexx_input2raw($_POST['newsTeaserText'][$langId]) : null;
                 if (!isset($teaserText)) {
                     $teaserText = isset($langData[$langId]['teaser_text']) ? $langData[$langId]['teaser_text'] : '';
                 }
                 $this->_objTpl->setVariable(array('NEWS_LANG_ID' => $langId, 'NEWS_TEASER_TEXT' => contrexx_raw2xhtml($teaserText), 'NEWS_TEASER_TEXT_LENGTH' => !empty($teaserText) ? strlen($teaserText) : 0, 'NEWS_TITLE_DISPLAY' => $display ? 'block' : 'none'));
                 $this->_objTpl->parse('news_teaser_text_list');
                 // parse text
                 $text = isset($_POST['news_text'][$langId]) ? $_POST['news_text'][$langId] : null;
                 if (!isset($text)) {
                     $text = isset($langData[$langId]['text']) ? $langData[$langId]['text'] : '';
                 }
                 $this->_objTpl->setVariable(array('NEWS_LANG_ID' => $langId, 'NEWS_TEXT' => contrexx_raw2xhtml($text)));
                 $this->_objTpl->parse('news_text_list');
                 if ($display) {
                     $selectedLangId = $langId;
                     $newsText = contrexx_raw2xhtml($text);
                     $first = false;
                 }
             }
         }
         if ($intLanguageCounter == 1) {
             $this->_objTpl->setVariable('NEWS_LANG_TAB_DISPLAY_STYLE', 'none');
             $this->_objTpl->hideBlock('news_language_checkboxes');
         }
         $this->_objTpl->setVariable('NEWS_DEFAULT_LANG', contrexx_raw2xhtml(\FWLanguage::getLanguageParameter($selectedLangId, 'name')));
         if ($this->arrSettings['news_use_teaser_text'] != 1) {
             $this->_objTpl->hideBlock('news_use_teaser_text');
         }
         $teaserShowLink = $objResult->fields['teaser_show_link'];
         if ($objResult->fields['status'] == 1) {
             $status = 'checked="checked"';
         }
         $startDate = $objResult->fields['startdate'] !== '0000-00-00 00:00:00' ? strtotime($objResult->fields['startdate']) : 0;
         $endDate = $objResult->fields['enddate'] !== '0000-00-00 00:00:00' ? strtotime($objResult->fields['enddate']) : 0;
         if (!empty($startDate) || !empty($endDate)) {
             $this->_objTpl->setVariable(array('NEWS_SCHEDULED' => 'checked="checked"', 'NEWS_SCHEDULED_DISPLAY' => 'display: block;'));
         } else {
             $this->_objTpl->setVariable('NEWS_SCHEDULED_DISPLAY', 'display: none;');
         }
         if (empty($objResult->fields['redirect'])) {
             $this->_objTpl->setVariable(array('NEWS_TYPE_SELECTION_CONTENT' => 'style="display: block;"', 'NEWS_TYPE_SELECTION_REDIRECT' => 'style="display: none;"', 'NEWS_TYPE_CHECKED_CONTENT' => 'checked="checked"', 'NEWS_TYPE_CHECKED_REDIRECT' => ''));
         } else {
             $this->_objTpl->setVariable(array('NEWS_TYPE_SELECTION_CONTENT' => 'style="display: none;"', 'NEWS_TYPE_SELECTION_REDIRECT' => 'style="display: block;"', 'NEWS_TYPE_CHECKED_CONTENT' => '', 'NEWS_TYPE_CHECKED_REDIRECT' => 'checked="checked"'));
         }
         $objTeaser = new \Cx\Core_Modules\News\Controller\Teasers(true);
         $frameIds = '';
         $associatedFrameIds = '';
         $arrAssociatedFrameIds = explode(';', $objTeaser->arrTeasers[$newsid]['teaser_frames']);
         foreach ($arrAssociatedFrameIds as $teaserFrameId) {
             if (empty($teaserFrameId)) {
                 continue;
             }
             $associatedFrameIds .= "<option value=\"" . $teaserFrameId . "\">" . $objTeaser->arrTeaserFrames[$teaserFrameId]['name'] . "</option>\n";
         }
         foreach ($objTeaser->arrTeaserFrameNames as $frameName => $frameId) {
             if (!in_array($frameId, $arrAssociatedFrameIds)) {
                 $frameIds .= "<option value=\"" . $frameId . "\">" . $frameName . "</option>\n";
             }
         }
         $this->_objTpl->setVariable(array('NEWS_ID' => $copy ? '' : $id, 'NEWS_STORED_ID' => $copy ? '' : $id, 'NEWS_TEXT_PREVIEW' => new \Cx\Core\Wysiwyg\Wysiwyg('newsText', $newsText, 'full'), 'NEWS_REDIRECT' => contrexx_raw2xhtml($objResult->fields['redirect']), 'NEWS_SOURCE' => contrexx_raw2xhtml($objResult->fields['source']), 'NEWS_URL1' => contrexx_raw2xhtml($objResult->fields['url1']), 'NEWS_URL2' => contrexx_raw2xhtml($objResult->fields['url2']), 'NEWS_PUBLISHER_NAME' => contrexx_raw2xhtml($newsPublisherName), 'NEWS_PUBLISHER_ID' => contrexx_raw2xhtml($newsPublisherId), 'NEWS_AUTHOR_NAME' => contrexx_raw2xhtml($newsAuthorName), 'NEWS_AUTHOR_ID' => contrexx_raw2xhtml($newsAuthorId), 'NEWS_CREATE_DATE' => $this->valueFromDate($objResult->fields['date']), 'NEWS_STARTDATE' => $this->valueFromDate($startDate), 'NEWS_ENDDATE' => $this->valueFromDate($endDate), 'NEWS_STATUS' => isset($_GET['validate']) ? 'checked="checked"' : $status, 'NEWS_TEASER_SHOW_LINK_CHECKED' => $teaserShowLink ? 'checked="checked"' : '', 'NEWS_TEASER_IMAGE_PATH' => contrexx_raw2xhtml($objResult->fields['teaser_image_path']), 'NEWS_TEASER_IMAGE_THUMBNAIL_PATH' => contrexx_raw2xhtml($objResult->fields['teaser_image_thumbnail_path']), 'NEWS_DATE' => date('Y-m-d H:i:s'), 'NEWS_SUBMIT_NAME' => isset($_GET['validate']) ? 'validate' : 'store', 'NEWS_SUBMIT_NAME_TEXT' => isset($_GET['validate']) ? $_ARRAYLANG['TXT_CONFIRM'] : $_ARRAYLANG['TXT_STORE'], 'NEWS_MEDIA_BROWSER_BROWSE_BUTTON' => self::getMediaBrowserButton(array('type' => 'button', 'id' => 'newsMediaBrowser', 'style' => 'display:none;'), 'SetUrl'), 'NEWS_RELATED_NEWS_ENABLED_CHECKED' => !empty($objResult->fields['enable_related_news']) ? 'checked="checked"' : '', 'NEWS_TAGS_ENABLED_CHECKED' => !empty($objResult->fields['enable_tags']) ? 'checked="checked"' : ''));
         if ($this->arrSettings['news_message_protection'] == '1') {
             if ($this->arrSettings['news_message_protection_restricted'] == '1') {
                 $userGroupIds = $objFWUser->objUser->getAssociatedGroupIds();
             }
             if ($objResult->fields['frontend_access_id']) {
                 $objFrontendGroups = $objFWUser->objGroup->getGroups(array('dynamic' => $objResult->fields['frontend_access_id']));
                 $arrFrontendGroups = $objFrontendGroups ? $objFrontendGroups->getLoadedGroupIds() : array();
             } else {
                 $arrFrontendGroups = array();
             }
             if ($objResult->fields['backend_access_id']) {
                 $objBackendGroups = $objFWUser->objGroup->getGroups(array('dynamic' => $objResult->fields['backend_access_id']));
                 $arrBackendGroups = $objBackendGroups ? $objBackendGroups->getLoadedGroupIds() : array();
             } else {
                 $arrBackendGroups = array();
             }
             $readAccessGroups = '';
             $readNotAccessGroups = '';
             $modifyAccessGroups = '';
             $modifyNotAccessGroups = '';
             $objGroup = $objFWUser->objGroup->getGroups();
             if ($objGroup) {
                 while (!$objGroup->EOF) {
                     ${$objGroup->getType() == 'frontend' ? in_array($objGroup->getId(), $arrFrontendGroups) ? 'readAccessGroups' : 'readNotAccessGroups' : (in_array($objGroup->getId(), $arrBackendGroups) ? 'modifyAccessGroups' : 'modifyNotAccessGroups')} .= '<option value="' . $objGroup->getId() . '"' . (!\Permission::hasAllAccess() && $this->arrSettings['news_message_protection_restricted'] == '1' && !in_array($objGroup->getId(), $userGroupIds) ? ' disabled="disabled"' : '') . '>' . htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET) . '</option>';
                     $objGroup->next();
                 }
             }
             $this->_objTpl->setVariable(array('NEWS_READ_ACCESS_NOT_ASSOCIATED_GROUPS' => $readNotAccessGroups, 'NEWS_READ_ACCESS_ASSOCIATED_GROUPS' => $readAccessGroups, 'NEWS_READ_ACCESS_ALL_CHECKED' => $objResult->fields['frontend_access_id'] ? '' : 'checked="checked"', 'NEWS_READ_ACCESS_SELECTED_CHECKED' => $objResult->fields['frontend_access_id'] ? 'checked="checked"' : '', 'NEWS_READ_ACCESS_DISPLAY' => $objResult->fields['frontend_access_id'] ? '' : 'none', 'NEWS_MODIFY_ACCESS_NOT_ASSOCIATED_GROUPS' => $modifyNotAccessGroups, 'NEWS_MODIFY_ACCESS_ASSOCIATED_GROUPS' => $modifyAccessGroups, 'NEWS_MODIFY_ACCESS_ALL_CHECKED' => $objResult->fields['backend_access_id'] ? '' : 'checked="checked"', 'NEWS_MODIFY_ACCESS_SELECTED_CHECKED' => $objResult->fields['backend_access_id'] ? 'checked="checked"' : '', 'NEWS_MODIFY_ACCESS_DISPLAY' => $objResult->fields['backend_access_id'] ? '' : 'none'));
             $this->_objTpl->touchBlock('news_permission_tab');
         } else {
             $this->_objTpl->hideBlock('news_permission_tab');
         }
         //Customized News Module Improvements
         if (!empty($this->arrSettings['news_use_tags'])) {
             $this->registerTagJsCode();
             $newsTagDetails = $this->getNewsTags($id);
             $newsTags = $newsTagDetails['tagList'];
             if ($this->_objTpl->blockExists('newsTags')) {
                 foreach ($newsTags as $newsTag) {
                     $this->_objTpl->setVariable('NEWS_TAGS', $newsTag);
                     $this->_objTpl->parse('newsTags');
                 }
             }
             $this->_objTpl->touchBlock('newsTagsBlock');
         } else {
             $this->_objTpl->hideBlock('newsTagsBlock');
         }
         if (!empty($this->arrSettings['use_related_news'])) {
             $objCx = \ContrexxJavascript::getInstance();
             $objCx->setVariable('noResultsMsg', $_ARRAYLANG['TXT_NEWS_NOT_FOUND'], 'news/news-live-search');
             \JS::registerJS('core_modules/News/View/Script/news-live-search.js');
             \JS::registerCss('core_modules/News/View/Style/news-live-search.css');
             //Parsing the related news tags
             $relatedNewsIds = isset($_POST['relatedNews']) ? contrexx_input2raw($_POST['relatedNews']) : $this->getRelatedNews($id);
             //Getting the related news ids
             $this->parseRelatedNewsTags($this->_objTpl, $relatedNewsIds, LANG_ID);
             $this->_objTpl->touchBlock('relatedNewsBlock');
         } else {
             $this->_objTpl->hideBlock('relatedNewsBlock');
         }
     } else {
         $this->strErrMessage = $_ARRAYLANG['TXT_NEWS_ENTRY_NOT_FOUND'];
         $this->overview();
         return;
     }
     if ($_CONFIG['newsTeasersStatus'] == '1') {
         $this->_objTpl->parse('newsTeaserOptions');
         $this->_objTpl->setVariable(array('TXT_USAGE' => $_ARRAYLANG['TXT_USAGE'], 'TXT_USE_ONLY_TEASER_TEXT' => $_ARRAYLANG['TXT_USE_ONLY_TEASER_TEXT'], 'TXT_TEASER_TEASER_BOXES' => $_ARRAYLANG['TXT_TEASER_TEASER_BOXES'], 'TXT_AVAILABLE_BOXES' => $_ARRAYLANG['TXT_AVAILABLE_BOXES'], 'TXT_SELECT_ALL' => $_ARRAYLANG['TXT_SELECT_ALL'], 'TXT_DESELECT_ALL' => $_ARRAYLANG['TXT_DESELECT_ALL'], 'TXT_ASSOCIATED_BOXES' => $_ARRAYLANG['TXT_ASSOCIATED_BOXES'], 'NEWS_HEADLINES_TEASERS_TXT' => $_ARRAYLANG['TXT_HEADLINES'] . ' / ' . $_ARRAYLANG['TXT_TEASERS'], 'NEWS_USE_ONLY_TEASER_CHECKED' => $objResult->fields['teaser_only'] == '1' ? 'checked="checked"' : '', 'NEWS_TEASER_FRAMES' => $frameIds, 'NEWS_TEASER_ASSOCIATED_FRAMES' => $associatedFrameIds));
     } else {
         $this->_objTpl->hideBlock('newsTeaserOptions');
         $this->_objTpl->setVariable('NEWS_HEADLINES_TEASERS_TXT', $_ARRAYLANG['TXT_HEADLINES']);
     }
     $categoryRelatedToNews = $this->getNewsRelCategories($id);
     $this->_objTpl->setVariable('NEWS_CAT_MENU', $this->getCategoryMenu($this->nestedSetRootId, $categoryRelatedToNews));
     $news_type_menu = '';
     if ($this->arrSettings['news_use_types'] == 1) {
         $news_type_menu = "<tr class=\"row2\">\n<td nowrap=\"nowrap\">{$_ARRAYLANG['TXT_NEWS_TYPE']}</td><td><select name=\"newsType\"><option value=\"0\">{$_ARRAYLANG['TXT_NO_TYPE']}</option>" . $this->getTypeMenu($newsType) . "</select></td></tr>";
     }
     // Activate Comments
     $news_comment = '';
     if ($this->arrSettings['news_comments_activated'] == 1) {
         $commentsChecked = $newsComment == 1 ? 'checked="checked"' : '';
         $this->_objTpl->setVariable(array('TXT_NEWS_ALLOW_COMMENTS' => $_ARRAYLANG['TXT_NEWS_ALLOW_COMMENTS'], 'NEWS_COMMENT_CHECKED' => $commentsChecked));
     } else {
         $this->_objTpl->hideBlock('news_allow_comments_option');
     }
     $this->_objTpl->setVariable('NEWS_TYPE_MENU', $news_type_menu);
     $this->_objTpl->setVariable('NEWS_FORM_ACTION', $copy ? 'add' : 'update');
     $this->_objTpl->setVariable('NEWS_STORED_FORM_ACTION', 'update');
     $this->_objTpl->setVariable('NEWS_TOP_TITLE', $_ARRAYLANG['TXT_EDIT_NEWS_CONTENT']);
 }
コード例 #4
0
 public function showOrders()
 {
     global $_ARRAYLANG;
     $term = isset($_GET['filter-term']) ? contrexx_input2raw($_GET['filter-term']) : '';
     $filterUserId = isset($_GET['filter-user-id']) ? contrexx_input2raw($_GET['filter-user-id']) : 0;
     $objFilterUser = null;
     if (!empty($term) || !empty($filterUserId)) {
         if ($filterUserId) {
             $objFilterUser = \FWUser::getFWUserObject()->objUser->getUser($filterUserId);
         }
         $orders = $this->orderRepository->findOrdersBySearchTerm($term, $objFilterUser);
     } else {
         $orders = $this->orderRepository->getAllByDesc();
     }
     $view = new \Cx\Core\Html\Controller\ViewGenerator($orders, array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_ACT_DEFAULT'], 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false), 'fields' => array('contactId' => array('header' => 'contactId', 'table' => array('parse' => function ($value) {
         global $_ARRAYLANG;
         $userId = \Cx\Modules\Crm\Controller\CrmLibrary::getUserIdByCrmUserId($value);
         $userName = \FWUser::getParsedUserTitle($userId);
         $crmDetailLink = "<a href='index.php?cmd=Crm&amp;act=customers&amp;tpl=showcustdetail&amp;id={$value}' \n                                                    title='{$_ARRAYLANG['TXT_MODULE_ORDER_CRM_CONTACT']}'>\n                                                    <img \n                                                        src='" . \Env::get('cx')->getCodeBaseCoreWebPath() . "/Core/View/Media/navigation_level_1_189.png' \n                                                        width='16' height='16' \n                                                        alt='{$_ARRAYLANG['TXT_MODULE_ORDER_CRM_CONTACT']}'\n                                                    />\n                                                </a>";
         $url = "<a href='index.php?cmd=Access&amp;act=user&amp;tpl=modify&amp;id={$userId}'\n                                       title='{$_ARRAYLANG['TXT_MODULE_ORDER_MODIY_USER_ACCOUNT']}'>" . $userName . "</a>" . $crmDetailLink;
         return $url;
     })), 'subscriptions' => array('header' => 'subscriptions', 'table' => array('parse' => function ($subscriptions) {
         $result = array();
         foreach ($subscriptions as $subscription) {
             $productEntity = $subscription->getProductEntity();
             $productEntityName = $subscription->getProduct()->getName();
             if (!$productEntity) {
                 continue;
             }
             $productEditLink = $productEntity;
             if (method_exists($productEntity, 'getEditLink')) {
                 $productEditLink = $productEntity->getEditLink();
             }
             $subscriptionEditUrl = '<a href=​index.php?cmd=Order&act=subscription&editid=' . $subscription->getId() . '>' . $productEntityName . '</a>';
             $result[] = $subscriptionEditUrl . ' (' . $productEditLink . ')';
         }
         return implode(', ', $result);
     })))));
     if (isset($_GET['editid']) && !empty($_GET['editid']) || isset($_GET['add']) && !empty($_GET['add'])) {
         $this->template->hideBlock("order_filter");
     } else {
         \FWUser::getUserLiveSearch(array('minLength' => 1, 'canCancel' => true, 'canClear' => true));
         $this->template->setVariable(array('TXT_MODULE_ORDER_SEARCH' => $_ARRAYLANG['TXT_MODULE_ORDER_SEARCH'], 'TXT_MODULE_ORDER_FILTER' => $_ARRAYLANG['TXT_MODULE_ORDER_FILTER'], 'TXT_MODULE_ORDER_SEARCH_TERM' => $_ARRAYLANG['TXT_MODULE_ORDER_SEARCH_TERM'], 'ORDER_SEARCH_VALUE' => isset($_GET['filter-term']) ? contrexx_input2xhtml($_GET['filter-term']) : '', 'ORDER_USER_ID' => contrexx_raw2xhtml($filterUserId), 'ORDER_USER_NAME' => $objFilterUser ? contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objFilterUser)) : ''));
     }
     $this->template->setVariable('ORDERS_CONTENT', $view->render());
 }
コード例 #5
0
 /**
  * add or edit contact
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 function _modifyContact()
 {
     global $_ARRAYLANG, $objDatabase, $objJs, $objResult, $_LANGID, $_CORELANG;
     \JS::activate('cx');
     \JS::activate("jquery");
     \JS::activate("jqueryui");
     $objFWUser = \FWUser::getFWUserObject();
     \FWUser::getUserLiveSearch(array('minLength' => 3, 'canCancel' => true, 'canClear' => true));
     \JS::registerJS("modules/Crm/View/Script/main.js");
     \JS::registerJS("modules/Crm/View/Script/contact.js");
     \JS::registerCSS("modules/Crm/View/Style/main.css");
     \JS::registerCSS("modules/Crm/View/Style/contact.css");
     \JS::registerCSS("lib/javascript/chosen/chosen.css");
     \JS::registerJS("lib/javascript/chosen/chosen.jquery.js");
     $cxjs = \ContrexxJavascript::getInstance();
     $cxjs->setVariable('TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT', $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT'], 'modifyContact');
     $mes = isset($_REQUEST['mes']) ? base64_decode($_REQUEST['mes']) : '';
     if (!empty($mes)) {
         switch ($mes) {
             case "customerupdated":
                 $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_CUSTOMER_DETAILS_UPDATED_SUCCESSFULLY'];
                 break;
             case "customeradded":
                 $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_CUSTOMER_ADDED_SUCCESSFULLY'];
                 break;
             case "contactupdated":
                 $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_CUSTOMER_CONTACT_UPDATED_SUCCESSFULLY'];
                 break;
             case "contactadded":
                 $this->_strOkMessage = $_ARRAYLANG['TXT_CRM_CUSTOMER_CONTACT_ADDED_SUCCESSFULLY'];
                 break;
         }
     }
     $settings = $this->getSettings();
     $_GET['type'] = isset($_GET['type']) ? $_GET['type'] : 'customer';
     $redirect = isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : base64_decode('&act=customers');
     $this->_pageTitle = isset($_REQUEST['id']) ? $_ARRAYLANG["TXT_CRM_EDIT_" . strtoupper($_GET['type'])] : $_ARRAYLANG["TXT_CRM_ADD_" . strtoupper($_GET['type'])];
     $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_customer_modify.html');
     $this->_objTpl->setGlobalVariable("MODULE_NAME", $this->moduleName);
     $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     $this->contact = new \Cx\Modules\Crm\Model\Entity\CrmContact();
     !empty($id) ? $this->contact->id = $id : '';
     $contactType = isset($_GET['type']) && $_GET['type'] == 'contact' ? 2 : 1;
     //person
     $this->contact->family_name = isset($_POST['family_name']) ? contrexx_input2raw($_POST['family_name']) : '';
     $this->contact->contact_role = isset($_POST['contact_role']) ? contrexx_input2raw($_POST['contact_role']) : '';
     $this->contact->contact_language = isset($_POST['contact_language']) ? (int) $_POST['contact_language'] : (empty($id) ? $_LANGID : 0);
     $this->contact->contact_customer = isset($_POST['company']) ? (int) $_POST['company'] : (isset($_GET['custId']) ? (int) $_GET['custId'] : 0);
     $this->contact->contactType = $contactType;
     $this->contact->companySize = isset($_POST['companySize']) ? contrexx_input2raw($_POST['companySize']) : 0;
     $this->contact->contact_gender = isset($_POST['contact_gender']) ? (int) $_POST['contact_gender'] : 0;
     $this->contact->emailDelivery = empty($_POST) || isset($_POST['emailDelivery']) ? 1 : 0;
     $accountUserID = isset($_POST['contactId']) ? intVal($_POST['contactId']) : 0;
     $accountUserEmail = isset($_POST['contact_email']) ? contrexx_input2raw($_POST['contact_email']) : '';
     $accountUserPassword = isset($_POST['contact_password']) ? contrexx_input2raw($_POST['contact_password']) : '';
     $sendLoginDetails = isset($_POST['send_account_notification']);
     $this->contact->account_id = 0;
     // customer
     $tpl = isset($_REQUEST['tpl']) ? contrexx_input2db($_REQUEST['tpl']) : '';
     if (isset($_GET['design']) && $_GET['design'] == 'custom') {
         $this->_objTpl->setVariable(array('PM_REMOVE_BACKGROUND_STYLE' => $this->pmRemoveStylesAddcustomer(), 'PM_AJAX_SAVE_FROM_SHADOWBOX_JAVASCRIPT' => $objJs->pmAjaxformSubmitForShadowbox($tpl)));
     }
     $defaultTypeId = $objDatabase->getOne('SELECT `id` FROM ' . DBPREFIX . 'module_' . $this->moduleNameLC . '_customer_types WHERE `default` = 1');
     $this->contact->customerId = isset($_POST['customerId']) ? contrexx_input2raw($_POST['customerId']) : '';
     $this->contact->customerType = isset($_POST['customer_type']) ? (int) $_POST['customer_type'] : (empty($id) ? $defaultTypeId : '');
     $this->contact->customerName = isset($_POST['companyName']) ? contrexx_input2raw($_POST['companyName']) : '';
     $this->contact->addedUser = $objFWUser->objUser->getId();
     $this->contact->currency = isset($_POST['currency']) ? (int) $_POST['currency'] : '';
     $this->contact->datasource = 1;
     $customerContacts = isset($_POST['companyContacts']) ? array_map('intval', (array) $_POST['companyContacts']) : array();
     $assignedMembersShip = isset($_POST['assigned_memberships']) ? array_map('intval', (array) $_POST['assigned_memberships']) : array();
     $this->contact->notes = isset($_POST['notes']) ? contrexx_input2raw($_POST['notes']) : '';
     $this->contact->industryType = isset($_POST['industryType']) ? (int) $_POST['industryType'] : 0;
     $this->contact->user_name = isset($_POST['contact_username']) ? contrexx_input2raw($_POST['contact_username']) : '';
     if (isset($_POST['save_contact']) || isset($_POST['save_add_new_contact'])) {
         $msg = '';
         switch (true) {
             case $contactType == 1 && !empty($id):
                 $msg = "customerupdated";
                 break;
             case $contactType == 2 && !empty($id):
                 $msg = "contactupdated";
                 break;
             case $contactType == 1:
                 $msg = "customeradded";
                 break;
             case $contactType == 2:
                 $msg = "contactadded";
                 break;
             default:
                 break;
         }
         $result = $this->parseContacts($_POST);
         // unset customer type, customerId the contact have customer
         if ($this->contact->contactType == 2 && $this->contact->contact_customer != 0) {
             $this->contact->customerType = 0;
             $this->contact->currency = 0;
             $this->contact->customerId = '';
         }
         $accountMandatory = !empty($accountUserEmail) ? false : !$settings['user_account_mantatory'];
         if (!$settings['create_user_account'] || $contactType == 1 || !empty($accountUserEmail) && $this->addUser($accountUserEmail, $accountUserPassword, $sendLoginDetails, $result, $accountUserID) || $accountMandatory) {
             $this->contact->save();
             $this->updateCustomerMemberships((array) $assignedMembersShip, $this->contact->id);
             if ($contactType == 2) {
                 // For contact
                 //$this->save
             } else {
                 $this->updateCustomerContacts((array) $customerContacts, $this->contact->id);
             }
             // insert Emails
             $objDatabase->Execute("DELETE FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_emails` WHERE `contact_id` = {$this->contact->id}");
             $query = "INSERT INTO `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_emails` (email, email_type, is_primary, contact_id) VALUES ";
             $values = array();
             foreach ($result['contactemail'] as $value) {
                 if (!empty($value['value'])) {
                     $values[] = "('" . contrexx_input2db($value['value']) . "', '" . (int) $value['type'] . "', '" . (int) $value['primary'] . "', '" . $this->contact->id . "')";
                 }
             }
             if (is_array($values) && !empty($values)) {
                 $query .= implode(",", $values);
                 $objDatabase->Execute($query);
             }
             // insert Phone
             $objDatabase->Execute("DELETE FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_phone` WHERE `contact_id` = {$this->contact->id}");
             $query = "INSERT INTO `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_phone` (phone, phone_type, is_primary, contact_id) VALUES ";
             $values = array();
             foreach ($result['contactphone'] as $value) {
                 if (!empty($value['value'])) {
                     $values[] = "('" . contrexx_input2db($value['value']) . "', '" . (int) $value['type'] . "', '" . (int) $value['primary'] . "', '" . $this->contact->id . "')";
                 }
             }
             if (is_array($values) && !empty($values)) {
                 $query .= implode(",", $values);
                 $objDatabase->Execute($query);
             }
             // insert Website
             $assignedWebsites = array();
             foreach ($result['contactwebsite'] as $value) {
                 if (!empty($value['value'])) {
                     $fields = array('url' => contrexx_input2raw($value['value']), 'url_profile' => (int) $value['profile'], 'is_primary' => $value['primary'], 'contact_id' => $this->contact->id);
                     if (!empty($value['id'])) {
                         array_push($assignedWebsites, $value['id']);
                         $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true)) . " WHERE `id` = {$value['id']} AND `contact_id` = {$this->contact->id}";
                         $objDatabase->Execute($query);
                     } else {
                         $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true));
                         $db = $objDatabase->Execute($query);
                         if ($db) {
                             array_push($assignedWebsites, $objDatabase->INSERT_ID());
                         }
                     }
                 }
             }
             $whereWebId = !empty($assignedWebsites) ? " AND `id` NOT IN (" . implode(',', $assignedWebsites) . ")" : "";
             $objDatabase->Execute("DELETE FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites` WHERE `contact_id` = {$this->contact->id} {$whereWebId}");
             // insert social networks
             $assignedSocialNetwork = array();
             foreach ($result['contactsocial'] as $value) {
                 if (!empty($value['value'])) {
                     $fields = array('id' => array('val' => !empty($value['id']) ? (int) $value['id'] : null, 'omitEmpty' => true), 'url' => contrexx_input2raw($value['value']), 'url_profile' => (int) $value['profile'], 'is_primary' => $value['primary'], 'contact_id' => $this->contact->id);
                     if (!empty($value['id'])) {
                         array_push($assignedSocialNetwork, $value['id']);
                         $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_social_network", $fields, array('escape' => true)) . " WHERE `id` = {$value['id']} AND `contact_id` = {$this->contact->id}";
                         $objDatabase->Execute($query);
                     } else {
                         $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_social_network", $fields, array('escape' => true));
                         $db = $objDatabase->Execute($query);
                         if ($db) {
                             array_push($assignedSocialNetwork, $objDatabase->INSERT_ID());
                         }
                     }
                 }
             }
             $whereWebId = !empty($assignedSocialNetwork) ? " AND `id` NOT IN (" . implode(',', $assignedSocialNetwork) . ")" : "";
             $objDatabase->Execute("DELETE FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_social_network` WHERE `contact_id` = {$this->contact->id} {$whereWebId}");
             // insert address
             $objDatabase->Execute("DELETE FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` WHERE `contact_id` = {$this->contact->id}");
             $query = "INSERT INTO `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` (address, city, state, zip, country, Address_Type, is_primary, contact_id) VALUES ";
             $values = array();
             foreach ($result['contactAddress'] as $value) {
                 if (!empty($value['address']) || !empty($value['city']) || !empty($value['state']) || !empty($value['zip']) || !empty($value['country'])) {
                     $values[] = "('" . contrexx_input2db($value['address']) . "', '" . contrexx_input2db($value['city']) . "', '" . contrexx_input2db($value['state']) . "', '" . contrexx_input2db($value['zip']) . "', '" . contrexx_input2db($value['country']) . "', '" . intval($value['type']) . "', '" . intval($value['primary']) . "', '" . $this->contact->id . "')";
                 }
             }
             if (is_array($values) && !empty($values)) {
                 $query .= implode(",", $values);
                 $objDatabase->Execute($query);
             }
             $ChckCount = 0;
             if (!empty($id)) {
                 $contactId = $this->contact->contact_customer;
             }
             if ($this->contact->contactType == 2) {
                 $contactId = $this->contact->contact_customer;
             }
             $customerId = $this->contact->id;
             $customerName = $this->contact->customerName;
             // notify the staff's
             $this->notifyStaffOnContactAccModification($this->contact->id, $this->contact->customerName, $this->contact->family_name, $this->contact->contact_gender);
             // ajax request
             if (isset($_GET['design']) && $_GET['design'] == 'custom') {
                 $returnString = array('errChk' => $ChckCount, 'customerId' => $customerId, 'customerName' => $customerName, 'contactId' => $contactId, 'msg' => $msg);
                 echo json_encode($returnString);
                 exit;
             }
             if (isset($_POST['save_add_new_contact'])) {
                 $contactTypeUrl = $contactType == 2 ? '&type=contact' : '';
                 \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . "&act=customers&tpl=managecontact&mes=" . base64_encode($msg) . $contactTypeUrl);
                 exit;
             }
             \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . "&act=customers&mes=" . base64_encode($msg) . base64_decode($redirect));
             exit;
         } elseif (empty($accountUserEmail)) {
             $this->_strErrMessage = $_ARRAYLANG['TXT_CRM_EMAIL_EMPTY'];
         }
     } elseif ($this->contact->load($id)) {
         if ($contactType == 1) {
             $objContact = $objDatabase->Execute("SELECT `id` FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` WHERE `contact_customer` = {$this->contact->id}");
             if ($objContact) {
                 while (!$objContact->EOF) {
                     $customerContacts[] = (int) $objContact->fields['id'];
                     $objContact->MoveNext();
                 }
             }
         }
         $objMemberShips = $objDatabase->Execute("SELECT `membership_id` FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_membership` WHERE `contact_id` = {$this->contact->id}");
         if ($objMemberShips) {
             while (!$objMemberShips->EOF) {
                 $assignedMembersShip[] = (int) $objMemberShips->fields['membership_id'];
                 $objMemberShips->Movenext();
             }
         }
         // Get emails and phones
         $objEmails = $objDatabase->Execute("SELECT * FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_emails` WHERE contact_id = {$this->contact->id} ORDER BY id ASC");
         if ($objEmails) {
             while (!$objEmails->EOF) {
                 $result['contactemail'][] = array("type" => $objEmails->fields['email_type'], "primary" => $objEmails->fields['is_primary'], "value" => $objEmails->fields['email']);
                 $objEmails->MoveNext();
             }
         }
         $objPhone = $objDatabase->Execute("SELECT * FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_phone` WHERE contact_id = {$this->contact->id} ORDER BY id ASC");
         if ($objPhone) {
             while (!$objPhone->EOF) {
                 $result['contactphone'][] = array("type" => $objPhone->fields['phone_type'], "primary" => $objPhone->fields['is_primary'], "value" => $objPhone->fields['phone']);
                 $objPhone->MoveNext();
             }
         }
         $objWebsite = $objDatabase->Execute("SELECT * FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites` WHERE contact_id = {$this->contact->id} ORDER BY id ASC");
         if ($objWebsite) {
             while (!$objWebsite->EOF) {
                 $result['contactwebsite'][] = array("id" => $objWebsite->fields['id'], "profile" => $objWebsite->fields['url_profile'], "primary" => $objWebsite->fields['is_primary'], "value" => $objWebsite->fields['url']);
                 $objWebsite->MoveNext();
             }
         }
         $objSocial = $objDatabase->Execute("SELECT * FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_social_network` WHERE contact_id = {$this->contact->id} ORDER BY id ASC");
         if ($objSocial) {
             while (!$objSocial->EOF) {
                 $result['contactsocial'][] = array("id" => $objSocial->fields['id'], "profile" => $objSocial->fields['url_profile'], "primary" => $objSocial->fields['is_primary'], "value" => $objSocial->fields['url']);
                 $objSocial->MoveNext();
             }
         }
         $objAddress = $objDatabase->Execute("SELECT * FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` WHERE contact_id = {$this->contact->id} ORDER BY id ASC");
         if ($objAddress) {
             while (!$objAddress->EOF) {
                 $result['contactAddress'][] = array("address" => $objAddress->fields['address'], "city" => $objAddress->fields['city'], "state" => $objAddress->fields['state'], "zip" => $objAddress->fields['zip'], "country" => $objAddress->fields['country'], "type" => $objAddress->fields['Address_Type'], "primary" => $objAddress->fields['is_primary']);
                 $objAddress->MoveNext();
             }
         }
     }
     // reset the email and phone fields
     if (empty($result['contactemail'])) {
         $result['contactemail'][] = array("type" => $contactType == 1 ? 1 : 0, "primary" => 1, "value" => "");
     }
     if (empty($result['contactphone'])) {
         $result['contactphone'][] = array("type" => 1, "primary" => 1, "value" => "");
     }
     if (empty($result['contactwebsite'])) {
         $result['contactwebsite'][] = array("id" => 0, "profile" => $contactType == 1 ? 3 : 1, "primary" => 1, "value" => "");
     }
     if (empty($result['contactsocial'])) {
         $result['contactsocial'][] = array("id" => 0, "profile" => 4, "primary" => 1, "value" => "");
     }
     if (empty($result['contactAddress'])) {
         $result['contactAddress'][] = array("address" => '', "city" => '', "state" => '', "zip" => "", "country" => "", "type" => 2, "primary" => 1);
     }
     if (!empty($result['contactemail'])) {
         $Count = 1;
         //$showEmail = false;
         $showEmail = true;
         foreach ($result['contactemail'] as $email) {
             if (!empty($email['value']) && !$showEmail) {
                 $showEmail = true;
             }
             $this->_objTpl->setVariable(array('CRM_CONTACT_EMAIL_NAME' => "contactemail_{$Count}_{$email['type']}_{$email['primary']}", 'CRM_CONTACT_EMAIL' => contrexx_raw2xhtml($email['value']), 'CRM_EMAIL_OPTION' => $_ARRAYLANG[$this->emailOptions[$email['type']]], 'CRM_CONTACT_EMAIL_PRIMARY' => $email['primary'] ? "primary_field" : "not_primary_field"));
             $block = $contactType == 1 ? "customerEmailContainer" : "contactEmailContainer";
             $this->_objTpl->parse($block);
             $Count++;
         }
     }
     if (!empty($result['contactphone'])) {
         foreach ($result['contactphone'] as $phone) {
             $this->_objTpl->setVariable(array('CRM_CONTACT_PHONE_NAME' => "contactphone_{$Count}_{$phone['type']}_{$phone['primary']}", 'CRM_CONTACT_PHONE' => contrexx_raw2xhtml($phone['value']), 'CRM_PHONE_OPTION' => $_ARRAYLANG[$this->phoneOptions[$phone['type']]], 'CRM_CONTACT_PHONE_PRIMARY' => $phone['primary'] ? "primary_field" : "not_primary_field"));
             $block = $contactType == 1 ? "customerPhoneContainer" : "contactPhoneContainer";
             $this->_objTpl->parse($block);
             $Count++;
         }
     }
     if (!empty($result['contactwebsite'])) {
         foreach ($result['contactwebsite'] as $website) {
             $this->_objTpl->setVariable(array('CRM_CONTACT_WEBSITE_NAME' => "contactwebsite_{$Count}_{$website['profile']}_{$website['primary']}", 'CRM_CONTACT_WEBSITE' => contrexx_raw2xhtml(html_entity_decode($website['value'], ENT_QUOTES, CONTREXX_CHARSET)), 'CRM_WEBSITE_PROFILE' => !empty($this->websiteProfileOptions[$website['profile']]) ? $_ARRAYLANG[$this->websiteProfileOptions[$website['profile']]] : '', 'CRM_WEBSITE_OPTION' => $website['type'] != '' && !empty($this->websiteOptions[$website['type']]) ? $_ARRAYLANG[$this->websiteOptions[$website['type']]] : '', 'CRM_CONTACT_WEB_ID_NAME' => "website_{$Count}", 'CRM_CONTACT_WEB_ID' => (int) $website['id'], 'CRM_CONTACT_WEBSITE_PRIMARY' => $website['primary'] ? "primary_field" : "not_primary_field"));
             $block = $contactType == 1 ? "customerwebsiteContainer" : "contactwebsiteContainer";
             $this->_objTpl->parse($block);
             $Count++;
         }
     }
     if (!empty($result['contactsocial'])) {
         foreach ($result['contactsocial'] as $social) {
             $this->_objTpl->setVariable(array('CRM_CONTACT_SOCIAL_NAME' => "contactsocial_{$Count}_{$social['profile']}_{$social['primary']}", 'CRM_CONTACT_SOCIAL' => contrexx_raw2xhtml(html_entity_decode($social['value'], ENT_QUOTES, CONTREXX_CHARSET)), 'CRM_SOCIAL_PROFILE' => $_ARRAYLANG[$this->socialProfileOptions[$social['profile']]], 'CRM_CONTACT_SOCIAL_ID_NAME' => "social_{$Count}", 'CRM_CONTACT_SOCIAL_ID' => (int) $social['id'], 'CRM_CONTACT_SOCIAL_PRIMARY' => $social['primary'] ? "primary_field" : "not_primary_field"));
             $block = $contactType == 1 ? "customerSocialLinkContainer" : "contactSocialLinkContainer";
             $this->_objTpl->parse($block);
             $Count++;
         }
     }
     if (!empty($result['contactAddress'])) {
         $showAddress = false;
         foreach ($result['contactAddress'] as $address) {
             if (!empty($address['address']) && !$showAddress) {
                 $showAddress = true;
             }
             $primary = $address['primary'] ? 1 : 0;
             $this->_objTpl->setVariable(array('CRM_CONTACT_ADDRESS_NAME' => "contactAddress_{$Count}_1_{$primary}", 'CRM_CONTACT_ADDRESS_VALUE' => contrexx_raw2xhtml($address['address']), 'CRM_CONTACT_CITY_NAME' => "contactAddress_{$Count}_2_{$primary}", 'CRM_CONTACT_CITY_VALUE' => contrexx_raw2xhtml($address['city']), 'CRM_CONTACT_STATE_NAME' => "contactAddress_{$Count}_3_{$primary}", 'CRM_CONTACT_STATE_VALUE' => contrexx_raw2xhtml($address['state']), 'CRM_CONTACT_ZIP_NAME' => "contactAddress_{$Count}_4_{$primary}", 'CRM_CONTACT_ZIP_VALUE' => contrexx_raw2xhtml($address['zip']), 'CRM_CONTACT_COUNTRY_NAME' => "contactAddress_{$Count}_5_{$primary}", 'CRM_CONTACT_COUNTRY_VALUE' => $this->getContactAddressCountry($this->_objTpl, $address['country'], $contactType == 1 ? "customerCrmCountry" : 'crmCountry'), 'CRM_CONTACT_ADDR_TYPE_NAME' => "contactAddress_{$Count}_6_{$primary}", 'CRM_CONTACT_ADDR_TYPE_VALUE' => $this->getContactAddrTypeCountry($this->_objTpl, $address['type'], $contactType == 1 ? "customerAddressType" : 'addressType'), 'CRM_CONTACT_ADDRESS_PRIMARY' => $primary ? "primary_field_address" : "not_primary_field_address"));
             $block = $contactType == 1 ? "customerAddressContainer" : "contactAddressContainer";
             $this->_objTpl->parse($block);
             $Count++;
         }
     }
     $this->getContactAddressCountry($this->_objTpl, '', $contactType == 1 ? "customerAdditionalcrmCountry" : 'additionalcrmCountry');
     $this->getContactAddrTypeCountry($this->_objTpl, 2, $contactType == 1 ? "customerAdditionaladdressType" : 'additionaladdressType');
     // special fields for contacts
     $objResult = $objDatabase->Execute('SELECT  id,name,lang FROM    ' . DBPREFIX . 'languages');
     while (!$objResult->EOF) {
         $this->_objTpl->setVariable(array('TXT_LANG_ID' => (int) $objResult->fields['id'], 'TXT_LANG_NAME' => contrexx_raw2xhtml($objResult->fields['name']), 'TXT_LANG_SELECT' => $objResult->fields['id'] == $this->contact->contact_language ? "selected=selected" : ""));
         $langBlock = $contactType == 2 ? "showAddtionalContactLanguages" : "ContactLanguages";
         $this->_objTpl->parse($langBlock);
         $objResult->MoveNext();
     }
     // special fields for customer
     if ($contactType == 1) {
         $this->getCustomerTypeDropDown($this->_objTpl, $this->contact->customerType, 'customerTypes', array('is_hide' => false));
         // Customer Types
         // Parse the contacts
         if (!empty($customerContacts)) {
             $objContacts = $objDatabase->Execute("SELECT `id`, `customer_name`, `contact_familyname` FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` WHERE `id` IN (" . implode(',', $customerContacts) . ")");
             if ($objContacts) {
                 $row = "row2";
                 while (!$objContacts->EOF) {
                     $this->_objTpl->setVariable(array('CRM_CONTACT_ID' => $objContacts->fields['id'], 'CRM_CONTACT_NAME' => contrexx_raw2xhtml($objContacts->fields['contact_familyname'] . " " . $objContacts->fields['customer_name']), 'ROW_CLASS' => $row = $row == 'row2' ? "row1" : "row2"));
                     $this->_objTpl->parse("customerContacts");
                     $objContacts->MoveNext();
                 }
             }
         }
         $this->_objTpl->setVariable('CRM_CONTACTS_HEADER_CLASS', !empty($customerContacts) ? 'header-collapse' : 'header-expand');
         // parse currency
         $this->getCustomerCurrencyDropDown($this->_objTpl, $this->contact->currency, "currency");
         // parse companysize
         $this->getCompanySizeDropDown($this->_objTpl, $this->contact->companySize, "companySize");
     } else {
         $this->getCustomerTypeDropDown($this->_objTpl, $this->contact->customerType, "contactCustomerTypes", array('is_hide' => false));
         // Customer Types
         $this->getCustomerCurrencyDropDown($this->_objTpl, $this->contact->currency, "contactCurrency");
         // currency
     }
     $memberships = array_keys($this->getMemberships());
     $membershipBlock = $contactType == 1 ? "assignedGroup" : "contactMembership";
     $this->getMembershipDropdown($this->_objTpl, $memberships, $membershipBlock, $assignedMembersShip);
     if (!empty($this->contact->account_id)) {
         $objUser = $objFWUser->objUser->getUser($this->contact->account_id);
         if ($objUser) {
             $accountName = contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objUser));
         }
     } else {
         $objUser = false;
     }
     $this->_objTpl->setVariable(array('CRM_ADDRESS_HEADER_CLASS' => $showAddress ? 'header-collapse' : 'header-expand', 'CRM_ADDRESS_BLOCK_DISPLAY' => $showAddress ? 'table-row-group' : 'none', 'CRM_DESCRIPTION_HEADER_CLASS' => !empty($this->contact->notes) ? 'header-collapse' : 'header-expand', 'CRM_DESCRIPTION_BLOCK_DISPLAY' => !empty($this->contact->notes) ? 'table-row-group' : 'none', 'CRM_MEMBERSHIP_HEADER_CLASS' => !empty($assignedMembersShip) ? 'header-collapse' : 'header-expand', 'CRM_MEMBERSHIP_BLOCK_DISPLAY' => !empty($assignedMembersShip) ? 'table-row-group' : 'none'));
     $this->_objTpl->setGlobalVariable(array('TXT_CON_FAMILY' => contrexx_raw2xhtml($this->contact->family_name), 'TXT_CON_ROLE' => contrexx_raw2xhtml($this->contact->contact_role), 'CRM_INPUT_COUNT' => $Count, 'CRM_CONTACT_COMPANY_ID' => (int) $this->contact->contact_customer, 'CRM_CONTACT_COMPANY' => $this->contact->contact_customer != null ? contrexx_raw2xhtml($objDatabase->getOne("SELECT `customer_name` FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` WHERE id = {$this->contact->contact_customer} ")) : '', 'CRM_CONTACT_NOTES' => contrexx_raw2xhtml($this->contact->notes), 'CRM_INDUSTRY_DROPDOWN' => $this->listIndustryTypes($this->_objTpl, 2, $this->contact->industryType), 'CRM_CUSTOMERID' => contrexx_input2xhtml($this->contact->customerId), 'CRM_COMPANY_NAME' => contrexx_input2xhtml($this->contact->customerName), 'CRM_CONTACT_ID' => $this->contact->id != null ? $this->contact->id : 0, 'CRM_CONTACT_USER_ID' => $this->contact->account_id != null ? $this->contact->account_id : 0, 'CRM_CONTACT_USERNAME' => $objUser ? contrexx_raw2xhtml($objUser->getEmail()) : '', 'CRM_CONTACT_ACCOUNT_USERNAME' => $objUser ? $accountName : ' ', 'CRM_CONTACT_SHOW_PASSWORD' => "style='display: none;'", 'CRM_CONTACT_RANDOM_PASSWORD' => \User::make_password(), 'CRM_GENDER_FEMALE_SELECTED' => $this->contact->contact_gender == 1 ? 'selected' : '', 'CRM_GENDER_MALE_SELECTED' => $this->contact->contact_gender == 2 ? 'selected' : '', 'CRM_CONTACT_TYPE' => $contactType == 1 ? 'company' : 'contact', 'CRM_ACCOUNT_MANTORY' => $settings['create_user_account'] && $settings['user_account_mantatory'] ? '<font color="red">*</font>' : '', 'CRM_ACCOUNT_MANTORY_CLASS' => $settings['create_user_account'] && $settings['user_account_mantatory'] ? 'mantatory' : '', 'CRM_EMAIL_DELIVERY' => $this->contact->emailDelivery ? 'checked="checked"' : '', 'TXT_CRM_EMPLOYEE' => $_ARRAYLANG['TXT_CRM_EMPLOYEE'], 'TXT_CRM_CITY' => $_ARRAYLANG['TXT_CRM_TITLE_CITY'], 'TXT_CRM_STATE' => $_ARRAYLANG['TXT_CRM_STATE'], 'TXT_CRM_ZIP_CODE' => $_ARRAYLANG['TXT_CRM_ZIP_CODE'], 'TXT_CRM_EDITCUSTOMERCONTACT_TITLE' => isset($_REQUEST['id']) ? $_ARRAYLANG["TXT_CRM_EDIT_" . strtoupper($_GET['type'])] : $_ARRAYLANG["TXT_CRM_ADD_" . strtoupper($_GET['type'])], 'TXT_CRM_INDUSTRY_TYPE' => $_ARRAYLANG['TXT_CRM_INDUSTRY_TYPE'], 'TXT_CRM_DATASOURCE' => $_ARRAYLANG['TXT_CRM_DATASOURCE'], 'TXT_CRM_OPTION' => $_ARRAYLANG['TXT_CRM_WORK'], 'TXT_CRM_EMAIL_DEFAULT_OPTION' => $contactType == 1 ? $_ARRAYLANG['TXT_CRM_HOME'] : $_ARRAYLANG['TXT_CRM_WORK'], 'TXT_CRM_PROFILE_OPTION' => $contactType == 1 ? $_ARRAYLANG['TXT_CRM_BUSINESS1'] : $_ARRAYLANG['TXT_CRM_WORK'], 'TXT_CRM_SOCIAL_PROFILE_OPTION' => $_ARRAYLANG['TXT_CRM_FACEBOOK'], 'TXT_CRM_NAME' => $_ARRAYLANG['TXT_CRM_NAME'], 'TXT_CRM_EMAIL' => $_ARRAYLANG['TXT_CRM_EMAIL'], 'TXT_CRM_PHONE' => $_ARRAYLANG['TXT_CRM_PHONE'], 'TXT_CRM_TITLE_LANGUAGE' => $_ARRAYLANG['TXT_CRM_TITLE_LANGUAGE'], 'TXT_CRM_ROLE' => $_ARRAYLANG['TXT_CRM_ROLE'], 'TXT_CRM_FAMILY_NAME' => $_ARRAYLANG['TXT_CRM_FAMILY_NAME'], 'TXT_CRM_TITLE_SELECT_LANGUAGE' => $_ARRAYLANG['TXT_CRM_TITLE_SELECT_LANGUAGE'], 'TXT_CRM_HOME' => $_ARRAYLANG['TXT_CRM_HOME'], 'TXT_CRM_WORK' => $_ARRAYLANG['TXT_CRM_WORK'], 'TXT_CRM_BUSINESS1' => $_ARRAYLANG['TXT_CRM_BUSINESS1'], 'TXT_CRM_BUSINESS2' => $_ARRAYLANG['TXT_CRM_BUSINESS2'], 'TXT_CRM_BUSINESS3' => $_ARRAYLANG['TXT_CRM_BUSINESS3'], 'TXT_CRM_PRIVATE' => $_ARRAYLANG['TXT_CRM_PRIVATE'], 'TXT_CRM_OTHERS' => $_ARRAYLANG['TXT_CRM_OTHERS'], 'TXT_CRM_MOBILE' => $_ARRAYLANG['TXT_CRM_MOBILE'], 'TXT_CRM_FAX' => $_ARRAYLANG['TXT_CRM_FAX'], 'TXT_CRM_DIRECT' => $_ARRAYLANG['TXT_CRM_DIRECT'], 'TXT_CRM_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_DESCRIPTION'], 'TXT_COMPANY_NAME' => $_ARRAYLANG['TXT_CRM_TITLE_COMPANY_NAME'], 'TXT_CRM_WEBSITE_SOCIAL_NETWORK' => $_ARRAYLANG['TXT_CRM_WEBSITE_SOCIAL_NETWORK'], 'TXT_CRM_WEBSITE' => $_ARRAYLANG['TXT_CRM_WEBSITE'], 'TXT_CRM_SKYPE' => $_ARRAYLANG['TXT_CRM_SKYPE'], 'TXT_CRM_TWITTER' => $_ARRAYLANG['TXT_CRM_TWITTER'], 'TXT_CRM_LINKEDIN' => $_ARRAYLANG['TXT_CRM_LINKEDIN'], 'TXT_CRM_FACEBOOK' => $_ARRAYLANG['TXT_CRM_FACEBOOK'], 'TXT_CRM_LIVEJOURNAL' => $_ARRAYLANG['TXT_CRM_LIVEJOURNAL'], 'TXT_CRM_MYSPACE' => $_ARRAYLANG['TXT_CRM_MYSPACE'], 'TXT_CRM_GMAIL' => $_ARRAYLANG['TXT_CRM_GMAIL'], 'TXT_CRM_BLOGGER' => $_ARRAYLANG['TXT_CRM_BLOGGER'], 'TXT_CRM_YAHOO' => $_ARRAYLANG['TXT_CRM_YAHOO'], 'TXT_CRM_MSN' => $_ARRAYLANG['TXT_CRM_MSN'], 'TXT_CRM_ICQ' => $_ARRAYLANG['TXT_CRM_ICQ'], 'TXT_CRM_JABBER' => $_ARRAYLANG['TXT_CRM_JABBER'], 'TXT_CRM_AIM' => $_ARRAYLANG['TXT_CRM_AIM'], 'TXT_CRM_GOOGLE_PLUS' => $_ARRAYLANG['TXT_CRM_GOOGLE_PLUS'], 'TXT_CRM_XING' => $_ARRAYLANG['TXT_CRM_XING'], 'TXT_CRM_ADDRESS' => $_ARRAYLANG['TXT_CRM_TITLE_ADDRESS'], 'TXT_CRM_SELECT_COUNTRY' => $_ARRAYLANG['TXT_CRM_SELECT_COUNTRY'], 'TXT_CRM_OVERVIEW' => $_ARRAYLANG['TXT_CRM_OVERVIEW'], 'TXT_CRM_ARE_YOU_SURE_DELETE_ENTRIES' => $_ARRAYLANG['TXT_CRM_ARE_YOU_SURE_DELETE_ENTRIES'], 'TXT_CRM_ARE_YOU_SURE_DELETE_SELECTED_ENTRIES' => $_ARRAYLANG['TXT_CRM_ARE_YOU_SURE_DELETE_SELECTED_ENTRIES'], 'TXT_CRM_ACCOUNT_EMAIL' => $_ARRAYLANG['TXT_CRM_ACCOUNT_EMAIL'], 'TXT_CRM_ACCOUNT_PASSWORD' => $_ARRAYLANG['TXT_CRM_ACCOUNT_PASSWORD'], 'TXT_CRM_SEND_LOGIN_DETAILS' => $_ARRAYLANG['TXT_CRM_SEND_LOGIN_DETAILS'], 'TXT_CRM_CHOOSE_MEMBERSHIPS' => $_ARRAYLANG['TXT_CRM_CHOOSE_MEMBERSHIPS'], 'TXT_CRM_EMAIL_DELIVERY' => $_ARRAYLANG['TXT_CRM_EMAIL_DELIVERY'], 'TXT_CRM_COMPANY_NAME' => $_ARRAYLANG['TXT_CRM_TITLE_COMPANY_NAME'], 'TXT_CRM_CUSTOMERTYPE' => $_ARRAYLANG['TXT_CRM_TITLE_CUSTOMERTYPE'], 'TXT_CRM_SOCIAL_NETWORK' => $_ARRAYLANG['TXT_CRM_SOCIAL_NETWORK'], 'TXT_CRM_GENDER' => $_ARRAYLANG['TXT_CRM_GENDER'], 'TXT_CRM_NOT_SPECIFIED' => $_ARRAYLANG['TXT_CRM_NOT_SPECIFIED'], 'TXT_CRM_GENDER_MALE' => $_ARRAYLANG['TXT_CRM_GENDER_MALE'], 'TXT_CRM_GENDER_FEMALE' => $_ARRAYLANG['TXT_CRM_GENDER_FEMALE'], 'TXT_CRM_CUSTOMERID' => $_ARRAYLANG['TXT_CRM_TITLE_CUSTOMERID'], 'TXT_CRM_CURRENCY' => $_ARRAYLANG['TXT_CRM_TITLE_CURRENCY'], 'TXT_CRM_COMPANY_SIZE' => $_ARRAYLANG['TXT_CRM_COMPANY_SIZE'], 'TXT_CRM_PLEASE_SELECT' => $_ARRAYLANG['TXT_CRM_PLEASE_SELECT'], 'TXT_CRM_GENERAL_INFORMATION' => $_ARRAYLANG['TXT_CRM_GENERAL_INFORMATION'], 'TXT_CRM_PROFILE_INFORMATION' => $_ARRAYLANG['TXT_CRM_PROFILE_INFORMATION'], 'TXT_CRM_ALL_PERSONS' => $_ARRAYLANG['TXT_CRM_ALL_PERSONS'], 'TXT_CRM_ADD_CONTACT' => $_ARRAYLANG['TXT_CRM_ADD_OR_LINK_CONTACT'], 'TXT_CRM_ENTER_WEBSITE' => $_ARRAYLANG['TXT_CRM_ENTER_WEBSITE'], 'TXT_CRM_WEBSITE_NAME' => $_ARRAYLANG['TXT_CRM_WEBSITE_NAME'], 'TXT_CRM_FUNCTIONS' => $_ARRAYLANG['TXT_CRM_FUNCTIONS'], 'TXT_CRM_SELECT_FROM_CONTACTS' => $_ARRAYLANG['TXT_CRM_SELECT_FROM_CONTACTS'], 'TXT_CRM_NO_MATCHES' => $_ARRAYLANG['TXT_CRM_NO_MATCHES'], 'TXT_CRM_ADD_NEW' => $_ARRAYLANG['TXT_CRM_ADD_NEW'], 'TXT_CANCEL' => $_ARRAYLANG['TXT_CANCEL'], 'TXT_CRM_WEBSITE' => $_ARRAYLANG['TXT_CRM_WEBSITE'], 'TXT_CRM_ADD_WEBSITE' => $_ARRAYLANG['TXT_CRM_ADD_WEBSITE'], 'TXT_CRM_PLEASE_SELECT' => $_ARRAYLANG['TXT_CRM_PLEASE_SELECT'], 'TXT_CRM_WEBSITES' => $_ARRAYLANG['TXT_CRM_WEBSITES'], 'BTN_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], 'TXT_CRM_ADD_NEW_CUSTOMER' => $_ARRAYLANG['TXT_CRM_ADD_NEW_CUSTOMER'], 'TXT_CRM_ADD_NEW_CONTACT' => $_ARRAYLANG['TXT_CRM_ADD_NEW_CONTACT'], 'TXT_CRM_PROFILE' => $_ARRAYLANG['TXT_CRM_PROFILE'], 'TXT_CRM_ACCOUNT' => $_ARRAYLANG['TXT_CRM_ACCOUNT'], 'TXT_CORE_SEARCH_USER' => $_ARRAYLANG['TXT_CORE_SEARCH_USER'], 'TXT_CRM_ADVANCED_OPTIONS' => $_ARRAYLANG['TXT_CRM_ADVANCED_OPTIONS'], 'TXT_CRM_MEMBERSHIP' => $_ARRAYLANG['TXT_CRM_MEMBERSHIP'], 'TXT_CRM_ADD_NEW_ACCOUNT' => $_ARRAYLANG['TXT_CRM_ADD_NEW_ACCOUNT'], 'TXT_CRM_FIND_CONTACT_BY_NAME' => $_ARRAYLANG['TXT_CRM_FIND_CONTACT_BY_NAME'], 'TXT_CRM_FIND_COMPANY_BY_NAME' => $_ARRAYLANG['TXT_CRM_FIND_COMPANY_BY_NAME'], 'TXT_CRM_SAVE_CONTACT' => $contactType == 2 ? $_ARRAYLANG['TXT_CRM_SAVE_PERSON'] : $_ARRAYLANG['TXT_CRM_SAVE_COMPANY'], 'TXT_CRM_SAVE_AND_ADD_NEW_CONTACT' => $contactType == 2 ? $_ARRAYLANG['TXT_CRM_SAVE_AND_ADD_NEW_PERSON'] : $_ARRAYLANG['TXT_CRM_SAVE_AND_ADD_NEW_COMPANY'], 'TXT_CRM_SELECT_CUSTOMER_WATERMARK' => $this->contact->customerName == null ? 'crm-watermark' : '', 'COMPANY_MENU_ACTIVE' => $contactType == 1 ? 'active' : '', 'CONTACT_MENU_ACTIVE' => $contactType == 2 ? 'active' : '', 'CRM_REDIRECT_LINK' => $redirect));
     if ($contactType == 2) {
         // If contact type eq to `contact`
         if ($settings['create_user_account']) {
             $this->_objTpl->touchBlock("contactUserName");
             $this->_objTpl->touchBlock("contactPassword");
             $this->_objTpl->touchBlock("show-account-details");
             $this->_objTpl->touchBlock("contactSendNotification");
         } else {
             $this->_objTpl->hideBlock("contactUserName");
             $this->_objTpl->hideBlock("contactPassword");
             $this->_objTpl->hideBlock("show-account-details");
             $this->_objTpl->touchBlock("emptyContactUserName");
             $this->_objTpl->touchBlock("emptyContactPassword");
         }
         $this->_objTpl->parse("contactBlock");
         $this->_objTpl->hideBlock("customerBlock");
         $this->_objTpl->hideBlock("customerAdditionalBlock");
         $this->_objTpl->touchBlock("contactWebsiteOptions");
         $this->_objTpl->hideBlock("companyWebsiteOptions");
     } else {
         $this->_objTpl->parse("customerBlock");
         $this->_objTpl->parse("customerAdditionalBlock");
         $this->_objTpl->hideBlock("contactBlock");
         $this->_objTpl->touchBlock("companyWebsiteOptions");
         $this->_objTpl->hideBlock("contactWebsiteOptions");
     }
 }
コード例 #6
0
 public function showOrders()
 {
     global $_ARRAYLANG;
     $term = isset($_GET['filter-term']) ? contrexx_input2raw($_GET['filter-term']) : '';
     $filterUserId = isset($_GET['filter-user-id']) ? contrexx_input2raw($_GET['filter-user-id']) : 0;
     $objFilterUser = null;
     if (!empty($term) || !empty($filterUserId)) {
         if ($filterUserId) {
             $objFilterUser = \FWUser::getFWUserObject()->objUser->getUser($filterUserId);
         }
         $orders = $this->orderRepository->findOrdersBySearchTerm($term, $objFilterUser);
     } else {
         $orders = $this->orderRepository->getAllByDesc();
     }
     $orders = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($orders);
     // setDataType is used to make the ViewGenerator load the proper options if $orders is empty
     $orders->setDataType('Cx\\Modules\\Order\\Model\\Entity\\Order');
     $options = $this->getController('Backend')->getAllViewGeneratorOptions();
     $view = new \Cx\Core\Html\Controller\ViewGenerator($orders, $options);
     if (isset($_GET['editid']) && !empty($_GET['editid']) || isset($_GET['add']) && !empty($_GET['add'])) {
         $this->template->hideBlock("order_filter");
     } else {
         \FWUser::getUserLiveSearch(array('minLength' => 1, 'canCancel' => true, 'canClear' => true));
         $this->template->setVariable(array('TXT_MODULE_ORDER_SEARCH' => $_ARRAYLANG['TXT_MODULE_ORDER_SEARCH'], 'TXT_MODULE_ORDER_FILTER' => $_ARRAYLANG['TXT_MODULE_ORDER_FILTER'], 'TXT_MODULE_ORDER_SEARCH_TERM' => $_ARRAYLANG['TXT_MODULE_ORDER_SEARCH_TERM'], 'ORDER_SEARCH_VALUE' => isset($_GET['filter-term']) ? contrexx_input2xhtml($_GET['filter-term']) : '', 'ORDER_USER_ID' => contrexx_raw2xhtml($filterUserId), 'ORDER_USER_NAME' => $objFilterUser ? contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objFilterUser)) : ''));
     }
     $this->template->setVariable('ORDERS_CONTENT', $view->render());
 }