/** * Задать условия фильтрация для колонок * * @param RM_List_Object obList * @param array data * @return void **/ public function setFilters(RM_List_Object $obList, $data = array(), $default = array()) { $filter = isset($data['f']) ? $data['f'] : array(); foreach ($obList->getAllColumns() as $column) { //echo $column->variable() . ' => ' . $column->filterVariable() . '<br>'; if (isset($data[$column->variable()])) { $filter[$column->id()] = $data[$column->variable()]; } } // add dafult filters foreach ($default as $varname => $value) { if (is_array(@$filter[$obList->getColumnByVarname($varname)->id()])) { $count = array_count_values($filter[$obList->getColumnByVarname($varname)->id()]); if (@$count[''] == count(@$filter[$obList->getColumnByVarname($varname)->id()])) { // if all array elements is empty $filter[$obList->getColumnByVarname($varname)->id()] = $value; } } elseif (empty($filter[$obList->getColumnByVarname($varname)->id()])) { $filter[$varname] = $value; } } if ($obList->report_type == 'list') { $obList->setFilters($filter); } }
/** * Description... * * @return array **/ public function columns($type = NULL) { foreach ($this->_list->columns() as $col) { if (!isNull($type) && $col->placement != $type) { continue; } $this->_columns[$col->id()] = (object) array('data' => $col->show($this), 'class' => $col->className(), 'column' => $col, 'position' => $this->_pos); } return $this->_columns; }
public function getRowHighlight(RM_List_Object $list, RM_List_Row $row) { switch ($list->id()) { case 15: # TODO: Перенести в декоратор! return $row->ssl_only ? 'row_pink' : ''; break; default: return $this->decorator($list->id())->getRowHighlight($row); break; } }
public function init(RM_List_Object $list) { $this->_list = $list; $this->addItem(array('img' => '/img/report_settings.gif', 'alt' => L('menu.main.user_sort', array('menu_name' => L($list->menuCaption()))), 'url' => '#', 'extra' => ' onclick="getSortUser(\'' . $list->id() . '\');" ')); $this->addSeparator(); if ($this->_list->excelAvailable() && MC('List')->canLoadToExcel($list->id())) { $url = @$_SERVER['SERVER_PORT'] == 443 ? U('report.https_excel') : U('report.excel'); $url .= '?' . $_SERVER['QUERY_STRING']; $this->addItem(array('url' => $url, 'img' => '/img/toexcel.gif', 'alt' => L('report.toexcel'))); if (!$list->mailingAvailable()) { $this->addSeparator(); } } if ($list->mailingAvailable()) { $q['mailing'] = 1; $url = url($q, 'abs'); $this->addItem(array('url' => $url, 'img' => '/img/plan.gif', 'alt' => L('report.mailing'))); $this->addSeparator(); } $this->addButtonNoFilter(array('alt' => L('report.reset_filter'), 'extra' => 'onclick="clearForm(\'filterForm\'); return false;"')); $this->addButtonFilter(array('alt' => L('report.filter'), 'extra' => 'onclick="startSearch(); return false;"')); if ($this->_list->edit_script) { if (count($this->_toHtml) > 4) { $this->addSeparator(); } $this->addItem(array('img' => '/img/save.gif', 'alt' => L('common.save'), 'extra' => 'class="edit_script"')); } }
/** * Generate report * * @return bool **/ public function generateReport() { $begin = microtime(true); $this->_dropTmpTables(); $this->_createTmpTables(); $this->_fillTmpTables(); $this->_countPanelistActivity(); $this->_countMoneyInMonth(); $this->_countCategoryInMonth(); $this->_countPercents(); $this->_prepareData(); $this->_fillDataToReportTable(); $this->_dropTmpTables(); $end = microtime(true); $this->_list->updated(); M('Trace')->trace('report_region_payment', "Payments for the " . D($this->_getStartDate(), 'date-format') . " - " . D($this->_getEndDate(), 'date-format') . " has been counted up for " . round($end - $begin, 2) . " sec"); // так как отчет пересчитывается раз в месяц, то отправим емейл с уведомлением (в логах трудно отследить, пересчитался отчет или нет). M("MailSend")->sendAdminMail(array("subject" => "Payment region report", "body" => "Payments for the " . D($this->_getStartDate(), 'date-format') . " - " . D($this->_getEndDate(), 'date-format') . " has been counted up\n" . 'table: ' . $this->_report_table . "\n" . 'execution time: ' . round($end - $begin, 2) . ' sec')) or die("Cannot send mail!"); return TRUE; }
/** * Enter description here... * * @return int */ public function getTotal() { $arr = $this->_list->collectAggregate(); return $arr['total']; }
/** * Remove usergroup from access list of this report * * @return bool **/ public function removeGroupAccess(RM_Account_iGroup $obGroup, RM_List_Object $obList) { return M('Db')->exec("DELETE FROM " . $this->_tables['access'] . " WHERE list_id = ? AND group_id = ?", $obList->id(), $obGroup->id()); }