Exemplo n.º 1
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $projet_item = new PluginProjetProjet_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginProjetProjet') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $PluginProjetTask = new PluginProjetTask();
                         $restrict = "`plugin_projet_projets_id` = '" . $key . "'";
                         $tasks = getAllDatasFromTable("glpi_plugin_projet_tasks");
                         if (!empty($tasks)) {
                             foreach ($tasks as $task) {
                                 $PluginProjetTask->getFromDB($task["id"]);
                                 $tasktype = PluginProjetTaskType::transfer($PluginProjetTask->fields["plugin_projet_tasktypes_id"], $input['entities_id']);
                                 if ($tasktype > 0) {
                                     $values["id"] = $task["id"];
                                     $values["plugin_projet_tasktypes_id"] = $tasktype;
                                     $PluginProjetTask->update($values);
                                 }
                                 $values["id"] = $task["id"];
                                 $values["entities_id"] = $input['entities_id'];
                                 $PluginProjetTask->update($values);
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Install":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $values = array('plugin_projet_projets_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($projet_item->add($values)) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         case "Desinstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($projet_item->deleteItemByProjetAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Exemplo n.º 2
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     $projet_item = new PluginProjetProjet_Item();
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginProjetTask') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         $tasktype = PluginProjetTaskType::transfer($this->fields["plugin_projet_tasktypes_id"], $input['entities_id']);
                         if ($tasktype > 0) {
                             $values["id"] = $key;
                             $values["plugin_projet_tasktypes_id"] = $tasktype;
                             $this->update($values);
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($this->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         case "Duplicate":
             if ($input['itemtype'] == 'PluginProjetTask') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $this->getFromDB($key);
                         unset($this->fields["id"]);
                         $this->fields["name"] = addslashes($this->fields["name"]);
                         $this->fields["comment"] = addslashes($this->fields["comment"]);
                         $this->fields["sub"] = addslashes($this->fields["sub"]);
                         $this->fields["others"] = addslashes($this->fields["others"]);
                         $this->fields["affect"] = addslashes($this->fields["affect"]);
                         if ($this->add($this->fields)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
             break;
     }
     return $res;
 }
Exemplo n.º 3
0
 /**
  * Display a Planning Item
  *
  * @param $parm Array of the item to display
  * @return Nothing (display function)
  **/
 static function displayPlanningItem(array $val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/task.form.php?id=" . $val["id"] . "'";
     echo " onmouseout=\"cleanhide('content_task_" . $val["id"] . $rand . "')\" \n               onmouseover=\"cleandisplay('content_task_" . $val["id"] . $rand . "')\"";
     echo ">";
     switch ($type) {
         case "in":
             //TRANS: %1$s is the start time of a planned item, %2$s is the end
             $beginend = sprintf(__('From %1$s to %2$s :'), date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"])));
             printf(__('%1$s %2$s'), $beginend, Html::resume_text($val["name"], 80));
             break;
         case "begin":
             $start = sprintf(__('Start at %s'), date("H:i", strtotime($val["begin"])));
             printf(__('%1$s: %2$s'), $start, Html::resume_text($val["name"], 80));
             break;
         case "end":
             $end = sprintf(__('End at %s'), date("H:i", strtotime($val["end"])));
             printf(__('%1$s: %2$s'), $end, Html::resume_text($val["name"], 80));
             break;
     }
     if ($val["users_id"] && $who == 0) {
         echo " - " . __('User') . " " . getUserName($val["users_id"]);
     }
     echo "</a><br>";
     echo PluginProjetProjet::getTypeName(1) . " : <a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php?id=" . $val["plugin_projet_projets_id"] . "'";
     echo ">" . $val["project"] . "</a>";
     echo "<div class='over_link' id='content_task_" . $val["id"] . $rand . "'>";
     if ($val["end"]) {
         echo "<strong>" . __('End date') . "</strong> : " . Html::convdatetime($val["end"]) . "<br>";
     }
     if ($val["type"]) {
         echo "<strong>" . PluginProjetTaskType::getTypeName(1) . "</strong> : " . $val["type"] . "<br>";
     }
     if ($val["state"]) {
         echo "<strong>" . __('State') . "</strong> : " . $val['state'] . "<br>";
     }
     if ($val["location"]) {
         echo "<strong>" . _n('Location', 'Locations', 1) . "</strong>: " . $val["location"] . "<br>";
     }
     if ($val["priority"]) {
         echo "<strong>" . __('Priority') . "</strong> : " . Ticket::getPriorityName($val["priority"]) . "<br>";
     }
     if ($val["content"]) {
         echo "<strong>" . __('Description') . "</strong> : " . $val["content"];
     }
     echo "</div>";
 }