Commit 9954e9c4 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Several fixes to invoice module.

- fix currency symbol (euro)
- fix invoice tabs
- fix overviews and layout
- fix links to project
parent 09561e2f
...@@ -40,7 +40,18 @@ foreach ($temp_billed as $task_log) ...@@ -40,7 +40,18 @@ foreach ($temp_billed as $task_log)
$billed .= $task_log . ', '; $billed .= $task_log . ', ';
if (!empty($billed)) if (!empty($billed))
$billed = '(' . substr($billed, 0, -2) . ')'; $billed = '(' . substr($billed, 0, -2) . ')';
$q->clear();
$q->addQuery('invoice_tag, invoice_status');
$q->addTable('invoice');
$q->addWhere('invoice_id = ' . $invoice_id);
$ptrc = $q->exec();
$nums=db_num_rows($ptrc);
echo db_error();
for ($x=0; $x < $nums; $x++) {
$row = db_fetch_assoc( $ptrc );
$invoice_tag = $row["invoice_tag"];
$invoice_status = $row["invoice_status"];
}
$q->clear(); $q->clear();
$q->addQuery(' $q->addQuery('
task_log.task_log_id as task_log_id, task_log.task_log_id as task_log_id,
...@@ -188,11 +199,11 @@ if ($a["task_amount"] == "0") { ...@@ -188,11 +199,11 @@ if ($a["task_amount"] == "0") {
$s .= '<td nowrap="nowrap" align=center>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td>'; $s .= '<td nowrap="nowrap" align=center>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td>';
$s .= '<td nowrap="nowrap" align=center>'.$tasks["task_log_hours"].'</td>'; $s .= '<td nowrap="nowrap" align=center>'.$tasks["task_log_hours"].'</td>';
$s .= '<td nowrap="nowrap">'.$costdesc.'</td>'; $s .= '<td nowrap="nowrap">'.$costdesc.'</td>';
$s .= '<td nowrap="nowarap">' . dPgetConfig('currency_symbol').$amount.'</td>'; $s .= '<td nowrap="nowarap">' . dPgetConfig('currency_symbol') . '&nbsp;' . $amount.'</td>';
$s .= '</tr>'; $s .= '</tr>';
$s .= '<tr>'; $s .= '<tr>';
$s .= '<td colspan="2">&nbsp;</td>'; $s .= '<td colspan="2">&nbsp;</td>';
$s .= '<td colspan="5">'; $s .= '<td colspan="6">';
$s .= $tasks["task_log_description"]; $s .= $tasks["task_log_description"];
$s .= '</td>'; $s .= '</td>';
$s .= "</tr>\n"; $s .= "</tr>\n";
...@@ -234,7 +245,7 @@ $date = new CDate($a['task_log_date']); ...@@ -234,7 +245,7 @@ $date = new CDate($a['task_log_date']);
<td nowrap>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td> <td nowrap>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td>
<td nowrap>'.$a['task_log_hours'].'</td> <td nowrap>'.$a['task_log_hours'].'</td>
<td nowrap>'.$a['billingcode_name'].'</td> <td nowrap>'.$a['billingcode_name'].'</td>
<td align="right" nowrap="nowrap">$<input type="text" name="fixed_'.$a['task_log_id'].'" size="6"> <td align="right" nowrap="nowrap">'.dPgetConfig('currency_symbol').'&nbsp; <input type="text" name="fixed_'.$a['task_log_id'].'" size="6">
</tr> </tr>
'; ';
if (trim($check['task_invoice']) == '') if (trim($check['task_invoice']) == '')
...@@ -346,6 +357,16 @@ Invoices will not be editable once the status changes from Open for Editing. ...@@ -346,6 +357,16 @@ Invoices will not be editable once the status changes from Open for Editing.
</td> </td>
</tr> </tr>
<tr valign="top" width="90%"> <tr valign="top" width="90%">
<td align="right">Invoice Number&nbsp;
<?php echo $invoice_id?>
</td>
</tr>
<tr valign="top" width="90%">
<td align="right">Invoice Tag&nbsp;
<input type="text" name="tag" value="<?php echo $invoice_tag;?>" class="text" />
</td>
</tr>
<tr valign="top" width="90%">
<td align="right">Invoice Status&nbsp; <td align="right">Invoice Status&nbsp;
<select name="stat" size="1" class="text"> <select name="stat" size="1" class="text">
<option value="0">Open for Editing</option> <option value="0">Open for Editing</option>
...@@ -389,8 +410,11 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -389,8 +410,11 @@ for ($s=0; $s < count($tasks); $s++) {
} }
?> ?>
<tr> <tr>
<td colspan=6 align=right><b>Total</b></td> <td colspan=7 align=right><b>Total</b></td>
<td>$<?php echo $myamount ?></td> <td>
<?php echo dPgetConfig('currency_symbol'); ?>&nbsp;
<?php echo $myamount ?>
</td>
</tr> </tr>
</table> </table>
...@@ -401,6 +425,7 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -401,6 +425,7 @@ for ($s=0; $s < count($tasks); $s++) {
<input type="hidden" name="invoice_project" value="<?php echo $project_id;?>" /> <input type="hidden" name="invoice_project" value="<?php echo $project_id;?>" />
<input type="hidden" name="project_id" value="<?php echo $project_id;?>" /> <input type="hidden" name="project_id" value="<?php echo $project_id;?>" />
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id;?>" /> <input type="hidden" name="invoice_id" value="<?php echo $invoice_id;?>" />
<input type="hidden" name="tag" value="<?php echo $invoice_tag;?>" />
<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;?>" />
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Start Date');?> <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Start Date');?>
...@@ -428,6 +453,7 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -428,6 +453,7 @@ for ($s=0; $s < count($tasks); $s++) {
<input type="hidden" name="invoice_project" value="<?php echo $project_id;?>" /> <input type="hidden" name="invoice_project" value="<?php echo $project_id;?>" />
<input type="hidden" name="project_id" value="<?php echo $project_id;?>" /> <input type="hidden" name="project_id" value="<?php echo $project_id;?>" />
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id;?>" /> <input type="hidden" name="invoice_id" value="<?php echo $invoice_id;?>" />
<input type="hidden" name="tag" value="<?php echo $invoice_tag;?>" />
<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;?>" />
<tr> <tr>
...@@ -462,6 +488,7 @@ if (isset($_POST['start_date'])) ...@@ -462,6 +488,7 @@ if (isset($_POST['start_date']))
</tr> </tr>
<form name="editFrm" action="./index.php?m=invoice" method="post"> <form name="editFrm" action="./index.php?m=invoice" method="post">
<input type="hidden" name="dosql" value="do_invoice_aed" /> <input type="hidden" name="dosql" value="do_invoice_aed" />
<input type="hidden" name="tag" value="<?php echo $invoice_tag;?>" />
<input type="hidden" name="invoice_project" value="<?php echo $project_id;?>" /> <input type="hidden" name="invoice_project" value="<?php echo $project_id;?>" />
<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;?>" />
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
$del = isset($_POST['del']) ? $_POST['del'] : 0; $del = isset($_POST['del']) ? $_POST['del'] : 0;
$stat = isset($_POST['stat']) ? $_POST['stat'] : -1; $stat = isset($_POST['stat']) ? $_POST['stat'] : -1;
$tag = isset($_POST['tag']) ? $_POST['tag'] : -1;
$obj = new CInvoice(); $obj = new CInvoice();
...@@ -26,6 +26,11 @@ if ($del) { ...@@ -26,6 +26,11 @@ if ($del) {
} else { } else {
$AppUI->setMsg( $msg . "updated", UI_MSG_OK, true ); $AppUI->setMsg( $msg . "updated", UI_MSG_OK, true );
} }
if (($msg = $obj->change_invoice_tag($tag))) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
} else {
$AppUI->setMsg( $msg . "updated", UI_MSG_OK, true );
}
$AppUI->redirect("m=invoice&a=addedit&invoice_id=".$obj->task_invoice."&project_id=".$obj->_invoice_project); $AppUI->redirect("m=invoice&a=addedit&invoice_id=".$obj->task_invoice."&project_id=".$obj->_invoice_project);
} else { } else {
while(list($key,$value)=each($_POST)) { while(list($key,$value)=each($_POST)) {
......
...@@ -16,6 +16,7 @@ $active = intval( !$AppUI->getState( 'InvoiceIdxTab' ) ); ...@@ -16,6 +16,7 @@ $active = intval( !$AppUI->getState( 'InvoiceIdxTab' ) );
$q = new DBQuery; $q = new DBQuery;
$q->addQuery(' $q->addQuery('
invoice_id, invoice_id,
invoice_tag,
invoice_project, invoice_project,
invoice_status, invoice_status,
invoice_date, invoice_date,
......
...@@ -40,9 +40,7 @@ class CInvoice extends CDpObject { ...@@ -40,9 +40,7 @@ class CInvoice extends CDpObject {
$msg = $this->check(); $msg = $this->check();
$q = new DBQuery; $q = new DBQuery;
$q->addTable('invoice_task_queue'); $q->addTable('invoice_task_queue');
$q->addInsert('task_invoice,task_amount,task_log_id', $q->addInsert('task_invoice,task_amount,task_log_id', $this->task_invoice.','.$this->task_amount.','.$this->task_log_id, true);
$this->task_invoice.','.$this->task_amount.','.$this->task_log_id,
true);
$q->exec(); $q->exec();
//db_insertObject('invoice_task_queue',$this,'task_queue_id'); //db_insertObject('invoice_task_queue',$this,'task_queue_id');
...@@ -104,4 +102,14 @@ class CInvoice extends CDpObject { ...@@ -104,4 +102,14 @@ class CInvoice extends CDpObject {
$q->addWhere('invoice_id = ' . $this->task_invoice); $q->addWhere('invoice_id = ' . $this->task_invoice);
$q->exec(); $q->exec();
} }
function change_invoice_tag($tag)
{
$this->_action='updated';
$q = new DBQuery;
$q->addTable('invoice');
$q->addUpdate('invoice_tag', $tag);
$q->addWhere('invoice_id = ' . $this->task_invoice);
$q->exec();
}
} }
...@@ -15,6 +15,7 @@ $tab = $AppUI->getState( 'ProjVwTab' ) !== NULL ? $AppUI->getState( 'ProjVwTab' ...@@ -15,6 +15,7 @@ $tab = $AppUI->getState( 'ProjVwTab' ) !== NULL ? $AppUI->getState( 'ProjVwTab'
$q = new DBQuery; $q = new DBQuery;
$q->addQuery(' $q->addQuery('
invoice_id, invoice_id,
invoice_tag,
invoice_project, invoice_project,
invoice_status, invoice_status,
invoice_date, invoice_date,
...@@ -73,6 +74,7 @@ $q->addWhere('user_id = ' . $a['invoice_creator']); ...@@ -73,6 +74,7 @@ $q->addWhere('user_id = ' . $a['invoice_creator']);
// name link // name link
$alt = htmlspecialchars( $a["invoice_id"] ); $alt = htmlspecialchars( $a["invoice_id"] );
$s .= '<td align=right>&nbsp;<a href="./index.php?m=invoice&a=view&invoice_id='.$a["invoice_id"].'&project_id='.$project_id.'" title="' . $alt . '"># ' . $a["invoice_id"] . '</a></td>'; $s .= '<td align=right>&nbsp;<a href="./index.php?m=invoice&a=view&invoice_id='.$a["invoice_id"].'&project_id='.$project_id.'" title="' . $alt . '"># ' . $a["invoice_id"] . '</a></td>';
$s .= '<td align=right>&nbsp;<a href="./index.php?m=invoice&a=view&invoice_id='.$a["invoice_id"].'&project_id='.$project_id.'" title="' . $alt . '">' . $a["invoice_tag"] . '</a></td>';
// task owner // task owner
$s .= '<td nowrap="nowrap" align=center>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td>'; $s .= '<td nowrap="nowrap" align=center>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td>';
// start date // start date
...@@ -98,6 +100,7 @@ if ($perms->checkModule('invoice', 'add')) ...@@ -98,6 +100,7 @@ if ($perms->checkModule('invoice', 'add'))
<tr> <tr>
<th width="10">&nbsp;</th> <th width="10">&nbsp;</th>
<th width="250"><?php echo $AppUI->_('Invoice Number');?></th> <th width="250"><?php echo $AppUI->_('Invoice Number');?></th>
<th width="250"><?php echo $AppUI->_('Invoice Tag');?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Invoice Creator');?></th> <th nowrap="nowrap"><?php echo $AppUI->_('Invoice Creator');?></th>
<th width="100" nowrap="nowrap"><?php echo $AppUI->_('Creation Date');?></th> <th width="100" nowrap="nowrap"><?php echo $AppUI->_('Creation Date');?></th>
<th width="100" nowrap="nowrap"><?php echo $AppUI->_('Invoive Status');?></th> <th width="100" nowrap="nowrap"><?php echo $AppUI->_('Invoive Status');?></th>
......
...@@ -29,6 +29,7 @@ class CSetupInvoice{ ...@@ -29,6 +29,7 @@ class CSetupInvoice{
function install() { function install() {
$sql = "( $sql = "(
`invoice_id` bigint(20) NOT NULL auto_increment, `invoice_id` bigint(20) NOT NULL auto_increment,
`invoice_tag` char(10) NOT NULL unique,
`invoice_project` int(11) NOT NULL default '0', `invoice_project` int(11) NOT NULL default '0',
`invoice_status` int(4) NOT NULL default '0', `invoice_status` int(4) NOT NULL default '0',
`invoice_date` int(11) NOT NULL default '0', `invoice_date` int(11) NOT NULL default '0',
......
...@@ -172,7 +172,7 @@ if ($a["task_amount"] == "0") { ...@@ -172,7 +172,7 @@ if ($a["task_amount"] == "0") {
$s .= '<td nowrap="nowrap" align=center>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td>'; $s .= '<td nowrap="nowrap" align=center>'.$username["contact_first_name"].' '.$username["contact_last_name"].'</td>';
$s .= '<td nowrap="nowrap" align=center>'.$tasks["task_log_hours"].'</td>'; $s .= '<td nowrap="nowrap" align=center>'.$tasks["task_log_hours"].'</td>';
$s .= '<td nowrap="nowrap"> '.$costdesc.'</td>'; $s .= '<td nowrap="nowrap"> '.$costdesc.'</td>';
$s .= '<td nowrap="nowrap">'.dPgetConfig('currency_symbol').$amount.'</td>'; $s .= '<td nowrap="nowrap">'.dPgetConfig('currency_symbol').'&nbsp;'.$amount.'</td>';
$s .= '</tr>'; $s .= '</tr>';
$s .= '<tr>'; $s .= '<tr>';
$s .= '<td colspan="1">&nbsp;</td>'; $s .= '<td colspan="1">&nbsp;</td>';
...@@ -243,7 +243,7 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -243,7 +243,7 @@ for ($s=0; $s < count($tasks); $s++) {
if (!empty($bcodes)) if (!empty($bcodes))
foreach ($bcodes as $code=>$rate) foreach ($bcodes as $code=>$rate)
$temp[] = sprintf("%.2f", round($hours[strtolower($code)] - $tmp[strtolower($code)], 2)); $temp[] = sprintf("%.2f", round($hours[strtolower($code)] - $tmp[strtolower($code)], 2));
$temp[] = dPgetConfig('currency_symbol') . sprintf("%.2f", round($amount_fixed - $tmpfix, 2)); $temp[] = dPgetConfig('currency_symbol') . sprintf(" %.2f", round($amount_fixed - $tmpfix, 2));
$pdfdata2t[] = array_merge($tmppdfdata2, $temp); $pdfdata2t[] = array_merge($tmppdfdata2, $temp);
} }
...@@ -293,7 +293,11 @@ $tasks=db_fetch_assoc($tmptasks); ...@@ -293,7 +293,11 @@ $tasks=db_fetch_assoc($tmptasks);
?> ?>
<tr> <tr>
<td colspan=5 align=right><b>Total</b></td> <td colspan=5 align=right><b>Total</b></td>
<td>$<?php echo $myamount ?></td> <td>
<?php echo dPgetConfig('currency_symbol'); ?>
&nbsp;
<?php echo $myamount ?>
</td>
</tr> </tr>
</table> </table>
......
...@@ -10,6 +10,9 @@ $df = $AppUI->getPref('SHDATEFORMAT'); ...@@ -10,6 +10,9 @@ $df = $AppUI->getPref('SHDATEFORMAT');
<th nowrap="nowrap"> <th nowrap="nowrap">
<a href="?m=invoice&orderby=invoice_id" class="hdr"><?php echo $AppUI->_('Invoice Number');?></a> <a href="?m=invoice&orderby=invoice_id" class="hdr"><?php echo $AppUI->_('Invoice Number');?></a>
</th> </th>
<th nowrap="nowrap">
<a href="?m=invoice&orderby=invoice_tag" class="hdr"><?php echo $AppUI->_('Invoice Tag');?></a>
</th>
<th nowrap="nowrap"> <th nowrap="nowrap">
<a href="?m=invoice&orderby=invoice_project" class="hdr"><?php echo $AppUI->_('Project');?></a> <a href="?m=invoice&orderby=invoice_project" class="hdr"><?php echo $AppUI->_('Project');?></a>
</th> </th>
...@@ -62,22 +65,23 @@ foreach ($invoices as $row) ...@@ -62,22 +65,23 @@ foreach ($invoices as $row)
$s .= '<a href="?m=invoice&a=addedit&invoice_id=' . $row['invoice_id'] . '&project_id=' . $row['invoice_project'] . '"><img src="./images/icons/pencil.gif" alt="'.$AppUI->_( 'Edit Invoice' ).'" border="0" width="12" height="12"></a>'; $s .= '<a href="?m=invoice&a=addedit&invoice_id=' . $row['invoice_id'] . '&project_id=' . $row['invoice_project'] . '"><img src="./images/icons/pencil.gif" alt="'.$AppUI->_( 'Edit Invoice' ).'" border="0" width="12" height="12"></a>';
$s .= '&nbsp; </td>'; $s .= '&nbsp; </td>';
$s .= $CR . '<td nowrap="nowrap" width=100><a href="?m=invoice&a=view&project_id=' . $row["invoice_project"] . '&invoice_id=' . $row["invoice_id"] .'">#' . $row["invoice_id"] . '</a></td>'; $s .= $CR . '<td nowrap="nowrap" width=100><a href="?m=invoice&a=view&project_id=' . $row["invoice_project"] . '&invoice_id=' . $row["invoice_id"] .'">#' . $row["invoice_id"] . '</a></td>';
$s .= $CR . '<td nowrap="nowrap" width=100><a href="?m=invoice&a=view&project_id=' . $row["invoice_project"] . '&invoice_id=' . $row["invoice_id"] .'">' . $row["invoice_tag"] . '</a></td>';
$s .= $CR . '<td width=500>'; $s .= $CR . '<td width=500>';
$s .= $CT . '<a href="?m=projects&a=view&project_id=' . $row["invoice_project"] . '" title="' . $myproject_name[0]["project_description"] . '">' . $myproject_name[0]["project_name"] . '</a>'; $s .= $CT . '<a href="?m=projects&a=view&project_id=' . $row["invoice_project"] . '" title="' . $myproject_name[0]["project_description"] . '">' . $myproject_name[0]["project_name"] . '</a>';
$s .= $CR . '</td>'; $s .= $CR . '</td>';
$s .= $CR . '<td nowrap="nowrap">' .$myuser_name[0]["contact_first_name"]. ' '.$myuser_name[0]["contact_last_name"]. '</td>'; $s .= $CR . '<td nowrap="nowrap">' .$myuser_name[0]["contact_first_name"]. ' '.$myuser_name[0]["contact_last_name"]. '</td>';
$s .= $CR . '<td nowrap="nowrap">' .$mydate. '</td>'; $s .= $CR . '<td nowrap="nowrap">' .$mydate. '</td>';
$s .= $CR . '<td nowrap="nowrap">'.dPgetConfig('currency_symbol') .$total_amount. '</td>'; $s .= $CR . '<td nowrap="nowrap">'.dPgetConfig('currency_symbol').'&nbsp;'.$total_amount. '</td>';
$s .= $CR . '</tr>'; $s .= $CR . '</tr>';
echo $s; echo $s;
} }
} }
if ($none) { if ($none) {
echo $CR . '<tr><td colspan="6">' . $AppUI->_( 'No open invoice available' ) . '</td></tr>'; echo $CR . '<tr><td colspan="7">' . $AppUI->_( 'No open invoice available' ) . '</td></tr>';
} }
?> ?>
<tr> <tr>
<td colspan="6">&nbsp;</td> <td colspan="7">&nbsp;</td>
</tr> </tr>
</table> </table>
<?php <?php
......
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