/** {@inheritDoc} */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->where(array('class_key' => 'msProduct'));
     $c->leftJoin('msProductData', 'Data', 'msProduct.id = Data.id');
     $c->leftJoin('msCategoryMember', 'Member', 'msProduct.id = Member.product_id');
     $c->leftJoin('msVendor', 'Vendor', 'Data.vendor = Vendor.id');
     $c->leftJoin('msCategory', 'Category', 'Category.id = msProduct.parent');
     if ($this->getProperty('combo')) {
         $c->select('msProduct.id,msProduct.pagetitle,msProduct.context_key');
     } else {
         $c->select($this->modx->getSelectColumns('msProduct', 'msProduct'));
         $c->select($this->modx->getSelectColumns('msProductData', 'Data', '', array('id'), true));
         $c->select($this->modx->getSelectColumns('msVendor', 'Vendor', 'vendor_', array('name')));
         $c->select($this->modx->getSelectColumns('msCategory', 'Category', 'category_', array('pagetitle')));
     }
     if ($query = $this->getProperty('query', null)) {
         $queryWhere = array('msProduct.id' => $query, 'OR:msProduct.pagetitle:LIKE' => '%' . $query . '%', 'OR:description:LIKE' => '%' . $query . '%', 'OR:introtext:LIKE' => '%' . $query . '%', 'OR:Data.article:LIKE' => '%' . $query . '%', 'OR:Data.vendor:LIKE' => '%' . $query . '%', 'OR:Data.made_in:LIKE' => '%' . $query . '%', 'OR:Vendor.name:LIKE' => '%' . $query . '%', 'OR:Category.pagetitle:LIKE' => '%' . $query . '%');
         $c->where($queryWhere);
     }
     $parent = $this->getProperty('parent');
     if (!empty($parent)) {
         $category = $this->modx->getObject('modResource', $this->getProperty('parent'));
         $this->parent = $parent;
         $parents = array($parent);
         if ($this->modx->getOption('ms2_category_show_nested_products', null, true)) {
             $tmp = $this->modx->getChildIds($parent, 10, array('context' => $category->get('context_key')));
             foreach ($tmp as $v) {
                 $parents[] = $v;
             }
         }
         $c->orCondition(array('parent:IN' => $parents, 'Member.category_id:IN' => $parents), '', 1);
     }
     return $c;
 }
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modMediaSource', 'Source');
     $c->leftJoin($this->classKey, 'Thumb', "`{$this->classKey}`.`id` = `Thumb`.`parent`");
     $c->groupby($this->classKey . '.id');
     $c->select('`Source`.`name` as `source_name`');
     $c->select('`Thumb`.`url` as `thumbnail`');
     $c->where(array('resource_id' => $this->getProperty('resource_id')));
     $parent = $this->getProperty('parent');
     if ($parent !== false) {
         $c->where(array('parent' => $parent));
     }
     $query = trim($this->getProperty('query'));
     if (!empty($query)) {
         $c->where(array('file:LIKE' => "%{$query}%", 'OR:name:LIKE' => "%{$query}%", 'OR:alt:LIKE' => "%{$query}%", 'OR:description:LIKE' => "%{$query}%", 'OR:add:LIKE' => "%{$query}%"));
     }
     $tags = array_map('trim', explode(',', $this->getProperty('tags')));
     if (!empty($tags[0])) {
         $tags = implode("','", $tags);
         $c->innerJoin('msResourceFileTag', 'Tag', "`{$this->classKey}`.`id` = `Tag`.`file_id` AND `Tag`.`tag` IN ('" . $tags . "')");
         $c->groupby($this->classKey . '.id');
         $c->prepare();
         $this->modx->log(1, $c->toSQL());
     }
     return $c;
 }
