3 require_once('code/tasks.php');
5 function index_main() {
13 tem_show('main_body');
16 # pass multiple argumens for where-clause and printf-args just like db_get_rows()
17 function task_summary($tem_prefix, $where_clause/*, ... */) {
18 $args = func_get_args();
19 $args = array_slice($args, 1);
20 array_unshift($args, 'tasks', 'id,price,title,state,client_id');
21 $rows = call_user_func_array('db_get_rows', $args);
22 #$rows = db_get_rows('tasks', 'id,price,title,state,client_id', $where_clause);
25 foreach($rows as $row) {
26 list($id, $price, $title, $state, $client_id) = $row;
27 tem_set('task_id', $id);
28 tem_set('task_title', $title);
29 tem_set('task_price', $price);
30 tem_set('task_state', task_state_pretty($state));
31 if(logged_in_as_contractor()) {
32 tem_set('client', db_get_value('people', 'username', 'where id=%i', $client_id));
34 tem_show($tem_prefix . '_row');
38 tem_set('task_total', $total);
40 tem_show($tem_prefix);
44 function _index_main() {
45 $client_id = logged_in();
47 # make sure they've filled out the tiny user agreement
48 $tiny_agreement = db_get_value('people', 'tiny_agreement', 'where id=%i', $client_id);
49 if($tiny_agreement < 30) {
50 return './tiny_agreement';
53 if(logged_in_as_contractor()) {
55 tem_show('needs_attention_header');
56 task_summary('needs_approval', 'where state=%i order by id desc', TASK_WORKING);
57 task_summary('needs_fixing', 'where (state=%i || state=%i) || (client_id=1 && state<%i) order by id desc', TASK_NEEDS_QUOTE, TASK_BUG, TASK_QUEUED);
58 task_summary('finished_unpaid', 'where state=%i && paid = 0 order by id desc', TASK_FINISHED);
59 task_summary('finished_paid', 'where state=%i && paid = 1 order by id desc', TASK_FINISHED);
60 task_summary('queue', 'where state=%i order by client_id, ord', TASK_QUEUED);
62 if(db_count('tasks', 'where client_id=%i && (state=%i || state=%i || state=%i || state=%i)', $client_id, TASK_DRAFT, TASK_NEEDS_CLARIFICATION, TASK_NEEDS_GO_AHEAD, TASK_NEEDS_TESTING)) {
63 tem_show('needs_attention_header');
64 task_summary('needs_approval', 'where client_id=%i && (state=%i || state=%i) order by id', $client_id, TASK_NEEDS_GO_AHEAD, TASK_NEEDS_TESTING);
65 task_summary('needs_fixing', 'where client_id=%i && (state=%i || state=%i) order by id', $client_id, TASK_DRAFT, TASK_NEEDS_CLARIFICATION);
67 task_summary('queue', 'where client_id=%i && state=%i order by ord', $client_id, TASK_QUEUED);
68 task_summary('jason', 'where client_id=%i && (state=%i || state=%i) order by id desc', $client_id, TASK_NEEDS_QUOTE, TASK_BUG);
69 task_summary('jason_working', 'where client_id=%i && state=%i order by id desc', $client_id, TASK_WORKING);
70 task_summary('finished_unpaid', 'where client_id=%i && state=%i && paid=0 order by id desc', $client_id, TASK_FINISHED);
71 task_summary('finished_paid', 'where client_id=%i && state=%i && paid=1 order by id desc', $client_id, TASK_FINISHED);