Пример #1
0
 public function render(Am_View $view, $user = null)
 {
     $html = $this->html;
     if (strpos($html, '%user.') !== false) {
         $t = new Am_SimpleTemplate();
         if ($user) {
             $t->assign('user', $user);
         }
         $t->assignStdVars();
         $html = $t->render($html);
     }
     if ($this->use_layout) {
         $view->content = '<div class="am-content-page">' . $html . '</div>';
         $view->title = $this->title;
         $view->meta_title = $this->meta_title ? $this->meta_title : $this->title;
         if ($this->meta_keywords) {
             $view->headMeta()->setName('keywords', $this->meta_keywords);
         }
         if ($this->meta_description) {
             $view->headMeta()->setName('description', $this->meta_description);
         }
         return $view->render($this->tpl ? $this->tpl : 'layout.phtml');
     } else {
         return $html;
     }
 }
Пример #2
0
 function renderInvoiceCommissions(Invoice $invoice, Am_View $view)
 {
     $query = new Am_Query($this->getDi()->affCommissionTable);
     $query->leftJoin('?_invoice', 'i', 'i.invoice_id=t.invoice_id')->leftJoin('?_user', 'a', 't.aff_id=a.user_id')->leftJoin('?_product', 'p', 't.product_id=p.product_id')->addField('CONCAT(a.login, \' (\', a.name_f, \' \', a.name_l,\') #\', a.user_id)', 'aff_name')->addField('p.title', 'product_title')->addWhere('t.invoice_id=?', $invoice->pk())->leftJoin('?_aff_payout_detail', 'apd', 't.payout_detail_id=apd.payout_detail_id')->leftJoin('?_aff_payout', 'ap', 'ap.payout_id=apd.payout_id')->addField('ap.date', 'payout_date')->addField('ap.payout_id')->addField('apd.is_paid')->setOrder('commission_id', 'desc');
     $items = $query->selectAllRecords();
     $view->comm_items = $items;
     $view->invoice = $invoice;
     $view->has_tiers = $this->getDi()->affCommissionRuleTable->getMaxTier();
     return $view->render('blocks/admin-user-invoice-details.phtml');
 }
Пример #3
0
 public function __toString()
 {
     try {
         $t = new Am_View();
         $t->form = $this;
         return $t->render('admin/_form.phtml');
     } catch (Exception $e) {
         user_error('Exception catched: ' . get_class($e) . ':' . $e->getMessage(), E_USER_ERROR);
     }
 }
Пример #4
0
 function renderForm($addHidden)
 {
     $this->initPossibleConditions();
     $t = new Am_View();
     $renderer = HTML_QuickForm2_Renderer::factory('array');
     if (!$this->form) {
         $this->createForm(array());
     }
     $this->form->render($renderer);
     $t->assign('form', $renderer->toArray());
     $t->assign('description', $this->getDescription(true));
     $t->assign('serialized', $this->serialize());
     $t->assign('hidden', $addHidden);
     $t->assign('loadSearchOptions', Am_Controller::renderOptions($this->getLoadOptions(), $this->saved_search_id));
     return $t->render($this->template);
 }
Пример #5
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     $invoice = $this->getDi()->invoiceTable->findBySecureId($request->getFiltered('id'), $this->getId());
     if (!$invoice) {
         throw new Am_Exception_InputError(___("Sorry, seems you have used wrong link"));
     }
     $view = new Am_View();
     $html = $this->getConfig('html', 'SITE OWNER DID NOT PROVIDE INSTRUCTIONS FOR OFFLINE PAYMENT YET');
     $tpl = new Am_SimpleTemplate();
     $tpl->invoice = $invoice;
     $tpl->user = $this->getDi()->userTable->load($invoice->user_id);
     $tpl->invoice_id = $invoice->invoice_id;
     $tpl->cancel_url = REL_ROOT_URL . '/cancel?id=' . $invoice->getSecureId('CANCEL');
     $view->content = $tpl->render($html);
     $view->title = $this->getTitle();
     $response->setBody($view->render("layout.phtml"));
 }
