home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / tasks / vw_log_update.php < prev    next >
Encoding:
PHP Script  |  2003-12-17  |  5.7 KB  |  175 lines

  1. <?php /* TASKS $Id: vw_log_update.php,v 1.11 2003/12/17 02:03:38 robertoibarra Exp $ */
  2. GLOBAL $AppUI, $task_id, $obj, $percent;
  3.  
  4. // check permissions
  5. $canEdit = !getDenyEdit( 'tasks', $task_id );
  6. if (!$canEdit) {
  7.     $AppUI->redirect( "m=public&a=access_denied" );
  8. }
  9.  
  10. $task_log_id = intval( dPgetParam( $_GET, 'task_log_id', 0 ) );
  11. $log = new CTaskLog();
  12. if ($task_log_id) {
  13.     $log->load( $task_log_id );
  14. } else {
  15.     $log->task_log_task = $task_id;
  16.     $log->task_log_name = $obj->task_name;
  17. }
  18.  
  19. // Lets check which cost codes have been used before
  20. $sql = "select distinct task_log_costcode
  21.         from task_log
  22.         where task_log_costcode != ''
  23.         order by task_log_costcode";
  24. $task_log_costcodes = array(""); // Let's add a blank default option
  25. $task_log_costcodes = array_merge($task_log_costcodes, db_loadColumn($sql));
  26.  
  27.  
  28. if ($canEdit) {
  29. // Task Update Form
  30.     $df = $AppUI->getPref( 'SHDATEFORMAT' );
  31.     $log_date = new CDate( $log->task_log_date );
  32.  
  33.     if ($task_log_id) {
  34.         echo $AppUI->_( "Edit Log" );
  35.     } else {
  36.         echo $AppUI->_( "Add Log" );
  37.     }
  38. ?>
  39.  
  40. <!-- TIMER RELATED SCRIPTS -->
  41. <script language="JavaScript">
  42.     // please keep these lines on when you copy the source
  43.     // made by: Nicolas - http://www.javascript-page.com
  44.     // adapted by: Juan Carlos Gonzalez jcgonz@users.sourceforge.net
  45.     
  46.     var timerID       = 0;
  47.     var tStart        = null;
  48.     var total_minutes = -1;
  49.     
  50.     function UpdateTimer() {
  51.        if(timerID) {
  52.           clearTimeout(timerID);
  53.           clockID  = 0;
  54.        }
  55.     
  56.        // One minute has passed
  57.        total_minutes = total_minutes+1;
  58.        
  59.        document.getElementById("timerStatus").innerHTML = "( "+total_minutes+" <?php echo $AppUI->_('minutes elapsed'); ?> )";
  60.  
  61.        // Lets round hours to two decimals
  62.        var total_hours   = Math.round( (total_minutes / 60) * 100) / 100;
  63.        document.editFrm.task_log_hours.value = total_hours;
  64.        
  65.        timerID = setTimeout("UpdateTimer()", 60000);
  66.     }
  67.     
  68.     function timerStart() {
  69.         if(!timerID){ // this means that it needs to be started
  70.             document.editFrm.timerStartStopButton.value = "<?php echo $AppUI->_('Stop');?>";
  71.             UpdateTimer();
  72.         } else { // timer must be stoped
  73.             document.editFrm.timerStartStopButton.value = "<?php echo $AppUI->_('Start');?>";
  74.             document.getElementById("timerStatus").innerHTML = "";
  75.             timerStop();
  76.         }
  77.     }
  78.     
  79.     function timerStop() {
  80.        if(timerID) {
  81.           clearTimeout(timerID);
  82.           timerID  = 0;
  83.           total_minutes = total_minutes-1;
  84.        }
  85.     }
  86.     
  87.     function timerReset() {
  88.         document.editFrm.task_log_hours.value = "0.00";
  89.         total_minutes = -1;
  90.     }
  91.     
  92. </script>
  93. <!-- END OF TIMER RELATED SCRIPTS -->
  94.  
  95.  
  96. <table cellspacing="1" cellpadding="2" border="0" width="100%">
  97. <form name="editFrm" action="?m=tasks&a=view&task_id=<?php echo $task_id;?>" method="post">
  98.     <input type="hidden" name="uniqueid" value="<?php echo uniqid("");?>" />
  99.     <input type="hidden" name="dosql" value="do_updatetask" />
  100.     <input type="hidden" name="task_log_id" value="<?php echo $log->task_log_id;?>" />
  101.     <input type="hidden" name="task_log_task" value="<?php echo $log->task_log_task;?>" />
  102.     <input type="hidden" name="task_log_creator" value="<?php echo $AppUI->user_id;?>" />
  103.     <input type="hidden" name="task_log_name" value="Update :<?php echo $log->task_log_name;?>" />
  104. <tr>
  105.     <td align="right">
  106.         <?php echo $AppUI->_('Date');?>
  107.     </td>
  108.     <td nowrap="nowrap">
  109.         <input type="hidden" name="task_log_date" value="<?php echo $log_date->format( FMT_TIMESTAMP_DATE );?>">
  110.         <input type="text" name="log_date" value="<?php echo $log_date->format( $df );?>" class="text" disabled="disabled">
  111.         <a href="#" onClick="popCalendar('log_date')">
  112.             <img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar');?>" border="0" />
  113.         </a>
  114.     </td>
  115.     <td align="right"><?php echo $AppUI->_('Summary');?>:</td>
  116.     <td>
  117.         <input type="text" class="text" name="task_log_name" value="<?php echo $log->task_log_name;?>" maxlength="255" size="30" />
  118.     </td>
  119. </tr>
  120. <tr>
  121.     <td align="right"><?php echo $AppUI->_('Progress');?></td>
  122.     <td>
  123.         <table>
  124.            <tr>
  125.               <td>
  126. <?php
  127.     echo arraySelect( $percent, 'task_percent_complete', 'size="1" class="text"', $obj->task_percent_complete ) . '%';
  128. ?>
  129.               </td>
  130.               <td valign="middle" >
  131.             <?php
  132.                 if ( $obj->task_owner != $AppUI->user_id ){
  133.                     echo "<input type='checkbox' name='task_log_notify_owner' /></td><td valign='middle'>" . $AppUI->_('Notify creator');    
  134.                 }
  135.             ?>             
  136.              </td>
  137.            </tr>
  138.         </table>
  139.     </td>
  140.     <td rowspan="3" align="right" valign="top"><?php echo $AppUI->_('Description');?>:</td>
  141.     <td rowspan="3">
  142.         <textarea name="task_log_description" class="textarea" cols="50" rows="6"><?php echo $log->task_log_description;?></textarea>
  143.     </td>
  144. </tr>
  145. <tr>
  146.     <td align="right">
  147.         <?php echo $AppUI->_('Hours Worked');?>
  148.     </td>
  149.     <td>
  150.         <input type="text" class="text" name="task_log_hours" value="<?php echo $log->task_log_hours;?>" maxlength="8" size="6" /> 
  151.         <input type='button' class="button" value='<?php echo $AppUI->_('Start');?>' onclick='javascript:timerStart()' name='timerStartStopButton' />
  152.         <input type='button' class="button" value='<?php echo $AppUI->_('Reset'); ?>' onclick="javascript:timerReset()" name='timerResetButton' /> 
  153.         <span id='timerStatus'></span>
  154.     </td>
  155. </tr>
  156. <tr>
  157.     <td align="right">
  158.         <?php echo $AppUI->_('Cost Code');?>
  159.     </td>
  160.     <td>
  161. <?php
  162.         echo arraySelect( $task_log_costcodes, 'task_log_costcodes', 'size="1" class="text" onchange="javascript:task_log_costcode.value = this.options[this.selectedIndex].text;"', '' );
  163. ?>
  164.          ->  <input type="text" class="text" name="task_log_costcode" value="<?php echo $log->task_log_costcode;?>" maxlength="8" size="8" />
  165.     </td>
  166. </tr>
  167. <tr>
  168.     <td colspan="4" valign="bottom" align="right">
  169.         <input type="button" class="button" value="<?php echo $AppUI->_('update task');?>" onclick="updateTask()" />
  170.     </td>
  171. </tr>
  172.  
  173. </form>
  174. </table>
  175. <?php } ?>