Example #1
0
 public function _format($d)
 {
     if (trim($d) == '') {
         return '';
     }
     switch ($this->format) {
         case self::DATE:
             return amDate($d);
         case self::TIME:
             return amTime($d);
         default:
             return amDatetime($d);
     }
 }
Example #2
0
 public function _format($d)
 {
     if (trim($d) == '') {
         return '';
     }
     if ($d == Am_Period::MAX_SQL_DATE) {
         return ___('Lifetime');
     }
     switch ($this->format) {
         case self::DATE:
             return amDate($d);
         case self::TIME:
             return amTime($d);
         default:
             return amDatetime($d);
     }
 }
 function init()
 {
     $this->addElement('text', 'root_url', array('size' => 40))->setLabel(___("Root URL\nroot script URL, usually %s", '<i>http://www.yoursite.com/amember</i>'))->addRule('callback2', '-error-must-be-returned-', array($this, 'validateRootUrl'));
     $this->addElement('text', 'root_surl', array('size' => 40))->setLabel(___("Secure Root URL\nsecure URL, usually %s", '<i>http<b>s</b>://www.yoursite.com/amember</i>'))->addRule('callback2', '-error-must-be-returned-', array($this, 'validateRootUrl'));
     if ('==TRIAL==' == '==' . 'TRIAL==') {
         $license = Am_Di::getInstance()->config->get('license');
         $this->addElement('textarea', 'license', array('style' => 'width:95%', 'rows' => count(explode("\n", $license)) + 1))->setLabel(___("License Key"))->addRule('required')->addRule('notregex', ___('You have license keys from past versions of aMember, please replace it with latest, one-line keys'), '/====\\s+LICENSE/')->addRule('callback', ___('Valid license key are one-line string,starts with L and ends with X'), array($this, 'validateKeys'));
         if ($domains = Am_License::getInstance()->getDomains()) {
             $cnt = '<i>' . implode(",", Am_License::getInstance()->getDomains()) . '</i> ';
             $cnt .= ___("expires") . ' ';
             $cnt .= amDate(Am_License::getInstance()->getExpires());
         } else {
             $cnt = "No License Configured";
         }
     } else {
         $cnt = "Using TRIAL Version - expires ==TRIAL_EXPIRES==";
     }
     $this->addElement('static')->setLabel(___('Configured License Keys'))->setContent($cnt);
     parent::init();
     $this->addSaveButton(___('Update License Information'));
 }
 public function resendPaymentLinkAction()
 {
     $this->getDi()->authAdmin->getUser()->checkPermission('grid_invoice', 'edit');
     $invoice = $this->getDi()->invoiceTable->load($this->getParam('invoice_id'));
     $form = new Am_Form_Admin('add-invoice');
     $tm_due = $form->addDate('tm_due')->setLabel(___('Due Date'));
     $tm_due->setValue($invoice->due_date < sqlDate('now') ? sqlDate('+7 days') : $invoice->due_date);
     $message = $form->addTextarea('message', array('class' => 'el-wide'))->setLabel(___("Message\n" . 'will be included to email to user'));
     $form->addElement('email_link', 'invoice_pay_link')->setLabel(___('Email Template with Payment Link'));
     $form->setDataSources(array($this->getRequest()));
     if ($form->isSubmitted() && $form->validate()) {
         $vars = $form->getValue();
         $invoice->due_date = $vars['tm_due'];
         $invoice->save();
         $et = Am_Mail_Template::load('invoice_pay_link', $invoice->getUser()->lang ? $invoice->getUser()->lang : null);
         $et->setUser($invoice->getUser());
         $et->setUrl(ROOT_SURL . sprintf('/pay/%s', $invoice->getSecureId('payment-link')));
         $et->setMessage($vars['message']);
         $et->setInvoice($invoice);
         $et->setInvoice_text($invoice->render());
         $et->send($invoice->getUser());
         Am_Controller::ajaxResponse(array('ok' => true, 'msg' => ___('Invoice link has been sent to user again'), 'invoice_id' => $invoice->pk(), 'due_date_html' => amDate($invoice->due_date)));
     } else {
         echo $form;
     }
 }
