function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $task_item = new PluginResourcesTask_Item(); switch ($input['action']) { case "Transfert": if ($input['itemtype'] == 'PluginResourcesTask') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); $tasktype = PluginResourcesTaskType::transfer($PluginResourcesTask->fields["plugin_resources_tasktypes_id"], $input['entities_id']); if ($tasktype > 0) { $values["id"] = $key; $values["plugin_resources_tasktypes_id"] = $tasktype; $PluginResourcesTask->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'] == 'PluginResourcesTask') { 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"]); if ($this->add($this->fields)) { $res['ok']++; } else { $res['ko']++; } } } } break; case "Install": foreach ($input["item"] as $key => $val) { if ($val == 1) { $values = array('plugin_resources_tasks_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']); if ($task_item->add($values)) { $res['ok']++; } else { $res['ko']++; } } } break; case "Desinstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($task_item->deleteItemByTaskAndItem($key, $input['item_item'], $input['typeitem'])) { $res['ok']++; } else { $res['ko']++; } } } break; default: return parent::doSpecificMassiveActions($input); break; } return $res; }
function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $resource_item = new PluginResourcesResource_Item(); switch ($input['action']) { case "Transfert": if ($input['itemtype'] == 'PluginResourcesResource') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); $contracttype = PluginResourcesContractType::transfer($PluginResourcesResource->fields["plugin_resources_contracttypes_id"], $input['entities_id']); if ($contracttype > 0) { $values["id"] = $key; $values["plugin_resources_contracttypes_id"] = $contracttype; $this->update($values); } unset($values); $resourcestate = PluginResourcesResourceState::transfer($PluginResourcesResource->fields["plugin_resources_resourcestates_id"], $input['entities_id']); if ($resourcestate > 0) { $values["id"] = $key; $values["plugin_resources_resourcestates_id"] = $resourcestate; $this->update($values); } unset($values); $department = PluginResourcesDepartment::transfer($PluginResourcesResource->fields["plugin_resources_departments_id"], $input['entities_id']); if ($department > 0) { $values["id"] = $key; $values["plugin_resources_departments_id"] = $department; $this->update($values); } unset($values); $situation = PluginResourcesResourceSituation::transfer($PluginResourcesResource->fields["plugin_resources_resourcesituations_id"], $input['entities_id']); if ($situation > 0) { $values["id"] = $key; $values["plugin_resources_resourcesituations_id"] = $situation; $this->update($values); } unset($values); $contractnature = PluginResourcesContractNature::transfer($PluginResourcesResource->fields["plugin_resources_contractnatures_id"], $input['entities_id']); if ($contractnature > 0) { $values["id"] = $key; $values["plugin_resources_contractnatures_id"] = $contractnature; $this->update($values); } unset($values); $rank = PluginResourcesRank::transfer($PluginResourcesResource->fields["plugin_resources_ranks_id"], $input['entities_id']); if ($rank > 0) { $values["id"] = $key; $values["plugin_resources_ranks_id"] = $rank; $this->update($values); } unset($values); $speciality = PluginResourcesResourceSpeciality::transfer($PluginResourcesResource->fields["plugin_resources_resourcespecialities_id"], $input['entities_id']); if ($speciality > 0) { $values["id"] = $key; $values["plugin_resources_resourcespecialities_id"] = $speciality; $this->update($values); } unset($values); $PluginResourcesTask = new PluginResourcesTask(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $tasks = getAllDatasFromTable("glpi_plugin_resources_tasks", $restrict); if (!empty($tasks)) { foreach ($tasks as $task) { $PluginResourcesTask->getFromDB($task["id"]); $tasktype = PluginResourcesTaskType::transfer($PluginResourcesTask->fields["plugin_resources_tasktypes_id"], $input['entities_id']); if ($tasktype > 0) { $values["id"] = $task["id"]; $values["plugin_resources_tasktypes_id"] = $tasktype; $PluginResourcesTask->update($values); } $values["id"] = $task["id"]; $values["entities_id"] = $input['entities_id']; $PluginResourcesTask->update($values); } } unset($values); $PluginResourcesEmployment = new PluginResourcesEmployment(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $employments = getAllDatasFromTable("glpi_plugin_resources_employments", $restrict); if (!empty($employments)) { foreach ($employments as $employment) { $PluginResourcesEmployment->getFromDB($employment["id"]); $rank = PluginResourcesRank::transfer($PluginResourcesEmployment->fields["plugin_resources_ranks_id"], $input['entities_id']); if ($rank > 0) { $values["id"] = $employment["id"]; $values["plugin_resources_ranks_id"] = $rank; $PluginResourcesEmployment->update($values); } $PluginResourcesEmployment->getFromDB($employment["id"]); $profession = PluginResourcesProfession::transfer($PluginResourcesEmployment->fields["plugin_resources_professions_id"], $input['entities_id']); if ($profession > 0) { $values["id"] = $employment["id"]; $values["plugin_resources_professions_id"] = $profession; $PluginResourcesEmployment->update($values); } $values["id"] = $employment["id"]; $values["entities_id"] = $input['entities_id']; $PluginResourcesEmployment->update($values); } } unset($values); $PluginResourcesEmployee = new PluginResourcesEmployee(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $employees = getAllDatasFromTable("glpi_plugin_resources_employees", $restrict); if (!empty($employees)) { foreach ($employees as $employee) { $employer = PluginResourcesEmployer::transfer($employee["plugin_resources_employers_id"], $input['entities_id']); if ($employer > 0) { $values["id"] = $employee["id"]; $values["plugin_resources_employers_id"] = $employer; $PluginResourcesEmployee->update($values); } $client = PluginResourcesClient::transfer($employee["plugin_resources_clients_id"], $input['entities_id']); if ($client > 0) { $values["id"] = $employee["id"]; $values["plugin_resources_clients_id"] = $client; $PluginResourcesEmployee->update($values); } } } unset($values); $query = "UPDATE `glpi_plugin_resources_checklists`\n SET `entities_id` = '" . $input['entities_id'] . "'\n WHERE `plugin_resources_resources_id` ='{$key}'"; $DB->query($query); $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_resources_resources_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']); if ($resource_item->add($values)) { $res['ok']++; } else { $res['ko']++; } } } break; case "Desinstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($resource_item->deleteItemByResourcesAndItem($key, $input['item_item'], $input['typeitem'])) { $res['ok']++; } else { $res['ko']++; } } } break; case "Send": if ($this->sendEmail($input)) { $res['ok']++; } else { $res['ko']++; } break; default: return parent::doSpecificMassiveActions($input); break; } return $res; }
/** * 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/resources/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 PluginResourcesResource::getTypeName(1) . " : <a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resource.form.php?id=" . $val["plugin_resources_resources_id"] . "'"; echo ">" . $val["resource"] . "</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>" . PluginResourcesTaskType::getTypeName(1) . "</strong> : " . $val["type"] . "<br>"; } if ($val["content"]) { echo "<strong>" . __('Description') . "</strong> : " . $val["content"]; } echo "</div>"; }
function plugin_resources_getDropdown() { $plugin = new Plugin(); if ($plugin->isActivated("resources")) { return array('PluginResourcesContractType' => PluginResourcesContractType::getTypeName(2), 'PluginResourcesTaskType' => PluginResourcesTaskType::getTypeName(2), 'PluginResourcesResourceState' => PluginResourcesResource::getTypeName(2) . " - " . PluginResourcesResourceSituation::getTypeName(2), 'PluginResourcesDepartment' => PluginResourcesDepartment::getTypeName(2), 'PluginResourcesEmployer' => PluginResourcesEmployer::getTypeName(2), 'PluginResourcesClient' => PluginResourcesClient::getTypeName(2), 'PluginResourcesChoiceItem' => PluginResourcesChoiceItem::getTypeName(2), 'PluginResourcesResourceSituation' => PluginResourcesEmployer::getTypeName(2) . " - " . PluginResourcesResourceSituation::getTypeName(2), 'PluginResourcesContractNature' => PluginResourcesContractNature::getTypeName(2), 'PluginResourcesRank' => PluginResourcesRank::getTypeName(2), 'PluginResourcesResourceSpeciality' => PluginResourcesResourceSpeciality::getTypeName(2), 'PluginResourcesLeavingReason' => PluginResourcesLeavingReason::getTypeName(2), 'PluginResourcesProfession' => PluginResourcesProfession::getTypeName(2), 'PluginResourcesProfessionLine' => PluginResourcesProfessionLine::getTypeName(2), 'PluginResourcesProfessionCategory' => PluginResourcesProfessionCategory::getTypeName(2), 'PluginResourcesEmploymentState' => PluginResourcesEmploymentState::getTypeName(2), 'PluginResourcesBudgetType' => PluginResourcesBudgetType::getTypeName(2), 'PluginResourcesBudgetVolume' => PluginResourcesBudgetVolume::getTypeName(2), 'PluginResourcesCost' => PluginResourcesCost::getTypeName(2)); } else { return array(); } }