/**
  * This is not the best example to follow
  * Please see the category plugin for a better example
  */
 public function post()
 {
     require_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $db =& JFactory::getDBO();
     $app = JFactory::getApplication();
     $userid = JRequest::getInt('user_id', 0);
     $planid = JRequest::getInt('plan_id', 0);
     //$new_expiry = JRequest::getString('date',0);
     $obj = new stdClass();
     //validate plan
     $plans = SubscriptionPlanHandler::getPlanList();
     $muser = metaUserDB::getIDbyUserid($userid);
     //$pplan = metaUserDB::getPreviousPlan($muser);
     //$uplan = metaUserDB::getUsedPlans($muser);
     //print_r($new_expiry);die;
     if (!$userid) {
         $obj->success = 0;
         $obj->code = 21;
         $obj->message = "invalid user id";
     } elseif (!$plans[array_search($planid, $plans)]) {
         $obj->success = 0;
         $obj->code = 22;
         $obj->message = "invalid plan id";
     } else {
         $plan = new SubscriptionPlan($db);
         $plan->load($planid);
         //print_r($plan->params['full_period']);die;
         //check user is metauser
         /*if ( is_a( $user, 'metaUser' ) ) {
         			$metaUser = $user;
         			} elseif( is_a( $user, 'Subscription' ) ) {
         			$metaUser = new metaUser( $user->userid );
         
         			$metaUser->focusSubscription = $user;
         			}*/
         $metaUser = new metaUser($userid);
         $renew = $metaUser->is_renewing();
         //$metaUser->focusSubscription->lifetime;
         $metaUser->focusSubscription->plan = $planid;
         $metaUser->focusSubscription->status = 'Active';
         $metaUser->temporaryRFIX();
         //$metaUser->focusSubscription->lifetime = 1;
         //set expiration
         $now = (int) gmdate('U');
         //$current = strtotime($new_expiry);
         //$metaUser->focusSubscription->expiration = $new_expiry;
         //$metaUser->objSubscription->expiration = $new_expiry;
         $reply = $metaUser->focusSubscription->storeload();
         if ($reply && $planid) {
             $history = new logHistory($db);
             $obj->success = 1;
             $obj->message = "User added to plan";
         }
     }
     $this->plugin->setResponse($obj);
 }
 /**
  * This is not the best example to follow
  * Please see the category plugin for a better example
  */
 public function post()
 {
     require_once JPATH_SITE . '/components/com_acctexp/acctexp.class.php';
     $db =& JFactory::getDBO();
     $app = JFactory::getApplication();
     $userid = JRequest::getInt('user_id', 0);
     $planid = JRequest::getInt('plan_id', 0);
     $new_expiry = JRequest::getString('date', 0);
     //convert date in format
     $new_expiry = date("Y-m-d h:i:s", strtotime($new_expiry));
     $obj = new stdClass();
     //validate plan
     $plans = SubscriptionPlanHandler::getPlanList();
     $muser = metaUserDB::getIDbyUserid($userid);
     $plnuser = SubscriptionPlanHandler::getPlanUserlist($planid);
     if (!$userid) {
         $obj->success = 0;
         $obj->code = 21;
         $obj->message = "invalid user id";
     } elseif (!$plans[array_search($planid, $plans)]) {
         $obj->success = 0;
         $obj->code = 22;
         $obj->message = "invalid plan id";
     } elseif ($userid == $plnuser[array_search($userid, $plnuser)]) {
         $plan = new SubscriptionPlan($db);
         $plan->load($planid);
         $metaUser = new metaUser($userid);
         $renew = $metaUser->is_renewing();
         $lifetime = $metaUser->focusSubscription->lifetime;
         $metaUser->focusSubscription->plan = $planid;
         $metaUser->focusSubscription->status = 'Active';
         $metaUser->temporaryRFIX();
         $metaUser->focusSubscription->lifetime = 0;
         //set expiration
         //$now = (int) gmdate('U');
         $metaUser->focusSubscription->expiration = $new_expiry;
         //$metaUser->objSubscription->expiration = $new_expiry;
         $reply = $metaUser->focusSubscription->storeload();
         if ($reply && $planid) {
             $obj->success = 1;
             $obj->message = "Expiry updated";
         }
     } else {
         $obj->success = 0;
         $obj->code = 31;
         $obj->message = "Plan not assigned to user";
     }
     $this->plugin->setResponse($obj);
 }