Example #5
0
 public function formatPeriod(Am_Period $period, $format = "%s", $skip_one_c = false)
 {
     switch ($period->getUnit()) {
         case 'd':
             $uu = $period->getCount() == 1 ? ___('day') : ___('days');
             break;
         case 'm':
             $uu = $period->getCount() == 1 ? ___('month') : ___('months');
             break;
         case 'y':
             $uu = $period->getCount() == 1 ? ___('year') : ___('years');
             break;
         case Am_Period::FIXED:
             if ($period->getCount() == Am_Period::MAX_SQL_DATE) {
                 return " for lifetime";
             }
             return " up to " . amDate($period->getCount());
     }
     $cc = $period->getCount();
     if ($period->getCount() == 1) {
         $cc = $skip_one_c ? '' : 'one';
     }
     return sprintf($format, "{$cc} {$uu}");
 }
Example #6
0
 public function renderAccess($page, $pointer)
 {
     $invoice = $this->invoice;
     //if user is not approved there is no access records
     $accessrecords = $invoice->getAccessRecords();
     if (!$accessrecords) {
         return $pointer;
     }
     $payment = $this->payment;
     $padd = 20;
     $width_date = 120;
     $fontH = $this->getFontRegular();
     $fontHB = $this->getFontBold();
     $table = new Am_Pdf_Table();
     $table->setMargin($padd, $padd, $padd, $padd);
     $table->setStyleForRow(1, array('shape' => array('type' => Zend_Pdf_Page::SHAPE_DRAW_STROKE, 'color' => new Zend_Pdf_Color_Html("#cccccc")), 'font' => array('face' => $fontHB, 'size' => 10)));
     $table->setStyleForColumn(2, array('width' => $width_date));
     $table->setStyleForColumn(3, array('width' => $width_date));
     $table->addRow(array(___('Subscription/Product Title'), ___('Begin'), ___('Expire')));
     $get_product_ids = create_function('$access', 'return $access->product_id;');
     $productOptions = $this->getDi()->productTable->getProductTitles(array_map($get_product_ids, $accessrecords));
     foreach ($accessrecords as $a) {
         /* @var $a Access */
         if ($a->invoice_payment_id != $payment->pk()) {
             continue;
         }
         $table->addRow(array($productOptions[$a->product_id], amDate($a->begin_date), $a->expire_date == Am_Period::MAX_SQL_DATE ? ___('Lifetime') : amDate($a->expire_date)));
     }
     $pointer = $page->drawTable($table, 0, $pointer);
     return $pointer;
 }
 function renderTitle($noTags = false)
 {
     if ($noTags) {
         return $this->title;
     }
     $total = $this->getDataSource()->getFoundRows();
     $page = $this->getCurrentPage();
     $count = $this->getCountPerPage();
     $ret = "";
     $ret .= '<h1>';
     $ret .= Am_Controller::escape($this->title);
     $msgs = array();
     if ($total) {
         $msgs[] = ___("displaying records %d-%d from %d", $page * $count + 1, min($total, ($page + 1) * $count), $total);
     } else {
         $msgs[] = ___("no records");
     }
     if ($this->filter && $this->filter->isFiltered()) {
         $override = array();
         $dates = $this->filter->getDates();
         $msgs[] = sprintf("%s %s - %s", ___('period'), amDate($dates[0]), amDate($dates[1]));
     }
     if ($msgs) {
         $ret .= ' (' . implode(", ", $msgs) . ')';
     }
     $ret .= "</h1>";
     return $ret;
 }
 protected function formatDate($tm)
 {
     return amDate($tm);
 }
Example #9
0
 public function renderPayout(Am_Record $record, $f, $g)
 {
     $out = $record->payout_detail_id ? sprintf('<a href="%s" class="link" target="_top">%s</a>', $this->escape(REL_ROOT_URL . '/aff/admin-payout/view?payout_id=' . $record->payout_id), amDate($record->payout_date)) : '&ndash;';
     return $g->renderTd($out, false);
 }
Example #10
0
 public function render()
 {
     $invoice = $this->invoice;
     $payment = $this->payment;
     $user = $invoice->getUser();
     $pdf = $this->createPdfTemplate();
     $event = new Am_Event(Am_Event::PDF_INVOICE_BEFORE_RENDER, array('amPdfInvoice' => $this, 'pdf' => $pdf, 'invoice' => $invoice, 'payment' => $payment, 'user' => $user));
     $event->setReturn(false);
     $this->getDi()->hook->call($event);
     // If event processing already rendered the Pdf.
     if ($event->getReturn() === true) {
         return $pdf->render();
     }
     $width_num = 30;
     $width_qty = 40;
     $width_price = 80;
     $width_total = 120;
     $padd = 20;
     $left = $padd;
     $right = $this->getPaperWidth() - $padd;
     $fontH = $this->getFontRegular();
     $fontHB = $this->getFontBold();
     $styleBold = array('font' => array('face' => $fontHB, 'size' => 10));
     $page = new Am_Pdf_Page_Decorator($pdf->pages[0]);
     $page->setFont($fontH, 10);
     $pointer = $this->getPointer();
     $pointerL = $pointerR = $pointer;
     $leftCol = new stdClass();
     $leftCol->invoiceNumber = ___('Corrective Invoice Number: ') . $payment->getDisplayInvoiceId();
     $leftCol->recInvoiceNumber = ___('Rectifies Invoice Number: ') . $this->getOrigPayment()->getDisplayInvoiceId();
     $leftCol->date = ___('Date: ') . amDate($payment->dattm);
     if ($user->tax_id) {
         $leftCol->taxId = ___('EU VAT ID: ') . $user->tax_id;
     }
     $this->getDi()->hook->call(Am_Event::PDF_INVOICE_COL_LEFT, array('col' => $leftCol, 'invoice' => $invoice, 'payment' => $payment, 'user' => $user));
     foreach ($leftCol as $line) {
         $page->drawText($line, $left, $pointerL);
         $page->nl($pointerL);
     }
     $rightCol = new stdClass();
     $rightCol->name = $invoice->getName();
     $rightCol->email = $invoice->getEmail();
     $rightCol->address = implode(', ', array_filter(array($invoice->getStreet(), $invoice->getCity())));
     $rightCol->country = implode(', ', array_filter(array($this->getState($invoice), $invoice->getZip(), $this->getCountry($invoice))));
     $this->getDi()->hook->call(Am_Event::PDF_INVOICE_COL_RIGHT, array('col' => $rightCol, 'invoice' => $invoice, 'payment' => $payment, 'user' => $user));
     foreach ($rightCol as $line) {
         $page->drawText($line, $right, $pointerR, 'UTF-8', Am_Pdf_Page_Decorator::ALIGN_RIGHT);
         $page->nl($pointerR);
     }
     $pointer = min($pointerR, $pointerL);
     $p = new stdClass();
     $p->value =& $pointer;
     $this->getDi()->hook->call(Am_Event::PDF_INVOICE_BEFORE_TABLE, array('page' => $page, 'pointer' => $p, 'invoice' => $invoice, 'payment' => $payment, 'user' => $user));
     $table = new Am_Pdf_Table();
     $table->setMargin($padd, $padd, $padd, $padd);
     $table->setStyleForRow(1, array('shape' => array('type' => Zend_Pdf_Page::SHAPE_DRAW_STROKE, 'color' => new Zend_Pdf_Color_Html("#cccccc")), 'font' => array('face' => $fontHB, 'size' => 10)));
     $table->setStyleForColumn(1, array('align' => 'right', 'width' => $width_num));
     $table->setStyleForColumn(3, array('align' => 'right', 'width' => $width_qty));
     $table->setStyleForColumn(4, array('align' => 'right', 'width' => $width_price));
     $table->setStyleForColumn(5, array('align' => 'right', 'width' => $width_total));
     $table->addRow(array(___('#'), ___('Subscription/Product Title'), ___('Qty'), ___('Unit Price'), ___('Total Price')));
     $num = 0;
     foreach ($invoice->getItems() as $p) {
         /* @var $p InvoiceItem */
         $table->addRow(array(++$num . '.', $p->item_title, $p->qty, $invoice->getCurrency($this->isFirstPayment() ? $p->first_price : $p->second_price), $invoice->getCurrency($this->isFirstPayment() ? $p->getFirstSubtotal() : $p->getSecondSubtotal())));
     }
     $pointer = $page->drawTable($table, 0, $pointer);
     $table = new Am_Pdf_Table();
     $table->setMargin($padd, $padd, $padd, $padd);
     $table->setStyleForColumn(2, array('align' => 'right', 'width' => $width_total));
     $subtotal = $this->isFirstPayment() ? $invoice->first_subtotal : $invoice->second_subtotal;
     $total = $this->isFirstPayment() ? $invoice->first_total : $invoice->second_total;
     if ($subtotal != $total) {
         $table->addRow(array(___('Subtotal'), $invoice->getCurrency($subtotal)))->addStyle($styleBold);
     }
     if ($this->isFirstPayment() && $invoice->first_discount > 0 || !$this->isFirstPayment() && $invoice->second_discount > 0) {
         $table->addRow(array(___('Coupon Discount'), $invoice->getCurrency($this->isFirstPayment() ? $invoice->first_discount : $invoice->second_discount)));
     }
     $table->addRow(array(___('Total'), $invoice->getCurrency($total)))->addStyle($styleBold);
     $table->addRow(array(___('Taxable Income'), "-" . $invoice->getCurrency($this->getOrigPayment()->amount - $this->getOrigPayment()->tax)))->addStyle($styleBold);
     if ($this->getOrigPayment()->tax > 0) {
         $table->addRow(array(___('Tax') . " " . $invoice->tax_rate . "%", "-" . $invoice->getCurrency($this->getOrigPayment()->tax)))->addStyle($styleBold);
     }
     $table->addRow(array(___('Amount Paid'), $invoice->getCurrency(sprintf("%.2f", $this->getOrigPayment()->amount - $this->payment->amount))))->addStyle(array('font' => array('face' => $fontHB, 'size' => 10)));
     $x = $this->getPaperWidth() - ($width_qty + $width_price + $width_total) - 2 * $padd;
     $pointer = $page->drawTable($table, $x, $pointer);
     $page->nl($pointer);
     $page->nl($pointer);
     if (!$this->getDi()->config->get('invoice_do_not_include_terms')) {
         $termsText = new Am_TermsText($invoice);
         $page->drawTextWithFixedWidth(___('Subscription Terms') . ': ' . $termsText, $left, $pointer, $this->getPaperWidth() - 2 * $padd);
         $page->nl($pointer);
     }
     $p = new stdClass();
     $p->value =& $pointer;
     $this->getDi()->hook->call(Am_Event::PDF_INVOICE_AFTER_TABLE, array('page' => $page, 'pointer' => $p, 'invoice' => $invoice, 'payment' => $payment, 'user' => $user));
     if (!$this->getDi()->config->get('invoice_custom_template') || !$this->getDi()->uploadTable->load($this->getDi()->config->get('invoice_custom_template'))) {
         if ($ifn = $this->getDi()->config->get('invoice_footer_note')) {
             $tmpl = new Am_SimpleTemplate();
             $tmpl->assignStdVars();
             $tmpl->assign('user', $user);
             $tmpl->assign('invoice', $invoice);
             $ifn = $tmpl->render($ifn);
             $page->nl($pointer);
             $page->drawTextWithFixedWidth($ifn, $left, $pointer, $this->getPaperWidth() - 2 * $padd);
         }
     }
     return $pdf->render();
 }
