[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/reports/reports/ -> taskenddate.php (source)

   1  <?php /* $Id: taskenddate.php 136 2008-04-04 14:24:17Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/reports/reports/taskenddate.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  global $AppUI, $cal_sdf;
   6  $AppUI->loadCalendarJS();
   7  
   8  $do_report = w2PgetParam($_POST, 'do_report', 0);
   9  $log_start_date = w2PgetParam($_POST, 'log_start_date', 0);
  10  $log_end_date = w2PgetParam($_POST, 'log_end_date', 0);
  11  $user_id = w2PgetParam($_POST, 'user_id', $AppUI->user_id);
  12  
  13  // create Date objects from the datetime fields

  14  $start_date = intval($log_start_date) ? new CDate($log_start_date) : new CDate();
  15  $end_date = intval($log_end_date) ? new CDate($log_end_date) : new CDate();
  16  
  17  if (!$log_start_date) {
  18      $start_date->subtractSpan(new Date_Span('14,0,0,0'));
  19  }
  20  $end_date->setTime(23, 59, 59);
  21  ?>
  22  
  23  <script language="javascript">
  24  function setDate( frm_name, f_date ) {
  25      fld_date = eval( 'document.' + frm_name + '.' + f_date );
  26      fld_real_date = eval( 'document.' + frm_name + '.' + 'log_' + f_date );
  27      if (fld_date.value.length>0) {
  28        if ((parseDate(fld_date.value))==null) {
  29              alert('The Date/Time you typed does not match your prefered format, please retype.');
  30              fld_real_date.value = '';
  31              fld_date.style.backgroundColor = 'red';
  32          } else {
  33              fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
  34              fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
  35              fld_date.style.backgroundColor = '';
  36            }
  37      } else {
  38            fld_real_date.value = '';
  39      }
  40  }
  41  </script>
  42  
  43  <form name="editFrm" action="index.php?m=reports" method="post">
  44  <input type="hidden" name="project_id" value="<?php echo $project_id; ?>" />
  45  <input type="hidden" name="report_type" value="<?php echo $report_type; ?>" />
  46  <?php
  47  if (function_exists('styleRenderBoxTop')) {
  48      echo styleRenderBoxTop();
  49  }
  50  ?>
  51  <table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
  52  <tr>
  53      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('For period'); ?>:</td>
  54      <td nowrap="nowrap">
  55          <input type="hidden" name="log_start_date" id="log_start_date" value="<?php echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
  56          <input type="text" name="start_date" id="start_date" onchange="setDate('editFrm', 'start_date');" value="<?php echo $start_date ? $start_date->format($df) : ''; ?>" class="text" />
  57          <a href="javascript: void(0);" onclick="return showCalendar('start_date', '<?php echo $df ?>', 'editFrm', null, true)">
  58              <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
  59          </a>
  60      </td>
  61      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('to'); ?></td>
  62      <td nowrap="nowrap">
  63          <input type="hidden" name="log_end_date" id="log_end_date" value="<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
  64          <input type="text" name="end_date" id="end_date" onchange="setDate('editFrm', 'end_date');" value="<?php echo $end_date ? $end_date->format($df) : ''; ?>" class="text" />
  65          <a href="javascript: void(0);" onclick="return showCalendar('end_date', '<?php echo $df ?>', 'editFrm', null, true)">
  66              <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
  67          </a>
  68      </td>
  69  
  70      <td nowrap='nowrap'>
  71         <?php
  72  $users = w2PgetUsers();
  73  echo arraySelect($users, 'user_id', 'class="text"', $user_id);
  74  ?>
  75      </td>
  76      
  77      <td align="right" width="50%" nowrap="nowrap">
  78          <input class="button" type="submit" name="do_report" value="<?php echo $AppUI->_('submit'); ?>" />
  79      </td>
  80  </tr>
  81  </table>
  82  </form>
  83  <?php
  84  if ($do_report) {
  85  
  86      $q = new DBQuery;
  87      $q->addTable('tasks', 't');
  88      $q->addTable('users', 'u');
  89      $q->addTable('projects', 'p');
  90      $q->addQuery('t.*, p.project_name, u.user_username');
  91      $q->addQuery('CONCAT(contact_first_name, \' \', contact_last_name) AS user_username');
  92      $q->leftJoin('contacts', 'ct', 'ct.contact_id = u.user_contact');
  93      $q->addWhere('p.project_active = 1');
  94      if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
  95          $q->addWhere('p.project_status <> ' . (int)$template_status);
  96      }
  97  
  98      if ($user_id > 0) {
  99          $q->addTable('user_tasks', 'ut');
 100          $q->addWhere('ut.user_id =' . $user_id);
 101          $q->addWhere('ut.task_id = t.task_id');
 102      }
 103  
 104      if ($project_id != 0) {
 105          $q->addWhere('task_project =' . $project_id);
 106      }
 107  
 108      $q->addWhere('p.project_id   = t.task_project');
 109      $q->addWhere('t.task_dynamic = 0');
 110      $q->addWhere('t.task_owner = u.user_id');
 111      $q->addWhere('task_end_date >= \'' . $start_date->format(FMT_DATETIME_MYSQL) . '\'');
 112      $q->addWhere('task_end_date <= \'' . $end_date->format(FMT_DATETIME_MYSQL) . '\'');
 113  
 114      $q->addOrder('project_name ASC');
 115      $q->addOrder('task_end_date ASC');
 116  
 117      $tasks = $q->loadHashList('task_id');
 118      $q->clear();
 119      $first_task = current($tasks);
 120      $actual_project_id = 0;
 121      $first_task = true;
 122      $task_log = array();
 123  
 124      if (function_exists('styleRenderBoxBottom')) {
 125          echo styleRenderBoxBottom();
 126      }
 127      echo '<br />';
 128      if (function_exists('styleRenderBoxTop')) {
 129          echo styleRenderBoxTop();
 130      }
 131      echo '<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
 132  <tr>
 133      <td>';
 134  
 135      echo '<table class="std" width="100%">';
 136      echo '<tr><th>' . $AppUI->_('Task name') . '</th><th>' . $AppUI->_('T.Owner') . '</th><th>' . $AppUI->_('H.Alloc.') . '</th><th>' . $AppUI->_('Task end date') . '</th><th>' . $AppUI->_('Last activity date') . '</th><th>' . $AppUI->_('Done') . '?</th></tr>';
 137      $hrs = $AppUI->_('hrs'); // To avoid calling $AppUI each row

 138      foreach ($tasks as $task) {
 139          if ($actual_project_id != $task['task_project']) {
 140              echo '<tr><td colspan="6"><b>' . $task['project_name'] . '</b></td>';
 141              $actual_project_id = $task['task_project'];
 142          }
 143          $q->addTable('task_log');
 144          $q->addQuery('*');
 145          $q->addWhere('task_log_task = ' . (int)$task['task_id']);
 146          $q->addOrder('task_log_date DESC');
 147          $q->setLimit(1);
 148          $task_log = $q->loadHash();
 149          $q->clear();
 150  
 151          $done_img = $task['task_percent_complete'] == 100 ? 'Yes' : 'No';
 152          echo '<tr><td>&nbsp;&nbsp;&nbsp;' . $task['task_name'] . '</td><td>' . $task['user_username'] . '</td><td align="right">' . ($task['task_duration'] * $task['task_duration_type']) . ' ' . $hrs . '</td><td align="center">' . $task['task_end_date'] . '</td><td align="center">' . $task_log['task_log_date'] . '</td><td align="center">' . $done_img . '</td></tr>';
 153      }
 154      echo '</table>';
 155      echo '</td>
 156  </tr>
 157  </table>';
 158  }
 159  ?>


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