public function goFilterAjax()
 {
     $validator = Validator::create(array('package' => 'min:3|max:1024', 'package_version' => 'min:3|max:255', 'brand' => 'min:3|max:255', 'os_version' => 'min:1|max:255', 'phone_model' => 'min:3|max:255', 'product' => 'min:3|max:255'));
     if ($validator->failed()) {
         return BootstrapUI::formResponse()->failedOn($validator);
     }
     $data = $validator->getParamsObj();
     $params = array();
     if ($data->package !== null) {
         $params['package'] = $data->package;
     }
     if ($data->package_version !== null) {
         $params['package_version'] = $data->package_version;
     }
     if ($data->brand !== null) {
         $params['brand'] = $data->brand;
     }
     if ($data->os_version !== null) {
         $params['os_version'] = $data->os_version;
     }
     if ($data->phone_model !== null) {
         $params['phone_model'] = $data->phone_model;
     }
     if ($data->product !== null) {
         $params['product'] = $data->product;
     }
     // the country is array
     if (Input::hasPost('country')) {
         $params['country'] = implode(',', array_values(Input::post('country')));
     }
     if (sizeof($params) == 0) {
         return BootstrapUI::formResponse()->failed('You must define at least one criteria!');
     }
     return BootstrapUI::formResponse()->redirect(Url::href('live-feed', 'filter', $params));
 }
Esempio n. 2
0
 public function __construct()
 {
     parent::__construct();
     $this->remove('icon');
     $this->set('__field_name', Input::post('__field_name'));
     $this->set('__field_id', Input::post('__field_id'));
     $this->set('__form_id', Input::post('__form_id'));
 }
 public function findAnyAjax()
 {
     $stackTraceId = Input::post('stack_trace_id');
     $total = Crash\Archive::count(array('stack_trace_id' => $stackTraceId));
     if ($total > 0) {
         $random = rand(0, $total - 1);
         $records = Crash\Archive::query()->field('id')->where('stack_trace_id', $stackTraceId)->limit($random, 1)->fetchAllObj();
         $id = $records[0]->id;
         return BootstrapUI::buttonRemoteResponse()->redirect(\Koldy\Url::href('report', $id));
     } else {
         return BootstrapUI::buttonRemoteResponse()->disableButton()->text('No reports');
     }
 }
 public function versionsAjax()
 {
     $packageId = (int) Input::post('package_id');
     if ($packageId <= 0) {
         Application::throwError(400, 'Bad request');
     }
     $resultSet = new Package\ResultSet\Version();
     $resultSet->setPackageId($packageId, Input::post('last'));
     $timeFrom = $resultSet->getFromTime();
     return BootstrapUI::tableRemoteResponse()->primaryKey('package_version_id')->column('total', function ($value, $row) {
         return \Bootstrap::label($value)->color('red');
     })->column('name')->column('action', function ($value, $row) use($packageId, $timeFrom) {
         return \Bootstrap::anchor(\Bootstrap::icon('search'), \Koldy\Url::href('reports', 'search', array('package_version_id' => $row['package_version_id'], 'date_from' => \Misc::userDate('Y-m-d H:i:s', strtotime($timeFrom)))))->title('Find reports with this package version')->asButton()->size('xs')->color('red');
     })->resultSet($resultSet)->handle();
 }
Esempio n. 5
0
 /**
  * Handle the request
  * @return \Bootstrap\Response\TableRemote
  */
 public function handle()
 {
     $this->params = Input::requireParams('page', 'limit', 'field', 'dir');
     $page = (int) $this->params->page;
     if ($page < 1) {
         $page = 1;
     }
     $limitPerPage = (int) $this->params->limit;
     $field = (string) trim($this->params->field);
     $this->resultSet->page($page, $limitPerPage)->orderBy($field, $this->params->dir);
     // check if this is request with search
     $search = trim((string) \Koldy\Input::post('search'));
     if ($search != '') {
         $fields = $this->searchFields !== null ? $this->searchFields : $this->columns;
         foreach ($fields as $field) {
             $this->resultSet->orWhere($field, "%{$search}%", null, 'LIKE');
         }
     }
     \Log::debug($this->resultSet);
     // get the rows of data
     $this->data = $this->resultSet->fetch();
     if (is_array($this->data)) {
         $this->tbody = array();
         foreach ($this->data as $row) {
             $this->tbody[] = "<tr data-id=\"{$row[$this->primaryKey]}\">";
             foreach ($this->columns as $column) {
                 $value = isset($row[$column]) ? $row[$column] : null;
                 if (isset($this->columnValueModifier[$column])) {
                     $fn = $this->columnValueModifier[$column];
                     $fnResult = $fn($value, $row);
                     $this->tbody[] = "<td>{$fnResult}</td>";
                 } else {
                     $value = strip_tags(stripslashes($value));
                     $this->tbody[] = "<td>{$value}</td>";
                 }
             }
             $this->tbody[] = '</tr>';
         }
         $this->tbody = implode("\n", $this->tbody);
     }
     // get the totals
     $total = (int) $this->resultSet->count();
     // get the info
     if ($total > 0) {
         $start = ($this->params->page - 1) * $this->params->limit + 1;
         $end = $start + $this->params->limit;
         if ($end > $total) {
             $end = $total;
         }
         /*$this->info = __('table.records.info', 'Showing {from} - {to} of {total}',
         			'The info below remote table about how many rows are visible. Variables are {from}, {to} and {total}',
         			array('from' => $start, 'to' => $end, 'total' => $total)
         		);*/
         $this->info = "Showing {$start} - {$end} of {$total}";
     } else {
         $this->info = 'No results';
     }
     // create pagination
     $this->pagination = new \Koldy\Pagination($this->params->page, $total);
     $this->pagination->setItemsPerPage(10)->setCssDefault('btn btn-primary btn-xs')->setCssSelected('btn-info');
     return $this;
 }