Example #11
0
 function render($indent = "", InvoicePayment $payment = null)
 {
     $prefix = !is_null($payment) && !$payment->isFirst() ? 'second' : 'first';
     $tm_added = is_null($payment) ? $this->tm_added : $payment->dattm;
     $newline = "\r\n";
     $price_width = max(mb_strlen(Am_Currency::render($this->{$prefix . '_total'}, $this->currency)), 8);
     $column_padding = 1;
     $column_title_max = 60;
     $column_title_min = 20;
     $column_qty = 4 + $price_width;
     $column_num = 3;
     $column_amount = $price_width;
     $space = str_repeat(' ', $column_padding);
     $max_length = 0;
     foreach ($this->getItems() as $item) {
         $max_length = max(mb_strlen(___($item->item_title)), $max_length);
     }
     $column_title = max(min($max_length, $column_title_max), $column_title_min);
     $row_width = $column_num + $column_padding + $column_title + $column_padding + $column_qty + $column_padding + $column_amount + $column_padding;
     $column_total = $column_title + $column_qty + $column_padding;
     $total_space = str_repeat(' ', $column_padding + $column_num + $column_padding);
     $border = $indent . str_repeat('-', $row_width) . "{$newline}";
     $out = $indent . ___("Invoice") . ' #' . $this->public_id . " / " . amDate($tm_added) . "{$newline}";
     $out .= $border;
     $num = 1;
     foreach ($this->getItems() as $item) {
         $title = explode("\n", $this->wordWrap(___($item->item_title), $column_title, "\n", true));
         $out .= $indent . sprintf("{$space}%{$column_num}s{$space}%-{$column_title}s{$space}%{$column_qty}s{$space}%{$price_width}s{$newline}", $num . '.', $title[0], $item->qty . 'x' . Am_Currency::render($item->{$prefix . '_price'}, $this->currency), Am_Currency::render($item->{$prefix . '_total'}, $this->currency));
         for ($i = 1; $i < count($title); $i++) {
             $out .= $indent . sprintf("{$space}%{$column_num}s{$space}%-{$column_title}s{$newline}", ' ', $title[$i]);
         }
         $num++;
     }
     $out .= $border;
     if ($this->{$prefix . '_subtotal'} != $this->{$prefix . '_total'}) {
         $out .= $indent . sprintf("{$total_space}%-{$column_total}s{$space}%{$price_width}s{$newline}", ___('Subtotal'), Am_Currency::render($this->{$prefix . '_subtotal'}, $this->currency));
     }
     if ($this->{$prefix . '_discount'} > 0) {
         $out .= $indent . sprintf("{$total_space}%-{$column_total}s{$space}%{$price_width}s{$newline}", ___('Discount'), Am_Currency::render($this->{$prefix . '_discount'}, $this->currency));
     }
     if ($this->{$prefix . '_shipping'} > 0) {
         $out .= $indent . sprintf("{$total_space}%-{$column_total}s{$space}%{$price_width}s{$newline}", ___('Shipping'), Am_Currency::render($this->{$prefix . '_shipping'}, $this->currency));
     }
     if ($this->{$prefix . '_tax'} > 0) {
         $out .= $indent . sprintf("{$total_space}%-{$column_total}s{$space}%{$price_width}s{$newline}", ___('Tax') . sprintf(' (%d%s)', $this->tax_rate, '%'), Am_Currency::render($this->{$prefix . '_tax'}, $this->currency));
     }
     $out .= $indent . sprintf("{$total_space}%-{$column_total}s{$space}%{$price_width}s{$newline}", ___('Total'), Am_Currency::render($this->{$prefix . '_total'}, $this->currency));
     $out .= $border;
     if ($this->rebill_times) {
         $terms = explode("\n", $this->wordWrap(___($this->getTerms()), $row_width, "\n", true));
         foreach ($terms as $term_part) {
             $out .= $indent . $term_part . $newline;
         }
         $out .= $border;
     }
     return $out;
 }
 function render(&$out, $obj, $controller)
 {
     $field = $this->f;
     $val = $field->valueFromTable($out);
     switch ($field->getType()) {
         case 'date':
             $res = amDate($val);
             break;
         case 'select':
         case 'radio':
         case 'checkbox':
         case 'multi_select':
             $val = (array) $val;
             foreach ($val as $k => $v) {
                 $val[$k] = @$field->options[$v];
             }
             $res = implode(", ", $val);
             break;
         default:
             $res = $val;
     }
     $out = $controller->renderTd($res);
 }
 public function getRecordTitle(CouponBatch $batch = null)
 {
     return $batch ? sprintf('%s (#%d - %s)', ___('Coupon Batch'), $batch->pk(), $batch->comment ? $batch->comment : $batch->discount . ($batch->discount_type == 'percent' ? '%' : '$') . ($batch->begin_date ? ', ' . amDate($batch->begin_date) . '-' . amDate($batch->expire_date) : '')) : ___('Coupon Batch');
 }
Example #14
0
 public function export(AffPayout $payout, Am_Query $details, Zend_Controller_Response_Http $response)
 {
     $q = $details->query();
     while ($d = $payout->getDi()->db->fetchRow($q)) {
         $d = $payout->getDi()->affPayoutDetailTable->createRecord($d);
         /* @var $d AffPayoutDetail */
         $aff = $d->getAff();
         $rows[] = array($aff->data()->get('aff_bitcoin_wallet'), moneyRound($d->amount), Am_Currency::getDefault(), $aff->user_id, "Affiliate commission to " . amDate($payout->thresehold_date));
     }
     $this->sendCsv("bitcoint-commission-" . $payout->payout_id . ".txt", $rows, $response);
 }
Example #15
0
 public function sendCronExpires()
 {
     $mails = $this->findBy(array('name' => EmailTemplate::EXPIRE));
     if (!$mails) {
         return;
     }
     // nothing to send
     $byDate = array();
     // templates by expiration date
     foreach ($mails as $et) {
         $et->_productIds = $et->findMatchingProductIds();
         ///
         $day = -$et->day;
         $string = $day . ' days';
         if ($day >= 0) {
             $string = "+{$string}";
         }
         if ($day == 0) {
             $string = 'today';
         }
         $date = date('Y-m-d', strtotime($string, $this->getDi()->time));
         $byDate[$date][] = $et;
     }
     $userTable = $this->getDi()->userTable;
     // now query expirations
     $q = $this->getDi()->accessTable->queryExpirations(array_keys($byDate));
     $sent = array();
     // user_id => array('tpl_id')
     while ($row = $this->_db->fetchRow($q)) {
         $user = $userTable->createRecord($row);
         if ($user->unsubscribed || !$user->is_approved) {
             continue;
         }
         foreach ($byDate[$row['_expire_date']] as $et) {
             // do not send same template agian to the same user
             if (!empty($sent[$user->user_id]) && array_search($et->pk(), $sent[$user->user_id]) !== false) {
                 continue;
             }
             if ($et->_productIds == ResourceAccess::ANY_PRODUCT || in_array($row['_product_id'], $et->_productIds)) {
                 // check if no matching not_conditions
                 if (!$et->checkNotConditions($user)) {
                     continue;
                 }
                 $recipients = array();
                 if ($et->recipient_user) {
                     $recipients[] = $user;
                 }
                 if ($et->recipient_aff && $user->aff_id && ($aff = $this->getDi()->userTable->load($user->aff_id, false))) {
                     $recipients[] = $aff;
                 }
                 if ($et->recipient_admin) {
                     $recipients[] = Am_Mail_Template::TO_ADMIN;
                 }
                 if ($et->recipient_emails) {
                     foreach (array_map('trim', explode(',', $et->recipient_emails)) as $email) {
                         if ($email) {
                             $recipients[] = $email;
                         }
                     }
                 }
                 foreach ($recipients as $recipient) {
                     $tpl = Am_Mail_Template::createFromEmailTemplate($et);
                     $tpl->setUser($user);
                     $tpl->setExpires(amDate($row['_expire_date']));
                     $tpl->setProduct_title($this->getDi()->productTable->load($row['_product_id'])->title);
                     $tpl->send($recipient);
                 }
                 $sent[$user->user_id][] = $et->pk();
             }
         }
     }
 }
