Commit 8db6b42f authored by diery's avatar diery

Update

parent a47b3644
This diff is collapsed.
...@@ -78,7 +78,7 @@ $db['default'] = array( ...@@ -78,7 +78,7 @@ $db['default'] = array(
'hostname' => 'localhost', 'hostname' => 'localhost',
'username' => 'root', 'username' => 'root',
'password' => '', 'password' => '',
'database' => '', 'database' => 'inspinia_ci3',
'dbdriver' => 'mysqli', 'dbdriver' => 'mysqli',
'dbprefix' => '', 'dbprefix' => '',
'pconnect' => FALSE, 'pconnect' => FALSE,
......
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class C_sys_menu extends MY_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('sys/M_sys_menu', 'menu');
$this->load->model('sys/M_sys_sous_menu', 'sous_menu');
$this->load->model('sys/M_sys_role', 'role');
// $this->load->helper('form');
}
public function index()
{
$menu_liste = $this->menu->get_menu_liste();
$data['menu_liste'] = $menu_liste;
$this->load->view('sys/V_sys_menu', $data);
}
public function list_menu()
{
$data['menu_liste'] = $this->menu->get_active_data();
$this->load->view('sys/V_list_menu', $data);
}
public function get_record_menu()
{
$args = func_get_args();
$this->menu->id_menu = $args[0];
$this->menu->get_record();
echo json_encode($this->menu, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function save_menu()
{
if ($this->input->post('id_menu') != '')
$this->menu->id_menu = $this->input->post('id_menu');
$this->menu->code = $this->input->post('code');
$this->menu->libelle = $this->input->post('libelle');
$this->menu->etat = '1';
echo json_encode($this->menu->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function delete_menu()
{
$args = func_get_args();
$list_sous_menu = $this->sous_menu->get_list_sous_menu($args[0]);
foreach ($list_sous_menu as $sous_menu) {
$this->delete_sous_menu($sous_menu->{$this->sous_menu->get_db_table_pk()});
}
$this->menu->id_menu = $args[0];
echo json_encode($this->menu->fake_delete(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function delete_sous_menu($id_sous_menu)
{
$this->role->delete_all($id_sous_menu);
$this->sous_menu->id_sous_menu = $id_sous_menu;
echo json_encode($this->sous_menu->fake_delete(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function list_sous_menu()
{
$data_menu = $this->menu->get_data();
$data['select_data_menu'] = create_select_list($data_menu, 'id_menu', 'libelle');
$data['sous_menu_liste'] = $this->sous_menu->get_active_data();
$this->load->view('sys/V_list_sous_menu', $data);
}
public function get_record_sous_menu()
{
$args = func_get_args();
$this->sous_menu->id_sous_menu = $args[0];
$this->sous_menu->get_record();
echo json_encode($this->sous_menu, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function save_sous_menu()
{
$id_menu = $this->input->post('id_sous_menu');
if (isset($id_menu) && $id_menu != "")
$this->sous_menu->id_sous_menu = $this->input->post('id_sous_menu');
$this->sous_menu->id_menu = $this->input->post('id_menu');
$this->sous_menu->code = $this->input->post('code');
$this->sous_menu->libelle = $this->input->post('libelle');
$this->sous_menu->etat = '1';
echo json_encode($this->sous_menu->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class C_sys_niits extends MY_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('sys/M_sys_niits', 'user');
$this->load->model('sys/M_sys_profil', 'profil');
}
public function index()
{
$user_data = $this->user->get_data();
$data['all_data'] = $user_data;
$profil = $this->profil->get_data();
$data['select_profile'] = create_select_list($profil, 'id_type_profil', 'libelle_type_profil');
$this->load->view('sys/V_sys_niits', $data);
}
public function save()
{
if ($this->input->post('id') != '')
$this->user->id = $this->input->post('id');
$this->user->ien = $this->input->post('ien');
$this->user->email = $this->input->post('email');
$this->user->id_profil = $this->input->post('id_profil');
$this->user->code_str = $this->input->post('code_str');
$this->user->password = $this->input->post('password');
$this->user->statut = $this->input->post('statut');
echo json_encode($this->user->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function get_record()
{
$args = func_get_args();
$this->user->id = $args[0];
$this->user->get_record();
echo json_encode($this->user, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function delete()
{
$args = func_get_args();
$this->user->id = $args[0];
echo json_encode($this->user->delete(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class C_sys_profil extends MY_Controller
{
//Initialisation des roles à -1
var $tab_post_role = array('-1','-1','-1','-1');
public function __construct()
{
parent::__construct();
$this->load->model('sys/M_sys_profil', 'profil');
$this->load->model('sys/M_sys_role', 'role');
}
public function index()
{
$all_data = $this->profil->get_data();
$data['all_data'] = $all_data;
$this->load->view('sys/V_sys_profil', $data);
}
public function get_menu_liste()
{
$args = func_get_args();
$data['data_menu'] = $this->role->get_menu_liste($args[0]);
$data['id_profil'] = $args[0];
$this->load->view('sys/V_sys_role', $data);
}
public function save_role_action()
{
//Repérage des liens
$cur_id_lk = 0;
$tab_temp_role = array();
$id_pfl = $this->input->post('id_role_profil');
///RAZ des sous-menus associés au profil
$this->role->raz_sous_menu_active($id_pfl);
//print_r($_POST['btn_role']);
//exit;
foreach ($_POST['btn_role'] as $btn_role)
{
$tab_role = explode('_', $btn_role);
$role = $tab_role[0];
$id_lk = $tab_role[1];
if ($cur_id_lk != $id_lk) //Chagement de lien
{
if ($cur_id_lk != 0) ///Passage Nx
{
$this->role->save_role_action($cur_id_lk, $id_pfl, $this->tab_post_role);
$this->tab_post_role = array('-1', '-1', '-1', '-1');
$this->tab_post_role = $this->curent_role($role, $this->tab_post_role);
} else //Passage N0
{
$this->tab_post_role = $this->curent_role($role, $this->tab_post_role);
}
$cur_id_lk = $id_lk;
} else {
$this->tab_post_role = $this->curent_role($role, $this->tab_post_role);
}
}
if ($cur_id_lk != 0) ///On est pas au premier parcours
{
$d = $this->role->save_role_action($cur_id_lk, $id_pfl, $this->tab_post_role);
$this->tab_post_role = array('-1', '-1', '-1', '-1');
}
echo json_encode($d, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
//Enregistrer les modifs sur les roles
protected function curent_role($role, $tab_role)
{
switch ($role)
{
case 'read':
$tab_role[0] = '1';
break;
case 'add':
$tab_role[1] = '1';
break;
case 'upd':
$tab_role[2] = '1';
break;
case 'del':
$tab_role[3] = '1';
break;
}
return $tab_role;
}
public function get_record()
{
$args = func_get_args();
$this->profil->id_type_profil = $args[0];
$this->profil->get_record();
echo json_encode($this->profil, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function delete()
{
$args = func_get_args();
$this->profil->id_type_profil = $args[0];
echo json_encode($this->profil->delete(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function save()
{
$post_id_type_profil = $this->input->post('id_type_profil');
if($post_id_type_profil != '')
{
$this->profil->id_type_profil = $this->input->post('id_type_profil');
}
$this->profil->libelle_type_profil = $this->input->post('libelle_type_profil');
$this->profil->etat = '1'; //$this->input->post('etat');
echo json_encode($this->profil->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function change_etat()
{
$args =func_get_args();
//var_dump($args);exit;
$id_profil = $args[0];
$statut = $args[1];
$this->profil->etat_change($id_profil,$statut);
$all_data = $this->profil->get_data();
$data['all_data'] = $all_data;;
$this->load->view('sys/V_sys_profil', $data);
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class C_sys_role extends CI_Controller //r�les && links
{
public function __construct()
{
parent::__construct();
$this->load->model('sys/M_sys_role', 'm_mod_name');
$this->load->model('Global_bdd', 'gl_bdd');
//$this->load->model('M_type_batiment', 'type_batiment');
}
public function index()
{
$all_data = $this->m_mod_name->get_data_liste();
$all_type_status = $this->m_mod_name->get_data_forform_etat();
$data['all_data'] = $all_data;
// $data['all_type_elts'] = $all_type_elts;
$data['dat_form_statut'] = $all_type_status;
$data['dat_form_liens'] = $this->gl_bdd->get_data_for_combo("sys_nav_liens", "id_lien", "libelle_text" , " WHERE `etat`='1'");
$data['dat_form_profils'] = $this->gl_bdd->get_data_for_combo("sys_s_profil", "id_type_profil", "libelle_type_profil", " WHERE `etat`='1'");
$this->load->view('sys/v_sys_role', $data);
}
public function get_record()
{
$args = func_get_args();
$this->m_mod_name->id_actions = $args[0];
$this->m_mod_name->get_record();
echo json_encode($this->m_mod_name, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function delete()
{
$args = func_get_args();
$this->m_mod_name->id_actions = $args[0];
echo json_encode($this->m_mod_name->delete(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function save()
{
$input_post = $this->input->post('id_actions');
if(!empty($input_post))
{
$this->m_mod_name->id_actions = $this->input->post('id_actions');
}
//print_r($this->input->post('d_ajouter'));
//break;
$this->m_mod_name->id_type_profil = $this->input->post('id_type_profil');
$this->m_mod_name->id_lien = $this->input->post('id_lien');
$this->m_mod_name->d_consultation = $this->conv_checkbox($this->input->post('d_consultation'));
$this->m_mod_name->d_ajouter = $this->conv_checkbox($this->input->post('d_ajouter'));
$this->m_mod_name->d_modifier = $this->conv_checkbox($this->input->post('d_modifier'));
$this->m_mod_name->d_supprimer = $this->conv_checkbox($this->input->post('d_supprimer'));
echo json_encode($this->m_mod_name->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function conv_checkbox($val)
{
if($val=='on')
return '1';
else
return '-1';
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class C_sys_stagiaire extends MY_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('sys/M_sys_profil', 'profil');
$this->load->model('M_personnel', 'personnel');
$this->load->model('M_structure', 'structure');
$this->load->helper('string');
//$this->load->model('M_table_param');
}
public function index()
{
$user_data = $this->personnel->get_stagiaire();
$data['all_data'] = $user_data;
$structure = $this->structure->get_data();
$data['select_code_str'] = create_select_list($structure, 'code_str', 'libelle');
$this->load->view('sys/V_sys_stagiaire', $data);
}
public function save_stagiaire()
{
if ($this->input->post('id') != '')
{
$this->personnel->id = $this->input->post('id');
$this->personnel->ien = $this->input->post('ien');
$this->personnel->prenom = $this->input->post('prenom');
$this->personnel->nom = $this->input->post('nom');
$this->personnel->code_str = $this->input->post('code_str');
$this->personnel->email_pro = $this->input ->post('email_pro');
echo json_encode($this->personnel->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
else{
$ien = generer_ien_stg();
$this->personnel->ien = $ien;
$this->personnel->prenom = $this->input->post('prenom');
$this->personnel->nom = $this->input->post('nom');
$this->personnel->code_str = $this->input->post('code_str');
$this->personnel->email_pro = $this->input ->post('email_pro');
$this->personnel->etat = 1;
echo json_encode($this->personnel->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
}
public function get_record()
{
$args =func_get_args();
$this->personnel->id = $args[0];
$this->personnel->get_record();
echo json_encode($this->personnel, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function delete()
{
$args = func_get_args();
$this->personnel->id = $args[0];
$this->personnel->id = $args[0];
$this->personnel->delete();
echo json_encode($this->personnel->delete(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class C_sys_user extends MY_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('sys/M_sys_user', 'user');
$this->load->model('sys/M_sys_profil', 'profil');
$this->load->model('M_personnel', 'pers');
//$this->load->model('M_table_param');
}
public function index()
{
$user_data = $this->user->get_data();
$data['all_data'] = $user_data;
//var_dump($data['all_data']);
$profil = $this->profil->get_data();
$data['select_profile'] = create_select_list($profil, 'id_type_profil', 'libelle_type_profil');
$this->load->view('sys/V_sys_user', $data);
}
public function save()
{
$ien = trim($this->input->post('ien'));
if (!empty($this->user->verif_ienusr($ien)))
{
$d=array("status" => "error", "message" =>"Ien deja utilisateur" );
echo json_encode($d, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
die();
}
$info = file_get_contents("http://apps.education.sn/C_personnel_api/getIEN_info_all?ien=".$ien);
$infos = json_decode($info,true ) ;
if ($infos["code"] == 1 or $info == false)
{
$d=array("status" => "error", "message" =>"Ien introuvable" );
echo json_encode($d, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
die();
}
$infos = $infos["record"];
if (empty($this->pers->get_personnel_ien($ien)))
{
$this->pers->ien = $ien;
$this->pers->prenom = $infos["prenom"];
$this->pers->nom = $infos["nom"];
$this->pers->code_str = $infos["code_str"];
$this->pers->email_pro = $infos["email_pro"];
$this->pers->save();
}
//var_dump($infos);exit();
// echo json_encode($this->pers->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);exit();
$this->user->ien = $ien ;
$this->user->id_profil = $this->input->post('id_profil');
$this->user->code_str = $infos["code_str"];
$this->user->statut = '1';
echo json_encode($this->user->save(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function get_record()
{
$args = func_get_args();
$this->user->ien = $args[0];
$this->user->get_record();
echo json_encode($this->user, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function delete()
{
$args = func_get_args();
$this->pers->id = $args[0];
$this->user->id = $args[0];
$this->user->delete();
echo json_encode($this->pers->delete(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
public function tout_activer()
{
//var_dump($_POST);exit;
$tab = $_POST['id_checks'];
$statut = '1';
if ($_POST['id_checks'] == null)
{
// $d=array("status" => "error", "message" =>"Veuillez selectionner les profil à activer !" );
// echo json_encode($d, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
echo json_encode($tab, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
die();
}
else
{
foreach($tab as $value)
{
$this->user->change_etat($value,$statut);
}
// $d=array("status" => "success", "message" =>"Les profils sélectionnés sont activés !" );
// echo json_encode($d, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
echo json_encode($tab, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
die();
}
}
public function tout_desactiver()
{
//var_dump($_POST);exit;
$tab = $_POST['id_checks'];
$statut = '-1';
if ($_POST['id_checks'] == null)
{
echo json_encode($tab, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
die();
}
else
{
foreach($tab as $value)
{
$this->user->change_etat($value,$statut);
}
echo json_encode($tab, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
die();
}
}
public function generer_code()
{
$chaine = "0123456789";
srand((double)microtime()*1000000);
$code = '';
for($i = 0; $i < 4; $i++)
{
$code .= $chaine[rand()%strlen($chaine)];
}
return $code;
}
public function reset_pw()
{
$args = func_get_args();
$id = $args[0];
$tel = $this->user->get_tel_by_id($id);
$email = $this->user->get_email_by_id($id);
$code_acces = $this->generer_code();
$result = $this->user->pw_reset($id,$code_acces);
if($result['status'] == 'success')
{
$message = "<table cellpadding='5' cellspacing='5'>
<tr>
<td>Votre identifiant :</td><td><b>".$tel."</b></td>
</tr>
<tr>
<td>Mot de passe :</td><td><b>".$code_acces."</b></td>
</tr>
</table>";
$signature = "SYSGERM";
$objet = "SYSGERM: Réinitialisation compte utilisateur";
$testmail = sendmail($signature, $email, $objet, $message);
}
echo json_encode($result, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Controller extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->the_session_expired();
date_default_timezone_set('UTC');
}
private function the_session_expired()
{
$tab_data_ses = $this->session->all_userdata();
if (empty($tab_data_ses['tel']))
{
$this->session->sess_destroy();
header("Location:".base_url());
exit();
}
else
{
return 1;
}
}
}
<?php
require_once 'application/core/MY_Model_Interface.php';
abstract class MY_Model extends CI_Model implements MY_Model_Interface{
function __construct($db_select = null)
{
parent::__construct();
//Load them in the constructor
if(!defined('DB_USER') || !defined('DB_PWD') || !defined('DB_DATABASE') || !defined('DB_HOST')):
define('DB_USER', $this->db->username);
define('DB_PWD', $this->db->password);
define('DB_DATABASE', $this->db->database);
define('DB_HOST',$this->db->hostname);
endif;
if(empty($db_select))
$db_string = $this->select_db();
else
$db_string = $db_select;
$this->db = $this->load->database($db_string, TRUE);
// $this->dbp = $this->load->database('planete', TRUE);
//$this->dbm = $this->load->database('planete_management', TRUE);
}
public function select_db(){
return 'default';
}
public function fake_delete()
{
$this->db->where($this->get_db_table_pk(), $this->{$this->get_db_table_pk()});
$this->db->update($this->get_db_table(), array($this->get_db_table_etat() => '-1'));
if ($this->db->trans_status() === FALSE) {
$status = 'error';
$result = 'Error! ID [' . $this->{$this->get_db_table_pk()} . '] not found';
} else {
$status = 'success';
$result = 'Suppression effectuée avec succées.';
}
$d = array();
$d['status'] = $status;
$d['message'] = $result;
return $d;
}
public function restor()
{
$this->db->where($this->get_db_table_pk(), $this->{$this->get_db_table_pk()});
$this->db->update($this->get_db_table(), array($this->get_db_table_etat() => '1'));
if ($this->db->trans_status() === FALSE) {
$status = 'error';
$result = 'Error! ID [' . $this->{$this->get_db_table_pk()} . '] not found';
} else {
$status = 'success';
$result = 'Restauration effectuée avec succées.';
}
$d = array();
$d['status'] = $status;
$d['message'] = $result;
return $d;
}
public function get_etat($code)
{
$sql ="SELECT ".$this->get_db_table_etat()."
FROM ".$this->get_db_table()."
WHERE ".$this->get_db_table_pk()." ='".$code."'";
$query = $this->db->query($sql);
return array_values($query->row_array());
}
private function insert()
{
$this->db->insert($this->get_db_table(), $this);
if(!empty($this->get_db_table_pk())){
$this->{$this->get_db_table_pk()} = $this->db->insert_id();
return $this->{$this->get_db_table_pk()};
}
else{
return '';
}
}
private function update()
{
$this->db->update($this->get_db_table(), $this, array(
$this->get_db_table_pk() => $this->{$this->get_db_table_pk()}
));
return $this->{$this->get_db_table_pk()};
}
public function save()
{
if(isset($this->{$this->get_db_table_pk()}) && !empty($this->get_db_table_pk()) ){
$id = $this->update();
}
else{
$id = $this->insert();
}
if ($this->db->trans_status() === FALSE) {
$status = 'error';
$result = 'Erreur d\'enregistrement.';
}
else {
$status = 'success';
$result = 'Enregistrement effectué avec succées.';
}
$d = array();
$d['id'] = $id;
$d['status'] = $status;
$d['message'] = $result;
return $d;
}
//ingored null
private function insert_without_null(){
foreach($this as $key=>$value){
if($value == null && $key != $this->{$this->get_db_table_pk()})
unset($this->$key);
}
$this->db->insert($this->get_db_table(), $this);
$this->{$this->get_db_table_pk()} = $this->db->insert_id();
return $this->{$this->get_db_table_pk()};
}
private function update_without_null(){
foreach($this as $key=>$value){
if($value == null && $key != $this->{$this->get_db_table_pk()})
unset($this->$key);
}
$this->db->update($this->get_db_table(), $this, array(
$this->get_db_table_pk() => $this->{$this->get_db_table_pk()}
));
return $this->{$this->get_db_table_pk()};
}
public function save_without_null(){
if(isset($this->{$this->get_db_table_pk()})){
$id = $this->update_without_null();
}
else{
$id = $this->insert_without_null();
}
if ($this->db->trans_status() === FALSE) {
$status = 'error';
$result = 'Erreur d\'enregistrement.';
}
else {
$status = 'success';
$result = 'Enregistrement effectué avec succées.';
}
$d = array();
$d['id'] = $id;
$d['status'] = $status;
$d['message'] = $result;
return $d;
}
public function delete(){
$this->db->delete($this->get_db_table(), array($this->get_db_table_pk() => $this->{$this->get_db_table_pk()}));
if ($this->db->trans_status() === FALSE) {
$status = 'error';
$result = 'Error! ID ['.$this->{$this->get_db_table_pk()}.'] not found';
}
else {
$status = 'success';
$result = 'Suppression effectuée avec succées.';
}
$d = array();
$d['status'] = $status;
$d['message'] = $result;
return $d;
}
public function get_data()
{
return $this->db->select('*')
->from($this->get_db_table())
->get()
->result();
}
public function get_active_data()
{
if ($this->get_db_table_etat()) {
return $this->db->select('*')
->from($this->get_db_table())
->where($this->get_db_table_etat(), '1')
->get()
->result();
} else {
$this->get_active_data();
}
}
public function get_record(){
$row = $this->db->select('*')
->from($this->get_db_table())
->where($this->get_db_table_pk(), $this->{$this->get_db_table_pk()})
->get()
->result();
$row = reset($row);
if($row == null)
$this->{$this->get_db_table_pk()} = null;
else
foreach ($row as $param => $value){
$this->{$param} = $value;
}
}
public function get_active_record()
{
$row = $this->db->select('*')
->from($this->get_db_table())
->where($this->get_db_table_pk(), $this->{$this->get_db_table_pk()})
->where($this->get_db_table_etat(), '1')
->get()
->result();
$row = reset($row);
if ($row == null)
$this->{$this->get_db_table_pk()} = null;
else
foreach ($row as $param => $value) {
$this->{$param} = $value;
}
}
public function get_id_()
{
return $this->db->select('*')
->from($this->get_vf_table())
->where($this->get_vf_table_pk(), $this->{$this->get_vf_table_pk()})
->get()
->result();
}
public function check_unique_field($table, $col_name, $val_to_search, $extraWhere = null)
{
$sql = "SELECT $col_name FROM $table WHERE $col_name='".trim($val_to_search)."'";
if($extraWhere != null && $extraWhere != '')
$sql .= " AND $extraWhere";
$row = $this->db->query($sql)->row();
if(!empty($row))
{
$d = array();
$d['status'] = 'error';
$d['message'] = "La valeur ".$val_to_search." existe déjà.";
echo json_encode($d, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
exit();
die();
}
}
}
<?php
interface MY_Model_Interface{
public function get_db_table();
public function get_db_table_pk();
}
\ No newline at end of file
This diff is collapsed.
<?php
class M_sys_menu extends MY_Model
{
public $id_menu;
public $code;
public $libelle;
public $etat;
public function get_db_table_pk()
{
return 'id_menu';
}
public function get_db_table_etat()
{
return 'etat';
}
public function get_active_data()
{
return $this->db->where('etat', '1')
->get($this->get_db_table())
->result();
}
public function get_db_table()
{
return 'sys_menu' ;
}
public function get_menu_liste()
{
$sql = "SELECT
m.id_menu,
m.libelle as m_libelle,
sm.id_sous_menu,
sm.libelle as sm_libelle
FROM
sys_sous_menu sm
INNER JOIN sys_menu m ON
m.id_menu = sm.id_menu
ORDER BY m.libelle ASC";
$query = $this->db->query($sql);
return $query->result();
}
}
<?php
class M_sys_niits extends MY_Model
{
public $id ;
public $ien ;
public $email ;
public $id_profil;
public $code_str;
public $password;
public $statut;
public function get_data(){
return $this->db->select('us.*, p.libelle_type_profil,a.email_agent as email')
->from($this->get_db_table().' us')
->join('sys_type_profil p','p.id_type_profil = us.id_profil')
->join('agent a','a.IEN = us.ien')
->get()
->result();
}
public function get_db_table()
{
return 'sys_user';
}
public function get_db_table_pk()
{
return 'id';
}
public function get_db_table_etat()
{
return 'statut';
}
}
<?php
class M_sys_profil extends MY_Model
{
public $id_type_profil;
public $libelle_type_profil;
public $etat;
private $insert_role = '';
private $update_role = '';
public function get_db_table()
{
return 'sys_type_profil';;
}
public function get_db_table_pk(){
return 'id_type_profil';
}
public function get_data_liste()
{
$sql = "SELECT * FROM sys_type_profil WHERE etat='1'";
$query = $this->db->query($sql);
return $query->result();
}
public function get_db_table_etat()
{
return 'etat';
}
public function etat_change($id_profil,$etat)
{
return $this->db->query( 'UPDATE sys_type_profil SET etat = "'.$etat.'" WHERE id_type_profil ="'.$id_profil.'"' );
}
}
<?php
class M_sys_role extends MY_Model
{
public $id_actions;
public $id_type_profil;
public $id_sous_menu;
public $d_read;
public $d_add;
public $d_upd;
public $d_del;
public function get_db_table_pk(){
return 'id_actions';
}
public function delete_all($id_sous_menu)
{
$this->db->where($this->get_db_table_fk(), $id_sous_menu);
$this->db->delete($this->get_db_table());
}
public function get_db_table_fk()
{
return 'id_sous_menu';
}
public function get_db_table($alias = NULL)
{
return 'sys_type_action' . db_alias($alias);;
}
////Recupere la liste des menus et sous menus pour le profil selectionné avec les droits
public function get_menu_liste($id_type_profil)
{
$sql = "SELECT
m.id_menu,
m.code as m_code,
m.libelle as m_libelle,
sm.id_sous_menu,
sm.code as sm_code,
sm.libelle as sm_libelle,
a.id_type_profil,
CASE a.d_read
WHEN '1' THEN 'checked'
ELSE ''
END d_read,
CASE a.d_add
WHEN '1' THEN 'checked'
ELSE ''
END d_add,
CASE a.d_upd
WHEN '1' THEN 'checked'
ELSE ''
END d_upd,
CASE a.d_del
WHEN '1' THEN 'checked'
ELSE ''
END d_del
FROM
sys_sous_menu sm
LEFT OUTER JOIN sys_type_action a ON
sm.id_sous_menu = a.id_sous_menu AND a.id_type_profil = '$id_type_profil'
INNER JOIN sys_menu m ON
m.id_menu = sm.id_menu
ORDER BY m.id_menu ASC";
$query = $this->db->query($sql, $id_type_profil);
return $query->result();
}
public function save_role_action($id_sous_menu, $id_type_profil, $post_role)
{
$sql = "SELECT COUNT(id_sous_menu) as smenu FROM sys_type_action
WHERE id_sous_menu = '$id_sous_menu'
AND id_type_profil = '$id_type_profil'";
$query = $this->db->query($sql);
$row = $query->row();
$this->db->trans_begin();
if($row->smenu > 0)
{
//echo $row->link;
$post_role[] = $id_type_profil;
$post_role[] = $id_sous_menu;
$this->update_role = "UPDATE sys_type_action SET";
$this->update_role .= " d_read = ?,";
$this->update_role .= " d_add = ?,";
$this->update_role .= " d_upd = ?,";
$this->update_role .= " d_del = ?";
$this->update_role .= " WHERE id_type_profil = ? AND id_sous_menu = ?";
$this->db->query($this->update_role, $post_role);
}else
{
///Les elements ci dessous doivent venir en premier dans le tableau
$tab_post_role[] = $id_type_profil;
$tab_post_role[] = $id_sous_menu;
//on complement les elements de role dans le tebleau
foreach($post_role as $val_role)
{
$tab_post_role[] = $val_role;
}
//Gestion des sous menus
$this->insert_smenu = "INSERT INTO sys_type_action SET";
$this->insert_smenu .= " id_type_profil = ?,";
$this->insert_smenu .= " id_sous_menu = ?,";
$this->insert_smenu .= " d_read = ?,";
$this->insert_smenu .= " d_add = ?,";
$this->insert_smenu .= " d_upd = ?,";
$this->insert_smenu .= " d_del = ?";
$this->db->query($this->insert_smenu, $tab_post_role);
}
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback();
$status = 'error';
$result = 'Erreur lors de la mise à jour des roles';
}
else
{
$this->db->trans_commit();
$status = 'success';
$result = 'Mise a jour des roles effectuée avec succès';
}
$d = array();
$d['status'] = $status;
$d['message'] = $result;
return $d;
}
public function raz_sous_menu_active($id_profil)
{
///RAZ des sous-menus associés au profil
$sql_sm = "UPDATE sys_type_action SET
d_read = '-1', d_add = '-1', d_upd = '-1', d_del = '-1'
WHERE id_type_profil = '$id_profil'";
$this->db->query($sql_sm);
}
public function get_conn_roles($id_profil /*, $code_str, $ien*/)
{
//$pdo =& get_instance();
$sql = "SELECT
a.d_read,
a.d_add,
a.d_upd,
a.d_del,
m.code as mcode,
m.libelle,
sm.code as smcode,
sm.libelle
FROM
sys_type_action a
INNER JOIN sys_sous_menu sm ON
a.id_sous_menu = sm.id_sous_menu AND a.id_type_profil = ?
AND a.d_read = '1'
INNER JOIN sys_menu m ON
sm.id_menu = m.id_menu
INNER JOIN sys_type_profil p ON
p.id_type_profil = a.id_type_profil
INNER JOIN sys_user n ON
n.id_profil = p.id_type_profil
ORDER BY a.id_actions ASC";
$query = $this->db->query($sql, array($id_profil));
$result = $query->result();
return $result;
}
public function get_conn_roles1($id_profil /*, $code_str, $ien*/)
{
//$pdo =& get_instance();
$sql = "SELECT
a.d_read,
a.d_add,
a.d_upd,
a.d_del,
m.code as mcode,
m.libelle,
sm.code as smcode,
sm.libelle
FROM
sys_type_action a
INNER JOIN sys_sous_menu sm ON
a.id_sous_menu = sm.id_sous_menu AND a.id_type_profil = ?
AND a.d_read = '1'
INNER JOIN sys_menu m ON
sm.id_menu = m.id_menu
INNER JOIN sys_type_profil p ON
p.id_type_profil = a.id_type_profil
INNER JOIN agent_snop n ON
n.id_profil = p.id_type_profil
ORDER BY a.id_actions ASC";
$query = $this->db->query($sql, array($id_profil));
$result = $query->result();
return $result;
}
}
\ No newline at end of file
<?php
class M_sys_sous_menu extends MY_Model
{
public $id_sous_menu;
public $id_menu;
public $code;
public $libelle;
public $etat;
public function fake_delete_all($id_menu)
{
$this->db->set($this->get_db_table_etat(), '-1');
$this->db->where($this->get_db_table_fk(), $id_menu);
$this->db->update($this->get_db_table());
}
public function get_db_table_etat()
{
return 'etat';
}
public function get_db_table_fk()
{
return 'id_menu';
}
public function get_db_table()
{
return 'sys_sous_menu';
}
public function get_list_sous_menu($id_menu)
{
return $this->db->select($this->get_db_table_pk())
->from($this->get_db_table())
->where($this->get_db_table_fk(), $id_menu)
->get()->result();
}
public function get_db_table_pk()
{
return 'id_sous_menu';
}
public function get_active_data()
{
return $this->db->select('sm.*, m.libelle as menu')
->where('sm.etat', '1')
->join('sys_menu m', 'm.id_menu = sm.id_menu')
->get($this->get_db_table().' as sm')
->result();
}
public function get_menu_liste()
{
$sql = "SELECT
m.id_menu,
m.libelle as m_libelle,
sm.id_sous_menu,
sm.libelle as sm_libelle
FROM
sys_sous_menu sm
INNER JOIN sys_menu m ON
m.id_menu = sm.id_menu
ORDER BY m.libelle ASC";
$query = $this->db->query($sql);
return $query->result();
}
}
<?php
class M_sys_user extends MY_Model
{
public $id ;
public $id_profil;
public $mot_de_passe;
public $statut;
public $id_personnel;
public function get_data( /*$code_str*/)
{
return $this->db->select("usr.*, pers_str.*, ssp.*, s.libelle_structure")
->from($this->get_db_table() . ' as usr')
->join('personnel as pers_str', 'pers_str.id_personnel = usr.id_personnel')
->join('sys_type_profil as ssp', 'ssp.id_type_profil = usr.id_profil')
->join('structure as s', 's.id_structure = pers_str.id_structure')
// ->where('pers_str.id_structure', $_SESSION['id_structure'])
->get()
->result();
}
public function get_db_table()
{
return 'sys_user';
}
public function get_db_table_pk()
{
return 'id';
}
public function change_etat($id,$statut)
{
return $this->db->query( 'UPDATE sys_user SET statut = "'.$statut.'" WHERE id_personnel ="'.$id.'"');
}
public function get_info_mail($id)
{
return $this->db->select("pers.*")
->from('sys_user as usr')
->join('personnel as pers', 'pers.id_personnel = usr.id_personnel')
->where('id', $id)
->get()
->result();
}
public function get_tel_by_id($id)
{
$tel = $this->db->select("pers.tel_personnel")
->from('sys_user as usr')
->join('personnel as pers', 'pers.id_personnel = usr.id_personnel')
->where('id', $id)
->get()
->row();
return $tel->tel_personnel;
}
public function get_email_by_id($id)
{
$email = $this->db->select("pers.email_personnel")
->from('sys_user as usr')
->join('personnel as pers', 'pers.id_personnel = usr.id_personnel')
->where('id', $id)
->get()
->row();
return $email->email_personnel;
}
public function pw_reset($id,$pw)
{
$this->db->set('mot_de_passe', $pw)
->where('id', $id)
->update('sys_user');
if ($this->db->trans_status() === FALSE)
{
$status = 'error';
$result = 'Erreur lors de la réinitialisation.';
}
else
{
$status = 'success';
$result = 'Mot de passe réinitialisé avec succées.';
}
$d = array();
$d['id'] = $id;
$d['status'] = $status;
$d['message'] = $result;
return $d;
}
}
This diff is collapsed.
<div class="row">
<div class="col-sm-1.5" style="margin-bottom: 15px">
<button type="button" id="btn_add" class="btn btn-rounded btn-primary" id="loadingModal">Nouveau</button>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<h3 class="card-title mb-2">Liste des menus </h3>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="datatable-buttons" class="datatable table table-stripped table-bordered">
<thead>
<tr>
<th style="width: 20%">Code</th>
<th style="width: 70%">Libellé</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($menu_liste as $value): ?>
<tr>
<td><?= $value->code ?></td>
<td><?= $value->libelle ?></td>
<td style="width: 10%">
<?php btn_edit_action($value->id_menu, 'LST_MENU'); ?> &nbsp;
<?php btn_delete_action($value->id_menu, 'LST_MENU'); ?>&nbsp;
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- sample modal content -->
<div id="modal_form" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="standard-modalLabel" aria-hidden="true">
<form action="#" id="form">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="standard-modalLabel">Title</h4>
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
<input type="hidden" id="id_menu" name="id_menu"/>
<div class="form-body">
<div class="form-group row">
<label class="col-lg-3 col-form-label">Code <span class="text-danger">*</span></label>
<div class="col-lg-9">
<input name="code" id="code" type="text"
class="form-control" required>
</div>
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">Libelle <span class="text-danger">*</span></label>
<div class="col-lg-9">
<input name="libelle" id="libelle" type="text"
class="form-control" required>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="close-btn" class="btn btn-danger float-left">Fermer</button>
<button type="submit" class="btn btn-primary">Enrégistrer</button>
<!-- <input type="submit" class="btn btn-primary" value="Enregistrer"/>
<button type="button" class="btn btn-default btn-close" data-dismiss="modal">Fermer</button> -->
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</form>
</div><!-- /.modal -->
<script type="text/javascript">
$(document).ready(function () {
$('#datatable-buttons').managing_ajax({
id_modal_form: 'modal_form',
id_form: 'form',
url_submit: "<?php echo site_url('sys/C_sys_menu/save_menu')?>",
title_modal_add: 'Ajouter un menu',
focus_add: 'code',
title_modal_edit: 'Modifier un menu',
focus_edit: 'libelle',
url_edit: "<?php echo site_url('sys/C_sys_menu/get_record_menu')?>",
url_delete: "<?php echo site_url('sys/C_sys_menu/delete_menu')?>",
});
$('.btn-close').click(function(){
//alert('ok');
$('#modal_form').modal('hide');
});
$('#close-btn').click(function(){
//alert('ok');
$('#modal_form').modal('hide');
});
});
</script>
<?php if (ENVIRONMENT !== 'production'): ?>{elapsed_time} seconds&nbsp;|&nbsp;{memory_usage}<?php endif ?>
\ No newline at end of file
<div class="row">
<div class="col-sm-1.5" style="margin-bottom: 15px">
<button type="button" id="btn_add" class="btn btn-rounded btn-primary" id="loadingModal">Nouveau</button>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<h3 class="card-title mb-2">Liste des sous menus </h3>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="datatable-buttons" class="datatable table table-stripped table-bordered">
<thead>
<tr>
<th style="width: 15%">Menu</th>
<th style="width: 15%">Code</th>
<th style="width: 60%">Libellé</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
// var_dump($select_data_menu);
// exit();
?>
<?php foreach ($sous_menu_liste as $value): ?>
<tr>
<td><?= $value->menu ?></td>
<td><?= $value->code ?></td>
<td><?= $value->libelle ?></td>
<td style="width: 10%">
<?php btn_edit_action($value->id_sous_menu, 'LST_S_MENU'); ?> &nbsp;
<?php btn_delete_action($value->id_sous_menu, 'LST_S_MENU'); ?>&nbsp;
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- sample modal content -->
<div id="modal_form" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="standard-modalLabel" aria-hidden="true">
<form action="#" id="form">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="standard-modalLabel">Title</h4>
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
<input type="hidden" id="id_sous_menu" name="id_sous_menu"/>
<div class="form-body">
<div class="form-group row">
<label class="col-lg-3 col-form-label">Menu <span class="text-danger">*</span></label>
<div class="col-lg-9">
<select name="id_menu" id="id_menu" class="form-control select" required>
<?php echo $select_data_menu; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">Code <span class="text-danger">*</span></label>
<div class="col-lg-9">
<input name="code" id="code" type="text"
class="form-control" required>
</div>
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label">Libelle <span class="text-danger">*</span></label>
<div class="col-lg-9">
<input name="libelle" id="libelle" type="text"
class="form-control" required>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="close-btn" class="btn btn-danger float-left">Fermer</button>
<button type="submit" class="btn btn-primary">Enrégistrer</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</form>
</div><!-- /.modal -->
<script type="text/javascript">
$(document).ready(function () {
$('#datatable-buttons').managing_ajax({
id_modal_form: 'modal_form',
id_form: 'form',
url_submit: "<?php echo site_url('sys/C_sys_menu/save_sous_menu')?>",
title_modal_add: 'Ajouter un menu',
focus_add: 'code',
title_modal_edit: 'Modifier un menu',
focus_edit: 'libelle',
url_edit: "<?php echo site_url('sys/C_sys_menu/get_record_sous_menu')?>",
url_delete: "<?php echo site_url('sys/C_sys_menu/delete_sous_menu')?>",
});
$('.btn-close').click(function(){
//alert('ok');
$('#modal_form').modal('hide');
});
$('#close-btn').click(function(){
//alert('ok');
$('#modal_form').modal('hide');
});
});
</script>
<?php if (ENVIRONMENT !== 'production'): ?>{elapsed_time} seconds&nbsp;|&nbsp;{memory_usage}<?php endif ?>
\ No newline at end of file
<style>
.table > tbody > tr > td,
{
padding: 2px;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #ddd;
}
.titre{
color:#FFF;
font-weight:bold;
background-color: #3d5ee1;
}
.thtitre{
color:#FFF;
font-weight:bold;
background-color:#09F;
}
.table th, .table td {
border-top: none !important;
border-left: none !important;
}
</style>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h5 class="card-title">Liste des menus</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="datatable-buttons" class="table table-striped mb-0 table-bordered">
<?php
$k = 0; ///Incremente les parcours de la table data_menu
$i = 0; /// Pointeur sur les menus
$menu_parent = '';
foreach($menu_liste as $smenu)
{
$k = $smenu->id_sous_menu;
if($i != $smenu->id_menu)
{
$i = $smenu->id_menu;
if($menu_parent != '') ///On a dépassé le premier tour
{
?>
</table>
<?php
}
///Cela nous servira de repere pour pouvoir fermer le tableau
$menu_parent = $smenu->m_libelle;
?>
<table width="100%" id="datatable-buttons" class="table table-striped mb-0 table-bordered">
<tr>
<thead class="titre">
<td width="30%">MENUS</td>
<td>SOUS-MENUS</td>
</thead>
</tr>
<tr>
<td><b><?php echo $menu_parent;?></b></td>
<td><?php echo $smenu->sm_libelle ?></td>
</tr>
<?php
}else
{
?>
<tr>
<td></td>
<td><?php echo $smenu->sm_libelle ?></td>
</tr>
<?php
}
}
?>
</div>
</div>
</div>
</div>
\ No newline at end of file
This diff is collapsed.
<style>
.table > tbody > tr > td,
{
padding: 2px;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #3d5ee1;
}
.titre{
color:#FFF;
font-weight:bold;
background-color: #3d5ee1;
}
.thtitre{
color:#FFF;
font-weight:bold;
background-color:#3d5ee1;
}
.table th, .table td {
border-top: none !important;
border-left: none !important;
}
</style>
<form id="form_role" method="post">
<input type="hidden" name="id_role_profil" id="id_role_profil" value="<?php echo $id_profil ?>">
<input type="button" id="btn-role-save" class="btn btn-rounded btn-primary" value="Enregistrer"/>
<br><br>
<legend></legend>
<div class="clearfix"></div>
<div class="row">
<?php
$js_menu = '';
$js_smenu = '';
$js_tgl = '';
?>
<div class="col-md-3 table-responsive">
<table width="100%" class="table border-0 star-student table-hover table-center mb-0 datatable table-striped" cellpadding="0" border="0">
<thead class="student-thread">
<tr><th colspan="2" class="thtitre">LISTE DES MENUS</th></tr>
</thead>
<?php
$data_val = 0; ///Pour les numeros de data-val dans le a-href
$pmenu = ''; //Pour la liste des elements de data-val de la fonction jquery
$cur_mn = ''; ///Pour connaitre le menu courant
$rpr_data_val = 0; //Repere pour le premier parcours
foreach($data_menu as $menu)
{
if($cur_mn != $menu->m_libelle)
{
$cur_mn = $menu->m_libelle;
$data_val = $menu->id_menu;
if($rpr_data_val == 0)
{
$pmenu .= "#pmenu_$data_val";
}else
{
$pmenu .= ", #pmenu_$data_val";
}
?>
<tr><th><a href="#" class="link" data-val="<?php echo $data_val ?>"><?php echo $menu->m_libelle ?></a></th></tr>
<?php
$rpr_data_val = $data_val;
}
}
?>
</table>
</div>
<div class="col-md-1">
</div>
<div class="col-md-8">
<?php
$k = 0; ///Incremente les parcours de la table data_menu
$i = 0; /// Pointeur sur les menus
$menu_parent = '';
foreach($data_menu as $smenu)
{
$k = $smenu->id_sous_menu;
if($i != $smenu->id_menu)
{
$i = $smenu->id_menu;
if($menu_parent != '') ///On a dépassé le premier tour
{
?>
</table>
<?php
}
///Cela nous servira de repere pour pouvoir fermer le tableau
$menu_parent = $smenu->m_libelle;
?>
<table class="table border-0 star-student table-hover table-center mb-0 datatable table-striped" width="98%" id="pmenu_<?php echo $i ?>" style="display:none;">
<tr>
<thead class="titre student-thread">
<td><input type="checkbox" name="menu_<?php echo $i ?>" class="pmenu_<?php echo $i ?>"></td>
<?php
///Bout de code js
$js_menu .= "$('.pmenu_$i').click(function(){
//on cherche les checkbox à l'intérieur de l'id
var pmenu_$i = $('#pmenu_$i').find(':checkbox');
if(this.checked)
{ // si 'checkAll' est coché
pmenu_$i.prop('checked', true);
}else
{ // si on décoche 'checkAll'
pmenu_$i.prop('checked', false);
}
});";
?>
<td>SOUS-MENUS</td>
<td>Lecture</td>
<td>Ajout</td>
<td>Modif</td>
<td>Suppr</td>
</thead>
</tr>
<tr id="psmenu_<?php echo $k ?>">
<td><input type="checkbox" name="menu_<?php echo $k ?>" class="psmenu_<?php echo $k ?>"></td>
<?php
///Bout de code js
$js_smenu .= "
$('.psmenu_$k').click(function(){
//on cherche les checkbox à l'intérieur de l'id
var psmenu_$k = $('#psmenu_$k').find(':checkbox');
if(this.checked)
{ // si 'checkAll' est coché
psmenu_$k.prop('checked', true);
}else
{ // si on décoche 'checkAll'
psmenu_$k.prop('checked', false);
}
});";
///Bout de code js
$js_smenu .= "
$(':checkbox.smenu_$k').click(function(){
$(':checkbox.pmenu_$i').prop('checked', false);
$(':checkbox.psmenu_$k').prop('checked', false);
});
$(':checkbox.psmenu_$k').click(function(){
$(':checkbox.pmenu_$i').prop('checked', false);
});";
?>
<td><?php echo $smenu->sm_libelle ?></td>
<td><input type="checkbox" name="btn_role[]" value="read_<?php echo $k ?>" <?php echo $smenu->d_read; ?> class="smenu_<?php echo $k ?>"></td>
<td><input type="checkbox" name="btn_role[]" value="add_<?php echo $k ?>" <?php echo $smenu->d_add; ?> class="smenu_<?php echo $k ?>"></td>
<td><input type="checkbox" name="btn_role[]" value="upd_<?php echo $k ?>" <?php echo $smenu->d_upd; ?> class="smenu_<?php echo $k ?>"></td>
<td><input type="checkbox" name="btn_role[]" value="del_<?php echo $k ?>" <?php echo $smenu->d_del; ?> class="smenu_<?php echo $k ?>"></td>
</tr>
<?php
}else
{
?>
<tr id="psmenu_<?php echo $k ?>">
<td><input type="checkbox" name="menu_<?php echo $k ?>" class="psmenu_<?php echo $k ?>"></td>
<?php
///Bout de code js
$js_smenu .= "
$('.psmenu_$k').click(function(){
//on cherche les checkbox à l'intérieur de l'id
var psmenu_$k = $('#psmenu_$k').find(':checkbox');
if(this.checked)
{ // si 'checkAll' est coché
psmenu_$k.prop('checked', true);
}else
{ // si on décoche 'checkAll'
psmenu_$k.prop('checked', false);
}
});";
///Bout de code js
$js_smenu .= "
$(':checkbox.smenu_$k').click(function(){
$(':checkbox.pmenu_$i').prop('checked', false);
$(':checkbox.psmenu_$k').prop('checked', false);
});
$(':checkbox.psmenu_$k').click(function(){
$(':checkbox.pmenu_$i').prop('checked', false);
});";
?>
<td><?php echo $smenu->sm_libelle ?></td>
<td><input type="checkbox" name="btn_role[]" value="read_<?php echo $k ?>" <?php echo $smenu->d_read; ?> class="smenu_<?php echo $k ?>"></td>
<td><input type="checkbox" name="btn_role[]" value="add_<?php echo $k ?>" <?php echo $smenu->d_add; ?> class="smenu_<?php echo $k ?>"></td>
<td><input type="checkbox" name="btn_role[]" value="upd_<?php echo $k ?>" <?php echo $smenu->d_upd; ?> class="smenu_<?php echo $k ?>"></td>
<td><input type="checkbox" name="btn_role[]" value="del_<?php echo $k ?>" <?php echo $smenu->d_del; ?> class="smenu_<?php echo $k ?>"></td>
</tr>
<?php
}
}
?>
</div>
</div>
</form>
<script>
$(document).ready(function (){
$('#btn-role-save').on('click', function (event){
$.ajax({
url: "<?php echo site_url('sys/C_sys_profil/save_role_action')?>",
type: "POST",
data: $('#form_role').serialize(),
dataType: "JSON",
success: function (data){
if(data.status == 'success')
{
$.Notification.autoHideNotify('success', 'bottom right', data.message);
$('#modal_role').modal('hide');
}else
{
$.Notification.autoHideNotify('error', 'bottom right', data.message)
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Erreur envoi');
}
});
});
});
</script>
<script>
////Niveau Sous-menu
<?php echo $js_menu ?>
////Niveau Menu
<?php echo $js_smenu ?>
</script>
<script>
$(document).ready(function (){
$('.link').click(function (event) {
var val = $(this).data('val');
//$('#pmenu_0,#pmenu_1').hide();
$('<?php echo $pmenu; ?>').hide();
$('#pmenu_'+val ).show();
return false;
});
});
</script>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment