Пример #1
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);
 }
Пример #2
0
    static function listSubscriptions($rows, $nav, $state, $lists, $subscriptionid, $action)
    {
        HTML_myCommon::startCommon('aec-wrap-geometry');
        $th_list = array(array('username', 'CNAME'), array('name', 'USERLOGIN'), array('status', 'AEC_CMN_STATUS', 'left', 'filter_status'), array('signup_date', 'SUBSCR_DATE'));
        if ($state->filter->status[0] != 'manual') {
            $th_list = array_merge($th_list, array(array('lastpay_date', 'LASTPAY_DATE'), array('type', 'METHOD'), array('plan_name', 'USERPLAN', 'left', array('filter_plan', 'filter_group')), array('expiration', 'EXPIRATION')));
        }
        ?>
		<form action="index.php" method="post" name="adminForm" id="adminForm">
			<?php 
        HTML_myCommon::getHeader($action[1], '' . $action[0], '', $state->search, 'bulk-edit', 'Subscription');
        ?>
			<input type="hidden" name="orderby_subscr" value="<?php 
        echo $state->sort;
        ?>
"/>

			<div class="container-fluid">
				<div class="row">
					<div class="col-sm-12">
						<div class="col-sm-12">
							<table class="table table-hover table-striped table-selectable">
								<thead><tr>
									<th class="text-center">
										<a class="btn btn-success btn-xs select-all pull-left" href="#">ALL</a>
									</th>
									<th>&nbsp;</th>
									<?php 
        aecAdmin::th_set($th_list, $lists, $state->sort);
        ?>
									<?php 
        if ($action[0] == 'manual') {
            ?>
										<th class="text-left"></th>
										<th class="text-left"></th>
										<th class="text-left"></th>
										<th class="text-left"></th>
									<?php 
        }
        ?>
								</tr></thead>
								<tbody>
								<?php 
        if (empty($rows)) {
            ?>
									<tr class="warning">
										<td class="text-center" colspan="10">
											No Results. Perhaps you need to adjust the <i class="glyphicon glyphicon-filter"></i>Filters in the table head?
										</td>
									</tr>
								<?php 
        }
        ?>
								<?php 
        foreach ($rows as $i => $row) {
            if (!isset($row->status)) {
                $row->status = '-';
                $row->lastpay_date = '-';
                $row->type = '-';
                $row->plan_name = '-';
                $row->lifetime = '-';
                $row->expiration = '-';
            }
            $rowstyle = '';
            if (is_array($subscriptionid)) {
                if (in_array($row->id, $subscriptionid)) {
                    $rowstyle = ' class="warning"';
                }
            }
            ?>
									<tr<?php 
            echo $rowstyle;
            ?>
>
										<td class="text-center"><?php 
            echo JHTML::_('grid.id', $i, $row->id, false, $action[0] == 'manual' ? 'userid' : 'subscriptionid');
            ?>
</td>
										<td class="text-center"><?php 
            echo !empty($row->primary) ? aecHTML::Icon('star') : '&nbsp;';
            ?>
</td>
										<td class="text-left"><a href="<?php 
            echo 'index.php?option=com_acctexp&amp;task=edit&amp;entity=Membership&amp;' . ($action[0] == 'manual' ? 'userid' : 'subscriptionid') . '=' . $row->id;
            ?>
" title="<?php 
            echo JText::_('AEC_CMN_CLICK_TO_EDIT');
            ?>
"><?php 
            echo empty($row->name) ? JText::_('UNNAMED ITEM') : stripslashes($row->name);
            ?>
</a></td>
										<td class="text-left"><?php 
            echo $row->username;
            ?>
</td>
										<td><?php 
            echo $row->status;
            ?>
</td>
										<td class="text-left"><?php 
            echo HTML_AcctExp::DisplayDateInLocalTime($row->signup_date);
            ?>
</td>
										<?php 
            if ($action[0] != 'manual') {
                ?>
											<td class="text-left"><?php 
                echo HTML_AcctExp::DisplayDateInLocalTime($row->lastpay_date);
                ?>
</td>
											<td><?php 
                echo $row->type;
                ?>
</td>
											<td class="text-left"><?php 
                echo $row->plan_name;
                ?>
</td>
											<td class="text-left"><?php 
                echo $row->lifetime ? JText::_('AEC_CMN_LIFETIME') : HTML_AcctExp::DisplayDateInLocalTime($row->expiration);
                ?>
</td>
										<?php 
            } else {
                ?>
											<td class="text-left"></td>
											<td class="text-left"></td>
											<td class="text-left"></td>
											<td class="text-left"></td>
										<?php 
            }
            ?>
									</tr>
								<?php 
        }
        ?>
								</tbody>
								<tfoot>
								<tr>
									<td colspan="11">
										<?php 
        echo $nav->getListFooter();
        ?>
									</td>
								</tr>
								</tfoot>
							</table>
						</div>
					</div>
				</div>
			</div>

			<div class="modal fade" id="bulk-edit">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"><span>&times;</span><span class="sr-only">Close</span></button>
							<h3>Bulk Edit Subscriptions</h3>
						</div>
						<div class="modal-body">
							<p>With selected users:</p>
							<div class="form-group">
								<?php 
        echo $lists['set_plan'];
        ?>
							</div>
							<div class="form-group">
								<div class="form-group">
									<?php 
        echo $lists['set_status'];
        ?>
								</div>
							</div>
							<label class="control-label">Change Expiration:</label>
							<div class="form-inline">
								<div class="form-group">
									<?php 
        echo $lists['add_or_set_expiration'];
        ?>
								</div>
								<div class="form-group">
									<input type="text" name="set_time" class="form-control" id="set_time" placeholder="">
								</div>
								<div class="form-group">
									<?php 
        echo $lists['set_time_unit'];
        ?>
								</div>

							</div>
							<!-- TODO: Ctrls for expiration add/set, time, period -->
						</div>
						<div class="modal-footer">
							<input type="button" class="btn btn-primary" onclick="document.adminForm.submit();" value="<?php 
        echo JText::_('AEC_CMN_APPLY');
        ?>
"/>
						</div>
					</div>
				</div>
			</div>
			<?php 
        HTML_myCommon::endForm('Membership');
        HTML_myCommon::endCommon();
    }