Commit 433881e8 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add new tab "Loss" to record invoices never paid and considered losses.

parent 1e528799
<?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 ) ); $invoice_id = intval( dPgetParam( $_REQUEST, "invoice_id", 0 ) );
$project_id = intval( dPgetParam( $_REQUEST, "project_id", 0 ) ); $project_id = intval( dPgetParam( $_REQUEST, "project_id", 0 ) );
// check permissions for this record // check permissions for this record
// Done automatically in index.php // Done automatically in index.php
//$canEdit = !getDenyEdit( $m, $project_id); //$canEdit = !getDenyEdit( $m, $project_id);
if (!$canEdit) { if (!$canEdit) {
$AppUI->redirect( "m=public&a=access_denied" ); $AppUI->redirect( "m=public&a=access_denied" );
} }
// format dates // format dates
$df = $AppUI->getPref('SHDATEFORMAT'); $df = $AppUI->getPref('SHDATEFORMAT');
$start_date = new CDate( $row->project_start_date ); $start_date = new CDate( $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 CDate( $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 CDate( $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 CTitleBlock( $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" );
$titleBlock->addCrumb( '?m=invoice', 'view all invoices' ); $titleBlock->addCrumb( '?m=invoice', 'view all invoices' );
$titleBlock->show(); $titleBlock->show();
$task_id=(int)$_REQUEST["task_id"]; $task_id=(int)$_REQUEST["task_id"];
if($task_id == '') { if($task_id == '') {
$task_id=0; $task_id=0;
} }
$q = new DBQuery; $q = new DBQuery;
$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());
$billed = ''; $billed = '';
foreach ($temp_billed as $task_log) 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->clear();
$q->addQuery('invoice_tag, invoice_status'); $q->addQuery('invoice_tag, invoice_status');
$q->addTable('invoice'); $q->addTable('invoice');
$q->addWhere('invoice_id = ' . $invoice_id); $q->addWhere('invoice_id = ' . $invoice_id);
$ptrc = $q->exec(); $ptrc = $q->exec();
$nums=db_num_rows($ptrc); $nums=db_num_rows($ptrc);
echo db_error(); echo db_error();
for ($x=0; $x < $nums; $x++) { for ($x=0; $x < $nums; $x++) {
$row = db_fetch_assoc( $ptrc ); $row = db_fetch_assoc( $ptrc );
$invoice_tag = $row["invoice_tag"]; $invoice_tag = $row["invoice_tag"];
$invoice_status = $row["invoice_status"]; $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,
task_log_task, task_log_task,
task_log_name, task_log_name,
task_log_description, task_log_description,
task_log_creator, task_log_creator,
task_log_hours, task_log_hours,
task_log_date, task_log_date,
billingcode_name'); billingcode_name');
$q->addTable('task_log'); $q->addTable('task_log');
$q->addTable('tasks'); $q->addTable('tasks');
$q->addTable('projects'); $q->addTable('projects');
$q->leftJoin('billingcode', 'b', 'billingcode_id = task_log_costcode'); $q->leftJoin('billingcode', 'b', 'billingcode_id = task_log_costcode');
$q->addWhere('tasks.task_project = project_id'); $q->addWhere('tasks.task_project = project_id');
if (!empty($billed)) if (!empty($billed))
$q->addWhere('task_log_id not in ' . $billed); $q->addWhere('task_log_id not in ' . $billed);
$q->addWhere('tasks.task_id = task_log_task'); $q->addWhere('tasks.task_id = task_log_task');
$q->addWhere('project_id = ' . $project_id); $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 CDate($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 CDate($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)
$q->addWhere('task_log_task = ' . $task_id); $q->addWhere('task_log_task = ' . $task_id);
//$sql .= "ORDER BY task_log_name"; //$sql .= "ORDER BY task_log_name";
$tasks_log = $q->loadList(); $tasks_log = $q->loadList();
$q->clear(); $q->clear();
$q->addQuery(' $q->addQuery('
task_queue_id, task_queue_id,
task_log_id, task_log_id,
task_amount'); task_amount');
$q->addTable('invoice_task_queue'); $q->addTable('invoice_task_queue');
$q->addWhere('task_invoice = ' . $invoice_id); $q->addWhere('task_invoice = ' . $invoice_id);
$q->addOrder('task_log_id DESC'); $q->addOrder('task_log_id DESC');
$tasks = $q->loadList(); $tasks = $q->loadList();
$q->clear(); $q->clear();
$q->addQuery('task_id, task_name'); $q->addQuery('task_id, task_name');
$q->addTable('tasks'); $q->addTable('tasks');
$q->addTable('task_log'); $q->addTable('task_log');
$q->addWhere('task_id = task_log_task'); $q->addWhere('task_id = task_log_task');
if (!empty($billed)) if (!empty($billed))
$q->addWhere('task_log_id not in ' . $billed); $q->addWhere('task_log_id not in ' . $billed);
//AND task_percent_complete > 0 //AND task_percent_complete > 0
$q->addWhere('task_project = ' . $project_id); $q->addWhere('task_project = ' . $project_id);
$q->addGroup('task_id HAVING count(task_log_task) > 0'); $q->addGroup('task_id HAVING count(task_log_task) > 0');
$q->addOrder('task_name ASC'); $q->addOrder('task_name ASC');
$task_list=array("0"=>"Select Task"); $task_list=array("0"=>"Select Task");
$ptrc = $q->exec(); $ptrc = $q->exec();
$nums=db_num_rows($ptrc); $nums=db_num_rows($ptrc);
echo db_error(); echo db_error();
for ($x=0; $x < $nums; $x++) { for ($x=0; $x < $nums; $x++) {
$row = db_fetch_assoc( $ptrc ); $row = db_fetch_assoc( $ptrc );
$task_list[$row["task_id"]] = $row["task_name"]; $task_list[$row["task_id"]] = $row["task_name"];
} }
$q->clear(); $q->clear();
$q->addQuery('project_company'); $q->addQuery('project_company');
$q->addTable('projects'); $q->addTable('projects');
$q->addWhere('project_id = '. $project_id); $q->addWhere('project_id = '. $project_id);
//$tmpprj=db_exec($sql); //$tmpprj=db_exec($sql);
//$row=db_fetch_assoc($tmpprj); //$row=db_fetch_assoc($tmpprj);
//$company_id=$row["project_company"]; //$company_id=$row["project_company"];
$company_id = $q->loadResult(); $company_id = $q->loadResult();
$q->clear(); $q->clear();
$q->addQuery(' $q->addQuery('
billingcode_id, billingcode_id,
billingcode_name, billingcode_name,
billingcode_value'); billingcode_value');
$q->addTable('billingcode'); $q->addTable('billingcode');
$q->addWhere('company_id = ' . $company_id); $q->addWhere('company_id = ' . $company_id);
$q->addOrder('billingcode_name ASC'); $q->addOrder('billingcode_name ASC');
$billingcodes = $q->loadList(); $billingcodes = $q->loadList();
function showtask(&$a) { 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 DBQuery;
$q->addQuery(' $q->addQuery('
task_log_id, task_log_id,
task_log_task, task_log_task,
task_log_name, task_log_name,
task_log_description, task_log_description,
task_log_costcode, task_log_costcode,
task_log_creator, task_log_creator,
task_log_hours, task_log_hours,
task_log_date, task_log_date,
task_log_task'); task_log_task');
$q->addTable('task_log'); $q->addTable('task_log');
$q->addWhere('task_log_id = ' . $a['task_log_id']); $q->addWhere('task_log_id = ' . $a['task_log_id']);
$q->addOrder('task_log_name ASC'); $q->addOrder('task_log_name ASC');
$tmptasks=$q->exec(); $tmptasks=$q->exec();
$tasks=db_fetch_assoc($tmptasks); $tasks=db_fetch_assoc($tmptasks);
$q->clear(); $q->clear();
$q->addQuery(' $q->addQuery('
contact_first_name, contact_first_name,
contact_last_name'); contact_last_name');
$q->addTable('contacts'); $q->addTable('contacts');
$q->leftJoin('users', 'u', 'user_contact = contact_id'); $q->leftJoin('users', 'u', 'user_contact = contact_id');
$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); $username=db_fetch_assoc($tmpuser);
if ($a["task_amount"] == "0") { if ($a["task_amount"] == "0") {
$costdesc="None"; $costdesc="None";
for ($x=0; $x < count($billingcodes); $x++) { for ($x=0; $x < count($billingcodes); $x++) {
if ($billingcodes[$x]["billingcode_id"] == $tasks["task_log_costcode"]) { if ($billingcodes[$x]["billingcode_id"] == $tasks["task_log_costcode"]) {
$costdesc=$billingcodes[$x]["billingcode_name"]; $costdesc=$billingcodes[$x]["billingcode_name"];
$rate=$billingcodes[$x]["billingcode_value"]; $rate=$billingcodes[$x]["billingcode_value"];
} }
} }
$amount=round($rate * $tasks["task_log_hours"],2); $amount=round($rate * $tasks["task_log_hours"],2);
} else { } else {
$costdesc="Fixed Price"; $costdesc="Fixed Price";
$amount=round($a["task_amount"],2); $amount=round($a["task_amount"],2);
} }
$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 CDate($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">' . 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="6">'; $s .= '<td colspan="6">';
$s .= $tasks["task_log_description"]; $s .= $tasks["task_log_description"];
$s .= '</td>'; $s .= '</td>';
$s .= "</tr>\n"; $s .= "</tr>\n";
echo $s; echo $s;
return $amount; return $amount;
} }
function showtasklog(&$a) { function showtasklog(&$a) {
global $AppUI, $project_id; global $AppUI, $project_id;
$df = $AppUI->getPref( 'SHDATEFORMAT' ); $df = $AppUI->getPref( 'SHDATEFORMAT' );
$q = new DBQuery; $q = new DBQuery;
$q->addQuery(' $q->addQuery('
contact_first_name, contact_first_name,
contact_last_name'); contact_last_name');
$q->addTable('contacts'); $q->addTable('contacts');
$q->leftJoin('users', 'u', 'user_contact = contact_id'); $q->leftJoin('users', 'u', 'user_contact = contact_id');
$q->addWhere('user_id = ' . $a['task_log_creator']); $q->addWhere('user_id = ' . $a['task_log_creator']);
$tmpuser=$q->exec(); $tmpuser=$q->exec();
$username=db_fetch_assoc($tmpuser); $username=db_fetch_assoc($tmpuser);
$q->clear(); $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();
$check=db_fetch_assoc($tmpcheck); $check=db_fetch_assoc($tmpcheck);
$date = new CDate($a['task_log_date']); $date = new CDate($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>
<td nowrap>'.$date->format($df).'</td> <td nowrap>'.$date->format($df).'</td>
<td>'.$a["task_log_description"].'</td> <td>'.$a["task_log_description"].'</td>
<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">'.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']) == '')
echo $s; echo $s;
} }
?> ?>
<link rel="stylesheet" type="text/css" media="all" href="lib/calendar/calendar-dp.css" title="blue" /> <link rel="stylesheet" type="text/css" media="all" href="lib/calendar/calendar-dp.css" title="blue" />
<!-- import the calendar script --> <!-- import the calendar script -->
<script type="text/javascript" src="<?php echo $AppUI->cfg['base_url'];?>lib/calendar/calendar.js"></script> <script type="text/javascript" src="<?php echo $AppUI->cfg['base_url'];?>lib/calendar/calendar.js"></script>
<!-- import the language module --> <!-- import the language module -->
<script type="text/javascript" src="<?php echo $AppUI->cfg['base_url'];?>lib/calendar/lang/calendar-<?php echo $AppUI->user_locale; ?>.js"></script> <script type="text/javascript" src="<?php echo $AppUI->cfg['base_url'];?>lib/calendar/lang/calendar-<?php echo $AppUI->user_locale; ?>.js"></script>
<script language="javascript"> <script language="javascript">
function submitIt() { function submitIt() {
var f = document.editFrm; var f = document.editFrm;
var msg = ''; var msg = '';
/* /*
if (f.project_end_date.value > 0 && f.project_end_date.value < f.project_start_date.value) { if (f.project_end_date.value > 0 && f.project_end_date.value < f.project_start_date.value) {
msg += "\n<?php echo $AppUI->_('projectsBadEndDate1');?>"; msg += "\n<?php echo $AppUI->_('projectsBadEndDate1');?>";
} }
if (f.project_actual_end_date.value > 0 && f.project_actual_end_date.value < f.project_start_date.value) { if (f.project_actual_end_date.value > 0 && f.project_actual_end_date.value < f.project_start_date.value) {
msg += "\n<?php echo $AppUI->_('projectsBadEndDate2');?>"; msg += "\n<?php echo $AppUI->_('projectsBadEndDate2');?>";
} }
*/ */
if (msg.length < 1) { if (msg.length < 1) {
f.submit(); f.submit();
} else { } else {
alert(msg); alert(msg);
} }
} }
function delIt2(id) { function delIt2(id) {
if (confirm( "<?php echo $AppUI->_('doDelete', UI_OUTPUT_JS).' '.$AppUI->_('Invoice Item', UI_OUTPUT_JS).'?';?>" )) { if (confirm( "<?php echo $AppUI->_('doDelete', UI_OUTPUT_JS).' '.$AppUI->_('Invoice Item', UI_OUTPUT_JS).'?';?>" )) {
document.frmDelete2.task_queue_id.value = id; document.frmDelete2.task_queue_id.value = id;
document.frmDelete2.submit(); document.frmDelete2.submit();
} }
} }
function changeIt() { function changeIt() {
var f=document.changeMe; var f=document.changeMe;
f.submit(); f.submit();
} }
function searchIt() { function searchIt() {
document.searchMe.submit(); document.searchMe.submit();
} }
function changeStat() { function changeStat() {
var f=document.frmStatus; var f=document.frmStatus;
f.submit(); f.submit();
} }
var calendarField = ''; var calendarField = '';
var calWin = null; var calWin = null;
function popCalendar( field ){ function popCalendar( field ){
calendarField = field; calendarField = field;
idate = eval( 'document.searchMe.' + field + '.value' ); idate = eval( 'document.searchMe.' + field + '.value' );
window.open( 'index.php?m=public&a=calendar&dialog=1&callback=setCalendar&date=' + idate, 'calwin', 'top=250,left=250,width=250, height=220, scollbars=false' ); window.open( 'index.php?m=public&a=calendar&dialog=1&callback=setCalendar&date=' + idate, 'calwin', 'top=250,left=250,width=250, height=220, scollbars=false' );
} }
/** /**
* @param string Input date in the format YYYYMMDD * @param string Input date in the format YYYYMMDD
* @param string Formatted date * @param string Formatted date
*/ */
function setCalendar( idate, fdate ) { function setCalendar( idate, fdate ) {
fld_date = eval( 'document.searchMe.inv_' + calendarField ); fld_date = eval( 'document.searchMe.inv_' + calendarField );
fld_fdate = eval( 'document.searchMe.' + calendarField ); fld_fdate = eval( 'document.searchMe.' + calendarField );
fld_date.value = idate; fld_date.value = idate;
fld_fdate.value = fdate; fld_fdate.value = fdate;
} }
function checkUncheckAll(theElement) { function checkUncheckAll(theElement) {
//documentation for this script at http://www.shawnolson.net/a/693/ //documentation for this script at http://www.shawnolson.net/a/693/
var theForm = theElement.form, z = 0; var theForm = theElement.form, z = 0;
while (theForm[z].name != 'checkall') { while (theForm[z].name != 'checkall') {
if (theForm[z].type == 'checkbox') if (theForm[z].type == 'checkbox')
theForm[z].checked = theElement.checked; theForm[z].checked = theElement.checked;
z++; z++;
} }
} }
</script> </script>
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="std"> <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
<form name="frmDelete2" action="./index.php?m=invoice" method="post"> <form name="frmDelete2" 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="del" value="1" /> <input type="hidden" name="del" value="1" />
<input type="hidden" name="task_queue_id" value="0" /> <input type="hidden" name="task_queue_id" value="0" />
<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;?>" />
</form> </form>
<table cellspacing="0" cellpadding="4" border="0" width="40%" class="std" valign="top"> <table cellspacing="0" cellpadding="4" border="0" width="40%" class="std" valign="top">
<form name="statusFrm" action="./index.php?m=invoice" method="post"> <form name="statusFrm" 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="del" value="0" /> <input type="hidden" name="del" value="0" />
<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="invoice_id" value="<?php echo $invoice_id;?>" /> <input type="hidden" name="invoice_id" 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 valign="top" width="90%"> <tr valign="top" width="90%">
<td align="left"> <td align="left">
Invoices will not be editable once the status changes from Open for Editing. 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; <td align="right">Invoice Number&nbsp;
<?php echo $invoice_id?> <?php echo $invoice_id?>
</td> </td>
</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" />
</td> </td>
</tr> </tr>
<tr valign="top" width="90%"> <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 <?php if ($invoice_status == "0") print "selected" ?> value="0">Open for Editing</option>
<option value="1">Pending Payment</option> <option <?php if ($invoice_status == "1") print "selected" ?> value="1">Pending Payment</option>
<option value="2">Paid</option> <option <?php if ($invoice_status == "2") print "selected" ?> value="2">Paid</option>
</select> <option <?php if ($invoice_status == "3") print "selected" ?> value="3">Loss</option>
</td> </select>
</tr> </td>
<tr> </tr>
<td align="right"> <tr>
<input class="button" type="submit" name="submit" value="<?php echo $AppUI->_('submit');?>"/> <td align="right">
</td> <input class="button" type="submit" name="submit" value="<?php echo $AppUI->_('submit');?>"/>
</tr> </td>
</form> </tr>
</table> </form>
</table>
<br>
<br>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<tr> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<th width="10">&nbsp;</th> <tr>
<th width="15">&nbsp;</td> <th width="10">&nbsp;</th>
<th><?php echo $AppUI->_('Date');?></th> <th width="15">&nbsp;</td>
<th><?php echo $AppUI->_('Task Name');?></th> <th><?php echo $AppUI->_('Date');?></th>
<th width="250" nowrap="nowrap"><?php echo $AppUI->_('Task Creator');?></th> <th><?php echo $AppUI->_('Task Name');?></th>
<th width="100" nowrap="nowrap"><?php echo $AppUI->_('Task Hours');?></th> <th width="250" nowrap="nowrap"><?php echo $AppUI->_('Task Creator');?></th>
<th width="100" nowrap="nowrap"><?php echo $AppUI->_('Billing Code');?></th> <th width="100" nowrap="nowrap"><?php echo $AppUI->_('Task Hours');?></th>
<th width="100" nowrap="nowrap"><?php echo $AppUI->_('Amount');?></th> <th width="100" nowrap="nowrap"><?php echo $AppUI->_('Billing Code');?></th>
</tr> <th width="100" nowrap="nowrap"><?php echo $AppUI->_('Amount');?></th>
<?php </tr>
$myamount=0; <?php
for ($s=0; $s < count($tasks); $s++) { $myamount=0;
$tnums=count($tasks); for ($s=0; $s < count($tasks); $s++) {
if ($tnums) { $tnums=count($tasks);
$tmpamount=0; if ($tnums) {
$tmpamount = showtask( $tasks[$s], 1 ); $tmpamount=0;
$myamount=$myamount + $tmpamount; $tmpamount = showtask( $tasks[$s], 1 );
} $myamount=$myamount + $tmpamount;
} }
?> }
<tr> ?>
<td colspan=7 align=right><b>Total</b></td> <tr>
<td colspan=7 align=right><b>Total</b></td>
<td> <td>
<?php echo dPgetConfig('currency_symbol'); ?>&nbsp; <?php echo dPgetConfig('currency_symbol'); ?>&nbsp;
<?php echo $myamount ?> <?php echo $myamount ?>
</td> </td>
</tr> </tr>
</table> </table>
<table cellspacing="0" cellpadding="4" border="0" width="70%" class="std"> <table cellspacing="0" cellpadding="4" border="0" width="70%" class="std">
<tr valign="top" width="90%"> <tr valign="top" width="90%">
<form name="searchMe" action="./index.php?m=invoice&a=addedit" method="post"> <form name="searchMe" action="./index.php?m=invoice&a=addedit" method="post">
<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="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');?>
<input type="hidden" name="inv_start_date" value="" class="text" /> <input type="hidden" name="inv_start_date" value="" class="text" />
<input type="text" name="start_date" value="" class="text" /> <input type="text" name="start_date" value="" class="text" />
<a href="#" onClick="popCalendar('start_date')"> <a href="#" onClick="popCalendar('start_date')">
<img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar');?>" border="0" /> <img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar');?>" border="0" />
</a> </a>
</td> </td>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('End Date');?> <td align="right" nowrap="nowrap"><?php echo $AppUI->_('End Date');?>
<input type="hidden" name="inv_end_date" value="" class="text" /> <input type="hidden" name="inv_end_date" value="" class="text" />
<input type="text" name="end_date" value="" class="text" /> <input type="text" name="end_date" value="" class="text" />
<a href="#" onClick="popCalendar('end_date')"> <a href="#" onClick="popCalendar('end_date')">
<img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar');?>" border="0" /> <img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar');?>" border="0" />
</a> </a>
</td> </td>
<td> <td>
<input class="button" type="button" name="btnFuseSearch" value="<?php echo $AppUI->_('search');?>" onClick="searchIt();" /> <input class="button" type="button" name="btnFuseSearch" value="<?php echo $AppUI->_('search');?>" onClick="searchIt();" />
</td> </td>
</tr> </tr>
</form> </form>
<form name="changeMe" action="./index.php?m=invoice&a=addedit" method="post"> <form name="changeMe" action="./index.php?m=invoice&a=addedit" method="post">
<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="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>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Task Name');?> <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Task Name');?>
<?php echo arraySelect( $task_list, 'task_id', 'size="1" class="text" onchange="changeIt();"', $obj->task_status, true );?></td> <?php echo arraySelect( $task_list, 'task_id', 'size="1" class="text" onchange="changeIt();"', $obj->task_status, true );?></td>
</form> </form>
</tr> </tr>
<tr> <tr>
<td colspan="2" align="right"> <td colspan="2" align="right">
<input class="button" type="button" name="btnFuseAction" value="<?php echo $AppUI->_('Add selected tasks log to invoice');?>" onClick="submitIt();" /> <input class="button" type="button" name="btnFuseAction" value="<?php echo $AppUI->_('Add selected tasks log to invoice');?>" onClick="submitIt();" />
</td> </td>
</tr> </tr>
<?php <?php
if (isset($_POST['start_date'])) if (isset($_POST['start_date']))
{ {
?> ?>
<tr><td colspan="2"><?php 'Dates between: ' . $_POST['start_date'] . ' and ' . $_POST['end_date'] . '<br />'?></td></tr>; <tr><td colspan="2"><?php 'Dates between: ' . $_POST['start_date'] . ' and ' . $_POST['end_date'] . '<br />'?></td></tr>;
<?php <?php
} }
?> ?>
</table> </table>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<tr> <tr>
<th><?php $AppUI->_('Select') ?></th> <th><?php $AppUI->_('Select') ?></th>
<th><?php echo $AppUI->_('Date');?></th> <th><?php echo $AppUI->_('Date');?></th>
<th><?php echo $AppUI->_('Log Summary');?></th> <th><?php echo $AppUI->_('Log Summary');?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Creator');?></th> <th nowrap="nowrap"><?php echo $AppUI->_('Creator');?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Hours');?></th> <th nowrap="nowrap"><?php echo $AppUI->_('Hours');?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Billing Code');?></th> <th nowrap="nowrap"><?php echo $AppUI->_('Billing Code');?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Fixed Amount');?></th> <th nowrap="nowrap"><?php echo $AppUI->_('Fixed Amount');?></th>
</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="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;?>" />
<?php <?php
//echo '<tr><td>'; print_r($tasks_log); echo '</td></tr>'; //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);
} }
?> ?>
<tr><td><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/>all</td></tr> <tr><td><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/>all</td></tr>
</form> </form>
</table> </table>
* <?php echo $AppUI->_('requiredField');?> * <?php echo $AppUI->_('requiredField');?>
...@@ -45,6 +45,7 @@ $tabBox = new CTabBox( "?m=invoice", dPgetConfig('root_dir') . '/modules/invoice ...@@ -45,6 +45,7 @@ $tabBox = new CTabBox( "?m=invoice", dPgetConfig('root_dir') . '/modules/invoice
$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->show(); $tabBox->show();
?> ?>
...@@ -46,6 +46,8 @@ function showtask_inv( &$a, $level=0 ) { ...@@ -46,6 +46,8 @@ 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
$invoice_status="Loss";
} }
$start_date=strftime($df,$a["invoice_date"]); $start_date=strftime($df,$a["invoice_date"]);
......
<?php
include("vw_inc.php");
echo invoices(3);
?>
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