public function setGrid(Am_Grid_Editable $grid) { $grid->addCallback(Am_Grid_ReadOnly::CB_RENDER_TABLE, array($this, 'renderOut')); /* @var $ds Am_Query */ $this->ds = clone $grid->getDataSource(); parent::setGrid($grid); }
public function indexAction() { if (is_null($this->layout)) { echo $this->grid->run(); } else { $this->grid->runWithLayout($this->layout); } }
protected function getContent($obj, Am_Grid_Editable $grid) { $id = $this->action->getIdForRecord($obj); $val = $obj->{$this->field->getFieldName()}; list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id)); $content = sprintf('<input name="%s" class="live-checkbox" data-url="%s" data-id="%d" data-params="%s" data-value="%s" data-empty_value="%s" type="checkbox" %s/>', Am_Controller::escape($grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id)), Am_Controller::escape($url), $id, Am_Controller::escape(Am_Controller::getJson($params)), Am_Controller::escape($this->action->getValue()), Am_Controller::escape($this->action->getEmptyValue()), $val == $this->action->getValue() ? 'checked ' : ''); return $content; }
public function createForm(Am_Grid_Editable $grid) { $id = substr($grid->getId(), 1); $form = new Am_Form_Admin(); $form->addText("value", array('size' => 40))->setLabel(___("Value\nuse % as wildcard mask")); $form->addHidden("type")->setValue($id); $form->addText('comment', array('size' => 40))->setLabel(___("Comment")); return $form; }
public function createGrid() { $ds = new Am_Query($this->getDi()->newsletterGuestTable); $g = new Am_Grid_Editable('_guest', ___("Newsletter Guest Subscribers"), $ds, $this->_request, $this->view); $g->setPermissionId('newsletter'); $g->setForm(array($this, 'createForm')); $g->setFilter(new Am_Grid_Filter_Text(___('Filter by e-mail or name'), array('name_f' => 'LIKE', 'name_l' => 'LIKE', 'email' => 'LIKE'))); $g->addGridField('name_f', ___('First Name')); $g->addGridField('name_l', ___('Last name')); $g->addGridField('email', ___('E-Mail')); $g->addGridField('subscriptions', ___('Subscriptions'))->setGetFunction(array($this, 'getGuestSubscriptions')); $g->setFormValueCallback('_s', array('RECORD', 'getLists'), array('RECORD', 'setLists')); return $g; }
protected function initGridFields() { $this->addField(new Am_Grid_Field_Expandable('_access', ___('Products'), false))->setPlaceholder(array($this, 'getPlaceholder'))->setRenderFunction(array($this, 'renderProducts'))->setGetFunction(array($this, 'getProducts'))->setMaxLength(200); $this->addField('_link', ___('Link'), false)->setRenderFunction(array($this, 'renderLink')); $this->actionAdd(new Am_Grid_Action_SortContent()); parent::initGridFields(); }
protected function initGridFields() { $this->addField(new Am_Grid_Field('title', 'Title', true, '', null, '45%')); $this->addField(new Am_Grid_Field('url', 'URL', true, '', null, '50%')); $this->addField(new Am_Grid_Field('is_disabled', 'Is Disabled?', true, '', null, '5%')); parent::initGridFields(); }
public function indexAction() { $ds = new Am_Query($this->getDi()->apiKeyTable); $grid = new Am_Grid_Editable('_api', ___("API Keys"), $ds, $this->_request, $this->view, $this->getDi()); $grid->addField('comment', ___('Comment')); $grid->addField(new Am_Grid_Field_Expandable('key', ___('Key')))->setPlaceholder(array($this, 'truncateKey')); $grid->addField(new Am_Grid_Field_IsDisabled()); $grid->setForm(array($this, 'createForm')); $grid->addCallback(Am_Grid_Editable::CB_VALUES_TO_FORM, array($this, 'valuesToForm')); $grid->addCallback(Am_Grid_Editable::CB_VALUES_FROM_FORM, array($this, 'valuesFromForm')); $grid->addCallback(Am_Grid_ReadOnly::CB_RENDER_CONTENT, array($this, 'renderContent')); return $grid->runWithLayout('admin/layout.phtml'); }
function createGrid() { $query = new Am_Query($this->getDi()->fileDownloadTable); $query->leftJoin('?_file', 'f', 'f.file_id=t.file_id')->addField('f.title', 'title')->addWhere('user_id=?', $this->getParam('user_id')); $grid = new Am_Grid_Editable('_file_download', ___("File Downloads"), $query, $this->_request, $this->view); $grid->setPermissionId(Am_Auth_Admin::PERM_LOGS_DOWNLOAD); $grid->actionsClear(); $grid->actionAdd(new Am_Grid_Action_Delete()); $grid->actionAdd(new Am_Grid_Action_Group_Delete()); $grid->addField(new Am_Grid_Field_Date('dattm', ___('Date/Time'))); $grid->addField('remote_addr', ___('IP')); $grid->addField('title', ___('File')); return $grid; }
public function createGrid() { $ds = new Am_Query($this->getDi()->helpdeskCategoryTable); $ds->leftJoin('?_admin', 'a', 't.owner_id=a.admin_id')->addField("CONCAT(a.login, ' (',a.name_f, ' ', a.name_l, ')')", 'owner'); $ds->setOrder('sort_order'); $grid = new Am_Grid_Editable('_helpdesk_category', ___("Ticket Categories"), $ds, $this->_request, $this->view); $grid->addField(new Am_Grid_Field('title', ___('Title'), true, '', null, '50%')); $grid->addField(new Am_Grid_Field('owner_id', ___('Owner'), true, '', array($this, 'renderOwner'))); $grid->addField(new Am_Grid_Field_IsDisabled()); $grid->setForm('Am_Form_Admin_HelpdeskCategory'); $grid->addCallback(Am_Grid_Editable::CB_BEFORE_SAVE, array($this, 'beforeSave')); $grid->setPermissionId(Bootstrap_Helpdesk::ADMIN_PERM_CATEGORY); $grid->actionAdd(new Am_Grid_Action_Sort_HelpdeskCategory()); return $grid; }
public function createGrid() { $grid = new Am_Grid_Editable('_curr', ___('Currency Exchange Rates'), new Am_Query($this->getDi()->currencyExchangeTable), $this->_request, $this->view); $grid->setFilter(new Am_Grid_Filter_CurrencyExchange()); $grid->addField('currency', ___('Currency')); $grid->addField(new Am_Grid_Field_Date('date', ___('Date')))->setFormatDate(); $grid->addField('rate', ___('Exchange Rate')); $grid->setForm(array($this, 'createForm')); return $grid; }
public function createGrid() { $ds = new Am_Query($this->getDi()->stateTable); $ds = $ds->addWhere('t.country=?', $this->country); $ds->addField('ABS(tag)', 'tag_abs'); $ds->setOrderRaw('tag_abs desc, title'); $grid = new Am_Grid_Editable('_s', ___("Browse States"), $ds, $this->_request, $this->view); $grid->setPermissionId(Am_Auth_Admin::PERM_COUNTRY_STATE); $grid->addField(new Am_Grid_Field('tag_abs', ___('Sort Order'), true, null, null, '10%')); $grid->addField(new Am_Grid_Field('title', ___('Title'), true)); $grid->addField(new Am_Grid_Field('state', ___('Code'), true)); $grid->addField(new Am_Grid_Field('country', ___('Country'), true)); $grid->setForm(array($this, 'createForm')); $grid->actionDelete('delete'); $grid->addCallback(Am_Grid_ReadOnly::CB_TR_ATTRIBS, array($this, 'getTrAttribs')); $grid->addCallback(Am_Grid_Editable::CB_VALUES_TO_FORM, array($this, 'valuesToForm')); $grid->addCallback(Am_Grid_Editable::CB_VALUES_FROM_FORM, array($this, 'valuesFromForm')); $grid->actionAdd(new Am_Grid_Action_LiveEdit('title')); $grid->actionAdd(new Am_Grid_Action_Group_StateEnable(false)); $grid->actionAdd(new Am_Grid_Action_Group_StateEnable(true)); $grid->setFilter(new Am_Grid_Filter_Text(___('Filter by State Title'), array('title' => 'LIKE'))); return $grid; }
public function createGrid() { $ds = new Am_Query($this->getDi()->emailTemplateLayoutTable); $grid = new Am_Grid_Editable('_etl', ___('Email Template Layouts'), $ds, $this->_request, $this->view); $grid->addField(new Am_Grid_Field('name', ___('Title')))->setRenderFunction(array($this, 'renderTitle')); $grid->setForm(array($this, 'createForm')); $grid->setRecordTitle(___('Layout')); $grid->actionGet('delete')->setIsAvailableCallback(function ($r) { return $r->pk() > 3; }); return $grid; }
public function log($message = null, $tablename = null, $record_id = null) { if ($message === null) { $message = $this->grid->getRecordTitle($this->getTitle()); } if ($tablename === null) { $tablename = 'grid' . $this->grid->getId(); } if ($record_id === null) { try { $record_id = $this->grid->getRecordId(); } catch (Exception $e) { } } if (!defined('AM_ADMIN') || !AM_ADMIN) { return; } $this->grid->getDi()->adminLogTable->log($message, $tablename, $record_id); }
public function displaysnippetsAction() { if (!$this->strategy->canUseSnippets()) { throw new Am_Exception_AccessDenied(); } $ticket = $this->getDi()->helpdeskTicketTable->load($this->getParam('ticket'), false); $tpl = null; if ($ticket) { $tpl = new Am_SimpleTemplate(); $tpl->assign('user', $ticket->getUser()); } $ds = new Am_Query($this->getDi()->helpdeskSnippetTable); $grid = new Am_Grid_Editable('_snippet', ___('Snippets'), $ds, $this->getRequest(), $this->view, $this->getDi()); $grid->addField('title', ___('Title'))->setRenderFunction(function ($record, $fieldName, $grid) use($tpl) { $c = $record->content; if ($tpl) { $c = $tpl->render($c); } return sprintf('<td><a href="javascript:;" class="local am-helpdesk-insert-snippet" data-snippet-content="%s">%s</a></td>', Am_Controller::escape($c), Am_Controller::escape($record->title)); }); $grid->setForm(array($this, 'createForm')); $grid->actionGet('insert')->setTarget(null); $grid->setPermissionId(Bootstrap_Helpdesk::ADMIN_PERM_ID); $grid->isAjax($this->isAjax() && $this->isGridRequest('_snippet')); echo $grid->run(); }
function commTabAction() { $this->setActiveMenu('users-browse'); $ds = new Am_Query($this->getDi()->affCommissionTable); $ds->leftJoin('?_invoice', 'i', 'i.invoice_id=t.invoice_id'); $ds->leftJoin('?_user', 'u', 'u.user_id=i.user_id'); $ds->leftJoin('?_product', 'p', 't.product_id=p.product_id')->addField('u.user_id', 'user_id')->addField('CONCAT(u.login, \' (\',u.name_f, \' \',u.name_l,\') [#\', u.user_id, \']\')', 'user_name')->addField('p.title', 'product_title')->addField('IF(payout_detail_id IS NULL, \'no\', \'yes\')', 'is_paid'); $ds->setOrder('date', 'desc')->addWhere('t.aff_id=?', $this->getParam('user_id')); $grid = new Am_Grid_Editable('_affcomm', ___('Affiliate Commission'), $ds, $this->_request, $this->view); $grid->setPermissionId(Bootstrap_Aff::ADMIN_PERM_ID); $grid->actionsClear(); $userUrl = new Am_View_Helper_UserUrl(); $grid->addField(new Am_Grid_Field_Date('date', ___('Date')))->setFormatDate(); $grid->addField('user_name', ___('User'))->addDecorator(new Am_Grid_Field_Decorator_Link($userUrl->userUrl('{user_id}'), '_top')); $grid->addField('product_title', ___('Product')); $grid->addField('record_type', ___('Type'))->setRenderFunction(array($this, 'renderType')); $fieldAmount = $grid->addField('amount', ___('Commission'))->setRenderFunction(array($this, 'renderCommAmount')); $grid->addField('is_paid', ___('Paid')); $grid->addField('tier', ___('Tier'))->setRenderFunction(array($this, 'renderTier')); $grid->addCallback(Am_Grid_ReadOnly::CB_TR_ATTRIBS, array($this, 'commCbGetTrAttribs')); $grid->setFilter(new Am_Grid_Filter_AffCommission()); $grid->actionAdd(new Am_Grid_Action_Total())->addField($fieldAmount, "IF(record_type='void', -1*%1\$s, %1\$s)"); $grid->actionAdd(new Am_Grid_Action_Aff_Void()); $grid->runWithLayout('admin/user-layout.phtml'); }
function init() { parent::init(); $this->addField('country', ___('Country'))->setGetFunction(function ($record, $grid, $field) { static $countries; if (!is_array($countries)) { $countries = array(); } if (!$record->country) { return ''; } if (!isset($countries[$record->country])) { $countries[$record->country] = Am_Di::getInstance()->countryTable->getTitleByCode($record->country); } return $record->country . "(" . $countries[$record->country] . ")"; }); $this->totals[] = $this->addField('sales_amount', ___('Consumer Sales'))->setGetFunction(array($this, 'getAmount')); $this->totals[] = $this->addField('sales_without_tax_amount', ___('Amount excl. VAT'))->setGetFunction(array($this, 'getAmount')); $this->addField('tax_rate', ___('VAT Rate'))->setGetFunction(function ($record, $grid, $field) { return $record->{$field} ? $record->{$field} . "%" : "-"; }); $this->totals[] = $this->addField('tax_amount', ___('VAT Amount'))->setGetFunction(array($this, 'getAmount')); $this->setFilter(new Am_Grid_Filter_EU_VAT_Report()); }
public function createDemoHistoryGrid() { $records = $this->getDi()->store->getBlob('import-records'); $records = $records ? unserialize($records) : array(); $ds = new Am_Grid_DataSource_Array($records); $ds->setOrder('date', true); $grid = new Am_Grid_Editable('_h', ___('Import History'), $ds, $this->_request, $this->view); $grid->setPermissionId(Am_Auth_Admin::PERM_IMPORT); $grid->addField(new Am_Grid_Field_Date('date', ___('Date'), false, '', null, '10%'))->setFormatDate(); $grid->addField('id', '#'); $grid->addField(new Am_Grid_Field('title', ___('Title'), false, '', array($this, 'renderGridTitle'), '90%')); $grid->actionsClear(); $grid->actionAdd(new Am_Grid_Action_ImportDel()); return $grid; }
protected function initGridFields() { $this->addField(new Am_Grid_Field('name', ___('Title'))); parent::initGridFields(); }
public function categoryAction() { $ret = array(); foreach ($this->getDi()->helpdeskFaqTable->getCategories() as $category) { $cat = new stdClass(); $cat->name = $category; $ret[] = $cat; } $ds = new Am_Grid_DataSource_FaqCategory($ret); $grid = new Am_Grid_Editable('_helpdesk_faq_category', ___('Categories'), $ds, $this->_request, $this->view); $grid->setPermissionId(Bootstrap_Helpdesk::ADMIN_PERM_FAQ); $grid->addField(new Am_Grid_Field('name', ___('Title'))); $grid->actionsClear(); $grid->actionAdd(new Am_Grid_Action_Back('faq-edit-category-back', ___('Back to FAQ List'))); $grid->actionAdd(new Am_Grid_Action_LiveEdit('name')); $grid->runWithLayout('admin/layout.phtml'); }
public function createGrid() { $this->view->headScript()->appendFile(REL_ROOT_URL . "/application/default/views/public/js/jquery/jquery.json.js"); $this->view->headScript()->appendScript($this->getJs()); $table = $this->getDi()->savedFormTable; $ds = new Am_Query($table); $ds->addWhere('`type` in (?a)', array_keys($table->getTypeDefs())); $ds->addOrderRaw("`type`='signup' DESC"); $grid = new Am_Grid_Editable('_s', ___("Forms Editor"), $ds, $this->_request, $this->view); $grid->setForm(array($this, 'createForm')); $grid->setRecordTitle(' '); //$grid->addGridField(new Am_Grid_Field('saved_form_id', '#', true, '', null, '5%')); $grid->addGridField(SavedForm::D_SIGNUP, ___('Default Signup'), false)->setWidth('5%')->setRenderFunction(array($this, 'renderDefault')); $grid->addGridField(SavedForm::D_MEMBER, ___('Default for Members'), false)->setWidth('5%')->setRenderFunction(array($this, 'renderDefault')); $existingTypes = $this->getDi()->savedFormTable->getExistingTypes(); $grid->actionGet('edit')->setTarget('_top'); $grid->actionDelete('insert'); foreach ($this->getDi()->savedFormTable->getTypeDefs() as $type => $typeDef) { if (!empty($typeDef['isSingle']) && in_array($type, $existingTypes)) { continue; } $grid->actionAdd(new Am_Grid_Action_Insert('insert-' . $type))->addUrlParam('type', $type)->setTitle(___('New %s', $typeDef['title'])); } $grid->addCallback(Am_Grid_Editable::CB_BEFORE_SAVE, array($this, 'beforeSave')); $grid->addGridField(new Am_Grid_Field('type', ___('Type'))); $grid->addGridField(new Am_Grid_Field('title', ___('Title'))); $grid->addGridField(new Am_Grid_Field('comment', ___('Comment'))); $grid->addGridField(new Am_Grid_Field('code', ___('Code'))); $grid->addGridField(new Am_Grid_Field('url', ___('URL')))->setRenderFunction(array($this, 'renderUrl')); $grid->actionGet('delete')->setIsAvailableCallback(create_function('$record', 'return $record->canDelete();')); return $grid; }
public function createInvoice() { $query = new Am_Query(new InvoiceLogTable()); $query->addField("m.login", "login"); $query->leftJoin("?_user", "m", "t.user_id=m.user_id"); $query->setOrder('tm', 'desc'); $g = new Am_Grid_Editable('_invoice', ___('Invoice Log'), $query, $this->getRequest(), $this->view); $g->addField(new Am_Grid_Field('tm', ___('Time'), true, '', null, '10%')); $g->addField(new Am_Grid_Field('invoice_id', ___('Invoice'), true, '', null, '5%')); $g->addField(new Am_Grid_Field('login', ___('User'), true, '', null, '5%')); $g->addField(new Am_Grid_Field('remote_addr', ___('IP'), true, '', null, '5%')); $g->addField(new Am_Grid_Field('paysys_id', ___('Paysystem'), true, '', null, '10%')); $g->addField(new Am_Grid_Field('title', ___('Title'), true, '', null, '25%')); $g->addField(new Am_Grid_Field_Expandable('details', ___('Details'), false, '', null, '25%'))->setGetFunction(array($this, 'renderInvoiceDetails')); $g->actionsClear(); $g->actionAdd(new Am_Grid_Action_InvoiceRetry()); $g->setFilter(new Am_Grid_Filter_InvoiceLog()); return $g; }
public function indexAction() { $this->grid->runWithLayout($this->layout); }
public function setGrid(Am_Grid_Editable $grid) { $grid->addCallback(Am_Grid_ReadOnly::CB_RENDER_TABLE, array($this, 'renderLink')); parent::setGrid($grid); }
public function __construct(Am_Request $request, Am_View $view) { $di = Am_Di::getInstance(); $ds = null; $i = 0; $key = null; foreach ($di->resourceAccessTable->getAccessTables() as $k => $t) { $q = new Am_Query($t); $q->clearFields(); if (empty($key)) { $key = $t->getKeyField(); } $q->addField($t->getKeyField(), $key); $type = $t->getAccessType(); $q->addField("'{$type}'", 'resource_type'); $q->addField($t->getTitleField(), 'title'); $q->addField($q->escape($t->getAccessTitle()), 'type_title'); $q->addField($q->escape($t->getPageId()), 'page_id'); if ($t instanceof EmailTemplateTable) { $q->addWhere('name IN (?a)', array(EmailTemplate::AUTORESPONDER, EmailTemplate::EXPIRE)); } if (empty($ds)) { $ds = $q; } else { $ds->addUnion($q); } } // yes we need that subquery in subquery to mask field names // to get access of fields of main query (!) $ds->addOrderRaw("(SELECT _sort_order\n FROM ( SELECT sort_order as _sort_order,\n resource_type as _resource_type,\n resource_id as _resource_id\n FROM ?_resource_access_sort ras) AS _ras\n WHERE _resource_id={$key} AND _resource_type=resource_type LIMIT 1),\n {$key}, resource_type"); parent::__construct('_all', ___('All Content'), $ds, $request, $view, $di); $this->addField('type_title', ___('Type')); $this->addField('title', ___('Title')); if ($this->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_resource_resource_category")) { $this->addField(new Am_Grid_Field('rgroup', ___('Categories'), false))->setRenderFunction(array($this, 'renderCategory')); } $this->actionDelete('insert'); $this->actionDelete('edit'); $this->actionDelete('delete'); $this->actionAdd(new Am_Grid_Action_ContentAllEdit('edit', ___('Edit'), '')); $this->actionAdd(new Am_Grid_Action_SortContent()); }
public function createGrid() { $ds = new Am_Query($this->getDi()->notificationTable); $ds->leftJoin('?_notification_click', 'nc', 't.notification_id=nc.notification_id')->addField('COUNT(nc.notification_click_id)', 'cnt')->addOrder('sort_order'); $grid = new Am_Grid_Editable('_notification', ___('Notifications'), $ds, $this->_request, $this->view, $this->getDi()); $grid->setPermissionId(Am_Plugin_Notification::ADMIN_PERM_ID); $grid->addField('content', ___('Content')); $grid->addField('url', ___('Link')); $grid->addField(new Am_Grid_Field_Date('begin', ___('Begin')))->setFormatDate(); $grid->addField(new Am_Grid_Field_Date('expire', ___('Expire')))->setFormatDate(); $grid->addField('cnt', ___('Clicks'), true, null, null, '1%')->setRenderFunction(array($this, 'renderClicks')); $grid->addField(new Am_Grid_Field_IsDisabled()); $grid->setForm(array($this, 'createForm')); $grid->addCallback(Am_Grid_Editable::CB_VALUES_TO_FORM, array($this, 'valuesToForm')); $grid->addCallback(Am_Grid_Editable::CB_VALUES_FROM_FORM, array($this, 'valuesFromForm')); $grid->actionAdd(new Am_Grid_Action_NotificationPreview('preview', ___('Preview')))->setTarget('_top'); $grid->actionAdd(new Am_Grid_Action_Group_Delete()); $grid->actionAdd(new Am_Grid_Action_Sort_Notification()); $grid->addCallback(Am_Grid_ReadOnly::CB_RENDER_STATIC, array($this, 'renderStatic')); $grid->setFilter(new Am_Grid_Filter_Text(___('Filter by Content or Link'), array('content' => 'LIKE', 'url' => 'LIKE'))); $grid->setRecordTitle(___('Notification')); return $grid; }
public function createMailQueue() { $ds = new Am_Query($this->getDi()->mailQueueTable); $ds->setOrder('added', true); $g = new Am_Grid_Editable('_mail', ___("E-Mail Queue"), $ds, $this->getRequest(), $this->view); $g->setPermissionId(Am_Auth_Admin::PERM_LOGS_MAIL); $g->addField(new Am_Grid_Field('recipients', ___('Recipients'), true, '', null, '20%')); $g->addField(new Am_Grid_Field_Date('added', ___('Added'), true)); $g->addField(new Am_Grid_Field_Date('sent', ___('Sent'), true)); $g->addField(new Am_Grid_Field('subject', ___('Subject'), true, '', null, '30%'))->setRenderFunction(array($this, 'renderSubject')); $body = new Am_Grid_Field_Expandable('body', ___('Mail'), true, '', null, '20%'); $body->setEscape(true); $body->setGetFunction(array($this, 'renderMail')); $g->addField($body); $g->setFilter(new Am_Grid_Filter_Text(___("Filter by subject or recepient"), array('subject' => 'LIKE', 'recipients' => 'LIKE'))); $g->actionsClear(); $g->actionAdd(new Am_Grid_Action_MailRetry('retry')); if ($this->getDi()->authAdmin->getUser()->isSuper()) { $g->actionAdd(new Am_Grid_Action_Delete()); $g->actionAdd(new Am_Grid_Action_Group_Delete()); } return $g; }
public function createGrid() { $ds = new Am_Query($this->getDi()->otoTable); $grid = new Am_Grid_Editable('_oto', ___('One Time Offer'), $ds, $this->_request, $this->view, $this->getDi()); $grid->setPermissionId(Am_Plugin_Oto::ADMIN_PERM_ID); $grid->addField('comment', ___('Comment')); $grid->addField(new Am_Grid_Field_IsDisabled()); $grid->setForm(array($this, 'createForm')); $grid->setFormValueCallback('conditions', array('RECORD', 'getConditions'), array('RECORD', 'setConditions')); $grid->setFormValueCallback('view', array('RECORD', 'getView'), array('RECORD', 'setView')); $grid->actionGet('edit')->setTarget('_top'); $grid->addCallback(Am_Grid_Editable::CB_VALUES_TO_FORM, array($this, 'valuesToForm')); $grid->addCallback(Am_Grid_Editable::CB_VALUES_FROM_FORM, array($this, 'valuesFromForm')); $grid->actionAdd(new Am_Grid_Action_Url('preview', ___('Preview'), REL_ROOT_URL . '/admin-one-time-offer/preview?id=__ID__'))->setTarget('_blank'); $grid->actionAdd(new Am_Grid_Action_CopyOto())->setTarget('_top'); $grid->actionAdd(new Am_Grid_Action_Group_Callback('disable', ___('Disable'), array($this, 'disableOto'))); $grid->actionAdd(new Am_Grid_Action_Group_Callback('enable', ___('Enable'), array($this, 'enableOto'))); $grid->actionAdd(new Am_Grid_Action_Group_Delete()); $grid->actionAdd(new Am_Grid_Action_LiveEdit('comment')); $grid->setRecordTitle(___('One Time Offer')); return $grid; }
public function upgradesAction() { $billingTableRecords = $this->getDi()->billingPlanTable->findBy(); $productOptions = $this->getDi()->productTable->getOptions(); $planOptions = array(); foreach ($billingTableRecords as $bp) { if (!isset($productOptions[$bp->product_id])) { continue; } /* @var $bp BillingPlan */ if (!($terms = $bp->terms)) { $tt = new Am_TermsText($bp); $terms = $tt->getString(); } $planOptions[$bp->pk()] = $productOptions[$bp->product_id] . '/' . $bp->title . ' (' . $terms . ')'; } $ds = new Am_Query($this->getDi()->productUpgradeTable); $grid = new Am_Grid_Editable('_upgrades', ___("Product Upgrades"), $ds, $this->_request, $this->view); $grid->setPermissionId('grid_product'); $grid->_planOptions = $planOptions; $grid->addField(new Am_Grid_Field_Enum('from_billing_plan_id', ___('Upgrade From')))->setTranslations($planOptions); $grid->addField(new Am_Grid_Field_Enum('to_billing_plan_id', ___('Upgrade To')))->setTranslations($planOptions); $grid->addField('surcharge', ___('Surcharge'))->setGetFunction(create_function('$r', 'return Am_Currency::render($r->surcharge);')); $grid->setForm(array($this, 'createUpgradesForm')); $grid->runWithLayout('admin/layout.phtml'); }
function viewAction() { // display payouts list date | method | total | paid | $id = $this->getInt('payout_id'); if (!$id) { throw new Am_Exception_InputError("Not payout_id passed"); } $ds = new Am_Query($this->getDi()->affPayoutDetailTable); $ds->leftJoin('?_aff_payout', 'p', 'p.payout_id=t.payout_id'); $ds->leftJoin('?_user', 'u', 't.aff_id=u.user_id'); $ds->addField('u.*'); $ds->addField('p.type', 'type'); $ds->addWhere('t.payout_id=?d', $id); $grid = new Am_Grid_Editable('_d', ___("Payout %d Details", $id), $ds, $this->_request, $this->view); $grid->setPermissionId('affiliates'); $grid->addCallback(Am_Grid_Editable::CB_RENDER_TABLE, array($this, 'addBackLink')); $grid->addField('email', ___('E-Mail')); $grid->addField('name_f', ___('First Name')); $grid->addField('name_l', ___('Last Name')); $grid->addField('type', ___('Payout Method')); $grid->addField('amount', ___('Amount')); // $grid->addField('receipt_id', ___('Receipt Id')); $grid->addField('is_paid', ___('Is Paid?')); $grid->addField(new Am_Grid_Field_Expandable('_details', ___('Payout Details')))->setGetFunction(array($this, 'getPayoutDetails')); $grid->actionsClear(); //$grid->actionAdd(new Am_Grid_Action_LiveEdit('receipt_id')); $grid->actionAdd(new Am_Grid_Action_PayoutMarkPaid('mark_paid', ___("Mark Paid"))); $grid->actionAdd(new Am_Grid_Action_PayoutMarkNotPaid('mark_notpaid', ___("Mark NOT Paid"))); $grid->runWithLayout(); // detail payout records date | method | paid | receipt_id | aff. payout fields }