Пример #1
0
 /**
  * get customer search result
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return json result
  */
 public function searchContacts()
 {
     global $objDatabase;
     $searchFields = array('companyname_filter' => isset($_REQUEST['companyname_filter']) ? contrexx_input2raw($_REQUEST['companyname_filter']) : '', 'contactSearch' => isset($_REQUEST['contactSearch']) ? (array) $_REQUEST['contactSearch'] : array(1, 2), 'advanced-search' => $_REQUEST['advanced-search'], 's_name' => $_REQUEST['s_name'], 's_email' => $_REQUEST['s_email'], 's_address' => $_REQUEST['s_address'], 's_city' => $_REQUEST['s_city'], 's_postal_code' => $_REQUEST['s_postal_code'], 's_notes' => $_REQUEST['s_notes'], 'customer_type' => $_REQUEST['customer_type'], 'filter_membership' => $_REQUEST['filter_membership'], 'term' => isset($_REQUEST['term']) ? contrexx_input2raw($_REQUEST['term']) : '', 'sorto' => $_REQUEST['sorto'], 'sortf' => $_REQUEST['sortf']);
     $objCrmLibrary = new CrmLibrary($this->getName());
     $query = $objCrmLibrary->getContactsQuery($searchFields);
     $objResult = $objDatabase->Execute($query);
     $result = array();
     if ($objResult) {
         while (!$objResult->EOF) {
             if ($objResult->fields['contact_type'] == 1) {
                 $contactName = $objResult->fields['customer_name'];
             } else {
                 $contactName = $objResult->fields['customer_name'] . " " . $objResult->fields['contact_familyname'];
             }
             $result[] = array('id' => (int) $objResult->fields['id'], 'label' => html_entity_decode(stripslashes($contactName), ENT_QUOTES, CONTREXX_CHARSET), 'value' => html_entity_decode(stripslashes($contactName), ENT_QUOTES, CONTREXX_CHARSET));
             $objResult->MoveNext();
         }
     }
     return $result;
 }
Пример #2
0
 /**
  * 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));
     }
 }
Пример #3
0
 /**
  * Constructor
  */
 public function __construct($product, $options)
 {
     // Important:
     // A subscription must always have a valid $product.
     // The following exception is for the sole purpose of making this class
     // compatible with the \Cx\Core\Html\Controller\ViewGenerator library
     // for autogenerating user-interfaces.
     if (!$product) {
         return;
     }
     $this->subscriptionDate = new \DateTime();
     $this->product = $product;
     $this->setProductEntity($product->getNewEntityForSale($options));
     $objCurrency = null;
     if ($this->getOrder()) {
         $objCurrency = $this->getOrder()->getCurrency();
     } else {
         $defaultCurrencyId = \Cx\Modules\Crm\Controller\CrmLibrary::getDefaultCurrencyId();
         $objCurrency = $defaultCurrencyId ? \Env::get('em')->getRepository('Cx\\Modules\\Crm\\Model\\Entity\\Currency')->findOneById($defaultCurrencyId) : null;
     }
     $this->paymentAmount = $product->getPaymentAmount($options['renewalUnit'], $options['renewalQuantifier'], $objCurrency);
     $this->paymentState = self::PAYMENT_OPEN;
     if ($product->isExpirable()) {
         $this->expirationDate = $product->getExpirationDate($options['renewalUnit'], $options['renewalQuantifier']);
     }
     if ($product->isRenewable()) {
         list($this->renewalUnit, $this->renewalQuantifier) = $product->getRenewalDefinition($options['renewalUnit'], $options['renewalQuantifier']);
         $this->renewalDate = $product->getRenewalDate($this->renewalUnit, $this->renewalQuantifier);
     }
     if (isset($options['description'])) {
         $this->setDescription($options['description']);
     }
     //Set state initialized to active.
     $this->state = self::STATE_ACTIVE;
 }
 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());
 }