Beispiel #3
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 #4
0
 public function Action()
 {
     if (empty($_POST['delete'])) {
         return '<p>Please select a processor to remove.</p>';
     }
     if (empty($_POST['replace'])) {
         return '<p>Please select a processor to replace the removed processor with.</p>';
     }
     $db = JFactory::getDBO();
     $replacepp = new PaymentProcessor();
     $replacepp->loadName($_POST['replace']);
     $deletepp = new PaymentProcessor();
     $deletepp->loadName($_POST['delete']);
     $query = 'UPDATE #__acctexp_invoices' . ' SET `method` = \'' . $replacepp->processor_name . '\'' . ' WHERE `method` = \'' . $deletepp->processor_name . '\'';
     $db->setQuery($query);
     $db->query();
     $query = 'UPDATE #__acctexp_subscr' . ' SET `type` = \'' . $replacepp->processor_name . '\'' . ' WHERE `type` = \'' . $deletepp->processor_name . '\'';
     $db->setQuery($query);
     $db->query();
     $query = 'UPDATE #__acctexp_log_history' . ' SET `proc_id` = \'' . $replacepp->id . '\', `proc_name` = \'' . $replacepp->processor_name . '\'' . ' WHERE `proc_name` = \'' . $replacepp->processor_name . '\'';
     $db->setQuery($query);
     $db->query();
     $planlist = SubscriptionPlanHandler::getPlanList();
     foreach ($planlist as $planid) {
         $plan = new SubscriptionPlan();
         $plan->load($planid);
         if (empty($plan->params['processors'])) {
             continue;
         }
         if (in_array($deletepp->id, $plan->params['processors'])) {
             unset($plan->params['processors'][array_search($deletepp->id, $plan->params['processors'])]);
             if (!in_array($replacepp->id, $plan->params['processors'])) {
                 $plan->params['processors'][] = $replacepp->id;
             }
             $plan->check();
             $plan->store();
         }
     }
     $query = 'DELETE FROM #__acctexp_config_processors' . ' WHERE `id` = \'' . $deletepp->id . '\'';
     $db->setQuery($query);
     $db->query();
     return "<p>Alright, replaced and deleted!</p>";
 }
