Commit 6b4f0383 authored by Jean-Paul Saman's avatar Jean-Paul Saman

addedit.php: refactored invoice_getHours() and invoice_showtask()

parent 06d0421a
...@@ -52,11 +52,12 @@ if($task_id == '') { ...@@ -52,11 +52,12 @@ if($task_id == '') {
$q = new w2p_Database_Query(); $q = new w2p_Database_Query();
$q->addQuery('task_log_id'); $q->addQuery('task_log_id');
$q->addTable('invoice_task_queue'); $q->addTable('invoice_task_queue');
// FIXME: not sure this solutions is correct
//$temp_billed = db_loadColumn($q->prepare()); //$temp_billed = db_loadColumn($q->prepare());
$temp_billed = $q->prepare(); $tmpbilled = $q->exec();
$temp_billed = db_fetch_assoc($tmpbilled);
$billed = ''; $billed = '';
foreach ($temp_billed as $task_log) { foreach ($temp_billed as $task_log) {
echo "invoice: " . $task_log . "<br>";
$billed .= $task_log . ', '; $billed .= $task_log . ', ';
} }
if (!empty($billed)) if (!empty($billed))
...@@ -166,29 +167,9 @@ $q->addOrder('billingcode_name ASC'); ...@@ -166,29 +167,9 @@ $q->addOrder('billingcode_name ASC');
$billingcodes = $q->loadList(); $billingcodes = $q->loadList();
// FIXME: Refactor invoice_showtask() and invoice_getHours() function invoice_getTasks(&$a) {
// since they query the same database with the same row.
// This would make all more efficient.
function invoice_getHours(&$a) {
global $project_id; global $project_id;
$q = new w2p_Database_Query();
$q->addQuery('task_log_id, task_log_hours');
$q->addTable('task_log');
$q->addWhere('task_log_id = ' . $a['task_log_id']);
$q->addOrder('task_log_name ASC');
$tmptasks=$q->exec();
$tasks=db_fetch_assoc($tmptasks);
$hours = $tasks['task_log_hours'];
return $hours;
}
function invoice_showtask(&$a) {
global $AppUI, $project_id, $billingcodes;
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new w2p_Database_Query(); $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
task_log_id, task_log_id,
...@@ -206,8 +187,14 @@ function invoice_showtask(&$a) { ...@@ -206,8 +187,14 @@ function invoice_showtask(&$a) {
$tmptasks=$q->exec(); $tmptasks=$q->exec();
$tasks=db_fetch_assoc($tmptasks); $tasks=db_fetch_assoc($tmptasks);
return $tasks;
}
$q->clear(); function invoice_showtask(&$a, $tasks) {
global $AppUI, $project_id, $billingcodes;
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
contact_first_name, contact_first_name,
contact_last_name'); contact_last_name');
...@@ -405,7 +392,7 @@ Invoices will not be editable once the status changes from Open for Editing. ...@@ -405,7 +392,7 @@ Invoices will not be editable once the status changes from Open for Editing.
</tr> </tr>
<tr valign="top" width="90%"> <tr valign="top" width="90%">
<td align="right">Invoice Tag&nbsp; <td align="right">Invoice Tag&nbsp;
<input type="text" name="tag" value="<?php echo $invoice_tag;?>" class="text" /> <input type="text" name="tag" value="<?php echo $invoice_tag;?>" class="text" pattern="^]s*]d{8}" size=8 />
</td> </td>
</tr> </tr>
<tr valign="top" width="90%"> <tr valign="top" width="90%">
...@@ -449,10 +436,10 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -449,10 +436,10 @@ for ($s=0; $s < count($tasks); $s++) {
$tnums=count($tasks); $tnums=count($tasks);
if ($tnums) { if ($tnums) {
$tmpamount=0; $tmpamount=0;
$tmpamount = invoice_showtask( $tasks[$s], 1 ); $t = invoice_getTasks($tasks[$s]);
$tmpamount = invoice_showtask( $tasks[$s], $t );
$myamount=$myamount + $tmpamount; $myamount=$myamount + $tmpamount;
$t = &$tasks[$s]; $myhours = $myhours + $t['task_log_hours'];
$myhours = $myhours + invoice_getHours( $tasks[$s]);
} }
} }
?> ?>
...@@ -544,7 +531,6 @@ if (isset($_POST['start_date'])) ...@@ -544,7 +531,6 @@ if (isset($_POST['start_date']))
<input type="hidden" name="task_invoice" value="<?php echo $invoice_id;?>" /> <input type="hidden" name="task_invoice" value="<?php echo $invoice_id;?>" />
<input type="hidden" name="project_creator" value="<?php echo $AppUI->user_id;?>" /> <input type="hidden" name="project_creator" value="<?php echo $AppUI->user_id;?>" />
<?php <?php
//echo '<tr><td>'; print_r($tasks_log); echo '</td></tr>';
for ($s=0; $s < count($tasks_log); $s++) { for ($s=0; $s < count($tasks_log); $s++) {
showtasklog( $tasks_log[$s],1); showtasklog( $tasks_log[$s],1);
} }
......
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