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