function getDatasForTemplate($event, $options = array())
 {
     $this->datas['##consumable.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.consumable.entity##'] = __('Entity');
     $this->datas['##consumable.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.consumable.entity##'] = __('Entity');
     switch ($event) {
         case self::CONSUMABLE_REQUEST:
             $this->datas['##consumable.action##'] = __('Consumable request', 'consumables');
             break;
         case self::CONSUMABLE_RESPONSE:
             $this->datas['##consumable.action##'] = __('Consumable validation', 'consumables');
             break;
     }
     // Consumable request
     $this->datas['##lang.consumablerequest.consumable##'] = _n('Consumable', 'Consumables', 1);
     $this->datas['##lang.consumablerequest.consumabletype##'] = _n('Consumable type', 'Consumable types', 1);
     $this->datas['##lang.consumablerequest.request_date##'] = __('Request date');
     $this->datas['##lang.consumablerequest.requester##'] = __('Requester');
     $this->datas['##lang.consumablerequest.status##'] = __('Status');
     $this->datas['##lang.consumablerequest.number##'] = __('Number of used consumables');
     $this->datas['##lang.consumablerequest.validator##'] = __('Approver');
     $this->datas['##lang.consumablerequest.comment##'] = __('Comments');
     $consumable = $options['consumablerequest'];
     $this->datas['##consumablerequest.consumable##'] = Dropdown::getDropdownName(ConsumableItem::getTable(), $consumable['consumables_id']);
     $this->datas['##consumablerequest.consumabletype##'] = Dropdown::getDropdownName(ConsumableItemType::getTable(), $consumable['consumableitemtypes_id']);
     $this->datas['##consumablerequest.request_date##'] = Html::convDateTime($consumable['date_mod']);
     $this->datas['##consumablerequest.end_date##'] = Html::convDateTime($consumable['end_date']);
     $this->datas['##consumablerequest.requester##'] = Html::clean(getUserName($consumable['requesters_id']));
     $this->datas['##consumablerequest.validator##'] = Html::clean(getUserName($consumable['validators_id']));
     $this->datas['##consumablerequest.number##'] = $consumable['number'];
     $this->datas['##consumablerequest.status##'] = CommonITILValidation::getStatus($consumable['status']);
     if (isset($options['comment'])) {
         $this->datas['##consumablerequest.comment##'] = Html::clean($options['comment']);
     }
 }