Пример #6
0
 /**
  * Redirect customer to new url
  * @param $targetTop useful when doing a redirect in AJAX generated html
  */
 function redirectHtml($url, $text = '', $title = 'Redirecting...', $targetTop = false, $proccessed = null, $total = null)
 {
     $this->view->assign('title', $title);
     $this->view->assign('text', $text);
     $this->view->assign('url', $url);
     if (!is_null($total)) {
         $width = 100 * $proccessed / $total;
         $this->view->width = min(100, round($width));
         $this->view->showProgressBar = true;
         $this->view->total = $total;
         $this->view->proccessed = $proccessed;
     }
     if ($targetTop) {
         $this->view->assign('target', '_top');
     }
     if (ob_get_level()) {
         ob_end_clean();
     }
     $this->getResponse()->setBody($this->view->render(defined('AM_ADMIN') ? 'admin/redirect.phtml' : 'redirect.phtml'));
     throw new Am_Exception_Redirect($url);
     // exit gracefully
 }
Пример #7
0
 public function viewAction()
 {
     $ticketIdentity = $this->_request->get('ticket');
     $ticket = $this->getDi()->helpdeskTicketTable->load($ticketIdentity);
     if (!$this->strategy->canViewTicket($ticket)) {
         throw new Am_Exception_AccessDenied(___('Access Denied'));
     }
     $grid = new Am_Helpdesk_Grid($this->getRequest(), $this->getView());
     $grid->getDataSource()->getDataSourceQuery()->addWhere('m.user_id=?d', $ticket->user_id);
     $grid->actionsClear();
     $t = new Am_View();
     $t->assign('ticket', $ticket);
     $t->assign('user', $ticket->getUser());
     $t->assign('strategy', $this->strategy);
     $t->assign('historyGrid', $grid->render());
     $content = $t->render($this->strategy->getTemplatePath() . '/ticket.phtml');
     if ($this->isAjax()) {
         header('Content-type: text/html; charset=UTF-8');
         echo $content;
     } else {
         $this->view->assign('content', $content);
         $this->view->display($this->strategy->getTemplatePath() . '/index.phtml');
     }
 }
Пример #8
0
 public function viewAction()
 {
     $ticketIdentity = $this->getParam('ticket');
     $ticket = $this->getDi()->helpdeskTicketTable->load($ticketIdentity);
     if (!$this->strategy->canViewTicket($ticket)) {
         throw new Am_Exception_AccessDenied(___('Access Denied'));
     }
     $grid = new Am_Helpdesk_Grid_Admin($this->getRequest(), $this->getView());
     $grid->getDataSource()->getDataSourceQuery()->addWhere('m.user_id=?d', $ticket->user_id);
     $grid->actionsClear();
     $grid->removeField('m_login');
     $grid->addCallback(Am_Grid_ReadOnly::CB_TR_ATTRIBS, function (&$ret, $record) use($ticket) {
         if ($record->pk() == $ticket->pk()) {
             $ret['class'] = isset($ret['class']) ? $ret['class'] . ' emphase' : 'emphase';
         }
     });
     $grid->isAjax($this->isAjax() && $this->isGridRequest('_grid'));
     if ($grid->isAjax()) {
         echo $grid->run();
         return;
     }
     $category = $ticket->getCategory();
     $t = new Am_View();
     $t->assign('ticket', $ticket);
     $t->assign('category', $category);
     $t->assign('user', $ticket->getUser());
     $t->assign('strategy', $this->strategy);
     $t->assign('historyGrid', $grid->render());
     $content = $t->render($this->strategy->getTemplatePath() . '/ticket.phtml');
     if ($this->isAjax()) {
         header('Content-type: text/html; charset=UTF-8');
         echo $content;
     } else {
         $this->view->assign('content', $content);
         $this->view->display($this->strategy->getTemplatePath() . '/index.phtml');
     }
 }
