JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
7f2a922240297746fca07bc26d52bda13f86d4f1
[contractor-progress.git] / index.php
1 <?php
2
3 require_once('code/tasks.php');
4
5 function enc_money($float) {
6         return format_money($float, $cents = true);
7 }
8
9 function index_main() {
10         if(!logged_in()) {
11                 return './login';
12         }
13         $ret = _index_main();
14         if($ret) {
15                 return $ret;
16         }
17         tem_show('main_body');
18 }
19
20 function task_summary($tem_prefix, $where_clause) {
21         $rows = db_get_rows('tasks', 'id,price,title,state', $where_clause);
22         if($rows) {
23                 $total = 0.0;
24                 foreach($rows as $row) {
25                         list($id, $price, $title, $state) = $row;
26                         tem_set('task_id', $id);
27                         tem_set('task_title', $title);
28                         tem_set('task_price', $price);
29                         tem_set('task_state', task_state_pretty($state));
30                         tem_show($tem_prefix . '_row');
31                         $total += $price;
32                 }
33
34                 tem_set('task_total', $total);
35
36                 tem_show($tem_prefix);
37         }
38 }
39
40 function _index_main() {
41         task_summary('needs_attention', 'where state=' . TASK_DRAFT . ' || state=' . TASK_NEEDS_CLARIFICATION . ' || state=' . TASK_NEEDS_GO_AHEAD . ' || state=' . TASK_NEEDS_TESTING . ' order by id');
42         task_summary('queue', 'where state=' . TASK_QUEUED . ' || state='. TASK_BUG . ' order by ord');
43         task_summary('jason', 'where state=' . TASK_NEEDS_QUOTE . ' || state=' . TASK_WORKING . ' || state=' . TASK_BUG . ' order by id desc');
44         #task_summary('jason_pricing', 'where state=' . TASK_NEEDS_QUOTE . ' order by id desc');
45         #task_summary('jason_working', 'where state=' . TASK_WORKING . ' order by id desc');
46         task_summary('finished_unpaid', 'where state=' . TASK_FINISHED . ' && paid = 0 order by id desc');
47         task_summary('finished_paid', 'where state=' . TASK_FINISHED . ' && paid = 1 order by id desc');
48         return;
49 }