From cbafb2c3196d960b7d3e37b4d2a1b5bf7c8bf14d Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Mon, 8 Dec 2008 04:06:17 -0500 Subject: [PATCH] contractor can enter tasks for clients without switching login --- tasks.html | 4 ++++ tasks.php | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tasks.html b/tasks.html index af09c86..80d3dba 100644 --- a/tasks.html +++ b/tasks.html @@ -46,6 +46,10 @@
+ + + + diff --git a/tasks.php b/tasks.php index 7c5f0d4..8995d80 100644 --- a/tasks.php +++ b/tasks.php @@ -32,14 +32,14 @@ function description_has_fixmes($description) { } # replace every character in $str with " " -function tonbsp($matches) { +function to_nbsp($matches) { return str_repeat(' ', strlen($matches[0]) * 2); } # encode as html, make it display newlines and leading spaces function enc_htmlbrtab($str) { $str = enc_htmlbr($str); - $str = preg_replace_callback("|^ *|m", tonbsp, $str); + $str = preg_replace_callback("|^ *|m", to_nbsp, $str); return $str; } @@ -210,7 +210,7 @@ function tasks_edit_main() { if(isset($_REQUEST['tasks_approve_price_id'])) { $id = $_REQUEST['tasks_approve_price_id']; - $owner = db_get_value('tasks', 'client_id', 'where id=%i', $id);; + $owner = db_get_value('tasks', 'client_id', 'where id=%i', $id); if(logged_in() != $owner) { message("Error: can't approve a task entered by/for another client."); return './'; @@ -290,7 +290,7 @@ function tasks_edit_main() { } } - if("you're happy with the POSTed values") { + if("you're happy with the POSTed values") { # if you change this change the one above if($edit_id) { if(isset($_REQUEST['price']) && logged_in_as_contractor()) { db_update('tasks', 'title,url,description,state,price', $title, $url, $description, $state, $price, 'where id=%i', $edit_id); @@ -302,6 +302,9 @@ function tasks_edit_main() { # new task $paid = 0; $client_id = logged_in(); + if(logged_in_as_contractor() && $_REQUEST['client_id']) { + $client_id = format_int($_REQUEST['client_id']); + } db_insert('tasks', 'client_id,title,url,description,state,paid', $client_id, $title, $url, $description, $state, $paid); message('Task saved.'); } @@ -348,6 +351,11 @@ function tasks_edit_main() { tem_show('bug_msg'); } else { tem_show('new_msg'); + if(logged_in_as_contractor()) { + pulldown('client_id', db_get_rows('people', 'id,name', 'where id > 1'), PULLDOWN_2D); + tem_set('client_id', format_int($_REQUEST['client_id'])); + tem_show('client_row'); + } } # display instructions -- 1.7.10.4
Client:
Title:
URL: