From 07cab4aae76e13130ff3d10b52873da1af6e7ad6 Mon Sep 17 00:00:00 2001 From: yllen Date: Thu, 3 Nov 2022 18:23:46 +0100 Subject: [PATCH 01/11] work for glpi10 - see #24 --- ajax/dropdownAllItems.php | 4 ++-- ajax/dropdownLocations.php | 2 +- ajax/dropdownNumber.php | 2 +- ajax/dropdownTickets.php | 2 +- front/config.form.php | 2 +- front/gestion.php | 2 +- front/reservation.form.php | 2 +- front/reservation.php | 2 +- front/reservation_item.form.php | 11 +++++---- front/reservation_item.php | 2 +- front/specification.form.php | 2 +- hook.php | 7 +++--- inc/config.class.php | 8 ++++--- inc/followup.class.php | 6 ++--- inc/gestion.class.php | 4 ++-- inc/menu.class.php | 4 ++-- inc/profile.class.php | 5 ++-- inc/reservation.class.php | 34 +++++++++++++++------------ inc/reservation_item.class.php | 33 +++++++++++++------------- inc/reservation_item_number.class.php | 2 +- inc/reservationpdf.class.php | 4 ++-- inc/specification.class.php | 23 +++++++++--------- inc/ticket.class.php | 2 +- setup.php | 10 ++++---- 24 files changed, 91 insertions(+), 84 deletions(-) diff --git a/ajax/dropdownAllItems.php b/ajax/dropdownAllItems.php index b1068ce..2dead43 100644 --- a/ajax/dropdownAllItems.php +++ b/ajax/dropdownAllItems.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -36,4 +36,4 @@ if (isset($_POST["itemtype"])) { PluginGeststockReservation::showAllModels( $_POST['myname'], $_POST['itemtype']); -} \ No newline at end of file +} diff --git a/ajax/dropdownLocations.php b/ajax/dropdownLocations.php index 0a91f04..aa17918 100644 --- a/ajax/dropdownLocations.php +++ b/ajax/dropdownLocations.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/ajax/dropdownNumber.php b/ajax/dropdownNumber.php index 097c05a..8561e4c 100644 --- a/ajax/dropdownNumber.php +++ b/ajax/dropdownNumber.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/ajax/dropdownTickets.php b/ajax/dropdownTickets.php index a9e5977..9af9ecc 100644 --- a/ajax/dropdownTickets.php +++ b/ajax/dropdownTickets.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/front/config.form.php b/front/config.form.php index 9460d4f..9ec7a46 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/front/gestion.php b/front/gestion.php index f7f45d0..2601561 100644 --- a/front/gestion.php +++ b/front/gestion.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/front/reservation.form.php b/front/reservation.form.php index b9c1a18..bfb11f9 100644 --- a/front/reservation.form.php +++ b/front/reservation.form.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/front/reservation.php b/front/reservation.php index 34d4e3b..b9376e9 100644 --- a/front/reservation.php +++ b/front/reservation.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/front/reservation_item.form.php b/front/reservation_item.form.php index 859620b..46d1ccf 100644 --- a/front/reservation_item.form.php +++ b/front/reservation_item.form.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -87,18 +87,19 @@ [$field => $value, 'entities_id' => $config->fields['entities_id_stock'], $itemsid => $ri->fields['models_id']]); - if ($data = $req->next()) { - toolbox::logdebug("data ", $data); + $find = false; + foreach ($req as $data) { + $find = true; // stock id of item if ($item->getFromDB($data['id']) && ($item->getField('states_id') == $config->fields['stock_status'])) { $tabid[] = $data['id']; - toolbox::logdebug("tabid", $tabid); } else { Session::addMessageAfterRedirect(__('The item with this number is not free', 'geststock'), false, ERROR); } - } else { + } + if ($find == false) { Session::addMessageAfterRedirect(sprintf(__('Item not found with this %s number', 'geststock'), $field." ".$value), false, ERROR); diff --git a/front/reservation_item.php b/front/reservation_item.php index f9181bc..bfc1896 100644 --- a/front/reservation_item.php +++ b/front/reservation_item.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/front/specification.form.php b/front/specification.form.php index efe488c..6227fbb 100644 --- a/front/specification.form.php +++ b/front/specification.form.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/hook.php b/hook.php index 661af90..7db574f 100644 --- a/hook.php +++ b/hook.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -138,9 +138,8 @@ function plugin_geststock_giveItem($type, $ID, $data, $num) { $number_device = count($result_device); $out = ''; if ($number_device > 0) { - for ($y=0 ; $y < $number_device ; $y++) { + foreach ($result_device as $row) { $column = "name"; - $row = $result_device->next(); $type = $row['itemtype']; if (!($item = $dbu->getItemForItemtype($type))) { continue; @@ -165,7 +164,7 @@ function plugin_geststock_giveItem($type, $ID, $data, $num) { 'ORDER' => $colname]; if ($result_linked = $DB->request($query)) { if (count($result_linked)) { - while ($data = $result_linked->next()) { + foreach ($result_linked as $data) { $out .= $data['nbrereserv']. " ".$item->getTypeName($data['nbrereserv'])." - ".$data['name']."
"; } diff --git a/inc/config.class.php b/inc/config.class.php index bae3433..707e60b 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -136,9 +136,11 @@ static function showConfigForm() { echo ""; if ($config->getFromDB(1)) { - echo ""; + echo Html::submit(_sx('button', 'Update'), ['name' => 'update', + 'class' => 'btn btn-primary']); } else { - echo ""; + echo Html::submit(_sx('button', 'Add'), ['name' => 'add', + 'class' => 'btn btn-primary']); } echo ""; HTML::closeForm(); diff --git a/inc/followup.class.php b/inc/followup.class.php index 18610cb..fb1212c 100644 --- a/inc/followup.class.php +++ b/inc/followup.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -83,7 +83,7 @@ static function showMassiveActionsSubForm(MassiveAction $ma) { 'addicon' => false, 'comments' => false]); echo "

