Пример #1
0
 /**
  * Default view function
  *
  * @return void
  */
 public function displayTask()
 {
     $filters = Filters::getFilters("{$this->_option}.{$this->_controller}");
     $records = Record::all();
     // Take filters and apply them to the tasks
     if ($filters['search']) {
         foreach ($filters['search'] as $term) {
             $records->where('description', 'LIKE', "%{$term}%", 'and', 1);
             $records->orWhereRelatedHas('task', function ($task) use($term) {
                 $task->where('name', 'LIKE', "%{$term}%");
             }, 1);
         }
     }
     if ($filters['q']) {
         foreach ($filters['q'] as $q) {
             if ($q['o'] == '=' && $q['column'] == 'date') {
                 $q['o'] = 'LIKE';
                 $q['value'] .= '%';
             }
             if ($q['o'] == '!=' && $q['column'] == 'date') {
                 $q['o'] = 'NOT LIKE';
                 $q['value'] .= '%';
             }
             $records->where($q['column'], $q['o'], $q['value']);
         }
     }
     // Display
     $this->view->filters = $filters;
     $this->view->records = $records->paginated()->ordered()->including('task', 'user', 'task.hub');
     $this->view->display();
 }
Пример #2
0
 /**
  * Default view function
  *
  * @return void
  */
 public function displayTask()
 {
     $filters = Filters::getFilters("{$this->_option}.{$this->_controller}");
     $tasks = Task::all();
     // Take filters and apply them to the tasks
     if ($filters['search']) {
         foreach ($filters['search'] as $term) {
             $tasks->where('name', 'LIKE', "%{$term}%");
         }
     }
     if ($filters['q']) {
         foreach ($filters['q'] as $q) {
             $tasks->where($q['column'], $q['o'], $q['value']);
         }
     }
     // Display
     $this->view->filters = $filters;
     $this->view->tasks = $tasks->paginated()->ordered()->including('liaison', 'assignee', 'hub');
     $this->view->display();
 }
Пример #3
0
							<?php 
foreach (Filters::getColumnNames('time_records', array("id", "description", "end")) as $c) {
    ?>
								<option value="<?php 
    echo $c['raw'];
    ?>
"><?php 
    echo $c['human'];
    ?>
</option>
							<?php 
}
?>
						</select>
						<?php 
echo Filters::buildSelectOperators();
?>
						<select name="q[value]" id="filter-value">
						</select>
						<input id="filter-submit" class="btn btn-success" type="submit" value="<?php 
echo Lang::txt('+ Add filter');
?>
" />
						<input type="hidden" value="time_records" id="filter-table" />
					</p>
				</div><!-- / .filters -->
			</form>
			<?php 
if (!empty($this->filters['q']) || is_array($this->filters['search']) && !empty($this->filters['search'][0])) {
    ?>
				<div id="applied-filters">
Пример #4
0
 /**
  * Retrieves possible unique values based on table and column
  *
  * @apiMethod GET
  * @apiUri    /time/getValues
  * @apiParameter {
  * 		"name":        "table",
  * 		"description": "Table name of interest",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     ""
  * }
  * @apiParameter {
  * 		"name":        "column",
  * 		"description": "Table column of interest",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     ""
  * }
  * @return  void
  */
 public function getValuesTask()
 {
     // Require authentication and authorization
     $this->requiresAuthentication();
     $this->authorizeOrFail();
     // Get table and column values
     $table = Request::getVar('table', '');
     $column = Request::getVar('column', '');
     // Make sure those values haven't been tampered with
     $acceptable = array('time_tasks', 'time_records');
     if (!in_array($table, $acceptable)) {
         App::abort(404, 'Table provided is not allowed');
     }
     // Setup query
     $query = "SELECT DISTINCT(" . $column . ") as val";
     $query .= " FROM #__" . $table;
     $query .= " ORDER BY val ASC";
     App::get('db')->setQuery($query);
     if (!($values = App::get('db')->loadObjectList())) {
         App::abort(500, 'Query failed');
     }
     // Process any overrides
     $values = Filters::filtersOverrides($values, $column);
     // Create object with values
     $response = new stdClass();
     $response->values = $values;
     // Return object
     $this->send($response);
 }