Commit 787b3ace authored by Jean-Paul Saman's avatar Jean-Paul Saman

addedit.php: refactor showtasklog()

parent 6b4f0383
...@@ -168,8 +168,6 @@ $q->addOrder('billingcode_name ASC'); ...@@ -168,8 +168,6 @@ $q->addOrder('billingcode_name ASC');
$billingcodes = $q->loadList(); $billingcodes = $q->loadList();
function invoice_getTasks(&$a) { function invoice_getTasks(&$a) {
global $project_id;
$q = new w2p_Database_Query(); $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
task_log_id, task_log_id,
...@@ -186,14 +184,15 @@ function invoice_getTasks(&$a) { ...@@ -186,14 +184,15 @@ function invoice_getTasks(&$a) {
$q->addOrder('task_log_name ASC'); $q->addOrder('task_log_name ASC');
$tmptasks=$q->exec(); $tmptasks=$q->exec();
$tasks=db_fetch_assoc($tmptasks); if (!$tmptasks) {
echo db_error();
return null;
}
$tasks=db_fetch_assoc($tmptasks);
return $tasks; return $tasks;
} }
function invoice_showtask(&$a, $tasks) { function invoice_getuser(&$tasks) {
global $AppUI, $project_id, $billingcodes;
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new w2p_Database_Query(); $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
contact_first_name, contact_first_name,
...@@ -203,7 +202,19 @@ function invoice_showtask(&$a, $tasks) { ...@@ -203,7 +202,19 @@ function invoice_showtask(&$a, $tasks) {
$q->addWhere('user_id = ' . $tasks['task_log_creator']); $q->addWhere('user_id = ' . $tasks['task_log_creator']);
$tmpuser=$q->exec(); $tmpuser=$q->exec();
$username=db_fetch_assoc($tmpuser); if (!$tmpuser) {
echo db_error();
return null;
}
$username=db_fetch_assoc($tmpuser);
return $username;
}
function invoice_showtask(&$a, $tasks) {
global $AppUI, $project_id, $billingcodes;
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$username = invoice_getuser($tasks);
if ($a["task_amount"] == "0") { if ($a["task_amount"] == "0") {
$costdesc="None"; $costdesc="None";
...@@ -242,26 +253,17 @@ function showtasklog(&$a) { ...@@ -242,26 +253,17 @@ function showtasklog(&$a) {
global $AppUI, $project_id; global $AppUI, $project_id;
$df = $AppUI->getPref( 'SHDATEFORMAT' ); $df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new w2p_Database_Query(); $username = invoice_getuser($a);
$q->addQuery('
contact_first_name,
contact_last_name');
$q->addTable('contacts');
$q->leftJoin('users', 'u', 'user_contact = contact_id');
$q->addWhere('user_id = ' . $a['task_log_creator']);
$tmpuser=$q->exec(); $q = new w2p_Database_Query();
if (!$tmpuser) {
echo db_error();
}
$username=db_fetch_assoc($tmpuser);
$q->clear();
$q->addQuery('task_invoice'); $q->addQuery('task_invoice');
$q->addTable('invoice_task_queue'); $q->addTable('invoice_task_queue');
$q->addWhere('task_log_id = ' . $a['task_log_id']); $q->addWhere('task_log_id = ' . $a['task_log_id']);
$tmpcheck=$q->exec(); $tmpcheck=$q->exec();
if (!$tmpcheck) {
echo db_error();
}
$check=db_fetch_assoc($tmpcheck); $check=db_fetch_assoc($tmpcheck);
$date = new w2p_Utilities_Date($a['task_log_date']); $date = new w2p_Utilities_Date($a['task_log_date']);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment