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');
$billingcodes = $q->loadList();
function invoice_getTasks(&$a) {
global $project_id;
$q = new w2p_Database_Query();
$q->addQuery('
task_log_id,
......@@ -186,14 +184,15 @@ function invoice_getTasks(&$a) {
$q->addOrder('task_log_name ASC');
$tmptasks=$q->exec();
$tasks=db_fetch_assoc($tmptasks);
if (!$tmptasks) {
echo db_error();
return null;
}
$tasks=db_fetch_assoc($tmptasks);
return $tasks;
}
function invoice_showtask(&$a, $tasks) {
global $AppUI, $project_id, $billingcodes;
$df = $AppUI->getPref( 'SHDATEFORMAT' );
function invoice_getuser(&$tasks) {
$q = new w2p_Database_Query();
$q->addQuery('
contact_first_name,
......@@ -203,7 +202,19 @@ function invoice_showtask(&$a, $tasks) {
$q->addWhere('user_id = ' . $tasks['task_log_creator']);
$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") {
$costdesc="None";
......@@ -242,26 +253,17 @@ function showtasklog(&$a) {
global $AppUI, $project_id;
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new w2p_Database_Query();
$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']);
$username = invoice_getuser($a);
$tmpuser=$q->exec();
if (!$tmpuser) {
echo db_error();
}
$username=db_fetch_assoc($tmpuser);
$q->clear();
$q = new w2p_Database_Query();
$q->addQuery('task_invoice');
$q->addTable('invoice_task_queue');
$q->addWhere('task_log_id = ' . $a['task_log_id']);
$tmpcheck=$q->exec();
if (!$tmpcheck) {
echo db_error();
}
$check=db_fetch_assoc($tmpcheck);
$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