示例#1
0
 public function index()
 {
     $rows = $this->getRows('ItemGroup');
     $gcolors = array();
     foreach ($rows as $rid => $row) {
         $query = 'SELECT count(*)' . 'FROM #__users AS a' . ' LEFT JOIN #__acctexp_subscr AS b ON a.id = b.userid' . ' WHERE b.plan = ' . $row->id . ' AND (b.status = \'Active\' OR b.status = \'Trial\')';
         $this->db->setQuery($query);
         $rows[$rid]->usercount = $this->db->loadResult();
         if ($this->db->getErrorNum()) {
             echo $this->db->stderr();
             return false;
         }
         $query = 'SELECT count(*)' . ' FROM #__users AS a' . ' LEFT JOIN #__acctexp_subscr AS b ON a.id = b.userid' . ' WHERE b.plan = ' . $row->id . ' AND (b.status = \'Expired\')';
         $this->db->setQuery($query);
         $rows[$rid]->expiredcount = $this->db->loadResult();
         if ($this->db->getErrorNum()) {
             echo $this->db->stderr();
             return false;
         }
         $gid = $rows[$rid]->id;
         if (!isset($gcolors[$gid])) {
             $gcolors[$gid] = array();
             $gcolors[$gid]['color'] = ItemGroupHandler::groupColor($gid);
         }
         $rows[$rid]->color = $gcolors[$gid]['color'];
         $parents = ItemGroupHandler::getParents($gid, 'group');
         $rows[$rid]->parent_groups = array();
         if (!empty($parents)) {
             foreach ($parents as $parent) {
                 if (!isset($gcolors[$parent])) {
                     $gcolors[$parent] = array();
                     $gcolors[$parent]['color'] = ItemGroupHandler::groupColor($parent);
                 }
                 $rows[$rid]->parent_groups[] = (object) array('id' => $parent, 'color' => $gcolors[$parent]['color']);
             }
         } else {
             $rows[$rid]->parent_groups[] = (object) array('id' => $gid, 'color' => $gcolors[$gid]['color']);
         }
         if (!empty($row->desc)) {
             $rows[$rid]->desc = stripslashes(strip_tags($row->desc));
             if (strlen($rows[$rid]->desc) > 50) {
                 $rows[$rid]->desc = substr($rows[$rid]->desc, 0, 50) . ' ...';
             }
         }
     }
     HTML_AcctExp::listItemGroups($rows, $this->getPagination(), $this->state);
 }