- 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();
+ $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);
+ if($tiny_agreement < 30 || $tiny_agreement > 999) {
+ return './tiny_agreement';
+ }
+ }
+
+ if($ever_was_contractor) {
+ tem_show('su_link');
+ }
+
+ if(logged_in_as_contractor()) {
+ tem_show('contractor_links');
+ tem_show('contractor_todo');
+
+ $GLOBALS['unpaid_totals'] = array();
+ 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);
+
+ 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);
+ totals_summary($GLOBALS['unpaid_totals']);
+ task_summary('finished_paid', 'where state=%i && paid = 1 order by finished_at desc limit 20', TASK_FINISHED);
+ } else {
+ tem_show('not_contractor_links');
+ $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('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);
+ }