function getHomeTopNews($catId = 0)
 {
     global $_CORELANG, $objDatabase;
     $catId = intval($catId);
     $i = 0;
     $this->_objTemplate->setTemplate($this->_pageContent, true, true);
     if ($this->_objTemplate->blockExists('newsrow')) {
         $this->_objTemplate->setCurrentBlock('newsrow');
     } else {
         return null;
     }
     $newsLimit = intval($this->arrSettings['news_top_limit']);
     if ($newsLimit > 50) {
         //limit to a maximum of 50 news
         $newsLimit = 50;
     }
     if ($newsLimit < 1) {
         //do not get any news if 0 was specified as the limit.
         $objResult = false;
     } else {
         //fetch news
         $objResult = $objDatabase->SelectLimit("\n                SELECT DISTINCT(tblN.id) AS id,\n                       tblN.`date`, \n                       tblN.teaser_image_path,\n                       tblN.teaser_image_thumbnail_path,\n                       tblN.redirect,\n                       tblN.publisher,\n                       tblN.publisher_id,\n                       tblN.author,\n                       tblN.author_id,\n                       tblL.title AS title, \n                       tblL.teaser_text\n                  FROM " . DBPREFIX . "module_news AS tblN\n            INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n            INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n                  WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n                   AND tblN.teaser_only='0'\n                   AND tblL.lang_id=" . FRONTEND_LANG_ID . "\n                   AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n                   AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid=" . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . "ORDER BY\n                       (SELECT COUNT(*) FROM " . DBPREFIX . "module_news_stats_view WHERE news_id=tblN.id AND time>'" . date_format(date_sub(date_create('now'), date_interval_create_from_date_string(intval($this->arrSettings['news_top_days']) . ' day')), 'Y-m-d H:i:s') . "') DESC", $newsLimit);
     }
     if ($objResult !== false && $objResult->RecordCount()) {
         while (!$objResult->EOF) {
             $newsid = $objResult->fields['id'];
             $newstitle = $objResult->fields['title'];
             $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
             $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
             $newsCategories = $this->getCategoriesByNewsId($newsid);
             $newsUrl = empty($objResult->fields['redirect']) ? \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect'];
             $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
             list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
             $this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher)));
             if (!empty($image)) {
                 $this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage));
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->parse('news_image');
                 }
             } else {
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->hideBlock('news_image');
                 }
             }
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
             $this->_objTemplate->parseCurrentBlock();
             $i++;
             $objResult->MoveNext();
         }
     } else {
         $this->_objTemplate->hideBlock('newsrow');
     }
     $this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']);
     return $this->_objTemplate->get();
 }
 function getHomeHeadlines($catId = 0)
 {
     global $_CORELANG, $objDatabase, $_LANGID;
     $i = 0;
     $catId = intval($catId);
     $this->_objTemplate->setTemplate($this->_pageContent, true, true);
     $newsLimit = intval($this->arrSettings['news_headlines_limit']);
     if ($newsLimit > 50) {
         //limit to a maximum of 50 news
         $newsLimit = 50;
     }
     if ($newsLimit < 1) {
         //do not get any news if 0 was specified as the limit.
         $objResult = false;
     } else {
         //fetch news
         $objResult = $objDatabase->SelectLimit("\n                SELECT DISTINCT(tblN.id) AS id,\n                       tblN.`date`, \n                       tblN.teaser_image_path,\n                       tblN.teaser_image_thumbnail_path,\n                       tblN.redirect,\n                       tblN.publisher,\n                       tblN.publisher_id,\n                       tblN.author,\n                       tblN.author_id,\n                       tblL.text NOT REGEXP '^(<br type=\"_moz\" />)?\$' AS newscontent,\n                       tblL.title AS title, \n                       tblL.teaser_text\n                  FROM " . DBPREFIX . "module_news AS tblN\n            INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n            INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n                  WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n                   AND tblN.teaser_only='0'\n                   AND tblL.lang_id=" . $_LANGID . "\n                   AND tblL.is_active=1\n                   AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n                   AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid=" . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . "ORDER BY date DESC", $newsLimit);
     }
     if ($objResult !== false && $objResult->RecordCount() >= 0) {
         while (!$objResult->EOF) {
             $newsid = $objResult->fields['id'];
             $newstitle = $objResult->fields['title'];
             $newsCategories = $this->getCategoriesByNewsId($newsid);
             $newsUrl = empty($objResult->fields['redirect']) ? empty($objResult->fields['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect'];
             $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle), 'headlineLink');
             $htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
             // in case that the message is a stub, we shall just display the news title instead of a html-a-tag with no href target
             if (empty($htmlLinkTitle)) {
                 $htmlLinkTitle = contrexx_raw2xhtml($newstitle);
             }
             list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
             $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
             $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
             $this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK_TITLE' => $htmlLinkTitle, 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'HEADLINE_ID' => $newsid, 'HEADLINE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'HEADLINE_TEXT' => nl2br($objResult->fields['teaser_text']), 'HEADLINE_LINK' => $htmlLinkTitle, 'HEADLINE_AUTHOR' => contrexx_raw2xhtml($author)));
             if (!empty($image)) {
                 $this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage, 'HEADLINE_IMAGE_PATH' => contrexx_raw2xhtml($objResult->fields['teaser_image_path']), 'HEADLINE_THUMBNAIL_PATH' => contrexx_raw2xhtml($imageSource)));
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->parse('news_image');
                 }
             } else {
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->hideBlock('news_image');
                 }
             }
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
             $this->_objTemplate->parse('headlines_row');
             $i++;
             $objResult->MoveNext();
         }
     } else {
         $this->_objTemplate->hideBlock('headlines_row');
     }
     $this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']);
     return $this->_objTemplate->get();
 }
Exemple #3
0
 private function user(&$metaPageTitle, &$pageTitle)
 {
     global $_CONFIG;
     $objFWUser = \FWUser::getFWUserObject();
     $objUser = $objFWUser->objUser->getUser(!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
     if ($objUser) {
         if ($objUser->getProfileAccess() != 'everyone') {
             if (!$objFWUser->objUser->login()) {
                 \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . CONTREXX_DIRECTORY_INDEX . '?section=Login&redirect=' . base64_encode(ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . '?section=Access&cmd=user&id=' . $objUser->getId()));
                 exit;
             }
             if ($objUser->getId() != $objFWUser->objUser->getId() && $objUser->getProfileAccess() == 'nobody' && !$objFWUser->objUser->getAdminStatus()) {
                 \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . CONTREXX_DIRECTORY_INDEX . '?section=Login&cmd=noaccess&redirect=' . base64_encode(ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . '?section=Access&cmd=user&id=' . $objUser->getId()));
                 exit;
             }
         }
         $metaPageTitle = \FWUser::getParsedUserTitle($objUser);
         $pageTitle = contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objUser));
         $this->_objTpl->setGlobalVariable(array('ACCESS_USER_ID' => $objUser->getId(), 'ACCESS_USER_USERNAME' => contrexx_raw2xhtml($objUser->getUsername()), 'ACCESS_USER_PRIMARY_GROUP' => contrexx_raw2xhtml($objUser->getPrimaryGroupName())));
         if ($objUser->getEmailAccess() == 'everyone' || $objFWUser->objUser->login() && ($objUser->getId() == $objFWUser->objUser->getId() || $objUser->getEmailAccess() == 'members_only' || $objFWUser->objUser->getAdminStatus())) {
             $this->parseAccountAttribute($objUser, 'email');
         } elseif ($this->_objTpl->blockExists('access_user_email')) {
             $this->_objTpl->hideBlock('access_user_email');
         }
         $nr = 0;
         while (!$objUser->objAttribute->EOF) {
             $objAttribute = $objUser->objAttribute->getById($objUser->objAttribute->getId());
             $this->parseAttribute($objUser, $objAttribute->getId(), 0, false, false, false, false, true, array('_CLASS' => $nr % 2 + 1)) ? $nr++ : false;
             $objUser->objAttribute->next();
         }
         $this->_objTpl->setVariable("ACCESS_REFERER", $_SERVER['HTTP_REFERER']);
     } else {
         // or would it be better to redirect to the home page?
         \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Access&cmd=members');
         exit;
     }
 }
 /**
  * This function returns the ViewGeneration options for a given entityClass
  *
  * @access protected
  * @global $_ARRAYLANG
  * @param $entityClassName contains the FQCN from entity
  * @return array with options
  */
 protected function getViewGeneratorOptions($entityClassName)
 {
     global $_ARRAYLANG;
     $classNameParts = explode('\\', $entityClassName);
     $classIdentifier = end($classNameParts);
     $langVarName = 'TXT_' . strtoupper($this->getType() . '_' . $this->getName() . '_ACT_' . $classIdentifier);
     $header = '';
     if (isset($_ARRAYLANG[$langVarName])) {
         $header = $_ARRAYLANG[$langVarName];
     }
     switch ($entityClassName) {
         case 'Cx\\Modules\\Order\\Model\\Entity\\Order':
             return 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();
                     if (!$productEntity) {
                         continue;
                     }
                     $productEntityName = $subscription->getProduct()->getName();
                     $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);
             }))));
             break;
         case 'Cx\\Modules\\Order\\Model\\Entity\\Subscription':
             return array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_ACT_SUBSCRIPTION'], 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false), 'fields' => array('id' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_ID']), 'subscriptionDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_DATE']), 'expirationDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_EXPIRATION_DATE']), 'productEntityId' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PRODUCT_ENTITY'], 'table' => array('parse' => function ($value, $rowData) {
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $productEntity = $subscription->getProductEntity();
                 if (!$productEntity) {
                     return;
                 }
                 $productEditLink = $productEntity;
                 if (method_exists($productEntity, 'getEditLink')) {
                     $productEditLink = $productEntity->getEditLink();
                 }
                 return $productEditLink;
             })), 'paymentAmount' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PAYMENT_AMOUNT'], 'table' => array('parse' => function ($value, $rowData) {
                 if (\FWValidator::isEmpty(floatval($value))) {
                     return null;
                 }
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $currency = '';
                 $order = $subscription->getOrder();
                 if ($order) {
                     $currency = !\FWValidator::isEmpty($order->getCurrency()) ? $order->getCurrency() : '';
                 }
                 $paymentInterval = $subscription->getRenewalUnit();
                 return $value . ' ' . $currency . ' / ' . $paymentInterval;
             })), 'renewalUnit' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_RENEWAL_UNIT'], 'table' => array('parse' => function ($value, $rowData) {
                 if (empty($value)) {
                     return null;
                 }
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $renewalDate = '';
                 if ($subscription->getRenewalDate()) {
                     $renewalDate = $subscription->getRenewalDate();
                     $quantifier = $subscription->getRenewalQuantifier();
                     $renewalDate->modify("-{$quantifier} {$value}");
                     return $renewalDate->format('d.M.Y H:i:s');
                 }
                 return $renewalDate;
             })), 'renewalQuantifier' => array('showOverview' => false), 'renewalDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_RENEWAL_DATE']), 'description' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_DESCRIPTION']), 'state' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_STATE']), 'terminationDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_TERMI_DATE']), 'note' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_NOTE']), 'product' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PRODUCT'], 'table' => array('parse' => function ($value, $rowData) {
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $product = $subscription->getProduct();
                 if (!$product) {
                     return;
                 }
                 return $product->getName();
             })), 'paymentState' => array('showOverview' => false), 'externalSubscriptionId' => array('showOverview' => false), 'order' => array('showOverview' => false)));
             break;
         default:
             return array('header' => $header, 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false));
     }
 }
 /**
  * notify the staffs regarding the account modification of a contact
  *
  * @param Integer $customerId    customer id
  * @param String  $first_name customer first name
  * @param String  $last_name customer last name
  *
  * @access public
  * @global object $objTemplate
  * @global array  $_ARRAYLANG
  *
  * @return null
  */
 public function notifyStaffOnContactAccModification($customerId = 0, $first_name = '', $last_name = '', $gender = 0)
 {
     global $objDatabase, $_ARRAYLANG;
     if (empty($customerId)) {
         return false;
     }
     $objFWUser = \FWUser::getFWUserObject();
     $settings = $this->getSettings();
     $resources = $this->getResources($settings['emp_default_user_group']);
     $customer_name = $first_name . " " . $last_name;
     $contact_gender = $gender == 1 ? "gender_female" : ($gender == 2 ? "gender_male" : 'gender_undefined');
     $emailIds = array();
     foreach ($resources as $key => $value) {
         $emailIds[] = $value['email'];
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     foreach ($emailIds as $emails) {
         if (!empty($emails)) {
             $objUsers = $objFWUser->objUser->getUsers($filter = array('email' => addslashes($emails)));
             $info['substitution'] = array('CRM_ASSIGNED_USER_NAME' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objUsers->getId())), 'CRM_ASSIGNED_USER_EMAIL' => $emails, 'CRM_CONTACT_FIRSTNAME' => contrexx_raw2xhtml($first_name), 'CRM_CONTACT_LASTNAME' => contrexx_raw2xhtml($last_name), 'CRM_CONTACT_GENDER' => contrexx_raw2xhtml($contact_gender), 'CRM_DOMAIN' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath(), 'CRM_CONTACT_DETAILS_URL' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=customers&tpl=showcustdetail&id={$customerId}", 'CRM_CONTACT_DETAILS_LINK' => "<a href='" . ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=customers&tpl=showcustdetail&id={$customerId}'>" . $customer_name . "</a>");
             //setting email template lang id
             $availableMailTempLangAry = $this->getActiveEmailTemLangId('Crm', CRM_EVENT_ON_ACCOUNT_UPDATED);
             $availableLangId = $this->getEmailTempLang($availableMailTempLangAry, $emails);
             $info['lang_id'] = $availableLangId;
             $dispatcher = CrmEventDispatcher::getInstance();
             $dispatcher->triggerEvent(CRM_EVENT_ON_ACCOUNT_UPDATED, null, $info);
         }
     }
 }
Exemple #6
0
 /**
  * Get a list of all news messages sorted by year and month.
  *
  * @access  private
  * @return  string      parsed content
  */
 private function getArchive()
 {
     global $objDatabase, $_ARRAYLANG;
     $categories = '';
     $i = 0;
     if ($categories = substr($_REQUEST['cmd'], 7)) {
         $categories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories(explode(',', $categories)));
     }
     $monthlyStats = $this->getMonthlyNewsStats($categories);
     if (!empty($monthlyStats)) {
         foreach ($monthlyStats as $key => $value) {
             $this->_objTpl->setVariable(array('NEWS_ARCHIVE_MONTH_KEY' => $key, 'NEWS_ARCHIVE_MONTH_NAME' => $value['name'], 'NEWS_ARCHIVE_MONTH_COUNT' => count($value['news'])));
             $this->_objTpl->parse('news_archive_months_list_item');
             foreach ($value['news'] as $news) {
                 $newsid = $news['id'];
                 $newstitle = $news['newstitle'];
                 $newsCategories = $this->getCategoriesByNewsId($newsid);
                 $newsCommentActive = $news['commentactive'];
                 $newsUrl = empty($news['newsredirect']) ? empty($news['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), $categories)), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $news['newsredirect'];
                 $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]'));
                 list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($news['teaser_image_path'], $news['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
                 $author = \FWUser::getParsedUserTitle($news['author_id'], $news['author']);
                 $publisher = \FWUser::getParsedUserTitle($news['publisher_id'], $news['publisher']);
                 $objResult = $objDatabase->Execute('SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $newsid);
                 $this->_objTpl->setVariable(array('NEWS_ARCHIVE_ID' => $newsid, 'NEWS_ARCHIVE_CSS' => 'row' . ($i % 2 + 1), 'NEWS_ARCHIVE_TEASER' => nl2br($news['teaser_text']), 'NEWS_ARCHIVE_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_LONG_DATE' => date(ASCMS_DATE_FORMAT, $news['newsdate']), 'NEWS_ARCHIVE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $news['newsdate']), 'NEWS_ARCHIVE_TIME' => date(ASCMS_DATE_FORMAT_TIME, $news['newsdate']), 'NEWS_ARCHIVE_LINK_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_LINK' => $htmlLink, 'NEWS_ARCHIVE_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_ARCHIVE_CATEGORY' => stripslashes($news['name']), 'NEWS_ARCHIVE_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_ARCHIVE_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_ARCHIVE_COUNT_COMMENTS' => contrexx_raw2xhtml($objResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS'])));
                 if (!$newsCommentActive || !$this->arrSettings['news_comments_activated']) {
                     if ($this->_objTpl->blockExists('news_archive_comments_count')) {
                         $this->_objTpl->hideBlock('news_archive_comments_count');
                     }
                 }
                 if (!empty($image)) {
                     $this->_objTpl->setVariable(array('NEWS_ARCHIVE_IMAGE' => $image, 'NEWS_ARCHIVE_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_ARCHIVE_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_IMAGE_LINK' => $htmlLinkImage));
                     if ($this->_objTpl->blockExists('news_archive_image')) {
                         $this->_objTpl->parse('news_archive_image');
                     }
                 } elseif ($this->_objTpl->blockExists('news_archive_image')) {
                     $this->_objTpl->hideBlock('news_archive_image');
                 }
                 self::parseImageBlock($this->_objTpl, $news['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'archive_image_thumbnail');
                 self::parseImageBlock($this->_objTpl, $news['teaser_image_path'], $newstitle, $newsUrl, 'archive_image_detail');
                 $this->_objTpl->parse('news_archive_link');
                 $i++;
             }
             $this->_objTpl->setVariable(array('NEWS_ARCHIVE_MONTH_KEY' => $key, 'NEWS_ARCHIVE_MONTH_NAME' => $value['name']));
             $this->_objTpl->parse('news_archive_month_list_item');
         }
         $this->_objTpl->parse('news_archive_months_list');
         $this->_objTpl->parse('news_archive_month_list');
         if ($this->_objTpl->blockExists('news_archive_status_message')) {
             $this->_objTpl->hideBlock('news_archive_status_message');
         }
     } else {
         $this->_objTpl->setVariable('TXT_NEWS_NO_NEWS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_NEWS_FOUND']);
         if ($this->_objTpl->blockExists('news_archive_status_message')) {
             $this->_objTpl->parse('news_archive_status_message');
         }
         $this->_objTpl->hideblock('news_archive_months_list');
         $this->_objTpl->hideBlock('news_archive_month_list');
     }
     return $this->_objTpl->get();
 }
 /**
  * Parsing the related News
  *
  * @global object $objDatabase
  * @global type   $_ARRAYLANG
  *
  * @param Object    $objTpl     Template Object
  * @param Interger  $newsId     News Id
  * @param Interger  $langId     Language id
  * @param type      $blockName  Block Name
  * @param type      $limit      Limit
  *
  * @return null
  */
 public function parseRelatedNews(\Cx\Core\Html\Sigma $objTpl, $newsId = null, $langId = null, $blockName = 'related_news', $limit = 0)
 {
     global $_ARRAYLANG, $objDatabase;
     if (empty($newsId) || !$objTpl->blockExists($blockName)) {
         return;
     }
     //Getting the related news ids
     $relatedNewsIds = $this->getRelatedNews($newsId);
     $defaultLangId = \FWLanguage::getDefaultLangId();
     //Getting the related news details for the given languages
     $relatedNewsDetails = $this->getRelatedNewsDetails($relatedNewsIds, array($langId, $defaultLangId));
     if (!empty($relatedNewsDetails)) {
         $defaultImage = \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/News/View/Media/default_news_image.png';
         $currentCount = 1;
         foreach ($relatedNewsIds as $relatedNewsId) {
             //If the limit is reached then the loop is stopped
             if (!empty($limit) && $currentCount > $limit) {
                 break;
             }
             /*
              * Checking the related news is available in the current
              * acitve front-end language if not available then the default
              * language details are getting used
              * Comment/Uncomment the following line if this condition
              * is required
              */
             //$currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId])
             //    ? $relatedNewsDetails[$relatedNewsId][$langId]
             //    : $relatedNewsDetails[$relatedNewsId][$defaultLangId];
             /*
              * Checking the related news is available in the current
              * acitve front-end language if not available then the related
              * News not listed Comment/Uncomment the following
              * line if this condition is required
              */
             $currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) ? $relatedNewsDetails[$relatedNewsId][$langId] : false;
             if (!$currentRelatedDetails) {
                 continue;
             }
             ++$currentCount;
             $categories = $this->getCategoriesByNewsId($relatedNewsId);
             $newsUrl = empty($currentRelatedDetails['redirect']) ? empty($currentRelatedDetails['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('news', $this->findCmdById('details', array_keys($categories)), FRONTEND_LANG_ID, array('newsid' => $relatedNewsId)) : $currentRelatedDetails['redirect'];
             $newstitle = $currentRelatedDetails['title'];
             $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]'));
             $htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
             // in case that the message is a stub,
             // we shall just display the news title instead of a html-a-tag
             // with no href target
             if (empty($htmlLinkTitle)) {
                 $htmlLinkTitle = contrexx_raw2xhtml($newstitle);
             }
             $imagePath = !empty($currentRelatedDetails['teaser_image_path']) ? $currentRelatedDetails['teaser_image_path'] : $defaultImage;
             $imageThumbPath = !empty($currentRelatedDetails['teaser_image_thumbnail_path']) ? $currentRelatedDetails['teaser_image_thumbnail_path'] : $defaultImage;
             $this->parseImageBlock($objTpl, $imagePath, $newstitle, $newsUrl, 'related_news_image');
             $this->parseImageBlock($objTpl, $imageThumbPath, $newstitle, $newsUrl, 'related_news_image_thumb');
             $author = \FWUser::getParsedUserTitle($currentRelatedDetails['author_id'], $currentRelatedDetails['author']);
             $publisher = \FWUser::getParsedUserTitle($currentRelatedDetails['publisher_id'], $currentRelatedDetails['publisher']);
             $objSubResult = $objDatabase->Execute('
                 SELECT count(`id`) AS `countComments`
                 FROM `' . DBPREFIX . 'module_news_comments`
                 WHERE `newsid` = ' . $relatedNewsId);
             $objTpl->setVariable(array('NEWS_RELATED_NEWS_ID' => contrexx_raw2xhtml($relatedNewsId), 'NEWS_RELATED_NEWS_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_RELATED_NEWS_LINK' => $htmlLink, 'NEWS_RELATED_NEWS_TITLE' => contrexx_raw2xhtml($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_SHORT' => strlen($currentRelatedDetails['title']) > 35 ? substr(strip_tags($currentRelatedDetails['title']), 0, 35) . '...' : strip_tags($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_LINK' => $htmlLinkTitle, 'NEWS_RELATED_NEWS_TEXT' => $currentRelatedDetails['text'], 'NEWS_RELATED_NEWS_TEXT_SHORT' => strlen($currentRelatedDetails['text']) > 250 ? substr(strip_tags($currentRelatedDetails['text']), 0, 247) . '...' : strip_tags($currentRelatedDetails['text']), 'NEWS_RELATED_NEWS_TEASER_TEXT' => nl2br($currentRelatedDetails['teaser_text']), 'NEWS_RELATED_NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_RELATED_NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_RELATED_NEWS_CATEGORY_NAMES' => implode(', ', contrexx_raw2xhtml($categories)), 'NEWS_RELATED_NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_COUNT_COMMENTS' => $currentRelatedDetails['commentactive'] && $this->arrSettings['news_comments_activated'] ? contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']) : ''));
             if (!$objSubResult->fields['countComments'] || !$this->arrSettings['news_comments_activated']) {
                 if ($objTpl->blockExists('related_news_comments_count')) {
                     $objTpl->hideBlock('related_news_comments_count');
                 }
             }
             if ($this->arrSettings['news_use_teaser_text'] != '1' && $objTpl->blockExists('news_use_teaser_text')) {
                 $objTpl->hideBlock('news_use_teaser_text');
             }
             $objTpl->parse($blockName);
         }
         if ($objTpl->blockExists('related_news_block')) {
             $objTpl->setVariable('TXT_NEWS_RELATED_NEWS', $_ARRAYLANG['TXT_NEWS_RELATED_NEWS']);
             $objTpl->touchBlock('related_news_block');
         }
     }
 }
 function access_user()
 {
     $objFWUser = \FWUser::getFWUserObject();
     $searchTerm = contrexx_input2raw($_GET['term']);
     $userType = contrexx_input2raw($_GET['type']);
     $userGroups = 0;
     if ($userType == 'newsAuthorName') {
         $userGroups = $this->arrSettings['news_assigned_author_groups'];
     } elseif ($userType == 'newsPublisherName') {
         $userGroups = $this->arrSettings['news_assigned_publisher_groups'];
     }
     $filter = $userGroups ? array('group_id' => explode(',', $userGroups)) : '';
     $objUser = $objFWUser->objUser->getUsers($filter, $searchTerm, null, array());
     $i = 0;
     $userAttr = array();
     while ($objUser && !$objUser->EOF) {
         $userName = $objUser->getUsername();
         $userId = $objUser->getId();
         if ($userName) {
             $userAttr[$i]['id'] = $userId;
             $userAttr[$i]['label'] = \FWUser::getParsedUserTitle($userId, '', true);
             $userAttr[$i]['value'] = \FWUser::getParsedUserTitle($userId);
             $i++;
         }
         $objUser->next();
     }
     echo json_encode($userAttr);
     exit;
 }
 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());
 }
Exemple #10
0
 /**
  * add /edit task
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 public function _modifyTask()
 {
     global $_ARRAYLANG, $objDatabase, $objJs, $objFWUser;
     \JS::registerCSS("modules/Crm/View/Style/contact.css");
     if (gettype($objFWUser) === 'NULL') {
         $objFWUser = \FWUser::getFWUserObject();
     }
     $objtpl = $this->_objTpl;
     $_SESSION['pageTitle'] = empty($_GET['id']) ? $_ARRAYLANG['TXT_CRM_ADDTASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'];
     $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_addtasks.html');
     $objtpl->setGlobalVariable("MODULE_NAME", $this->moduleName);
     $settings = $this->getSettings();
     $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
     $date = date('Y-m-d H:i:s');
     $title = isset($_POST['taskTitle']) ? contrexx_input2raw($_POST['taskTitle']) : '';
     $type = isset($_POST['taskType']) ? (int) $_POST['taskType'] : 0;
     $customer = isset($_REQUEST['customerId']) ? (int) $_REQUEST['customerId'] : '';
     $duedate = isset($_POST['date']) ? $_POST['date'] : $date;
     $assignedto = isset($_POST['assignedto']) ? intval($_POST['assignedto']) : 0;
     $description = isset($_POST['description']) ? contrexx_input2raw($_POST['description']) : '';
     $notify = isset($_POST['notify']);
     $taskId = isset($_REQUEST['searchType']) ? intval($_REQUEST['searchType']) : 0;
     $taskTitle = isset($_REQUEST['searchTitle']) ? contrexx_input2raw($_REQUEST['searchTitle']) : '';
     $redirect = isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : base64_encode('&act=task');
     // check permission
     if (!empty($id)) {
         $objResult = $objDatabase->Execute("SELECT `added_by`,\n                                                       `assigned_to`\n                                                    FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task`\n                                                 WHERE `id` = '{$id}'\n                                               ");
         $added_user = (int) $objResult->fields['added_by'];
         $assigned_user = (int) $objResult->fields['assigned_to'];
         if ($objResult) {
             list($task_edit_permission) = $this->getTaskPermission($added_user, $assigned_user);
             if (!$task_edit_permission) {
                 \Permission::noAccess();
             }
         }
     }
     if (isset($_POST['addtask'])) {
         if (!empty($id)) {
             if ($objFWUser->objUser->getAdminStatus() || $added_user == $objFWUser->objUser->getId() || $assigned_user == $assignedto) {
                 $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'description' => $description);
                 $query = \SQL::update("module_{$this->moduleNameLC}_task", $fields, array('escape' => true)) . " WHERE `id` = {$id}";
                 $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_UPDATE_MESSAGE'];
             } else {
                 $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE_ERR'];
             }
         } else {
             $addedDate = date('Y-m-d H:i:s');
             $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'added_by' => $objFWUser->objUser->getId(), 'added_date_time' => $addedDate, 'task_status' => '0', 'description' => $description);
             $query = \SQL::insert("module_{$this->moduleNameLC}_task", $fields, array('escape' => true));
             $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_OK_MESSAGE'];
         }
         $db = $objDatabase->Execute($query);
         if ($db) {
             if ($notify) {
                 $cx = \Cx\Core\Core\Controller\Cx::instanciate();
                 $id = !empty($id) ? $id : $objDatabase->INSERT_ID();
                 $info['substitution'] = array('CRM_ASSIGNED_USER_NAME' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($assignedto)), 'CRM_ASSIGNED_USER_EMAIL' => $objFWUser->objUser->getUser($assignedto)->getEmail(), 'CRM_DOMAIN' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath(), 'CRM_TASK_NAME' => $title, 'CRM_TASK_LINK' => "<a href='" . ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}'>{$title}</a>", 'CRM_TASK_URL' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}", 'CRM_TASK_DUE_DATE' => $duedate, 'CRM_TASK_CREATED_USER' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objFWUser->objUser->getId())), 'CRM_TASK_DESCRIPTION_TEXT_VERSION' => contrexx_html2plaintext($description), 'CRM_TASK_DESCRIPTION_HTML_VERSION' => $description);
                 //setting email template lang id
                 $availableMailTempLangAry = $this->getActiveEmailTemLangId('Crm', CRM_EVENT_ON_TASK_CREATED);
                 $availableLangId = $this->getEmailTempLang($availableMailTempLangAry, $objFWUser->objUser->getUser($assignedto)->getEmail());
                 $info['lang_id'] = $availableLangId;
                 $dispatcher = CrmEventDispatcher::getInstance();
                 $dispatcher->triggerEvent(CRM_EVENT_ON_TASK_CREATED, null, $info);
             }
             \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . base64_decode($redirect));
             exit;
         }
     } elseif (!empty($id)) {
         $objValue = $objDatabase->Execute("SELECT task_id,\n                                                            task_title,\n                                                            task_type_id,\n                                                            due_date,\n                                                            assigned_to,\n                                                            description,\n                                                            c.id,\n                                                            c.customer_name,\n                                                            c.contact_familyname\n                                                       FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task` AS t\n                                                       LEFT JOIN `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` AS c\n                                                            ON t.customer_id = c.id\n                                                       WHERE t.id='{$id}'");
         $title = $objValue->fields['task_title'];
         $type = $objValue->fields['task_type_id'];
         $customer = $objValue->fields['id'];
         $customerName = !empty($objValue->fields['customer_name']) ? $objValue->fields['customer_name'] . " " . $objValue->fields['contact_familyname'] : '';
         $duedate = $objValue->fields['due_date'];
         $assignedto = $objValue->fields['assigned_to'];
         $description = $objValue->fields['description'];
         $taskAutoId = $objValue->fields['task_id'];
     }
     $this->_getResourceDropDown('Members', $assignedto, $settings['emp_default_user_group']);
     $this->taskTypeDropDown($objtpl, $type);
     if (!empty($customer)) {
         // Get customer Name
         $objCustomer = $objDatabase->Execute("SELECT customer_name, contact_familyname  FROM `" . DBPREFIX . "module_crm_contacts` WHERE id = {$customer}");
         $customerName = $objCustomer->fields['customer_name'] . " " . $objCustomer->fields['contact_familyname'];
     }
     $objtpl->setVariable(array('CRM_LOGGED_USER_ID' => $objFWUser->objUser->getId(), 'CRM_TASK_AUTOID' => contrexx_raw2xhtml($taskAutoId), 'CRM_TASK_ID' => (int) $id, 'CRM_TASKTITLE' => contrexx_raw2xhtml($title), 'CRM_DUE_DATE' => contrexx_raw2xhtml($duedate), 'CRM_CUSTOMER_ID' => intval($customer), 'CRM_CUSTOMER_NAME' => contrexx_raw2xhtml($customerName), 'CRM_TASK_DESC' => new \Cx\Core\Wysiwyg\Wysiwyg('description', contrexx_raw2xhtml($description)), 'CRM_BACK_LINK' => base64_decode($redirect), 'TXT_CRM_ADD_TASK' => empty($id) ? $_ARRAYLANG['TXT_CRM_ADD_TASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'], 'TXT_CRM_TASK_ID' => $_ARRAYLANG['TXT_CRM_TASK_ID'], 'TXT_CRM_TASK_TITLE' => $_ARRAYLANG['TXT_CRM_TASK_TITLE'], 'TXT_CRM_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_TASK_TYPE'], 'TXT_CRM_SELECT_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_SELECT_TASK_TYPE'], 'TXT_CRM_CUSTOMER_NAME' => $_ARRAYLANG['TXT_CRM_CUSTOMER_NAME'], 'TXT_CRM_TASK_DUE_DATE' => $_ARRAYLANG['TXT_CRM_TASK_DUE_DATE'], 'TXT_CRM_TASK_RESPONSIBLE' => $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE'], 'TXT_CRM_SELECT_MEMBER_NAME' => $_ARRAYLANG['TXT_CRM_SELECT_MEMBER_NAME'], 'TXT_CRM_OVERVIEW' => $_ARRAYLANG['TXT_CRM_OVERVIEW'], 'TXT_CRM_TASK_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_TASK_DESCRIPTION'], 'TXT_CRM_FIND_COMPANY_BY_NAME' => $_ARRAYLANG['TXT_CRM_FIND_COMPANY_BY_NAME'], 'TXT_CRM_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], 'TXT_CRM_BACK' => $_ARRAYLANG['TXT_CRM_BACK'], 'TXT_CRM_NOTIFY' => $_ARRAYLANG['TXT_CRM_NOTIFY'], 'TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT' => $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT']));
 }
Exemple #11
0
 /**
  * Shows detail-page (content, voting & comments) for a single message. It checks also for new comments (POST) or votings (GET).
  *
  * @global  array
  * @global  ADONewConnection
  * @global  array
  * @param   integer     $intMessageId: The details of this page will be shown
  */
 function showDetails($intMessageId)
 {
     global $_CORELANG, $_ARRAYLANG, $objDatabase, $_CONFIG;
     $this->initUserId();
     $intMessageId = intval($intMessageId);
     if ($intMessageId < 1) {
         \Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?section=Blog");
     }
     //Empty form-values
     $strName = '';
     $strEMail = '';
     $strWWW = '';
     $strSubject = '';
     $strComment = '';
     //Check for new votings
     if (isset($_POST['vote'])) {
         $this->addVoting($intMessageId, $_POST['vote']);
     }
     //Check for new comments
     if (isset($_POST['frmAddComment_MessageId'])) {
         $this->addComment();
         if (!empty($this->_strErrorMessage) || !\FWUser::getFWUserObject()->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             //Error occured, get previous entered values
             $strName = htmlentities($_POST['frmAddComment_Name'], ENT_QUOTES, CONTREXX_CHARSET);
             $strEMail = htmlentities($_POST['frmAddComment_EMail'], ENT_QUOTES, CONTREXX_CHARSET);
             $strWWW = htmlentities($_POST['frmAddComment_WWW'], ENT_QUOTES, CONTREXX_CHARSET);
             $strSubject = htmlentities($_POST['frmAddComment_Subject'], ENT_QUOTES, CONTREXX_CHARSET);
             $strComment = contrexx_stripslashes(html_entity_decode($_POST['frmAddComment_Comment'], ENT_QUOTES, CONTREXX_CHARSET));
         }
     }
     //Count new hit
     $this->addHit($intMessageId);
     //After processing new actions: show page
     $arrEntries = $this->createEntryArray($this->_intLanguageId);
     //Loop over socializing-networks
     $strNetworks = '';
     $arrNetworks = $this->createNetworkArray();
     if (count($arrNetworks) > 0) {
         $strPageUrl = urlencode(\Cx\Core\Routing\Url::fromModuleAndCmd('Blog', 'details', '', array('id' => $intMessageId))->toString());
         foreach ($arrNetworks as $arrNetworkValues) {
             if (key_exists($this->_intLanguageId, $arrNetworkValues['status'])) {
                 $strUrl = str_replace('[URL]', $strPageUrl, $arrNetworkValues['submit']);
                 $strUrl = str_replace('[SUBJECT]', $arrEntries[$intMessageId]['subject'], $strUrl);
                 $strNetworks .= '<a href="' . $strUrl . '" title="' . $arrNetworkValues['name'] . ' (' . $arrNetworkValues['www'] . ')" target="_blank">' . $arrNetworkValues['icon_img'] . '</a>&nbsp;';
             }
         }
     }
     //Show message-part
     $this->_objTpl->setVariable(array('BLOG_DETAILS_ID' => $intMessageId, 'BLOG_DETAILS_TITLE' => $arrEntries[$intMessageId]['subject'], 'BLOG_DETAILS_POSTED' => $this->getPostedByString($arrEntries[$intMessageId]['user_name'], $arrEntries[$intMessageId]['time_created']), 'BLOG_DETAILS_POSTED_ICON' => $this->getPostedByIcon($arrEntries[$intMessageId]['time_created']), 'BLOG_DETAILS_CONTENT' => html_entity_decode($arrEntries[$intMessageId]['translation'][$this->_intLanguageId]['content']), 'BLOG_DETAILS_IMAGE' => $arrEntries[$intMessageId]['translation'][$this->_intLanguageId]['image'] != '' ? '<img src="' . $arrEntries[$intMessageId]['translation'][$this->_intLanguageId]['image'] . '" title="' . $arrEntries[$intMessageId]['subject'] . '" alt="' . $arrEntries[$intMessageId]['subject'] . '" />' : '', 'BLOG_DETAILS_NETWORKS' => $strNetworks));
     //Show voting-part
     if ($this->_arrSettings['blog_voting_activated']) {
         $this->_objTpl->setVariable(array('TXT_VOTING' => $_ARRAYLANG['TXT_BLOG_FRONTEND_OVERVIEW_VOTING'], 'TXT_VOTING_ACTUAL' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_VOTING_ACTUAL'], 'TXT_VOTING_AVG' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_VOTING_AVG'], 'TXT_VOTING_COUNT' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_VOTING_COUNT'], 'TXT_VOTING_USER' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_VOTING_USER']));
         $this->_objTpl->setVariable(array('BLOG_DETAILS_VOTING_BAR' => $this->getRatingBar($intMessageId), 'BLOG_DETAILS_VOTING_AVG' => '&#216;&nbsp;' . $arrEntries[$intMessageId]['votes_avg'], 'BLOG_DETAILS_VOTING_COUNT' => $arrEntries[$intMessageId]['votes'], 'BLOG_DETAILS_VOTING_USER' => $this->hasUserAlreadyVoted($intMessageId) ? $this->getUserVotingForMessage($intMessageId) : $this->getVotingBar($intMessageId)));
     } else {
         $this->_objTpl->hideBlock('votingPart');
     }
     //Show comment-part
     if ($this->_arrSettings['blog_comments_activated']) {
         //comments are activated
         $this->_objTpl->setVariable(array('TXT_COMMENTS' => $_ARRAYLANG['TXT_BLOG_FRONTEND_OVERVIEW_COMMENTS'], 'TXT_COMMENT_ADD' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD'], 'TXT_COMMENT_ADD_NAME' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_NAME'], 'TXT_COMMENT_ADD_EMAIL' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_EMAIL'], 'TXT_COMMENT_ADD_WWW' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_WWW'], 'TXT_COMMENT_ADD_SUBJECT' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_SUBJECT'], 'TXT_COMMENT_ADD_COMMENT' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_COMMENT'], 'TXT_COMMENT_ADD_RESET' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_RESET'], 'TXT_COMMENT_ADD_SUBMIT' => $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_SUBMIT']));
         if (\FWUser::getFWUserObject()->objUser->login()) {
             $this->_objTpl->hideBlock('comment_captcha');
         } else {
             $this->_objTpl->setVariable(array('TXT_COMMENT_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'], 'COMMENT_CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode()));
             $this->_objTpl->parse('comment_captcha');
         }
         $this->_objTpl->setVariable(array('BLOG_DETAILS_COMMENTS_JAVASCRIPT' => $this->getJavascript('comments')));
         $objFWUser = \FWUser::getFWUserObject();
         $objCommentsResult = $objDatabase->Execute('SELECT      comment_id,
                                                                 time_created,
                                                                 user_id,
                                                                 user_name,
                                                                 user_mail,
                                                                 user_www,
                                                                 subject,
                                                                 comment
                                                     FROM        ' . DBPREFIX . 'module_blog_comments
                                                     WHERE       message_id=' . $intMessageId . ' AND
                                                                 lang_id=' . $this->_intLanguageId . ' AND
                                                                 is_active="1"
                                                     ORDER BY    time_created ASC, comment_id ASC
                                                 ');
         if ($objCommentsResult->RecordCount() > 0) {
             while (!$objCommentsResult->EOF) {
                 //Get username and avatar
                 $strUserName = '';
                 $strUserAvatar = '<img src="' . ASCMS_BLOG_IMAGES_WEB_PATH . '/no_avatar.gif" alt="' . $strUserName . '" />';
                 $objUser = $objFWUser->objUser->getUser($objCommentsResult->fields['user_id']);
                 if ($objCommentsResult->fields['user_id'] == 0 || $objUser === false) {
                     $strUserName = $objCommentsResult->fields['user_name'];
                 } else {
                     $strUserName = contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objUser));
                     if ($objUser->getProfileAttribute('picture') != '') {
                         $strUserAvatar = '<img src="' . ASCMS_ACCESS_PROFILE_IMG_WEB_PATH . '/' . $objUser->getProfileAttribute('picture') . '" alt="' . $strUserName . '" />';
                     }
                 }
                 //Parse comment
                 $this->_objTpl->setVariable(array('BLOG_DETAILS_COMMENT_ID' => $objCommentsResult->fields['comment_id'], 'BLOG_DETAILS_COMMENT_TITLE' => htmlentities(stripslashes($objCommentsResult->fields['subject']), ENT_QUOTES, CONTREXX_CHARSET), 'BLOG_DETAILS_COMMENT_POSTED' => $this->getPostedByString($strUserName, date(ASCMS_DATE_FORMAT, $objCommentsResult->fields['time_created'])), 'BLOG_DETAILS_COMMENT_CONTENT' => \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($objCommentsResult->fields['comment']), 'BLOG_DETAILS_COMMENT_AVATAR' => $strUserAvatar));
                 $this->_objTpl->parse('showCommentRows');
                 $objCommentsResult->MoveNext();
             }
         } else {
             $this->_objTpl->setVariable('TXT_COMMENTS_NONE_EXISTING', $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_NONE_EXISTING']);
             $this->_objTpl->parse('showNoCommentRows');
         }
         if ($this->_arrSettings['blog_comments_anonymous'] || $this->_intCurrentUserId != 0) {
             //Anonymous comments allowed or user is logged in
             //Fill Add-Comment-Form
             //Determine the desired editor
             if ($this->_arrSettings['blog_comments_editor'] == 'wysiwyg') {
                 $strEditor = new \Cx\Core\Wysiwyg\Wysiwyg('frmAddComment_Comment', $strComment, 'bbcode');
             } else {
                 $strEditor = '<textarea name="frmAddComment_Comment" rows="12" cols="80" class="blogCommentTextarea">' . $strComment . '</textarea>';
             }
             $this->_objTpl->setVariable(array('BLOG_DETAILS_COMMENT_ADD_MESSAGE_ID' => $intMessageId, 'BLOG_DETAILS_COMMENT_ADD_NAME' => $this->_intCurrentUserId == 0 ? '<input type="text" name="frmAddComment_Name" value="' . $strName . '" class="blogCommentInput" />' : contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objFWUser->objUser)), 'BLOG_DETAILS_COMMENT_ADD_EMAIL' => $this->_intCurrentUserId == 0 ? '<input type="text" name="frmAddComment_EMail" value="' . $strEMail . '" class="blogCommentInput" />' : contrexx_raw2xhtml($objFWUser->objUser->getEmail()), 'BLOG_DETAILS_COMMENT_ADD_WWW' => $this->_intCurrentUserId == 0 ? '<input type="text" name="frmAddComment_WWW" value="' . $strWWW . '" class="blogCommentInput" />' : contrexx_raw2xhtml($objFWUser->objUser->getProfileAttribute('website')), 'BLOG_DETAILS_COMMENT_ADD_SUBJECT' => $strSubject, 'BLOG_DETAILS_COMMENT_ADD_COMMENT' => $strEditor));
         } else {
             //Anonymous comments arent allowed and the user isn't logged in -> Hide block!
             $this->_objTpl->setVariable('BLOG_DETAILS_COMMENT_ADD_ERROR', $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_LOGGED_IN']);
             $this->_objTpl->hideBlock('commentAddPart');
         }
     } else {
         //Comments dectivated - hide comment block
         $this->_objTpl->hideBlock('commentPart');
     }
     //Finally parse info / error messages
     if (empty($this->_strStatusMessage)) {
         $this->_objTpl->hideBlock('showOkay');
     } else {
         $this->_objTpl->setVariable('BLOG_DETAILS_COMMENT_OKAY', $this->_strStatusMessage);
     }
     if (empty($this->_strErrorMessage)) {
         $this->_objTpl->hideBlock('showError');
     } else {
         $this->_objTpl->setVariable('BLOG_DETAILS_COMMENT_ERROR', $this->_strErrorMessage);
     }
 }
 /**
  * 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");
     }
 }
 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());
 }