Exemple #3
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin("glData", "glData", "glData.identifier = {$this->classKey}.id");
     $c->select($this->modx->getSelectColumns("glData", "glData"));
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     switch ($this->classKey) {
         case 'glCountry':
             break;
         case 'glRegion':
             $c->leftJoin("glCountry", "glCountry", "glCountry.iso = {$this->classKey}.country");
             $c->select($this->modx->getSelectColumns("glCountry", "glCountry", 'country_', array('id'), true));
             break;
         case 'glCity':
             $c->leftJoin("glRegion", "glRegion", "glRegion.id = {$this->classKey}.region_id");
             $c->select($this->modx->getSelectColumns("glRegion", "glRegion", 'region_', array('id'), true));
             $c->leftJoin("glCountry", "glCountry", "glCountry.iso = glRegion.country");
             $c->select($this->modx->getSelectColumns("glCountry", "glCountry", 'country_', array('id'), true));
             break;
     }
     $active = $this->getProperty('active');
     if ($active != '') {
         $c->where(array("{$this->objectType}.active" => $active));
     }
     $default = $this->getProperty('default');
     if ($default != '') {
         $c->where(array("{$this->objectType}.default" => $default));
     }
     $query = trim($this->getProperty('query'));
     if ($query) {
         $c->where(array("{$this->objectType}.name_ru:LIKE" => "%{$query}%", "OR:{$this->objectType}.name_en:LIKE" => "%{$query}%"));
     }
     return $c;
 }
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modSnippet', 'Snippet');
     $c->leftJoin('modCronjobLog', 'Log');
     $c->select(array($this->modx->getSelectColumns($this->classKey, $this->classKey), $this->modx->getSelectColumns('modSnippet', 'Snippet', 'snippet_', array('id', 'name', 'description')), 'logs' => 'COUNT(Log.id)'));
     return $c;
 }
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modResource', 'modResource', 'modResource.id = scContent.resource');
     $c->leftJoin('modContentType', 'modContentType', 'modContentType.id = scContent.content_type');
     $c->leftJoin('modTemplate', 'modTemplate', 'modTemplate.id = scContent.template');
     $c->select($this->modx->getSelectColumns('scContent', 'scContent'));
     $c->select(array('resource_name' => 'modResource.pagetitle', 'content_type_name' => 'modContentType.name', 'template_name' => 'modTemplate.templatename'));
     /*		if ($this->getProperty('combo')) {
     			$c->select('id,name');
     			$c->where(array('active' => 1));
     			if ($requestId = $this->getProperty('request_id')) {
     
     				if ($request = $this->modx->getObject('psRequest', $requestId)) {
     
     					$status = $request->getOne('Status');
     					if ($status->get('final') == 1) {
     						$c->where(array('id' => $status->get('id')));
     					} else if ($status->get('fixed') == 1) {
     						$c->where(array('rank:>=' => $status->get('rank')));
     					}
     				}
     			}
     		}*/
     $query = trim($this->getProperty('query'));
     if ($query) {
         $c->where(array('uri:LIKE' => "%{$query}%", 'OR:pagetitle:LIKE' => "%{$query}%", 'OR:longtitle:LIKE' => "%{$query}%", 'OR:description:LIKE' => "%{$query}%", 'OR:introtext:LIKE' => "%{$query}%", 'OR:content:LIKE' => "%{$query}%"));
     }
     return $c;
 }
 /**
  * @return mixed
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->select($this->modx->getSelectColumns('modManagerLog', 'modManagerLog', '', array('action'), true));
     //        $c->select($this->modx->getSelectColumns('modManagerLog','modManagerLog'));
     $c->select(array('User.username', 'Template.templatename', 'Chunk.name as chunkname', 'Snippet.name as snippetname', 'Plugin.name as pluginname', 'TV.name as tvname'));
     $c->innerJoin('modUser', 'User');
     $c->leftJoin('modTemplate', 'Template', '`modManagerLog`.item = `Template`.`id` AND `modManagerLog`.`classKey` = "modTemplate"');
     $c->leftJoin('modChunk', 'Chunk', '`modManagerLog`.item = `Chunk`.`id` AND `modManagerLog`.`classKey` = "modChunk"');
     $c->leftJoin('modSnippet', 'Snippet', '`modManagerLog`.item = `Snippet`.`id` AND `modManagerLog`.`classKey` = "modSnippet"');
     $c->leftJoin('modPlugin', 'Plugin', '`modManagerLog`.item = `Plugin`.`id` AND `modManagerLog`.`classKey` = "modPlugin"');
     $c->leftJoin('modTemplateVar', 'TV', '`modManagerLog`.item = `TV`.`id` AND `modManagerLog`.`classKey` = "modTemplateVar"');
     $query = trim($this->getProperty('query'));
     if ($query) {
         $c->where('(Template.templatename LIKE "%' . $query . '%" OR Chunk.name LIKE "%' . $query . '%" OR Snippet.name LIKE "%' . $query . '%" OR Plugin.name LIKE "%' . $query . '%" OR TV.name LIKE "%' . $query . '%")');
     } else {
         $c->where('(modManagerLog.action LIKE "template_%" OR modManagerLog.action LIKE "chunk_%" OR modManagerLog.action LIKE "snippet_%" OR modManagerLog.action LIKE "plugin_%" OR modManagerLog.action LIKE "tv_%")');
     }
     $user = intval($this->getProperty('user'));
     if ($user) {
         $c->andCondition(array('modManagerLog.user' => $user));
     }
     $dateStart = trim($this->getProperty('datestart'));
     if ($dateStart) {
         $dateStart = date('Y-m-d', strtotime($dateStart));
         $c->andCondition(array('modManagerLog.occurred:>=' => $dateStart));
     }
     $dateEnd = trim($this->getProperty('dateend'));
     if ($dateEnd) {
         $dateEnd = date('Y-m-d 23:59:59', strtotime($dateEnd));
         $c->andCondition(array('modManagerLog.occurred:<=' => $dateEnd));
     }
     return $c;
 }
 public function prepareQueryAfterCount(xPDOQuery $c)
 {
     $c->leftJoin('modUserGroupRole', 'Role', array('Role.authority = modAccessContext.authority'));
     $c->leftJoin('modAccessPolicy', 'Policy');
     $c->select($this->modx->getSelectColumns('modAccessContext', 'modAccessContext'));
     $c->select(array('role_name' => 'Role.name', 'policy_name' => 'Policy.name', 'policy_data' => 'Policy.data'));
     return $c;
 }
Exemple #8
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->where(array('newsletter_id' => $this->getProperty('newsletter_id')));
     $c->leftJoin('modUser', 'modUser', 'sxSubscriber.user_id = modUser.id');
     $c->leftJoin('modUserProfile', 'modUserProfile', 'sxSubscriber.user_id = modUserProfile.internalKey');
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->select('modUser.username, modUserProfile.fullname');
     return $c;
 }
Exemple #9
0
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('msOrderStatus', 'msOrderStatus', '`msOrderLog`.`entry` = `msOrderStatus`.`id`');
     $c->leftJoin('msOrder', 'msOrder', '`msOrder`.`id` = `msOrderLog`.`order_id`');
     $c->where(array('order_id' => $this->getProperty('order_id'), 'msOrder.user_id' => $this->modx->user->id, 'action' => 'status'));
     $c->select($this->modx->getSelectColumns('msOrderLog', 'msOrderLog', '', array('timestamp', 'action', 'entry')));
     $c->select('`msOrderStatus`.`name` as `entry`, `msOrderStatus`.`color`');
     return $c;
 }
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin($this->linkedKey, $this->linkedKey, $this->classKey . '.id = ' . $this->linkedKey . '.id');
     $c->leftJoin('msdSaleMember', 'msdSaleMember', array($this->classKey . '.id = msdSaleMember.group_id', 'msdSaleMember.type' => $this->getProperty('type'), 'msdSaleMember.sale_id' => $this->getProperty('sale_id')));
     $c->select($this->modx->getSelectColumns($this->linkedKey, $this->linkedKey));
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->where(array('msdSaleMember.sale_id' => null));
     return $c;
 }
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->where(array('type' => $this->getProperty('type'), 'sale_id' => $this->getProperty('sale_id')));
     $c->leftJoin($this->linkedKey1, $this->linkedKey1, $this->classKey . '.group_id = ' . $this->linkedKey1 . '.id');
     $c->leftJoin($this->linkedKey2, $this->linkedKey2, $this->classKey . '.group_id = ' . $this->linkedKey2 . '.id');
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->select($this->modx->getSelectColumns($this->linkedKey1, $this->linkedKey1));
     $c->select($this->modx->getSelectColumns($this->linkedKey2, $this->linkedKey2));
     return $c;
 }
Exemple #12
0
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->innerJoin('msOrder', 'msOrder', '`msOrderProduct`.`order_id` = `msOrder`.`id`');
     $c->leftJoin('msProduct', 'msProduct', '`msOrderProduct`.`product_id` = `msProduct`.`id`');
     $c->leftJoin('msProductData', 'msProductData', '`msOrderProduct`.`product_id` = `msProductData`.`id`');
     $c->where(array('order_id' => $this->getProperty('order_id'), 'msOrder.user_id' => $this->modx->user->id));
     $c->select($this->modx->getSelectColumns('msOrderProduct', 'msOrderProduct'));
     $c->select($this->modx->getSelectColumns('msProduct', 'msProduct', 'product_'));
     $c->select($this->modx->getSelectColumns('msProductData', 'msProductData', 'product_', array('id'), true));
     return $c;
 }
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modUser', 'modUser', 'modalWindow.user = modUser.id');
     $c->leftJoin('modUserGroup', 'modUserGroup', 'modalWindow.group = modUserGroup.id');
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->select(array('user_description' => 'modUser.username', 'group_description' => 'modUserGroup.name'));
     $query = trim($this->getProperty('query'));
     if ($query) {
         $c->where(array('name:LIKE' => "%{$query}%", 'OR:description:LIKE' => "%{$query}%"));
     }
     return $c;
 }
Exemple #14
0
 /**
  * @param xPDOQuery $c
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $q = trim($this->getProperty('query'));
     $c->leftJoin('modUserProfile', 'modUserProfile', 'createdby = modUserProfile.internalKey');
     $c->leftJoin('modResource', 'modResource', 'res_id = modResource.id');
     $c->select($this->modx->getSelectColumns('idfxUserLikes', 'idfxUserLikes'));
     $c->select('modUserProfile.fullname as user_name, modResource.pagetitle as title');
     if ($q) {
         $c->where(array('modUserProfile.fullname:LIKE' => "%{$q}%", 'OR:modResource.pagetitle:LIKE' => "%{$q}%"));
     }
     return $c;
 }
Exemple #15
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modUser', 'modUser', '`Company`.`user` = `modUser`.`id`');
     $c->leftJoin('modUserProfile', 'modUserProfile', '`Company`.`user` = `modUserProfile`.`internalKey`');
     $companyColumns = $this->modx->getSelectColumns('Company', 'Company', '', array('user'), true);
     $c->select($companyColumns . ', `Company`.`user` as `user_id`, `modUserProfile`.`fullname` as `customer`, `modUser`.`username` as `customer_username`');
     $query = trim($this->getProperty('query'));
     if ($query) {
         $c->where(array('name:LIKE' => "%{$query}%", 'OR:description:LIKE' => "%{$query}%"));
     }
     return $c;
 }
 /**
  * @return mixed
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $rid = trim($this->getProperty('resource'));
     $c->setClassAlias('Permissions');
     $c->leftJoin('modUserProfile', 'User', 'Permissions.principal = User.internalKey AND Permissions.principal_type = "usr"');
     $c->leftJoin('modUserGroup', 'Group', 'Permissions.principal = Group.id AND Permissions.principal_type = "grp"');
     $c->select('Permissions.*, User.fullname, Group.name as groupname');
     $c->where(array('Permissions.rid' => $rid));
     $c->sortby('Permissions.weight', 'ASC');
     //$c->sortby('Permissions.priority', 'DESC');
     return $c;
 }
Exemple #17
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modMediaSource', 'Source');
     $c->leftJoin($this->classKey, 'Thumb', "`{$this->classKey}`.`id` = `Thumb`.`parent`");
     $c->groupby($this->classKey . '.id');
     $c->select('`Source`.`name` as `source_name`');
     $c->select('`Thumb`.`url` as `thumbnail`');
     $c->where(array('resource_id' => $this->getProperty('resource_id')));
     $parent = $this->getProperty('parent');
     if ($parent !== false) {
         $c->where(array('parent' => $parent));
     }
     return $c;
 }
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->innerJoin('msOrder', 'msOrder', '`msOrderProduct`.`order_id` = `msOrder`.`id`');
     $c->leftJoin('msProduct', 'msProduct', '`msOrderProduct`.`product_id` = `msProduct`.`id`');
     $c->leftJoin('msProductData', 'msProductData', '`msOrderProduct`.`product_id` = `msProductData`.`id`');
     $c->where(array('order_id' => $this->getProperty('order_id')));
     $c->select($this->modx->getSelectColumns('msOrderProduct', 'msOrderProduct'));
     $c->select($this->modx->getSelectColumns('msProduct', 'msProduct', 'product_'));
     $c->select($this->modx->getSelectColumns('msProductData', 'msProductData', 'product_', array('id'), true));
     if ($query = $this->getProperty('query', null)) {
         $c->where(array('msProduct.pagetitle:LIKE' => '%' . $query . '%', 'OR:msProduct.description:LIKE' => '%' . $query . '%', 'OR:msProduct.introtext:LIKE' => '%' . $query . '%', 'OR:msProductData.article:LIKE' => '%' . $query . '%', 'OR:msProductData.vendor:LIKE' => '%' . $query . '%', 'OR:msProductData.made_in:LIKE' => '%' . $query . '%'));
     }
     return $c;
 }
Exemple #19
0
 /** {@inheritDoc} */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('vpEvent', 'vpEvent', '`vpRoute`.`event` = `vpEvent`.`id`');
     $c->leftJoin('vpHandler', 'vpHandler', '`vpRoute`.`handler` = `vpHandler`.`id`');
     $routeColumns = $this->modx->getSelectColumns('vpRoute', 'vpRoute', '', array(), true);
     $c->select($routeColumns . ', `vpEvent`.`name` as `event_name`, `vpHandler`.`name` as `handler_name`');
     if ($active = $this->getProperty('active')) {
         $c->where(array('active' => $active));
     }
     if ($this->getProperty('combo')) {
         $c->select('id,name');
         $c->where(array('active' => 1));
     }
     return $c;
 }
