public function getMIform($request) { $settings = array(); $points = $this->getPoints($request); if ($this->settings['checkout_discount'] && $points) { if (!empty($request->invoice->currency)) { $currency = $request->invoice->currency; } else { global $aecConfig; $currency = $aecConfig->cfg['standard_currency']; } $value = AECToolbox::formatAmount($this->settings['checkout_conversion'], $currency, false); $total = AECToolbox::formatAmount($points * $this->settings['checkout_conversion'], $currency); $settings['vat_desc'] = array('p', sprintf(JText::_('MI_MI_AECPOINTS_CONVERSION_INFO'), $points, $value, $total)); $settings['use_points'] = array('inputC', JText::_('MI_MI_AECPOINTS_USE_POINTS_NAME'), JText::_('MI_MI_AECPOINTS_USE_POINTS_DESC'), ''); $settings['validation']['rules'] = array(); $settings['validation']['rules']['use_points'] = array('number' => true, 'min' => 0, 'max' => $this->getPoints($request)); } return $settings; }
public function getPrintout($InvoiceFactory, $forcecleared = false, $forcecounter = null) { global $aecConfig; if (is_null($forcecounter)) { $this->counter = $forcecounter; } if ($this->transaction_date == '0000-00-00 00:00:00' && $forcecleared) { $this->transaction_date = date('Y-m-d H:i:s', (int) gmdate('U')); } $data = $this->getWorkingData($InvoiceFactory); $data['invoice_id'] = $this->id; $data['invoice_number'] = $this->invoice_number; $data['invoice_date'] = aecTemplate::date($InvoiceFactory->invoice->created_date); $data['itemlist'] = array(); foreach ($InvoiceFactory->items->itemlist as $iid => $item) { if (isset($item['obj'])) { $amt = $item['terms']->nextterm->cost[0]->cost['amount']; $data['itemlist'][] = '<tr id="invoice_content_item">' . '<td>' . $item['name'] . '</td>' . '<td>' . AECToolbox::formatAmount($amt, $InvoiceFactory->invoice->currency) . '</td>' . '<td>' . $item['quantity'] . '</td>' . '<td>' . AECToolbox::formatAmount($amt * $item['quantity'], $InvoiceFactory->invoice->currency) . '</td>' . '</tr>'; foreach ($item['terms']->nextterm->cost as $cid => $cost) { if ($cid != 0) { if ($cost->type == 'discount') { if (!empty($cost->cost['details'])) { $ta = ' (' . $cost->cost['details'] . ')'; } else { $ta = ""; } $data['itemlist'][] = '<tr id="invoice_content_item">' . '<td>' . JText::_('AEC_CHECKOUT_DISCOUNT') . $ta . '</td>' . '<td></td>' . '<td></td>' . '<td>' . AECToolbox::formatAmount($cost->cost['amount'], $InvoiceFactory->invoice->currency) . '</td>' . '</tr>'; } elseif ($cost->type == 'cost') { if (!empty($cost->cost['details'])) { $ta = ' (' . $cost->cost['details'] . ')'; } else { $ta = ""; } $data['itemlist'][] = '<tr id="invoice_content_item">' . '<td>' . $ta . '</td>' . '<td></td>' . '<td></td>' . '<td>' . AECToolbox::formatAmount($cost->cost['amount'], $InvoiceFactory->invoice->currency) . '</td>' . '</tr>'; } } } } } $data['totallist'][] = '<tr id="invoice_content_item_separator">' . '<td colspan="4"></td>' . '</tr>'; if (isset($InvoiceFactory->items->tax)) { if (isset($InvoiceFactory->items->total)) { $data['totallist'][] = '<tr id="invoice_content_item_total">' . '<td>' . JText::_('INVOICEPRINT_TOTAL') . '</td>' . '<td></td>' . '<td></td>' . '<td>' . AECToolbox::formatAmount($InvoiceFactory->items->total->cost['amount'], $InvoiceFactory->invoice->currency) . '</td>' . '</tr>'; } foreach ($InvoiceFactory->items->tax as $item) { $details = null; foreach ($item['terms']->terms[0]->cost as $citem) { if ($citem->type == 'tax') { $details = $citem->cost['details']; } } $data['totallist'][] = '<tr id="invoice_content_item_tax">' . '<td>Tax' . ' ( ' . $details . ' )' . '</td>' . '<td></td>' . '<td></td>' . '<td>' . AECToolbox::formatAmount($item['cost'], $InvoiceFactory->invoice->currency) . '</td>' . '</tr>'; } } if (isset($InvoiceFactory->items->grand_total)) { $data['totallist'][] = '<tr id="invoice_content_item_total">' . '<td>' . JText::_('INVOICEPRINT_GRAND_TOTAL') . '</td>' . '<td></td>' . '<td></td>' . '<td>' . AECToolbox::formatAmount($InvoiceFactory->items->grand_total->cost['amount'], $InvoiceFactory->invoice->currency) . '</td>' . '</tr>'; } if ($this->transaction_date == '0000-00-00 00:00:00') { if (!$this->active) { $data['paidstatus'] = JText::_('INVOICEPRINT_PAIDSTATUS_CANCEL'); } else { $data['paidstatus'] = JText::_('INVOICEPRINT_PAIDSTATUS_UNPAID'); } } else { if (!$this->active) { $data['paidstatus'] = JText::_('INVOICEPRINT_PAIDSTATUS_CANCEL'); } else { $date = AECToolbox::formatDate($this->transaction_date); $data['paidstatus'] = sprintf(JText::_('INVOICEPRINT_PAIDSTATUS_PAID'), $date); } } $pplist = array(); if ($this->method != 'none') { $pp = new PaymentProcessor(); if ($pp->loadName($this->method)) { $pp->init(); $pp->getInfo(); if (!empty($InvoiceFactory->plan->id)) { $pp->exchangeSettingsByPlan($InvoiceFactory->plan->id, $InvoiceFactory->plan->params); } } } else { $pp = null; } $pplist[$this->method] = $pp; $recurring = false; if (!empty($pp)) { $recurring = $pplist[$this->method]->is_recurring(); } $data['recurringstatus'] = ""; if ($recurring) { $data['recurringstatus'] = JText::_('INVOICEPRINT_RECURRINGSTATUS_RECURRING'); } elseif (!empty($InvoiceFactory->plan->id)) { if (!empty($InvoiceFactory->plan->params['trial_amount']) && $InvoiceFactory->plan->params['trial_period']) { $data['recurringstatus'] = JText::_('INVOICEPRINT_RECURRINGSTATUS_ONCE'); } } $data['invoice_billing_history'] = ""; if (!empty($this->transactions)) { if (count($this->transactions) > 0 && !empty($data['recurringstatus']) && $this->method != 'none') { $data['paidstatus'] = sprintf(JText::_('INVOICEPRINT_PAIDSTATUS_PAID'), ""); foreach ($this->transactions as $transaction) { if (!isset($pplist[$transaction->processor])) { $pp = new PaymentProcessor(); if ($pp->loadName($transaction->processor)) { $pp->getInfo(); $pplist[$transaction->processor] = $pp; } } $data['invoice_billing_history'] .= '<tr><td>' . AECToolbox::formatDate($transaction->timestamp) . '</td><td>' . $transaction->amount . ' ' . $transaction->currency . '</td><td>' . $pplist[$transaction->processor]->info['longname'] . '</td></tr>'; } } } $s = array("before_header", "header", "after_header", "address", "before_content", "after_content", "before_footer", "footer", "after_footer"); foreach ($s as $k) { if (empty($data[$k])) { $data[$k] = ""; } } return $data; }
/** * @param InvoiceFactory $request */ static function formatAmountCustom($request, $plan, $forcedefault = false, $proposed = null) { if (empty($plan->params['customamountformat']) || $forcedefault) { $format = '{aecjson}{"cmd":"condition","vars":[{"cmd":"data","vars":"payment.freetrial"},' . '{"cmd":"concat","vars":[{"cmd":"constant","vars":"CONFIRM_FREETRIAL"}," ",{"cmd":"data","vars":"payment.method_name"}]},' . '{"cmd":"concat","vars":[{"cmd":"data","vars":"payment.amount"},{"cmd":"data","vars":"payment.currency_symbol"}," - ",{"cmd":"data","vars":"payment.method_name"}]}' . ']}{/aecjson}'; } else { $format = $plan->params['customamountformat']; } $request->payment->amount = AECToolbox::formatAmount($request->payment->amount); $rwEngine = new reWriteEngine(); $rwEngine->resolveRequest($request); $amount = $rwEngine->resolve($format); if (strpos($amount, 'JSON PARSE ERROR') !== false) { if (!$forcedefault) { return AECToolbox::formatAmountCustom($request, $plan, true, $amount); } else { return $proposed; } } return $amount; }
$amount = AECToolbox::correctAmount($cost->cost['amount']); $c = AECToolbox::formatAmount($amount, $InvoiceFactory->payment->currency); if (!empty($cost->cost['details'])) { $t .= ' ( ' . $cost->cost['details'] . ' )'; } } $cost[] = array('type' => $cost->type, 'details' => $t, 'cost' => $c); } } } } $i['terms'][] = array('type' => 'total', 'current' => 1, 'cost' => $cost); $itemlist[] = $i; if (!empty($InvoiceFactory->items->grand_total)) { $i = array('name' => JText::_('AEC_CHECKOUT_GRAND_TOTAL'), 'quantity' => 1, 'terms' => array()); $c = AECToolbox::formatAmount($InvoiceFactory->items->grand_total->renderCost(), $InvoiceFactory->payment->currency); $cost = array(array('type' => 'total', 'details' => JText::_('AEC_CHECKOUT_TOTAL'), 'cost' => $c)); $i['terms'][] = array('type' => 'total', 'current' => 1, 'cost' => $cost); $itemlist[] = $i; } } if (strpos($var, 'name="cardNumber"') && strpos($var, 'name="cardVV2"')) { $tmpl->enqueueValidation(array('rules' => array('cardNumber' => array('creditcard' => true, 'required' => true), 'cardVV2' => array('required' => true)))); } if (strpos($var, 'class="tab-content"')) { $tmpl->enqueueJQueryExtension('bootstrap/bootstrap.2.1.1.min'); $js = "jQuery('.nav-tabs a:first').tab('show');"; $tmpl->enqueueJQueryCode($js); } $tmpl->setTitle($InvoiceFactory->checkout['checkout_title']); $tmpl->defaultHeader();