Example #16
0
 public function getLabel($key)
 {
     $tm1 = $this->getStart($key);
     return amDate($tm1) . '-' . amDate($tm1 + 7 * 24 * 3600);
     // @todo fix last year week?
 }
Example #17
0
 public function getLabel($key)
 {
     $tm1 = $this->getStart($key);
     return amDate($tm1) . '-' . amDate($tm1 + 6 * 24 * 3600);
 }
 public function runAction()
 {
     $date = $this->getFiltered('date');
     if (!$date) {
         throw new Am_Exception_InputError("Wrong date");
     }
     $form = $this->createRunForm();
     if ($form->isSubmitted() && $form->validate()) {
         $value = $form->getValue();
         $this->doRun($value['paysys_id'], $value['date']);
         echo sprintf('<div class="info">%s</div><script type="text/javascript">window.location.href="' . $value['back_url'] . '"</script>', ___('Rebill Operation Completed for %s', amDate($value['date'])));
     } else {
         echo $form;
     }
 }
Example #19
0
 function sendRebillSuccessToUser(Invoice $invoice)
 {
     try {
         if ($et = Am_Mail_Template::load('cc.rebill_success')) {
             $et->setUser($invoice->getUser());
             $et->setInvoice($invoice);
             $et->setAmount($invoice->second_total);
             $et->setRebill_date($invoice->rebill_date ? amDate($invoice->rebill_date) : ___('NEVER'));
             $et->setMailPeriodic(Am_Mail::USER_REQUESTED);
             $et->send($invoice->getUser());
         }
     } catch (Exception $e) {
         // No mail exceptions when  rebilling;
         $this->getDi()->errorLogTable->logException($e);
     }
 }
