Beispiel #1
0
 public function get()
 {
     require_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $limitstart = JRequest::getInt('limitstart', 0);
     $limit = JRequest::getInt('limit', 20);
     $active = JRequest::getInt('active', 0);
     $visible = JRequest::getInt('visible', 0);
     $name = JRequest::getVar('name', '');
     $pattern = '/' . preg_quote($name, '/') . '/';
     $limit = $limit > 100 ? 100 : $limit;
     $t_plans = SubscriptionPlanHandler::getFullPlanList();
     $plans = SubscriptionPlanHandler::getFullPlanList($limitstart, $limit);
     $data = array();
     $data["total"] = count($t_plans);
     $sel_plan = array();
     foreach ($plans as $k => $val) {
         //$val->group_id = ItemGroupHandler::getItemListItem($val);
         unset($val->params);
         unset($val->custom_params);
         unset($val->restrictions);
         unset($val->micro_integrations);
         unset($val->lifetime);
         unset($val->email_desc);
         if ($active && $visible && $val->active == 1 && $val->visible == 1) {
             $sel_plan[$val->id] = $val;
         } elseif ($active && $val->active == $active && $val->visible != 0) {
             $sel_plan[$val->id] = $val;
         } elseif ($visible && $val->visible == $visible && $val->active != 0) {
             $sel_plan[$val->id] = $val;
         } elseif ($visible == 0 && $active == 0 && $name == '') {
             $sel_plan[$val->id] = $val;
         }
     }
     //$match = preg_match($pattern, $val->name);
     $name_arr = array();
     foreach ($sel_plan as $k => $v) {
         if (preg_match($pattern, $v->name)) {
             $name_arr[$v->id] = $v;
         }
         $sel_plan = $name_arr;
     }
     $data['count'] = count($sel_plan);
     $data['users'] = $sel_plan;
     $this->plugin->setResponse($data);
 }
