示例#1
0
 /**
  * Make query array.
  *
  * @param string $table Table
  * @param int $id Id
  * @param string $addWhere Additional where
  * @param string $fieldList Field list
  *
  * @return array
  */
 public function makeQueryArray($table, $id, $addWhere = '', $fieldList = '*')
 {
     $database = $this->getDatabaseConnection();
     $hookObjectsArr = array();
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'] as $classRef) {
             $hookObjectsArr[] = GeneralUtility::getUserObj($classRef);
         }
     }
     $tableControl = SettingsFactory::getInstance()->getTcaValue($table . '.ctrl');
     // Set ORDER BY:
     $orderBy = $tableControl['sortby'] ? 'ORDER BY ' . $table . '.' . $tableControl['sortby'] : $tableControl['default_sortby'];
     if ($this->sortField) {
         if (in_array($this->sortField, $this->makeFieldList($table, 1))) {
             $orderBy = 'ORDER BY ' . $table . '.' . $this->sortField;
             if ($this->sortRev) {
                 $orderBy .= ' DESC';
             }
         }
     }
     // Set LIMIT:
     $limit = '';
     if ($this->iLimit) {
         $limit = ($this->firstElementNumber ? $this->firstElementNumber . ',' : '') . ($this->iLimit + 1);
     }
     // Filtering on displayable pages (permissions):
     $pC = $table == 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : '';
     if ($id > 0) {
         $pidWhere = ' AND tx_commerce_orders.pid = ' . $id;
     } else {
         \CommerceTeam\Commerce\Utility\FolderUtility::initFolders();
         // Find the right pid for the Ordersfolder
         $orderPid = current(array_unique(\CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce')));
         $orderFolders = \CommerceTeam\Commerce\Utility\BackendUtility::getOrderFolderSelector($orderPid, PHP_INT_MAX);
         $list = array();
         foreach ($orderFolders as $orderFolder) {
             $list[] = $orderFolder[1];
         }
         $pidWhere = ' AND tx_commerce_orders.pid in (' . implode(',', $list) . ')';
     }
     // Adding search constraints:
     $search = $this->makeSearchString($table);
     // specialhandling of search for joins
     if ($search) {
         $searchParts = GeneralUtility::trimExplode('OR', $search);
         foreach ($searchParts as &$part) {
             $part = str_replace('LOWER(', 'LOWER(' . $table . '.', $part);
             $part = str_replace('LOWER(' . $table . '.\'', 'LOWER(\'', $part);
         }
         $search = implode(' OR ', $searchParts);
     }
     $queryParts = array('SELECT' => 'DISTINCT tx_commerce_order_articles.order_id, delivery_table.order_id AS order_number,
             tx_commerce_order_articles.article_type_uid, tx_commerce_order_articles.title AS payment,
             delivery_table.title AS delivery, tx_commerce_orders.uid, tx_commerce_orders.pid,
             tx_commerce_orders.crdate, tx_commerce_orders.tstamp, tx_commerce_orders.order_id,
             tx_commerce_orders.sum_price_gross, tt_address.tx_commerce_address_type_id, tt_address.company,
             tt_address.name, tt_address.surname, tt_address.address, tt_address.zip, tt_address.city,
             tt_address.email, tt_address.phone AS phone_1, tt_address.mobile AS phone_2,
             tx_commerce_orders.cu_iso_3_uid, tx_commerce_orders.tstamp, tx_commerce_orders.uid AS articles,
             tx_commerce_orders.comment, tx_commerce_orders.internalcomment,
             tx_commerce_orders.order_type_uid AS order_type_uid_noName, static_currencies.cu_iso_3', 'FROM' => 'tx_commerce_orders, tt_address, tx_commerce_order_articles,
             tx_commerce_order_articles AS delivery_table, static_currencies', 'WHERE' => 'static_currencies.uid = tx_commerce_orders.cu_iso_3_uid
             AND delivery_table.order_id = tx_commerce_orders.order_id
             AND tx_commerce_order_articles.order_id = tx_commerce_orders.order_id
             AND tx_commerce_order_articles.article_type_uid = ' . PAYMENTARTICLETYPE . '
             AND delivery_table.article_type_uid = ' . DELIVERYARTICLETYPE . '
             AND tx_commerce_orders.deleted = 0
             AND tx_commerce_orders.cust_deliveryaddress = tt_address.uid ' . $pC . ' ' . $addWhere . $pidWhere . ' ' . $search, 'GROUPBY' => '', 'ORDERBY' => $database->stripOrderBy($orderBy), 'LIMIT' => $limit);
     // get Module TSConfig
     $moduleConfig = BackendUtility::getModTSconfig($id, 'mod.commerce_orders');
     $deliveryProductUid = $moduleConfig['properties']['deliveryProductUid'] ? $moduleConfig['properties']['deliveryProductUid'] : 0;
     if ($deliveryProductUid > 0) {
         $deliveryArticles = \CommerceTeam\Commerce\Utility\BackendUtility::getArticlesOfProductAsUidList($deliveryProductUid);
         if (!empty($deliveryArticles)) {
             $queryParts['WHERE'] .= ' AND delivery_table.article_uid IN (' . implode(',', $deliveryArticles) . ') ';
         }
     }
     $paymentProductUid = $moduleConfig['properties']['paymentProductUid'] ? $moduleConfig['properties']['paymentProductUid'] : 0;
     if ($paymentProductUid > 0) {
         $paymentArticles = \CommerceTeam\Commerce\Utility\BackendUtility::getArticlesOfProductAsUidList($paymentProductUid);
         if (!empty($paymentArticles)) {
             $queryParts['WHERE'] .= ' AND delivery_table.article_uid IN (' . implode(',', $paymentArticles) . ') ';
         }
     }
     // Apply hook as requested in http://bugs.typo3.org/view.php?id=4361
     foreach ($hookObjectsArr as $hookObj) {
         if (method_exists($hookObj, 'makeQueryArray_post')) {
             $parameter = array('orderBy' => $orderBy, 'limit' => $limit, 'pC' => $pC, 'search' => $search);
             $hookObj->makeQueryArray_post($queryParts, $this, $table, $id, $addWhere, $fieldList, $parameter);
         }
     }
     return $queryParts;
 }
示例#2
0
 /**
  * Order Status
  * Selects only the order folders from the pages List.
  *
  * @param array $data Data
  *
  * @return void
  */
 public function orderStatus(array &$data)
 {
     /*
      * Create folder if not existing
      */
     \CommerceTeam\Commerce\Utility\FolderUtility::initFolders();
     /*
      * Create a new data item array
      */
     $data['items'] = array();
     // Find the right pid for the Ordersfolder
     list($orderPid) = array_unique(\CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce'));
     /*
      * Get the pages below $order_pid
      */
     /*
      * Check if the Current PID is below $orderPid,
      * id is below orderPid we could use the parent of
      * this record to build up the select Drop Down
      * otherwhise use the default PID
      */
     $localOrderPid = $data['row']['pid'];
     $rootline = BackendUtility::BEgetRootLine($localOrderPid);
     $rootlinePids = array();
     foreach ($rootline as $pages) {
         if (isset($pages['uid'])) {
             $rootlinePids[] = $pages['uid'];
         }
     }
     if (in_array($orderPid, $rootlinePids)) {
         /**
          * Page repository.
          *
          * @var \CommerceTeam\Commerce\Domain\Repository\PageRepository $pageRepository
          */
         $pageRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\PageRepository');
         $page = $pageRepository->findByUid($localOrderPid);
         if (!empty($page)) {
             $orderPid = $page['pid'];
         }
     }
     $data['items'] = \CommerceTeam\Commerce\Utility\BackendUtility::getOrderFolderSelector($orderPid, SettingsFactory::getInstance()->getExtConf('OrderFolderRecursiveLevel'));
 }