X-Git-Url: https://jasonwoof.com/gitweb/?p=contractor-progress.git;a=blobdiff_plain;f=index.php;fp=index.php;h=88b09f6434198e7cb1b99e2899c11e712daee514;hp=03e307755e6895685e8a84a73312af2136fbe9e4;hb=387c118c6b5f7f4c547f27db2ac8aab6612471ee;hpb=98110d79b6536290baffd1468f22cb8b046902cd diff --git a/index.php b/index.php index 03e3077..88b09f6 100644 --- a/index.php +++ b/index.php @@ -34,8 +34,14 @@ function task_summary($tem_prefix, $where_clause/*, ... */) { $args = array_slice($args, 1); array_unshift($args, 'tasks', 'id,price,title,state,client_id,paid'); $rows = call_user_func_array('db_get_rows', $args); - #$rows = db_get_rows('tasks', 'id,price,title,state,client_id', $where_clause); + $num_rows = 0; if($rows) { + $num_rows = count($rows); + if($num_rows > 1) { + tem_show($tem_prefix . '_plural'); + } else { + tem_show($tem_prefix . '_singular'); + } $total = 0.0; foreach($rows as $row) { list($id, $price, $title, $state, $client_id, $paid) = $row; @@ -45,6 +51,12 @@ function task_summary($tem_prefix, $where_clause/*, ... */) { tem_set('task_state', task_state_pretty($state)); if(logged_in_as_contractor()) { tem_set('client', db_get_value('people', 'username', 'where id=%i', $client_id)); + if($tem_prefix == 'queue') { + tem_show('queued_for'); + } + } + if($num_rows > 1 && $tem_prefix == 'queue') { + tem_show('not_the_only_queued'); } tem_show($tem_prefix . '_row'); if(!$paid && isset($GLOBALS['unpaid_totals'])) { @@ -63,6 +75,8 @@ function task_summary($tem_prefix, $where_clause/*, ... */) { tem_show($tem_prefix); } + + return $num_rows; } # pass multi-dimensional hash arr[client_id][status]. @@ -87,8 +101,8 @@ function totals_summary($arr) { if(isset($t['queue'])) { $queue = $t['queue']; } - if(isset($t['needs_approval'])) { # administrator page re-uses this for TASK_WORKING - $working = $t['needs_approval']; + if(isset($t['do_finish'])) { + $working = $t['do_finish']; } tem_set('tested_total', $finished_unpaid); tem_set('done_total', $finished_unpaid + $finished_untested); @@ -117,6 +131,15 @@ function _index_main() { $client_id = logged_in(); $ever_was_contractor = ever_was_contractor(); + $contractor_full_name = db_get_value('people', 'name', 'where id=1'); + if(!$contractor_full_name) { + die('To finish installing this site, make yourself an account in the people table with id=1'); + } + list($contractor_name,) = explode(' ', $contractor_full_name, 2); + tem_set('contractor_name', $contractor_name); + tem_set('contractor_full_name', $contractor_full_name); + + # make sure the client (not the contractor) has filled out the tiny agreement if(!$ever_was_contractor) { $tiny_agreement = db_get_value('people', 'tiny_agreement', 'where id=%i', $client_id); @@ -131,14 +154,13 @@ function _index_main() { if(logged_in_as_contractor()) { tem_show('contractor_links'); - tem_show('needs_attention_header'); + tem_show('contractor_todo'); $GLOBALS['unpaid_totals'] = array(); - # things with a view link: - task_summary('needs_approval', 'where state=%i order by id desc', TASK_WORKING); # this affects queued_total + task_summary('do_finish', 'where state=%i order by id desc', TASK_WORKING); # this affects queued_total + task_summary('do_fix', 'where state=%i order by client_id desc', TASK_BUG); + task_summary('do_price', 'where state=%i order by client_id desc', TASK_NEEDS_QUOTE); - # things with an edit link: - task_summary('needs_fixing', 'where state=%i || state=%i order by id desc', TASK_NEEDS_QUOTE, TASK_BUG); task_summary('finished_untested', 'where state=%i order by client_id, finished_at desc', TASK_NEEDS_TESTING); task_summary('finished_unpaid', 'where state=%i && paid=0 order by finished_at desc', TASK_FINISHED); task_summary('queue', 'where state=%i order by client_id, ord desc', TASK_QUEUED); @@ -146,14 +168,25 @@ function _index_main() { task_summary('finished_paid', 'where state=%i && paid = 1 order by finished_at desc limit 20', TASK_FINISHED); } else { tem_show('not_contractor_links'); - if(db_count('tasks', 'where client_id=%i && (state=%i || state=%i || state=%i || state=%i || state=%i)', $client_id, TASK_DRAFT, TASK_NEEDS_CLARIFICATION, TASK_ON_HOLD, TASK_NEEDS_GO_AHEAD, TASK_NEEDS_TESTING)) { - tem_show('needs_attention_header'); - task_summary('needs_approval', 'where client_id=%i && (state=%i || state=%i) order by id', $client_id, TASK_NEEDS_GO_AHEAD, TASK_NEEDS_TESTING); - task_summary('needs_fixing', 'where client_id=%i && (state=%i || state=%i || state=%i) order by id', $client_id, TASK_ON_HOLD, TASK_DRAFT, TASK_NEEDS_CLARIFICATION); + $num_rows = 0; + $num_rows += task_summary('do_approve_price', 'where client_id=%i && state=%i order by id', $client_id, TASK_NEEDS_GO_AHEAD); + $num_rows += task_summary('do_clarify', 'where client_id=%i && state=%i order by id', $client_id, TASK_NEEDS_CLARIFICATION); + $num_rows += task_summary('do_test', 'where client_id=%i && state=%i order by id', $client_id, TASK_NEEDS_TESTING); + $num_rows += task_summary('do_draft', 'where client_id=%i && state=%i order by id', $client_id, TASK_DRAFT); + $num_rows += task_summary('do_on_hold', 'where client_id=%i && state=%i order by id', $client_id, TASK_ON_HOLD); + + if($num_rows == 0) { + tem_show('nothing_needs_your_attention'); + } elseif($num_rows == 1) { + tem_show('this_needs_your_attention'); + } else { + tem_show('these_need_your_attention'); } + task_summary('queue', 'where client_id=%i && state=%i order by ord desc', $client_id, TASK_QUEUED); - task_summary('jason', 'where client_id=%i && (state=%i || state=%i) order by id desc', $client_id, TASK_NEEDS_QUOTE, TASK_BUG); - task_summary('jason_working', 'where client_id=%i && state=%i order by id desc', $client_id, TASK_WORKING); + + task_summary('contractor_will', 'where client_id=%i && (state=%i || state=%i || state=%i) order by id desc', $client_id, TASK_NEEDS_QUOTE, TASK_BUG, TASK_WORKING); + task_summary('finished_unpaid', 'where client_id=%i && state=%i && paid=0 order by finished_at desc', $client_id, TASK_FINISHED); task_summary('finished_paid', 'where client_id=%i && state=%i && paid=1 order by finished_at desc', $client_id, TASK_FINISHED); }