Beispiel #5
0
    $trial = strcmp($metaUser->objSubscription->status, 'Trial') === 0;
    if (!$trial) {
        $params = $metaUser->objSubscription->params;
        if (isset($params['trialflag'])) {
            $trial = 1;
        }
    }
}
$invoices = aecInvoiceHelper::InvoiceCountbyUserID($metaUser->userid);
if ($invoices) {
    $invoice = aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($metaUser->userid);
} else {
    $invoice = null;
}
$expiration = AECToolbox::formatDate($expired);
$tmpl->setTitle(JText::_('EXPIRED_TITLE'));
$continue = false;
if ($tmpl->cfg['continue_button'] && $metaUser->hasSubscription) {
    $status = SubscriptionPlanHandler::PlanStatus($metaUser->focusSubscription->plan);
    if (!empty($status)) {
        $continue = true;
    }
}
$intro = 0;
if ($metaUser->hasSubscription) {
    if ($metaUser->objSubscription->status == "Expired") {
        $intro = !$tmpl->cfg['intro_expired'];
    }
}
$tmpl->defaultHeader();
@(include $tmpl->tmpl('expired'));
Beispiel #6
0
 public function import()
 {
     $show_form = false;
     $done = false;
     $temp_dir = JPATH_SITE . '/tmp';
     $file_list = xJUtility::getFileArray($temp_dir, 'csv', false, true);
     $params = array();
     $lists = array();
     if (!empty($_FILES)) {
         if (strpos($_FILES['import_file']['name'], '.csv') === false) {
             $last = strrpos($_FILES['import_file']['name'], '.');
             $filename = substr($_FILES['import_file']['name'], 0, $last) . '.csv';
         } else {
             $filename = $_FILES['import_file']['name'];
         }
         $destination = $temp_dir . '/' . $filename;
         if (move_uploaded_file($_FILES['import_file']['tmp_name'], $destination)) {
             $file_select = $filename;
         }
     }
     if (empty($file_select)) {
         $file_select = aecGetParam('file_select', '');
     }
     if (empty($file_select)) {
         $show_form = true;
         $params['file_select'] = array('list', '');
         $params['MAX_FILE_SIZE'] = array('hidden', '5120000');
         $params['import_file'] = array('file', 'Upload', 'Upload a file and select it for importing', '');
         $file_htmllist = array();
         $file_htmllist[] = JHTML::_('select.option', '', JText::_('AEC_CMN_NONE_SELECTED'));
         if (!empty($file_list)) {
             foreach ($file_list as $name) {
                 $file_htmllist[] = JHTML::_('select.option', $name, $name);
             }
         }
         $lists['file_select'] = JHTML::_('select.genericlist', $file_htmllist, 'file_select', 'size="' . min(count($file_htmllist) + 1, 25) . '"', 'value', 'text', 0);
     } else {
         $options = array();
         if (!empty($_POST['assign_plan'])) {
             $options['assign_plan'] = $_POST['assign_plan'];
         }
         $import = new aecImport($temp_dir . '/' . $file_select, $options);
         if (!$import->read()) {
             die('could not read file');
         }
         $import->parse();
         if (empty($import->rows)) {
             die('could not find any entries in this file');
         }
         $params['file_select'] = array('hidden', $file_select);
         if (!isset($_POST['convert_field_0'])) {
             $fields = array('id' => 'User ID', 'name' => 'User Full Name', 'username' => 'Username', 'email' => 'User Email', 'password' => 'Password', 'plan_id' => 'Payment Plan ID', 'invoice_number' => 'Invoice Number', 'expiration' => 'Membership Expiration');
             $mis = array_merge(microIntegrationHandler::getMIList(false, false, false, false, 'mi_aecuserdetails'));
             foreach ($mis as $entry) {
                 $mi = new microIntegration();
                 $mi->load($entry->id);
                 if ($mi->callIntegration()) {
                     $fields = array_merge($fields, $mi->mi_class->getCustomFields());
                 }
             }
             $field_htmllist = array();
             $field_htmllist[] = JHTML::_('select.option', 0, 'Ignore');
             foreach ($fields as $name => $longname) {
                 $field_htmllist[] = JHTML::_('select.option', $name, $longname);
             }
             $cols = count($import->rows[0]);
             $columns = array();
             for ($i = 0; $i < $cols; $i++) {
                 $columns[] = 'convert_field_' . $i;
                 $params['convert_field_' . $i] = array('list', '', '', '');
                 $lists['convert_field_' . $i] = JHTML::_('select.genericlist', $field_htmllist, 'convert_field_' . $i, 'size="1" class="select2-bootstrap"', 'value', 'text', 0);
             }
             $rows_count = count($import->rows);
             $rowcount = min($rows_count, 5);
             $rows = array();
             for ($i = 0; $i < $rowcount; $i++) {
                 $rows[] = $import->rows[$i];
             }
             $params['assign_plan'] = array('list', 'Assign Plan', 'Assign users to a specific payment plan. Is overridden if you provide an individual plan ID with the "Payment Plan ID" field assignment.');
             $params['skip_first'] = array('toggle', 'Skip First Line', 'Do not import the first line (use this if you have column names in the first line).');
             $available_plans = SubscriptionPlanHandler::getActivePlanList();
             $lists['assign_plan'] = JHTML::_('select.genericlist', $available_plans, 'assign_plan', 'size="5"', 'value', 'text', 0);
         } else {
             $import->getConversionList();
             $import->import(array('skip_first' => $_POST['skip_first']));
             $done = true;
         }
     }
     $settingsparams = array();
     $settings = new aecSettings('import', 'general');
     $settings->fullSettingsArray($params, $settingsparams, $lists);
     // Call HTML Class
     $aecHTML = new aecHTML($settings->settings, $settings->lists);
     $aecHTML->form = $show_form;
     $aecHTML->done = $done;
     if (!empty($import->errors)) {
         $aecHTML->errors = $import->errors;
     }
     if (!$show_form && !$done) {
         $aecHTML->user_rows = $rows;
         $aecHTML->user_rows_count = $rows_count;
         $aecHTML->columns = $columns;
     }
     HTML_AcctExp::import($aecHTML);
 }
Beispiel #7
0
 * @package AEC - Account Control Expiration - Membership Manager
 * @subpackage Install Includes
 * @copyright 2006-2015 Copyright (C) David Deutsch
 * @author David Deutsch <*****@*****.**> & Team AEC - http://www.valanx.org
 * @license GNU/GPL v.3 http://www.gnu.org/licenses/gpl.html or, at your option, any later version
 */
