";
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 "
";
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']]];
}