Commit abc65b0f authored by Jean-Paul Saman's avatar Jean-Paul Saman

Port to web2project

parent 433881e8
<?php /* PROJECTS $Id: addedit.php,v 1.56 2003/09/11 02:47:22 gregorerhardt Exp $ */ <?php /* PROJECTS $Id: addedit.php,v 1.56 2003/09/11 02:47:22 gregorerhardt Exp $ */
$invoice_id = intval( dPgetParam( $_REQUEST, "invoice_id", 0 ) ); if (!defined('W2P_BASE_DIR')) {
$project_id = intval( dPgetParam( $_REQUEST, "project_id", 0 ) ); die('You should not access this file directly.');
}
$invoice_id = intval( w2PgetParam( $_REQUEST, "invoice_id", 0 ) );
$project_id = intval( w2PgetParam( $_REQUEST, "project_id", 0 ) );
// check permissions for this record // check permissions for this record
// Done automatically in index.php // Done automatically in index.php
...@@ -12,14 +16,14 @@ if (!$canEdit) { ...@@ -12,14 +16,14 @@ if (!$canEdit) {
// format dates // format dates
$df = $AppUI->getPref('SHDATEFORMAT'); $df = $AppUI->getPref('SHDATEFORMAT');
$start_date = new CDate( $row->project_start_date ); $start_date = new w2p_Utilities_Date( $row->project_start_date );
$end_date = intval( $row->project_end_date ) ? new CDate( $row->project_end_date ) : null; $end_date = intval( $row->project_end_date ) ? new w2p_Utilities_Date( $row->project_end_date ) : null;
$actual_end_date = intval( $row->project_actual_end_date ) ? new CDate( $row->project_actual_end_date ) : null; $actual_end_date = intval( $row->project_actual_end_date ) ? new w2p_Utilities_Date( $row->project_actual_end_date ) : null;
// setup the title block // setup the title block
$ttl = $invoice_id > 0 ? "Edit Invoice" : "New Invoice"; $ttl = $invoice_id > 0 ? "Edit Invoice" : "New Invoice";
$titleBlock = new CTitleBlock( $ttl, 'applet3-48.png', $m, "$m.$a" ); $titleBlock = new w2p_Theme_TitleBlock( $ttl, 'applet3-48.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=projects", "projects list" ); $titleBlock->addCrumb( "?m=projects", "projects list" );
if ($project_id != 0) if ($project_id != 0)
$titleBlock->addCrumb( "?m=projects&a=view&project_id=$project_id", "view this project" ); $titleBlock->addCrumb( "?m=projects&a=view&project_id=$project_id", "view this project" );
...@@ -31,7 +35,7 @@ if($task_id == '') { ...@@ -31,7 +35,7 @@ if($task_id == '') {
$task_id=0; $task_id=0;
} }
$q = new DBQuery; $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');
$temp_billed = db_loadColumn($q->prepare()); $temp_billed = db_loadColumn($q->prepare());
...@@ -74,13 +78,13 @@ $q->addWhere('project_id = ' . $project_id); ...@@ -74,13 +78,13 @@ $q->addWhere('project_id = ' . $project_id);
if (!empty($_POST["start_date"])) { if (!empty($_POST["start_date"])) {
$actual_start_date=strtotime($_REQUEST["start_date"]); $actual_start_date=strtotime($_REQUEST["start_date"]);
$start_date=new CDate($actual_start_date); $start_date=new w2p_Utilities_Date($actual_start_date);
$q->addWhere('task_log_date > \'' . $_REQUEST['inv_start_date'] . "'"); $q->addWhere('task_log_date > \'' . $_REQUEST['inv_start_date'] . "'");
} }
if (!empty($_POST['end_date'])) if (!empty($_POST['end_date']))
{ {
$actual_end_date=strtotime($_REQUEST["end_date"]); $actual_end_date=strtotime($_REQUEST["end_date"]);
$end_date=new CDate($actual_end_date); $end_date=new w2p_Utilities_Date($actual_end_date);
$q->addWhere("task_log_date < '" . $_REQUEST['inv_end_date'] . "' "); $q->addWhere("task_log_date < '" . $_REQUEST['inv_end_date'] . "' ");
} }
if ($task_id != 0) if ($task_id != 0)
...@@ -146,7 +150,7 @@ function showtask(&$a) { ...@@ -146,7 +150,7 @@ function showtask(&$a) {
global $AppUI, $project_id, $billingcodes; global $AppUI, $project_id, $billingcodes;
$df = $AppUI->getPref( 'SHDATEFORMAT' ); $df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
task_log_id, task_log_id,
task_log_task, task_log_task,
...@@ -192,14 +196,14 @@ if ($a["task_amount"] == "0") { ...@@ -192,14 +196,14 @@ if ($a["task_amount"] == "0") {
$s = "\n<tr>"; $s = "\n<tr>";
$s .= '<td><a href="./index.php?m=tasks&a=view&task_id=' . $tasks["task_log_task"] . '"><img src="./images/icons/pencil.gif" border="0" alt="Edit"></a></td>'; $s .= '<td><a href="./index.php?m=tasks&a=view&task_id=' . $tasks["task_log_task"] . '"><img src="./images/icons/pencil.gif" border="0" alt="Edit"></a></td>';
$s .= "<td><a href=\"javascript:delIt2({$a['task_queue_id']});\" title=\"".$AppUI->_('delete')."\"><img src=\"./images/icons/stock_delete-16.png\" border=\"0\" alt=\"Delete\"></a></td>"; $s .= "<td><a href=\"javascript:delIt2({$a['task_queue_id']});\" title=\"".$AppUI->_('delete')."\"><img src=\"./images/icons/stock_delete-16.png\" border=\"0\" alt=\"Delete\"></a></td>";
$tdate = new CDate($tasks['task_log_date']); $tdate = new w2p_Utilities_Date($tasks['task_log_date']);
$s .= '<td nowrap align="center">' . $tdate->format($df) . '</td>'; $s .= '<td nowrap align="center">' . $tdate->format($df) . '</td>';
$alt = htmlspecialchars( $tasks["task_log_name"] ); $alt = htmlspecialchars( $tasks["task_log_name"] );
$s .= '<td align=left>&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $tasks["task_log_task"] . '" title="' . $alt . '">' . $tasks["task_log_name"] . '</a></td>'; $s .= '<td align=left>&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $tasks["task_log_task"] . '" title="' . $alt . '">' . $tasks["task_log_name"] . '</a></td>';
$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') . '&nbsp;' . $amount.'</td>'; $s .= '<td nowrap="nowarap">' . w2PgetConfig('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>';
...@@ -216,7 +220,7 @@ function showtasklog(&$a) { ...@@ -216,7 +220,7 @@ function showtasklog(&$a) {
global $AppUI, $project_id; global $AppUI, $project_id;
$df = $AppUI->getPref( 'SHDATEFORMAT' ); $df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
contact_first_name, contact_first_name,
contact_last_name'); contact_last_name');
...@@ -235,7 +239,7 @@ $q->addWhere('task_log_id = ' . $a['task_log_id']); ...@@ -235,7 +239,7 @@ $q->addWhere('task_log_id = ' . $a['task_log_id']);
$tmpcheck=$q->exec(); $tmpcheck=$q->exec();
$check=db_fetch_assoc($tmpcheck); $check=db_fetch_assoc($tmpcheck);
$date = new CDate($a['task_log_date']); $date = new w2p_Utilities_Date($a['task_log_date']);
$s=' $s='
<tr valign="top"> <tr valign="top">
<td><input type="checkbox" name="num_'.$a["task_log_id"].'"></td> <td><input type="checkbox" name="num_'.$a["task_log_id"].'"></td>
...@@ -245,7 +249,7 @@ $date = new CDate($a['task_log_date']); ...@@ -245,7 +249,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">'.dPgetConfig('currency_symbol').'&nbsp; <input type="text" name="fixed_'.$a['task_log_id'].'" size="6"> <td align="right" nowrap="nowrap">'.w2PgetConfig('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']) == '')
...@@ -413,7 +417,7 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -413,7 +417,7 @@ for ($s=0; $s < count($tasks); $s++) {
<tr> <tr>
<td colspan=7 align=right><b>Total</b></td> <td colspan=7 align=right><b>Total</b></td>
<td> <td>
<?php echo dPgetConfig('currency_symbol'); ?>&nbsp; <?php echo w2PgetConfig('currency_symbol'); ?>&nbsp;
<?php echo $myamount ?> <?php echo $myamount ?>
</td> </td>
</tr> </tr>
...@@ -503,4 +507,4 @@ if (isset($_POST['start_date'])) ...@@ -503,4 +507,4 @@ if (isset($_POST['start_date']))
</form> </form>
</table> </table>
* <?php echo $AppUI->_('requiredField');?> <?php echo $AppUI->_('requiredField');?>
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
$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; $tag = isset($_POST['tag']) ? $_POST['tag'] : -1;
$obj = new CInvoice(); $obj = new CInvoice();
if (!$obj->bind( $_POST )) { if (!$obj->bind( $_POST )) {
$AppUI->setMsg( $obj->getError(), UI_MSG_ERROR ); $AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
$AppUI->redirect(); $AppUI->redirect();
...@@ -25,9 +27,9 @@ if ($del) { ...@@ -25,9 +27,9 @@ if ($del) {
$AppUI->setMsg( $msg, UI_MSG_ERROR ); $AppUI->setMsg( $msg, UI_MSG_ERROR );
} 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))) { if (($msg = $obj->change_invoice_tag($tag))) {
$AppUI->setMsg( $msg, UI_MSG_ERROR ); $AppUI->setMsg( $msg, UI_MSG_ERROR );
} else { } else {
$AppUI->setMsg( $msg . "updated", UI_MSG_OK, true ); $AppUI->setMsg( $msg . "updated", UI_MSG_OK, true );
} }
...@@ -46,6 +48,4 @@ if ($del) { ...@@ -46,6 +48,4 @@ if ($del) {
$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);
} }
?> ?>
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
//$AppUI->savePlace(); //$AppUI->savePlace();
if (isset( $_GET['project_id'] )) { if (isset( $_GET['project_id'] )) {
...@@ -13,9 +17,9 @@ if (isset( $_GET['tab'] )) { ...@@ -13,9 +17,9 @@ if (isset( $_GET['tab'] )) {
$tab = $AppUI->getState( 'InvoiceIdxTab' ) !== NULL ? $AppUI->getState( 'InvoiceIdxTab' ) : 1; $tab = $AppUI->getState( 'InvoiceIdxTab' ) !== NULL ? $AppUI->getState( 'InvoiceIdxTab' ) : 1;
$active = intval( !$AppUI->getState( 'InvoiceIdxTab' ) ); $active = intval( !$AppUI->getState( 'InvoiceIdxTab' ) );
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
invoice_id, invoice_id,
invoice_tag, invoice_tag,
invoice_project, invoice_project,
invoice_status, invoice_status,
...@@ -26,7 +30,7 @@ $q->addTable('invoice'); ...@@ -26,7 +30,7 @@ $q->addTable('invoice');
$invoices = $q->loadList(); $invoices = $q->loadList();
// setup the title block // setup the title block
$titleBlock = new CTitleBlock( 'Invoice', 'applet3-48.png', $m, "$m.$a" ); $titleBlock = new w2p_Theme_TitleBlock( 'Invoice', 'applet3-48.png', $m, "$m.$a" );
$titleBlock->addCell(); $titleBlock->addCell();
if ($canEdit && $project_id) { if ($canEdit && $project_id) {
$titleBlock->addCell( $titleBlock->addCell(
...@@ -41,11 +45,11 @@ $titleBlock->show(); ...@@ -41,11 +45,11 @@ $titleBlock->show();
// include("{$AppUI->cfg['root_dir']}/modules/invoice/index.php"); // include("{$AppUI->cfg['root_dir']}/modules/invoice/index.php");
// tabbed information boxes // tabbed information boxes
$tabBox = new CTabBox( "?m=invoice", dPgetConfig('root_dir') . '/modules/invoice/', $tab ); $tabBox = new CTabBox( "?m=$m", W2P_BASE_DIR . "/modules/$m/", $tab );
$tabBox->add( "vw_open", 'Invoices (Open)' ); $tabBox->add( "vw_open", 'Invoices (Open)' );
$tabBox->add( "vw_pend", 'Invoices (Pending)' ); $tabBox->add( "vw_pend", 'Invoices (Pending)' );
$tabBox->add( "vw_paid", 'Invoices (Paid)' ); $tabBox->add( "vw_paid", 'Invoices (Paid)' );
$tabBox->add( "vw_loss", 'Invoices (Loss)' ); $tabBox->add( "vw_loss", 'Invoices (Loss)' );
$tabBox->show(); $tabBox->show();
?> ?>
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
require_once( $AppUI->getSystemClass( 'libmail' ) ); //require_once( $AppUI->getSystemClass( 'libmail' ) );
require_once( $AppUI->getSystemClass( 'dp' ) ); //require_once( $AppUI->getSystemClass( 'w2p' ) );
class CInvoice extends CDpObject { class CInvoice extends w2p_Core_BaseObject {
var $invoice_task_queue_id = NULL; var $invoice_task_queue_id = NULL;
var $task_invoice = NULL; var $task_invoice = NULL;
...@@ -11,7 +14,7 @@ class CInvoice extends CDpObject { ...@@ -11,7 +14,7 @@ class CInvoice extends CDpObject {
var $task_amount = NULL; var $task_amount = NULL;
function CInvoice() { function CInvoice() {
$this->CDpObject( 'invoice_task_queue', 'task_invoice' ); $this->w2pObject( 'invoice_task_queue', 'task_invoice' );
$this->_invoice_project=$_POST["invoice_project"]; $this->_invoice_project=$_POST["invoice_project"];
$this->_task_queue_id=$_POST["task_queue_id"]; $this->_task_queue_id=$_POST["task_queue_id"];
} }
...@@ -26,7 +29,7 @@ class CInvoice extends CDpObject { ...@@ -26,7 +29,7 @@ class CInvoice extends CDpObject {
} }
function init() { function init() {
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addTable('invoice'); $q->addTable('invoice');
$q->addInsert('invoice_project,invoice_date,invoice_creator', $_POST['invoice_project'].','.time().','.$_POST['project_creator'], true);; $q->addInsert('invoice_project,invoice_date,invoice_creator', $_POST['invoice_project'].','.time().','.$_POST['project_creator'], true);;
$q->exec(); $q->exec();
...@@ -38,7 +41,7 @@ class CInvoice extends CDpObject { ...@@ -38,7 +41,7 @@ class CInvoice extends CDpObject {
function store() { function store() {
$msg = $this->check(); $msg = $this->check();
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addTable('invoice_task_queue'); $q->addTable('invoice_task_queue');
$q->addInsert('task_invoice,task_amount,task_log_id', $this->task_invoice.','.$this->task_amount.','.$this->task_log_id, true); $q->addInsert('task_invoice,task_amount,task_log_id', $this->task_invoice.','.$this->task_amount.','.$this->task_log_id, true);
$q->exec(); $q->exec();
...@@ -49,7 +52,7 @@ class CInvoice extends CDpObject { ...@@ -49,7 +52,7 @@ class CInvoice extends CDpObject {
function delete() function delete()
{ {
$this->_action='deleted'; $this->_action='deleted';
$q = new DBQuery(); $q = new w2p_Database_Query();
$q->setDelete('invoice_task_queue'); $q->setDelete('invoice_task_queue');
$q->addWhere('task_queue_id = ' . $this->_task_queue_id); $q->addWhere('task_queue_id = ' . $this->_task_queue_id);
if (!$q->exec()) if (!$q->exec())
...@@ -61,7 +64,7 @@ class CInvoice extends CDpObject { ...@@ -61,7 +64,7 @@ class CInvoice extends CDpObject {
function purge() function purge()
{ {
$this->_action='purged'; $this->_action='purged';
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery('invoice_status'); $q->addQuery('invoice_status');
$q->addTable('invoice'); $q->addTable('invoice');
$q->addWhere('invoice_id = ' . $this->task_invoice); $q->addWhere('invoice_id = ' . $this->task_invoice);
...@@ -96,7 +99,7 @@ class CInvoice extends CDpObject { ...@@ -96,7 +99,7 @@ class CInvoice extends CDpObject {
function change_status($stat) function change_status($stat)
{ {
$this->_action='updated'; $this->_action='updated';
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addTable('invoice'); $q->addTable('invoice');
$q->addUpdate('invoice_status', $stat); $q->addUpdate('invoice_status', $stat);
$q->addWhere('invoice_id = ' . $this->task_invoice); $q->addWhere('invoice_id = ' . $this->task_invoice);
...@@ -106,7 +109,7 @@ class CInvoice extends CDpObject { ...@@ -106,7 +109,7 @@ class CInvoice extends CDpObject {
function change_invoice_tag($tag) function change_invoice_tag($tag)
{ {
$this->_action='updated'; $this->_action='updated';
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addTable('invoice'); $q->addTable('invoice');
$q->addUpdate('invoice_tag', $tag); $q->addUpdate('invoice_tag', $tag);
$q->addWhere('invoice_id = ' . $this->task_invoice); $q->addWhere('invoice_id = ' . $this->task_invoice);
......
<?php <?php
$project_id = intval( dPgetParam( $_GET, "project_id", 0 ) ); if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
$project_id = intval( w2PgetParam( $_GET, "project_id", 0 ) );
$perms =& $AppUI->acl(); $perms =& $AppUI->acl();
if (!$perms->checkModuleItem('invoice', 'view', $project_id)) { if (!$perms->checkModuleItem('invoice', 'view', $project_id)) {
...@@ -12,9 +16,9 @@ if (isset( $_GET['tab'] )) { ...@@ -12,9 +16,9 @@ if (isset( $_GET['tab'] )) {
} }
$tab = $AppUI->getState( 'ProjVwTab' ) !== NULL ? $AppUI->getState( 'ProjVwTab' ) : 0; $tab = $AppUI->getState( 'ProjVwTab' ) !== NULL ? $AppUI->getState( 'ProjVwTab' ) : 0;
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
invoice_id, invoice_id,
invoice_tag, invoice_tag,
invoice_project, invoice_project,
invoice_status, invoice_status,
...@@ -46,13 +50,13 @@ function showtask_inv( &$a, $level=0 ) { ...@@ -46,13 +50,13 @@ function showtask_inv( &$a, $level=0 ) {
$invoice_status="Pending"; $invoice_status="Pending";
}elseif ($a["invouce_status"] == "2") { }elseif ($a["invouce_status"] == "2") {
$invoice_status="Paid"; $invoice_status="Paid";
}elseif ($a["invouce_status"] == "3") {^M }elseif ($a["invouce_status"] == "3") {^M
$invoice_status="Loss"; $invoice_status="Loss";
} }
$start_date=strftime($df,$a["invoice_date"]); $start_date=strftime($df,$a["invoice_date"]);
// edit query FROM users; user_first_name and user_last_name // edit query FROM users; user_first_name and user_last_name
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
contact_first_name, contact_first_name,
contact_last_name'); contact_last_name');
...@@ -75,7 +79,7 @@ $q->addWhere('user_id = ' . $a['invoice_creator']); ...@@ -75,7 +79,7 @@ $q->addWhere('user_id = ' . $a['invoice_creator']);
$s .= "\n\t</td>"; $s .= "\n\t</td>";
// 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>'; $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>';
...@@ -102,7 +106,7 @@ if ($perms->checkModule('invoice', 'add')) ...@@ -102,7 +106,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 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>
......
<?php /* PROJECTS $Id: reports.php,v 1.12 2005/04/15 11:27:50 cyberhorse Exp $ */ <?php /* PROJECTS $Id: reports.php,v 1.12 2005/04/15 11:27:50 cyberhorse Exp $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
error_reporting( E_ALL ); error_reporting( E_ALL );
$project_id = intval( dPgetParam( $_REQUEST, "project_id", 0 ) ); $project_id = intval( w2PgetParam( $_REQUEST, "project_id", 0 ) );
$report_type = dPgetParam( $_REQUEST, "report_type", '' ); $report_type = w2PgetParam( $_REQUEST, "report_type", '' );
$reports = $AppUI->readFiles( dPgetConfig( 'root_dir' )."/modules/invoice/reports", "\.php$" ); $reports = $AppUI->readFiles( w2PgetConfig( 'root_dir' )."/modules/invoice/reports", "\.php$" );
// $report_type_var = dPgetParam($_GET, 'report_type', ''); // $report_type_var = w2PgetParam($_GET, 'report_type', '');
if (!empty($report_type_var)) if (!empty($report_type_var))
$report_type_var = '&report_type=' . $report_type; $report_type_var = '&report_type=' . $report_type;
......
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
error_reporting(!E_ALL); error_reporting(!E_ALL);
$project_id = intval( dPgetParam( $_GET, "project_id", 0 ) ); $project_id = intval( w2PgetParam( $_GET, "project_id", 0 ) );
$invoice_id = intval( dPgetParam( $_GET, "invoice_id", 0 ) ); $invoice_id = intval( w2PgetParam( $_GET, "invoice_id", 0 ) );
$invoice_to = intval( dPgetParam( $_GET, "invoice_to", 0 ) ); $invoice_to = intval( w2PgetParam( $_GET, "invoice_to", 0 ) );
$tasks = intval( dPgetParam( $_GET, "tasks", 0 ) ); $tasks = intval( w2PgetParam( $_GET, "tasks", 0 ) );
$invTitlePos = 650; // up/down where to begin printing theINVOICE header $invTitlePos = 650; // up/down where to begin printing theINVOICE header
$invToPos = 600; // up/down where to print the To: block $invToPos = 600; // up/down where to print the To: block
$invToInfoPos = 570; // up/down where to print the To: and Info data $invToInfoPos = 570; // up/down where to print the To: and Info data
$df = $AppUI->getPref('SHDATEFORMAT'); $df = $AppUI->getPref('SHDATEFORMAT');
$font_dir = dPgetConfig( 'root_dir' )."/lib/ezpdf/fonts"; $font_dir = w2PgetConfig( 'root_dir' )."/lib/ezpdf/fonts";
$temp_dir = dPgetConfig( 'root_dir' )."/files/temp"; $temp_dir = w2PgetConfig( 'root_dir' )."/files/temp";
$base_url = dPgetConfig( 'base_url' ); $base_url = w2PgetConfig( 'base_url' );
require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) ); require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) );
...@@ -113,7 +116,7 @@ $leftIndent = $leftOffset + 15; // how far to indent the text UNDER "Inv ...@@ -113,7 +116,7 @@ $leftIndent = $leftOffset + 15; // how far to indent the text UNDER "Inv
// //
// query the database for the invoiced company address // query the database for the invoiced company address
// //
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
company_name, company_name,
company_address1, company_address1,
...@@ -169,7 +172,7 @@ $pdf->ezSetY( $invoiceInfo ); ...@@ -169,7 +172,7 @@ $pdf->ezSetY( $invoiceInfo );
// print invoice date // print invoice date
$xpos = $pdf->ezText( $invoice_id, $fontSize, array('aleft' => $aleftInfo )); $xpos = $pdf->ezText( $invoice_id, $fontSize, array('aleft' => $aleftInfo ));
$date = new CDate(); $date = new w2p_Utilities_Date();
$pdf->ezSetY( $xpos ); $pdf->ezSetY( $xpos );
$pdf->ezText( 'Invoice Date:', $fontSize, array('aleft' => $aleftText )); $pdf->ezText( 'Invoice Date:', $fontSize, array('aleft' => $aleftText ));
$pdf->ezSetY( $xpos ); $pdf->ezSetY( $xpos );
...@@ -193,7 +196,7 @@ $pdfheaders3 = array( ...@@ -193,7 +196,7 @@ $pdfheaders3 = array(
'Amount'); 'Amount');
//-- get some data //-- get some data
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery('task_amount'); $q->addQuery('task_amount');
$q->addQuery('invoice_task_queue.task_log_id'); $q->addQuery('invoice_task_queue.task_log_id');
$q->addQuery('task_log_description'); $q->addQuery('task_log_description');
...@@ -217,19 +220,19 @@ $invTotal = 0; ...@@ -217,19 +220,19 @@ $invTotal = 0;
$hoursTotal = 0; $hoursTotal = 0;
foreach ($pname as $inv) { foreach ($pname as $inv) {
$d = new CDate($inv['task_log_date']); $d = new w2p_Utilities_Date($inv['task_log_date']);
if ($inv['task_amount'] > 0) if ($inv['task_amount'] > 0)
$amt = $inv['task_amount']; $amt = $inv['task_amount'];
else else
$amt = round($inv['billingcode_value'] * $inv['task_log_hours'], 2); $amt = round($inv['billingcode_value'] * $inv['task_log_hours'], 2);
$dispAmt = dPgetConfig('currency_symbol') . sprintf("%.2f", $amt, 2); $dispAmt = w2PgetConfig('currency_symbol') . sprintf("%.2f", $amt, 2);
$invTotal = $invTotal + $amt; $invTotal = $invTotal + $amt;
$hoursTotal += $inv['task_log_hours']; $hoursTotal += $inv['task_log_hours'];
$pdfdata[] = array( $pdfdata[] = array(
$d->format($df), $d->format($df),
$inv['task_log_description'], $inv['task_log_description'],
(($inv['task_amount'] > 0)?'set':(dPgetConfig('currency_symbol').sprintf("%.2f",$inv['billingcode_value'], 2))), (($inv['task_amount'] > 0)?'set':(w2PgetConfig('currency_symbol').sprintf("%.2f",$inv['billingcode_value'], 2))),
sprintf("%.2f", $inv['task_log_hours'], 2), sprintf("%.2f", $inv['task_log_hours'], 2),
$dispAmt ); $dispAmt );
} }
...@@ -261,7 +264,7 @@ $pdf->ezText(''); ...@@ -261,7 +264,7 @@ $pdf->ezText('');
// print the invoice total // print the invoice total
$pdf->ezText("Total hours: " . sprintf("%.2f",$hoursTotal), 12, $pdf->ezText("Total hours: " . sprintf("%.2f",$hoursTotal), 12,
array('justification'=>'right')); array('justification'=>'right'));
$pdf->ezText("Invoice Total: " . dPgetConfig('currency_symbol').sprintf("%.2f",$invTotal,2), 12, $pdf->ezText("Invoice Total: " . w2PgetConfig('currency_symbol').sprintf("%.2f",$invTotal,2), 12,
array('justification'=>'right')); array('justification'=>'right'));
$options = array ( $options = array (
......
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
error_reporting(!E_ALL); error_reporting(!E_ALL);
$project_id = intval( dPgetParam( $_GET, "project_id", 0 ) ); $project_id = intval( w2PgetParam( $_GET, "project_id", 0 ) );
$invoice_id = intval( dPgetParam( $_GET, "invoice_id", 0 ) ); $invoice_id = intval( w2PgetParam( $_GET, "invoice_id", 0 ) );
$invoice_to = intval( dPgetParam( $_GET, "invoice_to", 0 ) ); $invoice_to = intval( w2PgetParam( $_GET, "invoice_to", 0 ) );
$tasks = intval( dPgetParam( $_GET, "tasks", 0 ) ); $tasks = intval( w2PgetParam( $_GET, "tasks", 0 ) );
$invTitlePos = 650; // up/down where to begin printing theINVOICE header $invTitlePos = 650; // up/down where to begin printing theINVOICE header
$invToPos = 600; // up/down where to print the To: block $invToPos = 600; // up/down where to print the To: block
$invToInfoPos = 570; // up/down where to print the To: and Info data $invToInfoPos = 570; // up/down where to print the To: and Info data
$df = $AppUI->getPref('SHDATEFORMAT'); $df = $AppUI->getPref('SHDATEFORMAT');
$font_dir = dPgetConfig( 'root_dir' )."/lib/ezpdf/fonts"; $font_dir = w2PgetConfig( 'root_dir' )."/lib/ezpdf/fonts";
$temp_dir = dPgetConfig( 'root_dir' )."/files/temp"; $temp_dir = w2PgetConfig( 'root_dir' )."/files/temp";
$base_url = dPgetConfig( 'base_url' ); $base_url = w2PgetConfig( 'base_url' );
require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) ); require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) );
...@@ -43,7 +46,7 @@ $textBColor = .3; ...@@ -43,7 +46,7 @@ $textBColor = .3;
// //
// query the database for company info // query the database for company info
// //
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
company_name, company_name,
company_address1, company_address1,
...@@ -113,7 +116,7 @@ $leftIndent = $leftOffset + 15; // how far to indent the text UNDER "Inv ...@@ -113,7 +116,7 @@ $leftIndent = $leftOffset + 15; // how far to indent the text UNDER "Inv
// //
// query the database for the invoiced company address // query the database for the invoiced company address
// //
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
company_name, company_name,
company_address1, company_address1,
...@@ -169,7 +172,7 @@ $pdf->ezSetY( $invoiceInfo ); ...@@ -169,7 +172,7 @@ $pdf->ezSetY( $invoiceInfo );
// print invoice date // print invoice date
$xpos = $pdf->ezText( $invoice_id, $fontSize, array('aleft' => $aleftInfo )); $xpos = $pdf->ezText( $invoice_id, $fontSize, array('aleft' => $aleftInfo ));
$date = new CDate(); $date = new w2p_Utilities_Date();
$pdf->ezSetY( $xpos ); $pdf->ezSetY( $xpos );
$pdf->ezText( 'Invoice Date:', $fontSize, array('aleft' => $aleftText )); $pdf->ezText( 'Invoice Date:', $fontSize, array('aleft' => $aleftText ));
$pdf->ezSetY( $xpos ); $pdf->ezSetY( $xpos );
...@@ -193,7 +196,7 @@ $pdfheaders3 = array( ...@@ -193,7 +196,7 @@ $pdfheaders3 = array(
'Amount'); 'Amount');
//-- get some data //-- get some data
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery('task_amount'); $q->addQuery('task_amount');
$q->addQuery('invoice_task_queue.task_log_id'); $q->addQuery('invoice_task_queue.task_log_id');
$q->addQuery('task_log_description'); $q->addQuery('task_log_description');
...@@ -217,19 +220,19 @@ $invTotal = 0; ...@@ -217,19 +220,19 @@ $invTotal = 0;
$hoursTotal = 0; $hoursTotal = 0;
foreach ($pname as $inv) { foreach ($pname as $inv) {
$d = new CDate($inv['task_log_date']); $d = new w2p_Utilities_Date($inv['task_log_date']);
if ($inv['task_amount'] > 0) if ($inv['task_amount'] > 0)
$amt = $inv['task_amount']; $amt = $inv['task_amount'];
else else
$amt = round($inv['billingcode_value'] * $inv['task_log_hours'], 2); $amt = round($inv['billingcode_value'] * $inv['task_log_hours'], 2);
$dispAmt = dPgetConfig('currency_symbol') . sprintf("%.2f", $amt, 2); $dispAmt = w2PgetConfig('currency_symbol') . sprintf("%.2f", $amt, 2);
$invTotal = $invTotal + $amt; $invTotal = $invTotal + $amt;
$hoursTotal += $inv['task_log_hours']; $hoursTotal += $inv['task_log_hours'];
$pdfdata[] = array( $pdfdata[] = array(
$d->format($df), $d->format($df),
$inv['task_log_description'], $inv['task_log_description'],
(($inv['task_amount'] > 0)?'set':(dPgetConfig('currency_symbol').sprintf("%.2f",$inv['billingcode_value'], 2))), (($inv['task_amount'] > 0)?'set':(w2PgetConfig('currency_symbol').sprintf("%.2f",$inv['billingcode_value'], 2))),
sprintf("%.2f", $inv['task_log_hours'], 2), sprintf("%.2f", $inv['task_log_hours'], 2),
$dispAmt ); $dispAmt );
} }
...@@ -261,7 +264,7 @@ $pdf->ezText(''); ...@@ -261,7 +264,7 @@ $pdf->ezText('');
// print the invoice total // print the invoice total
$pdf->ezText("Total hours: " . sprintf("%.2f",$hoursTotal), 12, $pdf->ezText("Total hours: " . sprintf("%.2f",$hoursTotal), 12,
array('justification'=>'right')); array('justification'=>'right'));
$pdf->ezText("Invoice Total: " . dPgetConfig('currency_symbol').sprintf("%.2f",$invTotal,2), 12, $pdf->ezText("Invoice Total: " . w2PgetConfig('currency_symbol').sprintf("%.2f",$invTotal,2), 12,
array('justification'=>'right')); array('justification'=>'right'));
$options = array ( $options = array (
......
<?php <?php
/* /*
* Name: Invoice * Name: Invoice
* Directory: invoice * Directory: invoice
* Version: 0.1 * Version: 0.5
* Class: user * Class: user
* UI Name: Invoice * UI Name: Invoice
* UI Icon: * UI Icon:
*/ */
// MODULE CONFIGURATION DEFINITION // MODULE CONFIGURATION DEFINITION
$config = array(); $config = array();
$config['mod_name'] = 'Invoice'; $config['mod_name'] = 'Invoice';
$config['mod_version'] = '0.5'; $config['mod_version'] = '0.5';
$config['mod_directory'] = 'invoice'; $config['mod_directory'] = 'invoice';
$config['mod_setup_class'] = 'CSetupInvoice'; $config['mod_setup_class'] = 'CSetupInvoice';
$config['mod_type'] = 'user'; $config['mod_type'] = 'user';
$config['mod_ui_name'] = 'Invoice'; $config['mod_ui_name'] = 'Invoice';
$config['mod_ui_icon'] = 'applet3-48.png'; $config['mod_ui_icon'] = 'applet3-48.png';
$config['mod_description'] = 'A module for billing tasks'; $config['mod_description'] = 'A module for billing tasks';
if (@$a == 'setup') { if (@$a == 'setup') {
echo dPshowModuleConfig( $config ); echo w2PshowModuleConfig( $config );
} }
class CSetupInvoice extends w2p_Core_Setup
class CSetupInvoice{ {
public 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_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', `invoice_paid` int(11) default NULL,
`invoice_paid` int(11) default NULL, `invoice_creator` int(11) NOT NULL default '0',
`invoice_creator` int(11) NOT NULL default '0', PRIMARY KEY (`invoice_id`)
PRIMARY KEY (`invoice_id`) ) TYPE=MyISAM ";
) TYPE=MyISAM "; $q = new w2p_Database_Query();
$q = new DBQuery; $q->createTable('invoice');
$q->createTable('invoice'); $q->createDefinition($sql);
$q->createDefinition($sql); $q->exec();
$q->exec(); $sql = "(
$sql = "( `task_queue_id` int(11) NOT NULL auto_increment,
`task_queue_id` int(11) NOT NULL auto_increment, `task_invoice` int(11) NOT NULL default '0',
`task_invoice` int(11) NOT NULL default '0', `task_amount` float NOT NULL default '0',
`task_amount` float NOT NULL default '0', `task_log_id` bigint(20) NOT NULL default '0',
`task_log_id` bigint(20) NOT NULL default '0', PRIMARY KEY (`task_queue_id`)
PRIMARY KEY (`task_queue_id`) ) TYPE=MyISAM ";
) TYPE=MyISAM "; $q->clear();
$q->clear(); $q->createTable('invoice_task_queue');
$q->createTable('invoice_task_queue'); $q->createDefinition($sql);
$q->createDefinition($sql); $q->exec();
$q->exec(); return parent::install();
return null; }
}
public function remove() {
function remove() { $q = new w2p_Database_Query();
$q = new DBQuery;
$q->dropTable('invoice');
$q->dropTable('invoice'); $q->exec();
$q->exec(); $q->clear();
$q->clear();
$q->dropTable('invoice_task_queue');
$q->dropTable('invoice_task_queue'); $q->exec();
$q->exec();
return parent::remove();
return null; }
}
public function upgrade($old_version) {
function upgrade() { switch ($old_version) {
return null; case 0.1:
} default:
} return true;
}
?> return false;
}
}
?>
<?php <?php
$invoice_id = intval( dPgetParam( $_GET, "invoice_id", 0 ) ); if (!defined('W2P_BASE_DIR')) {
$project_id = intval( dPgetParam( $_GET, "project_id", 0 ) ); die('You should not access this file directly.');
// //$report_type = dPgetParam( $_REQUEST, "report_type", '' ); }
$invoice_id = intval( w2PgetParam( $_GET, "invoice_id", 0 ) );
$project_id = intval( w2PgetParam( $_GET, "project_id", 0 ) );
// //$report_type = w2PgetParam( $_REQUEST, "report_type", '' );
// check permissions for this record // check permissions for this record
// Done in index.php // Done in index.php
$canEdit = !getDenyEdit( $m, $project_id); $perms = &$AppUI->acl();
//$canEdit = $perms->checkModuleItem( $m, 'edit', $project_id );
$canEdit = $perms->checkModule( $m, 'edit' );
if (!$canEdit) { if (!$canEdit) {
$AppUI->redirect( "m=public&a=access_denied" ); $AppUI->redirect( "m=public&a=access_denied" );
} }
...@@ -13,20 +19,20 @@ if (!$canEdit) { ...@@ -13,20 +19,20 @@ if (!$canEdit) {
// format dates // format dates
$df = $AppUI->getPref('SHDATEFORMAT'); $df = $AppUI->getPref('SHDATEFORMAT');
$start_date = new CDate( $row->project_start_date ); $start_date = new w2p_Utilities_Date( $row->project_start_date );
$end_date = intval( $row->project_end_date ) ? new CDate( $row->project_end_date ) : null; $end_date = intval( $row->project_end_date ) ? new w2p_Utilities_Date( $row->project_end_date ) : null;
$actual_end_date = intval( $row->project_actual_end_date ) ? new CDate( $row->project_actual_end_date ) : null; $actual_end_date = intval( $row->project_actual_end_date ) ? new w2p_Utilities_Date( $row->project_actual_end_date ) : null;
// setup the title block // setup the title block
$ttl = $project_id > 0 ? "View Invoice" : "View Invoice"; $ttl = $project_id > 0 ? "View Invoice" : "View Invoice";
$titleBlock = new CTitleBlock( $ttl, 'applet3-48.png', $m, "$m.$a" ); $titleBlock = new w2p_Theme_TitleBlock( $ttl, 'applet3-48.png', $m, "$m.$a" );
if ($project_id != 0) if ($project_id != 0)
$titleBlock->addCrumb( "?m=projects&a=view&project_id=$project_id", "view this project" ); $titleBlock->addCrumb( "?m=projects&a=view&project_id=$project_id", "view this project" );
$titleBlock->addCrumb( '?m=invoice', 'view all invoices'); $titleBlock->addCrumb( '?m=invoice', 'view all invoices');
$titleBlock->show(); $titleBlock->show();
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
task_queue_id, task_queue_id,
invoice_task_queue.task_log_id, invoice_task_queue.task_log_id,
...@@ -97,16 +103,16 @@ foreach($billingcodes as $values) ...@@ -97,16 +103,16 @@ foreach($billingcodes as $values)
//$amount_code = ; //$amount_code = ;
//$hours = ; //$hours = ;
$counter = 0; $counter = 0;
$start_date = new CDate(); $start_date = new w2p_Utilities_Date();
$finish_date = new CDate(0); $finish_date = new w2p_Utilities_Date(0);
function showtask(&$a) { function invoice_showtask(&$a) {
global $AppUI, $project_id, $billingcodes, $bcodes; global $AppUI, $project_id, $billingcodes, $bcodes;
global $pdfdata, $amount_code, $amount_fixed; global $pdfdata, $amount_code, $amount_fixed;
global $counter, $hours, $hours_fixed; global $counter, $hours, $hours_fixed;
$df = $AppUI->getPref( 'SHDATEFORMAT' ); $df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
task_log_id, task_log_id,
task_log_task, task_log_task,
...@@ -158,21 +164,21 @@ if ($a["task_amount"] == "0") { ...@@ -158,21 +164,21 @@ if ($a["task_amount"] == "0") {
$hours_fixed += $tasks['task_log_hours']; $hours_fixed += $tasks['task_log_hours'];
} }
global $start_date, $finish_date; global $start_date, $finish_date;
$t = new CDate($tasks['task_log_date']); $t = new w2p_Utilities_Date($tasks['task_log_date']);
if ($start_date->compare($t, $start_date) < 0) if ($start_date->compare($t, $start_date) < 0)
$start_date = $t; $start_date = $t;
if ($finish_date->compare($t, $finish_date) > 0) if ($finish_date->compare($t, $finish_date) > 0)
$finish_date = $t; $finish_date = $t;
$s = "\n<tr>"; $s = "\n<tr>";
$d = new CDate($tasks['task_log_date']); $d = new w2p_Utilities_Date($tasks['task_log_date']);
$s .= '<td nowrap>' . $d->format($df) . '</td>'; $s .= '<td nowrap>' . $d->format($df) . '</td>';
$alt = htmlspecialchars( $tasks["task_log_name"] ); $alt = htmlspecialchars( $tasks["task_log_name"] );
$s .= '<td align=left>&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $tasks["task_log_task"] . '" title="' . $alt . '">' . $tasks["task_log_name"] . '</a></td>'; $s .= '<td align=left>&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $tasks["task_log_task"] . '" title="' . $alt . '">' . $tasks["task_log_name"] . '</a></td>';
$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').'&nbsp;'.$amount.'</td>'; $s .= '<td nowrap="nowrap">'.w2PgetConfig('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>';
...@@ -226,11 +232,11 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -226,11 +232,11 @@ for ($s=0; $s < count($tasks); $s++) {
foreach($bcodes as $code => $rate) foreach($bcodes as $code => $rate)
$tmp[strtolower($code)] = $hours[strtolower($code)]; $tmp[strtolower($code)] = $hours[strtolower($code)];
$tmpfix = $amount_fixed; $tmpfix = $amount_fixed;
$tmpamount = showtask( $tasks[$s], 1 ); $tmpamount = invoice_showtask( $tasks[$s], 1 );
$myamount=$myamount + $tmpamount; $myamount=$myamount + $tmpamount;
$task_log = get_task_log($tasks[$s]['task_log_id']); $task_log = get_task_log($tasks[$s]['task_log_id']);
$date = new CDate($task_log['task_log_date']); $date = new w2p_Utilities_Date($task_log['task_log_date']);
$date = $date->format($df); $date = $date->format($df);
$tmppdfdata2 = array( $tmppdfdata2 = array(
// ++$counter, // ++$counter,
...@@ -243,7 +249,7 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -243,7 +249,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[] = w2PgetConfig('currency_symbol') . sprintf(" %.2f", round($amount_fixed - $tmpfix, 2));
$pdfdata2t[] = array_merge($tmppdfdata2, $temp); $pdfdata2t[] = array_merge($tmppdfdata2, $temp);
} }
...@@ -261,7 +267,7 @@ for ($s=0; $s < count($tasks); $s++) { ...@@ -261,7 +267,7 @@ for ($s=0; $s < count($tasks); $s++) {
function get_user_name($user_id) function get_user_name($user_id)
{ {
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery('user_username'); $q->addQuery('user_username');
$q->addTable('users'); $q->addTable('users');
$q->addWhere('user_id = ' . $user_id); $q->addWhere('user_id = ' . $user_id);
...@@ -271,7 +277,7 @@ function get_user_name($user_id) ...@@ -271,7 +277,7 @@ function get_user_name($user_id)
function get_task_log($task_log_id, $task=false) function get_task_log($task_log_id, $task=false)
{ {
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery(' $q->addQuery('
task_log_id, task_log_id,
task_log_task, task_log_task,
...@@ -294,7 +300,7 @@ $tasks=db_fetch_assoc($tmptasks); ...@@ -294,7 +300,7 @@ $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> <td>
<?php echo dPgetConfig('currency_symbol'); ?> <?php echo w2PgetConfig('currency_symbol'); ?>
&nbsp; &nbsp;
<?php echo $myamount ?> <?php echo $myamount ?>
</td> </td>
...@@ -302,15 +308,15 @@ $tasks=db_fetch_assoc($tmptasks); ...@@ -302,15 +308,15 @@ $tasks=db_fetch_assoc($tmptasks);
</table> </table>
<?php <?php
$q = new DBQuery; $q = new w2p_Database_Query();
$q->addQuery('project_name, project_short_name'); $q->addQuery('project_name, project_short_name');
$q->addTable('projects'); $q->addTable('projects');
$q->addWhere('project_id = ' . $project_id); $q->addWhere('project_id = ' . $project_id);
$pname = $q->loadList(); $pname = $q->loadList();
$font_dir = dPgetConfig( 'root_dir' )."/lib/ezpdf/fonts"; $font_dir = w2PgetConfig( 'root_dir' )."/lib/ezpdf/fonts";
$temp_dir = dPgetConfig( 'root_dir' )."/files/temp"; $temp_dir = w2PgetConfig( 'root_dir' )."/files/temp";
$base_url = dPgetConfig( 'base_url' ); $base_url = w2PgetConfig( 'base_url' );
require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) ); require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) );
//TRUE REPORT!!! //TRUE REPORT!!!
...@@ -330,12 +336,12 @@ require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) ); ...@@ -330,12 +336,12 @@ require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) );
// $pdf->selectFont( "$font_dir/Helvetica.afm" ); // $pdf->selectFont( "$font_dir/Helvetica.afm" );
// $report_type = dPgetParam( $_REQUEST, "report_type", '' ); // $report_type = w2PgetParam( $_REQUEST, "report_type", '' );
$reports = $AppUI->readFiles( dPgetConfig( 'root_dir' )."/modules/invoice/reports", "\.php$" ); $reports = $AppUI->readFiles( w2PgetConfig( 'root_dir' )."/modules/invoice/reports", "\.php$" );
// $report_type_var = dPgetParam($_GET, 'report_type', ''); // $report_type_var = w2PgetParam($_GET, 'report_type', '');
// if (!empty($report_type_var)) // if (!empty($report_type_var))
// $report_type_var = '&report_type=' . $report_type; // $report_type_var = '&report_type=' . $report_type;
......
<?php <?php
function invoices($type) if (!defined('W2P_BASE_DIR')) {
{ die('You should not access this file directly.');
GLOBAL $AppUI, $invoices; }
$df = $AppUI->getPref('SHDATEFORMAT');
?> function invoices($type)
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="tbl"> {
<tr> GLOBAL $AppUI, $invoices;
<th align="right" width="65" nowrap="nowrap">&nbsp;<?php echo $AppUI->_('sort by');?>:&nbsp;</th> $df = $AppUI->getPref('SHDATEFORMAT');
<th nowrap="nowrap"> ?>
<a href="?m=invoice&orderby=invoice_id" class="hdr"><?php echo $AppUI->_('Invoice Number');?></a> <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tbl">
</th> <tr>
<th nowrap="nowrap"> <th align="right" width="65" nowrap="nowrap">&nbsp;<?php echo $AppUI->_('sort by');?>:&nbsp;</th>
<a href="?m=invoice&orderby=invoice_tag" class="hdr"><?php echo $AppUI->_('Invoice Tag');?></a> <th nowrap="nowrap">
</th> <a href="?m=invoice&orderby=invoice_id" class="hdr"><?php echo $AppUI->_('Invoice Number');?></a>
<th nowrap="nowrap"> </th>
<a href="?m=invoice&orderby=invoice_project" class="hdr"><?php echo $AppUI->_('Project');?></a> <th nowrap="nowrap">
</th> <a href="?m=invoice&orderby=invoice_tag" class="hdr"><?php echo $AppUI->_('Invoice Tag');?></a>
<th nowrap="nowrap"> </th>
<a href="?m=invoice&orderby=invoice_creator" class="hdr"><?php echo $AppUI->_('Creator');?></a> <th nowrap="nowrap">
</th> <a href="?m=invoice&orderby=invoice_project" class="hdr"><?php echo $AppUI->_('Project');?></a>
<th nowrap="nowrap"> </th>
<a href="?m=invoice&orderby=invoice_date" class="hdr"><?php echo $AppUI->_('Created On');?></a> <th nowrap="nowrap">
</th> <a href="?m=invoice&orderby=invoice_creator" class="hdr"><?php echo $AppUI->_('Creator');?></a>
<th nowrap="nowrap"> </th>
<a href="?m=invoice&orderby=invoice_amount" class="hdr"><?php echo $AppUI->_('Invoice Amount');?>:</a> <th nowrap="nowrap">
</th> <a href="?m=invoice&orderby=invoice_date" class="hdr"><?php echo $AppUI->_('Created On');?></a>
</tr> </th>
<th nowrap="nowrap">
<?php <a href="?m=invoice&orderby=invoice_amount" class="hdr"><?php echo $AppUI->_('Invoice Amount');?>:</a>
$CR = "\n"; </th>
$CT = "\n\t"; </tr>
$none = true;
$q = new DBQuery; <?php
foreach ($invoices as $row) $CR = "\n";
{ $CT = "\n\t";
if ($row["invoice_status"] == $type) $none = true;
{ $q = new w2p_Database_Query();
$none = false; foreach ($invoices as $row)
$q->clear(); {
$q->addQuery(' if ($row["invoice_status"] == $type)
project_name, {
project_description'); $none = false;
$q->addTable('projects'); $q->clear();
$q->addWhere('project_id = ' . $row['invoice_project']); $q->addQuery('
$myproject_name=$q->loadList(); project_name,
project_description');
// edit query FROM users; user_first_name and user_last_name $q->addTable('projects');
$q->clear(); $q->addWhere('project_id = ' . $row['invoice_project']);
$q->addQuery(' $myproject_name=$q->loadList();
contact_first_name,
contact_last_name'); // edit query FROM users; user_first_name and user_last_name
$q->addTable('contacts'); $q->clear();
$q->leftJoin('users', 'u', 'user_contact=contact_id'); $q->addQuery('
$q->addWhere('user_id = ' . $row['invoice_creator']); contact_first_name,
contact_last_name');
$myuser_name=$q->loadList(); $q->addTable('contacts');
$mydate=strftime($df,$row["invoice_date"]); $q->leftJoin('users', 'u', 'user_contact=contact_id');
$q->addWhere('user_id = ' . $row['invoice_creator']);
$total_amount=get_invoice_amount($row["invoice_id"], $row["invoice_project"]);
$myuser_name=$q->loadList();
$s = '<tr>'; $mydate=strftime($df,$row["invoice_date"]);
$s .= $CR . '<td>';
if ($type == 0) $total_amount=get_invoice_amount($row["invoice_id"], $row["invoice_project"]);
$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 = '<tr>';
$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>';
$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>'; if ($type == 0)
$s .= $CR . '<td width=500>'; $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 .= $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 .= '&nbsp; </td>';
$s .= $CR . '</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">' .$myuser_name[0]["contact_first_name"]. ' '.$myuser_name[0]["contact_last_name"]. '</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 nowrap="nowrap">' .$mydate. '</td>'; $s .= $CR . '<td width=500>';
$s .= $CR . '<td nowrap="nowrap">'.dPgetConfig('currency_symbol').'&nbsp;'.$total_amount. '</td>'; $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 . '</tr>'; $s .= $CR . '</td>';
echo $s; $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">'.w2PgetConfig('currency_symbol').'&nbsp;'.$total_amount. '</td>';
if ($none) { $s .= $CR . '</tr>';
echo $CR . '<tr><td colspan="7">' . $AppUI->_( 'No open invoice available' ) . '</td></tr>'; echo $s;
} }
?> }
<tr> if ($none) {
<td colspan="7">&nbsp;</td> echo $CR . '<tr><td colspan="7">' . $AppUI->_( 'No open invoice available' ) . '</td></tr>';
</tr> }
</table> ?>
<?php <tr>
} <td colspan="7">&nbsp;</td>
</tr>
function get_invoice_amount($invoice_id, $project_id) { </table>
$amount=0; <?php
}
$q = new DBQuery;
$q->addQuery('project_company'); function get_invoice_amount($invoice_id, $project_id) {
$q->addTable('projects'); $amount=0;
$q->addWhere('project_id = '. $project_id);
$q = new w2p_Database_Query();
$company_id = $q->loadResult(); $q->addQuery('project_company');
//$tmpprj=db_exec($sql); $q->addTable('projects');
//$row=db_fetch_assoc($tmpprj); $q->addWhere('project_id = '. $project_id);
//$company_id=$row["project_company"];
$company_id = $q->loadResult();
$q->clear(); //$tmpprj=db_exec($sql);
$q->addQuery(' //$row=db_fetch_assoc($tmpprj);
billingcode_id, //$company_id=$row["project_company"];
billingcode_name,
billingcode_value'); $q->clear();
$q->addTable('billingcode'); $q->addQuery('
$q->addWhere('company_id = ' . $company_id); billingcode_id,
$q->addOrder('billingcode_name ASC'); billingcode_name,
billingcode_value');
$billingcodes = $q->loadList(); $q->addTable('billingcode');
$q->addWhere('company_id = ' . $company_id);
$q->clear(); $q->addOrder('billingcode_name ASC');
$q->addQuery('
t.task_invoice, $billingcodes = $q->loadList();
t.task_queue_id,
t.task_amount, $q->clear();
t.task_log_id, $q->addQuery('
t1.task_log_costcode, t.task_invoice,
t1.task_log_hours'); t.task_queue_id,
$q->addTable('invoice_task_queue', 't'); t.task_amount,
$q->leftJoin('task_log', 't1', 't.task_log_id=t1.task_log_id'); t.task_log_id,
$q->addWhere('task_invoice = ' . $invoice_id); t1.task_log_costcode,
$q->addGroup('t.task_log_id'); t1.task_log_hours');
$q->addTable('invoice_task_queue', 't');
$tasks=$q->loadList(); $q->leftJoin('task_log', 't1', 't.task_log_id=t1.task_log_id');
$q->addWhere('task_invoice = ' . $invoice_id);
foreach($tasks as $task) $q->addGroup('t.task_log_id');
{
if ($task['task_amount'] == '0') $tasks=$q->loadList();
{
for ($x=0; $x < count($billingcodes); $x++) foreach($tasks as $task)
if ($billingcodes[$x]['billingcode_id'] == $task['task_log_costcode']) {
$rate=$billingcodes[$x]['billingcode_value']; if ($task['task_amount'] == '0')
{
$amount+=round($rate * $task['task_log_hours'],2); for ($x=0; $x < count($billingcodes); $x++)
} if ($billingcodes[$x]['billingcode_id'] == $task['task_log_costcode'])
else $rate=$billingcodes[$x]['billingcode_value'];
$amount=$amount + round($task['task_amount'],2);
} $amount+=round($rate * $task['task_log_hours'],2);
}
return $amount; else
} $amount=$amount + round($task['task_amount'],2);
?> }
return $amount;
}
?>
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
include("vw_inc.php"); include("vw_inc.php");
echo invoices(3); echo invoices(3);
......
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
include("vw_inc.php"); include("vw_inc.php");
echo invoices(0); echo invoices(0);
......
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
include("vw_inc.php"); include("vw_inc.php");
echo invoices(2); echo invoices(2);
......
<?php <?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
include("vw_inc.php"); include("vw_inc.php");
echo invoices(1); echo invoices(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