144 lines
4.7 KiB
PHP
144 lines
4.7 KiB
PHP
<?php
|
|
class Clients extends CI_Controller {
|
|
|
|
function __construct()
|
|
{
|
|
parent::__construct('clients');
|
|
$this->load->helper('url');
|
|
$this->load->library('pagination');
|
|
$this->load->model('Clients_model');
|
|
$this->load->model('Projets_model');
|
|
$this->load->model('Tache_model');
|
|
$this->lang->load('clients');
|
|
$this->load->library('table');
|
|
$this->load->helper('form');
|
|
$this->load->library('session');
|
|
$this->load->model('Config_model');
|
|
$this->load->helper('jira_helper');
|
|
}
|
|
public function index()
|
|
{
|
|
$this->load->view('clients/header' );
|
|
$this->load->view('clients/list' );
|
|
$this->load->view('clients/footer' );
|
|
}
|
|
public function form($mem_id,$error='',$pageSection='')
|
|
{
|
|
|
|
// $error['error']=array('type'=>'error','message'=>'test');
|
|
// $error['error']=$error;
|
|
|
|
|
|
|
|
// prépare tout les info pour la forme
|
|
$data=$this->Clients_model->mod_getForminfo($mem_id);
|
|
|
|
|
|
$data['contacts']=$this->Clients_model->mod_listcontact($mem_id);
|
|
|
|
|
|
$data['projets']=$this->Clients_model->mod_listprojets($mem_id,1);
|
|
|
|
if ($pageSection<>'')
|
|
$data['pageSection']=$pageSection;
|
|
|
|
$this->load->view('clients/header' );
|
|
$this->load->view('clients/form',$data );
|
|
$this->load->view('clients/footer',$error );
|
|
}
|
|
public function loadData_list($record=0,$filtre1='',$filtre2='',$filtre3='',$filtre4='',$mem_listactive=1,$mem_projetsactive=1,$excel=0) {
|
|
|
|
|
|
|
|
$this->Config_model->conf_getFiltreData($this->session->id,'list_client','mem_select_1',$filtre1,1,0);
|
|
$this->Config_model->conf_getFiltreData($this->session->id,'list_client','mem_select_2',$filtre2,1,0);
|
|
$this->Config_model->conf_getFiltreData($this->session->id,'list_client','mem_select_3',$filtre3,1,0);
|
|
$this->Config_model->conf_getFiltreData($this->session->id,'list_client','mem_select_4',$filtre4,1,0);
|
|
$this->Config_model->conf_getFiltreData($this->session->id,'list_client','mem_listactive',$mem_listactive,1,0);
|
|
$this->Config_model->conf_getFiltreData($this->session->id,'list_client','mem_projetsactive',$mem_projetsactive,1,0);
|
|
|
|
$filtre1=urldecode($filtre1);
|
|
$filtre2=urldecode($filtre2);
|
|
$filtre3=urldecode($filtre3);
|
|
$filtre4=urldecode($filtre4);
|
|
$data=$this->Clients_model->mod_loadData_list($record,$filtre1,$filtre2,$filtre3,$filtre4,$mem_listactive,$mem_projetsactive,$excel);
|
|
|
|
echo json_encode($data);
|
|
}
|
|
|
|
public function saveRecord($id)
|
|
{
|
|
|
|
if ($id==0){
|
|
$id=$this->Clients_model->mod_createRecordbd($_POST,'com_');
|
|
|
|
if ($id!=0)
|
|
$error=array('type'=>'success','message'=>'Nouvelle fiche créée');
|
|
else
|
|
$error=array('type'=>'error','message'=>'test');
|
|
} else {
|
|
$ok=$this->Clients_model->mod_saveRecordbd($id,$_POST,'com_');
|
|
if ($ok)
|
|
$error=array('type'=>'success','message'=>'Fiche sauvegardé');
|
|
else
|
|
$error=array('type'=>'error','message'=>'test');
|
|
|
|
|
|
|
|
}
|
|
|
|
$this->form($id,$error);
|
|
}
|
|
|
|
public function deletecontact($id,$con_id){
|
|
$this->Clients_model->mod_deleteRecordbdcontact($id);
|
|
$error=array('type'=>'success','message'=>'Contact effacé');
|
|
|
|
$this->form($con_id,$error,'sectioncontacts');
|
|
}
|
|
public function editcontact($id,$con_id)
|
|
{
|
|
$new_post=array();
|
|
foreach($_POST as $key => $value ){
|
|
$pieces = explode("/", $key);
|
|
if ($pieces[0]==$id){
|
|
$new_post[$pieces[1]]=$value;
|
|
}
|
|
}
|
|
print_r($new_post);
|
|
print_r($_POST);
|
|
$this->Clients_model->mod_editRecordbdcontact($new_post,'con_',$id);
|
|
$error=array('type'=>'success','message'=>'Nouvelle fiche créée');
|
|
$this->form($con_id,$error,'sectioncontacts');
|
|
}
|
|
public function saveRecordcontact($id)
|
|
{
|
|
$mem_con_id=0;
|
|
if($_POST['button']=='new'){
|
|
$mem_con_id=0;
|
|
|
|
}else{
|
|
$mem_con_id=$_POST['button'];
|
|
|
|
}
|
|
|
|
|
|
$new_post=array();
|
|
|
|
foreach($_POST as $key => $value ){
|
|
$pieces = explode("/", $key);
|
|
if(isset($pieces[1])){
|
|
if ($pieces[0]== $mem_con_id){
|
|
$new_post[$pieces[1]]=$value;
|
|
}
|
|
}
|
|
}
|
|
if($_POST['button']=='new'){
|
|
$this->Clients_model->mod_createRecordbdcontact($new_post,'con_',$id);
|
|
}else{
|
|
$this->Clients_model->mod_editRecordbdcontact($new_post,'con_',$mem_con_id);
|
|
}
|
|
$error=array('type'=>'success','message'=>'Nouvelle fiche créée');
|
|
$this->form($id,$error,'sectioncontacts');
|
|
}
|
|
} |