[ Index ]

Source Code Reference for V1.00

title

Body

[close]

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

   1  <?php /* $Id: vw_log_update.php 137 2008-04-04 16:12:02Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/tasks/vw_log_update.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  global $AppUI, $task_id, $obj, $percent, $can_edit_time_information, $cal_sdf;
   7  $AppUI->loadCalendarJS();
   8  
   9  $perms = &$AppUI->acl();
  10  
  11  // check permissions
  12  $canEditTask = $perms->checkModuleItem('tasks', 'edit', $task_id);
  13  $canViewTask = $perms->checkModuleItem('tasks', 'view', $task_id);
  14  $canEdit = $perms->checkModule('task_log', 'edit');
  15  $canAdd = $perms->checkModule('task_log', 'add');
  16  
  17  $task_log_id = intval(w2PgetParam($_GET, 'task_log_id', 0));
  18  $log = new CTaskLog();
  19  if ($task_log_id) {
  20      if (!$canEdit || !$canViewTask) {
  21          $AppUI->redirect('m=public&a=access_denied');
  22      }
  23      $log->load($task_log_id);
  24  } else {
  25      if (!$canAdd || !$canViewTask) {
  26          $AppUI->redirect('m=public&a=access_denied');
  27      }
  28      $log->task_log_task = $task_id;
  29      $log->task_log_name = $obj->task_name;
  30  }
  31  
  32  // Check that the user is at least assigned to a task
  33  $task = new CTask;
  34  $task->load($task_id);
  35  if (!$task->canAccess($AppUI->user_id)) {
  36      $AppUI->redirect('m=public&a=access_denied');
  37  }
  38  
  39  $proj = &new CProject();
  40  $proj->load($obj->task_project);
  41  $q = new DBQuery();
  42  $q->addTable('billingcode');
  43  $q->addQuery('billingcode_id, billingcode_name');
  44  $q->addWhere('billingcode_status=0');
  45  $q->addWhere('(company_id=' . $proj->project_company . ' OR company_id = 0)');
  46  $q->addOrder('billingcode_name');
  47  
  48  $task_log_costcodes[0] = '';
  49  $rows = $q->loadList();
  50  echo db_error();
  51  $nums = 0;
  52  foreach ($rows as $key => $row) {
  53      $task_log_costcodes[$row['billingcode_id']] = $row['billingcode_name'];
  54  }
  55  
  56  $taskLogReference = w2PgetSysVal('TaskLogReference');
  57  
  58  // Task Update Form
  59  $df = $AppUI->getPref('SHDATEFORMAT');
  60  $log_date = new CDate($log->task_log_date);
  61  ?>
  62  
  63  <!-- TIMER RELATED SCRIPTS -->
  64  <script language="JavaScript">
  65      // please keep these lines on when you copy the source
  66      // made by: Nicolas - http://www.javascript-page.com
  67      // adapted by: Juan Carlos Gonzalez jcgonz@users.sourceforge.net
  68      
  69      var timerID       = 0;
  70      var tStart        = null;
  71      var total_minutes = -1;
  72      
  73      function UpdateTimer() {
  74         if(timerID) {
  75            clearTimeout(timerID);
  76            clockID  = 0;
  77         }
  78      
  79         // One minute has passed
  80         total_minutes = total_minutes+1;
  81         
  82         document.getElementById('timerStatus').innerHTML = '( '+total_minutes+' <?php echo $AppUI->_('minutes elapsed'); ?> )';
  83  
  84         // Lets round hours to two decimals
  85         var total_hours   = Math.round( (total_minutes / 60) * 100) / 100;
  86         document.editFrm.task_log_hours.value = total_hours;
  87         
  88         timerID = setTimeout('UpdateTimer()', 60000);
  89      }
  90      
  91      function timerStart() {
  92          if(!timerID){ // this means that it needs to be started
  93              timerSet();
  94              //document.editFrm.timerStartStopButton.value = '<?php echo $AppUI->_('Stop'); ?>';
  95              button = document.getElementById('timerStartStopButton');
  96              button.innerHTML = '<?php echo $AppUI->_('Stop'); ?>';
  97              UpdateTimer();
  98          } else { // timer must be stoped
  99              //document.editFrm.timerStartStopButton.value = '<?php echo $AppUI->_('Start'); ?>';
 100              button = document.getElementById('timerStartStopButton');
 101              button.innerHTML = '<?php echo $AppUI->_('Start'); ?>';
 102              document.getElementById('timerStatus').innerHTML = '';
 103              timerStop();
 104          }
 105      }
 106      
 107      function timerStop() {
 108         if(timerID) {
 109            clearTimeout(timerID);
 110            timerID  = 0;
 111            total_minutes = total_minutes-1;
 112         }
 113      }
 114      
 115      function timerReset() {
 116          document.editFrm.task_log_hours.value = '0.00';
 117          total_minutes = -1;
 118      }
 119  
 120      function timerSet() {
 121          total_minutes = Math.round(document.editFrm.task_log_hours.value * 60) -1;
 122      }
 123  
 124  function setDate( frm_name, f_date ) {
 125      fld_date = eval( 'document.' + frm_name + '.' + f_date );
 126      fld_real_date = eval( 'document.' + frm_name + '.' + 'task_' + f_date );
 127      if (fld_date.value.length>0) {
 128        if ((parseDate(fld_date.value))==null) {
 129              alert('The Date/Time you typed does not match your prefered format, please retype.');
 130              fld_real_date.value = '';
 131              fld_date.style.backgroundColor = 'red';
 132          } else {
 133              fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
 134              fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
 135              fld_date.style.backgroundColor = '';
 136            }
 137      } else {
 138            fld_real_date.value = '';
 139      }
 140  }    
 141  </script>
 142  <!-- END OF TIMER RELATED SCRIPTS -->
 143  
 144  <a name="log"></a>
 145  <form name="editFrm" action="?m=tasks&a=view&task_id=<?php echo $task_id; ?>" method="post"
 146    onsubmit='updateEmailContacts();'>
 147      <input type="hidden" name="uniqueid" value="<?php echo uniqid(''); ?>" />
 148      <input type="hidden" name="dosql" value="do_updatetask" />
 149      <input type="hidden" name="task_log_id" value="<?php echo $log->task_log_id; ?>" />
 150      <input type="hidden" name="task_log_task" value="<?php echo $log->task_log_task; ?>" />
 151      <input type="hidden" name="task_log_creator" value="<?php echo ($log->task_log_creator == 0 ? $AppUI->user_id : $log->task_log_creator); ?>" />
 152      <input type="hidden" name="task_log_name" value="Update :<?php echo $log->task_log_name; ?>" />
 153  <table cellspacing="1" cellpadding="2" border="0" width="100%">
 154  <tr>
 155      <td width='40%' valign='top'>
 156        <table width='100%'>
 157  <tr>
 158      <td align="right">
 159          <?php echo $AppUI->_('Date'); ?>
 160      </td>
 161      <td nowrap="nowrap">
 162          <input type="hidden" name="task_log_date" id="task_log_date" value="<?php echo $log_date ? $log_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
 163          <input type="text" name="log_date" id="log_date" onchange="setDate('editFrm', 'log_date');" value="<?php echo $log_date ? $log_date->format($df) : ''; ?>" class="text" />
 164          <a href="javascript: void(0);" onclick="return showCalendar('log_date', '<?php echo $df ?>', 'editFrm', null, true)">
 165              <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
 166          </a>
 167      </td>
 168  </tr>
 169  <tr>
 170      <td align="right"><?php echo ($canEditTask ? $AppUI->_('Progress') : ''); ?></td>
 171      <td>
 172          <table>
 173             <tr>
 174                <td>
 175  <?php
 176  echo ($canEditTask ? arraySelect($percent, 'task_percent_complete', 'size="1" class="text"', $obj->task_percent_complete) . '%' : '<input type="hidden" name="task_percent_complete" value="0" />');
 177  ?>
 178                </td>
 179                <td valign="middle" >
 180              <?php
 181  if ($obj->task_owner != $AppUI->user_id) {
 182      echo '<input type="checkbox" name="task_log_notify_owner" id="task_log_notify_owner" /></td><td valign="middle"><label for="task_log_notify_owner">' . $AppUI->_('Notify creator') . '</label>';
 183  }
 184  ?>             
 185               </td>
 186             </tr>
 187          </table>
 188      </td>
 189  </tr>
 190  <tr>
 191      <td align="right">
 192          <?php echo $AppUI->_('Hours Worked'); ?>
 193      </td>
 194      <td nowrap="nowrap">
 195          <input type="text" style="text-align:right;" class="text" name="task_log_hours" value="<?php echo $log->task_log_hours; ?>" maxlength="8" size="4" /> 
 196          <a class="button" href="javascript:;" onclick="javascript:timerStart()"><span id="timerStartStopButton"><?php echo $AppUI->_('Start'); ?></span></a>
 197          <a class="button" href="javascript:;" onclick="javascript:timerReset()"><span id="timerResetButton"><?php echo $AppUI->_('Reset'); ?></span></a>
 198          <span id='timerStatus'></span>
 199      </td>
 200  </tr>
 201  <tr>
 202          <td align="right">
 203          <?php echo $AppUI->_('Cost Code'); ?>
 204      </td>
 205      <td>
 206  <?php
 207  echo arraySelect($task_log_costcodes, 'task_log_costcodes', 'size="1" class="text" onchange="javascript:task_log_costcode.value = this.options[this.selectedIndex].value;"', $log->task_log_costcode);
 208  ?>
 209          -&gt;<input type="text" style="text-align:right;" class="text" name="task_log_costcode" value="<?php echo $log->task_log_costcode; ?>" maxlength="8" size="6" />
 210      </td>
 211  </tr>
 212  
 213  <?php
 214  if ($obj->canUserEditTimeInformation() && $canEditTask) {
 215      $end_date = intval($obj->task_end_date) ? new CDate($obj->task_end_date) : null;
 216  ?>
 217      <tr>
 218          <td align='right'>
 219              <?php echo $AppUI->_('Task end date'); ?>
 220          </td>
 221          <td>
 222              <input type="hidden" name="task_end_date" id="task_end_date" value="<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
 223              <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" />
 224              <a href="javascript: void(0);" onclick="return showCalendar('end_date', '<?php echo $df ?>', 'editFrm', null, true)">
 225                  <img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
 226              </a>
 227          </td>
 228      </tr>
 229  <?php
 230  }
 231  ?>
 232  </table>
 233  </td>
 234  <td width='60%' valign='top'>
 235  <table width='100%'>
 236  <tr>
 237      <td align="right"><?php echo $AppUI->_('Summary'); ?>:</td>
 238      <td valign="middle">
 239          <table width="100%">
 240              <tr>
 241                  <td align="left">
 242                      <input type="text" class="text" name="task_log_name" value="<?php echo $log->task_log_name; ?>" maxlength="255" size="30" />
 243                  </td>
 244                  <td align="center"><label for="task_log_problem"><?php echo $AppUI->_('Problem'); ?>:</label>
 245                      <input type="checkbox" value="1" name="task_log_problem" id="task_log_problem" <?php echo ($log->task_log_problem ? 'checked="checked"' : ''); ?> />
 246                  </td>
 247              </tr>
 248          </table>
 249      </td>
 250  </tr>
 251  <tr>
 252      <td align="right" valign="middle"><?php echo $AppUI->_('Reference'); ?>:</td>
 253      <td valign="middle">
 254          <?php echo arraySelect($taskLogReference, 'task_log_reference', 'size="1" class="text"', $log->task_log_reference, true); ?>
 255      </td>
 256  </tr>
 257  <tr>
 258      <td align="right">
 259          <?php echo $AppUI->_('URL'); ?>:
 260      </td>
 261      <td>
 262          <input type="text" class="text" name="task_log_related_url" value="<?php echo ($log->task_log_related_url); ?>" size="50" maxlength="255" title="<?php echo $AppUI->_('Must in general be entered with protocol name, e.g. http://...'); ?>"/>
 263      </td>
 264  </tr>
 265  <tr>
 266      <td align="right" valign="top"><?php echo $AppUI->_('Description'); ?>:</td>
 267      <td>
 268          <textarea name="task_log_description" class="textarea" cols="50" rows="6"><?php echo $log->task_log_description; ?></textarea>
 269      </td>
 270  </tr>
 271  <tr>
 272      <td align="right" valign="top"><?php echo $AppUI->_('Email Log to'); ?>:</td>
 273      <td>
 274  <?php
 275  $tl = $AppUI->getPref('TASKLOGEMAIL');
 276  $ta = $tl & 1;
 277  $tt = $tl & 2;
 278  $tp = $tl & 4;
 279  
 280  $task_email_title = array();
 281  $q = new DBQuery;
 282  $q->addTable('task_contacts', 'tc');
 283  $q->addJoin('contacts', 'c', 'c.contact_id = tc.contact_id', 'inner');
 284  $q->addWhere('tc.task_id = ' . (int)$task_id);
 285  $q->addQuery('tc.contact_id');
 286  $q->addQuery('c.contact_first_name, c.contact_last_name');
 287  $req = &$q->exec();
 288  $cidtc = array();
 289  for ($req; !$req->EOF; $req->MoveNext()) {
 290      $cidtc[] = $req->fields['contact_id'];
 291      $task_email_title[] = $req->fields['contact_first_name'] . ' ' . $req->fields['contact_last_name'];
 292  }
 293  
 294  $q->clear();
 295  $q->addTable('project_contacts', 'pc');
 296  $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id', 'inner');
 297  $q->addWhere('pc.project_id = ' . (int)$obj->task_project);
 298  $q->addQuery('pc.contact_id');
 299  $q->addQuery('c.contact_first_name, c.contact_last_name');
 300  $req = &$q->exec();
 301  $cidpc = array();
 302  $proj_email_title = array();
 303  for ($req; !$req->EOF; $req->MoveNext()) {
 304      if (!in_array($req->fields['contact_id'], $cidpc)) {
 305          $cidpc[] = $req->fields['contact_id'];
 306          $proj_email_title[] = $req->fields['contact_first_name'] . ' ' . $req->fields['contact_last_name'];
 307      }
 308  }
 309  $q->clear();
 310  ?>
 311          <input type="checkbox" name="email_assignees" id="email_assignees" <?php echo ($ta ? 'checked="checked"' : '');?> /><label for="email_assignees"><?php echo $AppUI->_('Task Assignees'); ?></label>
 312          <input type="hidden" name="email_task_list" id="email_task_list" value="<?php echo implode(',', $cidtc);?>" />
 313          <input type="checkbox" onmouseover="window.status = '<?php echo addslashes(implode(',', $task_email_title)); ?>';" onmouseout="window.status = '';" name="email_task_contacts" id="email_task_contacts" <?php echo ($tt ? 'checked="checked"' : ''); ?> /><label for="email_task_contacts"><?php echo $AppUI->_('Task Contacts'); ?></label>
 314          <input type="hidden" name="email_project_list" id="email_project_list" value="<?php echo implode(',', $cidpc); ?>" />
 315          <input type="checkbox" onmouseover="window.status = '<?php echo addslashes(implode(',', $proj_email_title)); ?>';" onmouseout="window.status = '';" name="email_project_contacts" id="email_project_contacts" <?php echo ($tp ? 'checked="checked"' : ''); ?> /><label for="email_project_contacts"><?php echo $AppUI->_('Project Contacts'); ?></label>
 316          <input type='hidden' name='email_others' id='email_others' value='' />
 317          <?php if ($AppUI->isActiveModule('contacts') && $perms->checkModule('contacts', 'view')) { ?>
 318              <input type='button' class='button' value='<?php echo $AppUI->_('Other Contacts...'); ?>' onclick='javascript:popEmailContacts();' />
 319          <?php } ?>
 320      </td>
 321  </tr>
 322  <tr>
 323      <td align="right" valign="top"><?php echo $AppUI->_('Extra Recipients'); ?>:</td>
 324      <td>
 325          <input type="text" class="text" name="email_extras" maxlength="255" size="30" />
 326      </td>
 327  </tr>
 328  <tr>
 329      <td colspan="2" valign="bottom" align="right">
 330          <input type="button" class="button" value="<?php echo $AppUI->_('update task'); ?>" onclick="updateTask()" />
 331      </td>
 332  </tr>
 333  </td>
 334  </table>
 335  </td>
 336  </tr>
 337  </table>
 338  </form>


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