home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / projects / book.inc < prev    next >
Encoding:
Text File  |  2004-03-08  |  8.7 KB  |  234 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13.  
  14. $time = get_time();
  15. $day = date("j", $time);
  16. $year = date("Y", $time);
  17. $month = date("m", $time);
  18.  
  19. $date = date($_SESSION['GO_SESSION']['date_format'], $time);
  20.  
  21. if (isset($_REQUEST['delete_hours']))
  22. {
  23.     $projects->delete_hours($_REQUEST['delete_hours']);
  24. }
  25.  
  26. ?>
  27. <input type="hidden" name="post_action" />
  28. <table border="0" cellpadding="0" cellspacing="0" height="300" width="100%">
  29. <tr>
  30.     <td class="TableInside" valign="top">
  31.     <?php
  32.     if (isset($feedback)) echo $feedback;
  33.  
  34.     if ($timer = $projects->get_timer($GO_SECURITY->user_id))
  35.     {
  36.         echo     '<table border="0" class="alert"><tr><td><img src="'.$GO_THEME->images['alert'].'" border="0" /></td>'.
  37.                 '<td><a class="normal" href="'.$_SERVER['PHP_SELF'].'?project_id='.$timer['project_id'].'&task=stop_timer">'.$pm_clocked_in.'</a></td></tr></table>';
  38.     }
  39.  
  40.     ?>
  41.     <table border="0" cellpadding="0" cellspacing="5" width="100%">
  42.     <?php
  43.     $pm_user_id = isset($_REQUEST['pm_user_id']) ? $_REQUEST['pm_user_id'] : $GO_SECURITY->user_id;
  44.     if ($GO_MODULES->write_permissions)
  45.     {
  46.         require_once($GO_CONFIG->class_path.'users.class.inc');
  47.         $users = new users();
  48.  
  49.         $ab_module = $GO_MODULES->get_module('addressbook');
  50.  
  51.         if ($pm_user_id > 0 && $user = $users->get_user($pm_user_id))
  52.         {
  53.             $middle_name = $user['middle_name'] == '' ? '' : $user['middle_name'].' ';
  54.             $user_name = $user['first_name'].' '.$middle_name.$user['last_name'];
  55.         }else
  56.         {
  57.             $user_name = isset($_REQUEST['user_name']) ? $_REQUEST['user_name'] : '';
  58.         }
  59.         echo '<tr><td><table border="0" cellpadding="0" cellspacing="0"><tr><td><a class="normal" href="javascript:popup(\''.$ab_module['url'].'select.php?users_only=true&multiselect=false&GO_HANDLER='.$GO_MODULES->url.'select_employer.php&pass_value=id\',\'550\',\'400\')"><img src="'.$GO_THEME->images['addressbook_small'].'" width="16" height="16" border="0" /></a> </td><td><a class="normal" href="javascript:popup(\''.$ab_module['url'].'select.php?users_only=true&multiselect=false&GO_HANDLER='.$GO_MODULES->url.'select_employer.php&pass_value=id\',\'550\',\'400\')">'.$pm_employee.'</a>: </td></tr></table></td>';
  60.         echo '<td><input type="hidden" value="'.$pm_user_id.'" name="pm_user_id" /><input type="hidden" value="'.$user_name.'" name="user_name" /><input type="text" name="user_name_text" class="textbox" style="width: 300px;" value="'.$user_name.'" disabled></td></tr>';
  61.  
  62.     }else
  63.     {
  64.         echo '<input type="hidden" name="pm_user_id" value="'.$GO_SECURITY->user_id.'" />';
  65.     }
  66.     ?>
  67.  
  68.  
  69.     <tr>
  70.         <td><?php echo $pm_starttime; ?>:</td>
  71.         <td>
  72.         <?php
  73.         $timer_start_date = isset($timer_start_time) ? date($_SESSION['GO_SESSION']['date_format'], $timer_start_time) : $date;
  74.         $start_date = isset($_POST['start_date']) ? $_POST['start_date'] : $timer_start_date;
  75.         $datepicker->print_date_picker('start_date', $_SESSION['GO_SESSION']['date_format'], $start_date);
  76.         echo ' ';
  77.         $hours = array("00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23", "24");
  78.         //$mins = array("00","15","30","45");
  79.         for ($i=0;$i<=60;$i++)
  80.         {
  81.             $text = strlen($i) < 2 ? '0'.$i : $i;
  82.             $mins[] = $text;
  83.         }
  84.         $hour = isset($timer_start_time) ? date('G', $timer_start_time) : 8;
  85.         $start_hour = isset($_POST['start_hour']) ? $_POST['start_hour'] : $hour;
  86.         $dropbox = new dropbox();
  87.         $dropbox->add_arrays($hours, $hours);
  88.         $dropbox->print_dropbox("start_hour", $start_hour);
  89.  
  90.         echo ' : ';
  91.         $min = isset($timer_start_time) ? date('i', $timer_start_time) : 0;
  92.         $start_min = isset($_POST['start_min']) ? $_POST['start_min'] : $min;
  93.         $dropbox = new dropbox();
  94.         $dropbox->add_arrays($mins, $mins);
  95.         $dropbox->print_dropbox("start_min", $start_min);
  96.         ?>
  97.         </td>
  98.         <td colspan="2">
  99.          
  100.         </td>
  101.     </tr>
  102.     <tr><td colspan="3"> </td></tr>
  103.     <tr>
  104.         <td colspan="2">
  105.         <?php
  106.         $_COOKIE['registration_method_cookie'] = isset($_COOKIE['registration_method_cookie']) ? $_COOKIE['registration_method_cookie'] : 'endtime';
  107.         $registration_method = isset($_POST['registration_method']) ? $_POST['registration_method'] : $_COOKIE['registration_method_cookie'];
  108.  
  109.         if ($registration_method == 'units')
  110.         {
  111.             $unit_check = 'checked';
  112.             $endtime_check = '';
  113.         }else
  114.         {
  115.             $unit_check = '';
  116.             $endtime_check = 'checked';
  117.         }
  118.         ?>
  119.         <input type="radio" name="registration_method" value="endtime" onclick="javascript:toggle_registration_method(this.value)" <?php echo $endtime_check; ?> /><?php echo $pm_endtime; ?>
  120.         </td>
  121.         <td colspan="2">
  122.         <input type="radio" name="registration_method" value="units" onclick="javascript:toggle_registration_method(this.value)" <?php echo $unit_check; ?> /><?php echo $pm_units; ?>
  123.         </td>
  124.     </tr>
  125.  
  126.     <tr>
  127.         <td><?php echo $pm_endtime; ?>:</td>
  128.         <td>
  129.         <?php
  130.         $timer_end_date = isset($timer_end_time) ? date($_SESSION['GO_SESSION']['date_format'], $timer_end_time) : $date;
  131.         $end_date = isset($_POST['end_date']) ? $_POST['end_date'] : $timer_end_date;
  132.         $datepicker->print_date_picker('end_date', $_SESSION['GO_SESSION']['date_format'], $end_date);
  133.         echo ' ';
  134.         $hour = isset($timer_end_time) ? date('G', $timer_end_time) : 17;
  135.         $end_hour = isset($_POST['end_hour']) ? $_POST['end_hour'] : $hour;
  136.         $dropbox = new dropbox();
  137.         $dropbox->add_arrays($hours, $hours);
  138.         $dropbox->print_dropbox("end_hour", $end_hour);
  139.  
  140.         echo ' : ';
  141.         $min = isset($timer_end_time) ? date('i', $timer_end_time) : 0;
  142.         $end_min = isset($_POST['end_min']) ? $_POST['end_min'] : $min;
  143.         $dropbox = new dropbox();
  144.         $dropbox->add_arrays($mins, $mins);
  145.         $dropbox->print_dropbox("end_min", $end_min);
  146.         ?>
  147.         </td>
  148.         <td>
  149.         <?php echo $pm_value; ?>:
  150.         </td>
  151.         <td>
  152.         <?php
  153.         $_COOKIE['unit_value_cookie'] = isset($_COOKIE['unit_value_cookie']) ? $_COOKIE['unit_value_cookie'] : '';
  154.         $unit_value = isset($_POST['unit_value']) ? $_POST['unit_value'] : $_COOKIE['unit_value_cookie'];
  155.         $dropbox = new dropbox();
  156.         for ($i=1;$i<=60;$i++)
  157.         {
  158.             $dropbox->add_value($i,$i);
  159.         }
  160.         $dropbox->print_dropbox('unit_value', $unit_value);
  161.         echo ' '.$pm_mins;
  162.         ?>
  163.         </td>
  164.     </tr>
  165.     <tr>
  166.         <td><?php echo $pm_breaktime; ?>:</td>
  167.         <td>
  168.         <?php
  169.         $break_hours = isset($_POST['break_hours']) ? $_POST['break_hours'] : 0;
  170.         $dropbox = new dropbox();
  171.         $dropbox->add_arrays($hours, $hours);
  172.         $dropbox->print_dropbox("break_hours", $break_hours);
  173.  
  174.         echo ' : ';
  175.         $break_mins = isset($_POST['break_mins']) ? $_POST['break_mins'] : 0;
  176.         $dropbox = new dropbox();
  177.         $dropbox->add_arrays($mins, $mins);
  178.         $dropbox->print_dropbox("break_mins", $break_mins);
  179.         ?>
  180.         </td>
  181.         <td>
  182.         <?php echo $pm_units; ?>:
  183.         </td>
  184.         <td>
  185.         <?php
  186.         $units = isset($_POST['units']) ? $_POST['units'] : '';
  187.         ?>
  188.         <input type="text" name="units" value="<?php echo $units; ?>" class="textbox" size="4" />
  189.         </td>
  190.     </tr>
  191.     <tr><td colspan="3"> </td></tr>
  192.     <tr>
  193.         <td valign="top"><?php echo $strComments; ?>:</td>
  194.         <td colspan="3">
  195.         <textarea class="textbox" name="comments" cols="40" rows="4"><?php if (isset($_POST['comments'])) echo $_POST['comments']; ?></textarea>
  196.         </td>
  197.     </tr>
  198.     <?php
  199.     echo '<tr><td colspan="4">';
  200.     $button = new button($cmdOk,"javascript:_save('save_hours', 'true')");
  201.     echo '  ';
  202.     $button = new button($cmdApply,"javascript:_save('save_hours', 'false')");
  203.     echo '  ';
  204.     $button = new button($cmdClose, "javascript:document.location='".$return_to."';");
  205.     echo '</td></tr>';
  206.     ?>
  207.     </table>
  208.     </td>
  209. </tr>
  210. </table>
  211.  
  212. <script type="text/javascript" language="javascript">
  213. function toggle_registration_method(registration_method)
  214. {
  215.     if (registration_method == "endtime")
  216.     {
  217.         document.projects_form.unit_value.disabled = true;
  218.         document.projects_form.units.disabled = true;
  219.         document.projects_form.end_hour.disabled = false;
  220.         document.projects_form.end_date.disabled = false;
  221.         document.projects_form.end_min.disabled = false;
  222.         document.projects_form.break_hours.disabled = false;
  223.         document.projects_form.break_mins.disabled = false;
  224.     }else
  225.     {
  226.         document.projects_form.unit_value.disabled = false;
  227.         document.projects_form.units.disabled = false;
  228.         document.projects_form.end_date.disabled = true;
  229.         document.projects_form.end_hour.disabled = true;
  230.         document.projects_form.end_min.disabled = true;
  231.         document.projects_form.break_hours.disabled = true;
  232.         document.projects_form.break_mins.disabled = true;
  233.     }
  234. }
  235. toggle_registration_method("<?php echo $registration_method; ?>");
  236. </script>