Exemple #20
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->groupby('glData.id');
     $c->leftJoin('glCountry', 'glCountry', 'glCountry.id = glData.identifier');
     $c->leftJoin('glRegion', 'glRegion', 'glRegion.id = glData.identifier');
     $c->leftJoin('glCity', 'glCity', 'glCity.id = glData.identifier');
     $c->select($this->modx->getSelectColumns('glData', 'glData'));
     $c->select(array('name' => 'glCountry.name_ru', 'name1' => 'glRegion.name_ru', 'name2' => 'glCity.name_ru', 'active' => 'glCountry.active', 'active1' => 'glRegion.active', 'active2' => 'glCity.active'));
     $query = trim($this->getProperty('query'));
     if ($query) {
         $c->where(array('name_ru:LIKE' => "%{$query}%", 'OR:name_en:LIKE' => "%{$query}%"));
     }
     //		$c->sortby('active', 'DESC');
     //		$c->sortby('name_ru', 'ASC');
     return $c;
 }
 /**
  * @return mixed
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modUser', 'UserCreate');
     $c->select('adminNotes.*, UserCreate.username');
     $where = '(adminNotes.private = 0 OR adminNotes.private = 1 AND adminNotes.createdby = ' . $this->modx->user->get('id') . ')';
     $query = trim($this->getProperty('searchQuery'));
     $wheresearch = trim($this->getProperty('wheresearch'));
     if ($query) {
         switch ($wheresearch) {
             case 1:
             case '':
                 $where .= ' AND (adminNotes.title LIKE "%' . $query . '%" OR adminNotes.text LIKE "%' . $query . '%"  OR FIND_IN_SET(\'' . $query . '\', `tags`))';
                 break;
             case 2:
                 $where .= ' AND adminNotes.title LIKE "%' . $query . '%"';
                 break;
             case 3:
                 $where .= ' AND adminNotes.text LIKE "%' . $query . '%"';
                 break;
             case 4:
                 $where .= " AND FIND_IN_SET('{$query}', `tags`)";
                 break;
         }
     }
     $c->where($where);
     $private = $this->getProperty('private');
     if ($private) {
         $c->andCondition(array('adminNotes.createdby' => $this->modx->user->id));
     }
     return $c;
 }
 /**
  * {@inheritdoc}
  * @param xPDOQuery $c
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $this->elementId = $this->getProperty('elementId', false);
     $this->elementType = $this->getProperty('elementType', false);
     $id = $this->getProperty('id', 0);
     /*$tagNameParts = xPDO :: escSplit('@', $this->getProperty('tag'));
       $propertySet = isset($tagNameParts[1]) ? trim($tagNameParts[1]) : null;
       if (isset($propertySet) && strpos($propertySet,':') != false) {
           $propSetParts = xPDO :: escSplit(':', $propertySet);
           $propertySet = trim($propSetParts[0]);
       }*/
     $c->leftJoin('modElementPropertySet', 'Elements', array('Elements.element_class' => $this->elementType, 'Elements.element' => $this->elementId, 'Elements.property_set = modPropertySet.id'));
     $this->showNotAssociated = (bool) $this->getProperty('showNotAssociated', false);
     $showAssociated = (bool) $this->getProperty('showAssociated', false);
     if ($this->showNotAssociated) {
         $c->where(array('Elements.property_set' => null));
     } else {
         if ($showAssociated) {
             $c->where(array('Elements.property_set:!=' => null));
         }
     }
     /*if (empty($id)) {
           $propertySet = $this->getProperty('propertySet', '');
           if (!empty($propertySet) && $this->modx->getCount('modPropertySet', array('name'=>$propertySet))) {
               $c->orCondition("modPropertySet.name = {$this->modx->quote($propertySet)}");
           }
       }*/
     return $c;
 }
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin($this->classKey, 'Children');
     $c->where(array($this->classKey . '.parent' => $this->getProperty('id')));
     $c->groupby($this->classKey . '.text');
     return parent::prepareQueryBeforeCount($c);
 }
