function index_main() {
if(!logged_in()) {
- return './login';
+ return 'login';
}
$ret = _index_main();
if($ret) {
tem_show('main_body');
}
-function task_summary($tem_prefix, $where_clause) {
- $rows = db_get_rows('tasks', 'id,price,title,state', $where_clause);
+# pass multiple argumens for where-clause and printf-args just like db_get_rows()
+function task_summary($tem_prefix, $where_clause/*, ... */) {
+ $args = func_get_args();
+ $args = array_slice($args, 1);
+ array_unshift($args, 'tasks', 'id,price,title,state,client_id');
+ print_r($args);
+ $rows = call_user_func_array('db_get_rows', $args);
+ #$rows = db_get_rows('tasks', 'id,price,title,state,client_id', $where_clause);
if($rows) {
$total = 0.0;
foreach($rows as $row) {
- list($id, $price, $title, $state) = $row;
+ list($id, $price, $title, $state, $client_id) = $row;
tem_set('task_id', $id);
tem_set('task_title', $title);
tem_set('task_price', $price);
tem_set('task_state', task_state_pretty($state));
+ if(logged_in_as_contractor()) {
+ tem_set('client', db_get_value('people', 'name', 'where id=%i', $client_id));
+ }
tem_show($tem_prefix . '_row');
$total += $price;
}
}
function _index_main() {
- task_summary('needs_attention', 'where state=' . TASK_DRAFT . ' || state=' . TASK_NEEDS_CLARIFICATION . ' || state=' . TASK_NEEDS_GO_AHEAD . ' || state=' . TASK_NEEDS_TESTING . ' order by id');
- task_summary('queue', 'where state=' . TASK_QUEUED . ' || state='. TASK_BUG . ' order by ord');
- task_summary('jason', 'where state=' . TASK_NEEDS_QUOTE . ' || state=' . TASK_WORKING . ' || state=' . TASK_BUG . ' order by id desc');
- #task_summary('jason_pricing', 'where state=' . TASK_NEEDS_QUOTE . ' order by id desc');
- #task_summary('jason_working', 'where state=' . TASK_WORKING . ' order by id desc');
- task_summary('finished_unpaid', 'where state=' . TASK_FINISHED . ' && paid = 0 order by id desc');
- task_summary('finished_paid', 'where state=' . TASK_FINISHED . ' && paid = 1 order by id desc');
+ $client_id = logged_in();
+ if(logged_in_as_contractor()) {
+ task_summary('needs_attention', 'where state=%i || state=%i || state=%i order by id desc', TASK_NEEDS_QUOTE, TASK_WORKING, TASK_BUG);
+ task_summary('finished_unpaid', 'where state=%i && paid = 0 order by id desc', TASK_FINISHED);
+ task_summary('finished_paid', 'where state=%i && paid = 1 order by id desc', TASK_FINISHED);
+ } else {
+ task_summary('needs_attention', 'where state=' . TASK_DRAFT . ' || state=' . TASK_NEEDS_CLARIFICATION . ' || state=' . TASK_NEEDS_GO_AHEAD . ' || state=' . TASK_NEEDS_TESTING . ' order by id');
+ task_summary('queue', 'where state=' . TASK_QUEUED . " && client_id=$client_id order by ord");
+ task_summary('jason', 'where state=' . TASK_NEEDS_QUOTE . ' || state=' . TASK_WORKING . ' || state=' . TASK_BUG . ' order by id desc');
+ #task_summary('jason_pricing', 'where state=' . TASK_NEEDS_QUOTE . ' order by id desc');
+ #task_summary('jason_working', 'where state=' . TASK_WORKING . ' order by id desc');
+ task_summary('finished_unpaid', 'where state=' . TASK_FINISHED . ' && paid = 0 order by id desc');
+ task_summary('finished_paid', 'where state=' . TASK_FINISHED . ' && paid = 1 order by id desc');
+ }
return;
}