Example #20
0
 public function getDescription()
 {
     $ids = $this->product_ids ? 'products # ' . join(',', $this->product_ids) : ___('any product');
     return htmlentities(___("have invoice for %s\n            that canceled between %s and %s", $ids, amDate($this->date_start), amDate($this->date_end)));
 }
 public function getReadableValue($lineParsed, $partialRecord = null)
 {
     if ($date = $this->getValue($lineParsed, $partialRecord)) {
         return amDate($date);
     } else {
         return '';
     }
 }
Example #22
0
 public function init()
 {
     $fieldSetBank = $this->addFieldset()->setLabel(___("Bank Details"));
     $fieldSetBank->addStatic(null, array('class' => 'no-label'))->setContent(___('These details can be found on your cheque book, bank statement, or bank card'));
     $name = $fieldSetBank->addGroup()->setLabel(___("Name of Account Holder\n" . 'first and last name'));
     $name->setSeparator(' ');
     $name->addRule('required', ___('Please enter name'));
     $name->addText('name_f', array('size' => 15))->addRule('required', ___('Please enter first name'))->addRule('regex', ___('Please enter first name'), '|^[a-zA-Z_\' -]+$|');
     $name->addText('name_l', array('size' => 15))->addRule('required', ___('Please enter your last name'))->addRule('regex', ___('Please enter last name'), '|^[a-zA-Z_\' -]+$|');
     $fieldSetBank->addText('account_number', array('autocomplete' => 'off', 'maxlength' => 20))->setLabel(___("Bank Account Number"))->addRule('required', ___('Please enter Account Number'))->addRule('regex', ___('Invalid Account Number'), '/^[a-zA-Z0-9]{1,20}$/');
     $fieldSetBank->addText('sort_code', array('autocomplete' => 'off', 'maxlength' => 9))->setLabel(___("Branch Sort Code"))->addRule('required', ___('Please enter Branch Sort Code'))->addRule('regex', ___('Invalid Routing Number'), '/^[a-zA-Z0-9]{1,9}$/');
     $fieldSetBank->addText('account_name', array('autocomplete' => 'off', 'maxlength' => 50))->setLabel(___("Bank Account Name\n" . 'name associated with the bank account'))->addRule('required');
     $fieldSetBank->addText()->setlabel(___('Date of First Collection'))->setValue(amDate($this->plugin->getPaymentDate(true)))->toggleFrozen(true);
     $fieldSetAddress = $this->addFieldset()->setLabel(___("Address Details"));
     $street = $fieldSetAddress->addText('street')->setLabel(___('Street Address'))->addRule('required', ___('Please enter Street Address'));
     $city = $fieldSetAddress->addText('city')->setLabel(___('City'))->addRule('required', ___('Please enter City'));
     $zip = $fieldSetAddress->addText('zip')->setLabel(___('ZIP'))->addRule('required', ___('Please enter ZIP code'));
     $country = $fieldSetAddress->addSelect('country')->setLabel(___('Country'))->setId('f_cc_country')->loadOptions(Am_Di::getInstance()->countryTable->getOptions(true));
     $country->addRule('required', ___('Please enter Country'));
     $group = $fieldSetAddress->addGroup()->setLabel(___('State'));
     $group->addRule('required', ___('Please enter State'));
     /** @todo load correct states */
     $stateSelect = $group->addSelect('state')->setId('f_cc_state')->loadOptions($stateOptions = Am_Di::getInstance()->stateTable->getOptions(@$_REQUEST['country'], true));
     $stateText = $group->addText('state')->setId('t_cc_state');
     $disableObj = $stateOptions ? $stateText : $stateSelect;
     $disableObj->setAttribute('disabled', 'disabled')->setAttribute('style', 'display: none');
     $this->addSaveButton(___('Submit Details'));
 }
Example #23
0
 function getText($format = "%s", $skip_one_c = false)
 {
     if ($this->isEmpty()) {
         return null;
     }
     switch ($this->unit) {
         case 'd':
             $uu = $this->count == 1 ? 'day' : 'days';
             break;
         case 'm':
             $uu = $this->count == 1 ? 'month' : 'months';
             break;
         case 'y':
             $uu = $this->count == 1 ? 'year' : 'years';
             break;
         case self::FIXED:
             return " up to " . amDate($this->count);
     }
     $cc = $this->count;
     if ($this->count == 1) {
         $cc = $skip_one_c ? '' : 'one';
     }
     return sprintf($format, "{$cc} {$uu}");
 }
