Ejemplo n.º 1
0
 /** @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;
 }
Ejemplo n.º 2
0
 public function _getWhere(Am_Query $q)
 {
     if (!$this->id) {
         return null;
     }
     $id = $q->escape($this->id);
     return "itd.value = {$id}";
 }
 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());
 }
Ejemplo n.º 4
0
 function _getWhere(Am_Query $q)
 {
     $field = $this->checkBlob ? $this->selfAlias() . '.`blob`' : $this->selfAlias() . '.`value`';
     $ret = $field . ' ' . $this->op;
     if ($this->op != 'IS NULL' && $this->op != 'IS NOT NULL') {
         $ret .= ' ' . $q->escape($this->value);
     }
     return $ret;
 }