[ Index ]

Source Code Reference for V1.00

title

Body

[close]

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

   1  <?php /* $Id: viewgantt.php 135 2008-04-04 13:49:13Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/tasks/viewgantt.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  global $AppUI, $min_view, $m, $a, $user_id, $tab, $tasks, $cal_sdf;
   7  $AppUI->loadCalendarJS();
   8  
   9  $min_view = defVal($min_view, false);
  10  
  11  $project_id = defVal(w2PgetParam($_GET, 'project_id', null), 0);
  12  
  13  // sdate and edate passed as unix time stamps

  14  $sdate = w2PgetParam($_POST, 'project_start_date', 0);
  15  $edate = w2PgetParam($_POST, 'project_end_date', 0);
  16  
  17  //if set GantChart includes user labels as captions of every GantBar

  18  $showLabels = w2PgetParam($_POST, 'showLabels', '0');
  19  $showLabels = (($showLabels != '0') ? '1' : $showLabels);
  20  
  21  $showWork = w2PgetParam($_POST, 'showWork', '0');
  22  $showWork = (($showWork != '0') ? '1' : $showWork);
  23  
  24  $sortByName = w2PgetParam($_POST, 'sortByName', '0');
  25  $sortByName = (($sortByName != '0') ? '1' : $sortByName);
  26  
  27  if ($a == 'todo') {
  28      if (isset($_POST['show_form'])) {
  29          $AppUI->setState('TaskDayShowArc', w2PgetParam($_POST, 'showArcProjs', 0));
  30          $AppUI->setState('TaskDayShowLow', w2PgetParam($_POST, 'showLowTasks', 0));
  31          $AppUI->setState('TaskDayShowHold', w2PgetParam($_POST, 'showHoldProjs', 0));
  32          $AppUI->setState('TaskDayShowDyn', w2PgetParam($_POST, 'showDynTasks', 0));
  33          $AppUI->setState('TaskDayShowPin', w2PgetParam($_POST, 'showPinned', 0));
  34      }
  35  
  36      $showArcProjs = $AppUI->getState('TaskDayShowArc', 0);
  37      $showLowTasks = $AppUI->getState('TaskDayShowLow', 1);
  38      $showHoldProjs = $AppUI->getState('TaskDayShowHold', 0);
  39      $showDynTasks = $AppUI->getState('TaskDayShowDyn', 0);
  40      $showPinned = $AppUI->getState('TaskDayShowPin', 0);
  41  } else {
  42      $showPinned = w2PgetParam($_POST, 'showPinned', '0');
  43      $showPinned = (($showPinned != '0') ? '1' : $showPinned);
  44  
  45      $showArcProjs = w2PgetParam($_POST, 'showArcProjs', '0');
  46      $showArcProjs = (($showArcProjs != '0') ? '1' : $showArcProjs);
  47  
  48      $showHoldProjs = w2PgetParam($_POST, 'showHoldProjs', '0');
  49      $showHoldProjs = (($showHoldProjs != '0') ? '1' : $showHoldProjs);
  50  
  51      $showDynTasks = w2PgetParam($_POST, 'showDynTasks', '0');
  52      $showDynTasks = (($showDynTasks != '0') ? '1' : $showDynTasks);
  53  
  54      $showLowTasks = w2PgetParam($_POST, 'showLowTasks', '0');
  55      $showLowTasks = (($showLowTasks != '0') ? '1' : $showLowTasks);
  56  }
  57  
  58  // months to scroll

  59  $scroll_date = 1;
  60  
  61  $display_option = w2PgetParam($_POST, 'display_option', 'this_month');
  62  
  63  // format dates

  64  $df = $AppUI->getPref('SHDATEFORMAT');
  65  
  66  if ($display_option == 'custom') {
  67      // custom dates

  68      $start_date = intval($sdate) ? new CDate($sdate) : new CDate();
  69      $end_date = intval($edate) ? new CDate($edate) : new CDate();
  70  } else {
  71      // month

  72      $start_date = new CDate();
  73      $start_date->day = 1;
  74      $end_date = new CDate($start_date);
  75      $end_date->addMonths($scroll_date);
  76  }
  77  
  78  // setup the title block

  79  if (!$min_view) {
  80      $titleBlock = new CTitleBlock('Gantt Chart', 'applet-48.png', $m, $m . '.' . $a);
  81      $titleBlock->addCrumb('?m=tasks', 'tasks list');
  82      $titleBlock->addCrumb('?m=projects&a=view&project_id=' . $project_id, 'view this project');
  83      $titleBlock->show();
  84  }
  85  ?>
  86  <script language="javascript">
  87  function setDate( frm_name, f_date ) {
  88      fld_date = eval( 'document.' + frm_name + '.' + f_date );
  89      fld_real_date = eval( 'document.' + frm_name + '.' + 'project_' + f_date );
  90      if (fld_date.value.length>0) {
  91        if ((parseDate(fld_date.value))==null) {
  92              alert('The Date/Time you typed does not match your prefered format, please retype.');
  93              fld_real_date.value = '';
  94              fld_date.style.backgroundColor = 'red';
  95          } else {
  96              fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
  97              fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
  98              fld_date.style.backgroundColor = '';
  99            }
 100      } else {
 101            fld_real_date.value = '';
 102      }
 103  }
 104  
 105  function scrollPrev() {
 106      f = document.editFrm;
 107  <?php
 108  $new_start = new CDate($start_date);
 109  $new_start->day = 1;
 110  $new_end = new CDate($end_date);
 111  $new_start->addMonths(-$scroll_date);
 112  $new_end->addMonths(-$scroll_date);
 113  echo "f.project_start_date.value='" . $new_start->format(FMT_TIMESTAMP_DATE) . "';";
 114  echo "f.project_end_date.value='" . $new_end->format(FMT_TIMESTAMP_DATE) . "';";
 115  ?>
 116      document.editFrm.display_option.value = 'custom';
 117      f.submit()
 118  }
 119  
 120  function scrollNext() {
 121      f = document.editFrm;
 122  <?php
 123  $new_start = new CDate($start_date);
 124  $new_start->day = 1;
 125  $new_end = new CDate($end_date);
 126  $new_start->addMonths($scroll_date);
 127  $new_end->addMonths($scroll_date);
 128  echo "f.project_start_date.value='" . $new_start->format(FMT_TIMESTAMP_DATE) . "';";
 129  echo "f.project_end_date.value='" . $new_end->format(FMT_TIMESTAMP_DATE) . "';";
 130  ?>
 131      document.editFrm.display_option.value = 'custom';
 132      f.submit()
 133  }
 134  
 135  function showThisMonth() {
 136      document.editFrm.display_option.value = "this_month";
 137      document.editFrm.submit();
 138  }
 139  
 140  function showFullProject() {
 141      document.editFrm.display_option.value = "all";
 142      document.editFrm.submit();
 143  }
 144  
 145  </script>
 146  
 147  
 148  <form name="editFrm" method="post" action="?<?php echo "m=$m&a=$a&tab=$tab&project_id=$project_id"; ?>">
 149  <input type="hidden" name="display_option" value="<?php echo $display_option; ?>" />
 150  <table border="0" cellpadding="4" cellspacing="0" class="std" width="100%">
 151  <tr>
 152      <td align="left" valign="top" width="20">
 153  <?php if ($display_option != "all") { ?>
 154          <a href="javascript:scrollPrev()">
 155              <img src="<?php echo w2PfindImage('prev.gif'); ?>" width="16" height="16" alt="<?php echo $AppUI->_('previous'); ?>" border="0">
 156          </a>
 157  <?php } ?>
 158      </td>
 159  
 160      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('From'); ?>:</td>
 161      <td align="left" nowrap="nowrap">
 162          <input type="hidden" name="project_start_date" id="project_start_date" value="<?php echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
 163          <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" />
 164          <a href="javascript: void(0);" onclick="return showCalendar('start_date', '<?php echo $df ?>', 'editFrm', null, true)">
 165          <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="" border="0" /></a>
 166      </td>
 167  
 168      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('To'); ?>:</td>
 169      <td align="left" nowrap="nowrap">
 170          <input type="hidden" name="project_end_date" id="project_end_date" value="<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
 171          <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" />
 172          <a href="javascript: void(0);" onclick="return showCalendar('end_date', '<?php echo $df ?>', 'editFrm', null, true)">
 173          <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="" border="0" /></a>
 174      <td valign="top">
 175          <input type="checkbox" name="showLabels" id="showLabels" <?php echo (($showLabels == 1) ? 'checked="checked"' : ''); ?> /><label for="showLabels"><?php echo $AppUI->_('Show captions'); ?></label>
 176      </td>
 177      <td valign="top">
 178          <input type="checkbox" name="showWork" id="showWork" <?php echo (($showWork == 1) ? 'checked="checked"' : ''); ?> /><label for="showWork"><?php echo $AppUI->_('Show work instead of duration'); ?></label>
 179      </td>    
 180      <td valign="top">
 181          <input type="checkbox" name="sortByName" id="sortByName" <?php echo (($sortByName == 1) ? 'checked="checked"' : ''); ?> /><label for="sortByName"><?php echo $AppUI->_('Sort by Task Name'); ?></label>
 182      </td>    
 183      <td align="left">
 184          <input type="button" class="button" value="<?php echo $AppUI->_('submit'); ?>" onclick='document.editFrm.display_option.value="custom";submit();' />
 185      </td>
 186  
 187      <td align="right" valign="top" width="20">
 188  <?php if ($display_option != 'all') { ?>
 189        <a href="javascript:scrollNext()">
 190            <img src="<?php echo w2PfindImage('next.gif'); ?>" width="16" height="16" alt="<?php echo $AppUI->_('next'); ?>" border="0" />
 191        </a>
 192  <?php } ?>
 193      </td>
 194  </tr>
 195  <?php if ($a == 'todo') { ?>
 196  <input type="hidden" name="show_form" value="1" />
 197  <tr>
 198      <td align="center" valign="bottom" nowrap="nowrap" colspan="7">
 199          <table width="100%" border="0" cellpadding="1" cellspacing="0">
 200              <tr>
 201              <td align="center" valign="bottom" nowrap="nowrap">
 202                  <input type="checkbox" name="showPinned" id="showPinned" <?php echo $showPinned ? 'checked="checked"' : ''; ?> />
 203                  <label for="showPinned"><?php echo $AppUI->_('Pinned Only'); ?></label>
 204              </td>
 205              <td align="center" valign="bottom" nowrap="nowrap">
 206                  <input type="checkbox" name="showArcProjs" id="showArcProjs" <?php echo $showArcProjs ? 'checked="checked"' : ''; ?> />
 207                  <label for="showArcProjs"><?php echo $AppUI->_('Archived/Template Projects'); ?></label>
 208              </td>
 209  <!--            <td align="center" valign="bottom" nowrap="nowrap">
 210                  <input type="checkbox" name="showHoldProjs" id="showHoldProjs" <?php echo $showHoldProjs ? 'checked="checked"' : ''; ?> />
 211                  <label for="showHoldProjs"><?php echo $AppUI->_('Projects on Hold'); ?></label>
 212              </td>-->
 213              <td align="center" valign="bottom" nowrap="nowrap">
 214                  <input type="checkbox" name="showDynTasks" id="showDynTasks" <?php echo $showDynTasks ? 'checked="checked"' : ''; ?> />
 215                  <label for="showDynTasks"><?php echo $AppUI->_('Dynamic Tasks'); ?></label>
 216              </td>
 217              <td align="center" valign="bottom" nowrap="nowrap">
 218                  <input type="checkbox" name="showLowTasks" id="showLowTasks" <?php echo $showLowTasks ? 'checked="checked"' : ''; ?> />
 219                  <label for="showLowTasks"><?php echo $AppUI->_('Low Priority Tasks'); ?></label>
 220              </td>
 221              </tr>
 222          </table>
 223      </td>
 224  </tr>
 225  <?php } ?>
 226  </form>
 227  
 228  <tr>
 229      <td align="center" valign="bottom" colspan="9">
 230          <?php echo "<a href='javascript:showThisMonth()'>" . $AppUI->_('show this month') . "</a> : <a href='javascript:showFullProject()'>" . ($a == 'todo' ? $AppUI->_('show all') : $AppUI->_('show full project')) . "</a><br>"; ?>
 231      </td>
 232  </tr>
 233  
 234  </table>
 235  
 236  <table cellspacing="0" cellpadding="0" border="1" align="center" class="std" width="100%">
 237  <tr>
 238      <td>
 239  <?php
 240  if ($a != 'todo') {
 241      $q = new DBQuery;
 242      $q->addTable('tasks');
 243      $q->addQuery('COUNT(task_id) AS N');
 244      $q->addWhere('task_project=' . (int)$project_id);
 245      $cnt = $q->loadList();
 246      $q->clear();
 247  } else {
 248      if (empty($tasks)) {
 249          $cnt[0]['N'] = 0;
 250      } else {
 251          $cnt[0]['N'] = 1;
 252      }
 253  }
 254  if ($cnt[0]['N'] > 0) {
 255      $src = '?m=tasks&a=gantt&suppressHeaders=1&project_id=' . $project_id . ($display_option == 'all' ? '' : '&start_date=' . $start_date->format('%Y-%m-%d') . '&end_date=' . $end_date->format('%Y-%m-%d')) . "&width=' + ((navigator.appName=='Netscape'?window.innerWidth:document.body.offsetWidth)*0.95) + '&showLabels=" . $showLabels . '&showWork=' . $showWork . '&sortByName=' . $sortByName . '&showPinned=' . $showPinned . '&showArcProjs=' . $showArcProjs . '&showHoldProjs=' . $showHoldProjs . '&showDynTasks=' . $showDynTasks . '&showLowTasks=' . $showLowTasks . '&caller=' . $a . '&user_id=' . $user_id;
 256      echo "<script>document.write('<img src=\"$src\">')</script>";
 257  } else {
 258      echo $AppUI->_('No tasks to display');
 259  }
 260  ?>
 261      </td>
 262  </tr>
 263  </table>


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