本文整理汇总了PHP中Reservation::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Reservation::getFromDB方法的具体用法?PHP Reservation::getFromDB怎么用?PHP Reservation::getFromDB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reservation
的用法示例。
在下文中一共展示了Reservation::getFromDB方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace
/**
* @param $type
* @param $model_id
* @param $tab_ids
* @param $location
**/
static function replace($type, $model_id, $tab_ids, $location)
{
global $DB, $CFG_GLPI, $PLUGIN_HOOKS;
$model = new PluginUninstallModel();
$model->getConfig($model_id);
$overwrite = $model->fields["overwrite"];
echo "<div class='center'>";
echo "<table class='tab_cadre_fixe'><tr><th>" . __('Replacement', 'uninstall') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
$count = 0;
$tot = count($tab_ids);
Html::createProgressBar(__('Please wait, replacement is running...', 'uninstall'));
foreach ($tab_ids as $olditem_id => $newitem_id) {
$count++;
$olditem = new $type();
$olditem->getFromDB($olditem_id);
$newitem = new $type();
$newitem->getFromDB($newitem_id);
//Hook to perform actions before item is being replaced
$olditem->fields['_newid'] = $newitem_id;
$olditem->fields['_uninstall_event'] = $model_id;
$olditem->fields['_action'] = 'replace';
Plugin::doHook("plugin_uninstall_replace_before", $olditem);
// Retrieve informations
//States
if ($model->fields['states_id'] != 0) {
$olditem->update(array('id' => $olditem_id, 'states_id' => $model->fields['states_id']), false);
}
// METHOD REPLACEMENT 1 : Archive
if ($model->fields['replace_method'] == self::METHOD_PURGE) {
$name_out = str_shuffle(Toolbox::getRandomString(5) . time());
$plugin = new Plugin();
if ($plugin->isActivated('PDF')) {
// USE PDF EXPORT
$plugin->load('pdf', true);
include_once GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php";
//Get all item's tabs
$tab = array_keys($olditem->defineTabs());
//Tell PDF to also export item's main tab, and in first position
array_unshift($tab, "_main_");
$itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($olditem);
$out = $itempdf->generatePDF(array($olditem_id), $tab, 1, false);
$name_out .= ".pdf";
} else {
//TODO Which datas ? Add Defaults...
$out = __('Replacement', 'uninstall') . "\r\n";
$datas = $olditem->fields;
unset($datas['comment']);
foreach ($datas as $k => $v) {
$out .= $k . ";";
}
$out .= "\r\n";
foreach ($datas as $k => $v) {
$out .= $v . ";";
}
// USE CSV EXPORT
$name_out .= ".csv";
}
// Write document
$out_file = GLPI_DOC_DIR . "/_uploads/" . $name_out;
$open_file = fopen($out_file, 'a');
fwrite($open_file, $out);
fclose($open_file);
// Compute comment text
$comment = __('This document is the archive of this replaced item', 'uninstall') . " " . self::getCommentsForReplacement($olditem, false, false);
// Create & Attach new document to current item
$doc = new Document();
$input = array('name' => addslashes(__('Archive of old material', 'uninstall')), 'upload_file' => $name_out, 'comment' => addslashes($comment), 'add' => __('Add'), 'entities_id' => $newitem->getEntityID(), 'is_recursive' => $newitem->isRecursive(), 'link' => "", 'documentcategories_id' => 0, 'items_id' => $olditem_id, 'itemtype' => $type);
//Attached the document to the old item, to generate an accurate name
$document_added = $doc->add($input);
//Attach the document to the new item, once the document's name is correct
$docItem = new Document_Item();
$docItemId = $docItem->add(array('documents_id' => $document_added, 'itemtype' => $type, 'items_id' => (int) $newitem_id));
}
// General Informations - NAME
if ($model->fields["replace_name"]) {
if ($overwrite || empty($newitem->fields['name'])) {
$newitem->update(array('id' => $newitem_id, 'name' => $olditem->getField('name')), false);
}
}
$data['id'] = $newitem->getID();
// General Informations - SERIAL
if ($model->fields["replace_serial"]) {
if ($overwrite || empty($newitem->fields['serial'])) {
$newitem->update(array('id' => $newitem_id, 'serial' => $olditem->getField('serial')), false);
}
}
// General Informations - OTHERSERIAL
if ($model->fields["replace_otherserial"]) {
if ($overwrite || empty($newitem->fields['otherserial'])) {
$newitem->update(array('id' => $newitem_id, 'otherserial' => $olditem->getField('otherserial')), false);
}
}
// Documents
//.........这里部分代码省略.........
示例2: showForm
/**
* Display for reservation
*
* @param $ID ID of the reservation (empty for create new)
* @param $options array
* - item reservation items ID for creation process
* - date date for creation process
**/
function showForm($ID, $options = array())
{
global $LANG;
if (!haveRight("reservation_helpdesk", "1")) {
return false;
}
$resa = new Reservation();
if (!empty($ID)) {
if (!$resa->getFromDB($ID)) {
return false;
}
if (!$resa->can($ID, "w")) {
return false;
}
// Set item if not set
if ((!isset($options['item']) || count($options['item']) == 0) && ($itemid = $resa->getField('reservationitems_id'))) {
$options['item'][$itemid] = $itemid;
}
} else {
$resa->getEmpty();
$resa->fields["begin"] = $options['date'] . " 12:00:00";
$resa->fields["end"] = $options['date'] . " 13:00:00";
}
// No item : problem
if (!isset($options['item']) || count($options['item']) == 0) {
return false;
}
echo "<div class='center'><form method='post' name=form action='reservation.form.php'>";
if (!empty($ID)) {
echo "<input type='hidden' name='id' value='{$ID}'>";
}
echo "<table class='tab_cadre'>";
echo "<tr><th colspan='2'>" . $LANG['reservation'][9] . "</th></tr>\n";
// Add Hardware name
$r = new ReservationItem();
echo "<tr class='tab_bg_1'><td>" . $LANG['common'][1] . " :</td>";
echo "<td>";
foreach ($options['item'] as $itemID) {
$r->getFromDB($itemID);
$type = $r->fields["itemtype"];
$name = NOT_AVAILABLE;
$item = NULL;
if (class_exists($r->fields["itemtype"])) {
$item = new $r->fields["itemtype"]();
$type = $item->getTypeName();
if ($item->getFromDB($r->fields["items_id"])) {
$name = $item->getName();
} else {
$item = NULL;
}
}
echo "<strong>{$type} - {$name}</strong><br>";
echo "<input type='hidden' name='items[{$itemID}]' value='{$itemID}'>";
}
echo "</td></tr>\n";
if (!haveRight("reservation_central", "w") || is_null($item) || !haveAccessToEntity($item->fields["entities_id"])) {
echo "<input type='hidden' name='users_id' value='" . getLoginUserID() . "'>";
} else {
echo "<tr class='tab_bg_2'><td>" . $LANG['common'][95] . " :</td>";
echo "<td>";
if (empty($ID)) {
User::dropdown(array('value' => getLoginUserID(), 'entity' => $item->getEntityID(), 'right' => 'all'));
} else {
User::dropdown(array('value' => $resa->fields["users_id"], 'entity' => $item->getEntityID(), 'right' => 'all'));
}
echo "</td></tr>\n";
}
echo "<tr class='tab_bg_2'><td>" . $LANG['search'][8] . " :</td><td>";
showDateTimeFormItem("begin", $resa->fields["begin"], -1, false);
echo "</td></tr>\n";
echo "<tr class='tab_bg_2'><td>" . $LANG['search'][9] . " :</td><td>";
showDateTimeFormItem("end", $resa->fields["end"], -1, false);
Alert::displayLastAlert('Reservation', $ID);
echo "</td></tr>\n";
if (empty($ID)) {
echo "<tr class='tab_bg_2'><td>" . $LANG['reservation'][27] . " :</td>";
echo "<td>";
echo "<select name='periodicity'>";
echo "<option value='day'>" . $LANG['reservation'][29] . "</option>\n";
echo "<option value='week'>" . $LANG['reservation'][28] . "</option>\n";
echo "</select>";
Dropdown::showInteger('periodicity_times', 1, 1, 60);
echo $LANG['reservation'][30];
echo "</td></tr>\n";
}
echo "<tr class='tab_bg_2'><td>" . $LANG['common'][25] . " :</td>";
echo "<td><textarea name='comment'rows='8' cols='30'>" . $resa->fields["comment"] . "</textarea>";
echo "</td></tr>\n";
if (empty($ID)) {
echo "<tr class='tab_bg_2'>";
echo "<td colspan='2' class='top center'>";
echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
//.........这里部分代码省略.........
示例3: mailUser
function mailUser($resaid)
{
global $DB, $CFG_GLPI;
$reservation = new Reservation();
$reservation->getFromDB($resaid);
NotificationEvent::raiseEvent('plugin_reservation_expiration', $reservation);
$config = new PluginReservationConfig();
$query = "UPDATE `glpi_plugin_reservation_manageresa` SET `dernierMail`= '" . date("Y-m-d H:i:s", time()) . "' WHERE `resaid` = " . $resaid;
$DB->query($query) or die("error on 'update' dans mailUser: " . $DB->error());
}
示例4: verifDisponibiliteAndMailIGS
static function verifDisponibiliteAndMailIGS($task, $itemtype, $idMat, $currentResa, $datedebut, $datefin)
{
global $DB, $CFG_GLPI;
$begin = $datedebut;
$end = $datefin;
$left = "";
$where = "";
$itemtable = getTableForItemType($itemtype);
if (isset($begin) && isset($end)) {
$left = "LEFT JOIN `glpi_reservations`\n ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n AND '" . $begin . "' < `glpi_reservations`.`end`\n AND '" . $end . "' > `glpi_reservations`.`begin`)";
$where = " AND `glpi_reservations`.`id` IS NOT NULL \n AND `glpi_reservations`.`id` != '" . $currentResa . "'\n AND `glpi_reservationitems`.`items_id` = '" . $idMat . "'";
}
$query = "SELECT `glpi_reservationitems`.`id`,\n `glpi_reservationitems`.`comment`,\n `{$itemtable}`.`name` AS name,\n `{$itemtable}`.`entities_id` AS entities_id,\n `glpi_reservations`.`id` AS resaid,\n `glpi_reservations`.`comment`,\n `glpi_reservations`.`begin`,\n `glpi_reservations`.`end`,\n `glpi_users`.`name` AS username,\n `glpi_reservationitems`.`items_id` AS items_id\n FROM `glpi_reservationitems`\n {$left}\n INNER JOIN `{$itemtable}`\n ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n LEFT JOIN `glpi_users` \n ON (`glpi_reservations`.`users_id` = `glpi_users`.`id`)\n WHERE `glpi_reservationitems`.`is_active` = '1'\n AND `glpi_reservationitems`.`is_deleted` = '0'\n AND `{$itemtable}`.`is_deleted` = '0'\n {$where}";
if ($result = $DB->query($query)) {
while ($row = $DB->fetch_assoc($result)) {
$task->log("CONFLIT avec la reservation du materiel " . $row['name'] . " par " . $row['username'] . " (du " . date("\\L d-m-Y \\à H:i:s", strtotime($row['begin'])) . " au " . date("\\L d-m-Y \\à H:i:s", strtotime($row['end'])));
$task->log("on supprime la resa numero : " . $row['resaid']);
$reservation = new Reservation();
$reservation->getFromDB($row['resaid']);
NotificationEvent::raiseEvent('plugin_reservation_conflit', $reservation);
$query = "DELETE FROM `glpi_reservations` WHERE `id`='" . $row["resaid"] . "';";
$DB->query($query) or die("error on 'delete' into glpi_reservations lors du cron : " . $DB->error());
}
}
}