Пример #9
0
 function render($path, Am_View $view)
 {
     $urlPath = $this->request->get('path', 'upload::');
     $list = array();
     foreach ($this->plugins as $pl) {
         $o = new stdclass();
         $o->title = $pl->getTitle();
         $o->link = $this->getUrl($pl->getPath(null));
         $list[$pl->getId()] = $o;
     }
     $view->plugins = $list;
     $view->description = $this->storage->getDescription();
     $view->active_plugin = $this->storage->getId();
     $view->path = $path;
     $view->currentUrl = $this->getUrl($path);
     $items = $actions = array();
     foreach ($this->storage->getItems($path, $actions) as $item) {
         switch (true) {
             case $item instanceof Am_Storage_File:
                 $item->_data_info = $item->info($this->secure);
                 $item->_link = $this->getUrl($this->storage->getPath($item->getPath()));
                 $items[] = $item;
                 break;
             case $item instanceof Am_Storage_Folder:
                 $item->_link = $this->getUrl($this->storage->getPath($item->getPath()));
                 $items[] = $item;
                 break;
         }
     }
     foreach ($actions as $item) {
         switch (true) {
             case $item instanceof Am_Storage_Action_Upload:
                 $item->_link = $this->getUrl($urlPath . '?action=upload');
                 $view->upload = $item;
                 break;
             case $item instanceof Am_Storage_Action_CreateFolder:
                 $item->_link = $this->getUrl($urlPath . '?action=create-folder');
                 $view->createfolder = $item;
                 break;
             case $item instanceof Am_Storage_Action_Refresh:
                 $item->_link = $this->getUrl($urlPath . '?action=refresh');
                 $view->refresh = $item;
                 break;
             case $item instanceof Am_Storage_Action_DeleteFile:
                 $item->_link = $this->getUrl($urlPath . '?action=delete-file&path=__PATH__');
                 $view->deletefile = $item;
                 break;
             default:
                 $actions[] = $item;
         }
     }
     $view->actions = $actions;
     $view->items = $items;
     $output = $view->render('admin/_storage-grid.phtml');
     $this->response->appendBody($output);
 }
Пример #10
0
 function render(Am_View $view)
 {
     if ($this->path) {
         $view->block = $this;
         // add plugin folder to search path for blocks
         $paths = $view->getScriptPaths();
         $newPaths = null;
         if ($this->plugin && !$this->plugin instanceof Am_Module && ($dir = $this->plugin->getDir())) {
             $newPaths = $paths;
             // we insert it to second postion, as first will be theme
             // lets keep there some place for redefenition
             array_splice($newPaths, 1, 0, array($dir));
             $view->setScriptPath(array_reverse($newPaths));
         }
         $pluginSaved = !empty($view->plugin) ? $view->plugin : null;
         if ($this->plugin) {
             $view->plugin = $this->plugin;
         }
         $out = $view->render("blocks/" . $this->path);
         $view->plugin = $pluginSaved;
         // remove plugin folder from view search path
         if (!empty($newPaths)) {
             $view->setScriptPath(array_reverse($paths));
         }
         return $out;
     } elseif ($this->callback) {
         return call_user_func($this->callback, $view, $this);
     } else {
         throw new Am_Exception_InternalError("Unknown block path format");
     }
 }
Пример #11
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     //if ($request->getActionName() == 'cron') return $this->onHourly();
     if ($request->getActionName() == 'thanks') {
         return $this->thanksAction($request, $response, $invokeArgs);
     }
     $invoice = $this->getDi()->invoiceTable->findBySecureId($request->getFiltered('id'), $this->getId());
     if (!$invoice) {
         throw new Am_Exception_InputError(___("Sorry, seems you have used wrong link"));
     }
     $u = $invoice->getUser();
     $xml = new DOMDocument('1.0', 'utf-8');
     $e = new DOMElement('PesapalDirectOrderInfo');
     $el = $xml->appendChild($e);
     $el->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchemainstance');
     $el->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
     $el->setAttribute('Amount', number_format($invoice->first_total, 2));
     $el->setAttribute('Description', $invoice->getLineDescription());
     $el->setAttribute('Code', '');
     $el->setAttribute('Type', 'MERCHANT');
     $el->setAttribute('PaymentMethod', '');
     $el->setAttribute('Reference', $invoice->public_id);
     $el->setAttribute('FirstName', $u->name_f);
     $el->setAttribute('LastName', $u->name_l);
     $el->setAttribute('Email', $u->email);
     $el->setAttribute('PhoneNumber', $u->phone);
     $el->setAttribute('UserName', $u->email);
     $el->setAttribute('Currency', $invoice->currency);
     $el->setAttribute('xmlns', 'http://www.pesapal.com');
     //post transaction to pesapal
     $consumer = $this->getConsumer();
     $token = $params = NULL;
     $method = $this->getMethod();
     $iframe_src = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", self::URL, $params);
     $iframe_src->set_parameter("oauth_callback", $this->getPluginUrl('thanks'));
     $iframe_src->set_parameter("pesapal_request_data", $s = htmlentities($xml->saveXML()));
     $iframe_src->sign_request($method, $consumer, $token);
     $view = new Am_View();
     $view->addScriptPath(dirname(__FILE__));
     $view->invoice = $invoice;
     $view->iframe_src = $iframe_src;
     $response->setBody($view->render("payment-pesapal-confirm.phtml"));
 }
Пример #12
0
 public function __toString()
 {
     $view = new Am_View();
     $view->form = $this;
     return $view->render('_form.phtml');
 }
Пример #13
0
 protected function populateForm()
 {
     $info = $this->getController()->getValue();
     foreach ($info as $k => $v) {
         if ($k[0] == '_') {
             unset($info[$k]);
         }
     }
     if (@$info['table_prefix']) {
         foreach ($info['table'] as &$v) {
             $v = preg_replace('/^' . preg_quote($info['table_prefix']) . '/', '', $v);
         }
     }
     $userFields = array();
     $guessFields = array();
     foreach ($info['field']['user'] as $fn => $a) {
         if (empty($a['field'])) {
             continue;
         }
         $guessFields[] = $fn;
         $expr = $a['field'];
         if ($expr == 'string') {
             $expr = var_export(':' . $a['text'], true);
         } elseif ($expr == 'expr') {
             $expr = '"!' . $a['text'] . '"';
         }
         $userFields[] = "array({$expr}, '{$fn}'),";
     }
     $view = new Am_View();
     $view->assign($info);
     $view->assign('guessFields', $guessFields);
     $view->assign('userFields', $userFields);
     $cnt = "<h2>Plugin Template Generated</h2>";
     $cnt .= "Put the following code to <i>application/default/plugins/protect/{$info['plugin']}.php</i> and start customization";
     $cnt .= "<div style='background-color: #eee; width: 90%; height: 300px; overflow-x: scroll; overflow-y: scroll;'>\n";
     $cnt .= highlight_string($view->render('admin/plugin-template.phtml'), true);
     $cnt .= "</div>";
     $el = $this->form->addStatic(null, array('class' => 'no-label'))->setContent($cnt);
     $gr = $this->form->addGroup(null, array('class' => 'no-label', 'style' => 'text-align:center'));
     $gr->addSubmit($this->getButtonName('back'), array('value' => 'Back'));
     $page = $this;
     while ($p = $page->getController()->previousPage($page)) {
         $page = $p;
     }
     $gr->addSubmit($page->getButtonName('jump'), array('value' => 'Start Over'));
 }
Пример #14
0
 function renderWidget(Am_View $view, $config = null)
 {
     $view->num = is_null($config) ? 5 : $config['num'];
     return $view->render('admin/helpdesk/widget/messages.phtml');
 }
Пример #15
0
 public function renderWidgetSales(Am_View $view, $config = null)
 {
     $intervals = is_null($config) ? array(Am_Interval::PERIOD_TODAY, Am_Interval::PERIOD_THIS_WEEK_FROM_SUN) : (array) $config['interval'];
     $out = '';
     foreach ($intervals as $interval) {
         list($start, $stop) = $this->getDi()->interval->getStartStop($interval);
         $view->start = $start;
         $view->stop = $stop;
         $view->reportTitle = $this->getDi()->interval->getTitle($interval);
         $view->controller = $this;
         $out .= $view->render('admin/widget/sales.phtml');
     }
     return $out;
 }