[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/tasks/ -> ae_dates.php (source)

   1  <?php /* $Id: ae_dates.php 135 2008-04-04 13:49:13Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/tasks/ae_dates.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  // $Id: ae_dates.php 135 2008-04-04 13:49:13Z pedroix $

   7  
   8  global $AppUI, $w2Pconfig, $task_parent_options, $loadFromTab;
   9  global $can_edit_time_information, $locale_char_set, $obj;
  10  global $durnTypes, $task_project, $task_id, $tab;
  11  global $cal_sdf;
  12  $AppUI->loadCalendarJS();
  13  
  14  //Time arrays for selects

  15  $start = intval(w2PgetConfig('cal_day_start'));
  16  $end = intval(w2PgetConfig('cal_day_end'));
  17  $inc = intval(w2PgetConfig('cal_day_increment'));
  18  if ($start === null)
  19      $start = 8;
  20  if ($end === null)
  21      $end = 17;
  22  if ($inc === null)
  23      $inc = 15;
  24  $hours = array();
  25  for ($current = $start; $current < $end + 1; $current++) {
  26      if ($current < 10) {
  27          $current_key = "0" . $current;
  28      } else {
  29          $current_key = $current;
  30      }
  31  
  32      if (stristr($AppUI->getPref('TIMEFORMAT'), '%p')) {
  33          //User time format in 12hr

  34          $hours[$current_key] = ($current > 12 ? $current - 12 : $current);
  35      } else {
  36          //User time format in 24hr

  37          $hours[$current_key] = $current;
  38      }
  39  }
  40  
  41  $minutes = array();
  42  $minutes['00'] = '00';
  43  for ($current = 0 + $inc; $current < 60; $current += $inc) {
  44      $minutes[$current] = $current;
  45  }
  46  
  47  // format dates

  48  $df = $AppUI->getPref('SHDATEFORMAT');
  49  
  50  if (intval($obj->task_start_date)) {
  51      $start_date = new CDate($obj->task_start_date);
  52  } elseif ($task_id != 0) {
  53      $start_date = null;
  54  } else {
  55      $start_date = new CDate();
  56  }
  57  //$start_date = intval( $obj->task_start_date ) ? new CDate( $obj->task_start_date ) : new CDate();

  58  $end_date = intval($obj->task_end_date) ? new CDate($obj->task_end_date) : null;
  59  
  60  // convert the numeric calendar_working_days config array value to a human readable output format

  61  $cwd = explode(',', $w2Pconfig['cal_working_days']);
  62  
  63  $cwd_conv = array_map('cal_work_day_conv', $cwd);
  64  $cwd_hr = implode(', ', $cwd_conv);
  65  
  66  function cal_work_day_conv($val) {
  67      global $locale_char_set, $AppUI;
  68      setlocale(LC_TIME, 'en');
  69      $wk = Date_Calc::getCalendarWeek(null, null, null, '%a', LOCALE_FIRST_DAY);
  70      setlocale(LC_ALL, $AppUI->user_lang);
  71  
  72      $day_name = $AppUI->_($wk[($val - LOCALE_FIRST_DAY) % 7]);
  73      if ($locale_char_set == 'utf-8' && function_exists('utf8_encode')) {
  74          $day_name = utf8_encode($day_name);
  75      }
  76      return htmlentities($day_name, ENT_COMPAT, $locale_char_set);
  77  }
  78  ?>
  79  
  80  <script language="javascript">
  81  function setDate( frm_name, f_date ) {
  82      fld_date = eval( 'document.' + frm_name + '.' + f_date );
  83      fld_real_date = eval( 'document.' + frm_name + '.' + 'task_' + f_date );
  84      if (fld_date.value.length>0) {
  85        if ((parseDate(fld_date.value))==null) {
  86              alert('The Date/Time you typed does not match your prefered format, please retype.');
  87              fld_real_date.value = '';
  88              fld_date.style.backgroundColor = 'red';
  89          } else {
  90              fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
  91              fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
  92              fld_date.style.backgroundColor = '';
  93            }
  94      } else {
  95            fld_real_date.value = '';
  96      }
  97  }
  98  </script>
  99  
 100  <form name="datesFrm" action="?m=tasks&a=addedit&task_project=<?php echo $task_project; ?>" method="post">
 101  <input name="dosql" type="hidden" value="do_task_aed" />
 102  <input name="task_id" type="hidden" value="<?php echo $task_id; ?>" />
 103  <input name="sub_form" type="hidden" value="1" />
 104  <table width="100%" border="0" cellpadding="4" cellspacing="0" class="std">
 105  <?php
 106  if ($can_edit_time_information) {
 107  ?>
 108  <tr>
 109      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Start Date'); ?></td>
 110      <td nowrap="nowrap">
 111          <input type='hidden' id='task_start_date' name='task_start_date' value='<?php echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : ''; ?>' />
 112          <input type='text' onchange="setDate('datesFrm', 'start_date');" class='text' style='width:120px;' id='start_date' name='start_date' value='<?php echo $start_date ? $start_date->format($df) : ''; ?>' />
 113          <a onclick="return showCalendar('start_date', '<?php echo $df ?>', 'datesFrm', null, true)" href="javascript: void(0);">
 114              <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
 115          </a>
 116      </td>
 117      <td>
 118          <table><tr>
 119                          
 120      <?php
 121      echo '<td>' . arraySelect($hours, 'start_hour', 'size="1" onchange="setAMPM(this)" class="text"', $start_date ? $start_date->getHour() : $start) . '</td><td> : </td>';
 122      echo '<td>' . arraySelect($minutes, 'start_minute', 'size="1" class="text"', $start_date ? $start_date->getMinute() : '0') . '</td>';
 123      if (stristr($AppUI->getPref('TIMEFORMAT'), '%p')) {
 124          echo '<td><input type="text" name="start_hour_ampm" id="start_hour_ampm" value="' . ($start_date ? $start_date->getAMPM() : ($start > 11 ? 'pm' : 'am')) . '" disabled="disabled" class="text" size="2" /></td>';
 125      }
 126  ?>
 127          </tr></table>
 128      </td>
 129  </tr>
 130  <tr>
 131      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Finish Date'); ?></td>
 132      <td nowrap="nowrap">
 133          <input type='hidden' id='task_end_date' name='task_end_date' value='<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : ''; ?>' />
 134          <input type='text' onchange="setDate('datesFrm', 'end_date');" class='text' style='width:120px;' id='end_date' name='end_date' value='<?php echo $end_date ? $end_date->format($df) : ''; ?>' />
 135          <a onclick="return showCalendar('end_date', '<?php echo $df ?>', 'datesFrm', null, true)" href="javascript: void(0);">
 136              <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
 137          </a>
 138      </td>
 139          <td>
 140  <table><tr>
 141      <?php
 142      echo '<td>' . arraySelect($hours, 'end_hour', 'size="1" onchange="setAMPM(this)" class="text"', $end_date ? $end_date->getHour() : $end) . '</td><td> : </td>';
 143      echo '<td>' . arraySelect($minutes, 'end_minute', 'size="1" class="text"', $end_date ? $end_date->getMinute() : '00') . '</td>';
 144      if (stristr($AppUI->getPref('TIMEFORMAT'), '%p')) {
 145          echo '<td><input type="text" name="end_hour_ampm" id="end_hour_ampm" value="' . ($end_date ? $end_date->getAMPM() : ($end > 11 ? 'pm' : 'am')) . '" disabled="disabled" class="text" size="2" /></td>';
 146      }
 147  ?>
 148      </tr></table>
 149      </td>
 150  </tr>
 151  <tr>
 152      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Expected Duration'); ?>:</td>
 153      <td nowrap="nowrap">
 154          <input type="text" class="text" name="task_duration" maxlength="8" size="6" value="<?php echo isset($obj->task_duration) ? $obj->task_duration : 1; ?>" />
 155      <?php
 156      echo arraySelect($durnTypes, 'task_duration_type', 'class="text"', $obj->task_duration_type, true);
 157  ?>
 158      </td>
 159      <td><?php echo $AppUI->_('Daily Working Hours') . ': ' . $w2Pconfig['daily_working_hours']; ?></td>
 160  
 161  </tr>
 162  <tr>
 163      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Calculate'); ?>:</td>
 164      <td nowrap="nowrap">
 165          <input type="button" value="<?php echo $AppUI->_('Duration'); ?>" onclick="calcDuration(document.datesFrm)" class="button" />
 166          <input type="button" value="<?php echo $AppUI->_('Finish Date'); ?>" onclick="calcFinish(document.datesFrm)" class="button" />
 167      </td>
 168      <td><?php echo $AppUI->_('Working Days') . ': ' . $cwd_hr; ?></td>
 169  </tr>
 170          <?php
 171  } else {
 172  ?>
 173  <tr>
 174          <td colspan='2'>
 175                  <?php echo $AppUI->_('Only the task owner, project owner, or system administrator is able to edit time related information.'); ?>
 176          </td>
 177  </tr>
 178          <?php
 179  } // end of can_edit_time_information

 180  
 181  ?>
 182  </table>
 183  </form>
 184  <script language="javascript">
 185      subForm.push(new FormDefinition(<?php echo $tab; ?>, document.datesFrm, checkDates, saveDates));
 186  </script>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7