Exemple #24
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('glRegion', 'glRegion', 'glRegion.id = glCity.region_id');
     $c->select($this->modx->getSelectColumns('glCity', 'glCity'));
     $c->select(array('region_name_ru' => 'glRegion.name_ru'));
     $id = $this->getProperty('id');
     if (!empty($id) and $this->getProperty('combo')) {
         $q = $this->modx->newQuery($this->objectType);
         $q->where(array('id!=' => $id));
         $q->select('id');
         $q->limit(11);
         $q->prepare();
         $q->stmt->execute();
         $ids = $q->stmt->fetchAll(PDO::FETCH_COLUMN, 0);
         $ids = array_merge_recursive(array($id), $ids);
         $c->where(array("{$this->objectType}.id:IN" => $ids));
     }
     $regionId = $this->getProperty('region_id');
     if ($regionId != '') {
         $c->where("{$this->objectType}.region_id={$regionId}");
     }
     $active = $this->getProperty('active');
     if ($active != '') {
         $c->where("{$this->objectType}.active={$active}");
     }
     $query = trim($this->getProperty('query'));
     if ($query) {
         $c->where(array("{$this->objectType}.name_ru:LIKE" => "%{$query}%", "OR:{$this->objectType}.name_en:LIKE" => "%{$query}%"));
     }
     $c->sortby('glCity.active', 'DESC');
     $c->sortby('glCity.name_ru', 'ASC');
     return $c;
 }
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->innerJoin('galAlbumItem', 'AlbumItems', array('galItem.id = AlbumItems.item', 'AlbumItems.album' => $this->getProperty('album')));
     $c->innerJoin('galAlbum', 'Album', array('Album.id = AlbumItems.album'));
     $c->leftJoin('galTag', 'Tags');
     return $c;
 }
