Intégration de l'entrepot dans les 'repositories' (invisibles pour les 'modules') 'machine' et 'user'
This commit is contained in:
parent
9210abcd64
commit
c045de0f77
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
// On met à jour les informations
|
// On met à jour les informations
|
||||||
$_SESSION['WAREHOUSE'] = [
|
$_SESSION['WAREHOUSE'] = [
|
||||||
'id' => $checkRoot->answer()[0]['id_warehouse'],
|
'id' => (int) $checkRoot->answer()[0]['id_warehouse'],
|
||||||
'name' => $checkRoot->answer()[0]['name']
|
'name' => $checkRoot->answer()[0]['name']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
|
|
||||||
// On met à jour les informations
|
// On met à jour les informations
|
||||||
$_SESSION['ADMIN'] = [
|
$_SESSION['ADMIN'] = [
|
||||||
'id' => $checkBranch->answer()[0]['id_admin'],
|
'id' => (int) $checkBranch->answer()[0]['id_admin'],
|
||||||
'username' => $checkBranch->answer()[0]['username'],
|
'username' => $checkBranch->answer()[0]['username'],
|
||||||
'mail' => $checkBranch->answer()[0]['mail']
|
'mail' => $checkBranch->answer()[0]['mail']
|
||||||
];
|
];
|
||||||
|
|
|
@ -46,6 +46,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct($path=null, $params=null){
|
public function __construct($path=null, $params=null){
|
||||||
|
|
||||||
|
// Si pas authentifié, erreur
|
||||||
|
if( Authentification::auth() < 2 ){
|
||||||
|
$this->error = ManagerError::PermissionError;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Si pas parametre manquant, on quitte
|
// Si pas parametre manquant, on quitte
|
||||||
if( $path == null ){
|
if( $path == null ){
|
||||||
$this->error = ManagerError::MissingPath;
|
$this->error = ManagerError::MissingPath;
|
||||||
|
@ -103,6 +111,9 @@
|
||||||
|
|
||||||
|
|
||||||
public function answer(){
|
public function answer(){
|
||||||
|
if( $this->error != ManagerError::Success )
|
||||||
|
return false;
|
||||||
|
|
||||||
return $this->answer;
|
return $this->answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,10 @@
|
||||||
|
|
||||||
/* [2] Creation de la machine
|
/* [2] Creation de la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$insert_machine = Database::getPDO()->prepare("INSERT INTO machine(id_machine, code, name)
|
$insert_machine = Database::getPDO()->prepare("INSERT INTO machine(id_machine, id_warehouse, code, name)
|
||||||
VALUES(DEFAULT, :code, :name)");
|
VALUES(DEFAULT, :id_warehouse, :code, :name)");
|
||||||
$insert_machine->execute([
|
$insert_machine->execute([
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id'],
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':name' => $name
|
':name' => $name
|
||||||
]);
|
]);
|
||||||
|
@ -63,11 +64,17 @@
|
||||||
*/
|
*/
|
||||||
public static function search($keyword){
|
public static function search($keyword){
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$searchmachines = Database::getPDO()->query("SELECT * FROM machine
|
$searchmachines = Database::getPDO()->prepare("SELECT * FROM machine
|
||||||
WHERE code LIKE '%".$keyword."%'
|
WHERE id_warehouse = :id_warehouse
|
||||||
|
AND ( code LIKE '%".$keyword."%'
|
||||||
OR name LIKE '%".$keyword."%'
|
OR name LIKE '%".$keyword."%'
|
||||||
|
)
|
||||||
");
|
");
|
||||||
|
|
||||||
|
$searchmachines->execute([
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
||||||
|
]);
|
||||||
|
|
||||||
return Database::delNumeric( $searchmachines->fetchAll() );
|
return Database::delNumeric( $searchmachines->fetchAll() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,11 +143,13 @@
|
||||||
$edit_machine = Database::getPDO()->prepare("UPDATE machine
|
$edit_machine = Database::getPDO()->prepare("UPDATE machine
|
||||||
SET code = :code,
|
SET code = :code,
|
||||||
name = :name
|
name = :name
|
||||||
WHERE id_machine = :id_machine");
|
WHERE id_machine = :id_machine
|
||||||
|
AND id_warehouse = :id_warehouse");
|
||||||
$edit_machine->execute([
|
$edit_machine->execute([
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':name' => $name,
|
':name' => $name,
|
||||||
':id_machine' => $id_machine
|
':id_machine' => $id_machine,
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,8 +183,11 @@
|
||||||
public static function delete($id_machine){
|
public static function delete($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");
|
$delete_machine = Database::getPDO()->prepare("DELETE FROM machine WHERE id_machine = :id_machine AND id_warehouse = :id_warehouse");
|
||||||
$delete_machine->execute([ ':id_machine' => $id_machine ]);
|
$delete_machine->execute([
|
||||||
|
':id_machine' => $id_machine,
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
/* [2] On verifie que la machine n'existe plus
|
/* [2] On verifie que la machine n'existe plus
|
||||||
|
|
|
@ -34,9 +34,10 @@
|
||||||
|
|
||||||
/* [2] Creation de l'utilisateur
|
/* [2] Creation de l'utilisateur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status)
|
$insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, id_warehouse, code, username, firstname, lastname, mail, password, status)
|
||||||
VALUES(DEFAULT, :code, :username, :firstname, :lastname, :mail, :password, :status)");
|
VALUES(DEFAULT, :id_warehouse, :code, :username, :firstname, :lastname, :mail, :password, :status)");
|
||||||
$insert_user->execute([
|
$insert_user->execute([
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id'],
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':username' => $username,
|
':username' => $username,
|
||||||
':firstname' => $firstname,
|
':firstname' => $firstname,
|
||||||
|
@ -72,14 +73,20 @@
|
||||||
*/
|
*/
|
||||||
public static function search($keyword){
|
public static function search($keyword){
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$searchusers = Database::getPDO()->query("SELECT * FROM user
|
$searchusers = Database::getPDO()->prepare("SELECT * FROM user
|
||||||
WHERE code LIKE '%".$keyword."%'
|
WHERE id_warehouse = :id_warehouse
|
||||||
|
AND ( code LIKE '%".$keyword."%'
|
||||||
OR username LIKE '%".$keyword."%'
|
OR username LIKE '%".$keyword."%'
|
||||||
OR firstname LIKE '%".$keyword."%'
|
OR firstname LIKE '%".$keyword."%'
|
||||||
OR lastname LIKE '%".$keyword."%'
|
OR lastname LIKE '%".$keyword."%'
|
||||||
OR mail LIKE '%".$keyword."%'
|
OR mail LIKE '%".$keyword."%'
|
||||||
|
)
|
||||||
");
|
");
|
||||||
|
|
||||||
|
$searchusers->execute([
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
||||||
|
]);
|
||||||
|
|
||||||
return Database::delNumeric( $searchusers->fetchAll() );
|
return Database::delNumeric( $searchusers->fetchAll() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +168,8 @@
|
||||||
mail = :mail,
|
mail = :mail,
|
||||||
password = :password,
|
password = :password,
|
||||||
status = :status
|
status = :status
|
||||||
WHERE id_user = :id_user");
|
WHERE id_user = :id_user
|
||||||
|
AND id_warehouse = :id_warehouse");
|
||||||
$edit_user->execute([
|
$edit_user->execute([
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':username' => $username,
|
':username' => $username,
|
||||||
|
@ -170,7 +178,8 @@
|
||||||
':mail' => $mail,
|
':mail' => $mail,
|
||||||
':password' => $password,
|
':password' => $password,
|
||||||
':status' => $status,
|
':status' => $status,
|
||||||
':id_user' => $id_user
|
':id_user' => $id_user,
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,8 +218,11 @@
|
||||||
public static function delete($id_user){
|
public static function delete($id_user){
|
||||||
/* [1] On redige/execute la requete
|
/* [1] On redige/execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$delete_user = Database::getPDO()->prepare("DELETE FROM user WHERE id_user = :id_user");
|
$delete_user = Database::getPDO()->prepare("DELETE FROM user WHERE id_user = :id_user AND id_warehouse = :id_warehouse");
|
||||||
$delete_user->execute([ ':id_user' => $id_user ]);
|
$delete_user->execute([
|
||||||
|
':id_user' => $id_user,
|
||||||
|
':id_warehouse' => $_SESSION['WAREHOUSE']['id']
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
/* [2] On verifie que l'utilisateur n'existe plus
|
/* [2] On verifie que l'utilisateur n'existe plus
|
||||||
|
|
Loading…
Reference in New Issue