Skip to content

Commit 9053003

Browse files
committed
new plugin
1 parent 5dad7e5 commit 9053003

34 files changed

+6121
-0
lines changed

ajax/dropdownAllItems.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/*
3+
* @version $Id: $
4+
-------------------------------------------------------------------------
5+
LICENSE
6+
7+
This file is part of GestStock plugin for GLPI.
8+
9+
GestStock is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU Affero General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
GestStock is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU Affero General Public License for more details.
18+
19+
You should have received a copy of the GNU Affero General Public License
20+
along with GestStock. If not, see <http://www.gnu.org/licenses/>.
21+
22+
@package geststock
23+
@author Nelly Mahu-Lasson
24+
@copyright Copyright (c) 2017 GestStock plugin team
25+
@license AGPL License 3.0 or (at your option) any later version
26+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+
@link
28+
@since version 1.0.0
29+
--------------------------------------------------------------------------
30+
*/
31+
32+
include ("../../../inc/includes.php");
33+
header("Content-Type: text/html; charset=UTF-8");
34+
Html::header_nocache();
35+
36+
// Make a select box
37+
38+
if (isset($_POST["itemtype"])) {
39+
PluginGeststockReservation::showAllModels( $_POST['myname'], $_POST['itemtype']);
40+
}

ajax/dropdownLocations.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/*
3+
* @version $Id: $
4+
-------------------------------------------------------------------------
5+
LICENSE
6+
7+
This file is part of GestStock plugin for GLPI.
8+
9+
GestStock is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU Affero General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
GestStock is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU Affero General Public License for more details.
18+
19+
You should have received a copy of the GNU Affero General Public License
20+
along with GestStock. If not, see <http://www.gnu.org/licenses/>.
21+
22+
@package geststock
23+
@author Nelly Mahu-Lasson
24+
@copyright Copyright (c) 2017 GestStock plugin team
25+
@license AGPL License 3.0 or (at your option) any later version
26+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+
@link
28+
@since version 1.0.0
29+
--------------------------------------------------------------------------
30+
*/
31+
32+
include ("../../../inc/includes.php");
33+
header("Content-Type: text/html; charset=UTF-8");
34+
Html::header_nocache();
35+
36+
// Make a select box
37+
if (isset($_POST["entity"])) {
38+
PluginGeststockReservation::showAllLocations($_POST["myname"], $_POST["entity"]);
39+
}

ajax/dropdownNumber.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/*
3+
* @version $Id: $
4+
-------------------------------------------------------------------------
5+
LICENSE
6+
7+
This file is part of GestStock plugin for GLPI.
8+
9+
GestStock is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU Affero General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
GestStock is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU Affero General Public License for more details.
18+
19+
You should have received a copy of the GNU Affero General Public License
20+
along with GestStock. If not, see <http://www.gnu.org/licenses/>.
21+
22+
@package geststock
23+
@author Nelly Mahu-Lasson
24+
@copyright Copyright (c) 2017 GestStock plugin team
25+
@license AGPL License 3.0 or (at your option) any later version
26+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+
@link
28+
@since version 1.0.0
29+
--------------------------------------------------------------------------
30+
*/
31+
32+
include ("../../../inc/includes.php");
33+
header("Content-Type: text/html; charset=UTF-8");
34+
Html::header_nocache();
35+
36+
if (isset($_POST["itemtype"]) && isset($_POST["model"])) {
37+
PluginGeststockReservation::showAllNumbers($_POST["itemtype"], $_POST["model"]);
38+
}

ajax/dropdownTickets.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/*
3+
* @version $Id: $
4+
-------------------------------------------------------------------------
5+
LICENSE
6+
7+
This file is part of GestStock plugin for GLPI.
8+
9+
GestStock is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU Affero General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
GestStock is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU Affero General Public License for more details.
18+
19+
You should have received a copy of the GNU Affero General Public License
20+
along with GestStock. If not, see <http://www.gnu.org/licenses/>.
21+
22+
@package geststock
23+
@author Nelly Mahu-Lasson
24+
@copyright Copyright (c) 2017 GestStock plugin team
25+
@license AGPL License 3.0 or (at your option) any later version
26+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+
@link
28+
@since version 1.0.0
29+
--------------------------------------------------------------------------
30+
*/
31+
32+
include ("../../../inc/includes.php");
33+
header("Content-Type: text/html; charset=UTF-8");
34+
Html::header_nocache();
35+
36+
// Make a select box
37+
if (isset($_POST["entity"])) {
38+
PluginGeststockReservation::showAllTickets($_POST["myname"], $_POST["entity"]);
39+
}

