/** @return Invoice|null */ public function loadInvoice($invoiceId) { $invoiceId = preg_replace('/-.*/', '', $invoiceId); $invoice = Am_Di::getInstance()->invoiceTable->findFirstByPublicId($invoiceId); // update invoice_id in the log record if ($invoice && $this->log) { $this->log->updateQuick(array('invoice_id' => $invoice->pk(), 'user_id' => $invoice->user_id)); } return $invoice; }
static function groupCallback($id, InvoiceLog $record, Am_Grid_Action_Group_Callback $action, Am_Grid_Editable $grid) { @set_time_limit(3600); try { $req = $record->getFirstRequest(); if (!$req) { echo "<br />\n{$record->log_id}: SKIPPED"; return; } $response = array(); self::repeat($record, $response); } catch (Exception $e) { $response['status'] = 'Error'; $response['msg'] = $e->getMessage(); } echo "<br />\n{$record->log_id}: {$response['status']} : {$response['msg']}"; }
public function renderInvoiceDetails(InvoiceLog $obj, $field, $controller, $fieldObj) { $fieldObj->setEscape(true); $ret = ""; $ret .= "<div class='collapsible'>\n"; $rows = $obj->getRenderedDetails(); $open = count($rows) == 1 ? 'open' : ''; foreach ($rows as $row) { $popup = @$row[2]; if ($popup) { $popup = "<br /><br />ENCODED DETAILS:<br />" . nl2br($row[2]); } $ret .= "\t<div class='item {$open}'>\n"; $ret .= "\t\t<div class='head'>{$row['0']}</div>\n"; $ret .= "\t\t<div class='more'>{$row['1']}{$popup}</div>\n"; $ret .= "\t</div>\n"; } $ret .= "</div>\n\n"; return $ret; }
/** * view method * * @param string $id * @return void */ public function listing_report_print($id = null) { $this->layoutOpt['layout'] = 'invoice'; $this->Invoice->id = $id; $this->Invoice->recursive = 1; if (!$this->Invoice->exists()) { throw new NotFoundException(__('Invalid invoice')); } App::import('Model', 'InvoiceManager.InvoiceStatus'); $invoiceStatus = new InvoiceStatus(); $status_list = $invoiceStatus->find('list', array('fields' => array('id', 'name'))); App::import('Model', 'InvoiceManager.InvoiceLog'); $invoiceLog = new InvoiceLog(); $status_log = $invoiceLog->find('all', array('conditions' => array('invoice_id' => $id))); $invoice = $this->Invoice->read(null, $id); $reportDate = date('l, F m, Y'); // debug($invoice); $this->set(compact('invoice', 'status_list', 'status_log', 'reportDate')); }
/** * Send response handle failure, return parsed array * @return array */ public function sendRequest(InvoiceLog $log) { $log->paysys_id = $this->plugin->getId(); $log->add($this); $response = $this->send(); $log->add($response); if ($response->getStatus() != 200) { throw new Am_Exception_InputError("Error communicating to PayPal, unable to finish transaction. Your account was not billed, please try again"); } parse_str($response->getBody(), $vars); if (!count($vars)) { throw new Am_Exception_InputError("Error communicating to PayPay, unable to parse response "); } return $vars; }