-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.php
More file actions
84 lines (73 loc) · 2.22 KB
/
search.php
File metadata and controls
84 lines (73 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require 'application/config/requirements.php';
Flight::set('flight.views.path', './application/views');
/**
* note** use this to debug: Flight::tools()->debug($data);
* use this to debug with var_dump: Flight::tools()->debug($data, true);
*/
class search
{
// public url functions <start>
/**
* The only function that will be called publicly.
*
* Params can't really be used in this framework. They are just present for reference.
* Params will be used by using the get global variable
* @param mixed $ac_no id
* @param string $from date start
* @param string $to date end
* @param string $update yes or no
*/
public static function index($ac_no = '', $from = '', $to = '', $update = '')
{
self::update_bio_log_records();
$where = self::where_query_builder();
if(Flight::tools()->is_ajax_request() === true)
{
$data = Flight::tools()->model()->bl()->read($where);
Flight::json(array('data' => $data));
}
else
Flight::suffer_tools()->render_suffer_page();
Flight::stop();
}
// public url functions <end>
/**
* Just update the records.
* Warning: Could take a while to finish.
*/
private static function update_bio_log_records()
{
if(Flight::request()->query->update_records == 'yes')
Pages::update(true);
}
/**
* build array understandable by meedo ORM to create a query
* @return array built query understandable by meedo
*/
private static function where_query_builder()
{
$ac_no = Flight::request()->query->ac_no; # could be comma separated multiple numbers
$from = Flight::request()->query->from_date; # date start
$to = Flight::request()->query->to_date; # date end
$order = Flight::request()->query->order; # order pattern only. ex: ASC, DESC
$ac_no_data = explode(',',str_replace(' ', '', $ac_no));
$where = array(
"AND" => array(
"log_time[<>]" => array(
$from,
$to,
),
),
);
if($order == NULL)
$where['ORDER'] = 'log_time ASC';
else
$where['ORDER'] = 'log_time '.$order;
if(!empty($ac_no_data[0]))
$where['AND']["ac_no"] = $ac_no_data;
return $where;
}
}
Flight::start();
?>