front/config.form.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/*
3+
* @version $Id: $
4+
-------------------------------------------------------------------------
5+
LICENSE
6+
7+
This file is part of GestStock plugin for GLPI.
8+
9+
GestStock is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU Affero General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
GestStock is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU Affero General Public License for more details.
18+
19+
You should have received a copy of the GNU Affero General Public License
20+
along with GestStock. If not, see <http://www.gnu.org/licenses/>.
21+
22+
@package geststock
23+
@author Nelly Mahu-Lasson
24+
@copyright Copyright (c) 2017 GestStock plugin team
25+
@license AGPL License 3.0 or (at your option) any later version
26+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+
@link
28+
@since version 1.0.0
29+
--------------------------------------------------------------------------
30+
*/
31+
32+
include ("../../../inc/includes.php");
33+
34+
$pluginGeststockConfig = new PluginGeststockConfig();
35+
$_POST['id'] = 1;
36+
$_POST['users_id'] = $_SESSION['glpiID'];
37+
38+
if (isset($_POST["add"])) {
39+
if ($newID = $pluginGeststockConfig->add($_POST)) {
40+
Event::log($newID, "pluginGeststock", 4, "tools",
41+
//TRANS: %1$s is the user login, %2$s is the name of the item to add
42+
sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], isset($_POST["name"])));
43+
if ($_SESSION['glpibackcreated']) {
44+
Html::redirect($pluginGeststockConfig->getFormURL()."?id=".$newID);
45+
}
46+
}
47+
Html::back();
48+
49+
} else if (isset($_POST["update"])) {
50+
$pluginGeststockConfig->update($_POST);
51+
Html::back();
52+
53+
} else {
54+
Html::header(PluginGeststockReservation::getTypeName(1), '', "tools", "plugingeststockmenu");
55+
$pluginGeststockConfig->showConfigForm();
56+
Html::footer();
57+
}

front/gestion.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/*
3+
* @version $Id: $
4+
-------------------------------------------------------------------------
5+
LICENSE
6+
7+
This file is part of GestStock plugin for GLPI.
8+
9+
GestStock is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU Affero General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
GestStock is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU Affero General Public License for more details.
18+
19+
You should have received a copy of the GNU Affero General Public License
20+
along with GestStock. If not, see <http://www.gnu.org/licenses/>.
21+
22+
@package geststock
23+
@author Nelly Mahu-Lasson
24+
@copyright Copyright (c) 016-2017 GestStock plugin team
25+
@license AGPL License 3.0 or (at your option) any later version
26+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+
@link
28+
@since version 1.0.0
29+
--------------------------------------------------------------------------
30+
*/
31+
32+
include ("../../../inc/includes.php");
33+
34+
Html::header(PluginGeststockGestion::getTypeName(1), '', "tools", "plugingeststockmenu");
35+
36+
if (Session::haveRight("plugin_geststock", PluginGeststockGestion::GESTION)) {
37+
$config = new PluginGeststockConfig();
38+
$config->getFromDB(1);
39+
$entity = $config->fields['entities_id_stock'];
40+
41+
if (isset($_GET["generate"])) {
42+
PluginGeststockGestion::GenerateReport($entity);
43+
Html::back();
44+
} else {
45+
PluginGeststockGestion::showStock($entity);
46+
}
47+
48+
} else {
49+
Html::displayRightError();
50+
}
51+
Html::footer();

