本文整理汇总了PHP中Am_Query类的典型用法代码示例。如果您正苦于以下问题:PHP Am_Query类的具体用法?PHP Am_Query怎么用?PHP Am_Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Am_Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGrid
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;
}
示例2: createAdapter
protected function createAdapter()
{
$q = new Am_Query(Am_Di::getInstance()->newsletterListTable);
$q->leftJoin('?_newsletter_user_subscription', 's', 's.list_id = t.list_id AND s.is_active > 0');
$q->addField('COUNT(s.list_id)', 'subscribed_users');
return $q;
}
示例3: getQuery
/** @return Am_Query */
public function getQuery()
{
$q = new Am_Query($this->getDi()->helpdeskMessageTable, 'hm');
$q->clearFields();
$q->addField('COUNT(message_id)', 'cnt');
$q->addWhere('admin_id IS NULL');
return $q;
}
示例4: getMainDataSource
/**
* @return Am_Query $query;
*/
function getMainDataSource()
{
$ds = new Am_Query($this->getDi()->invoicePaymentTable);
$ds->leftJoin('?_user', 'u', 't.user_id = u.user_id')->leftJoin('?_data', 'user_country', 't.invoice_id = user_country.id and `table` = "invoice" and `key`="tax_user_country"')->leftJoin('?_invoice_refund', 'refund', 't.invoice_payment_id = refund.invoice_payment_id')->leftJoin('?_invoice', 'invoice', 't.invoice_id = invoice.invoice_id')->addField('if(user_country.value is null, if(u.country is null, "", u.country), user_country.value)', 'country')->addField('invoice.tax_rate')->addField('round(sum(if(refund.amount, t.amount-refund.amount, t.amount)/t.base_currency_multi),2)', 'sales_amount')->addField('round(sum(if(refund.amount, (t.amount-refund.amount)*if(t.tax, t.tax, 0)/t.amount, if(t.tax, t.tax, 0))/t.base_currency_multi),2)', 'tax_amount')->addField('round(sum(if(refund.amount, (t.amount-refund.amount) - (t.amount-refund.amount)*if(t.tax, t.tax, 0)/t.amount, t.amount-if(t.tax, t.tax, 0))/t.base_currency_multi),2)', 'sales_without_tax_amount')->addField('concat(if(country is null, "", country), "-", if(invoice.tax_rate is null, "", invoice.tax_rate))', 'country_rate');
$ds->groupBy('country_rate', '');
$ds->addOrder('country');
return $ds;
}
示例5: getQuery
/** @return Am_Query */
public function getQuery()
{
$q = new Am_Query(new AffCommissionTable(), 'cl');
$q->clearFields();
$q->addField("SUM(IF(cl.record_type='commission', cl.amount, -cl.amount)) AS commission");
if ($this->aff_id) {
$q->addWhere("aff_id = ?d", $this->aff_id);
}
return $q;
}
示例6: getQuery
/** @return Am_Query */
public function getQuery()
{
$q = new Am_Query(new InvoicePaymentTable(), 'p');
$q->clearFields();
foreach ($this->getPaysystems() as $k => $ps) {
$ps = $q->escape($ps);
$q->addField("ROUND(SUM(IF(p.paysys_id={$ps}, p.amount/p.base_currency_multi, 0)),2)\n", 'amt_' . $k);
}
return $q;
}
示例7: renderInvoiceCommissions
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');
}
示例8: getQuery
/** @return Am_Query */
public function getQuery()
{
$q = new Am_Query(new AffCommissionTable(), 'cl');
$q->clearFields();
$q->addField("COUNT(DISTINCT invoice_payment_id) AS sales");
if ($this->aff_id) {
$q->addWhere("aff_id = ?d", $this->aff_id);
}
return $q;
}
示例9: createGrid
function createGrid($id, $title)
{
$ds = new Am_Query($this->getDi()->banTable);
$ds->addWhere("`type` = ?", $id);
$g = new Am_Grid_Editable('_' . $id, ___("Disallow new Signups by %s", $title), $ds, $this->_request, $this->view);
$g->setForm(array($this, 'createForm'));
$g->addGridField("value", ___("Locked Value"));
$g->addGridField("comment", ___("Comment"));
$g->addCallback(Am_Grid_ReadOnly::CB_RENDER_TABLE, array($this, 'renderConfig'));
return $g;
}
示例10: createGrid
function createGrid($id, $title)
{
$ds = new Am_Query($this->getDi()->banTable);
$ds->addWhere("`type` = ?", $id);
$g = new Am_Grid_Editable('_' . $id, ___('Disallow new Signups by %s', $title), $ds, $this->_request, $this->view);
$g->setPermissionId(Am_Auth_Admin::PERM_BAN);
$g->setForm(array($this, 'createForm'));
$g->addField('value', ___('Locked Value'));
$g->addField('comment', ___('Comment'));
$g->addCallback(Am_Grid_ReadOnly::CB_RENDER_TABLE, array($this, 'renderConfig'));
return $g;
}
示例11: createGrid
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;
}
示例12: createGrid
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;
}
示例13: _getWhere
function _getWhere(Am_Query $db)
{
$a = $db->getAlias();
switch ($this->type) {
case 'any':
$c = '';
break;
case 'paid':
$c = 'AND payout_detail_id IS NOT NULL';
break;
case 'not-paid':
$c = 'AND payout_detail_id IS NULL';
break;
}
return "EXISTS\n (SELECT * FROM ?_aff_commission\n WHERE aff_id={$a}.user_id\n {$c})";
}
示例14: viewAction
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
}
示例15: gridAction
public function gridAction()
{
$prefix = $this->getRequest()->getParam('prefix');
if (!$prefix) {
throw new Am_Exception_InputError('prefix is undefined');
}
if (!$this->getDi()->uploadAcl->checkPermission($prefix, Am_Upload_Acl::ACCESS_LIST, $this->getDi()->authAdmin->getUser())) {
throw new Am_Exception_AccessDenied();
}
$ds = new Am_Query($this->getDi()->uploadTable);
$ds->addWhere('prefix=?', $prefix);
$grid = new Am_Grid_Editable_Uploads('_files', 'Files', $ds, $this->getRequest(), $this->view);
$grid->setPermissionId('grid_content');
$grid->addField(new Am_Grid_Field('name', 'Name', true))->setRenderFunction(array($this, 'renderName'));
$grid->addField(new Am_Grid_Field('desc', 'Description', true));
$grid->actionsClear();
$grid->actionAdd(new Am_Grid_Action_LiveEdit('desc'));
$grid->addCallback(Am_Grid_ReadOnly::CB_RENDER_STATIC, array($this, 'addJs'));
$grid->isAjax(false);
$response = $grid->run();
$response->sendHeaders();
$response->sendResponse();
}