// Dont allow direct linking
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
// Check for a root group
$db->setQuery("SELECT id FROM  #__acctexp_itemgroups WHERE id='1'");
// Create root group completely out of thin air (tadaa!)
if ($db->loadResult() != 1) {
    $rootgroup = new ItemGroup();
    $rootgroup->id = 0;
    $rootgroup->active = 1;
    $rootgroup->visible = 1;
    $rootgroup->name = JText::_('AEC_INST_ROOT_GROUP_NAME');
    $rootgroup->desc = JText::_('AEC_INST_ROOT_GROUP_DESC');
    $rootgroup->params = array('color' => 'bbddff', 'icon' => 'flag_blue', 'reveal_child_items' => 1);
    $rootgroup->storeload();
    if ($rootgroup->id != 1) {
        $db->setQuery("UPDATE #__acctexp_itemgroups SET id='1' WHERE id='" . $rootgroup->id . "'");
        $db->query();
    }
    // Adding in root group relation for all plans
    $planlist = SubscriptionPlanHandler::listPlans();
    $db->setQuery("SELECT count(*) FROM  #__acctexp_itemxgroup");
    if (count($planlist) > $db->loadResult()) {
        ItemGroupHandler::setChildren(1, $planlist);
    }
}
Beispiel #8
0
 public function Action()
 {
     if (empty($_POST['start_date'])) {
         return null;
     }
     $db = JFactory::getDBO();
     $query = 'SELECT `id`' . ' FROM #__acctexp_microintegrations' . ' WHERE `class_name` LIKE \'%mi_supporttimetracker%\'';
     $db->setQuery($query);
     $mis = xJ::getDBArray($db);
     $planlist = array();
     foreach ($mis as $mi) {
         $plans = MicroIntegrationHandler::getPlansbyMI($mi);
         $planlist = array_merge($planlist, $plans);
     }
     $planlist = array_unique($planlist);
     $userlist = array();
     foreach ($planlist as $planid) {
         $users = SubscriptionPlanHandler::getPlanUserlist($planid);
         $userlist = array_merge($userlist, $users);
     }
     $userlist = array_unique($userlist);
     $start_timeframe = strtotime($_POST['start_date'] . ' 00:00:00');
     if (!empty($_POST['end_date'])) {
         $end_timeframe = strtotime($_POST['end_date'] . ' 23:59:59');
     } else {
         $end_timeframe = (int) gmdate('U');
     }
     $unused = $used = 0;
     $minordebt = 0;
     $minordebtthresh = 0;
     $minordebtth = 0;
     $minordebtlist = array();
     $majordebt = 0;
     $majordebtlist = array();
     $historylist = array();
     foreach ($userlist as $userid) {
         $db->setQuery('SELECT a.id, a.name, a.username, b.custom_params' . ' FROM #__users AS a' . ' LEFT JOIN `#__acctexp_metauser` AS b ON a.id = b.userid' . ' WHERE a.id = ' . $userid . ' AND b.custom_params <> ""');
         $user = $db->loadObject();
         if (empty($user->id)) {
             continue;
         }
         $uparams = unserialize(base64_decode($user->custom_params));
         if (!empty($uparams['support_minutes_history'])) {
             if (is_array($uparams['support_minutes_history'])) {
                 foreach ($uparams['support_minutes_history'] as $history) {
                     if ($history['tstamp'] > $start_timeframe && $history['tstamp'] <= $end_timeframe) {
                         if (!empty($history['userid']) && $history['minutes_used']) {
                             $add = array();
                             $add['userid'] = $user->id;
                             $add['name'] = $user->name;
                             $add['username'] = $user->username;
                             $historylist[$history['userid']][] = array_merge($history, $add);
                         }
                     }
                 }
             }
         }
         if (!empty($uparams['support_minutes_used'])) {
             $utotal = $uparams['support_minutes'] - $uparams['support_minutes_used'];
         } else {
             $utotal = $uparams['support_minutes'];
         }
         if ($utotal < 0) {
             if ($utotal < -30) {
                 $majordebtlist[] = array('userid' => $user->id, 'username' => $user->username, 'debt' => $utotal);
                 $majordebt += $utotal;
             } elseif ($utotal < -14) {
                 $minordebtlist[] = array('userid' => $user->id, 'username' => $user->username, 'debt' => $utotal);
                 $minordebt += $utotal;
             } else {
                 $minordebtthresh++;
                 $minordebtth += $utotal;
                 $minordebt += $utotal;
             }
         }
         if (!empty($uparams['support_minutes'])) {
             $unused += $uparams['support_minutes'] - $uparams['support_minutes_used'];
         }
         if (!empty($uparams['support_minutes_used'])) {
             $used += $uparams['support_minutes_used'];
         }
     }
     $return = "";
     foreach ($historylist as $userid => $history_list) {
         if (empty($history_list)) {
             continue;
         }
         $total_minutes = 0;
         $metaUser = new metaUser($userid);
         $return .= '<h1>' . $metaUser->cmsUser->name . '</h1>';
         $return .= '<table class="adminlist">';
         $return .= '<tr><th>Date</th><th>Username</th><th>Time Used</th><th>Details</th></tr>';
         $history_list = $this->historySort($history_list);
         foreach ($history_list as $history) {
             $userlink = '<a href="';
             $userlink .= JURI::base() . 'index.php?option=com_acctexp&amp;task=edit&amp;entity=Membership&amp;userid=' . $history['userid'];
             $userlink .= '">';
             $userlink .= $history['name'] . ' (' . $history['username'] . ')';
             $userlink .= '</a>';
             $return .= '<tr>';
             $return .= '<td>' . date('Y-m-d H:i:s', $history['tstamp']) . '</td>';
             $return .= '<td>' . $userlink . '</td>';
             $return .= '<td>' . $history['minutes_used'] . '</td>';
             $return .= '<td>' . $history['details'] . '</td>';
             $return .= '</tr>';
             $total_minutes += $history['minutes_used'];
         }
         $return .= '<tr><td><strong>TOTAL</strong></td><td></td><td><strong>' . $total_minutes . '</strong> (' . round($total_minutes / 60, 2) . ' hours)</td><td></td></tr>';
         $return .= '</table><br /><br />';
     }
     $return .= '<p>Total used minutes: <strong>' . $used . '</strong> (' . round($used / 60, 2) . ' hours)</p>';
     $return .= '<p>Total unused minutes: ' . $unused . ' (' . round($unused / 60, 2) . ' hours)</p>';
     $return .= '<p>Total minor debt: ' . $minordebt . ' (' . round($minordebt / 60, 2) . ' hours)</p>';
     $minordebtlist = $this->debtSort($minordebtlist);
     foreach ($minordebtlist as $user) {
         $return .= '<a href="' . JURI::base() . 'index.php?option=com_acctexp&amp;task=edit&amp;entity=Membership&amp;userid=' . $user['userid'] . '">' . $user['username'] . ' (' . $user['debt'] . ' minutes)</a> ';
     }
     $return .= '<p>' . $minordebtthresh . ' Users below the -15 minute threshhold, total debt: ' . $minordebtth . ' (' . round($majordebt / 60, 2) . ' hours)</p>';
     $return .= '<p>Total major debt: ' . $majordebt . ' (' . round($majordebt / 60, 2) . ' hours)</p>';
     $majordebtlist = $this->debtSort($majordebtlist);
     foreach ($majordebtlist as $user) {
         $return .= '<a href="' . JURI::base() . 'index.php?option=com_acctexp&amp;task=edit&amp;entity=Membership&amp;userid=' . $user['userid'] . '">' . $user['username'] . ' (' . $user['debt'] . ' minutes)</a> ';
     }
     return $return;
 }
 public function savePostParams($array)
 {
     // Strip out params that we don't need
     $params = $this->stripNonParams($array);
     // Filter out restrictions
     $fixed = aecRestrictionHelper::paramList();
     $fixed[] = 'has_restrictions';
     $fixed[] = 'sticky_permissions';
     $restrictions = array();
     foreach ($fixed as $varname) {
         if (!isset($array[$varname])) {
             continue;
         }
         $restrictions[$varname] = $array[$varname];
         unset($array[$varname]);
     }
     $this->restrictions = $restrictions;
     // Check whether there is a custom function for saving params
     $new_params = $this->functionProxy('saveparams', $params, $params);
     $this->name = $array['name'];
     $this->desc = $array['desc'];
     $this->active = $array['active'];
     $this->auto_check = $array['auto_check'];
     $this->on_userchange = $array['on_userchange'];
     $this->pre_exp_check = $array['pre_exp_check'];
     if (!empty($new_params['rebuild'])) {
         $planlist = MicroIntegrationHandler::getPlansbyMI($this->id);
         foreach ($planlist as $planid) {
             $plan = new SubscriptionPlan();
             $plan->load($planid);
             $userlist = SubscriptionPlanHandler::getPlanUserlist($planid);
             foreach ($userlist as $userid) {
                 $metaUser = new metaUser($userid);
                 if ($metaUser->cmsUser->id) {
                     $this->action($metaUser, $params, null, $plan);
                 }
             }
         }
         $newparams['rebuild'] = 0;
     }
     if (!empty($new_params['remove'])) {
         $planlist = MicroIntegrationHandler::getPlansbyMI($this->id);
         foreach ($planlist as $planid) {
             $plan = new SubscriptionPlan();
             $plan->load($planid);
             $userlist = SubscriptionPlanHandler::getPlanUserlist($planid);
             foreach ($userlist as $userid) {
                 $metaUser = new metaUser($userid);
                 $this->expiration_action($metaUser, $plan);
             }
         }
         $newparams['remove'] = 0;
     }
     $this->params = $new_params;
     return true;
 }