Exemple #26
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modTemplate', 'Template');
     $c->leftJoin('sxSubscriber', 'Subscribers');
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->select($this->modx->getSelectColumns('modTemplate', 'Template', '', array('templatename')));
     $c->select('COUNT(`Subscribers`.`id`) as `subscribers`');
     $c->groupby($this->classKey . '.id');
     if ($query = $this->getProperty('query')) {
         $c->where(array('name:LIKE' => "%{$query}%", 'OR:description:LIKE' => "%{$query}%"));
     }
     if ($this->getProperty('combo')) {
         $c->where(array('active' => 1));
     }
     return $c;
 }
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modUserProfile', 'modUserProfile', '`msOrder`.`user_id` = `modUserProfile`.`internalKey`');
     $c->leftJoin('msOrderStatus', 'msOrderStatus', '`msOrder`.`status` = `msOrderStatus`.`id`');
     $c->leftJoin('msDelivery', 'msDelivery', '`msOrder`.`delivery` = `msDelivery`.`id`');
     $c->leftJoin('msPayment', 'msPayment', '`msOrder`.`payment` = `msPayment`.`id`');
     $orderColumns = $this->modx->getSelectColumns('msOrder', 'msOrder', '', array('status', 'delivery', 'payment'), true);
     $c->select($orderColumns . ', `modUserProfile`.`fullname` as `customer`, `msOrderStatus`.`name` as `status`, `msOrderStatus`.`color`, `msDelivery`.`name` as `delivery`, `msPayment`.`name` as `payment`');
     if ($query = $this->getProperty('query')) {
         $c->where(array('num:LIKE' => '%' . $query . '%', 'OR:comment:LIKE' => '%' . $query . '%', 'OR:modUserProfile.fullname:LIKE' => '%' . $query . '%'));
     }
     if ($status = $this->getProperty('status')) {
         $c->where(array('status' => $status));
     }
     return $c;
 }
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->where(array('user_id' => $this->getProperty('user_id')));
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->leftJoin('msPayment', 'Payment');
     $c->select('Payment.name as payment_name');
     return $c;
 }
Exemple #29
0
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin($this->profitType, $this->profitType, array("{$this->profitType}.group = {$this->classKey}.id", "{$this->profitType}.identifier = {$this->getProperty('identifier')}", "{$this->profitType}.class" => "{$this->classKey}"));
     $c->select($this->modx->getSelectColumns($this->profitType, $this->profitType));
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->where(array("{$this->profitType}.profit" => null));
     return $c;
 }
 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->where(array('group_id' => $this->getProperty('group_id')));
     $c->leftJoin('msOrder', 'Order');
     $c->select($this->modx->getSelectColumns($this->classKey, $this->classKey));
     $c->select($this->modx->getSelectColumns('msOrder', 'Order', '', array('num')));
     return $c;
 }