Example #24
0
 function render($indent = "")
 {
     $out = $indent . ___("Invoice") . ' #' . $this->public_id . " / " . amDate($this->tm_added) . "\n";
     $out .= $indent . str_repeat('-', 70) . "\n";
     foreach ($this->getItems() as $item) {
         $out .= $indent . sprintf("  %-50s %3s%8.2f\n", ___($item->item_title), $this->currency, $item->first_total);
     }
     $out .= $indent . str_repeat('-', 70) . "\n";
     if ($this->first_subtotal != $this->first_total) {
         $out .= $indent . sprintf("  %-50s %3s%8.2f\n", ___("Subtotal"), $this->currency, $this->first_subtotal);
     }
     if ($this->first_discount > 0) {
         $out .= $indent . sprintf("  %-50s %3s%8.2f\n", ___("Discount"), $this->currency, $this->first_discount);
     }
     if ($this->first_shipping > 0) {
         $out .= $indent . sprintf("  %-50s %3s%8.2f\n", ___("Shipping"), $this->currency, $this->first_shipping);
     }
     if ($this->first_tax > 0) {
         $out .= $indent . sprintf("  %-50s %3s%8.2f\n", ___("Tax"), $this->currency, $this->first_tax);
     }
     $out .= $indent . sprintf("  %-50s %3s%8.2f\n", ___("Total"), $this->currency, $this->first_total);
     $out .= $indent . str_repeat('-', 70) . "\n";
     if ($this->rebill_times) {
         $out .= $indent . "  " . ___($this->getTerms()) . "\n";
         $out .= $indent . str_repeat('-', 70) . "\n";
     }
     return $out;
 }
Example #25
0
 public function stepConfirmUpgrades()
 {
     $form = new Am_Form_Admin();
     $upgrades = $form->addGroup('upgrades', array('class' => 'no-label'));
     $options = array();
     $static = '';
     $upgrades->addStatic()->setContent('<h2>' . ___('Available Upgrades') . '</h2>');
     foreach ($this->getSession()->upgrades as $k => $upgrade) {
         if (!empty($upgrade->new)) {
             $upgrades->addStatic()->setContent('<br /><h2>' . ___('New Modules Available') . '</h2>');
         }
         $text = sprintf('%s%s, ' . ___('version') . ' %s - %s' . '<br />', '<b>' . $upgrade->title . '</b>', $upgrade->type == 'core' ? '' : sprintf(' [%s - %s]', $upgrade->type, $upgrade->id), '<i>' . $upgrade->version . '</i>', '<i>' . amDate($upgrade->date) . '</i>');
         $upgrades->addCheckbox($k, empty($upgrade->checked) ? null : array('checked' => 'checked'))->setContent($text);
         $static .= "<div class='changelog' style='' data-for='{$k}'><pre>" . $upgrade->text . "</pre></div>\n";
         $upgrades->addStatic()->setContent($static);
     }
     $form->addCheckbox('_confirm', array('class' => 'no-label'))->setContent(___('I understand that upgrade may overwrite customized PHP files and templates, I have already made a backup of aMember Pro folder and database'))->addRule('required');
     $form->addSubmit('', array('value' => ___('Install Updates')));
     if ($form->isSubmitted() && $form->validate()) {
         $confirmed = array_keys(array_filter($upgrades->getValue()));
         if (!$confirmed) {
             $this->view->title = ___('No upgrades to install');
             $this->view->content = '<a href="' . REL_ROOT_URL . '/admin">' . ___('Back') . '</a>';
             return false;
         }
         $upgrades = $this->getSession()->upgrades;
         foreach ($upgrades as $k => $v) {
             if (!in_array($k, $confirmed)) {
                 unset($upgrades[$k]);
             }
         }
         $this->getSession()->upgrades = $upgrades;
         return true;
     } else {
         $this->view->content = (string) $form;
         $this->view->title = ___('Choose Upgrades to Install');
         $this->view->display('admin/layout.phtml');
         $this->noDisplay = true;
         return false;
     }
 }
 public function renderDate(CcRebill $obj)
 {
     $raw = $obj->rebill_date;
     $d = amDate($raw);
     return $this->renderTd("{$d}<input type='hidden' name='raw-date' value='{$raw}' />", false);
 }