Refactor module 'machineDefault' et repo 'machine' pour que soit un param du repo, mais automatiquement rempli par le module
This commit is contained in:
parent
e3934c9090
commit
798b88caa4
184
LICENSE
184
LICENSE
|
@ -1,11 +1,11 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
The GNU General Public License is a free, copyleft license for
|
||||||
software and other kinds of works.
|
software and other kinds of works.
|
||||||
|
@ -68,7 +68,7 @@ patents cannot be used to render the program non-free.
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
|
@ -211,26 +211,26 @@ and you may offer support or warranty protection for a fee.
|
||||||
produce it from the Program, in the form of source code under the
|
produce it from the Program, in the form of source code under the
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
a) The work must carry prominent notices stating that you modified
|
||||||
it, and giving a relevant date.
|
it, and giving a relevant date.
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
b) The work must carry prominent notices stating that it is
|
||||||
released under this License and any conditions added under section
|
released under this License and any conditions added under section
|
||||||
7. This requirement modifies the requirement in section 4 to
|
7. This requirement modifies the requirement in section 4 to
|
||||||
"keep intact all notices".
|
"keep intact all notices".
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
c) You must license the entire work, as a whole, under this
|
||||||
License to anyone who comes into possession of a copy. This
|
License to anyone who comes into possession of a copy. This
|
||||||
License will therefore apply, along with any applicable section 7
|
License will therefore apply, along with any applicable section 7
|
||||||
additional terms, to the whole of the work, and all its parts,
|
additional terms, to the whole of the work, and all its parts,
|
||||||
regardless of how they are packaged. This License gives no
|
regardless of how they are packaged. This License gives no
|
||||||
permission to license the work in any other way, but it does not
|
permission to license the work in any other way, but it does not
|
||||||
invalidate such permission if you have separately received it.
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
d) If the work has interactive user interfaces, each must display
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
work need not make them do so.
|
work need not make them do so.
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
A compilation of a covered work with other separate and independent
|
||||||
works, which are not by their nature extensions of the covered work,
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
@ -249,46 +249,46 @@ of sections 4 and 5, provided that you also convey the
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
in one of these ways:
|
in one of these ways:
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by the
|
(including a physical distribution medium), accompanied by the
|
||||||
Corresponding Source fixed on a durable physical medium
|
Corresponding Source fixed on a durable physical medium
|
||||||
customarily used for software interchange.
|
customarily used for software interchange.
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by a
|
(including a physical distribution medium), accompanied by a
|
||||||
written offer, valid for at least three years and valid for as
|
written offer, valid for at least three years and valid for as
|
||||||
long as you offer spare parts or customer support for that product
|
long as you offer spare parts or customer support for that product
|
||||||
model, to give anyone who possesses the object code either (1) a
|
model, to give anyone who possesses the object code either (1) a
|
||||||
copy of the Corresponding Source for all the software in the
|
copy of the Corresponding Source for all the software in the
|
||||||
product that is covered by this License, on a durable physical
|
product that is covered by this License, on a durable physical
|
||||||
medium customarily used for software interchange, for a price no
|
medium customarily used for software interchange, for a price no
|
||||||
more than your reasonable cost of physically performing this
|
more than your reasonable cost of physically performing this
|
||||||
conveying of source, or (2) access to copy the
|
conveying of source, or (2) access to copy the
|
||||||
Corresponding Source from a network server at no charge.
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
c) Convey individual copies of the object code with a copy of the
|
||||||
written offer to provide the Corresponding Source. This
|
written offer to provide the Corresponding Source. This
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
only if you received the object code with such an offer, in accord
|
only if you received the object code with such an offer, in accord
|
||||||
with subsection 6b.
|
with subsection 6b.
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
d) Convey the object code by offering access from a designated
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
Corresponding Source in the same way through the same place at no
|
Corresponding Source in the same way through the same place at no
|
||||||
further charge. You need not require recipients to copy the
|
further charge. You need not require recipients to copy the
|
||||||
Corresponding Source along with the object code. If the place to
|
Corresponding Source along with the object code. If the place to
|
||||||
copy the object code is a network server, the Corresponding Source
|
copy the object code is a network server, the Corresponding Source
|
||||||
may be on a different server (operated by you or a third party)
|
may be on a different server (operated by you or a third party)
|
||||||
that supports equivalent copying facilities, provided you maintain
|
that supports equivalent copying facilities, provided you maintain
|
||||||
clear directions next to the object code saying where to find the
|
clear directions next to the object code saying where to find the
|
||||||
Corresponding Source. Regardless of what server hosts the
|
Corresponding Source. Regardless of what server hosts the
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
available for as long as needed to satisfy these requirements.
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
you inform other peers where the object code and Corresponding
|
you inform other peers where the object code and Corresponding
|
||||||
Source of the work are being offered to the general public at no
|
Source of the work are being offered to the general public at no
|
||||||
charge under subsection 6d.
|
charge under subsection 6d.
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
A separable portion of the object code, whose source code is excluded
|
||||||
from the Corresponding Source as a System Library, need not be
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
@ -362,28 +362,28 @@ for which you have or can give appropriate copyright permission.
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
that material) supplement the terms of this License with terms:
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
terms of sections 15 and 16 of this License; or
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
author attributions in that material or in the Appropriate Legal
|
author attributions in that material or in the Appropriate Legal
|
||||||
Notices displayed by works containing it; or
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
requiring that modified versions of such material be marked in
|
requiring that modified versions of such material be marked in
|
||||||
reasonable ways as different from the original version; or
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
authors of the material; or
|
authors of the material; or
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
e) Declining to grant rights under trademark law for use of some
|
||||||
trade names, trademarks, or service marks; or
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
f) Requiring indemnification of licensors and authors of that
|
||||||
material by anyone who conveys the material (or modified versions of
|
material by anyone who conveys the material (or modified versions of
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
any liability that these contractual assumptions directly impose on
|
any liability that these contractual assumptions directly impose on
|
||||||
those licensors and authors.
|
those licensors and authors.
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
All other non-permissive additional terms are considered "further
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
@ -618,9 +618,9 @@ an absolute waiver of all civil liability in connection with the
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
copy of the Program in return for a fee.
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
possible use to the public, the best way to achieve this is to make it
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
@ -631,31 +631,31 @@ to attach them to the start of each source file to most effectively
|
||||||
state the exclusion of warranty; and each file should have at least
|
state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
{one line to give the program's name and a brief idea of what it does.}
|
{one line to give the program's name and a brief idea of what it does.}
|
||||||
Copyright (C) {year} {name of author}
|
Copyright (C) {year} {name of author}
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If the program does terminal interaction, make it output a short
|
||||||
notice like this when it starts in an interactive mode:
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
{project} Copyright (C) {year} {fullname}
|
{project} Copyright (C) {year} {fullname}
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
parts of the General Public License. Of course, your program's commands
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
|
|
@ -23,7 +23,11 @@
|
||||||
|
|
||||||
/* [1] Creation de la machine
|
/* [1] Creation de la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_machine = new Repo('machine/create', [$code, $name]);
|
$create_machine = new Repo('machine/create', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$code,
|
||||||
|
$name
|
||||||
|
]);
|
||||||
$id_machine = $create_machine->answer();
|
$id_machine = $create_machine->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
|
@ -31,8 +35,6 @@
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] Creation du groupe de meme nom que la machine
|
/* [2] Creation du groupe de meme nom que la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_group = new Repo('cluster/create', [$name] );
|
$create_group = new Repo('cluster/create', [$name] );
|
||||||
|
@ -43,11 +45,14 @@
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] Association au groupe
|
/* [3] Association au groupe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$assoc_goup = new Repo('cluster/link', [$id_group, $id_machine, clusterRepo::MACHINE_CLASS]);
|
$assoc_goup = new Repo('cluster/link', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$id_group,
|
||||||
|
$id_machine,
|
||||||
|
clusterRepo::MACHINE_CLASS]
|
||||||
|
);
|
||||||
$id_assoc = $assoc_goup->answer();
|
$id_assoc = $assoc_goup->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
|
@ -55,12 +60,11 @@
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] Gestion du retour
|
/* [4] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return [
|
return [
|
||||||
'ModuleError' => ManagerError::Success,
|
'ModuleError' => ManagerError::Success,
|
||||||
'id_machine' => $id_machine,
|
'id_machine' => $id_machine,
|
||||||
'id_cluster' => $id_group
|
'id_cluster' => $id_group
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -82,7 +86,12 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
/* Creation de l'association */
|
/* Creation de l'association */
|
||||||
$link_machine = new Repo('cluster/link', [$id_cluster, $id_machine, clusterRepo::MACHINE_CLASS]);
|
$link_machine = new Repo('cluster/link', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$id_cluster,
|
||||||
|
$id_machine,
|
||||||
|
clusterRepo::MACHINE_CLASS
|
||||||
|
]);
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
|
@ -105,7 +114,12 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
/* Suppression de l'association */
|
/* Suppression de l'association */
|
||||||
$link_machine = new Repo('cluster/unlink', [$id_cluster, $id_machine, clusterRepo::MACHINE_CLASS]);
|
$link_machine = new Repo('cluster/unlink', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$id_cluster,
|
||||||
|
$id_machine,
|
||||||
|
clusterRepo::MACHINE_CLASS
|
||||||
|
]);
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
|
@ -126,7 +140,10 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$machine = new Repo('machine/search', [$keywords]);
|
$machine = new Repo('machine/search', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$keywords
|
||||||
|
]);
|
||||||
|
|
||||||
return [ 'machines' => $machine->answer() ];
|
return [ 'machines' => $machine->answer() ];
|
||||||
}
|
}
|
||||||
|
@ -142,7 +159,7 @@
|
||||||
*/
|
*/
|
||||||
public static function getAll(){
|
public static function getAll(){
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$machines = new Repo('machine/getAll');
|
$machines = new Repo('machine/getAll', [$_SESSION['WAREHOUSE']['id']]);
|
||||||
|
|
||||||
return [ 'machines' => $machines->answer() ];
|
return [ 'machines' => $machines->answer() ];
|
||||||
}
|
}
|
||||||
|
@ -162,7 +179,10 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getById', [$id_machine]);
|
$request = new Repo('machine/getById', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$id_machine
|
||||||
|
]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
|
@ -188,7 +208,10 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getByCode', [$code]);
|
$request = new Repo('machine/getByCode', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$code
|
||||||
|
]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
|
@ -215,7 +238,10 @@
|
||||||
|
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getByName', [$name]);
|
$request = new Repo('machine/getByName', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$name
|
||||||
|
]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
|
@ -241,7 +267,10 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getClusters', [$id_machine]);
|
$request = new Repo('machine/getClusters', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$id_machine
|
||||||
|
]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
|
@ -271,7 +300,10 @@
|
||||||
|
|
||||||
/* [1] On verifie l'existence de la machine
|
/* [1] On verifie l'existence de la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$machine_exists = new Repo('machine/getById', [$id_machine]);
|
$machine_exists = new Repo('machine/getById', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$id_machine
|
||||||
|
]);
|
||||||
$machine_data = $machine_exists->answer();
|
$machine_data = $machine_exists->answer();
|
||||||
|
|
||||||
// Si on a recupere aucune machine, on retourne une erreur
|
// Si on a recupere aucune machine, on retourne une erreur
|
||||||
|
@ -324,7 +356,10 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/delete', [$id_machine]);
|
$request = new Repo('machine/delete', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$id_machine
|
||||||
|
]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
return [ 'status' => $answer ];
|
return [ 'status' => $answer ];
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
/* CREATION D'UNE MACHINE
|
/* CREATION D'UNE MACHINE
|
||||||
*
|
*
|
||||||
|
* @id_warehouse<int> UID de l'entrepot
|
||||||
* @code<String> Code de la machine
|
* @code<String> Code de la machine
|
||||||
* @name<String> Nom de la machine
|
* @name<String> Nom de la machine
|
||||||
*
|
*
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
* Renvoie FALSE si une erreur occure
|
* Renvoie FALSE si une erreur occure
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function create($code, $name){
|
public static function create($id_warehouse, $code, $name){
|
||||||
/* [1] Verification de l'unicite de code+name
|
/* [1] Verification de l'unicite de code+name
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$check_unique = ( self::getByCode($code) === false );
|
$check_unique = ( self::getByCode($code) === false );
|
||||||
|
@ -33,7 +34,7 @@
|
||||||
$insert_machine = Database::getPDO()->prepare("INSERT INTO machine(id_machine, id_warehouse, code, name)
|
$insert_machine = Database::getPDO()->prepare("INSERT INTO machine(id_machine, id_warehouse, code, name)
|
||||||
VALUES(DEFAULT, :id_warehouse, :code, :name)");
|
VALUES(DEFAULT, :id_warehouse, :code, :name)");
|
||||||
$insert_machine->execute([
|
$insert_machine->execute([
|
||||||
':id_warehouse' => $_SESSION['WAREHOUSE']['id'],
|
':id_warehouse' => $id_warehouse,
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':name' => $name
|
':name' => $name
|
||||||
]);
|
]);
|
||||||
|
@ -57,12 +58,13 @@
|
||||||
|
|
||||||
/* RENVOIE UNE LISTE DE MACHINE EN FONCTION D'UN MOT CLE
|
/* RENVOIE UNE LISTE DE MACHINE EN FONCTION D'UN MOT CLE
|
||||||
*
|
*
|
||||||
|
* @id_warehouse<int> UID de l'entrepot
|
||||||
* @keyword<String> Element de recherche
|
* @keyword<String> Element de recherche
|
||||||
*
|
*
|
||||||
* @return machines<Array> Retourne les machines trouvees
|
* @return machines<Array> Retourne les machines trouvees
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function search($keyword){
|
public static function search($id_warehouse, $keyword){
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$searchmachines = Database::getPDO()->prepare("SELECT * FROM machine
|
$searchmachines = Database::getPDO()->prepare("SELECT * FROM machine
|
||||||
WHERE id_warehouse = :id_warehouse
|
WHERE id_warehouse = :id_warehouse
|
||||||
|
@ -72,7 +74,7 @@
|
||||||
");
|
");
|
||||||
|
|
||||||
$searchmachines->execute([
|
$searchmachines->execute([
|
||||||
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
':id_warehouse' => $id_warehouse
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return Database::delNumeric( $searchmachines->fetchAll() );
|
return Database::delNumeric( $searchmachines->fetchAll() );
|
||||||
|
@ -85,22 +87,27 @@
|
||||||
|
|
||||||
/* RENVOIE LES GROUPES AUQUEL APPARTIENT UNE MACHINE DONNEE
|
/* RENVOIE LES GROUPES AUQUEL APPARTIENT UNE MACHINE DONNEE
|
||||||
*
|
*
|
||||||
|
* @id_warehouse<int> UID de l'entrepot
|
||||||
* @id_machine<int> UID de la machine en question
|
* @id_machine<int> UID de la machine en question
|
||||||
*
|
*
|
||||||
* @return clusters<Array> Retourne la liste des groupes auquel appartient la machine
|
* @return clusters<Array> Retourne la liste des groupes auquel appartient la machine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function getClusters($id_machine){
|
public static function getClusters($id_warehouse, $id_machine){
|
||||||
/* [1] On redige/execute la requete
|
/* [1] On redige/execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$get_clusters = Database::getPDO()->prepare("SELECT c.* FROM cluster as c, cluster_merge as cm
|
$get_clusters = Database::getPDO()->prepare("SELECT c.*
|
||||||
WHERE cm.id_cluster = c.id_cluster
|
FROM cluster as c, cluster_merge as cm, machine as m
|
||||||
AND cm.id_entity = :id_machine
|
WHERE cm.id_cluster = c.id_cluster
|
||||||
AND cm.class = :class
|
AND cm.id_entity = m.id_machine
|
||||||
|
AND m.id_warehouse = :id_warehouse
|
||||||
|
AND cm.id_entity = :id_machine
|
||||||
|
AND cm.class = :class
|
||||||
ORDER BY c.id_cluster");
|
ORDER BY c.id_cluster");
|
||||||
$get_clusters->execute([
|
$get_clusters->execute([
|
||||||
':id_machine' => $id_machine,
|
':id_warehouse' => $id_warehouse,
|
||||||
':class' => clusterRepo::MACHINE_CLASS
|
':id_machine' => $id_machine,
|
||||||
|
':class' => clusterRepo::MACHINE_CLASS
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/* [2] On retourne la liste des groupes
|
/* [2] On retourne la liste des groupes
|
||||||
|
@ -117,6 +124,7 @@
|
||||||
|
|
||||||
/* MODIFICATION D'UNE MACHINE DONNEE
|
/* MODIFICATION D'UNE MACHINE DONNEE
|
||||||
*
|
*
|
||||||
|
* @id_warehouse<int> UID de l'entrepot
|
||||||
* @id_machine<int> UID de la machine
|
* @id_machine<int> UID de la machine
|
||||||
* @code<String> Code RFID de la machine
|
* @code<String> Code RFID de la machine
|
||||||
* @name<String> Identifiant l'utilisateur
|
* @name<String> Identifiant l'utilisateur
|
||||||
|
@ -124,7 +132,7 @@
|
||||||
* @return status<Boolean> Renvoie si oui ou non tout s'est bien passe
|
* @return status<Boolean> Renvoie si oui ou non tout s'est bien passe
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function edit($id_machine=null, $code=null, $name=null){
|
public static function edit($id_warehouse, $id_machine=null, $code=null, $name=null){
|
||||||
/* [1] Verification de l'unicite de code+name (si differents)
|
/* [1] Verification de l'unicite de code+name (si differents)
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
// On recupere les machine ayant le meme code ou name (si existent)
|
// On recupere les machine ayant le meme code ou name (si existent)
|
||||||
|
@ -149,7 +157,7 @@
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':name' => $name,
|
':name' => $name,
|
||||||
':id_machine' => $id_machine,
|
':id_machine' => $id_machine,
|
||||||
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
':id_warehouse' => $id_warehouse
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,18 +183,21 @@
|
||||||
|
|
||||||
/* SUPPRIME UNE MACHINE DONNE
|
/* SUPPRIME UNE MACHINE DONNE
|
||||||
*
|
*
|
||||||
|
* @id_warehouse<int> UID de l'entrepot
|
||||||
* @id_machine<int> UID de la machine en question
|
* @id_machine<int> UID de la machine en question
|
||||||
*
|
*
|
||||||
* @return status<Boolean> Retourne si oui ou non la machine a bien ete supprime
|
* @return status<Boolean> Retourne si oui ou non la machine a bien ete supprime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function delete($id_machine){
|
public static function delete($id_warehouse, $id_machine){
|
||||||
/* [1] On redige/execute la requete
|
/* [1] On redige/execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$delete_machine = Database::getPDO()->prepare("DELETE FROM machine WHERE id_machine = :id_machine AND id_warehouse = :id_warehouse");
|
$delete_machine = Database::getPDO()->prepare("DELETE FROM machine
|
||||||
|
WHERE id_machine = :id_machine
|
||||||
|
AND id_warehouse = :id_warehouse");
|
||||||
$delete_machine->execute([
|
$delete_machine->execute([
|
||||||
':id_machine' => $id_machine,
|
':id_machine' => $id_machine,
|
||||||
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
':id_warehouse' => $id_warehouse
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,6 +214,148 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RETOURNE UNE MACHINE SPECIFIQUE
|
||||||
|
*
|
||||||
|
* @id_warehouse<id> UID de l'entrepot
|
||||||
|
* @id_machine<id> UID de la machine
|
||||||
|
*
|
||||||
|
* @return machine<Array> Données de la machine
|
||||||
|
* FALSE si aucun résultat
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getById($id_warehouse, $id_machine){
|
||||||
|
/* [1] On rédige/execute la requête
|
||||||
|
=========================================================*/
|
||||||
|
$get = Database::getPDO()->prepare("SELECT m.id_machine, m.code, m.name
|
||||||
|
FROM machine as m
|
||||||
|
WHERE m.id_warehouse = :id_warehouse
|
||||||
|
AND m.id_machine = :id_machine");
|
||||||
|
$get->execute([
|
||||||
|
':id_warehouse' => $id_warehouse,
|
||||||
|
':id_machine' => $id_machine
|
||||||
|
]);
|
||||||
|
|
||||||
|
/* [2] Gestion des données
|
||||||
|
=========================================================*/
|
||||||
|
$found = $get->fetch();
|
||||||
|
|
||||||
|
// Si aucun résultat
|
||||||
|
if( $found === false )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return Database::delNumeric( $found );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RETOURNE UNE MACHINE SPECIFIQUE
|
||||||
|
*
|
||||||
|
* @id_warehouse<id> UID de l'entrepot
|
||||||
|
* @code<String> Code RFID de la machine
|
||||||
|
*
|
||||||
|
* @return machine<Array> Données de la machine
|
||||||
|
* FALSE si aucun résultat
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getByCode($id_warehouse, $code){
|
||||||
|
/* [1] On rédige/execute la requête
|
||||||
|
=========================================================*/
|
||||||
|
$get = Database::getPDO()->prepare("SELECT m.id_machine, m.code, m.name
|
||||||
|
FROM machine as m
|
||||||
|
WHERE m.id_warehouse = :id_warehouse
|
||||||
|
AND m.code = :code");
|
||||||
|
$get->execute([
|
||||||
|
':id_warehouse' => $id_warehouse,
|
||||||
|
':code' => $code
|
||||||
|
]);
|
||||||
|
|
||||||
|
/* [2] Gestion des données
|
||||||
|
=========================================================*/
|
||||||
|
$found = $get->fetch();
|
||||||
|
|
||||||
|
// Si aucun résultat
|
||||||
|
if( $found === false )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return Database::delNumeric( $found );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RETOURNE UNE MACHINE SPECIFIQUE
|
||||||
|
*
|
||||||
|
* @id_warehouse<id> UID de l'entrepot
|
||||||
|
* @name<String> Nom de la machine
|
||||||
|
*
|
||||||
|
* @return machine<Array> Données de la machine
|
||||||
|
* FALSE si aucun résultat
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getByName($id_warehouse, $name){
|
||||||
|
/* [1] On rédige/execute la requête
|
||||||
|
=========================================================*/
|
||||||
|
$get = Database::getPDO()->prepare("SELECT m.id_machine, m.code, m.name
|
||||||
|
FROM machine as m
|
||||||
|
WHERE m.id_warehouse = :id_warehouse
|
||||||
|
AND m.name = :name");
|
||||||
|
$get->execute([
|
||||||
|
':id_warehouse' => $id_warehouse,
|
||||||
|
':name' => $name
|
||||||
|
]);
|
||||||
|
|
||||||
|
/* [2] Gestion des données
|
||||||
|
=========================================================*/
|
||||||
|
$found = $get->fetch();
|
||||||
|
|
||||||
|
// Si aucun résultat
|
||||||
|
if( $found === false )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return Database::delNumeric( $found );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RETOURNE TOUTES LES MACHINES DE L'ENTREPOT
|
||||||
|
*
|
||||||
|
* @id_warehouse<id> UID de l'entrepot
|
||||||
|
*
|
||||||
|
* @return machines<Array> Données des la machine
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getAll($id_warehouse){
|
||||||
|
/* [1] On rédige/execute la requête
|
||||||
|
=========================================================*/
|
||||||
|
$get = Database::getPDO()->prepare("SELECT m.id_machine, m.code, m.name
|
||||||
|
FROM machine as m
|
||||||
|
WHERE m.id_warehouse = :id_warehouse");
|
||||||
|
$get->execute([
|
||||||
|
':id_warehouse' => $id_warehouse
|
||||||
|
]);
|
||||||
|
|
||||||
|
return Database::delNumeric( $get->fetchAll() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue