Exemple #1
0
 public function metaUser($userid, $subscriptionid = null)
 {
     if (empty($userid) && !empty($subscriptionid)) {
         $userid = aecUserHelper::UserIDfromSubscriptionID($subscriptionid);
     }
     $this->meta = new metaUserDB();
     $this->meta->loadUserid($userid);
     $this->cmsUser = false;
     $this->hasCBprofile = false;
     $this->hasJSprofile = false;
     $this->userid = 0;
     $this->hasSubscription = 0;
     $this->objSubscription = null;
     $this->focusSubscription = null;
     if ($userid) {
         $this->cmsUser = new cmsUser();
         $this->cmsUser->load($userid);
         $this->userid = $userid;
         if (!empty($subscriptionid)) {
             $aecid = $subscriptionid;
         } else {
             $aecid = aecUserHelper::SubscriptionIDfromUserID($userid);
         }
         if ($aecid) {
             $this->objSubscription = new Subscription();
             $this->objSubscription->load($aecid);
             $this->focusSubscription = new Subscription();
             $this->focusSubscription->load($aecid);
             $this->hasSubscription = 1;
             $this->temporaryRFIX();
         }
     }
 }
Exemple #2
0
 public function edit($userid, $subscriptionid, $task, $page = 0)
 {
     if (!empty($subscriptionid)) {
         $userid = aecUserHelper::UserIDfromSubscriptionID($subscriptionid);
     }
     if (!empty($subscriptionid)) {
         $sid = $subscriptionid;
     } else {
         $sid = 0;
     }
     $lists = array();
     $metaUser = new metaUser($userid);
     if (!empty($sid)) {
         $metaUser->moveFocus($sid);
     } else {
         if ($metaUser->hasSubscription) {
             $sid = $metaUser->focusSubscription->id;
         }
     }
     if ($metaUser->loadSubscriptions() && !empty($sid)) {
         foreach ($metaUser->allSubscriptions as $s_id => $s_c) {
             if ($s_c->id == $sid) {
                 $metaUser->allSubscriptions[$s_id]->current_focus = true;
                 continue;
             }
         }
     }
     $invoices_limit = 15;
     $invoice_ids = aecInvoiceHelper::InvoiceIdList($metaUser->userid, $page * $invoices_limit, $invoices_limit);
     $group_selection = array();
     $group_selection[] = JHTML::_('select.option', '', JText::_('EXPIRE_SET'));
     $group_selection[] = JHTML::_('select.option', 'expired', JText::_('EXPIRE_NOW'));
     $group_selection[] = JHTML::_('select.option', 'excluded', JText::_('EXPIRE_EXCLUDE'));
     $group_selection[] = JHTML::_('select.option', 'active', JText::_('EXPIRE_INCLUDE'));
     $group_selection[] = JHTML::_('select.option', 'closed', JText::_('EXPIRE_CLOSE'));
     $group_selection[] = JHTML::_('select.option', 'cancelled', JText::_('EXPIRE_CANCEL'));
     $group_selection[] = JHTML::_('select.option', 'hold', JText::_('EXPIRE_HOLD'));
     $lists['set_status'] = JHTML::_('select.genericlist', $group_selection, 'set_status', 'class="inputbox" size="1"', 'value', 'text', '');
     $invoices = array();
     $couponsh = array();
     $invoice_counter = 0;
     $processors = PaymentProcessorHandler::getObjectList(PaymentProcessorHandler::getProcessorList());
     $procs = array('free' => 'Free', 'none' => 'None');
     foreach ($processors as $processor) {
         $procs[$processor->processor_name] = $processor->processor->info['longname'];
     }
     foreach ($invoice_ids as $inv_id) {
         $invoice = new Invoice();
         $invoice->load($inv_id);
         if (!empty($invoice->coupons)) {
             foreach ($invoice->coupons as $coupon_code) {
                 if (!isset($couponsh[$coupon_code])) {
                     $couponsh[$coupon_code] = couponHandler::idFromCode($coupon_code);
                 }
                 $couponsh[$coupon_code]['invoices'][] = $invoice->invoice_number;
             }
         }
         if ($invoice_counter >= $invoices_limit && strcmp($invoice->transaction_date, '0000-00-00 00:00:00') !== 0) {
             continue;
         } else {
             $invoice_counter++;
         }
         $status = aecHTML::Icon('plus') . HTML_AcctExp::DisplayDateInLocalTime($invoice->created_date) . '<br />';
         if (isset($invoice->params['deactivated'])) {
             $status .= aecHTML::Icon('remove-circle') . 'deactivated';
         } elseif (strcmp($invoice->transaction_date, '0000-00-00 00:00:00') === 0) {
             if (isset($invoice->params['pending_reason'])) {
                 if ($this->lang->hasKey('PAYMENT_PENDING_REASON_' . strtoupper($invoice->params['pending_reason']))) {
                     $status .= aecHTML::Icon('warning-sign') . JText::_('PAYMENT_PENDING_REASON_' . strtoupper($invoice->params['pending_reason']));
                 } else {
                     $status .= aecHTML::Icon('warning-sign') . $invoice->params['pending_reason'];
                 }
             } else {
                 $status .= aecHTML::Icon('time') . 'uncleared';
             }
         }
         $actions = array();
         $rowstyle = '';
         if (strcmp($invoice->transaction_date, '0000-00-00 00:00:00') === 0) {
             $checkoutlink = AECToolbox::deadsureURL('index.php?option=com_acctexp&amp;task=repeatPayment&amp;invoice=' . $invoice->invoice_number);
             $actions = array(array('repeat', 'arrow-right', 'USERINVOICE_ACTION_REPEAT', 'info', '', $checkoutlink), array('cancel', 'remove', 'USERINVOICE_ACTION_CANCEL', 'danger'), array('clear', 'ok', 'USERINVOICE_ACTION_CLEAR_APPLY', 'success', '&applyplan=1'), array('clear', 'check', 'USERINVOICE_ACTION_CLEAR', 'warning'));
             $rowstyle = ' style="background-color:#fee;"';
         } else {
             $status .= aecHTML::Icon('shopping-cart') . HTML_AcctExp::DisplayDateInLocalTime($invoice->transaction_date);
         }
         $actions[] = array('print', 'print', 'HISTORY_ACTION_PRINT', '', '&tmpl=component" target="_blank');
         $actions[] = array('pdf', 'file', 'PDF', '', '');
         $actionlist = '<div class="btn-group">';
         foreach ($actions as $action) {
             if (!empty($action[5])) {
                 $alink = $action[5];
             } else {
                 $alink = 'index.php?option=com_acctexp&task=' . $action[0] . 'Invoice&invoice=' . $invoice->invoice_number . '&returntask=edit&amp;entity=Membership&userid=' . $metaUser->userid;
                 if (!empty($action[4])) {
                     $alink .= $action[4];
                 }
             }
             $actionlist .= aecHTML::Button($action[1], $action[2], $action[3], $alink);
         }
         $actionlist .= '</div>';
         $non_formatted = $invoice->invoice_number;
         $invoice->formatInvoiceNumber();
         $is_formatted = $invoice->invoice_number;
         if ($non_formatted != $is_formatted) {
             $is_formatted = $non_formatted . "\n" . '(' . $is_formatted . ')';
         }
         $invoices[$inv_id] = array();
         $invoices[$inv_id]['rowstyle'] = $rowstyle;
         $invoices[$inv_id]['invoice_number'] = $is_formatted;
         $invoices[$inv_id]['amount'] = $invoice->amount . '&nbsp;' . $invoice->currency;
         $invoices[$inv_id]['status'] = $status;
         if ($procs[$invoice->method]) {
             $invoices[$inv_id]['processor'] = $invoice->method;
         } else {
             $invoices[$inv_id]['processor'] = $procs[$invoice->method];
         }
         $invoices[$inv_id]['usage'] = $invoice->usage;
         $invoices[$inv_id]['actions'] = $actionlist;
     }
     $coupons = array();
     $coupon_counter = 0;
     foreach ($couponsh as $coupon_code => $coupon) {
         if ($coupon_counter >= 10) {
             continue;
         } else {
             $coupon_counter++;
         }
         $cc = array();
         $cc['coupon_code'] = '<a href="index.php?option=com_acctexp&amp;task=edit&amp;entity=Coupon&id=' . $coupon['type'] . '.' . $coupon['id'] . '">' . $coupon_code . '</a>';
         $cc['invoices'] = implode(", ", $coupon['invoices']);
         $coupons[] = $cc;
     }
     // get available plans
     $available_plans = SubscriptionPlanHandler::getActivePlanList(false);
     $lists['assignto_plan'] = JHTML::_('select.genericlist', $available_plans, 'assignto_plan[]', 'size="1" multiple="multiple" class="select2-bootstrap"', 'value', 'text', 0);
     $userMIs = $metaUser->getUserMIs();
     $mi = array();
     $mi['profile'] = array();
     $mi['admin'] = array();
     $mi['profile_form'] = array();
     $mi['admin_form'] = array();
     $params = array();
     foreach ($userMIs as $m) {
         $pref = 'mi_' . $m->id . '_';
         $ui = $m->profile_info($metaUser);
         if (!empty($ui)) {
             $mi['profile'][] = array('name' => $m->info['name'] . ' - ' . $m->name, 'info' => $ui);
         }
         $uf = $m->profile_form($metaUser, true);
         if (!empty($uf)) {
             foreach ($uf as $k => $v) {
                 $mi['profile_form'][] = $pref . $k;
                 $params[$pref . $k] = $v;
             }
         }
         $ai = $m->admin_info($metaUser);
         if (!empty($ai)) {
             $mi['admin'][] = array('name' => $m->info['name'] . ' - ' . $m->name, 'info' => $ai);
         }
         $af = $m->admin_form($metaUser);
         if (!empty($af)) {
             foreach ($af as $k => $v) {
                 $mi['admin_form'][] = $pref . $k;
                 $params[$pref . $k] = $v;
             }
         }
     }
     if (!empty($params)) {
         $settings = new aecSettings('userForm', 'mi');
         $settings->fullSettingsArray($params, array(), $lists);
         // Call HTML Class
         $aecHTML = new aecHTML($settings->settings, $settings->lists);
     } else {
         $aecHTML = new stdClass();
     }
     $aecHTML->invoice_pages = (int) (aecInvoiceHelper::InvoiceCountbyUserID($metaUser->userid) / $invoices_limit);
     $aecHTML->invoice_page = $page;
     $aecHTML->sid = $sid;
     HTML_AcctExp::userForm($metaUser, $invoices, $coupons, $mi, $lists, $task, $aecHTML);
 }