Beispiel #10
0
 public function usageStatus()
 {
     if ($this->isCart()) {
         $this->getCart();
         foreach ($this->cart as $citem) {
             if (is_object($citem['obj'])) {
                 if (!$citem['obj']->active || !$citem['obj']->checkInventory()) {
                     return false;
                 }
             }
         }
         return true;
     }
     if (!empty($this->usage)) {
         return SubscriptionPlanHandler::PlanStatus($this->usage);
     }
     return true;
 }
Beispiel #11
0
 public function exportSales()
 {
     $db = JFactory::getDBO();
     $query = 'SELECT `id`' . ' FROM #__acctexp_log_history' . ' WHERE transaction_date >= \'' . $this->filter['date_start'] . '\'' . ' AND transaction_date <= \'' . $this->filter['date_end'] . '\'' . ' ORDER BY transaction_date ASC';
     $db->setQuery($query);
     $entries = xJ::getDBArray($db);
     switch ($this->options['collate']) {
         default:
         case 'day':
             $collation = 'Y-m-d';
             break;
         case 'week':
             $collation = 'Y-W';
             break;
         case 'month':
             $collation = 'Y-m';
             break;
         case 'year':
             $collation = 'Y';
             break;
     }
     $collators = array();
     switch ($this->options['breakdown']) {
         default:
         case 'plan':
             break;
         case 'group':
             $all_groups = ItemGroupHandler::getGroups();
             $collators = array();
             foreach ($all_groups as $gid) {
                 $collators[$gid] = ItemGroupHandler::getChildren($gid, 'item');
             }
             break;
     }
     $historylist = array();
     foreach ($entries as $id) {
         $entry = new logHistory();
         $entry->load($id);
         if (empty($entry->plan_id) || empty($entry->amount)) {
             continue;
         }
         if (!empty($this->filter['groupid'])) {
             if (empty($this->filter['planid'])) {
                 $this->filter['planid'] = array();
             }
             $children = ItemGroupHandler::getChildren($this->filter['groupid'], 'item');
             if (!empty($children)) {
                 $this->filter['planid'] = array_merge($this->filter['planid'], $children);
                 $this->filter['planid'] = array_unique($this->filter['planid']);
             }
         }
         if (!empty($this->filter['planid'])) {
             if (!in_array($entry->plan_id, $this->filter['planid'])) {
                 continue;
             }
         }
         if (!empty($this->filter['method'])) {
             if (!in_array($entry->proc_id, $this->filter['method'])) {
                 continue;
             }
         }
         $refund = false;
         if (is_array($entry->response)) {
             $filter = array('new_case', 'subscr_signup', 'paymentreview', 'subscr_eot', 'subscr_failed', 'subscr_cancel', 'Pending', 'Denied');
             $refund = false;
             foreach ($entry->response as $v) {
                 if (in_array($v, $filter)) {
                     continue 2;
                 } elseif ($v == 'refund' || $v == 'Reversed' || $v == 'Refunded') {
                     $refund = true;
                 }
             }
         }
         $date = date($collation, strtotime($entry->transaction_date));
         if ($this->options['breakdown'] == 'plan') {
             if (!array_key_exists($entry->plan_id, $collators)) {
                 $collators[$entry->plan_id] = 0;
             }
         }
         if (!isset($historylist[$date])) {
             $historylist[$date] = array();
         }
         $historylist[$date][] = $entry;
     }
     $line = array("line" => "Date");
     if ($this->options['breakdown'] == 'plan') {
         foreach ($collators as $col => $colamount) {
             $line['plan-' . $col] = "Plan #{$col}: " . SubscriptionPlanHandler::planName($col);
         }
     } elseif ($this->options['breakdown'] == 'group') {
         foreach ($collators as $col => $colplans) {
             $line['group-' . $col] = "Group #{$col}:" . ItemGroupHandler::groupName($col);
         }
     }
     $line['total_sum'] = "Total";
     // Remove whitespaces and newlines
     foreach ($line as $larrid => $larrval) {
         $line[$larrid] = trim($larrval);
         if (is_numeric($larrval)) {
             $line[$larrid] = AECToolbox::correctAmount($larrval);
         }
     }
     $this->exphandler->putDescription($line);
     $totalsum = 0;
     $collate_all = array();
     foreach ($collators as $col => $colv) {
         $collate_all[$col] = 0;
     }
     foreach ($historylist as $date => $collater) {
         $linesum = 0;
         $collatex = array();
         foreach ($collators as $col => $colv) {
             $collatex[$col] = 0;
         }
         foreach ($collater as $entry) {
             if ($this->options['breakdown'] == 'plan') {
                 $collatex[$entry->plan_id] += $entry->amount;
                 $collate_all[$entry->plan_id] += $entry->amount;
                 $linesum += $entry->amount;
                 $totalsum += $entry->amount;
             } else {
                 $pgroup = 0;
                 foreach ($collators as $gid => $gplans) {
                     if ($entry->plan_id == $gid) {
                         $pgroup = $gid;
                         break;
                     }
                 }
                 if ($pgroup) {
                     $collatex[$pgroup] += $entry->amount;
                     $collate_all[$pgroup] += $entry->amount;
                 }
                 $linesum += $entry->amount;
                 $totalsum += $entry->amount;
             }
         }
         $line = array("date" => $date);
         foreach ($collators as $col => $colamount) {
             if ($this->options['breakdown'] == 'plan') {
                 $line['plan-' . $col] = $collatex[$col];
             } else {
                 $line['group-' . $col] = $collatex[$col];
             }
         }
         $line['total_sum'] = $linesum;
         // Remove whitespaces and newlines
         $i = 0;
         foreach ($line as $larrid => $larrval) {
             $line[$larrid] = trim($larrval);
             if (is_numeric($larrval) && $i) {
                 $line[$larrid] = AECToolbox::correctAmount($larrval);
             }
             $i++;
         }
         $this->exphandler->putln($line);
     }
     $line = array("line" => "Grand Total");
     foreach ($collate_all as $col => $colamount) {
         if ($this->options['breakdown'] == 'plan') {
             $line['plan-' . $col] = $colamount;
         } else {
             $line['group-' . $col] = $colamount;
         }
     }
     $line['total_sum'] = $totalsum;
     // Remove whitespaces and newlines
     foreach ($line as $larrid => $larrval) {
         $line[$larrid] = trim($larrval);
         if (is_numeric($larrval)) {
             $line[$larrid] = AECToolbox::correctAmount($larrval);
         }
     }
     $this->exphandler->putSum($line);
 }
