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..1960a1a 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 @@ -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/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/geststock.xml b/geststock.xml index 73b4932..d3c1301 100644 --- a/geststock.xml +++ b/geststock.xml @@ -24,9 +24,19 @@ Nelly Mahu-Lasson - - 2.0.0.0 - 9.5.3 + + 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 + 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 diff --git a/hook.php b/hook.php index 661af90..88b56e4 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 @@ -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; } @@ -97,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"); @@ -113,6 +115,8 @@ function plugin_geststock_uninstall() { $item->deleteByCriteria(['itemtype' => 'PluginGeststockReservation']); } + $migration->executeMigration(); + return true; } @@ -138,9 +142,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 +168,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']."
"; } @@ -233,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', @@ -280,4 +283,4 @@ function plugin_geststock_addWhere($link, $nott, $type, $id, $val) { break; } return ""; -} \ No newline at end of file +} diff --git a/inc/config.class.php b/inc/config.class.php index bae3433..841f67d 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 @@ -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`), @@ -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..dabe56f 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 @@ -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`), @@ -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..52ec06b 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 @@ -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)) { @@ -65,4 +66,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..ba1c268 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"; @@ -422,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`), @@ -440,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"); } } @@ -982,8 +992,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 +1096,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 +1113,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 +1205,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..38daf4a 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(); @@ -288,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]; @@ -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..57afa60 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 @@ -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"); + } } @@ -98,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()); 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..90e3ebf 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 "" ; @@ -144,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"); } } diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 1045b3c..5dde9fa 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 @@ -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']); + } + } } } @@ -55,9 +62,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']; diff --git a/setup.php b/setup.php index 30a3461..8edd73e 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.1', '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']]]; }