Hi all
i am using dotproject in timesheet module the index page will display timesheetstartscreen.jpeg and when i press add timesheetadd.jpeg screen will display so in the timesheet add screen the date is displaying 01,january,1970 please see my code below addedit.php
the following code is dotproject/modules/timesheet/addedit.php
<?php /* Timesheet $Id: [B]addedit.php[/B],v 0.8 2005/03/30 Leon Schmets, leon@fsvproducts.nl*/
$date = intval( dPgetParam( $_GET, "date", 0 ) );
echo $_GET['date'];
#echo $date; die;
$first_time = new CDate($date);
$first_time->setTime( 0, 0, 0 );
$last_time = new CDate($date);
$last_time->setTime( 23, 59, 59 );
$prev_day = new CDate( Date_calc::prevDay( $first_time->day, $first_time->month, $first_time->year, FMT_TIMESTAMP_DATE ) );
$next_day = new CDate( Date_calc::nextDay( $first_time->day, $first_time->month, $first_time->year, FMT_TIMESTAMP_DATE ) );
$timesheet = new CTimesheet ( $first_time, $last_time );
$timlist = $timesheet->get( );
$tasklist = $timesheet->projectsAndTasks();
$ttl = $timesheet_id > 0 ? "Edit timesheet entry" : "New timesheet entry";
$titleBlock = new CTitleBlock( $ttl, 'clock.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=timesheet", "timesheet home" );
if ($canEdit && $einstein_id > 0) {
$titleBlock->addCrumbDelete( 'delete entry', $canDelete, $msg ); }
$titleBlock->show();
?>
<script language="javascript">
function submitIt(redirect_to) {
var f = document.editFrm;
if (redirect_to != '') {
f.redirect_to.value = redirect_to;
}
f.submit();
}
function delIt() {
if (confirm( "<?php echo $AppUI->_('Really delete this entry?');?>" )) { var f = document.listFrm;
f.del.value='1';
f.submit();
}
}
</script>
<?php
?>
<style type="text/css">
TR.modify {}
TR.header {
}
TR.spacer {
height: 1px;
}
TD.list {
padding: 1px 4px 1px 4px;
border-bottom: 1px solid #ccc;
border-right: 1px solid #ccc;
text-align: left;
}
TD.total {
font-weight: bold;
font-size: 9pt;
}
SELECT.tp {
font-size: 10px;
width: 100%;
}
INPUT.co {
font-size: 10px;
width: 100%;
}
</style>
<table cellspacing="0" cellpadding="1" border="1" width="100%">
<tr>
<td>
<a href="<?php echo '?m=timesheet&a=addedit&date='.$prev_day->format( FMT_TIMESTAMP_DATE ); ?>"><img src="images/prev.gif" width="16" height="16" alt="pre" border="0"></a>
</td>
<th width="100%" align="center">
<?php echo $first_time->format( "%A, %d %B %Y" ); ?>
</th>
<td>
<a href="<?php echo '?m=timesheet&a=addedit&date='.$next_day->format( FMT_TIMESTAMP_DATE ); ?>"><img src="images/next.gif" width="16" height="16" alt="next" border="0"></a>
</td>
</tr>
<tr class="spacer"><td colspan=3></td></tr>
</table>
<table id="ptlist" cellspacing="0" cellpadding="0" border="0" width="100%" class="tbl">
<form name="editFrm" action="./index.php?m=timesheet" method="post">
<!-- <form name="editFrm" action="./debug.php" method="post">
-->
<?php
?>
<input type="hidden" name="dosql" value="do_timesheet_aed" />
<input type="hidden" name="user_id" value="<?php echo $timesheet->user_id; ?>" />
<input type="hidden" name="first_time" value="<?php echo $first_time->format( FMT_TIMESTAMP ); ?>" />
<input type="hidden" name="last_time" value="<?php echo $last_time->format( FMT_TIMESTAMP ); ?>" />
<input type="hidden" name="redirect_to" value="m=timesheet" />
<tr><th width="35%"><?php echo $AppUI->_('Task name (Project name)'); ?></th><th width="50%"><?php echo $AppUI->_('Comment'); ?></th><th colspan=2><?php echo $AppUI->_('hours'); ?></th></tr>
<tr class="spacer"><td colspan="4" height="1" class="list"></td></tr>
<?php
$tplist = '<option selected value="NULL">'.$AppUI->_('--- Select a task from a project here ---').'</option>';
reset($tasklist);
while(list($inx,$tp) = each($tasklist)) {
$tplist .= '<option value="'.$tp['id'].'">'.$inx.'</option>';
}
$tvlist = '<option selected value="NULL"> </option>';
for ($i = 30; $i <990; $i +=30) {
$tvlist .= '<option value="'.$i.'">'.trim(($i/60)).'</option>';
}
$entry = new CTimeEntry();
$total = 0;
$index = 0;
reset($timlist);
while (list($key, $entry) = each($timlist)) {
extract($entry->get());
$total += $timmin;
if ($timstat == TIME_ENTRY_FROZEN) {
$s .= '<tr><td class="list">'.$timtname.' ('.$timpname.')</td>';
$s .= ($timcom) ? '<td class="list">'.$timcom.'</td>' : '<td class="list">'." ".'</td>';
$s .= '<td class="list">'.($timmin / 60) . '</td>';
$s .= '<td class="list"> </td></tr>';
}
else {
$s .= '<tr><td class="list"><select class="tp" name="tp_'.$index.'">';
reset($tasklist);
while (list ($inx,$tp) = each ($tasklist)) {
$s .= ($inx == $timtname.' ('.$timpname.')') ? '<option selected ' : '<option ';
$s .= 'value="'.$tp['id'].'">'.$inx.'</option>';
}
$s .= '</selected></td>';
$s .= '<td class="list"><input class="co" type="text" name="c_'.$index.'" value="'.$timcom.'" /></td>';
$s .= '<td class="list"><select class="tp" name="m_'.$index.'">';
for ($i = 0; $i <990; $i +=30) {
$s .= ($i == $timmin) ? '<option selected ' : '<option ';
$s .= 'value="'.$i.'">'.($i/60).'</option>';
}
$s .= '</selected></td>';
$s .= '<td class="list"><input type="checkbox" name="del_'.$index.'"><img src="./images/icons/stock_delete-16.png" width="16" height="16" alt="" border="0" />';
$s .= '<input type="hidden" name="timid_'.$index.'" value="'.$timid.'" /></td></tr>';
}
$index++;
}
while ($index < TIME_ENTRY_MAX_PER_DAY) {
$s .= '<tr><td class="list"><select class="tp" name="tp_'.$index.'">'.$tplist.'</select></td>';
$s .= '<td class="list"><input class="co" type="text" name="c_'.$index.'" /></td>';
$s .= '<td class="list"><select class="tp" name="m_'.$index.'">'.$tvlist.'</select></td>';
$s .= '<td class="list"> <input type="image" src="./images/icons/stock_delete-16.png" width="16" height="16" alt="" border="0"'.
'onclick="javaScript:tp_'.$index.'.selectedIndex=0;c_'.$index.'.value=\'\';m_'.$index.'.selectedIndex=0;return false;" />';
$s .= '<input type="hidden" name="timid_'.$index.'" value="0" /></td></tr>';
$index++;
}
$s .= '<tr><td> </td><td class="total" align="right">Total </td><td class="total"> '.($total/60).'</td><td> </td></tr>';
echo $s;
?>
</form>
</table>
<table width="100%">
<tr>
<td align="right">
<input class="button" type="button" name="cancel" value="<?php echo $AppUI->_('cancel');?>" onClick="javascript:if(confirm('Are you sure you want to cancel.')){location.href = './index.php?m=timesheet&<?php echo SID ?>';}" />
</td>
<td align="right">
<input class="button" type="submit" name="btnFuseAction" value="<?php echo $AppUI->_('submit and move to next day');?>" onClick="javascript:submitIt('<?php echo 'm=timesheet&a=addedit&date='.$next_day->format( FMT_TIMESTAMP_DATE ); ?>');" />
</td>
<td align="right">
<input class="button" type="submit" name="btnFuseAction" value="<?php echo $AppUI->_('submit');?>" onClick="javascript:submitIt('');" />
</td>
</tr>
</table>
the following code dotproject/modules/timesheet/index.php
<?php /* Timesheet $Id: index.php,v 0.8 2005/03/30 Leon Schmets, leon@fsvproducts.nl*/
$canRead = !getDenyRead( $m ); // retrieve module-based readPermission bool flag
$canEdit = !getDenyEdit( $m ); // retrieve module-based writePermission bool flag
if (!$canRead) { // lock out users that do not have at least readPermission on this module
$AppUI->redirect( "m=public&a=access_denied" );
}
$AppUI->savePlace(); //save the workplace state (have a footprint on this site)
if (isset( $_GET['tab'] )) {
$AppUI->setState( 'TimesheetIdxTab', $_GET['tab'] ); // saves the current tab box state
}
$tab = $AppUI->getState( 'TimesheetIdxTab' ) !== NULL ? $AppUI->getState( 'TimesheetIdxTab' ) : 0; // use first tab if no info is available
$active = intval( !$AppUI->getState( 'TimesheetIdxTab' ) );
$titleBlock = new CTitleBlock( 'Timesheet', 'clock.png', $m, "$m.$a" ); // load the icon automatically from ./images/
$titleBlock->addCell();
$today = date("D M j Y");
if ($canEdit) {
$titleBlock->addCell(
'<input type="submit" class="button" value="'.$AppUI->_('Add').'">', '',
'<form action="?m=timesheet&a=addedit" method="post">', '</form>' //call addedit.php in case of mouseclick
);
}
$titleBlock->show(); $tabBox = new CTabBox( "?m=timesheet", "{$dPconfig['root_dir']}/modules/timesheet/", $tab );
$tabBox->add( 'view', 'Week' ); // add a subsite vw_idx_about.php to the tab box object with title 'About Albert'
$tabBox->add( 'reports' , 'Reports' ); // add another subsite to the tab box object
$tabBox->add( 'admin' , 'Admin' ); // add another subsite to the tab box object
$tabBox->show(); ?>