Exemplo n.º 1
0
 /**
  * Applies a custom query to the QueryBuilder
  * 
  * @param QueryBuilder $qb The query builder
  * @param ManagerFilter $filter The query filter
  */
 protected function applyCustomQuery(QueryBuilder $qb, ManagerFilter $filter)
 {
     // Apply special handling for non-direct fields in relations, where the frontend has no idea about.
     foreach ($filter->getSorters() as $sorter) {
         switch ($sorter->getSortField()) {
             case "q.part_name":
                 $qb->join("q.part", "p");
                 $sorter->setSortField("p.name");
                 break;
             case "q.user_id":
                 $qb->leftJoin("q.user", "u");
                 $sorter->setSortField("u.username");
                 break;
             case "q.direction":
                 $sorter->setSortField("q.dateTime");
                 break;
             case "q.storageLocation_name":
                 $qb->join("q.part", "p")->join("p.storageLocation", "st");
                 $sorter->setSortField("st.name");
                 break;
             default:
                 break;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Appends various join tables to the result set
  * 
  * (non-PHPdoc)
  * @see PartKeepr\Manager.AbstractManager::applyCustomQuery()
  */
 protected function applyCustomQuery(QueryBuilder $qb, ManagerFilter $filter)
 {
     /**
      * Pull in additional tables
      */
     $qb->join("q.storageLocation", "st")->leftJoin("q.footprint", "f")->join("q.category", "c")->leftJoin("q.partUnit", "pu");
     // Apply special handling for non-direct fields in relations, where the frontend has no idea about.
     foreach ($filter->getSorters() as $sorter) {
         switch ($sorter->getSortField()) {
             case "q.categoryPath":
                 $sorter->setSortField("c.categoryPath");
                 break;
             case "q.storageLocationName":
                 $sorter->setSortField("st.name");
                 break;
             case "q.footprintName":
                 $sorter->setSortField("f.name");
                 break;
             default:
                 break;
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Applies record sorting
  * 
  * @param QueryBuilder $qb The query builder
  * @param ManagerFilter $filter The query filter
  */
 protected function applySorting(QueryBuilder $qb, ManagerFilter $filter)
 {
     foreach ($filter->getSorters() as $sorter) {
         if ($sorter->getSortField() !== null && $sorter->getSortField() != "q.") {
             $qb->addOrderBy($sorter->getSortField(), $sorter->getSortDirection());
         }
     }
 }