[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/resources/ -> tasks_dosql.addedit.php (source)

   1  <?php /* $Id: tasks_dosql.addedit.php 40 2008-02-11 12:11:44Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/resources/tasks_dosql.addedit.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  // Set the pre and post save functions
   7  global $pre_save, $post_save, $other_resources;
   8  
   9  $pre_save[] = 'resource_presave';
  10  $post_save[] = 'resource_postsave';
  11  $other_resources = null;
  12  
  13  /**
  14   * presave functions are called before the session storage of tab data
  15   * is destroyed.  It can be used to save this data to be used later in
  16   * the postsave function.
  17   */
  18  function resource_presave() {
  19      global $other_resources;
  20      // check to see if we are in the post save list or if we need to
  21      // interrogate the session.
  22      $other_resources = setItem('hresource_assign');
  23      //dprint(__file__, __line__, 5, "setting other resources to $other_resources");
  24  }
  25  
  26  /**
  27   * postsave functions are only called after a succesful save.  They are
  28   * used to perform database operations after the event.
  29   */
  30  function resource_postsave() {
  31      global $other_resources;
  32      global $obj;
  33      $task_id = $obj->task_id;
  34      //dprint(__file__, __line__, 5, "saving resources, $other_resources");
  35      if (isset($other_resources)) {
  36          $value = array();
  37          $reslist = explode(';', $other_resources);
  38          foreach ($reslist as $res) {
  39              if ($res) {
  40                  list($resource, $perc) = explode('=', $res);
  41                  $value[] = array($task_id, $resource, $perc);
  42              }
  43          }
  44          // first delete any elements already there, then replace with this
  45          // list.
  46          $q = new DBQuery;
  47          $q->setDelete('resource_tasks');
  48          $q->addWhere('task_id = ' . (int)$obj->task_id);
  49          $q->exec();
  50          $q->clear();
  51          if (count($value)) {
  52              foreach ($value as $v) {
  53                  $q->addTable('resource_tasks');
  54                  $q->addInsert('task_id,resource_id,percent_allocated', $v, true);
  55                  $q->exec();
  56                  $q->clear();
  57              }
  58          }
  59      }
  60  }
  61  ?>


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