front/reservation.form.php

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
/*
3+
* @version $Id: $
4+
-------------------------------------------------------------------------
5+
LICENSE
6+
7+
This file is part of GestStock plugin for GLPI.
8+
9+
GestStock is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU Affero General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
GestStock is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU Affero General Public License for more details.
18+
19+
You should have received a copy of the GNU Affero General Public License
20+
along with GestStock. If not, see <http://www.gnu.org/licenses/>.
21+
22+
@package geststock
23+
@author Nelly Mahu-Lasson
24+
@copyright Copyright (c) 2017 GestStock plugin team
25+
@license AGPL License 3.0 or (at your option) any later version
26+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+
@link
28+
@since version 1.0.0
29+
--------------------------------------------------------------------------
30+
*/
31+
32+
include ("../../../inc/includes.php");
33+
34+
Session::checkRight("plugin_geststock", READ);
35+
36+
if (!isset($_GET["id"])) {
37+
$_GET["id"] = "";
38+
}
39+
40+
$PluginReservation = new PluginGeststockReservation();
41+
$PluginItem = new PluginGeststockReservation_Item();
42+
$PluginFup = new PluginGeststockFollowup();
43+
$Fup = new TicketFollowup();
44+
45+
if (isset($_POST["add"])) {
46+
$PluginReservation->check(-1, CREATE, $_POST);
47+
if (empty($_POST['users_id'])) {
48+
$_POST['users_id'] = Session::getLoginUserID();
49+
}
50+
if (isset($_GET['tickets_id'])) {
51+
$_POST['tickets_id'] = $_GET['tickets_id'];
52+
}
53+
$newID = $PluginReservation->add($_POST);
54+
if ($newID) {
55+
Event::log($newID, "geststock", 4, "tools",
56+
sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $newID));
57+
}
58+
59+
if (isset($_POST['_nbrereserv'])) {
60+
foreach ($_POST['_nbrereserv'] as $lieu => $val) {
61+
if ($val > 0) {
62+
$newIDitem = $PluginItem->add(['plugin_geststock_reservations_id' => $newID,
63+
'itemtype' => $_POST['_itemtype'],
64+
'models_id' => $_POST['_model'],
65+
'nbrereserv' => $val,
66+
'locations_id_stock' => $lieu]);
67+
68+
if ($newIDitem) {
69+
$PluginFup->add(['plugin_geststock_reservations_id' => $newID,
70+
'plugin_geststock_reservations_items_id' => $newIDitem,
71+
'locations_id_old' => $lieu,
72+
'users_id' => Session::getLoginUserID()]);
73+
74+
$Fup->add(['tickets_id' => $_POST['tickets_id'],
75+
'content' => sprintf(__('%1$s %2$s'),
76+
__('New reservation created on ', 'geststock'),
77+
sprintf(__('%1$s (%2$s)'),
78+
$_SESSION["glpi_currenttime"],
79+
$newID)),
80+
'date' => $_SESSION["glpi_currenttime"],
81+
'users_id' => Session::getLoginUserID()]);
82+
}
83+
}
84+
}
85+
}
86+
if ($_SESSION['glpibackcreated']) {
87+
Html::redirect($PluginReservation->getFormURL()."?id=".$newID);
88+
}
89+
90+
$ticket = new Ticket();
91+
Html::redirect($ticket->getFormURL()."?id=".$_POST['tickets_id']);
92+
93+
94+
} else if (isset($_POST["update"])) {
95+
$PluginReservation->check($_POST['id'], UPDATE);
96+
$PluginReservation->update($_POST);
97+
Html::back();
98+
99+
} else if (isset($_POST["delete"])) {
100+
$PluginReservation->check($_POST['id'], DELETE);
101+
$PluginReservation->delete($_POST);
102+
Html::redirect($CFG_GLPI["root_doc"]."/plugins/geststock/front/reservation.php");
103+
104+
} else if (isset($_POST["restore"])) {
105+
$PluginReservation->check($_POST['id'], PURGE);
106+
$PluginReservation->restore($_POST);
107+
Html::back();
108+
109+
} else if (isset($_POST["purge"])) {
110+
$PluginReservation->check($_POST['id'], PURGE);
111+
if ($PluginReservation->delete($_POST, 1)) {
112+
Event::log($_POST["id"], "plugingeststockreservation", 4, "tools",
113+
sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
114+
}
115+
Html::redirect($CFG_GLPI["root_doc"]."/plugins/geststock/front/reservation.php");
116+
117+
} else {
118+
Html::header(PluginGeststockReservation::getTypeName(1), '', "tools", "plugingeststockmenu");
119+
$PluginReservation->display($_GET);
120+
Html::footer();
121+
}

0 commit comments

Comments
 (0)