\n"; - echo Html::submit(_x('button', 'Move'), ['name' => 'massiveaction']).""; + echo Html::submit(_sx('button', 'Move'), ['name' => 'massiveaction']).""; return true; } return parent::showMassiveActionsSubForm($ma); @@ -136,4 +136,4 @@ static function rawSearchOptionstoAdd($itemtype=null) { return $tab; } -} \ No newline at end of file +} diff --git a/inc/gestion.class.php b/inc/gestion.class.php index 1a65cf1..b7ef67d 100644 --- a/inc/gestion.class.php +++ b/inc/gestion.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -222,4 +222,4 @@ static function GenerateReport($entity) { file_put_contents(GLPI_PLUGIN_DOC_DIR."/geststock/tova.txt", $text); } -} \ No newline at end of file +} diff --git a/inc/menu.class.php b/inc/menu.class.php index 2517fcd..6a66ca3 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -65,4 +65,4 @@ static function removeRightsFromSession() { unset($_SESSION['glpimenu']['tools']['content']['pluginGeststockmenu']); } } -} \ No newline at end of file +} diff --git a/inc/profile.class.php b/inc/profile.class.php index 3b17f49..8500aac 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -117,7 +117,8 @@ function showForm($ID, $options=[]) { if ($canedit) { echo "
"; echo Html::hidden('id', ['value' => $ID]); - echo Html::submit(_sx('button', 'Save'), ['name' => 'update']); + echo Html::submit(_sx('button', 'Update'), ['name' => 'update', + 'class' => 'btn btn-primary']); echo "
\n"; Html::closeForm(); } diff --git a/inc/reservation.class.php b/inc/reservation.class.php index e47b10a..46828a5 100644 --- a/inc/reservation.class.php +++ b/inc/reservation.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -322,9 +322,9 @@ function showForm($ID, $options=[]) { echo ""; echo "".__('Ticket').""; echo "".Dropdown::getDropdownName('glpi_tickets', $ticket->fields['id']); - echo ""; - echo ""; - echo ""; + echo Html::hidden('entities_id_deliv', ['value' => $ticket->fields['entities_id']]); + echo Html::hidden('tickets_id', ['value' => $options['tickets_id']]); + echo Html::hidden('_fromticket', ['value' => 1]); } else { echo ""; @@ -365,8 +365,7 @@ function showForm($ID, $options=[]) { 'maybeempty' => true]); echo ""; echo "Numéro de valise"; - Html::autocompletionTextField($this,'number_tova', - ['value' => $this->fields["number_tova"]]); + echo Html::input('number_tova', ['value' => $this->fields["number_tova"]]); echo ""; echo ""; @@ -388,10 +387,14 @@ function showForm($ID, $options=[]) { echo ""; echo "".__('Comments').""; echo ""; - echo ""; if (empty($this->fields['date_reserv'])) { - echo ""; + echo Html::hidden('date_reserv', ['value' => $_SESSION["glpi_currenttime"]]); } echo "\n"; @@ -982,8 +985,8 @@ static function showForTicket(Ticket $ticket) { echo "".__('Add a reservation', 'geststock').""; echo ""; - echo ""; - echo ""; + echo Html::hidden('tickets_id', ['value' => $ID]); + echo Html::hidden('entities_id', ['value' => $ticket->fields['entities_id']]); if (Session::haveRight(self::$rightname, CREATE)) { echo ""; echo __('Create a reservation from this ticket', 'geststock'); @@ -1086,10 +1089,10 @@ function show_PDF($pdf) { $pdf->setColumnsSize(50,50); $pdf->displayLine(sprintf(__('%1$s: %2$s'), ''.__('Ticket').'', - Html::clean(Dropdown::getDropdownName('glpi_tickets', - $this->fields['tickets_id']))), + Toolbox::stripTags(Dropdown::getDropdownName('glpi_tickets', + $this->fields['tickets_id']))), sprintf(__('%1$s: %2$s'), ''.__('Status').'', - Html::clean(self::getStatusName($this->fields['status'])))); + Toolbox::stripTags(self::getStatusName($this->fields['status'])))); $pdf->displayLine(sprintf(__('%1$s: %2$s'), ''.__('Delivery date', 'geststock').'', Html::convDateTime($this->fields['date_whished'])), @@ -1103,7 +1106,7 @@ function show_PDF($pdf) { sprintf(__('%1$s: %2$s'), 'Numéro de valise ', $this->fields['number_tova']), sprintf(__('%1$s: %2$s'), 'Type de valise ', - Html::clean(self::getStatusTova($this->fields['type_tova'])))); + Toolbox::stripTags(self::getStatusTova($this->fields['type_tova'])))); } $pdf->setColumnsSize(100); @@ -1195,8 +1198,9 @@ static function isHoliday($date) { ) )"; if ($result = $DB->request($query)) { - $row = $result->next(); + foreach ($result as $row) { return $row['cpt']; + } } return false; } diff --git a/inc/reservation_item.class.php b/inc/reservation_item.class.php index 331052c..6e549f7 100644 --- a/inc/reservation_item.class.php +++ b/inc/reservation_item.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -203,8 +203,9 @@ static function showForItem(PluginGeststockReservation $resa) { $config->getFromDB(1); $entity = $config->fields['entities_id_stock']; PluginGeststockReservation::showAllItems("model", 0, 0, $entity); - echo ""; - echo ""; + echo Html::submit(_sx('button', 'Add'), ['name' => 'additem', + 'class' => 'btn btn-primary']); + echo Html::hidden('reservations_id', ['value' => $instID]); echo ""; echo ""; Html::closeForm(); @@ -321,8 +322,7 @@ static function showForItem(PluginGeststockReservation $resa) { $header_end .= ""; echo $header_begin.$header_top.$header_end; - for ($i=0 ; $i < $number ; $i++) { - $row = $result->next(); + foreach ($result as $row) { $type = $row['itemtype']; if (!($item = $dbu->getItemForItemtype($type))) { continue; @@ -352,7 +352,7 @@ static function showForItem(PluginGeststockReservation $resa) { _n('Stock reservation', 'Stock reservations', 2, 'geststock')." = ".$resa->getNameID()); - while ($data = $result_linked->next()) { + foreach ($result_linked as $data) { $item->getFromDB($data["id"]); Session::addToNavigateListItems($type,$data["id"]); if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { @@ -428,8 +428,8 @@ static function showForItem(PluginGeststockReservation $resa) { if ($canupdate && ($resa->fields['status'] < PluginGeststockReservation::RECEIPT)) { echo ""; - echo ""; - echo ""; + echo Html::hidden('users_id', ['value' => Session::getLoginUserID()]); + echo Html::hidden('reservations_id', ['value' => $resa->getField('id')]); echo ""; echo "" ; @@ -580,10 +580,12 @@ static function showItemToSend(PluginGeststockReservation $resa) { } if ($canupdate) { echo ""; - echo ""; - echo ""; - echo ""; + echo Html::submit(_sx('button', 'Update'), ['name' => 'addotherserial', + 'class' => 'btn btn-primary']); + echo ""> + echo Html::submit(__('Upload files', 'geststock'), ['name' => 'upload', + 'class' => 'btn btn-primary']); + echo Html::hidden('reservations_id', ['value' => $instID]); echo ""; } echo ""; @@ -779,7 +781,7 @@ static function showMassiveActionsSubForm(MassiveAction $ma) { 'addicon' => false, 'comments' => false]); echo "

\n"; - echo Html::submit(_x('button', 'Move'), ['name' => 'massiveaction']).""; + echo Html::submit(_sx('button', 'Move'), ['name' => 'massiveaction']).""; return true; } return parent::showMassiveActionsSubForm($ma); @@ -892,8 +894,7 @@ static function pdfForReservation(PluginPdfSimplePDF $pdf, PluginGeststockReserv if (!$number) { $pdf->displayLine(__('No item found')); } else { - for ($i=0 ; $i < $number ; $i++) { - $row = $result->next(); + foreach ($result as $row) { $type = $row['itemtype']; if (!($item = $dbu->getItemForItemtype($type))) { continue; @@ -919,7 +920,7 @@ static function pdfForReservation(PluginPdfSimplePDF $pdf, PluginGeststockReserv $dbu = new DbUtils(); if ($result_linked = $DB->request($query)) { if (count($result_linked)) { - while ($data = $result_linked->next()) { + foreach ($result_linked as $data) { $item->getFromDB($data["id"]); $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { diff --git a/inc/reservation_item_number.class.php b/inc/reservation_item_number.class.php index 8800625..d38b5a7 100644 --- a/inc/reservation_item_number.class.php +++ b/inc/reservation_item_number.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson -@copyright Copyright (c) 2017-2021 GestStock plugin team +@copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/inc/reservationpdf.class.php b/inc/reservationpdf.class.php index 2de06e0..46c8e01 100644 --- a/inc/reservationpdf.class.php +++ b/inc/reservationpdf.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -59,4 +59,4 @@ static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $ite } return true; } -} \ No newline at end of file +} diff --git a/inc/specification.class.php b/inc/specification.class.php index 28a2781..8b21cb2 100644 --- a/inc/specification.class.php +++ b/inc/specification.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -84,20 +84,17 @@ static function showSpecification($item) { } echo ""; echo "".__('Length', 'geststock').""; - Html::autocompletionTextField($spec, "length", - ["value" => isset($data['length']) ? $data['length'] : '0']); + echo Html::input("length", ["value" => isset($data['length']) ? $data['length'] : '0']); echo "  cm"; echo ""; echo "".__('Width', 'geststock').""; - Html::autocompletionTextField($spec, "width", - ["value" => isset($data['width']) ? $data['width'] : '0']); + echo Html::input("width", ["value" => isset($data['width']) ? $data['width'] : '0']); echo "  cm"; echo ""; echo "".__('Height', 'geststock').""; - Html::autocompletionTextField($spec, "height", - ["value" => isset($data['height']) ? $data['height'] : '0']); + echo Html::input("height", ["value" => isset($data['height']) ? $data['height'] : '0']); echo "  cm"; echo ""; @@ -114,12 +111,14 @@ static function showSpecification($item) { echo ""; if (isset($data['id'])) { - echo ""; - echo ""; + echo Html::submit(_sx('button', 'Update'), ['name' => 'update', + 'class' => 'btn btn-primary']); + echo Html::hidden('id', ['value' => $data['id']]); } else { - echo ""; - echo ""; - echo ""; + echo Html::submit(_sx('button', 'Add'), ['name' => 'add', + 'class' => 'btn btn-primary']); + echo Html::hidden('models_id', ['value' => $item->fields['id']]); + echo Html::hidden('itemtype', ['value' => $type]); } echo ""; echo "" ; diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 1045b3c..0757bbd 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link diff --git a/setup.php b/setup.php index 30a3461..90798ad 100644 --- a/setup.php +++ b/setup.php @@ -20,7 +20,7 @@ @package geststock @author Nelly Mahu-Lasson - @copyright Copyright (c) 2017-2021 GestStock plugin team + @copyright Copyright (c) 2017-2022 GestStock plugin team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link @@ -80,14 +80,14 @@ function plugin_init_geststock() { function plugin_version_geststock() { return ['name' => __('Stock gestion', 'geststock'), - 'version' => '2.0.0', + 'version' => '2.1.0', 'author' => 'Nelly Mahu-Lasson', 'license' => 'GPLv3+', 'homepage' => 'https://github.com/yllen/geststock', 'page' => "/front/reservation.php", - 'minGlpiVersion' => '9.5.3', - 'requirements' => ['glpi' => ['min' => '9.5.3', - 'max' => '9.6']]]; + 'minGlpiVersion' => '10.0.3', + 'requirements' => ['glpi' => ['min' => '10.0.3', + 'max' => '11.0.0']]]; } From e1e1f2a107c4bcbf06d5bfb12ac57f4267b078f1 Mon Sep 17 00:00:00 2001 From: yllen Date: Tue, 8 Nov 2022 18:17:09 +0100 Subject: [PATCH 02/11] fix for fresh install --- front/reservation.form.php | 4 ++-- hook.php | 8 ++++++-- inc/reservation.class.php | 17 ++++++++++++----- inc/reservation_item.class.php | 2 +- inc/reservation_item_number.class.php | 7 +++++-- inc/specification.class.php | 5 ++++- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/front/reservation.form.php b/front/reservation.form.php index bfb11f9..1960a1a 100644 --- a/front/reservation.form.php +++ b/front/reservation.form.php @@ -51,8 +51,8 @@ if (isset($_GET['tickets_id'])) { $_POST['tickets_id'] = $_GET['tickets_id']; } - $newID = $PluginReservation->add($_POST); - if ($newID) { + if ($newID = $PluginReservation->add($_POST)) { + Event::log($newID, "geststock", 4, "tools", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $newID)); } diff --git a/hook.php b/hook.php index 7db574f..4e52f01 100644 --- a/hook.php +++ b/hook.php @@ -31,7 +31,7 @@ function plugin_geststock_install() { global $DB; - $migration = new Migration(140); + $migration = new Migration(210); include_once(Plugin::getPhpDir('geststock')."/inc/gestion.class.php"); @@ -64,6 +64,8 @@ function plugin_geststock_install() { mkdir(PLUGIN_GESTSTOCK_UPLOAD_DIR); } + $migration->executeMigration(); + return true; } @@ -113,6 +115,8 @@ function plugin_geststock_uninstall() { $item->deleteByCriteria(['itemtype' => 'PluginGeststockReservation']); } + $migration->executeMigration(); + return true; } @@ -279,4 +283,4 @@ function plugin_geststock_addWhere($link, $nott, $type, $id, $val) { break; } return ""; -} \ No newline at end of file +} diff --git a/inc/reservation.class.php b/inc/reservation.class.php index 46828a5..ba1c268 100644 --- a/inc/reservation.class.php +++ b/inc/reservation.class.php @@ -425,14 +425,14 @@ static function install(Migration $mig) { `status` int(11) NOT NULL DEFAULT '1', `comment` text COLLATE utf8_unicode_ci, `is_deleted` tinyint(1) NOT NULL default '0', - `date_reserv` DATE COLLATE utf8_unicode_ci NULL, - `date_whished` DATE COLLATE utf8_unicode_ci NULL, - `receipt_date` DATE COLLATE utf8_unicode_ci NULL, - `date_tova` DATE COLLATE utf8_unicode_ci NULL, + `date_reserv` timestamp NULL DEFAULT NULL, + `date_whished` timestamp NULL DEFAULT NULL, + `receipt_date` timestamp NULL DEFAULT NULL, + `date_tova` timestamp NULL DEFAULT NULL, `number_tova` varchar(255) NULL, `type_tova` int(11) NULL, `number_package` int(11) NULL, - `date_mod` datetime DEFAULT NULL, + `date_mod` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE `unicity` (`entities_id_deliv`, `tickets_id`), KEY `users_id` (`users_id`), @@ -443,6 +443,13 @@ static function install(Migration $mig) { $DB->queryOrDie($query, 'Error in creating glpi_plugin_geststock_reservations'. "
".$DB->error()); + } else { + // migration to 2.1.0 + $mig->changeField($table, 'date_reserv', 'date_reserv', "timestamp NULL DEFAULT NULL"); + $mig->changeField($table, 'date_whished', 'date_whished', "timestamp NULL DEFAULT NULL"); + $mig->changeField($table, 'receipt_date', 'receipt_date', "timestamp NULL DEFAULT NULL"); + $mig->changeField($table, 'date_tova', 'date_tova', "timestamp NULL DEFAULT NULL"); + $mig->changeField($table, 'date_mod', 'date_mod', "timestamp NULL DEFAULT NULL"); } } diff --git a/inc/reservation_item.class.php b/inc/reservation_item.class.php index 6e549f7..096ef59 100644 --- a/inc/reservation_item.class.php +++ b/inc/reservation_item.class.php @@ -582,7 +582,7 @@ static function showItemToSend(PluginGeststockReservation $resa) { echo ""; echo Html::submit(_sx('button', 'Update'), ['name' => 'addotherserial', 'class' => 'btn btn-primary']); - echo ""> + echo ""; echo Html::submit(__('Upload files', 'geststock'), ['name' => 'upload', 'class' => 'btn btn-primary']); echo Html::hidden('reservations_id', ['value' => $instID]); diff --git a/inc/reservation_item_number.class.php b/inc/reservation_item_number.class.php index d38b5a7..ca1eaea 100644 --- a/inc/reservation_item_number.class.php +++ b/inc/reservation_item_number.class.php @@ -81,7 +81,7 @@ static function install(Migration $mig) { `locations_id_stock` int(11) NULL, `otherserial` text COLLATE utf8_unicode_ci, `users_id` int(11) NULL, - `date_mod` datetime default NULL, + `date_mod` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `plugin_geststock_reservations_items_id` (`plugin_geststock_reservations_items_id`), KEY `users_id` (users_id), @@ -90,7 +90,10 @@ static function install(Migration $mig) { $DB->queryOrDie($query, 'Error in creating glpi_plugin_geststock_reservations_items_numbers'. "
".$DB->error()); - } + } else { + // migration to 2.1.0 + $mig->changeField($table, 'date_mod', 'date_mod', "timestamp NULL DEFAULT NULL"); + } } diff --git a/inc/specification.class.php b/inc/specification.class.php index 8b21cb2..90e3ebf 100644 --- a/inc/specification.class.php +++ b/inc/specification.class.php @@ -143,13 +143,16 @@ static function install(Migration $mig) { `height` int(11) NULL, `weight` decimal(6,3) NOT NULL DEFAULT '000.000', `volume` float NULL, - `date_mod` datetime DEFAULT NULL, + `date_mod` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE `unicity` (`models_id`, `itemtype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->queryOrDie($query, 'Error in creating glpi_plugin_geststock_specifications'. "
".$DB->error()); + } else { + // migration to 2.1.0 + $mig->changeField($table, 'date_mod', 'date_mod', "timestamp NULL DEFAULT NULL"); } } From 7c4668e0ba89539305eeff460e5b803e442becbb Mon Sep 17 00:00:00 2001 From: yllen Date: Wed, 9 Nov 2022 15:31:49 +0100 Subject: [PATCH 03/11] fix display --- inc/reservation_item.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/reservation_item.class.php b/inc/reservation_item.class.php index 096ef59..38daf4a 100644 --- a/inc/reservation_item.class.php +++ b/inc/reservation_item.class.php @@ -289,7 +289,7 @@ static function showForItem(PluginGeststockReservation $resa) { } $i = $volume = $weight = $totvolume = $totweight = $j = 0; - echo "
"; + echo "
"; if ($canupdate && ($resa->fields['status'] < PluginGeststockReservation::RECEIPT)) { Html::openMassiveActionsForm('mass'.__CLASS__.$rand); $massiveactionparams = ['container' => 'mass'.__CLASS__.$rand]; From 5ee37b6035a9f915855676aea64506d820e6f2c5 Mon Sep 17 00:00:00 2001 From: yllen Date: Wed, 9 Nov 2022 15:36:12 +0100 Subject: [PATCH 04/11] update xml --- geststock.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/geststock.xml b/geststock.xml index 73b4932..a81fd4b 100644 --- a/geststock.xml +++ b/geststock.xml @@ -24,8 +24,13 @@ Nelly Mahu-Lasson - - 2.0.0.0 + + 2.1.0 + 10.0.3 + https://github.com/yllen/geststock/releases/download/v2.1.0/glpi-geststock-2.1.0.tar.gz + + + 2.0.0 9.5.3 https://github.com/yllen/geststock/releases/download/v2.0.0/glpi-geststock-2.0.0.tar.gz From 40e087e109e6ffdfd3c6b31df4cf5179a23f4d97 Mon Sep 17 00:00:00 2001 From: yllen Date: Wed, 9 Nov 2022 16:09:55 +0100 Subject: [PATCH 05/11] fix for fresh install --- inc/config.class.php | 2 +- inc/followup.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 707e60b..841f67d 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -50,7 +50,7 @@ static function install(Migration $mig) { `entities_id_stock` int(11) NULL, `stock_status` int(11) NULL, `transit_status` int(11) NULL, - `date_mod` datetime default NULL, + `date_mod` timestamp NULL DEFAULT NULL, `users_id` int(11) NULL, `criterion` varchar(100) NOT NULL, PRIMARY KEY (`id`), diff --git a/inc/followup.class.php b/inc/followup.class.php index fb1212c..dabe56f 100644 --- a/inc/followup.class.php +++ b/inc/followup.class.php @@ -43,7 +43,7 @@ static function install(Migration $mig) { `locations_id_old` int(11) NULL, `locations_id_new` int(11) NULL, `users_id` int(11) NULL, - `date_mod` datetime default NULL, + `date_mod` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `plugin_geststock_reservations_id` (`plugin_geststock_reservations_id`), KEY `plugin_geststock_reservations_items_id` (`plugin_geststock_reservations_items_id`), From 3d415344002e90b6c7f221b273784cd8ac967fe9 Mon Sep 17 00:00:00 2001 From: yllen Date: Wed, 21 Feb 2024 14:02:20 +0100 Subject: [PATCH 06/11] Better fix - see #13 --- inc/ticket.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 0757bbd..b4187a5 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -55,9 +55,10 @@ static function beforeUpdate(Ticket $ticket) { ['tickets_id' => $ticket->input['id']]) as $resa) { // no transfert if count items selected <> items reserved - $resaid = $resa['id']; + $req = $DB->request("glpi_plugin_geststock_reservations_items", + ['plugin_geststock_reservations_id' => $resa['id']]); - if ($resaitem->getFromDBByCrit(['plugin_geststock_reservations_id' => $resaid])) { + if ($req->count())) { foreach ($DB->request("glpi_plugin_geststock_reservations_items", ['plugin_geststock_reservations_id' => $resa['id']]) as $resait) { $resaitid = $resait['id']; From 433ad419c5db8ef31f03e7d41a135afca23a9b28 Mon Sep 17 00:00:00 2001 From: yllen Date: Thu, 11 Apr 2024 12:35:54 +0200 Subject: [PATCH 07/11] fix for PHP8 --- hook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hook.php b/hook.php index 4e52f01..1de8f87 100644 --- a/hook.php +++ b/hook.php @@ -236,7 +236,7 @@ function plugin_geststock_getAddSearchOptionsNew($itemtype) { 'name' => __('Length', 'geststock'), 'datatype' => 'number', 'joinparams' => ['jointype' => 'child', - 'condition' => [NEWTABLE.'.itemtype' => $obj], + 'condition' => ['NEWTABLE.itemtype' => $obj], 'linkfield' => 'models_id']]; $tab[] = ['id' => '4', From ceaa4c5d0ba82e10d6c693ab2fb493934f362c49 Mon Sep 17 00:00:00 2001 From: yllen Date: Thu, 18 Apr 2024 15:04:53 +0200 Subject: [PATCH 08/11] fix transfer --- inc/ticket.class.php | 7 +++++++ setup.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index b4187a5..5dde9fa 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -38,6 +38,13 @@ static function afterUpdate(Ticket $ticket) { && ($ticket->input['status'] == CommonITILObject::CLOSED)) { $reservation = new PluginGeststockReservation(); $reservation->transfertItem($ticket->input['id']); + // transfert only if not done + foreach ($DB->request('glpi_plugin_geststock_reservations', + ['tickets_id' => $ticket->input['id']]) as $resa) { + if ($reservation->getFromDB($resa['id']) && is_null($resa['receipt_date'])) { + $reservation->transfertItem($ticket->input['id']); + } + } } } diff --git a/setup.php b/setup.php index 90798ad..8edd73e 100644 --- a/setup.php +++ b/setup.php @@ -80,7 +80,7 @@ function plugin_init_geststock() { function plugin_version_geststock() { return ['name' => __('Stock gestion', 'geststock'), - 'version' => '2.1.0', + 'version' => '2.1.1', 'author' => 'Nelly Mahu-Lasson', 'license' => 'GPLv3+', 'homepage' => 'https://github.com/yllen/geststock', From 52ab570ed6f27d977aa803919a21805726d42ade Mon Sep 17 00:00:00 2001 From: yllen Date: Thu, 18 Apr 2024 15:11:02 +0200 Subject: [PATCH 09/11] update xml --- geststock.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/geststock.xml b/geststock.xml index a81fd4b..d3c1301 100644 --- a/geststock.xml +++ b/geststock.xml @@ -24,6 +24,11 @@ Nelly Mahu-Lasson + + 2.1.1 + ~10.0.3 + https://github.com/yllen/geststock/releases/download/v2.1.1/glpi-geststock-2.1.1.tar.gz + 2.1.0 10.0.3 @@ -31,7 +36,7 @@ 2.0.0 - 9.5.3 + ~9.5.3 https://github.com/yllen/geststock/releases/download/v2.0.0/glpi-geststock-2.0.0.tar.gz From 157b6eb6d31f4b908523ce2c352ffa522811ed19 Mon Sep 17 00:00:00 2001 From: yllen Date: Thu, 18 Apr 2024 18:43:38 +0200 Subject: [PATCH 10/11] fix for uninstall --- inc/reservation_item_number.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/reservation_item_number.class.php b/inc/reservation_item_number.class.php index ca1eaea..57afa60 100644 --- a/inc/reservation_item_number.class.php +++ b/inc/reservation_item_number.class.php @@ -101,7 +101,6 @@ static function uninstall() { global $DB; $tables = ['glpi_plugin_geststock_reservations_items_numbers']; - foreach ($tables as $table) { $query = "DROP TABLE IF EXISTS `$table`"; $DB->queryOrDie($query, $DB->error()); From 831b9580989c05d3a80d2f910e2fd7aab628aeaf Mon Sep 17 00:00:00 2001 From: yllen Date: Thu, 18 Apr 2024 18:44:14 +0200 Subject: [PATCH 11/11] fix for markerplace --- hook.php | 2 +- inc/menu.class.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hook.php b/hook.php index 1de8f87..88b56e4 100644 --- a/hook.php +++ b/hook.php @@ -99,7 +99,7 @@ function plugin_geststock_uninstall() { include_once(Plugin::getPhpDir('geststock')."/inc/specification.class.php"); PluginGeststockSpecification::uninstall(); - include_once(GLPI_ROOT."/plugins/geststock/inc/reservation_item_number.class.php"); + include_once(Plugin::getPhpDir('geststock')."/inc/reservation_item_number.class.php"); PluginGeststockReservation_Item_Number::uninstall(); include_once(Plugin::getPhpDir('geststock')."/inc/menu.class.php"); diff --git a/inc/menu.class.php b/inc/menu.class.php index 6a66ca3..52ec06b 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -43,9 +43,10 @@ static function getMenuName() { static function getMenuContent() { + $locinstall = Plugin::getPhpDir('geststock', false); $menu = []; $menu['title'] = self::getMenuName(); - $menu['page'] = "/plugins/geststock/front/reservation.php"; + $menu['page'] = $locinstall."/front/reservation.php"; $menu['links']['search'] = PluginGeststockReservation::getSearchURL(false); if (Session::haveRight('plugin_geststock', CREATE)) {