Пример #1
0
 /**
  *
  * @return array|boolean 
  */
 function getRemainingEntities($key, $remaining, $which = 'remaining')
 {
     $this->db->select("i.Name, m.Filename, i.ItemsID, l.KeysID");
     $this->db->from("leads l");
     $this->db->join('items i', 'l.ItemsID=i.ItemsID');
     $this->db->join('media m', 'l.MediaID=m.MediaID', 'left');
     $this->db->where('l.KeysID', $key);
     $this->db->where('!isnull(l.ItemsID)', false, false);
     if ($which == 'remaining') {
         $this->db->where_in('l.ItemsID', $remaining);
     } else {
         $this->db->where_not_in('l.ItemsID', $remaining);
     }
     if ($this->FilterItems) {
         $this->db->where_in('i.ItemsID', $this->FilterItems);
     }
     $this->db->group_by('i.Name');
     $query = $this->db->get();
     if ($query->num_rows()) {
         $ret = array();
         foreach ($query->result() as $row) {
             $items = $this->nextKey($row->ItemsID, parent::getProjectID($key));
             $thisitem = isset($items[0]) ? $items[0] : FALSE;
             $linkToItem = count($items) > 1 ? $items[1] : FALSE;
             $name = array();
             $name['name'] = $thisitem ? $thisitem->ItemName : $row->ItemsID;
             $name['NamesID'] = NULL;
             $name['tokey'] = $thisitem ? $thisitem->KeysID : FALSE;
             $name['LinkTo'] = $linkToItem ? $linkToItem->ItemName : FALSE;
             $name['LinkToKey'] = $linkToItem ? $linkToItem->KeysID : FALSE;
             $name['media'] = $row->Filename;
             $name['url'] = $thisitem ? $thisitem->ItemUrl : FALSE;
             $name['linkToUrl'] = $linkToItem ? $linkToItem->ItemUrl : FALSE;
             $ret[] = $name;
         }
         return $ret;
     } else {
         return false;
     }
 }