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());
 }
 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());
 }