Exemplo n.º 2
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkRight("consumable", READ);
$con = new Consumable();
$constype = new ConsumableItem();
if (isset($_POST["add_several"])) {
    $constype->check($_POST["consumableitems_id"], UPDATE);
    for ($i = 0; $i < $_POST["to_add"]; $i++) {
        unset($con->fields["id"]);
        $con->add($_POST);
    }
    Event::log($_POST["consumableitems_id"], "consumableitems", 4, "inventory", sprintf(__('%s adds consumables'), $_SESSION["glpiname"]));
    Html::back();
} else {
    Html::back();
}
Exemplo n.º 3
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkRight("consumable", "r");
$con = new Consumable();
$constype = new ConsumableItem();
if (isset($_POST["add_several"])) {
    $constype->check($_POST["consumableitems_id"], 'w');
    for ($i = 0; $i < $_POST["to_add"]; $i++) {
        unset($con->fields["id"]);
        $con->add($_POST);
    }
    Event::log($_POST["consumableitems_id"], "consumables", 4, "inventory", sprintf(__('%s adds consumables'), $_SESSION["glpiname"]));
    Html::back();
} else {
    Html::back();
}
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkRight("consumable", READ);
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
$constype = new ConsumableItem();
if (isset($_POST["add"])) {
    $constype->check(-1, CREATE, $_POST);
    if ($newID = $constype->add($_POST)) {
        Event::log($newID, "consumableitems", 4, "inventory", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
        if ($_SESSION['glpibackcreated']) {
            Html::redirect($constype->getFormURL() . "?id=" . $newID);
        }
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $constype->check($_POST["id"], DELETE);
        if ($constype->delete($_POST)) {
            Event::log($_POST["id"], "consumableitems", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        }
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
$constype = new ConsumableItem();
if (isset($_POST["add"])) {
    $constype->check(-1, 'w', $_POST);
    if ($newID = $constype->add($_POST)) {
        Event::log($newID, "consumables", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " " . $_POST["name"] . ".");
    }
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        $constype->check($_POST["id"], 'w');
        if ($constype->delete($_POST)) {
            Event::log($_POST["id"], "consumables", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][22]);
        }
        $constype->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
Exemplo n.º 6
0
 function getRights($interface = 'central')
 {
     $ci = new ConsumableItem();
     return $ci->getRights($interface);
 }
Exemplo n.º 7
0
 public function getLinkedItemDetails($itemtype, $items_id)
 {
     $comments = "";
     switch ($itemtype) {
         case 'ConsumableItem':
             $ci = new Consumable();
             if ($ci->getFromDB($items_id)) {
                 $ct = new ConsumableItem();
                 $ct->getFromDB($ci->fields['consumableitems_id']);
                 $comments .= "<strong>" . __("Entity") . ":</strong> ";
                 $comments .= Dropdown::getDropdownName("glpi_entities", $ct->fields["entities_id"]);
                 $comments .= '<br><strong>' . __("Consumable") . ' : </strong> #' . $items_id;
                 $comments .= '<br><strong>' . __("Consumable type") . ' : </strong>';
                 $comments .= $ct->fields['name'];
                 $comments .= '<br><strong>' . __("Manufacturer") . ' : </strong>';
                 $comments .= Dropdown::getDropdownName('glpi_manufacturers', $ct->fields['manufacturers_id']);
                 $comments .= '<br><strong>' . __("State") . ' : </strong>';
                 $comments .= !$ci->fields['users_id'] ? __("In stock") : __("Used");
                 if ($ci->fields['users_id']) {
                     $comments .= '<br><strong>' . __("User") . ' : </strong>';
                     $comments .= Dropdown::getDropdownName('glpi_users', $ci->fields['users_id']);
                 }
             }
             break;
         case 'CartridgeItem':
             $ci = new Cartridge();
             if ($ci->getFromDB($items_id)) {
                 $ct = new CartridgeItem();
                 $ct->getFromDB($ci->fields['cartridgeitems_id']);
                 $comments .= "<strong>" . __("Entity") . ":</strong> ";
                 $comments .= Dropdown::getDropdownName("glpi_entities", $ct->fields["entities_id"]);
                 $comments .= '<br><strong>' . __("Cartridge") . ' : </strong> #' . $items_id;
                 $comments .= '<br><strong>' . _n("New", "New", 2) . ' : </strong>';
                 $comments .= $ct->fields['name'];
                 $comments .= '<br><strong>' . __("Manufacturer") . ' : </strong>';
                 $comments .= Dropdown::getDropdownName('glpi_manufacturers', $ct->fields['manufacturers_id']);
             }
             break;
             // case 'Computer' :
             // case 'Monitor' :
             // case 'NetworkEquipment' :
             // case 'Peripheral' :
             // case 'Phone' :
             // case 'Printer' :
         // case 'Computer' :
         // case 'Monitor' :
         // case 'NetworkEquipment' :
         // case 'Peripheral' :
         // case 'Phone' :
         // case 'Printer' :
         default:
             $item = new $itemtype();
             $item->getFromDB($items_id);
             if ($item->getField("name")) {
                 $comments .= "<strong>" . __("Name") . ":</strong> ";
                 $comments .= $item->getField("name");
             }
             if ($item->getField("entities_id")) {
                 $comments .= "<strong>" . __("Entity") . ":</strong> ";
                 $comments .= Dropdown::getDropdownName("glpi_entities", $item->getField("entities_id"));
             }
             if ($item->getField("serial") != '') {
                 $comments .= "<br><strong>" . __("Serial number") . ":</strong> ";
                 $comments .= $item->getField("serial");
             }
             if ($item->getField("otherserial") != '') {
                 $comments .= "<br><strong>" . __("Inventory number") . ":</strong> ";
                 $comments .= $item->getField("otherserial");
             }
             if ($item->getField("locations_id")) {
                 $comments .= "<br><strong>" . __("Location") . ":</strong> ";
                 $comments .= Dropdown::getDropdownName('glpi_locations', $item->getField("locations_id"));
             }
             if ($item->getField("users_id")) {
                 $comments .= "<br><strong>" . __("User") . ":</strong> ";
                 $comments .= Dropdown::getDropdownName('glpi_users', $item->getField("users_id"));
             }
             break;
     }
     return $comments;
 }
Exemplo n.º 8
0
 /**
  * @param $item   string  ConsumableItem object
  **/
 static function countForConsumableItem(ConsumableItem $item)
 {
     $restrict = "`glpi_consumables`.`consumableitems_id` = '" . $item->getField('id') . "'";
     return countElementsInTable(array('glpi_consumables'), $restrict);
 }
Exemplo n.º 9
0
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
if (!isset($_GET["tID"])) {
    $_GET["tID"] = "";
}
if (!isset($_GET["cID"])) {
    $_GET["cID"] = "";
}
$con = new Consumable();
$constype = new ConsumableItem();
if (isset($_POST["add_several"])) {
    $constype->check($_POST["tID"], 'w');
    for ($i = 0; $i < $_POST["to_add"]; $i++) {
        unset($con->fields["id"]);
        $con->add($_POST);
    }
    Event::log($_POST["tID"], "consumables", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][89] . ": " . $_POST["to_add"]);
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_GET["delete"])) {
        $constype->check($_GET["tID"], 'w');
        if ($con->delete($_GET)) {
            Event::log($_GET["tID"], "consumables", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][91]);
        }
        glpi_header($_SERVER['HTTP_REFERER']);
Exemplo n.º 10
0
 /**
  * Print out the consumables of a defined type
  *
  *@param $consitem oject of ConsumableItem class
  *@param $show_old boolean : show old consumables or not.
  *
  *@return Nothing (displays)
  **/
 static function showForItem(ConsumableItem $consitem, $show_old = 0)
 {
     global $DB, $CFG_GLPI, $LANG;
     $tID = $consitem->getField('id');
     if (!$consitem->can($tID, 'r')) {
         return false;
     }
     $canedit = $consitem->can($tID, 'w');
     $query = "SELECT count(*) AS COUNT\n                FROM `glpi_consumables`\n                WHERE (`consumableitems_id` = '{$tID}')";
     if ($result = $DB->query($query)) {
         if (!$show_old && $canedit) {
             echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/consumable.form.php'>";
             echo "<input type='hidden' name='tID' value='{$tID}'>\n";
         }
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         if (!$show_old) {
             echo "<tr><th colspan='7'>";
             echo self::getCount($tID, -1);
             echo "</th></tr>";
         } else {
             // Old
             echo "<tr><th colspan='8'>" . $LANG['consumables'][35] . "</th></tr>";
         }
         $i = 0;
         echo "<tr><th>" . $LANG['common'][2] . "</th><th>" . $LANG['consumables'][23] . "</th>";
         echo "<th>" . $LANG['cartridges'][24] . "</th><th>" . $LANG['consumables'][26] . "</th>";
         if ($show_old) {
             echo "<th>" . $LANG['common'][34] . "</th>";
         }
         echo "<th>" . $LANG['financial'][3] . "</th>";
         if (!$show_old && $canedit && $DB->result($result, 0, 0) != 0) {
             echo "<th>";
             User::dropdown(array('value' => $consitem->fields["entities_id"], 'right' => 'all'));
             echo "&nbsp;<input type='submit' class='submit' name='give' value='" . $LANG['consumables'][32] . "'>";
             echo "</th>";
         } else {
             echo "<th>&nbsp;</th>";
         }
         if ($canedit) {
             echo "<th>&nbsp;</th>";
         }
         echo "</tr>";
     }
     $where = "";
     $leftjoin = "";
     $addselect = "";
     if (!$show_old) {
         // NEW
         $where = " AND `date_out` IS NULL\n                  ORDER BY `date_in`, `id`";
     } else {
         //OLD
         $where = " AND `date_out` IS NOT NULL\n                  ORDER BY `date_out` DESC,\n                           `date_in`,\n                           `id`";
         $leftjoin = " LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_consumables`.`users_id`) ";
         $addselect = ", `glpi_users`.`realname` AS REALNAME,\n                        `glpi_users`.`firstname` AS FIRSTNAME,\n                        `glpi_users`.`id` AS USERID,\n                        `glpi_users`.`name` AS USERNAME ";
     }
     $query = "SELECT `glpi_consumables`.*\n                       {$addselect}\n                FROM `glpi_consumables`\n                {$leftjoin}\n                WHERE `consumableitems_id` = '{$tID}'\n                      {$where}";
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         while ($data = $DB->fetch_array($result)) {
             $date_in = convDate($data["date_in"]);
             $date_out = convDate($data["date_out"]);
             echo "<tr class='tab_bg_1'><td class='center'>" . $data["id"] . "</td>";
             echo "<td class='center'>" . self::getStatus($data["id"]) . "</td>";
             echo "<td class='center'>" . $date_in . "</td>";
             echo "<td class='center'>" . $date_out . "</td>";
             if ($show_old) {
                 echo "<td class='center'>";
                 echo formatUserName($data["USERID"], $data["USERNAME"], $data["REALNAME"], $data["FIRSTNAME"]);
                 echo "</td>";
             }
             echo "<td class='center'>";
             Infocom::showDisplayLink('Consumable', $data["id"], 1);
             echo "</td>";
             if (!$show_old && $canedit) {
                 echo "<td class='center'>";
                 echo "<input type='checkbox' name='out[" . $data["id"] . "]'>";
                 echo "</td>";
             }
             if ($show_old && $canedit) {
                 echo "<td class='center'>";
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/consumable.form.php?restore=restore&amp;id=" . $data["id"] . "&amp;tID={$tID}'>" . $LANG['consumables'][37] . "</a>";
                 echo "</td>";
             }
             echo "<td class='center'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/consumable.form.php?delete=delete&amp;id=" . $data["id"] . "&amp;tID={$tID}'>" . $LANG['buttons'][6] . "</a>";
             echo "</td></tr>";
         }
     }
     echo "</table></div>";
     if (!$show_old && $canedit) {
         echo "</form>";
     }
 }
Exemplo n.º 11
0
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
if (!isset($_POST["id"])) {
    exit;
}
if (!isset($_REQUEST['glpi_tab'])) {
    exit;
}
checkRight("consumable", "r");
$consumable = new ConsumableItem();
if ($_POST["id"] > 0 && $consumable->can($_POST["id"], 'r')) {
    switch ($_REQUEST['glpi_tab']) {
        case -1:
            Consumable::showAddForm($consumable);
            Consumable::showForItem($consumable);
            Consumable::showForItem($consumable, 1);
            Infocom::showForItem($consumable);
            Document::showAssociated($consumable);
            Link::showForItem('ConsumableItem', $_POST["id"]);
            Plugin::displayAction($consumable, $_REQUEST['glpi_tab']);
            break;
        case 4:
            Infocom::showForItem($consumable);
            break;
        case 5:
Exemplo n.º 12
0
 /**
  * Show list of items
  * 
  * @param type $fields
  */
 function listItemsForUser($requesters_id, $options = array())
 {
     $params['begin_date'] = "NULL";
     $params['end_date'] = "NULL";
     foreach ($options as $key => $val) {
         $params[$key] = $val;
     }
     $data = $this->find('`requesters_id` = ' . $requesters_id . " " . "AND `end_date` >= '" . $params['begin_date'] . "' " . "AND (`end_date` <= '" . $params['end_date'] . "' OR `end_date` IS NULL)", "`end_date` DESC");
     $message = null;
     if (!empty($data)) {
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='7'>" . __('Consumable request report', 'consumables') . "</th>";
         $message .= "</tr>";
         $message .= "<tr>";
         $message .= "<th>" . _n('Consumable', 'Consumables', 1) . "</th>";
         $message .= "<th>" . _n('Consumable type', 'Consumable types', 1) . "</th>";
         $message .= "<th>" . __('Requester') . "</th>";
         $message .= "<th>" . __('Approver') . "</th>";
         $message .= "<th>" . __('Number of used consumables') . "</th>";
         $message .= "<th>" . __('Request date') . "</th>";
         $message .= "<th>" . __('Status') . "</th>";
         $message .= "</tr>";
         $consumable = new ConsumableItem();
         foreach ($data as $field) {
             $message .= "<tr class='tab_bg_1'>";
             $consumable->getFromDB($field['consumables_id']);
             $message .= "<td>" . $consumable->getLink() . "</td>";
             $message .= "<td>" . Dropdown::getDropdownName(ConsumableItemType::getTable(), $field['consumableitemtypes_id']) . "</td>";
             $message .= "<td>" . getUserName($field['requesters_id']) . "</td>";
             $message .= "<td>" . getUserName($field['validators_id']) . "</td>";
             $message .= "<td>" . $field['number'] . "</td>";
             $message .= "<td>" . Html::convDateTime($field['date_mod']) . "</td>";
             $message .= "<td>";
             $bgcolor = CommonITILValidation::getStatusColor($field['status']);
             $status = CommonITILValidation::getStatus($field['status']);
             $message .= "<div style='background-color:" . $bgcolor . ";'>" . $status . "</div>";
             $message .= "</td>";
             $message .= "</tr>";
         }
         $message .= "</table>";
         $message .= "</div>";
     } else {
         $message .= "<div class='center'>";
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='6'>" . __('Consumable request report', 'consumables') . "</th>";
         $message .= "</tr>";
         $message .= "<tr><td class='center'>" . __('No item found') . "</td></tr>";
         $message .= "</table>";
     }
     return array('success' => true, 'message' => $message);
 }