Beispiel #2
0
 public function index()
 {
     if (!empty($this->state->filter->group)) {
         $subselect = ItemGroupHandler::getChildren($this->state->filter->group, 'item');
         $this->addConstraint('id IN (' . implode(',', $subselect) . ')');
     } else {
         $subselect = array();
     }
     $nav = $this->getPagination();
     // get the subset (based on limits) of records
     $rows = SubscriptionPlanHandler::getFullPlanList($nav->limitstart, $nav->limit, $subselect, $this->state->sort, $this->state->search);
     $gcolors = array();
     foreach ($rows as $n => $row) {
         $query = 'SELECT count(*)' . ' FROM #__acctexp_subscr' . ' WHERE plan = ' . $row->id . ' AND (status = \'Active\' OR status = \'Trial\')';
         $this->db->setQuery($query);
         $rows[$n]->usercount = $this->db->loadResult();
         if ($this->db->getErrorNum()) {
             echo $this->db->stderr();
             return false;
         }
         $query = 'SELECT count(*)' . ' FROM #__acctexp_subscr' . ' WHERE plan = ' . $row->id . ' AND (status = \'Expired\')';
         $this->db->setQuery($query);
         $rows[$n]->expiredcount = $this->db->loadResult();
         if ($this->db->getErrorNum()) {
             echo $this->db->stderr();
             return false;
         }
         $query = 'SELECT group_id' . ' FROM #__acctexp_itemxgroup' . ' WHERE type = \'item\'' . ' AND item_id = \'' . $rows[$n]->id . '\'';
         $this->db->setQuery($query);
         $groups = xJ::getDBArray($this->db);
         $rows[$n]->groups = array();
         foreach ($groups as $group) {
             if (empty($group)) {
                 continue;
             }
             if (!isset($gcolors[$group])) {
                 $gcolors[$group] = array();
                 $gcolors[$group]['color'] = ItemGroupHandler::groupColor($group);
             }
             $rows[$n]->groups[] = (object) array('id' => $group, 'color' => $gcolors[$group]['color']);
         }
     }
     $grouplist = ItemGroupHandler::getTree();
     $glist = array();
     $sel_groups = array();
     $glist[] = JHTML::_('select.option', 0, '- - - - - -');
     if (empty($this->state->filter->group)) {
         $sel_groups[] = JHTML::_('select.option', 0, '- - - - - -');
     }
     foreach ($grouplist as $id => $glisti) {
         if (defined('JPATH_MANIFESTS')) {
             $glist[] = JHTML::_('select.option', $glisti[0], str_replace(' ', ' ', $glisti[1]));
         } else {
             $glist[] = JHTML::_('select.option', $glisti[0], $glisti[1]);
         }
         if (!empty($this->state->filter->group)) {
             if (in_array($glisti[0], $this->state->filter->group)) {
                 $sel_groups[] = JHTML::_('select.option', $glisti[0], $glisti[1]);
             }
         }
     }
     $lists['filter_group'] = JHTML::_('select.genericlist', $glist, 'group[]', 'size="4" multiple="multiple"', 'value', 'text', $sel_groups);
     $totals = array();
     $query = 'SELECT count(*)' . ' FROM #__acctexp_subscr' . ' WHERE (status = \'Active\' OR status = \'Trial\')' . (empty($subselect) ? '' : ' AND plan IN (' . implode(',', $subselect) . ')');
     $this->db->setQuery($query);
     $totals['active'] = $this->db->loadResult();
     if ($this->db->getErrorNum()) {
         echo $this->db->stderr();
         return false;
     }
     $query = 'SELECT count(*)' . ' FROM #__acctexp_subscr' . ' WHERE (status = \'Expired\')' . (empty($subselect) ? '' : ' AND plan IN (' . implode(',', $subselect) . ')');
     $this->db->setQuery($query);
     $totals['expired'] = $this->db->loadResult();
     if ($this->db->getErrorNum()) {
         echo $this->db->stderr();
         return false;
     }
     foreach ($rows as $rid => $row) {
         $rows[$rid]->link = 'index.php?option=com_acctexp&task=index&entity=Membership&plan=' . $row->id . '&groups[]=all';
         $rows[$rid]->link_active = 'index.php?option=com_acctexp&task=index&entity=Membership&plan=' . $row->id . '&groups[]=active';
         $rows[$rid]->link_expired = 'index.php?option=com_acctexp&task=index&entity=Membership&plan=' . $row->id . '&groups[]=expired';
         if ($totals['expired']) {
             $rows[$rid]->expired_percentage = $row->expiredcount / ($totals['expired'] / 100);
         } else {
             $rows[$rid]->expired_percentage = 0;
         }
         $rows[$rid]->expired_inner = false;
         if ($rows[$rid]->expired_percentage > 45) {
             $rows[$rid]->expired_inner = true;
         }
         if ($totals['active']) {
             $rows[$rid]->active_percentage = $row->usercount / ($totals['active'] / 100);
         } else {
             $rows[$rid]->active_percentage = 0;
         }
         $rows[$rid]->active_inner = false;
         if ($rows[$rid]->active_percentage > 45) {
             $rows[$rid]->active_inner = true;
         }
         if ($totals['active'] + $totals['expired']) {
             $rows[$rid]->total_percentage = ($row->expiredcount + $row->usercount) / (($totals['active'] + $totals['expired']) / 100);
         } else {
             $rows[$rid]->total_percentage = 0;
         }
         $rows[$rid]->total_inner = false;
         if ($rows[$rid]->total_percentage > 20) {
             $rows[$rid]->total_inner = true;
         }
         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::listSubscriptionPlans($rows, $this->state, $lists, $nav);
 }
Beispiel #3
0
 /**
  * @param string $method
  */
 public function aecReadout($optionlist, $method)
 {
     $this->optionlist = $optionlist;
     $this->method = "conversionHelper" . strtoupper($method);
     $this->lists = array();
     $this->acllist = xJACLhandler::aclList();
     foreach ($this->acllist as $aclitem) {
         $this->lists['gid'][$aclitem->group_id] = $aclitem->name;
     }
     $this->planlist = SubscriptionPlanHandler::getFullPlanList();
     foreach ($this->planlist as $planitem) {
         $this->lists['plan'][$planitem->id] = $planitem->name;
     }
     $this->milist = microIntegrationHandler::getMIList(null, null, isset($_POST['use_ordering']), true);
     foreach ($this->milist as $miitem) {
         $this->lists['mi'][$miitem->id] = $miitem->name;
     }
 }