/**
  * Initialization of the class.
  *
  * @return void
  */
 public function init()
 {
     // Setting GPvars:
     $this->id = (int) GeneralUtility::_GP('id');
     if (!$this->id) {
         \CommerceTeam\Commerce\Utility\FolderUtility::initFolders();
         $this->id = current(array_unique(FolderRepository::initFolders('Products', 'Commerce', 0, 'Commerce')));
     }
     $this->edit = GeneralUtility::_GP('edit');
     $this->return_id = GeneralUtility::_GP('return_id');
     $this->lastEdited = GeneralUtility::_GP('lastEdited');
     // Setting GPvars:
     $controlParams = GeneralUtility::_GP('control');
     if ($controlParams) {
         $controlArray = current($controlParams);
         $this->categoryUid = (int) $controlArray['uid'];
     }
     // Module name;
     $this->MCONF = $GLOBALS['MCONF'];
     // Page select clause:
     $this->perms_clause = \CommerceTeam\Commerce\Utility\BackendUtility::getCategoryPermsClause(1);
     $this->initPage();
     // Set up menus:
     $this->menuConfig();
 }
 /**
  * Initializing the module.
  *
  * @return void
  */
 public function init()
 {
     $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_list.xml');
     // Setting GPvars:
     $this->id = (int) GeneralUtility::_GP('id');
     if (!$this->id) {
         \CommerceTeam\Commerce\Utility\FolderUtility::initFolders();
         $this->id = current(array_unique(FolderRepository::initFolders('Products', 'Commerce', 0, 'Commerce')));
     }
     // Initialize the listing object, dblist, for rendering the list:
     $this->pointer = max(min(GeneralUtility::_GP('pointer'), 100000), 0);
     $this->imagemode = GeneralUtility::_GP('imagemode');
     $this->table = GeneralUtility::_GP('table');
     $this->search_field = GeneralUtility::_GP('search_field');
     $this->search_levels = GeneralUtility::_GP('search_levels');
     $this->showLimit = (int) GeneralUtility::_GP('showLimit');
     $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
     $this->clear_cache = (bool) GeneralUtility::_GP('clear_cache');
     $this->cmd = GeneralUtility::_GP('cmd');
     $this->cmd_table = GeneralUtility::_GP('cmd_table');
     // Setting GPvars:
     $controlParams = GeneralUtility::_GP('control');
     if ($controlParams) {
         $controlArray = current($controlParams);
         $this->categoryUid = (int) $controlArray['uid'];
     }
     // Module name;
     $this->MCONF = $GLOBALS['MCONF'];
     // Page select clause:
     $this->perms_clause = \CommerceTeam\Commerce\Utility\BackendUtility::getCategoryPermsClause(1);
     $this->initPage();
     $this->clearCache();
     // Set up menus:
     $this->menuConfig();
 }
 /**
  * Initiation of the class.
  *
  * @return void
  * @todo Check with User Permissions
  */
 public function init()
 {
     $backendUser = $this->getBackendUser();
     // Setting GPvars:
     $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
     $this->cMR = GeneralUtility::_GP('cMR');
     $this->setTemporaryDatabaseMount = GeneralUtility::_GP('setTempDBmount');
     // Generate Folder if necessary
     \CommerceTeam\Commerce\Utility\FolderUtility::initFolders();
     // Create page tree object:
     $this->pagetree = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\OrderTree');
     $this->pagetree->ext_IconMode = $backendUser->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
     $this->pagetree->ext_showPageId = $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
     $this->pagetree->addField('alias');
     $this->pagetree->addField('shortcut');
     $this->pagetree->addField('shortcut_mode');
     $this->pagetree->addField('mount_pid');
     $this->pagetree->addField('mount_pid_ol');
     $this->pagetree->addField('nav_hide');
     $this->pagetree->addField('url');
     // Temporary DB mounts:
     $this->pagetree->MOUNTS = array_unique(\CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce'));
     $this->initializeTemporaryDatabaseMount();
     // Setting highlight mode:
     $this->doHighlight = !$backendUser->getTSConfigVal('options.pageTree.disableTitleHighlight');
 }
 /**
  * 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;
 }
Example #5
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'));
 }
 /**
  * This method creates a dynaflex field configuration from the submitted
  * database entry. The variable "configData" contains the complete dynaflex
  * configuration of the field and the data that where maybe fetched from
  * the database.
  *
  * We have to fill the fields
  *
  * $config['name']
  * $config['label']
  * $config['config']
  *
  * @param array $aData The data array contains in element "row" the dataset
  *     of the table we're creating
  * @param array $config The config array is the dynaflex fieldconfiguration.
  * @param bool  $fetchFromDatabase If true the attribute data is fetched
  *     from database
  * @param bool  $onlyDisplay If true the field is not an input field but
  *     is displayed
  *
  * @return array The modified dynaflex configuration
  */
 public function getAttributeEditField(array $aData, array &$config, $fetchFromDatabase = true, $onlyDisplay = false)
 {
     // first of all, fetch data from attribute table
     if ($fetchFromDatabase) {
         $aData = $this->belib->getAttributeData($aData['row']['uid_foreign'], 'uid, title, has_valuelist, multiple, unit, deleted');
     }
     if ($aData['deleted'] == 1) {
         return array();
     }
     /*
      * Try to detect article UID since there is currently no way to get the
      * data from the method and get language_uid from article
      */
     $sysLanguageUid = 0;
     $getPostedit = GeneralUtility::_GPmerged('edit');
     if (is_array($getPostedit['tx_commerce_articles'])) {
         $articleUid = array_keys($getPostedit['tx_commerce_articles']);
         if ($articleUid[0] > 0) {
             $temporaryData = BackendUtility::getRecord('tx_commerce_articles', $articleUid[0], 'sys_language_uid');
             $sysLanguageUid = (int) $temporaryData['sys_language_uid'];
         }
     } elseif (is_array($getPostedit['tx_commerce_products'])) {
         $articleUid = array_keys($getPostedit['tx_commerce_products']);
         if ($articleUid[0] > 0) {
             $temporaryData = BackendUtility::getRecord('tx_commerce_products', $articleUid[0], 'sys_language_uid');
             $sysLanguageUid = (int) $temporaryData['sys_language_uid'];
         }
     }
     // set label and name
     $config['label'] = $aData['title'];
     $config['name'] = 'attribute_' . $aData['uid'];
     // get the value
     if ($onlyDisplay) {
         $config['config']['type'] = 'user';
         $config['config']['userFunc'] = 'tx_commerce_attributeEditor->displayAttributeValue';
         $config['config']['aUid'] = $aData['uid'];
         return $config;
     }
     /*
      * Get PID to select only the Attribute Values in the correct PID
      */
     FolderUtility::initFolders();
     $modPid = current(FolderRepository::initFolders('Commerce', 'commerce'));
     FolderRepository::initFolders('Products', 'commerce', $modPid);
     $attrPid = current(FolderRepository::initFolders('Attributes', 'commerce', $modPid));
     if ($aData['has_valuelist'] == 1) {
         $config['config'] = array('type' => 'select', 'foreign_table' => 'tx_commerce_attribute_values', 'foreign_table_where' => ' AND attributes_uid = ' . (int) $aData['uid'] . ' AND tx_commerce_attribute_values.pid = ' . (int) $attrPid . ' ORDER BY value', 'size' => 1, 'minitems' => 0, 'maxitems' => 1, 'items' => array(array('', 0)));
         if ((int) $aData['multiple'] == 1) {
             // create a selectbox for multiple selection
             $config['config']['multiple'] = 1;
             $config['config']['size'] = 5;
             $config['config']['maxitems'] = 100;
             unset($config['config']['items']);
         }
     } else {
         // the field should be a simple input field
         if ($aData['unit'] != '') {
             $config['label'] .= ' (' . $aData['unit'] . ')';
         }
         $config['config'] = array('type' => 'input');
     }
     // Dont display in lokalised version Attributes with valuelist
     if ($aData['has_valuelist'] == 1 && $sysLanguageUid != 0) {
         $config['config']['type'] = '';
         return false;
     }
     return $config;
 }