Beispiel #12
0
 * @version $Id: upgrade_1_2_0.inc.php
 * @package AEC - Account Control Expiration - Membership Manager
 * @subpackage Install Includes
 * @copyright 2011-2015 Copyright (C) David Deutsch
 * @author David Deutsch <*****@*****.**> & Team AEC - http://www.valanx.org
 * @license GNU/GPL v.3 http://www.gnu.org/licenses/gpl.html or, at your option, any later version
 */
// Dont allow direct linking
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
$eucaInstalldb->addColifNotExists('hidden', "int(4) NOT NULL default '0'", 'microintegrations');
$eucaInstalldb->addColifNotExists('restrictions', "text NULL", 'microintegrations');
// Due to a bug around 1.2 development, ALL processors were installed. Frequently.
// This fixes them.
$processors = PaymentProcessorHandler::getInstalledObjectList();
if (count($processors) > 50) {
    $plans = SubscriptionPlanHandler::getPlanList();
    $used_processors = array();
    foreach ($plans as $planid) {
        $plan = new SubscriptionPlan();
        $plan->load($planid);
        if (empty($plan->params['processors'])) {
            continue;
        }
        foreach ($plan->params['processors'] as $processor_id) {
            if (in_array($processor_id, $used_processors)) {
                continue;
            }
            $used_processors[] = $processor_id;
        }
    }
    foreach ($processors as $processor) {
Beispiel #13
0
 public function readPlans()
 {
     $db = JFactory::getDBO();
     $r = array();
     $r['head'] = "Payment Plans";
     $r['type'] = "table";
     $r['def'] = array("ID" => array('id'), "Published" => array('active', 'bool'), "Visible" => array('visible', 'bool'), "Name" => array('name', 'smartlimit haslink', 'editSubscriptionPlan', 'id'), "Desc" => array('desc', 'notags smartlimit'), "Primary" => array(array('params', 'make_primary'), 'bool'), "Activate" => array(array('params', 'make_active'), 'bool'), "Update Exist." => array(array('params', 'update_existing'), 'bool'), "Override Activat." => array(array('params', 'override_activation'), 'bool'), "Override Reg. Email" => array(array('params', 'override_regmail'), 'bool'), "Set GID" => array(array('params', 'gid_enabled'), 'bool'), "GID" => array(array('params', 'gid'), 'list', 'gid'), "Standard Parent Plan" => array(array('params', 'standard_parent'), 'list', 'plan'), "Fallback Plan" => array(array('params', 'fallback'), 'list', 'plan'), "Free" => array(array('params', 'full_free'), 'bool'), "Cost" => array(array('params', 'full_amount')), "Lifetime" => array(array('params', 'lifetime'), 'bool'), "Period" => array(array('params', 'full_period')), "Unit" => array(array('params', 'full_periodunit')), "Free Trial" => array(array('params', 'trial_free'), 'bool'), "Trial Cost" => array(array('params', 'trial_amount')), "Trial Period" => array(array('params', 'trial_period')), "Trial Unit" => array(array('params', 'trial_periodunit')), "Has MinGID" => array(array('restrictions', 'mingid_enabled'), 'bool'), "MinGID" => array(array('restrictions', 'mingid'), 'list', 'gid'), "Has FixGID" => array(array('restrictions', 'fixgid_enabled'), 'bool'), "FixGID" => array(array('restrictions', 'fixgid'), 'list', 'gid'), "Has MaxGID" => array(array('restrictions', 'fixgid_enabled'), 'bool'), "MaxGID" => array(array('restrictions', 'fixgid'), 'list', 'gid'), "Requires Prev. Plan" => array(array('restrictions', 'previousplan_req_enabled'), 'bool'), "Prev. Plan" => array(array('restrictions', 'previousplan_req'), 'list', 'plan'), "Excluding Prev. Plan" => array(array('restrictions', 'previousplan_req_enabled_excluded'), 'bool'), "Excl. Prev. Plan" => array(array('restrictions', 'previousplan_req_excluded'), 'list', 'plan'), "Requires Curr. Plan" => array(array('restrictions', 'currentplan_req_enabled'), 'bool'), "Curr. Plan" => array(array('restrictions', 'currentplan_req'), 'list', 'plan'), "Excluding Curr. Plan" => array(array('restrictions', 'currentplan_req_enabled_excluded'), 'bool'), "Excl. Curr. Plan" => array(array('restrictions', 'currentplan_req_excluded'), 'list', 'plan'), "Requires Overall Plan" => array(array('restrictions', 'overallplan_req_enabled'), 'bool'), "Overall Plan" => array(array('restrictions', 'overallplan_req'), 'list', 'plan'), "Excluding Overall. Plan" => array(array('restrictions', 'overallplan_req_enabled_excluded'), 'bool'), "Excl. Overall. Plan" => array(array('restrictions', 'overallplan_req_excluded'), 'list', 'plan'), "Min Used Plan" => array(array('restrictions', 'used_plan_min_enabled'), 'bool'), "Min Used Plan Amount" => array(array('restrictions', 'used_plan_min_amount')), "Min Used Plans" => array(array('restrictions', 'used_plan_min'), 'list', 'plan'), "Max Used Plan" => array(array('restrictions', 'used_plan_max_enabled'), 'bool'), "Max Used Plan Amount" => array(array('restrictions', 'used_plan_max_amount')), "Max Used Plans" => array(array('restrictions', 'used_plan_max'), 'list', 'plan'), "Custom Restrictions" => array(array('restrictions', 'custom_restrictions_enabled'), 'bool'), "Restrictions" => array(array('restrictions', 'custom_restrictions')));
     $plans = SubscriptionPlanHandler::getPlanList(null, null, isset($_POST['use_ordering']));
     $r['set'] = array();
     foreach ($plans as $planid) {
         $plan = new SubscriptionPlan();
         $plan->load($planid);
         $ps = array();
         foreach ($r['def'] as $nn => $def) {
             $ps = array_merge($ps, $this->conversionHelper($def, $plan));
         }
         $r['set'][] = $ps;
     }
     return $r;
 }