update
This commit is contained in:
976
application/models/Clients_model.php
Normal file
976
application/models/Clients_model.php
Normal file
@ -0,0 +1,976 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Clients_model extends CI_Model {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->helper('date');
|
||||
$this->load->model('FxForm_model');
|
||||
}
|
||||
|
||||
public function mod_getRecords($rowno,$rowperpage,$filtre1="",$filtre2="",$filtre3="",$filtre4="",$mem_listactive=1,$langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,config_pays.pay_nom_'.$langue.' as com_pay,config_provinces.pro_nom_'.$langue.' as com_pro,cli_genres.gen_nom_'.$langue.' as com_type ');
|
||||
$this->db->from('cli_compte');
|
||||
$this->db->join('config_pays', 'cli_compte.com_pay_id=config_pays.pay_id','left');
|
||||
$this->db->join('config_provinces', 'cli_compte.com_pro_id=config_provinces.pro_id','left');
|
||||
$this->db->join('cli_genres', 'cli_compte.com_gen_id=cli_genres.gen_id','left');
|
||||
|
||||
$this->db->limit($rowperpage, $rowno);
|
||||
$this->db->order_by('com_num_client desc');
|
||||
$this->db->where("com_actif",$mem_listactive );
|
||||
if($filtre1!="")
|
||||
$this->db->where("com_num_client LIKE '%$filtre1%'");
|
||||
if($filtre2!="")
|
||||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||||
if($filtre4!="")
|
||||
$this->db->where("com_gen_id",$filtre4);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
// $clients=$query->result_array();
|
||||
$newclients=array();
|
||||
// ajouter la liste des type
|
||||
$xx=0;
|
||||
// for ($x = 0; $x < count($clients); $x++) {
|
||||
foreach ($query->result_array() as $clients)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('cli_contacts');
|
||||
$this->db->where('ref_id',$clients['com_id']);
|
||||
$this->db->where('con_actif=1' );
|
||||
|
||||
$query2 = $this->db->get();
|
||||
|
||||
$row = $query2->result_array();
|
||||
$mem_contact="";
|
||||
$mem_contact_list=array();
|
||||
$xxx=0;
|
||||
foreach($row as $key => $value)
|
||||
{
|
||||
$mem_contact=$mem_contact.$value['con_prenom']." ".$value['con_nom']." ".$value['con_telephone'].' '.$value['con_ext']."<br>";
|
||||
$mem_contact_list[$xxx]['con_prenom']=$value['con_prenom'];
|
||||
$mem_contact_list[$xxx]['con_nom']=$value['con_nom'];
|
||||
$mem_contact_list[$xxx]['con_telephone']=$value['con_telephone'];
|
||||
$mem_contact_list[$xxx]['con_ext']=$value['con_ext'];
|
||||
$mem_contact_list[$xxx]['con_courriel']=$value['con_courriel'];
|
||||
$mem_contact_list[$xxx]['con_telephone2']=$value['con_telephone2'];
|
||||
|
||||
$xxx=$xxx+1;
|
||||
}
|
||||
|
||||
$mem_type=substr($mem_contact, 0, -4);
|
||||
$mem_skip=false;
|
||||
if($filtre3!=""){
|
||||
$pos = strrpos(strtolower($mem_type), strtolower($filtre3));
|
||||
if ($pos === false) { // note: three equal signs
|
||||
$mem_skip=true;
|
||||
}
|
||||
|
||||
}
|
||||
if (!$mem_skip){
|
||||
$newclients[$xx]=$clients;
|
||||
|
||||
$newclients[$xx]['list_contacts']=$mem_type;
|
||||
$newclients[$xx]['contact_list_array']=$mem_contact_list;
|
||||
$xx++;
|
||||
}
|
||||
}
|
||||
|
||||
return $newclients;
|
||||
}
|
||||
public function mod_getRecordCountfilter($filtre1="",$filtre2="",$filtre3="",$filtre4="",$mem_listactive=1)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('* ');
|
||||
$this->db->from('cli_compte');
|
||||
$this->db->join('config_pays', 'cli_compte.com_pay_id=config_pays.pay_id','left');
|
||||
$this->db->join('config_provinces', 'cli_compte.com_pro_id=config_provinces.pro_id','left');
|
||||
$this->db->join('cli_genres', 'cli_compte.com_gen_id=cli_genres.gen_id','left');
|
||||
|
||||
$this->db->order_by('com_num_client desc');
|
||||
$this->db->where("com_actif",$mem_listactive );
|
||||
if($filtre1!="")
|
||||
$this->db->where("com_num_client LIKE '%$filtre1%'");
|
||||
if($filtre2!="")
|
||||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||||
if($filtre4!="")
|
||||
$this->db->where("com_gen_id",$filtre4);
|
||||
$query = $this->db->get();
|
||||
|
||||
$clients=$query->result_array();
|
||||
$newclients=array();
|
||||
// ajouter la liste des type
|
||||
$xx=0;
|
||||
for ($x = 0; $x < count($clients); $x++) {
|
||||
|
||||
$this->db->select('*');
|
||||
$this->db->from('cli_contacts');
|
||||
$this->db->where('ref_id',$clients[$x]['com_id']);
|
||||
$query2 = $this->db->get();
|
||||
$row = $query2->result_array();
|
||||
$mem_contact="";
|
||||
foreach($row as $key => $value)
|
||||
{
|
||||
|
||||
|
||||
$mem_contact=$mem_contact.$value['con_prenom']." ".$value['con_nom']." ".$value['con_telephone'].' '.$value['con_ext']."<br>";
|
||||
|
||||
}
|
||||
|
||||
$mem_type=substr($mem_contact, 0, -4);
|
||||
$mem_skip=false;
|
||||
if($filtre3!=""){
|
||||
$pos = strrpos($mem_type, $filtre3);
|
||||
if ($pos === false) { // note: three equal signs
|
||||
$mem_skip=true;
|
||||
}
|
||||
|
||||
}
|
||||
if (!$mem_skip){
|
||||
$newclients[$xx]=$clients[$x];
|
||||
|
||||
$newclients[$xx]['list_contacts']=$mem_type;
|
||||
$xx++;
|
||||
}
|
||||
}
|
||||
|
||||
return $xx;
|
||||
}
|
||||
|
||||
|
||||
public function mod_getRecords_contacts($id,$langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,cli_contacts_roles.rol_nom as role');
|
||||
$this->db->from('cli_contacts');
|
||||
$this->db->join('cli_contacts_roles', 'cli_contacts_roles.rol_id=cli_contacts.con_role_id','left');
|
||||
$this->db->where('cli_contacts.ref_id',$id);
|
||||
$this->db->where('cli_contacts.con_actif',1);
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
public function mod_getRecord($id,$langue='fr')
|
||||
{
|
||||
// trouve un enregiestrement
|
||||
$this->db->select('*,config_pays.pay_nom_'.$langue.' as com_pay,config_provinces.pro_nom_'.$langue.' as com_pro ');
|
||||
$this->db->from('cli_compte');
|
||||
$this->db->join('config_pays', 'cli_compte.com_pay_id=config_pays.pay_id','left');
|
||||
$this->db->join('config_provinces', 'cli_compte.com_pro_id=config_provinces.pro_id','left');
|
||||
$this->db->where('com_id='.$id);
|
||||
|
||||
$this->db->limit(1);
|
||||
$this->db->order_by('com_num_client desc');
|
||||
$query = $this->db->get();
|
||||
return $query->row();
|
||||
}
|
||||
public function mod_saveRecordbd($id,$data,$pref)
|
||||
{
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data=array();
|
||||
// ajoute les checkbox
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif']=0;
|
||||
foreach($data as $key => $value )
|
||||
{
|
||||
if (substr($key,0,strlen($pref))==$pref){
|
||||
$mem_data[$key]=$value;
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_modif']= date("Y-m-d H:i:s") ;
|
||||
$mem_where = "com_id =".$id;
|
||||
|
||||
$str = $this->db->update('cli_compte', $mem_data, $mem_where);
|
||||
$ok=true;
|
||||
|
||||
return $ok ;
|
||||
}
|
||||
public function mod_createRecordbd($data,$pref)
|
||||
{
|
||||
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif']=0;
|
||||
// creation de la chaine de save
|
||||
|
||||
$mem_data=array();
|
||||
foreach($data as $key => $value )
|
||||
{
|
||||
if (substr($key,0,strlen($pref))==$pref){
|
||||
$mem_data[$key]=$value;
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_creation']=date("Y-m-d H:i:s");
|
||||
$mem_data['com_actif']=1;
|
||||
$str = $this->db->insert('cli_compte', $mem_data);
|
||||
|
||||
$ok=true;
|
||||
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
public function mod_editRecordbdcontact($data,$pref,$ref_id)
|
||||
{
|
||||
$mem_data=array();
|
||||
foreach($data as $key => $value )
|
||||
{
|
||||
if (substr($key,0,strlen($pref))==$pref){
|
||||
$mem_data[$key]=$value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$mem_where = "con_id =".$ref_id;
|
||||
|
||||
$str = $this->db->update('cli_contacts', $mem_data, $mem_where);
|
||||
|
||||
$ok=true;
|
||||
|
||||
return ;
|
||||
}
|
||||
public function mod_createRecordbdcontact($data,$pref,$ref_id)
|
||||
{
|
||||
$mem_data=array();
|
||||
foreach($data as $key => $value )
|
||||
{
|
||||
if (substr($key,0,strlen($pref))==$pref){
|
||||
$mem_data[$key]=$value;
|
||||
}
|
||||
}
|
||||
$mem_data['ref_id']=$ref_id;
|
||||
$mem_data['con_creation']=date("Y-m-d H:i:s");
|
||||
$mem_data['con_actif']=1;
|
||||
|
||||
$str = $this->db->insert('cli_contacts', $mem_data);
|
||||
|
||||
$ok=true;
|
||||
|
||||
return ;
|
||||
}
|
||||
public function mod_deleteRecordbdcontact($id)
|
||||
{
|
||||
|
||||
$mem_data['con_actif']=0;
|
||||
$mem_where = "con_id =".$id;
|
||||
|
||||
$str = $this->db->update('cli_contacts', $mem_data, $mem_where);
|
||||
|
||||
|
||||
$ok=true;
|
||||
|
||||
return ;
|
||||
}
|
||||
public function mod_getRecordCount() {
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('cli_compte');
|
||||
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_loadData_list($record=0,$filtre1='',$filtre2='',$filtre3='',$filtre4='',$mem_listactive=1,$mem_projetsactive=1,$excel=0) {
|
||||
|
||||
|
||||
$this->load->model('Config_model');
|
||||
$filtre1=($filtre1=='null'?'':$filtre1);
|
||||
$filtre2=($filtre2=='null'?'':$filtre2);
|
||||
$filtre3=($filtre3=='null'?'':$filtre3);
|
||||
$filtre4=($filtre4=='null'?'':$filtre4);
|
||||
$recordPerPage = 999;
|
||||
$config["cur_page"] = $record;
|
||||
if($record != 0){
|
||||
$record = ($record-1) * $recordPerPage;
|
||||
}
|
||||
$recordCount2 = $this->mod_getRecordCount();
|
||||
$recordCount = $this->mod_getRecordCountfilter($filtre1,$filtre2,$filtre3,$filtre4,$mem_listactive);
|
||||
|
||||
$client_list = $this->mod_getRecords($record,$recordPerPage,$filtre1,$filtre2,$filtre3,$filtre4,$mem_listactive);
|
||||
$config['base_url'] = base_url().'index.php/Clients/loadData_list';
|
||||
$config['use_page_numbers'] = TRUE;
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Previous';
|
||||
$config['total_rows'] = $recordCount;
|
||||
$config['per_page'] = $recordPerPage;
|
||||
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["uri_segment"] = 2;
|
||||
$config["num_links"] = 2;
|
||||
$config['full_tag_open'] = '<div ><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></div><!--pagination-->';
|
||||
|
||||
$config['first_link'] = '« First';
|
||||
$config['first_tag_open'] = '<li class="prev page">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
|
||||
$config['last_link'] = 'Last »';
|
||||
$config['last_tag_open'] = '<li class="next page">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
|
||||
$config['next_link'] = 'Next →';
|
||||
$config['next_tag_open'] = '<li class="next page">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
|
||||
$config['prev_link'] = '← Previous';
|
||||
$config['prev_tag_open'] = '<li class="prev page">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
|
||||
$config['cur_tag_open'] = '<li class="active"><a href="">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
|
||||
$config['num_tag_open'] = '<li class="page">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$this->pagination->initialize($config);
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
$data['recordCount']=$recordCount2;
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
$mem_excel='<a id="excel" data-id="1" class="btn btn-primary btn-circle fa fa-cloud-download"> </a>';
|
||||
|
||||
$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||||
$header=array($mem_excel.$mem_link_new,
|
||||
'Compagnie',
|
||||
'Type',
|
||||
'Ville',
|
||||
'Contacts','Code Client','Type');
|
||||
if ($excel==1){
|
||||
$mem_excel_output['header']=array('','Nom du client', 'Type','Contact','Télépnone','ext',
|
||||
'Email','Cellulaire', );
|
||||
$mem_excel_output['headerwidth']=array(5,40,15,30,20,10,40,20,30,5,30,30);
|
||||
|
||||
}
|
||||
if ($excel==2){
|
||||
$mem_excel_output['header']=array('Compagnie','Contact',);
|
||||
$mem_excel_output['headerwidth']=array(40,40,40,40,40,40,40,40,40,40,40,40);
|
||||
|
||||
}
|
||||
$nbitem=0;
|
||||
|
||||
// filter
|
||||
global $mem_data;
|
||||
$data_row = array();
|
||||
$data_row[]=array('data'=>'Filtre', 'align' => 'left');
|
||||
|
||||
// ----compagnie---------------------------------------------------------------------
|
||||
$mem_champ='filtre_2';
|
||||
$mem_value=$filtre2;
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_2');
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// ----contact---------------------------------------------------------------------
|
||||
$data_row[]=array('data'=>"", 'align' => 'left');
|
||||
$data_row[]=array('data'=>"", 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='filtre_3';
|
||||
$mem_value=$filtre3;
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_3');
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
// --code client-----------------------------------------------------------------------
|
||||
$mem_champ='filtre_1';
|
||||
$mem_value=$filtre1;
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_1',5);
|
||||
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
|
||||
|
||||
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// --code client-----------------------------------------------------------------------
|
||||
|
||||
$mem_champ='filtre_4';
|
||||
$mem_value=$filtre4;
|
||||
$mem_data['select'][$mem_champ]['choix']=$this->Config_model->conf_getGenresClient('fr',true);
|
||||
|
||||
$mem_filtre=form_dropdown($mem_champ,$mem_data['select'][$mem_champ]['choix'],$mem_value,'class="filtre_4"');
|
||||
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
// prépare les donnés du tableau
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
|
||||
$mem_excel2='<a id="excel" data-filtre1="'.$row['com_num_client'].'" data-id="2" class="btn btn-primary btn-circle fa fa-cloud-download"> </a>';
|
||||
|
||||
// faire le link pour edit
|
||||
$mem_link_edit=anchor('clients/form/'.$row['com_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit" ');
|
||||
$mem_link_projet=anchor('projets/createRecord/0/'.$row['com_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-briefcase" ');
|
||||
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_edit.$mem_excel2, 'align' => 'left' );
|
||||
$data_row[] = array('data'=>$row['com_compagnie'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['com_type'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['com_ville'], 'align' => 'left');
|
||||
|
||||
|
||||
$data_row[] = array('data'=>$row['list_contacts'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_num_client'], 'align' => 'left','width' => '5');
|
||||
$data_row[] = array('data'=>$row['gen_nom_fr'], 'align' => 'left');
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
// print_r($row['contact_list_array']);
|
||||
// echo('<br>'); echo('<br>');
|
||||
|
||||
// echo('<br>');
|
||||
if ($excel==1){
|
||||
$data_row_excel = array();
|
||||
$data_row_excel[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$row['com_compagnie'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$row['com_type'], 'align' => 'left');
|
||||
// $data_row_excel[] = array('data'=>$row['det_fac_numero'], 'align' => 'left');
|
||||
// $data_row_excel[] = array('data'=>$row['proj_numero'], 'align' => 'left','width'=>3);
|
||||
// $data_row_excel[] = array('data'=>number_format($row['det_fac_avanttx'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
$mem_nb_contact=1;
|
||||
if(count($row['contact_list_array'])!=0){
|
||||
foreach($row['contact_list_array'] as $contact){
|
||||
if ($mem_nb_contact==1){
|
||||
$data_row_excel[] = array('data'=>$contact['con_prenom'].' '.$contact['con_nom'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_telephone'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_ext'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_courriel'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_telephone2'], 'align' => 'right');
|
||||
|
||||
|
||||
|
||||
|
||||
$mem_nb_contact=$mem_nb_contact+1;
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
}else{
|
||||
$data_row_excel = array();
|
||||
$data_row_excel[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_prenom'].' '.$contact['con_nom'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_telephone'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_ext'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_courriel'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$contact['con_telephone2'], 'align' => 'right');
|
||||
$mem_nb_contact=$mem_nb_contact+1;
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}else{ $mem_excel_output['data'][]=$data_row_excel;}
|
||||
}
|
||||
|
||||
$client_listprojet=$this->Config_model->conf_getprojetsclients($row['com_id'],$mem_projetsactive,$filtre3);
|
||||
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($client_listprojet);
|
||||
// echo '</pre>';
|
||||
// echo("--------------------------");
|
||||
|
||||
$mem_projets=$this->Clients_model->mod_listprojets($row['com_id'],$mem_projetsactive,$filtre3,"clients");
|
||||
|
||||
|
||||
|
||||
if ($excel==2){
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($client_listprojet);
|
||||
// echo '</pre>';
|
||||
|
||||
$data_row_excel = array();
|
||||
|
||||
$data_row_excel[] = array('data'=>$row['com_compagnie'], 'align' => 'left');
|
||||
|
||||
$data_row_excel[] = array('data'=>$row['list_contacts'], 'align' => 'left');
|
||||
|
||||
|
||||
|
||||
// $data_row_excel[] = array('data'=>$row['det_fac_numero'], 'align' => 'left');
|
||||
// $data_row_excel[] = array('data'=>$row['proj_numero'], 'align' => 'left','width'=>3);
|
||||
// $data_row_excel[] = array('data'=>number_format($row['det_fac_avanttx'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
$data_row_excel = array();
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
$data_row_excel = array();
|
||||
|
||||
|
||||
$data_row_excel[] = array('data'=>'Numéro de projet', 'align' => 'right','bold' => true);
|
||||
$data_row_excel[] = array('data'=>'Étape du projet', 'align' => 'left','bold' => true);
|
||||
$data_row_excel[] = array('data'=>'Nom du projet', 'align' => 'left','bold' => true);
|
||||
$data_row_excel[] = array('data'=>'Représentant Express Tours', 'align' => 'left','bold' => true);
|
||||
$data_row_excel[] = array('data'=>'Contact', 'align' => 'left','bold' => true);
|
||||
$data_row_excel[] = array('data'=>'Date de confirmation du projet', 'align' => 'left','bold' => true);
|
||||
$data_row_excel[] = array('data'=>'Date de début du projet', 'align' => 'left','bold' => true);
|
||||
$data_row_excel[] = array('data'=>'Date de fin du projet', 'align' => 'left','bold' => true);
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
|
||||
$mem_nb_contact=1;
|
||||
if(count($client_listprojet)!=0){
|
||||
foreach($client_listprojet as $projet){
|
||||
$data_row_excel = array();
|
||||
$data_row_excel[] = array('data'=>$projet['proj_numero'], 'align' => 'left'); ;
|
||||
//$data_row_excel[] = array('data'=> $this->Config_model->conf_getGenresProjetid($projet['proj_dest'],$langue='fr'), 'align' => 'left'); ;
|
||||
$data_row_excel[] = array('data'=>$projet['gen_nom_fr'], 'align' => 'left'); ;
|
||||
|
||||
$data_row_excel[] = array('data'=>$projet['proj_nom'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$projet['usa_prenom']." ".$projet['usa_nom'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$projet['con_prenom']." ".$projet['con_nom'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$projet['proj_date_annule'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$projet['proj_date_debut'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$projet['proj_date_fin'], 'align' => 'left');
|
||||
|
||||
$mem_nb_contact=$mem_nb_contact+1;
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}else{ $mem_excel_output['data'][]=$data_row_excel;}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// valide les projets
|
||||
|
||||
|
||||
// $projets=$this->Config_model->conf_getprojetsclients($row['com_id']);
|
||||
|
||||
// $mem_projets="";
|
||||
// $mem_projets_client='';
|
||||
// foreach($projets as $value){
|
||||
// $mem_link_edit=anchor('projets/form/'.$value['proj_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit statut_'.$value['proj_etape'].'"' );
|
||||
// $mem_projets=$mem_projets. $mem_link_edit;
|
||||
// $mem_projets=$mem_projets.' '.$value['proj_numero'].' '.$value['proj_nom'].'<br>';
|
||||
// $mem_projets_client=' Création de projet <br>';
|
||||
// }
|
||||
|
||||
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=>'' );
|
||||
$data_row[] = array('data'=>$mem_projets,'colspan' => 6 );
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead>',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
if ($excel!=0){
|
||||
// $mem_excel_output['data']=$tabular_data;
|
||||
|
||||
|
||||
$data['fichier']="clients.xls";
|
||||
$mem_excel_output['fichier']="clients";
|
||||
// $mem_excel_output['titre']="depart du ".$debut.' @ '.$fin;
|
||||
$mem_excel_output['titre']="rapport en date du ".date("Y-m-d H:i");;
|
||||
$mem_parameter=array('premiere_ligne'=>0);
|
||||
|
||||
$this->Config_model->excel($mem_excel_output,$mem_parameter);
|
||||
|
||||
}
|
||||
|
||||
$data['empData'] = $tableau_sortie;
|
||||
|
||||
return $data;
|
||||
}
|
||||
public function mod_listcontact($record=0) {
|
||||
|
||||
|
||||
|
||||
// $recordCount = $this->Clients_model->getRecordCount();
|
||||
|
||||
$client_list = $this->mod_getRecords_contacts($record);
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
$mem_link_new='<button value="new" name="button" id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
|
||||
|
||||
$header=array('','Prénom',
|
||||
'Nom',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Téléphone bureau',
|
||||
'Ext',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Cellulaire',
|
||||
'Courriel',
|
||||
'Role','');
|
||||
// prépare les donnés du tableau
|
||||
$nbitem=0;
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
|
||||
|
||||
$mem_link_edit=anchor('clients/deletecontact/'.$row['con_id'] .'/'.$record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-trash" ');
|
||||
//$mem_link_save=anchor('clients/editcontact/'.$row['con_id'] .'/'.$record, ' ', 'class="btn btn-primary btn-circle glyphicon" ');
|
||||
$mem_link_save='<button value="'.$row['con_id'].'" name="button" id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon"></button> ';
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left','size'=>5);
|
||||
// $data_row[] = array('data'=>$row['con_prenom'], 'align' => 'left');
|
||||
|
||||
// $data_row[] = array('data'=>$row['con_nom'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_telephone'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_ext'],'width'=>'5', 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_telephone2'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_courriel'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['role'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_prenom'],'name' => $row['con_id'].'/con_prenom' ,'size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_nom'],'name' => $row['con_id'].'/con_nom' ,'size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_telephone'],'name' => $row['con_id'].'/con_telephone' ,'size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_ext'],'name' => $row['con_id'].'/con_ext' ,'size'=>5)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_telephone2'],'name' => $row['con_id'].'/con_telephone2' ,'size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_courriel'],'name' => $row['con_id'].'/con_courriel' ,'size'=>15)));
|
||||
|
||||
$mem_choix=$this->Config_model->conf_getRolesContacts();
|
||||
$mem_roles=form_dropdown($row['con_id'].'/con_role_id',$mem_choix,$row['con_role_id']) ;
|
||||
|
||||
|
||||
$data_row[] = array('data'=>$mem_roles , 'align' => 'left');
|
||||
$data_row[] = array('data'=>$mem_link_save , 'align' => 'left');
|
||||
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_new);
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_prenom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_nom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_telephone','size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_ext','size'=>5)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_telephone2','size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_courriel','size'=>15)));
|
||||
|
||||
$mem_choix=$this->Config_model->conf_getRolesContacts();
|
||||
$mem_roles=form_dropdown('0/con_role_id',$mem_choix) ;
|
||||
|
||||
|
||||
$data_row[] = array('data'=>$mem_roles , 'align' => 'left');
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
|
||||
return $tableau_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function mod_listprojets($record=0,$mem_projetsactive=1,$filtre3="",$go="") {
|
||||
|
||||
// $recordCount = $this->Clients_model->getRecordCount();
|
||||
$client_list=$this->Config_model->conf_getprojetsclients($record,$mem_projetsactive,$filtre3);
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
$mem_link_new='<button id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
|
||||
$mem_link_projet=anchor('projets/createRecord/0/'.$record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-briefcase" ');
|
||||
$header=array($mem_link_projet,'Numéro',
|
||||
'',
|
||||
'Étape',
|
||||
'Nom',
|
||||
'Représentant',
|
||||
'Contact',
|
||||
'Confirmation',
|
||||
'Date début',
|
||||
'Date fin');
|
||||
// prépare les donnés du tableau
|
||||
$nbitem=0;
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit=anchor('projets/form/'.$row['proj_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit" ');
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left', 'width' => '2');
|
||||
$data_row[] = array('data'=>$row['proj_numero'], 'align' => 'left', 'width' => '2');
|
||||
$data_row[] = array('data'=>" ", 'align' => 'left','class'=>'statut_'.$row['proj_etape']);
|
||||
|
||||
|
||||
|
||||
$data_row[] = array(
|
||||
'data' => $this->load->view('projets/form_etape_client', ['etape' => $row['proj_etape'],'row'=> $row,'key' => $nbitem,"go"=>$go ], true),
|
||||
'align' => 'left'
|
||||
);
|
||||
|
||||
$data_row[] = array('data'=>$row['proj_nom'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['rep_prenom']." ".$row['rep_nom'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['con_prenom']." ".$row['con_nom'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['proj_date_confirmation'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['proj_date_debut'], 'align' => 'left', 'width' => '75');
|
||||
$data_row[] = array('data'=>$row['proj_date_fin'], 'align' => 'left', 'width' => '75');
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th style="background-color: #003333">',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
|
||||
if(!isset($tabular_data))
|
||||
$tabular_data=array();
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
|
||||
return $tableau_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function mod_getforminfo($id)
|
||||
{
|
||||
global $mem_data, $validation;
|
||||
|
||||
$this->load->model('Config_model');
|
||||
$this->load->model('FxForm_model');
|
||||
// vas chercher les info de la fiche
|
||||
|
||||
if($id!=0)
|
||||
$info = $this->mod_getRecord($id);
|
||||
|
||||
// prepare info pour chaque champs utilisé
|
||||
// input
|
||||
$mem_data['mem_id']=$id;
|
||||
$mem_champ='com_compagnie';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'Compagnie','<i class="icon-prepend fa fa- fa-building"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_num_client';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'Numéro client','');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_gen_id';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix']=$this->Config_model->conf_getGenresClient();
|
||||
$mem_data['select'][$mem_champ]['value']= $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Type';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_representant_id';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix']=$this->Config_model->conf_getRepresentantsClient();
|
||||
$mem_data['select'][$mem_champ]['value']= $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Représentant';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_langue';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getLangues();
|
||||
// value multipli select
|
||||
$mem_value = explode(',', $mem_value);
|
||||
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Langue';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ='com_actif';
|
||||
$mem_value=($id==0 ? true : ($info->$mem_champ==1 ? true:false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'Actif';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_ville';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'Ville','');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_pro_id';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix']=$this->Config_model->conf_getProvinces();
|
||||
$mem_data['select'][$mem_champ]['value']= $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Province';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_pay_id';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix']=$this->Config_model->conf_getPays();
|
||||
$mem_data['select'][$mem_champ]['value']= $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Pays';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_codepostal';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'Code postal','');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_adresse';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'Adresse','');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='com_notes';
|
||||
$mem_value=($id==0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'Notes','','Notes');
|
||||
|
||||
$mem_data['validation']=$this->FxForm_model->fxValidation($validation['rule'],$validation['message']);
|
||||
|
||||
|
||||
|
||||
return $mem_data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
916
application/models/Config_model.php
Normal file
916
application/models/Config_model.php
Normal file
@ -0,0 +1,916 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Config_model extends CI_Model {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
|
||||
}
|
||||
|
||||
public function conf_getProvinces($langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('pro_id,pro_nom_'.$langue.' as nom');
|
||||
$this->db->from('config_provinces');
|
||||
|
||||
$this->db->order_by('pro_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['pro_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function conf_getPays($langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('pay_id,pay_nom_'.$langue.' as nom');
|
||||
$this->db->from('config_pays');
|
||||
|
||||
$this->db->order_by('pay_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['pay_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getLangues($langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('lang_id,lang_nom_'.$langue.' as nom');
|
||||
$this->db->from('config_langues');
|
||||
|
||||
$this->db->order_by('lang_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['lang_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function conf_getRolesContacts($langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('rol_id,rol_nom');
|
||||
$this->db->from('cli_contacts_roles');
|
||||
|
||||
$this->db->order_by('rol_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['rol_id']]=$pro['rol_nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getRolesContactsFournisseur($langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('rol_id,rol_nom');
|
||||
$this->db->from('fou_contacts_roles');
|
||||
|
||||
$this->db->order_by('rol_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['rol_id']]=$pro['rol_nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getGenresClient($langue='fr',$choix_vide=false)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_id,gen_nom_'.$langue.' as nom');
|
||||
$this->db->from('cli_genres');
|
||||
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['gen_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getFiltreData($usa_id,$page,$var,$vardefault,$update=0,$typenum=1)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*');
|
||||
$this->db->from('usa_filtre');
|
||||
$this->db->where('fil_usa_id',$usa_id);
|
||||
$this->db->where('fil_page',$page);
|
||||
$this->db->where('fil_var',$var);
|
||||
$query = $this->db->get();
|
||||
$sortie=$query->row();
|
||||
if ($sortie==null){
|
||||
|
||||
$mem_data['fil_usa_id'] = $usa_id ;
|
||||
$mem_data['fil_page']=$page;
|
||||
$mem_data['fil_var']=$var;
|
||||
$mem_data['fil_value']=$vardefault;
|
||||
|
||||
$str = $this->db->insert('usa_filtre', $mem_data);
|
||||
$mem_return=$vardefault;
|
||||
}else{
|
||||
if ($update==1){
|
||||
|
||||
$mem_data['fil_value']=$vardefault;
|
||||
$mem_where = "fil_usa_id=".$usa_id." and "."fil_page='".$page."' and fil_var='".$var."'";
|
||||
$str = $this->db->update('usa_filtre', $mem_data, $mem_where);
|
||||
$mem_return=$vardefault;
|
||||
}else{
|
||||
$mem_return=$sortie->fil_value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($typenum==0)
|
||||
$mem_return='"'.$mem_return.'"';
|
||||
return $mem_return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function conf_getGenresFournisseur($langue='fr',$choix_vide=false,$produit=0)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_id,gen_nom_'.$langue.' as nom');
|
||||
|
||||
$this->db->from('fou_genres');
|
||||
if ($produit==0)
|
||||
$this->db->where('gen_actif_fournisseur',1);
|
||||
else
|
||||
$this->db->where('gen_actif_produit',1);
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['gen_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getGenresPaiement($langue='fr',$choix_vide=false)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_id,gen_nom_'.$langue.' as nom');
|
||||
|
||||
$this->db->from('pai_genres');
|
||||
|
||||
$this->db->where('gen_actif',1);
|
||||
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['gen_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function conf_getClient($langue='fr',$choix_vide=false)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('com_id,com_compagnie as nom');
|
||||
$this->db->from('cli_compte');
|
||||
|
||||
$this->db->order_by('com_compagnie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['com_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function conf_getContactClient($langue='fr',$choix_vide=false,$mem_com_id)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('con_id,con_prenom,con_nom');
|
||||
$this->db->from('cli_contacts');
|
||||
$this->db->where('con_actif',1);
|
||||
$this->db->where('ref_id',$mem_com_id);
|
||||
$this->db->order_by('con_nom');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['con_id']]=$pro['con_prenom'].' '.$pro['con_nom'];
|
||||
|
||||
}
|
||||
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function conf_getGenresProjet($type='a',$langue='fr',$choix_vide=false)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_id,gen_nom_'.$langue.' as nom');
|
||||
$this->db->from('proj_genres');
|
||||
$this->db->where('gen_actif',1);
|
||||
$this->db->where('gen_cat',$type);
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['gen_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getGenresProjetid( $id,$langue='fr' )
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_id,gen_nom_'.$langue.' as nom');
|
||||
$this->db->from('proj_genres');
|
||||
|
||||
$this->db->where('gen_id',$id);
|
||||
|
||||
$query = $this->db->get();
|
||||
$mem_result = $query->row()->nom;
|
||||
return $mem_result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function conf_getListeevenement()
|
||||
{
|
||||
$db2 = $this->load->database('ms1inscription', TRUE);
|
||||
|
||||
// On sélectionne l'année de fin pour trier et afficher si besoin
|
||||
$db2->select('eve_id, eve_nom_fr, eve_date_fin, YEAR(eve_date_fin) AS annee', FALSE);
|
||||
$db2->from('inscriptions_evenements');
|
||||
$db2->where('eve_actif', 1);
|
||||
$db2->where('eve_nom_fr != ""'); // uniquement ceux qui ont un nom (FR ou pas)
|
||||
|
||||
// Tri: par année DESC puis par nom FR ASC
|
||||
$db2->order_by('YEAR(eve_date_fin) DESC', '', FALSE);
|
||||
$db2->order_by('eve_nom_fr ASC');
|
||||
|
||||
$query = $db2->get();
|
||||
$mem_result = $query->result_array();
|
||||
$mem_sortie = array();
|
||||
|
||||
// Option vide en première position
|
||||
$mem_sortie[0] = '';
|
||||
|
||||
foreach ($mem_result as $row) {
|
||||
$annee = !empty($row['annee']) ? (string)$row['annee'] : '';
|
||||
$nom = trim($row['eve_nom_fr']);
|
||||
|
||||
if ($nom === '') {
|
||||
$libelle = 'Événement sans nom' . ($annee !== '' ? ' (' . $annee . ')' : '');
|
||||
} else {
|
||||
$libelle = '(' . $annee . ') '.$nom;
|
||||
}
|
||||
|
||||
$mem_sortie[$row['eve_id']] = $libelle;
|
||||
}
|
||||
|
||||
return $mem_sortie;
|
||||
}
|
||||
|
||||
|
||||
public function conf_getGenresTache_id($id,$langue='fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_nom_'.$langue.' as nom');
|
||||
$this->db->from('tach_genres');
|
||||
|
||||
$this->db->where('gen_id',$id);
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
$mem_result = $query->row()->nom;
|
||||
return $mem_result;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getGenresTache($langue='fr',$choix_vide=false,$cat='a',$gen_fonction='t')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_id,gen_nom_'.$langue.' as nom');
|
||||
$this->db->from('tach_genres');
|
||||
$this->db->where('gen_actif',1);
|
||||
if($cat!="")
|
||||
$this->db->where('gen_cat',$cat);
|
||||
|
||||
$this->db->where('gen_fonction',$gen_fonction);
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['gen_id']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getGenresSection($langue='fr',$choix_vide=false)
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('gen_id,gen_nom_'.$langue.' as nom');
|
||||
$this->db->from('tach_section');
|
||||
$this->db->where('gen_actif',1);
|
||||
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['nom']]=$pro['nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function conf_csscouleurprojets(){
|
||||
|
||||
// list la bb client
|
||||
$this->db->select('*');
|
||||
$this->db->from('proj_genres');
|
||||
$this->db->where('gen_actif',1);
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie='<style>';
|
||||
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie=$mem_sortie.'.statut_'.$pro['gen_id'].' {
|
||||
background-color: '.$pro['gen_color'].'; color: '.$pro['gen_text_color'].'; }';
|
||||
|
||||
}
|
||||
$mem_sortie=$mem_sortie.'</style>';
|
||||
return $mem_sortie;
|
||||
}
|
||||
public function conf_csscouleurtaches(){
|
||||
|
||||
// list la bb client
|
||||
$this->db->select('*');
|
||||
$this->db->from('tach_genres');
|
||||
$this->db->where('gen_actif',1);
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie='<style>';
|
||||
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie=$mem_sortie.'.statuttach_'.$pro['gen_id'].' {
|
||||
background-color: '.$pro['gen_color'].'; color: '.$pro['gen_text_color'].'; }';
|
||||
|
||||
}
|
||||
$mem_sortie=$mem_sortie.'</style>';
|
||||
return $mem_sortie;
|
||||
}
|
||||
public function conf_javacouleurprojets(){
|
||||
|
||||
// list la bb client
|
||||
$this->db->select('*');
|
||||
$this->db->from('proj_genres');
|
||||
$this->db->where('gen_actif',1);
|
||||
$this->db->order_by('gen_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie='';
|
||||
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie=$mem_sortie.'mcolor['.$pro['gen_id'].']="'.$pro['gen_color'].'";tcolor['.$pro['gen_id'].']="'.$pro['gen_text_color'].'";';
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $mem_sortie;
|
||||
}
|
||||
|
||||
|
||||
public function conf_getRepresentantsClient()
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('usa_id,usa_prenom,usa_nom');
|
||||
$this->db->from('usa_usagers');
|
||||
$this->db->where('usa_actif',1);
|
||||
$this->db->where('usa_representant',1);
|
||||
$this->db->order_by('usa_representant_trie');
|
||||
$query = $this->db->get();
|
||||
$mem_result=$query->result_array();
|
||||
$mem_sortie=array();
|
||||
$mem_sortie[0]=' ';
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['usa_id']]=$pro['usa_prenom'].' '.$pro['usa_nom'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function conf_getLastnumprojets()
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('proj_numero');
|
||||
$this->db->from('proj_entete');
|
||||
|
||||
|
||||
$this->db->order_by('proj_numero desc');
|
||||
$query = $this->db->get();
|
||||
|
||||
$sortie=$query->row();
|
||||
|
||||
return $sortie->proj_numero ;
|
||||
|
||||
}
|
||||
public function conf_getprojetsclients($client_id,$mem_projetsactive,$filtre3="")
|
||||
{
|
||||
// list la bb client
|
||||
|
||||
$this->db->select('*,if(proj_date_debut="0000-00-00","9999-99-99",proj_date_debut) as trie, cli_contacts.con_prenom as con_prenom, cli_contacts.con_nom as con_nom,usa_usagers.usa_prenom as rep_prenom,usa_usagers.usa_nom as rep_nom,cli_compte.com_compagnie as compagnie,proj_genres.gen_nom_fr as etape');
|
||||
$this->db->from('proj_entete');
|
||||
$this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id ','left');
|
||||
$this->db->join('cli_contacts', 'proj_entete.proj_contact_principale=cli_contacts.con_id ','left');
|
||||
$this->db->join('proj_genres', 'proj_genres.gen_id=proj_entete.proj_etape','left');
|
||||
$this->db->join('usa_usagers', 'usa_usagers.usa_id=proj_entete.proj_representant_id','left');
|
||||
|
||||
|
||||
if ($mem_projetsactive==1){
|
||||
|
||||
$this->db->where('proj_genres.gen_id != 4');
|
||||
$this->db->where('proj_genres.gen_id != 6');
|
||||
$this->db->where('proj_genres.gen_id != 7');
|
||||
}
|
||||
|
||||
if ($filtre3 != '') {
|
||||
$needle = '%' . mb_strtolower($filtre3, 'UTF-8') . '%';
|
||||
$this->db->where("LOWER(CONCAT(con_nom, ' ', con_prenom)) LIKE", $needle);
|
||||
}
|
||||
|
||||
$this->db->where('proj_client_id',$client_id);
|
||||
$this->db->order_by('trie');
|
||||
$query = $this->db->get();
|
||||
|
||||
$mem_result=$query->result_array();
|
||||
|
||||
return $mem_result ;
|
||||
|
||||
}
|
||||
public function conf_tax_desc($langue='fr')
|
||||
{
|
||||
|
||||
$this->db->select('*');
|
||||
$this->db->from('proj_taux');
|
||||
|
||||
|
||||
$this->db->where('tau_actif',1);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
$mem_result=$query->result_array();
|
||||
|
||||
|
||||
$mem_sortie=array();
|
||||
|
||||
foreach ($mem_result as $pro ){
|
||||
$mem_sortie[$pro['tau_nom_fr']]['taux']=$pro['tau_taux'];
|
||||
$mem_sortie[$pro['tau_nom_fr']]['nom']=$pro['tau_nom_'.$langue];
|
||||
$mem_sortie[$pro['tau_nom_fr']]['note']=$pro['tau_note'];
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
}
|
||||
public function conf_numero_facture()
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('config_variable');
|
||||
$this->db->where('config_varname','code_facture');
|
||||
$query = $this->db->get();
|
||||
$sortie=$query->row();
|
||||
$mem_fact= $sortie->config_valeur;
|
||||
|
||||
$this->db->select('*');
|
||||
$this->db->from('config_variable');
|
||||
$this->db->where('config_varname','numero_facture');
|
||||
$query = $this->db->get();
|
||||
|
||||
$sortie=$query->row();
|
||||
$mem_fact=$mem_fact.$sortie->config_valeur;
|
||||
|
||||
$mem_data['config_valeur']= $sortie->config_valeur+1 ;
|
||||
$mem_where = "config_varname ="."'numero_facture'";
|
||||
|
||||
$str = $this->db->update('config_variable', $mem_data, $mem_where);
|
||||
return $mem_fact;
|
||||
}
|
||||
public function conf_var_html($clef,$langue='fr')
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('config_variable');
|
||||
$this->db->where('config_varname',$clef.'_'.$langue);
|
||||
$query = $this->db->get();
|
||||
$sortie=$query->row();
|
||||
//$mem_html= $sortie->config_html_fr;
|
||||
$mem_html= $sortie->{'config_html_'.$langue};
|
||||
|
||||
return $mem_html;
|
||||
}
|
||||
public function conf_email($data,$langue='fr')
|
||||
{
|
||||
|
||||
$this->load->library('email');
|
||||
$config = Array(
|
||||
'protocol' => 'smtp',
|
||||
'smtp_host' => 'smtpout.secureserver.net',
|
||||
'smtp_port' => 25,
|
||||
'smtp_user' => 'send@progiweb.us',
|
||||
'smtp_pass' => 'ProgiwebAirstream'
|
||||
);
|
||||
|
||||
|
||||
//$config['mailpath'] = '/usr/sbin/sendmail';
|
||||
$config['charset'] = 'UTF-8';
|
||||
$config['wordwrap'] = TRUE;
|
||||
|
||||
$this->email->initialize($config);
|
||||
|
||||
// $this->email->set_mailtype("html");
|
||||
//$this->email->from('info@progiweb.ca','test' );
|
||||
$this->email->from('your@example.com','test','email');
|
||||
$this->email->to($data['mem_fou_email']);
|
||||
|
||||
|
||||
// $this->email->bcc('stephan@progiweb.ca');
|
||||
$this->email->subject($data['mem_sujet']);
|
||||
|
||||
|
||||
// $this->email->message("Bonjour,\nVoici de nouvelles réservations.\nMerci de me confirmer que vous avez bien reçu le fichier.\n\n\nHello,\nHere are some new reservations.\nThank you to confirm that you received the file.\n");
|
||||
$this->email->message($data['mem_email']);
|
||||
$this->email->send();
|
||||
if ( ! $this->email->send())
|
||||
{
|
||||
echo $this->email->print_debugger();
|
||||
echo('error');
|
||||
|
||||
}
|
||||
|
||||
echo('fin');
|
||||
}
|
||||
|
||||
function fxSendMail($data) {
|
||||
|
||||
$blnGoDaddy = $data['blnGoDaddy'];
|
||||
$error = 0;
|
||||
$strError = '';
|
||||
$arrSmtp = $GLOBALS['strDebug'] = array();
|
||||
require_once 'mailer/PHPMailer.php';
|
||||
require_once 'mailer/SMTP.php';
|
||||
require_once 'mailer/Exception.php';
|
||||
|
||||
$mail = new PHPMailer\PHPMailer\PHPMailer();
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'localhost';
|
||||
$mail->Port = 25;
|
||||
$mail->SMTPAuth = false; // PAS d'authentification
|
||||
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->SMTPDebug = 0; // ou 2 pour déboguer
|
||||
|
||||
// Options SSL pour éviter les erreurs de certificat
|
||||
$mail->SMTPOptions = array(
|
||||
'ssl' => array(
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true
|
||||
)
|
||||
);
|
||||
|
||||
$arrSmtp['host'] = $mail->Host;
|
||||
$arrSmtp['port'] = $mail->Port;
|
||||
|
||||
|
||||
$mail->SetFrom($data['from_mail'],'');
|
||||
// $from_mail="ms1inscription@progiweb.ca";
|
||||
// $mail->SetFrom($from_mail, fxRemoveHtml($GLOBALS['vClient']));
|
||||
$mail->Subject = $data['subject'];
|
||||
|
||||
$mail->CharSet = "UTF-8";
|
||||
$mail->AddReplyTo($data['from_mail'], $data['from_name']);
|
||||
|
||||
|
||||
if ($data['attach'] != '') {
|
||||
$mail->AddAttachment($data['attach']);
|
||||
//$mail->AddStringAttachment($data['attach'],'reservation.pdf',"utf-8",'application/pdf');
|
||||
}
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Body = $data['body'];
|
||||
if ($data['to_mail']==''){
|
||||
|
||||
}else{
|
||||
$mail->AddAddress($data['to_mail'], $data['to_name']);
|
||||
// if ( $data['to_mail_bcc']!='')
|
||||
// $mail->addCC($data['to_mail_bcc']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// $mail->addCC($data['to_mail_bcc2']);
|
||||
|
||||
|
||||
$mail->SMTPDebug = 0;
|
||||
$mail->Debugoutput = function($str, $level) { $GLOBALS['strDebug'][] = "debug level $level; message: $str\n"; };
|
||||
|
||||
if (!$mail->send()) {
|
||||
echo('erreur');
|
||||
$error = 1;
|
||||
$strError = print_r($mail->ErrorInfo, true);
|
||||
}
|
||||
// print_r($GLOBALS['strDebug']);
|
||||
$this->fxLogMail($data['to_mail'], $data['to_name'], $error, $strError, print_r($GLOBALS['strDebug'], true), print_r($arrSmtp, true), $data['subject'], $data['body'],$data['attach']);
|
||||
|
||||
// Clear all addresses and attachments for next loop
|
||||
$mail->ClearAddresses();
|
||||
$mail->ClearAttachments();
|
||||
|
||||
if ($error == 0)
|
||||
return true;
|
||||
else {
|
||||
//fxcreer_log("Erreur lors de l'envoi du mail. (TO: $to_mail, FROM $from_mail:, SUJET: $subject)");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fxLogMail($to_mail, $to_name, $error, $strError, $strDebug, $strSmtp, $subject, $body,$attch) {
|
||||
|
||||
|
||||
$mem_data['log_error'] = intval($error) ;
|
||||
$mem_data['log_error_msg']=$strError;
|
||||
$mem_data[' log_smtp_connect']=$strSmtp;
|
||||
$mem_data['log_smtp_debug']=$strDebug;
|
||||
$mem_data['log_subject']=$subject;
|
||||
$mem_data['log_message']=$body;
|
||||
$mem_data['log_mailto']=$to_mail;
|
||||
$mem_data['log_nameto']=$to_name;
|
||||
$mem_data['log_attch']=$attch;
|
||||
$str = $this->db->insert('email_logs', $mem_data);
|
||||
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
function fx_info_google_calendar($id){
|
||||
$this->db->select("
|
||||
td.*,
|
||||
CONCAT(aqui.usa_prenom,' ',aqui.usa_nom) AS usa_aqui,
|
||||
CONCAT(cr.usa_prenom,' ',cr.usa_nom) AS usa_create,
|
||||
CONCAT(fin.usa_prenom,' ',fin.usa_nom) AS usa_fin,
|
||||
aqui.usa_courriel as email,
|
||||
client.com_compagnie AS com_client,
|
||||
projet.com_compagnie AS com_projet,
|
||||
fournisseur.com_compagnie AS fournisseur,
|
||||
COALESCE(client.com_compagnie, projet.com_compagnie) AS com_client_affiche
|
||||
", false);
|
||||
$this->db->from('tach_details td');
|
||||
|
||||
$this->db->join('usa_usagers aqui', 'td.tach_aqui_id = aqui.usa_id', 'left');
|
||||
$this->db->join('usa_usagers cr', 'td.tach_create_user_id = cr.usa_id', 'left');
|
||||
$this->db->join('usa_usagers fin', 'td.tach_fin_user_id = fin.usa_id', 'left'); // ajuste si besoin
|
||||
$this->db->join('tach_genres', 'td.tach_type = gen_id', 'left');
|
||||
|
||||
$sec = "LOWER(REPLACE(REPLACE(td.tach_section,'-',''),' ',''))";
|
||||
|
||||
$this->db->join(
|
||||
'proj_entete',
|
||||
"td.tach_section_id = proj_id AND $sec IN ('projets','projet','projetsclient','projetsfournisseur','projetclient','projetfournisseur')",
|
||||
'left'
|
||||
);
|
||||
$this->db->join(
|
||||
'cli_compte client',
|
||||
"td.tach_section_id = client.com_id AND $sec IN ('clients','client')",
|
||||
'left'
|
||||
);
|
||||
$this->db->join(
|
||||
'cli_compte projet',
|
||||
"projet.com_id = proj_entete.proj_client_id AND $sec IN ('projets','projet','projetsclient','projetsfournisseur','projetclient','projetfournisseur')",
|
||||
'left'
|
||||
);
|
||||
$this->db->join(
|
||||
'fou_compte fournisseur',
|
||||
"td.tach_section_id = fournisseur.com_id AND $sec IN ('fournisseurs','fournisseur')",
|
||||
'left'
|
||||
);
|
||||
|
||||
$this->db->where('td.tach_id', $id);
|
||||
$row = $this->db->get()->row_array();
|
||||
|
||||
|
||||
|
||||
return $row;
|
||||
|
||||
|
||||
|
||||
}
|
||||
// fonction pour formatter une valeur sous la forme $ 9,999.99
|
||||
public function excel($data,$mem_parameter=array()){
|
||||
$mem_premiere_ligne=1;
|
||||
if (isset($mem_parameter['premiere_ligne']))
|
||||
$mem_premiere_ligne=$mem_parameter['premiere_ligne'];
|
||||
|
||||
// print("<pre>".print_r($data,true)."</pre>");
|
||||
// exit;
|
||||
|
||||
$memexcfichier = $data['fichier'];
|
||||
|
||||
include 'php/Classes/PHPExcel.php';
|
||||
|
||||
/** PHPExcel_Writer_Excel2007 */
|
||||
//include 'php/Classes/PHPExcel/Writer/Excel2007.php';
|
||||
require_once 'php/Classes/PHPExcel.php';
|
||||
|
||||
// header('Cache-Control: max-age=0');
|
||||
// Instantiate a new PHPExcel object
|
||||
$objPHPExcel = new PHPExcel();
|
||||
// Set the active Excel worksheet to sheet 0
|
||||
|
||||
$objPHPExcel->getProperties()->setCreator("Progiweb");
|
||||
// $objPHPExcel->getProperties()->setLastModifiedBy("Stephan Leith");
|
||||
$objPHPExcel->getProperties()->setTitle("Rapport");
|
||||
// $objPHPExcel->getProperties()->setSubject("Rapport de temps");
|
||||
// $objPHPExcel->getProperties()->setDescription("Rapport");
|
||||
// $objPHPExcel->getProperties()->setKeywords("Temps");
|
||||
// $objPHPExcel->getProperties()->setCategory("Rapport");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
// Initialise the Excel row number
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', $data['titre']);
|
||||
|
||||
$column = 'A';
|
||||
foreach($data['headerwidth'] as $header){
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($column)->setWidth($header);
|
||||
|
||||
$column++;
|
||||
}
|
||||
|
||||
$column = 'A';
|
||||
foreach($data['header'] as $header){
|
||||
$objPHPExcel->getActiveSheet()->getStyle($column.'3')->getFont()->setBold(true);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue($column.'3', $header);
|
||||
$column++;
|
||||
}
|
||||
|
||||
|
||||
$column = 'A';
|
||||
$mem_ligne=4;
|
||||
$mem_x=0;
|
||||
foreach($data['data'] as $row){
|
||||
|
||||
|
||||
|
||||
if($mem_x>=$mem_premiere_ligne){
|
||||
|
||||
foreach($row as $col){
|
||||
|
||||
if (isset($col['format'])){
|
||||
|
||||
switch ($col['format']) {
|
||||
case 'argent':
|
||||
$objPHPExcel->getActiveSheet()->getStyle($column.$mem_ligne)->getNumberFormat()->setFormatCode('# ##0.00');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (isset($col['bold']) && $col['bold'] == true) {
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getStyle($column.$mem_ligne)
|
||||
->getFont()
|
||||
->setBold(true);
|
||||
}
|
||||
|
||||
|
||||
if (isset($col['color'])){
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle($column.$mem_ligne)->applyFromArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('rgb' => $col['color'])
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
$col['data'] = preg_replace('/<br\s*\/?>/i', "\n", $col['data']);
|
||||
// activer retour à la ligne dans la cellule
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getStyle($column.$mem_ligne)
|
||||
->getAlignment()
|
||||
->setWrapText(true);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue($column.$mem_ligne, $col['data']);
|
||||
|
||||
$column++;
|
||||
}
|
||||
}
|
||||
$column = 'A';
|
||||
$mem_ligne++;
|
||||
$mem_x++;
|
||||
}
|
||||
|
||||
|
||||
// Instantiate a Writer to create an OfficeOpenXML Excel .xlsx file
|
||||
//$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
// Write the Excel file to filename some_excel_file.xlsx in the current directory
|
||||
|
||||
$mem_file_location= $_SERVER['DOCUMENT_ROOT'].'/data/'. $memexcfichier. '.xls';
|
||||
$objWriter->save( $mem_file_location);
|
||||
$mem_file= $memexcfichier. '.xls';
|
||||
$memurl="?fl=".$mem_file_location."&f=".$mem_file;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
17
application/models/Form_fields_model.php
Normal file
17
application/models/Form_fields_model.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Form_fields_model extends CI_Model
|
||||
{
|
||||
protected $table = 'form_fields';
|
||||
|
||||
public function get_active_fields($form_key)
|
||||
{
|
||||
return $this->db
|
||||
->where('form_key', $form_key)
|
||||
->where('active', 1)
|
||||
->order_by('field_order', 'ASC')
|
||||
->get($this->table)
|
||||
->result_array();
|
||||
}
|
||||
}
|
||||
960
application/models/Fournisseurs_model.php
Normal file
960
application/models/Fournisseurs_model.php
Normal file
@ -0,0 +1,960 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Fournisseurs_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->helper('date');
|
||||
$this->load->model('Projets_model');
|
||||
|
||||
}
|
||||
public function mod_listprojetsproduit($record=0,$listactif) {
|
||||
|
||||
|
||||
// $recordCount = $this->Clients_model->getRecordCount();
|
||||
//$client_list=$this->Config_model->conf_getprojetsclients($record);
|
||||
$client_list=$this->Projets_model->mod_getRecords_produits_fournisseur($record,$listactif);
|
||||
// creation du tableau
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
// $mem_link_new='<button id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
$mem_link_new='';
|
||||
//$mem_link_projet=anchor('projets/createRecord/0/'.$record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-briefcase" ');
|
||||
$mem_link_projet='';
|
||||
$header=array(
|
||||
'',
|
||||
'Numero',
|
||||
'Nom',
|
||||
'Client',
|
||||
'Date de début',
|
||||
'' );
|
||||
// prépare les donnés du tableau
|
||||
$nbitem=0;
|
||||
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit=anchor('projets/form/'.$row['proj_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit" ');
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left', 'width' => '2');
|
||||
$data_row[] = array('data'=>$row['proj_numero'], 'align' => 'left', 'width' => '2');
|
||||
$data_row[] = array('data'=>$row['des_nom_fr'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_compagnie_client'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['proj_date_debut'], 'align' => 'left');
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th style="background-color: #003333">',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
|
||||
if(!isset($tabular_data))
|
||||
$tabular_data=array();
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
|
||||
return $tableau_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_loadData_list($record=0,$filtre1='',$filtre2='',$filtre3='', $listactif=1, $model='',$excel=0,$filtre4='') {
|
||||
|
||||
if ($excel=="null")
|
||||
$excel=0;
|
||||
$filtre1=($filtre1=='null'?'':$filtre1);
|
||||
$filtre2=($filtre2=='null'?'':$filtre2);
|
||||
$filtre4=($filtre4=='null'?'':$filtre4);
|
||||
|
||||
if ($model == "liste")
|
||||
$recordPerPage = 10;
|
||||
else
|
||||
$recordPerPage = 5;
|
||||
$config["cur_page"] = $record;
|
||||
if($record != 0){
|
||||
$record = ($record-1) * $recordPerPage;
|
||||
}
|
||||
|
||||
$recordCount2 = $this->Fournisseurs_model->mod_getRecordCount();
|
||||
|
||||
$recordCount = $this->Fournisseurs_model->mod_getRecordCountfilter($filtre1,$filtre2,$filtre3,$filtre4);
|
||||
$client_list = $this->Fournisseurs_model->mod_getRecords($record,$recordPerPage,$filtre1,$filtre2,$filtre3,"fr",$filtre4);
|
||||
$config['base_url'] = base_url().'index.php/Fournisseurs/loadData_list';
|
||||
$config['use_page_numbers'] = TRUE;
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Previous';
|
||||
$config['total_rows'] = $recordCount;
|
||||
$config['per_page'] = $recordPerPage;
|
||||
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["uri_segment"] = 2;
|
||||
$config["num_links"] = 2;
|
||||
$config['full_tag_open'] = '<div ><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></div><!--pagination-->';
|
||||
|
||||
$config['first_link'] = '« First';
|
||||
$config['first_tag_open'] = '<li class="prev page">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
|
||||
$config['last_link'] = 'Last »';
|
||||
$config['last_tag_open'] = '<li class="next page">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
|
||||
$config['next_link'] = 'Next →';
|
||||
$config['next_tag_open'] = '<li class="next page">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
|
||||
$config['prev_link'] = '← Previous';
|
||||
$config['prev_tag_open'] = '<li class="prev page">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
|
||||
$config['cur_tag_open'] = '<li class="active"><a href="">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
|
||||
$config['num_tag_open'] = '<li class="page">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$this->pagination->initialize($config);
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
$data['recordCount']=$recordCount2;
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
$mem_excel='<label for="excel"><a id="excel" data-id="1" class="btn btn-primary btn-circle fa fa-cloud-download"> </a></label>';
|
||||
|
||||
if ($model == 'projets'){ $mem_link_new='';
|
||||
}else{
|
||||
$mem_link_new=anchor('fournisseurs/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||||
|
||||
}
|
||||
$data['model']=$model;
|
||||
$header=array($mem_link_new,
|
||||
'Compagnie',
|
||||
'Ville',
|
||||
'Type',
|
||||
|
||||
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Téléphone ');
|
||||
|
||||
$nbitem=0;
|
||||
if ($excel!=0){
|
||||
$mem_excel_output['header']=array('Client','Date de facturation',
|
||||
'No. de facture',
|
||||
'No. de projet',
|
||||
'Total avant tx',
|
||||
'TPS',
|
||||
'TVQ',
|
||||
'TVH',
|
||||
'OPC',
|
||||
'Total',
|
||||
'Dépôt/paiement',
|
||||
'À recevoir','Nb jours','OPC avant');
|
||||
$mem_excel_output['headerwidth']=array(45,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
|
||||
}
|
||||
// filter
|
||||
global $mem_data;
|
||||
$data_row = array();
|
||||
$data_row[]=array('data'=>'Filtre', 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ='filtre_fournisseurs_1';
|
||||
// $mem_value=trim($filtre1);
|
||||
// $this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_1');
|
||||
|
||||
// $mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
// $data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='filtre_fournisseurs_2';
|
||||
$mem_value=trim($filtre2);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_2');
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='filtre_fournisseurs_1';
|
||||
$mem_value=trim($filtre1);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_1');
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
if ($model == "liste"){
|
||||
$mem_champ='filtre_fournisseurs_3';
|
||||
$mem_value=$filtre3;
|
||||
$mem_data['select'][$mem_champ]['choix']=$this->Config_model->conf_getGenresFournisseur('fr',true);
|
||||
// value multipli select
|
||||
//$mem_value = explode(',', $mem_value);
|
||||
$mem_filtre=form_dropdown($mem_champ,$mem_data['select'][$mem_champ]['choix'],$mem_value,'class="filtre_fournisseurs_3"');
|
||||
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
}
|
||||
$mem_champ='filtre_fournisseurs_4';
|
||||
$mem_value=trim($filtre4);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_4');
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
|
||||
// echo form_dropdown($mem_champ,$select[$mem_champ]['choix'],$select[$mem_champ]['value']);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
// prépare les donnés du tableau
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
|
||||
|
||||
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit="";
|
||||
if ($model == "liste"){
|
||||
$mem_link_edit=anchor('fournisseurs/form/'.$row['com_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit" ');
|
||||
|
||||
}else{
|
||||
$databtn = array(
|
||||
'name' => 'button_fou',
|
||||
'id' => 'button_fou',
|
||||
'value' => $row['com_id'],
|
||||
'class' => 'btn btn-success btn-circle glyphicon glyphicon-plus-sign'
|
||||
);
|
||||
$mem_link_edit = form_button($databtn);
|
||||
|
||||
$mem_link_delete = '';
|
||||
|
||||
}
|
||||
|
||||
//excel
|
||||
|
||||
if ($excel!=0){
|
||||
$data_row_excel = array();
|
||||
$data_row_excel[] = array('data'=>$row['com_compagnie'], 'align' => 'left');
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['com_num_client'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_compagnie'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_ville'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['list_type'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['rep_prenom']." ".$row['rep_nom'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_telephone'], 'align' => 'left');
|
||||
$tabular_data[] = $data_row;
|
||||
// print_r( $row);
|
||||
|
||||
$mem_projets=$this->mod_listprojetsproduit($row['com_id'],$listactif);
|
||||
|
||||
$client_list=$this->Projets_model->mod_getRecords_produits_fournisseur($record,$listactif);
|
||||
|
||||
if ($excel!=0){
|
||||
$mem_excel_output['header']=array(
|
||||
'No.projet',
|
||||
'Qté',
|
||||
'Nom',
|
||||
'Client',
|
||||
'Étape',
|
||||
'Date debut',
|
||||
'Date fin',
|
||||
'Destination',
|
||||
'contrat');
|
||||
$mem_excel_output['headerwidth']=array(45,10,25,25,15,25,25,25,25,15,15,15,15,15,15,15);
|
||||
|
||||
|
||||
|
||||
$client_list=$this->Projets_model->mod_getRecords_produits_fournisseur($row['com_id'],$listactif);
|
||||
|
||||
|
||||
$type=array();
|
||||
$type=$this->Config_model->conf_getGenresProjet('a','fr');
|
||||
|
||||
foreach($client_list as $row){
|
||||
$mem_type=$type[$row['det_etape']];
|
||||
$data_row_excel = array();
|
||||
$data_row_excel[] = array('data'=>$row['proj_numero'], 'align' => 'right');
|
||||
$data_row_excel[] = array('data'=>$row['det_qte'], 'align' => 'right');
|
||||
$data_row_excel[] = array('data'=>$row['des_nom_fr'], 'align' => 'right');
|
||||
|
||||
$data_row_excel[] = array('data'=>$row['com_compagnie'], 'align' => 'right');
|
||||
$data_row_excel[] = array('data'=>$mem_type, 'align' => 'right');
|
||||
$data_row_excel[] = array('data'=>$row['det_depart'], 'align' => 'right');
|
||||
$data_row_excel[] = array('data'=>$row['det_retour'], 'align' => 'right');
|
||||
$data_row_excel[] = array('data'=>$row['det_destination'], 'align' => 'right');
|
||||
$data_row_excel[] = array('data'=>$row['det_contrat'], 'align' => 'right');
|
||||
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// $mem_projets=$this->mod_listprojetsproduit(74);
|
||||
|
||||
// $projets=$this->Config_model->conf_getprojetsclients($row['com_id']);
|
||||
|
||||
// $mem_projets="";
|
||||
// $mem_projets_client='';
|
||||
// foreach($projets as $value){
|
||||
// $mem_link_edit=anchor('projets/form/'.$value['proj_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit statut_'.$value['proj_etape'].'"' );
|
||||
// $mem_projets=$mem_projets. $mem_link_edit;
|
||||
// $mem_projets=$mem_projets.' '.$value['proj_numero'].' '.$value['proj_nom'].'<br>';
|
||||
// $mem_projets_client=' Création de projet <br>';
|
||||
// }
|
||||
|
||||
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=>'' );
|
||||
$data_row[] = array('data'=>$mem_projets,'colspan' => 6 );
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead>',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
$this->table->set_heading($header);
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
if ($excel!=0){
|
||||
// $mem_excel_output['data']=$tabular_data;
|
||||
|
||||
|
||||
$data['fichier']="fournisseurs.xls";
|
||||
$mem_excel_output['fichier']="fournisseurs";
|
||||
// $mem_excel_output['titre']="depart du ".$debut.' @ '.$fin;
|
||||
$mem_excel_output['titre']="rapport en date du ".date("Y-m-d H:i");;
|
||||
$mem_parameter=array('premiere_ligne'=>0);
|
||||
|
||||
$this->Config_model->excel($mem_excel_output,$mem_parameter);
|
||||
|
||||
}
|
||||
$data['list'] = $tableau_sortie;
|
||||
|
||||
return $data ;
|
||||
}
|
||||
|
||||
public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $langue = 'fr', $filtre4 = "")
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,usa_usagers.usa_prenom as rep_prenom,usa_usagers.usa_nom as rep_nom,config_pays.pay_nom_' . $langue . ' as com_pay,config_provinces.pro_nom_' . $langue . ' as com_pro ');
|
||||
$this->db->from('fou_compte');
|
||||
$this->db->join('config_pays', 'fou_compte.com_pay_id=config_pays.pay_id', 'left');
|
||||
$this->db->join('config_provinces', 'fou_compte.com_pro_id=config_provinces.pro_id', 'left');
|
||||
$this->db->join('usa_usagers', 'usa_usagers.usa_id=fou_compte.com_representant_id', 'left');
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("com_ville LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||||
if ($filtre3 != 0)
|
||||
$this->db->where("FIND_IN_SET (" . $filtre3 . ",com_ref_type)");
|
||||
if ($filtre4 != "")
|
||||
$this->db->where("com_telephone LIKE '%$filtre4%'");
|
||||
$this->db->limit($rowperpage, $rowno);
|
||||
$this->db->order_by('com_compagnie');
|
||||
$query = $this->db->get();
|
||||
// echo '<pre>'.$this->db->last_query().'</pre>';
|
||||
$four = $query->result_array();
|
||||
// ajouter la liste des type
|
||||
for ($x = 0; $x < count($four); $x++) {
|
||||
|
||||
$replist = explode(",", $four[$x]['com_ref_type']);
|
||||
$mem_type = "";
|
||||
foreach ($replist as $key => $value) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('fou_genres');
|
||||
$this->db->where('gen_id', $value);
|
||||
$query2 = $this->db->get();
|
||||
$row = $query2->row_array();
|
||||
|
||||
if ($row) { // si un résultat existe
|
||||
$mem_type .= $row['gen_nom_fr'] . '<br>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$mem_type = substr($mem_type, 0, -4);
|
||||
$four[$x]['list_type'] = $mem_type;
|
||||
}
|
||||
|
||||
return $four;
|
||||
}
|
||||
|
||||
public function mod_getRecords_contacts($id, $langue = 'fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,fou_contacts_roles.rol_nom as role');
|
||||
$this->db->from('fou_contacts');
|
||||
$this->db->join('fou_contacts_roles', 'fou_contacts_roles.rol_id=fou_contacts.con_role_id', 'left');
|
||||
$this->db->where('fou_contacts.ref_id', $id);
|
||||
$this->db->where('fou_contacts.con_actif', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function mod_getRecord($id, $langue = 'fr')
|
||||
{
|
||||
// trouve un enregiestrement
|
||||
$this->db->select('*,config_pays.pay_nom_' . $langue . ' as com_pay,config_provinces.pro_nom_' . $langue . ' as com_pro ');
|
||||
$this->db->from('fou_compte');
|
||||
$this->db->join('config_pays', 'fou_compte.com_pay_id=config_pays.pay_id', 'left');
|
||||
$this->db->join('config_provinces', 'fou_compte.com_pro_id=config_provinces.pro_id', 'left');
|
||||
$this->db->where('com_id=' . $id);
|
||||
|
||||
$this->db->limit(1);
|
||||
$this->db->order_by('com_num_client desc');
|
||||
$query = $this->db->get();
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
public function mod_saveRecordbd($id, $data, $pref)
|
||||
{
|
||||
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data = array();
|
||||
// ajoute les checkbox
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif'] = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
switch ($key) {
|
||||
case 'com_ref_type':
|
||||
$mem_value = '';
|
||||
foreach ($data['com_ref_type'] as $key2 => $value2) {
|
||||
$mem_value = $mem_value . $value2 . ',';
|
||||
|
||||
}
|
||||
$mem_value = rtrim($mem_value, ",");
|
||||
$mem_data['com_ref_type'] = $mem_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_modif'] = date("Y-m-d H:i:s");
|
||||
$mem_where = "com_id =" . $id;
|
||||
|
||||
$str = $this->db->update('fou_compte', $mem_data, $mem_where);
|
||||
$ok = true;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
public function mod_createRecordbd($data, $pref)
|
||||
{
|
||||
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif'] = 0;
|
||||
// creation de la chaine de save
|
||||
|
||||
$mem_data = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
|
||||
switch ($key) {
|
||||
case 'com_ref_type':
|
||||
$mem_value = '';
|
||||
foreach ($data['com_ref_type'] as $key2 => $value2) {
|
||||
$mem_value = $mem_value . $value2 . ',';
|
||||
|
||||
}
|
||||
$mem_value = rtrim($mem_value, ",");
|
||||
$mem_data['com_ref_type'] = $mem_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['com_actif'] = 1;
|
||||
$str = $this->db->insert('fou_compte', $mem_data);
|
||||
|
||||
$ok = true;
|
||||
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
public function mod_editRecordbdcontact($data,$pref,$ref_id)
|
||||
{
|
||||
$mem_data=array();
|
||||
foreach($data as $key => $value )
|
||||
{
|
||||
if (substr($key,0,strlen($pref))==$pref){
|
||||
$mem_data[$key]=$value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$mem_where = "con_id =".$ref_id;
|
||||
|
||||
$str = $this->db->update('fou_contacts', $mem_data, $mem_where);
|
||||
|
||||
$ok=true;
|
||||
|
||||
return ;
|
||||
}
|
||||
public function mod_createRecordbdcontact($data, $pref, $ref_id)
|
||||
{
|
||||
|
||||
|
||||
$mem_data = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['ref_id'] = $ref_id;
|
||||
$mem_data['con_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['con_actif'] = 1;
|
||||
|
||||
$str = $this->db->insert('fou_contacts', $mem_data);
|
||||
|
||||
$ok = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function mod_deleteRecordbdcontact($id)
|
||||
{
|
||||
|
||||
$mem_data['con_actif'] = 0;
|
||||
$mem_where = "con_id =" . $id;
|
||||
|
||||
$str = $this->db->update('fou_contacts', $mem_data, $mem_where);
|
||||
|
||||
|
||||
$ok = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function mod_getRecordCount()
|
||||
{
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('fou_compte');
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "", $filtre4 = "")
|
||||
{
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('fou_compte');
|
||||
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("com_ville LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||||
if ($filtre3 != 0)
|
||||
$this->db->where("FIND_IN_SET (" . $filtre3 . ",com_ref_type)");
|
||||
if ($filtre4 != "")
|
||||
$this->db->where("com_telephone LIKE '%$filtre4%'");
|
||||
|
||||
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_listcontact($record = 0)
|
||||
{
|
||||
|
||||
|
||||
// $recordCount = $this->Fournisseurs_model->getRecordCount();
|
||||
|
||||
$client_list = $this->mod_getRecords_contacts($record);
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
$mem_link_new = '<button value="new" name="button" id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
|
||||
|
||||
$header=array('','Prénom',
|
||||
'Nom',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Téléphone bureau',
|
||||
'Ext',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Cellulaire',
|
||||
'Courriel',
|
||||
'Role','');
|
||||
// prépare les donnés du tableau
|
||||
$nbitem = 0;
|
||||
foreach ($client_list as $row) {
|
||||
$nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit = anchor('fournisseurs/deletecontact/' . $row['con_id'] . '/' . $record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-trash" ');
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$mem_link_save='<button value="'.$row['con_id'].'" name="button" id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon"></button> ';
|
||||
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_prenom'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_nom'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_telephone'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_ext'],'width'=>'5', 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_telephone2'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_courriel'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['role'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_prenom'],'name' => $row['con_id'].'/con_prenom' ,'size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_nom'],'name' => $row['con_id'].'/con_nom' ,'size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_telephone'],'name' => $row['con_id'].'/con_telephone' ,'size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_ext'],'name' => $row['con_id'].'/con_ext' ,'size'=>5)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_telephone2'],'name' => $row['con_id'].'/con_telephone2' ,'size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_courriel'],'name' => $row['con_id'].'/con_courriel' ,'size'=>15)));
|
||||
$mem_choix = $this->Config_model->conf_getRolesContactsFournisseur();
|
||||
$mem_roles=form_dropdown($row['con_id'].'/con_role_id',$mem_choix,$row['con_role_id']) ;
|
||||
|
||||
|
||||
$data_row[] = array('data'=>$mem_roles , 'align' => 'left');
|
||||
$data_row[] = array('data'=>$mem_link_save , 'align' => 'left');
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_new);
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_prenom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_nom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_telephone','size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_ext','size'=>5)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_telephone2','size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_courriel','size'=>15)));
|
||||
|
||||
$mem_choix = $this->Config_model->conf_getRolesContactsFournisseur();
|
||||
$mem_roles = form_dropdown('0/con_role_id', $mem_choix);
|
||||
|
||||
|
||||
$data_row[] = array('data' => $mem_roles, 'align' => 'left');
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie = $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
return $tableau_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_getforminfo($id)
|
||||
{
|
||||
global $mem_data, $validation;
|
||||
|
||||
$this->load->model('Config_model');
|
||||
$this->load->model('FxForm_model');
|
||||
// vas chercher les info de la fiche
|
||||
|
||||
if ($id != 0)
|
||||
$info = $this->mod_getRecord($id);
|
||||
|
||||
// prepare info pour chaque champs utilisé
|
||||
// input
|
||||
$mem_data['mem_id'] = $id;
|
||||
$mem_champ = 'com_compagnie';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Compagnie', '<i class="icon-prepend fa fa- fa-building"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
//$mem_champ = 'com_num_client';
|
||||
//$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
// $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Numéro Fournisseur', '');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_ref_type';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresFournisseur();
|
||||
// value multipli select
|
||||
$mem_value = explode(',', $mem_value);
|
||||
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Type';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_langue';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getLangues();
|
||||
|
||||
|
||||
// value multipli select
|
||||
$mem_value = explode(',', $mem_value);
|
||||
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Langue';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ = 'com_representant_id';
|
||||
// $mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
// $mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getRepresentantsClient();
|
||||
// $mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
// $mem_data['label'][$mem_champ] = 'Représentant';
|
||||
// $mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'com_actif';
|
||||
$mem_value = ($id == 0 ? true : ($info->$mem_champ == 1 ? true : false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'Actif';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_nom';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Nom', '<i class="icon-prepend fa fa- fa-user"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_prenom';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Prénom', '<i class="icon-prepend fa fa- fa-user"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'com_courriel';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'E-Mail', '<i class="icon-prepend fa fa- fa-envelope"></i>');
|
||||
|
||||
$mem_rule = "
|
||||
" . $mem_champ . " : {
|
||||
required : true,
|
||||
email : true
|
||||
}";
|
||||
$mem_message = "
|
||||
" . $mem_champ . " : {
|
||||
required : 'Champ obligatoire',
|
||||
email : ' <strong>Le E-Mail est pas valide</strong>'
|
||||
}";
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ, $mem_rule, $mem_message);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_telephone';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Téléphone', '<i class="icon-prepend fa fa- fa-phone"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_telephone_ext';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Extension', '<i class="icon-prepend fa fa- fa-phone"></i>');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_ville';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Ville', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_pro_id';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getProvinces();
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Province';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_pay_id';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getPays();
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Pays';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_codepostal';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Code postal', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_adresse';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Adresse', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_notes';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Notes', '', 'Notes');
|
||||
|
||||
$mem_data['validation'] = $this->FxForm_model->fxValidation($validation['rule'], $validation['message']);
|
||||
|
||||
|
||||
return $mem_data;
|
||||
}
|
||||
public function mod_selectcontact($fournisseur_id,$langue='fr',$choix_vide=true)
|
||||
{
|
||||
|
||||
|
||||
$contacts=$this->Fournisseurs_model->mod_getRecords_contacts($fournisseur_id);
|
||||
// list la bb client
|
||||
|
||||
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($contacts as $pro ){
|
||||
$mem_sortie[$pro['con_id']]=$pro['con_prenom']." ".$pro['con_nom']." (".$pro['rol_nom'].")";
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
860
application/models/Fournisseursprojets_model.php
Normal file
860
application/models/Fournisseursprojets_model.php
Normal file
@ -0,0 +1,860 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Fournisseursprojets_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->helper('date');
|
||||
$this->load->model('Projets_model');
|
||||
|
||||
}
|
||||
public function mod_listprojetsproduit($record=0,$listactif) {
|
||||
|
||||
|
||||
|
||||
// $recordCount = $this->Clients_model->getRecordCount();
|
||||
//$client_list=$this->Config_model->conf_getprojetsclients($record);
|
||||
$client_list=$this->Projets_model->mod_getRecords_produits_fournisseur($record,$listactif);
|
||||
// creation du tableau
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
// $mem_link_new='<button id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
$mem_link_new='';
|
||||
//$mem_link_projet=anchor('projets/createRecord/0/'.$record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-briefcase" ');
|
||||
$mem_link_projet='';
|
||||
$header=array(
|
||||
'',
|
||||
'Numero',
|
||||
'Nom',
|
||||
'Client',
|
||||
'Date de début',
|
||||
'' );
|
||||
// prépare les donnés du tableau
|
||||
$nbitem=0;
|
||||
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit=anchor('projets/form/'.$row['proj_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit" ');
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left', 'width' => '2');
|
||||
$data_row[] = array('data'=>$row['proj_numero'], 'align' => 'left', 'width' => '2');
|
||||
$data_row[] = array('data'=>$row['des_nom_fr'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_compagnie_client'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['proj_date_debut'], 'align' => 'left');
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th style="background-color: #003333">',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
|
||||
if(!isset($tabular_data))
|
||||
$tabular_data=array();
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
|
||||
return $tableau_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_loadData_list($record=0,$filtre1='',$filtre2='',$filtre3='', $listactif, $model='') {
|
||||
|
||||
$filtre1=($filtre1=='null'?'':$filtre1);
|
||||
$filtre2=($filtre2=='null'?'':$filtre2);
|
||||
if ($model == "liste")
|
||||
$recordPerPage = 10;
|
||||
else
|
||||
$recordPerPage = 5;
|
||||
$config["cur_page"] = $record;
|
||||
if($record != 0){
|
||||
$record = ($record-1) * $recordPerPage;
|
||||
}
|
||||
|
||||
$recordCount2 = $this->Fournisseursprojets_model->mod_getRecordCount();
|
||||
|
||||
$recordCount = $this->Fournisseursprojets_model->mod_getRecordCountfilter($filtre1,$filtre2,$filtre3);
|
||||
$client_list = $this->Fournisseursprojets_model->mod_getRecords($record,$recordPerPage,$filtre1,$filtre2,$filtre3);
|
||||
$config['base_url'] = base_url().'index.php/Fournisseursprojets/loadData_list';
|
||||
$config['use_page_numbers'] = TRUE;
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Previous';
|
||||
$config['total_rows'] = $recordCount;
|
||||
$config['per_page'] = $recordPerPage;
|
||||
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["uri_segment"] = 2;
|
||||
$config["num_links"] = 2;
|
||||
$config['full_tag_open'] = '<div ><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></div><!--pagination-->';
|
||||
|
||||
$config['first_link'] = '« First';
|
||||
$config['first_tag_open'] = '<li class="prev page">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
|
||||
$config['last_link'] = 'Last »';
|
||||
$config['last_tag_open'] = '<li class="next page">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
|
||||
$config['next_link'] = 'Next →';
|
||||
$config['next_tag_open'] = '<li class="next page">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
|
||||
$config['prev_link'] = '← Previous';
|
||||
$config['prev_tag_open'] = '<li class="prev page">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
|
||||
$config['cur_tag_open'] = '<li class="active"><a href="">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
|
||||
$config['num_tag_open'] = '<li class="page">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$this->pagination->initialize($config);
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
$data['recordCount']=$recordCount2;
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
|
||||
if ($model == 'projets'){ $mem_link_new='';
|
||||
}else{
|
||||
$mem_link_new=anchor('fournisseursprojets/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||||
|
||||
}
|
||||
$data['model']=$model;
|
||||
$header=array($mem_link_new,
|
||||
'Compagnie',
|
||||
'Ville',
|
||||
'Type',
|
||||
|
||||
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Téléphone ');
|
||||
|
||||
$nbitem=0;
|
||||
|
||||
|
||||
// filter
|
||||
global $mem_data;
|
||||
$data_row = array();
|
||||
$data_row[]=array('data'=>'Filtre', 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ='filtre_fournisseurs_1';
|
||||
// $mem_value=trim($filtre1);
|
||||
// $this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_1');
|
||||
|
||||
// $mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
// $data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='filtre_fournisseurs_2';
|
||||
$mem_value=trim($filtre2);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_2');
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$data_row[]=array('data'=>"", 'align' => 'left');
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
if ($model == "liste"){
|
||||
$mem_champ='filtre_fournisseurs_3';
|
||||
$mem_value=$filtre3;
|
||||
$mem_data['select'][$mem_champ]['choix']=$this->Config_model->conf_getGenresFournisseur('fr',true);
|
||||
// value multipli select
|
||||
//$mem_value = explode(',', $mem_value);
|
||||
$mem_filtre=form_dropdown($mem_champ,$mem_data['select'][$mem_champ]['choix'],$mem_value,'class="filtre_fournisseurs_3"');
|
||||
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
}
|
||||
// echo form_dropdown($mem_champ,$select[$mem_champ]['choix'],$select[$mem_champ]['value']);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
// prépare les donnés du tableau
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
|
||||
|
||||
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit="";
|
||||
if ($model == "liste"){
|
||||
$mem_link_edit=anchor('fournisseursprojets/form/'.$row['com_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit" ');
|
||||
|
||||
}else{
|
||||
$databtn = array(
|
||||
'name' => 'button_fou',
|
||||
'id' => 'button_fou',
|
||||
'value' => $row['com_id'],
|
||||
'class' => 'btn btn-success btn-circle glyphicon glyphicon-plus-sign'
|
||||
);
|
||||
$mem_link_edit = form_button($databtn);
|
||||
|
||||
$mem_link_delete = '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['com_num_client'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_compagnie'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_ville'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['list_type'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['rep_prenom']." ".$row['rep_nom'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_telephone'], 'align' => 'left');
|
||||
$tabular_data[] = $data_row;
|
||||
// print_r( $row);
|
||||
|
||||
$mem_projets=$this->mod_listprojetsproduit($row['com_id'],$listactif);
|
||||
// $mem_projets=$this->mod_listprojetsproduit(74);
|
||||
|
||||
// $projets=$this->Config_model->conf_getprojetsclients($row['com_id']);
|
||||
|
||||
// $mem_projets="";
|
||||
// $mem_projets_client='';
|
||||
// foreach($projets as $value){
|
||||
// $mem_link_edit=anchor('projets/form/'.$value['proj_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit statut_'.$value['proj_etape'].'"' );
|
||||
// $mem_projets=$mem_projets. $mem_link_edit;
|
||||
// $mem_projets=$mem_projets.' '.$value['proj_numero'].' '.$value['proj_nom'].'<br>';
|
||||
// $mem_projets_client=' Création de projet <br>';
|
||||
// }
|
||||
|
||||
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=>'' );
|
||||
$data_row[] = array('data'=>$mem_projets,'colspan' => 6 );
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead>',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
$this->table->set_heading($header);
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
|
||||
$data['list'] = $tableau_sortie;
|
||||
|
||||
return $data ;
|
||||
}
|
||||
|
||||
public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $langue = 'fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,usa_usagers.usa_prenom as rep_prenom,usa_usagers.usa_nom as rep_nom,config_pays.pay_nom_' . $langue . ' as com_pay,config_provinces.pro_nom_' . $langue . ' as com_pro ');
|
||||
$this->db->from('fou_compte');
|
||||
$this->db->join('config_pays', 'fou_compte.com_pay_id=config_pays.pay_id', 'left');
|
||||
$this->db->join('config_provinces', 'fou_compte.com_pro_id=config_provinces.pro_id', 'left');
|
||||
$this->db->join('usa_usagers', 'usa_usagers.usa_id=fou_compte.com_representant_id', 'left');
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("com_num_client LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||||
if ($filtre3 != 0)
|
||||
$this->db->where("FIND_IN_SET (" . $filtre3 . ",com_ref_type)");
|
||||
|
||||
$this->db->limit($rowperpage, $rowno);
|
||||
$this->db->order_by('com_compagnie');
|
||||
$query = $this->db->get();
|
||||
$four = $query->result_array();
|
||||
// ajouter la liste des type
|
||||
for ($x = 0; $x < count($four); $x++) {
|
||||
|
||||
$replist = explode(",", $four[$x]['com_ref_type']);
|
||||
$mem_type = "";
|
||||
foreach ($replist as $key => $value) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('fou_genres');
|
||||
$this->db->where('gen_id', $value);
|
||||
$query2 = $this->db->get();
|
||||
$row = $query2->row_array();
|
||||
|
||||
$mem_type = $mem_type . $row['gen_nom_fr'] . '<br>';
|
||||
|
||||
}
|
||||
|
||||
$mem_type = substr($mem_type, 0, -4);
|
||||
$four[$x]['list_type'] = $mem_type;
|
||||
}
|
||||
|
||||
return $four;
|
||||
}
|
||||
|
||||
public function mod_getRecords_contacts($id, $langue = 'fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,fou_contacts_roles.rol_nom as role');
|
||||
$this->db->from('fou_contacts');
|
||||
$this->db->join('fou_contacts_roles', 'fou_contacts_roles.rol_id=fou_contacts.con_role_id', 'left');
|
||||
$this->db->where('fou_contacts.ref_id', $id);
|
||||
$this->db->where('fou_contacts.con_actif', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function mod_getRecord($id, $langue = 'fr')
|
||||
{
|
||||
// trouve un enregiestrement
|
||||
$this->db->select('*,config_pays.pay_nom_' . $langue . ' as com_pay,config_provinces.pro_nom_' . $langue . ' as com_pro ');
|
||||
$this->db->from('fou_compte');
|
||||
$this->db->join('config_pays', 'fou_compte.com_pay_id=config_pays.pay_id', 'left');
|
||||
$this->db->join('config_provinces', 'fou_compte.com_pro_id=config_provinces.pro_id', 'left');
|
||||
$this->db->where('com_id=' . $id);
|
||||
|
||||
$this->db->limit(1);
|
||||
$this->db->order_by('com_num_client desc');
|
||||
$query = $this->db->get();
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
public function mod_saveRecordbd($id, $data, $pref)
|
||||
{
|
||||
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data = array();
|
||||
// ajoute les checkbox
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif'] = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
switch ($key) {
|
||||
case 'com_ref_type':
|
||||
$mem_value = '';
|
||||
foreach ($data['com_ref_type'] as $key2 => $value2) {
|
||||
$mem_value = $mem_value . $value2 . ',';
|
||||
|
||||
}
|
||||
$mem_value = rtrim($mem_value, ",");
|
||||
$mem_data['com_ref_type'] = $mem_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_modif'] = date("Y-m-d H:i:s");
|
||||
$mem_where = "com_id =" . $id;
|
||||
|
||||
$str = $this->db->update('fou_compte', $mem_data, $mem_where);
|
||||
$ok = true;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
public function mod_createRecordbd($data, $pref)
|
||||
{
|
||||
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif'] = 0;
|
||||
// creation de la chaine de save
|
||||
|
||||
$mem_data = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
|
||||
switch ($key) {
|
||||
case 'com_ref_type':
|
||||
$mem_value = '';
|
||||
foreach ($data['com_ref_type'] as $key2 => $value2) {
|
||||
$mem_value = $mem_value . $value2 . ',';
|
||||
|
||||
}
|
||||
$mem_value = rtrim($mem_value, ",");
|
||||
$mem_data['com_ref_type'] = $mem_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['com_actif'] = 1;
|
||||
$str = $this->db->insert('fou_compte', $mem_data);
|
||||
|
||||
$ok = true;
|
||||
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
public function mod_editRecordbdcontact($data,$pref,$ref_id)
|
||||
{
|
||||
$mem_data=array();
|
||||
foreach($data as $key => $value )
|
||||
{
|
||||
if (substr($key,0,strlen($pref))==$pref){
|
||||
$mem_data[$key]=$value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$mem_where = "con_id =".$ref_id;
|
||||
|
||||
$str = $this->db->update('fou_contacts', $mem_data, $mem_where);
|
||||
|
||||
$ok=true;
|
||||
|
||||
return ;
|
||||
}
|
||||
public function mod_createRecordbdcontact($data, $pref, $ref_id)
|
||||
{
|
||||
|
||||
|
||||
$mem_data = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['ref_id'] = $ref_id;
|
||||
$mem_data['con_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['con_actif'] = 1;
|
||||
|
||||
$str = $this->db->insert('fou_contacts', $mem_data);
|
||||
|
||||
$ok = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function mod_deleteRecordbdcontact($id)
|
||||
{
|
||||
|
||||
$mem_data['con_actif'] = 0;
|
||||
$mem_where = "con_id =" . $id;
|
||||
|
||||
$str = $this->db->update('fou_contacts', $mem_data, $mem_where);
|
||||
|
||||
|
||||
$ok = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function mod_getRecordCount()
|
||||
{
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('fou_compte');
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "")
|
||||
{
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('fou_compte');
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("com_num_client LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||||
if ($filtre3 != 0)
|
||||
$this->db->where("FIND_IN_SET (" . $filtre3 . ",com_ref_type)");
|
||||
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_listcontact($record = 0)
|
||||
{
|
||||
|
||||
|
||||
// $recordCount = $this->Fournisseurs_model->getRecordCount();
|
||||
|
||||
$client_list = $this->mod_getRecords_contacts($record);
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
$mem_link_new = '<button value="new" name="button" id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
|
||||
|
||||
$header=array('','Prénom',
|
||||
'Nom',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Téléphone bureau',
|
||||
'Ext',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Cellulaire',
|
||||
'Courriel',
|
||||
'Role','');
|
||||
// prépare les donnés du tableau
|
||||
$nbitem = 0;
|
||||
foreach ($client_list as $row) {
|
||||
$nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit = anchor('fournisseursprojets/deletecontact/' . $row['con_id'] . '/' . $record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-trash" ');
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$mem_link_save='<button value="'.$row['con_id'].'" name="button" id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon"></button> ';
|
||||
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_prenom'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_nom'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_telephone'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_ext'],'width'=>'5', 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_telephone2'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['con_courriel'], 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['role'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_prenom'],'name' => $row['con_id'].'/con_prenom' ,'size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_nom'],'name' => $row['con_id'].'/con_nom' ,'size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_telephone'],'name' => $row['con_id'].'/con_telephone' ,'size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_ext'],'name' => $row['con_id'].'/con_ext' ,'size'=>5)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_telephone2'],'name' => $row['con_id'].'/con_telephone2' ,'size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('value' =>$row['con_courriel'],'name' => $row['con_id'].'/con_courriel' ,'size'=>15)));
|
||||
$mem_choix = $this->Config_model->conf_getRolesContactsFournisseur();
|
||||
$mem_roles=form_dropdown($row['con_id'].'/con_role_id',$mem_choix,$row['con_role_id']) ;
|
||||
|
||||
|
||||
$data_row[] = array('data'=>$mem_roles , 'align' => 'left');
|
||||
$data_row[] = array('data'=>$mem_link_save , 'align' => 'left');
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_new);
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_prenom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_nom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_telephone','size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_ext','size'=>5)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_telephone2','size'=>10)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => '0/con_courriel','size'=>15)));
|
||||
|
||||
$mem_choix = $this->Config_model->conf_getRolesContactsFournisseur();
|
||||
$mem_roles = form_dropdown('0/con_role_id', $mem_choix);
|
||||
|
||||
|
||||
$data_row[] = array('data' => $mem_roles, 'align' => 'left');
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie = $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
return $tableau_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_getforminfo($id)
|
||||
{
|
||||
global $mem_data, $validation;
|
||||
|
||||
$this->load->model('Config_model');
|
||||
$this->load->model('FxForm_model');
|
||||
// vas chercher les info de la fiche
|
||||
|
||||
if ($id != 0)
|
||||
$info = $this->mod_getRecord($id);
|
||||
|
||||
// prepare info pour chaque champs utilisé
|
||||
// input
|
||||
$mem_data['mem_id'] = $id;
|
||||
$mem_champ = 'com_compagnie';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Compagnie', '<i class="icon-prepend fa fa- fa-building"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
//$mem_champ = 'com_num_client';
|
||||
//$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
// $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Numéro Fournisseur', '');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_ref_type';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresFournisseur();
|
||||
// value multipli select
|
||||
$mem_value = explode(',', $mem_value);
|
||||
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Type';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_langue';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getLangues();
|
||||
|
||||
|
||||
// value multipli select
|
||||
$mem_value = explode(',', $mem_value);
|
||||
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Langue';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ = 'com_representant_id';
|
||||
// $mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
// $mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getRepresentantsClient();
|
||||
// $mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
// $mem_data['label'][$mem_champ] = 'Représentant';
|
||||
// $mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'com_actif';
|
||||
$mem_value = ($id == 0 ? true : ($info->$mem_champ == 1 ? true : false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'Actif';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_nom';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Nom', '<i class="icon-prepend fa fa- fa-user"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_prenom';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Prénom', '<i class="icon-prepend fa fa- fa-user"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'com_courriel';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'E-Mail', '<i class="icon-prepend fa fa- fa-envelope"></i>');
|
||||
|
||||
$mem_rule = "
|
||||
" . $mem_champ . " : {
|
||||
required : true,
|
||||
email : true
|
||||
}";
|
||||
$mem_message = "
|
||||
" . $mem_champ . " : {
|
||||
required : 'Champ obligatoire',
|
||||
email : ' <strong>Le E-Mail est pas valide</strong>'
|
||||
}";
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ, $mem_rule, $mem_message);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_telephone';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Téléphone', '<i class="icon-prepend fa fa- fa-phone"></i>');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_telephone_ext';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Extension', '<i class="icon-prepend fa fa- fa-phone"></i>');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_ville';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Ville', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_pro_id';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getProvinces();
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Province';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_pay_id';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getPays();
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Pays';
|
||||
$mem_data['icon'][$mem_champ] = '';
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_codepostal';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Code postal', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_adresse';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Adresse', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'com_notes';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Notes', '', 'Notes');
|
||||
|
||||
$mem_data['validation'] = $this->FxForm_model->fxValidation($validation['rule'], $validation['message']);
|
||||
|
||||
|
||||
return $mem_data;
|
||||
}
|
||||
public function mod_selectcontact($fournisseur_id,$langue='fr',$choix_vide=true)
|
||||
{
|
||||
|
||||
|
||||
$contacts=$this->Fournisseursprojets_model->mod_getRecords_contacts($fournisseur_id);
|
||||
// list la bb client
|
||||
|
||||
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($contacts as $pro ){
|
||||
$mem_sortie[$pro['con_id']]=$pro['con_prenom']." ".$pro['con_nom']." (".$pro['rol_nom'].")";
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
111
application/models/FxForm_model.php
Normal file
111
application/models/FxForm_model.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21g
|
||||
*/
|
||||
class fxForm_model extends CI_Model {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public function fxValidation($rule,$message)
|
||||
{
|
||||
$mem_rules='rules : {';
|
||||
foreach($rule as $key=>$value){
|
||||
$mem_rules=$mem_rules.$value.',';
|
||||
|
||||
|
||||
}
|
||||
$mem_rules=rtrim($mem_rules,", ");
|
||||
$mem_rules=$mem_rules.' },';
|
||||
$mem_messages='messages : {';
|
||||
foreach($message as $key=>$value){
|
||||
$mem_messages=$mem_messages.$value.',';
|
||||
|
||||
|
||||
}
|
||||
$mem_messages=rtrim($mem_messages,", ");
|
||||
$mem_messages=$mem_messages.' },';
|
||||
|
||||
$mem_return['rules']=$mem_rules;
|
||||
$mem_return['messages']=$mem_messages;
|
||||
return $mem_return ;
|
||||
}
|
||||
public function fxinputtxt($mem_champ,$mem_value,$mem_label,$mem_icon='',$mem_placeholder='',$mem_class='',$mem_size='',$readonly=false){
|
||||
|
||||
global $mem_data;
|
||||
$mem_data['input'][$mem_champ] = array(
|
||||
'type' => 'text',
|
||||
'name' => $mem_champ,
|
||||
'id' => $mem_champ,
|
||||
'placeholder' => $mem_placeholder,
|
||||
'value' => $mem_value,
|
||||
'class' =>$mem_class,
|
||||
'size' =>$mem_size
|
||||
);
|
||||
if ($readonly)
|
||||
$mem_data['input'][$mem_champ]['readonly']='readonly';
|
||||
|
||||
|
||||
|
||||
$mem_data['label'][$mem_champ] = $mem_label;
|
||||
$mem_data['icon'][$mem_champ] = $mem_icon;
|
||||
return;
|
||||
}
|
||||
public function fxcheckbox($mem_champ,$mem_value,$mem_label,$mem_icon='',$mem_placeholder='',$mem_class='',$mem_size='',$readonly=false){
|
||||
|
||||
global $mem_data;
|
||||
$mem_data['input'][$mem_champ] = array(
|
||||
'type' => 'checkbox',
|
||||
'name' => $mem_champ,
|
||||
'id' => $mem_champ,
|
||||
|
||||
'placeholder' => $mem_placeholder,
|
||||
'value' => $mem_value,
|
||||
'class' =>$mem_class,
|
||||
'size' =>$mem_size
|
||||
);
|
||||
if ($readonly)
|
||||
$mem_data['input'][$mem_champ]['readonly']='readonly';
|
||||
if ($mem_value==1)
|
||||
$mem_data['input'][$mem_champ]['checked']='TRUE';
|
||||
|
||||
|
||||
|
||||
$mem_data['label'][$mem_champ] = $mem_label;
|
||||
$mem_data['icon'][$mem_champ] = $mem_icon;
|
||||
return;
|
||||
}
|
||||
public function fxvaliderequired($mem_champ,$rule='',$message='' ){
|
||||
|
||||
global $validation;
|
||||
if ($rule==""){
|
||||
$rule="
|
||||
".$mem_champ." : {
|
||||
required : true
|
||||
}";
|
||||
|
||||
}
|
||||
if ($message==""){
|
||||
$message="
|
||||
".$mem_champ." : {
|
||||
required : 'Champ obligatoire'
|
||||
}";
|
||||
|
||||
}
|
||||
|
||||
$validation['rule'][]=$rule ;
|
||||
$validation['message'][]=$message;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
193
application/models/GoogleDocs_model.php
Normal file
193
application/models/GoogleDocs_model.php
Normal file
@ -0,0 +1,193 @@
|
||||
|
||||
<?php
|
||||
// application/models/GoogleDocs_model.php
|
||||
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
|
||||
use Google\Client as Google_Client;
|
||||
use Google\Service\Drive as Google_Service_Drive;
|
||||
use Google\Service\Drive\DriveFile as Google_Service_Drive_DriveFile;
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class GoogleDocs_model extends CI_Model
|
||||
{
|
||||
private $cfg = [];
|
||||
private $driveService = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cfg = $this->config->item('google') ?: [];
|
||||
$this->load->database();
|
||||
$this->load->helper('url'); // pour base_url()
|
||||
}
|
||||
|
||||
/* ========= AUTH SERVICE ACCOUNT (JWT) ========= */
|
||||
|
||||
private function getClient(array $scopes): Google_Client
|
||||
{
|
||||
$credsPath = $this->cfg['credentials_path'] ?? null;
|
||||
if (!$credsPath || !is_file($credsPath)) {
|
||||
throw new Exception("google.credentials_path introuvable : ".($credsPath ?? '(null)'));
|
||||
}
|
||||
$client = new Google_Client();
|
||||
$client->setAuthConfig($credsPath);
|
||||
$client->setScopes($scopes);
|
||||
$client->setAccessType('offline');
|
||||
if (!empty($this->cfg['subject'])) {
|
||||
$client->setSubject($this->cfg['subject']); // DWD si configuré
|
||||
}
|
||||
return $client;
|
||||
}
|
||||
|
||||
private function drive(): Google_Service_Drive
|
||||
{
|
||||
if ($this->driveService instanceof Google_Service_Drive) {
|
||||
return $this->driveService;
|
||||
}
|
||||
$client = $this->getClient(['https://www.googleapis.com/auth/drive']);
|
||||
$this->driveService = new Google_Service_Drive($client);
|
||||
return $this->driveService;
|
||||
}
|
||||
|
||||
/* ========= Utilitaires ========= */
|
||||
|
||||
private function sanitizeDriveName(string $s): string
|
||||
{
|
||||
// Retire caractères non valides pour un nom Drive
|
||||
$s = preg_replace('/[\\\\\/:*?"<>|]/u', ' ', $s);
|
||||
$s = preg_replace('/\s+/u', ' ', trim($s));
|
||||
return mb_substr($s, 0, 240, 'UTF-8');
|
||||
}
|
||||
|
||||
/* ========= PUBLIC: Créer / Actualiser “InfoCourse {NomProjet}” ========= */
|
||||
|
||||
public function creer_document($proj_id)
|
||||
{
|
||||
// Données projet
|
||||
$this->load->model('Projets_model');
|
||||
$mem_proj = $this->Projets_model->mod_getRecord((int)$proj_id);
|
||||
if (empty($mem_proj) || empty($mem_proj->proj_google_rep_id)) {
|
||||
return; // rien à faire sans dossier cible
|
||||
}
|
||||
|
||||
$this->load->model('Clients_model');
|
||||
$contacts = $this->Clients_model->mod_getRecords_contacts($mem_proj->proj_client_id);
|
||||
|
||||
$parentId = $mem_proj->proj_google_rep_id;
|
||||
$dateHeure = date('Y-m-d H:i');
|
||||
$mem_link = base_url('index.php/projets/form/'.$mem_proj->proj_id);
|
||||
$nomProject = $this->sanitizeDriveName((string)$mem_proj->proj_nom);
|
||||
$nomFichier = 'InfoCourse ' . $nomProject; // ← comme demandé
|
||||
|
||||
$drive = $this->drive();
|
||||
|
||||
try {
|
||||
// DriveId du dossier (Shared drive)
|
||||
$folderInfo = $drive->files->get($parentId, [
|
||||
'fields' => 'driveId',
|
||||
'supportsAllDrives' => true
|
||||
]);
|
||||
$driveId = $folderInfo->getDriveId();
|
||||
|
||||
// ===== Construire le tableau (même rendu que ton exemple)
|
||||
$rows = [
|
||||
['Nom du projet', (string)$mem_proj->proj_nom],
|
||||
['Date', (string)($mem_proj->proj_date_debut ?? '')],
|
||||
['Client', (string)($mem_proj->compagnie ?? '')],
|
||||
['Notes', (string)($mem_proj->proj_notes ?? '')],
|
||||
['Lien', "<a href='{$mem_link}'>".$mem_link."</a>"],
|
||||
['Représentant', (string)($mem_proj->rep_prenom ?? '')],
|
||||
['Date de création', $dateHeure],
|
||||
];
|
||||
|
||||
// Contacts + tickets Jira ouverts
|
||||
if (is_array($contacts)) {
|
||||
foreach ($contacts as $c) {
|
||||
$nomComplet = trim(($c['con_prenom'] ?? '').' '.($c['con_nom'] ?? ''));
|
||||
$email = $c['con_courriel'] ?? '';
|
||||
$tel = $c['con_telephone2'] ?? '';
|
||||
$role = $c['rol_nom'] ?? '';
|
||||
|
||||
$ligne = $nomComplet;
|
||||
if ($email) $ligne .= $email;
|
||||
if ($tel) $ligne .= ' - '.$tel;
|
||||
if ($role) $ligne .= ' - '.$role;
|
||||
|
||||
$rows[] = [$nomComplet, $ligne];
|
||||
|
||||
if (function_exists('jira_get_tickets_by_email') && $email) {
|
||||
$tickets = jira_get_tickets_by_email($email);
|
||||
if (!empty($tickets['ouverts'])) {
|
||||
$li = '';
|
||||
foreach ($tickets['ouverts'] as $t) {
|
||||
$sum = isset($t['summary']) ? htmlspecialchars($t['summary']) : '';
|
||||
$key = $t['key'] ?? '';
|
||||
$url = $t['url'] ?? '#';
|
||||
$st = $t['status'] ?? '';
|
||||
$li .= '<li><a href="'.$url.'" target="_blank">'.$key.'</a> — '.$sum.' ('.$st.')</li>';
|
||||
}
|
||||
$rows[] = ['Tickets ouvert', '<ul>'.$li.'</ul>'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===== Supprimer l’existant (même nom, même dossier)
|
||||
$nameEsc = addcslashes($nomFichier, "'");
|
||||
$existing = $drive->files->listFiles([
|
||||
'q' => "name = '{$nameEsc}' and mimeType='application/vnd.google-apps.document' and '{$parentId}' in parents and trashed = false",
|
||||
'spaces' => 'drive',
|
||||
'driveId' => $driveId,
|
||||
'corpora' => 'drive',
|
||||
'includeItemsFromAllDrives' => true,
|
||||
'supportsAllDrives' => true,
|
||||
'fields' => 'files(id)'
|
||||
]);
|
||||
if (count($existing->getFiles()) > 0) {
|
||||
$drive->files->delete($existing->getFiles()[0]->getId(), ['supportsAllDrives' => true]);
|
||||
}
|
||||
|
||||
// ===== HTML (table)
|
||||
$html = '<html><body>';
|
||||
$html .= '<table border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;">';
|
||||
foreach ($rows as $row) {
|
||||
$label = htmlspecialchars($row[0]);
|
||||
$value = $row[1]; // peut contenir du HTML (lien/ul)
|
||||
$html .= "<tr>";
|
||||
$html .= "<td style='width:30%;'><strong>{$label}</strong></td>";
|
||||
$html .= "<td>{$value}</td>";
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= '</table>';
|
||||
$html .= '</body></html>';
|
||||
|
||||
// ===== Import HTML -> Google Docs
|
||||
$tmp = tempnam(sys_get_temp_dir(), 'gdoc_').'.html';
|
||||
file_put_contents($tmp, $html);
|
||||
$content = file_get_contents($tmp);
|
||||
|
||||
$fileMeta = new Google_Service_Drive_DriveFile([
|
||||
'name' => $nomFichier,
|
||||
'mimeType' => 'application/vnd.google-apps.document',
|
||||
'parents' => [$parentId]
|
||||
]);
|
||||
|
||||
$file = $drive->files->create($fileMeta, [
|
||||
'data' => $content,
|
||||
'mimeType' => 'text/html',
|
||||
'uploadType' => 'multipart',
|
||||
'fields' => 'id',
|
||||
'supportsAllDrives' => true
|
||||
]);
|
||||
|
||||
@unlink($tmp);
|
||||
// (optionnel) log_message('info', 'InfoCourse généré: '.$file->id);
|
||||
|
||||
} catch (Exception $e) {
|
||||
log_message('error', 'creer_document: '.$e->getMessage());
|
||||
echo "Erreur : ".$e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
244
application/models/GoogleDocs_model_avant.php
Normal file
244
application/models/GoogleDocs_model_avant.php
Normal file
@ -0,0 +1,244 @@
|
||||
<?php
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
|
||||
use Google\Client as Google_Client;
|
||||
use Google\Service\Drive as Google_Service_Drive;
|
||||
use Google\Service\Docs as Google_Service_Docs;
|
||||
use Google\Service\Docs\Request as Google_Service_Docs_Request;
|
||||
use Google\Service\Docs\BatchUpdateDocumentRequest as Google_Service_Docs_BatchUpdateDocumentRequest;
|
||||
use Google\Service\Drive\DriveFile as Google_Service_Drive_DriveFile;
|
||||
|
||||
class GoogleDocs_model_avant extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
private $user_id;
|
||||
|
||||
public function set_user_id($id)
|
||||
{
|
||||
$this->user_id = $id;
|
||||
}
|
||||
public function getClient() {
|
||||
require_once APPPATH . '../vendor/autoload.php';
|
||||
|
||||
$client = new \Google_Client();
|
||||
$client->setApplicationName('Google Drive API - MS1');
|
||||
$client->setScopes([
|
||||
Google_Service_Drive::DRIVE_FILE,
|
||||
Google_Service_Drive::DRIVE_METADATA_READONLY
|
||||
]);
|
||||
$client->setAuthConfig(APPPATH . 'credentials/credentials.json');
|
||||
$client->setAccessType('offline');
|
||||
$client->setPrompt('select_account consent');
|
||||
$client->setRedirectUri(base_url('index.php/GoogleDrive/test_google'));
|
||||
|
||||
$tokenDir = APPPATH . 'credentials/tokens/';
|
||||
if (!is_dir($tokenDir)) {
|
||||
mkdir($tokenDir, 0700, true);
|
||||
}
|
||||
|
||||
|
||||
$user_id =$this->user_id; // à adapter selon ton système d’authentification
|
||||
$tokenPath = $tokenDir . 'token_' . $user_id . '.json';
|
||||
|
||||
// 1. Si token.json existe, on le charge
|
||||
if (file_exists($tokenPath)) {
|
||||
$accessToken = json_decode(file_get_contents($tokenPath), true);
|
||||
$client->setAccessToken($accessToken);
|
||||
|
||||
// 2. Si expiré, on tente de le refresh automatiquement
|
||||
if ($client->isAccessTokenExpired()) {
|
||||
if ($client->getRefreshToken()) {
|
||||
$client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
|
||||
file_put_contents($tokenPath, json_encode($client->getAccessToken()));
|
||||
} else {
|
||||
unlink($tokenPath);
|
||||
redirect($client->createAuthUrl());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// 3. Pas de token -> redirection OAuth
|
||||
if (isset($_GET['code'])) {
|
||||
$accessToken = $client->fetchAccessTokenWithAuthCode($_GET['code']);
|
||||
|
||||
if (!isset($accessToken['error'])) {
|
||||
file_put_contents($tokenPath, json_encode($client->getAccessToken()));
|
||||
} else {
|
||||
echo 'Erreur OAuth : ' . print_r($accessToken, true);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
redirect($client->createAuthUrl());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
return $client;
|
||||
}
|
||||
|
||||
public function creer_document($proj_id)
|
||||
{
|
||||
$this->load->model('Projets_model');
|
||||
$mem_proj = $this->Projets_model->mod_getRecord($proj_id);
|
||||
|
||||
if($mem_proj->proj_google_rep_id==""){
|
||||
return;
|
||||
}
|
||||
$this->load->model('Clients_model');
|
||||
$contacts2 = $this->Clients_model->mod_getRecords_contacts( $mem_proj->proj_client_id);
|
||||
|
||||
|
||||
|
||||
$mem_link = base_url() . "index.php/projets/form/" . $mem_proj->proj_id;
|
||||
$this->set_user_id($this->session->userdata('id'));
|
||||
$client = $this->getClient();
|
||||
|
||||
if (!($client instanceof Google_Client)) {
|
||||
echo "Erreur : Le client Google n'est pas valide ou vous n'êtes plus connecté.";
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$driveService = new Google_Service_Drive($client);
|
||||
$docsService = new Google_Service_Docs($client);
|
||||
|
||||
$nomFichier = 'Infos Course '.$this->session->username;
|
||||
$parentId = $mem_proj->proj_google_rep_id;
|
||||
$dateHeure = date('Y-m-d H:i');
|
||||
|
||||
// Récupère le driveId du répertoire (Drive partagé)
|
||||
$folderInfo = $driveService->files->get($parentId, [
|
||||
'fields' => 'driveId',
|
||||
'supportsAllDrives' => true
|
||||
]);
|
||||
$driveId = $folderInfo->getDriveId();
|
||||
|
||||
// Données à insérer
|
||||
$data = [
|
||||
['Nom du projet', $mem_proj->proj_nom],
|
||||
['Date', $mem_proj->proj_date_debut],
|
||||
['Client', $mem_proj->compagnie],
|
||||
['Notes', $mem_proj->proj_notes],
|
||||
['Lien', "<a href='{$mem_link}'>$mem_link</a>"],
|
||||
['Représentant', $mem_proj->rep_prenom],
|
||||
['Date de création', $dateHeure],
|
||||
];
|
||||
|
||||
// Ajout dynamique des autres contacts
|
||||
$i = 1;
|
||||
foreach ($contacts2 as $c) {
|
||||
$nomComplet = trim($c['con_prenom'] . ' ' . $c['con_nom']);
|
||||
$email = $c['con_courriel'] ?? '';
|
||||
$tel = $c['con_telephone2'] ?? '';
|
||||
$rol_nom = $c['rol_nom'] ?? '';
|
||||
// Tu peux aussi appeler jira_get_tickets_by_email($email) ici si tu veux inclure les tickets
|
||||
|
||||
$ligne = $nomComplet;
|
||||
if ($email) $ligne .= '' . $email;
|
||||
if ($tel) $ligne .= ' - ' . $tel;
|
||||
if ($rol_nom) $ligne .= ' - ' . $rol_nom;
|
||||
$data[] = [ $nomComplet, $ligne];
|
||||
$i++;
|
||||
$tickets = jira_get_tickets_by_email($email);
|
||||
if (!empty($tickets['ouverts'])):
|
||||
$ligne='';
|
||||
foreach ($tickets['ouverts'] as $t):
|
||||
|
||||
$ligne .= '<li><a href="'.$t['url'].'" target="_blank">'.$t['key'].'</a>
|
||||
— '. htmlspecialchars($t['summary']) .'('. $t['status'].')
|
||||
</li>';
|
||||
endforeach;
|
||||
|
||||
|
||||
$data[] = ['Tickets ouvert ' , $ligne];
|
||||
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
|
||||
// Recherche d’un document existant dans le dossier
|
||||
$response = $driveService->files->listFiles([
|
||||
'q' => sprintf(
|
||||
"name = '%s' and mimeType='application/vnd.google-apps.document' and '%s' in parents and trashed = false",
|
||||
addslashes($nomFichier),
|
||||
$parentId
|
||||
),
|
||||
'spaces' => 'drive',
|
||||
'driveId' => $driveId,
|
||||
'corpora' => 'drive',
|
||||
'includeItemsFromAllDrives' => true,
|
||||
'supportsAllDrives' => true,
|
||||
'fields' => 'files(id)'
|
||||
]);
|
||||
|
||||
// Supprime l'ancien fichier s'il existe
|
||||
if (count($response->getFiles()) > 0) {
|
||||
$existingFileId = $response->getFiles()[0]->getId();
|
||||
$driveService->files->delete($existingFileId, ['supportsAllDrives' => true]);
|
||||
}
|
||||
|
||||
// Contenu HTML à insérer
|
||||
$html = '<html><body>';
|
||||
$html .= '<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse;">';
|
||||
foreach ($data as $row) {
|
||||
$html .= "<tr><td style='width: 30%;'><strong>{$row[0]}</strong></td><td>{$row[1]}</td></tr>";
|
||||
}
|
||||
$html .= '</table>';
|
||||
$html .= '</body></html>';
|
||||
|
||||
// Fichier temporaire HTML
|
||||
$tempFile = tempnam(sys_get_temp_dir(), 'google_doc_html_') . '.html';
|
||||
file_put_contents($tempFile, $html);
|
||||
|
||||
// Création du fichier dans le Drive partagé
|
||||
$fileMetadata = new Google_Service_Drive_DriveFile([
|
||||
'name' => $nomFichier,
|
||||
'mimeType' => 'application/vnd.google-apps.document',
|
||||
'parents' => [$parentId]
|
||||
]);
|
||||
|
||||
$content = file_get_contents($tempFile);
|
||||
$file = $driveService->files->create($fileMetadata, [
|
||||
'data' => $content,
|
||||
'mimeType' => 'text/html',
|
||||
'uploadType' => 'multipart',
|
||||
'fields' => 'id',
|
||||
'supportsAllDrives' => true
|
||||
]);
|
||||
|
||||
unlink($tempFile);
|
||||
|
||||
echo "Document mis à jour avec succès. ID : " . $file->id;
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "Erreur : " . $e->getMessage();
|
||||
//exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_local_drive_path($folderId, Google_Service_Drive $driveService, $driveLetter = 'G', $basePath = 'My Drive\\Projets') {
|
||||
try {
|
||||
$folder = $driveService->files->get($folderId, [
|
||||
'fields' => 'name',
|
||||
'supportsAllDrives' => true // 👈 ici aussi
|
||||
]);
|
||||
$folderName = $folder->getName();
|
||||
|
||||
return $driveLetter . ':\\' . $basePath . '\\' . $folderName;
|
||||
|
||||
} catch (Exception $e) {
|
||||
log_message('error', 'Erreur get_local_drive_path(): ' . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
173
application/models/GoogleDrive_model.php
Normal file
173
application/models/GoogleDrive_model.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class GoogleDrive_model extends CI_Model
|
||||
{
|
||||
/** @var object|null */
|
||||
private $gds = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->gds = $this->boot_google_drive_any();
|
||||
if (!$this->gds) {
|
||||
log_message('error', '[GoogleDrive_model] Aucune classe Google Drive trouvée.');
|
||||
throw new Exception('Librairie Google Drive introuvable (GoogleDrive / GoogleDriveDocs / …)');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Essaie d’inclure et d’instancier une des classes de ta stack.
|
||||
* - Fichiers testés: GoogleDrive.php, GoogleDriveDocs.php, DiagGoogle.php, GoogleServiceJWT.php
|
||||
* - Dossiers testés: application/libraries, application/models, application/
|
||||
*/
|
||||
private function boot_google_drive_any()
|
||||
{
|
||||
$files = ['GoogleDrive.php','GoogleDriveDocs.php','DiagGoogle.php','GoogleServiceJWT.php'];
|
||||
$dirs = [APPPATH.'libraries/', APPPATH.'models/', APPPATH];
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
foreach ($files as $fn) {
|
||||
$path = $dir.$fn;
|
||||
if (is_file($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Classes candidates (ajoute ici si ton nom diffère)
|
||||
$classes = ['GoogleDriveService','GoogleDrive','GoogleDriveDocs','DiagGoogle'];
|
||||
foreach ($classes as $cls) {
|
||||
if (class_exists($cls)) {
|
||||
try {
|
||||
// Si l’un de ces constructeurs a besoin de paramètres, adapte ici.
|
||||
return new $cls();
|
||||
} catch (Throwable $e) {
|
||||
// essaie la suivante
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste les sous-dossiers d’un parent.
|
||||
* Retour: array [['id'=>..., 'name'=>...], ...]
|
||||
*/
|
||||
public function list_children(string $drive_id, string $parent_id): array
|
||||
{
|
||||
// Méthodes possibles dans ta lib (on tente dans cet ordre)
|
||||
$candidates = [
|
||||
'listFolders', 'list_children', 'children', 'listFoldersInParent'
|
||||
];
|
||||
|
||||
$results = null;
|
||||
foreach ($candidates as $m) {
|
||||
if (method_exists($this->gds, $m)) {
|
||||
try {
|
||||
$results = $this->gds->$m($drive_id, $parent_id);
|
||||
} catch (ArgumentCountError $e) {
|
||||
// ordre inversé éventuel
|
||||
$results = $this->gds->$m($parent_id, $drive_id);
|
||||
} catch (Throwable $t) {
|
||||
$results = null;
|
||||
}
|
||||
if (is_array($results)) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($results)) {
|
||||
throw new Exception('Aucune méthode compatible pour lister les sous-dossiers dans la librairie GoogleDrive*.');
|
||||
}
|
||||
|
||||
$out = [];
|
||||
foreach ($results as $f) {
|
||||
$id = $f['id'] ?? ($f['fileId'] ?? ($f['gid'] ?? null));
|
||||
$name = $f['name'] ?? ($f['title'] ?? ($f['nom'] ?? null));
|
||||
if ($id && $name) {
|
||||
$out[] = ['id'=>$id, 'name'=>$name];
|
||||
}
|
||||
}
|
||||
usort($out, fn($a,$b)=>strcasecmp($a['name'],$b['name']));
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construit la chaîne base->...->final (ou [] si final est hors du sous-arbre).
|
||||
*/
|
||||
public function build_chain_from_base(string $drive_id, string $base_id, string $final_id): array
|
||||
{
|
||||
if ($base_id === $final_id) {
|
||||
$base = $this->get_file($drive_id, $base_id);
|
||||
return [['id'=>$base_id, 'name'=>$base['name'] ?? '(racine)']];
|
||||
}
|
||||
|
||||
$nodes = [];
|
||||
$cur = $final_id;
|
||||
$guard = 0;
|
||||
|
||||
while ($cur && $guard < 100) {
|
||||
$file = $this->get_file($drive_id, $cur);
|
||||
if (!$file) break;
|
||||
|
||||
$nodes[] = ['id'=>$cur, 'name'=>$file['name'] ?? $cur];
|
||||
|
||||
if ($cur === $base_id) break;
|
||||
|
||||
$parents = $this->get_parents($drive_id, $cur);
|
||||
$cur = $parents[0] ?? null;
|
||||
$guard++;
|
||||
}
|
||||
|
||||
$foundBase = false;
|
||||
foreach ($nodes as $n) { if ($n['id'] === $base_id) { $foundBase = true; break; } }
|
||||
if (!$foundBase) return [];
|
||||
|
||||
return array_reverse($nodes);
|
||||
}
|
||||
|
||||
private function get_file(string $drive_id, string $file_id): ?array
|
||||
{
|
||||
$candidates = ['getFile','get_file','fileGet','get'];
|
||||
foreach ($candidates as $m) {
|
||||
if (method_exists($this->gds, $m)) {
|
||||
try {
|
||||
$res = $this->gds->$m($drive_id, $file_id);
|
||||
} catch (ArgumentCountError $e) {
|
||||
$res = $this->gds->$m($file_id, $drive_id);
|
||||
} catch (Throwable $t) {
|
||||
$res = null;
|
||||
}
|
||||
if (is_array($res)) {
|
||||
$name = $res['name'] ?? ($res['title'] ?? ($res['nom'] ?? null));
|
||||
return ['id'=>$file_id, 'name'=>$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function get_parents(string $drive_id, string $file_id): array
|
||||
{
|
||||
$candidates = ['getParents','parents','fileParents'];
|
||||
foreach ($candidates as $m) {
|
||||
if (method_exists($this->gds, $m)) {
|
||||
try {
|
||||
$res = $this->gds->$m($drive_id, $file_id);
|
||||
} catch (ArgumentCountError $e) {
|
||||
$res = $this->gds->$m($file_id, $drive_id);
|
||||
} catch (Throwable $t) {
|
||||
$res = null;
|
||||
}
|
||||
if (is_array($res)) {
|
||||
$ids = [];
|
||||
foreach ($res as $p) {
|
||||
$ids[] = is_array($p) ? ($p['id'] ?? $p['fileId'] ?? $p['gid'] ?? null) : $p;
|
||||
}
|
||||
return array_values(array_filter($ids));
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
26
application/models/Home_model.php
Normal file
26
application/models/Home_model.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Home_model extends CI_Model {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->model('Tache_model');
|
||||
|
||||
}
|
||||
|
||||
public function return_calendar_taches($filtre1){
|
||||
$data=$this->Tache_model->mod_listtache_count_jour($filtre1);
|
||||
|
||||
$sortie['taches']=$data['jour'];
|
||||
$sortie['tachesdetails']=$data['details'];
|
||||
return $sortie;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
571
application/models/Lots_model.php
Normal file
571
application/models/Lots_model.php
Normal file
@ -0,0 +1,571 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Lots_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->helper('date');
|
||||
$this->load->model('FxForm_model');
|
||||
$this->load->model('Config_model');
|
||||
$this->load->model('Lots_pdf_model');
|
||||
}
|
||||
public function mod_getRecordCount()
|
||||
{
|
||||
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('proj_details_details');
|
||||
$this->db->where('det_res_active',1);
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
public function mod_modiflot($id,$choix){
|
||||
|
||||
if ($choix==1){
|
||||
$mem_data['det_res_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['det_res_active'] = $choix;
|
||||
}else{
|
||||
$mem_data['det_res_creation'] = "0000-00-00 00:00:00";
|
||||
$mem_data['det_res_active'] = $choix;
|
||||
}
|
||||
|
||||
$mem_where = 'detail_id =' . $id;
|
||||
|
||||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||||
return;
|
||||
}
|
||||
public function mod_modiflot_send_reservation($id,$lotnum){
|
||||
|
||||
|
||||
$mem_data['det_res_envoi'] = date("Y-m-d H:i:s");
|
||||
$mem_data['det_res_active'] = 0;
|
||||
$mem_data['det_res_lot_fait'] = 1;
|
||||
$mem_data['det_res_lot_numero'] = $lotnum;
|
||||
$mem_where = 'detail_id =' . $id;
|
||||
|
||||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||||
return;
|
||||
}
|
||||
public function mod_modiflot_pdf_confirmation($id,$nom,$mem_lot,$proj_ent_id){
|
||||
|
||||
|
||||
$mem_data['det_con_envoi'] = date("Y-m-d H:i:s");
|
||||
$mem_data['det_con_lot_fait'] = 1;
|
||||
$mem_data['det_con_active'] = 0;
|
||||
|
||||
$mem_data['det_con_pdf'] = utf8_encode($nom);
|
||||
$mem_data['det_con_lot_numero'] = $mem_lot;
|
||||
$mem_where = 'detail_id =' . $id;
|
||||
|
||||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||||
// bd unique
|
||||
$mem_data2['proj_con_pdf_creation'] = date("Y-m-d H:i:s");
|
||||
// $mem_data['det_con_envoi'] = date("Y-m-d H:i:s");
|
||||
|
||||
|
||||
$mem_data2['proj_con_pdf'] = utf8_encode($nom);
|
||||
$mem_data2['proj_con_pdf_lot_numero'] = $mem_lot;
|
||||
$mem_data2['proj_con_pdf_detail_detail_id'] = $id;
|
||||
|
||||
$mem_data2['proj_con_pdf_ent_id'] = $proj_ent_id;
|
||||
$str = $this->db->insert('proj_con_pdf', $mem_data2);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
public function mod_modiflot_pdf_facturation($id,$nom,$mem_lot,$mem_montant=123){
|
||||
|
||||
|
||||
$mem_data['det_fac_envoi'] = date("Y-m-d H:i:s");
|
||||
$mem_data['det_fac_lot_fait'] = 1;
|
||||
$mem_data['det_fac_active'] = 0;
|
||||
$mem_data['det_fac_montant'] =$mem_montant;
|
||||
$mem_data['det_fac_pdf'] = utf8_encode($nom);
|
||||
$mem_data['det_fac_lot_numero'] = $mem_lot;
|
||||
$mem_where = 'detail_id =' . $id;
|
||||
|
||||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||||
return;
|
||||
}
|
||||
public function mod_modiflot_pdf_facturation_montant($mem_lot,$mem_montant){
|
||||
|
||||
|
||||
$mem_data=$mem_montant;
|
||||
|
||||
$mem_where = 'det_fac_lot_numero =' . $mem_lot;
|
||||
|
||||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||||
return;
|
||||
}
|
||||
public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif=1)
|
||||
{
|
||||
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('proj_details_details');
|
||||
|
||||
if ($listactif==1)
|
||||
$this->db->where('det_res_active', 1);
|
||||
else
|
||||
$this->db->where('det_res_lot_fait', 1);
|
||||
// if ($filtre1 != "")
|
||||
// $this->db->where("des_nom_fr LIKE '%$filtre1%'");
|
||||
// if ($filtre2 != "")
|
||||
// $this->db->where("des_description_fr LIKE '%$filtre2%'");
|
||||
// if ($filtre3 != "")
|
||||
// $this->db->where("des_ref_type = " . $filtre3);
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
|
||||
|
||||
}
|
||||
public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif = 1, $langue = 'fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,fou_compte.com_langue as fou_langue,cli_contacts.con_prenom as cli_contact_prenom,cli_contacts.con_nom as cli_contact_nom,fou_contacts.con_courriel as fou_contact_courriel,fou_contacts.con_prenom as fou_contact_prenom,fou_contacts.con_nom as fou_contact_nom,cli_compte.com_compagnie as com_compagnie_client,fou_compte.com_compagnie as com_compagnie_fou');
|
||||
$this->db->from('proj_details_details');
|
||||
|
||||
$this->db->join('proj_details', 'proj_details.proj_det_id=proj_details_details.proj_det_id', 'left');
|
||||
$this->db->join('proj_entete', 'proj_entete.proj_id=proj_details.proj_ent_id', 'left');
|
||||
$this->db->join('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||||
$this->db->join('pro_descriptions', 'pro_descriptions.des_id=proj_details.proj_prod_id', 'left');
|
||||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||||
$this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id', 'left');
|
||||
$this->db->join('fou_contacts', 'fou_contacts.con_id=proj_details_details.det_res_contact_id', 'left');
|
||||
$this->db->join('cli_contacts', 'cli_contacts.con_id=proj_entete.proj_contact_principale', 'left');
|
||||
|
||||
if ($listactif==1)
|
||||
$this->db->where('det_res_active', 1);
|
||||
else
|
||||
$this->db->where('det_res_lot_fait', 1);
|
||||
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("fou_compte.com_compagnie LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("des_description_fr LIKE '%$filtre2%'");
|
||||
if ($filtre3 != "")
|
||||
$this->db->where("des_ref_type = " . $filtre3);
|
||||
|
||||
|
||||
$this->db->limit($rowperpage, $rowno);
|
||||
$this->db->order_by("fou_compte.com_id,proj_details_details.det_res_contact_id,proj_details_details.det_res_creation");
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
public function mod_getRecords_lot($listafaire,$listactif=1)
|
||||
{
|
||||
|
||||
if (isset($listafaire['go'])){
|
||||
$liste = implode(',',$listafaire['go']);
|
||||
|
||||
|
||||
// list la bb client
|
||||
$this->db->select('*,fou_compte.com_langue as fou_langue,cli_contacts.con_prenom as cli_contact_prenom,cli_contacts.con_nom as cli_contact_nom,fou_contacts.con_courriel as fou_contact_courriel,fou_contacts.con_prenom as fou_contact_prenom,fou_contacts.con_nom as fou_contact_nom,cli_compte.com_compagnie as com_compagnie_client,fou_compte.com_compagnie as com_compagnie_fou');
|
||||
$this->db->from('proj_details_details');
|
||||
|
||||
$this->db->join('proj_details', 'proj_details.proj_det_id=proj_details_details.proj_det_id', 'left');
|
||||
$this->db->join('proj_entete', 'proj_entete.proj_id=proj_details.proj_ent_id', 'left');
|
||||
$this->db->join('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||||
$this->db->join('pro_descriptions', 'pro_descriptions.des_id=proj_details.proj_prod_id', 'left');
|
||||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||||
$this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id', 'left');
|
||||
$this->db->join('fou_contacts', 'fou_contacts.con_id=proj_details_details.det_res_contact_id', 'left');
|
||||
$this->db->join('cli_contacts', 'cli_contacts.con_id=proj_entete.proj_contact_principale', 'left');
|
||||
|
||||
if ($listactif==1)
|
||||
$this->db->where('det_res_active', 1);
|
||||
else
|
||||
$this->db->where('det_res_lot_fait', 1);
|
||||
|
||||
$this->db->where('FIND_IN_SET(proj_details.proj_det_id ,"'. $liste.'") ');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$this->db->order_by("fou_compte.com_id,proj_details_details.det_res_contact_id,proj_details_details.det_res_creation");
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
}
|
||||
public function mod_loadData_list($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $listactif = 1 )
|
||||
{
|
||||
|
||||
// $config['suffix'] = '/'.$filtre1.'/'. $filtre2.'/'.$filtre3.'/'. $listactif;
|
||||
$filtre1 = ($filtre1 == 'null' ? '' : $filtre1);
|
||||
$filtre2 = ($filtre2 == 'null' ? '' : $filtre2);
|
||||
$filtre3 = ($filtre3 == 'null' ? '' : $filtre3);
|
||||
//echo($listactif);
|
||||
$recordPerPage = 10000;
|
||||
|
||||
$config["cur_page"] = $record;
|
||||
if ($record != 0) {
|
||||
$record = ($record - 1) * $recordPerPage;
|
||||
}
|
||||
|
||||
$recordCount2 = $this->mod_getRecordCount();
|
||||
$recordCount = $this->mod_getRecordCountfilter($filtre1, $filtre2, $filtre3, $listactif);
|
||||
|
||||
$client_list = $this->mod_getRecords($record, $recordPerPage, $filtre1, $filtre2, $filtre3, $listactif);
|
||||
|
||||
$config['base_url'] = base_url() . 'index.php/Lots/loadData_list';
|
||||
|
||||
$config['use_page_numbers'] = TRUE;
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Previous';
|
||||
$config['total_rows'] = $recordCount;
|
||||
$config['per_page'] = $recordPerPage;
|
||||
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["uri_segment"] = 2;
|
||||
$config["num_links"] = 2;
|
||||
$config['full_tag_open'] = '<div ><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></div><!--pagination-->';
|
||||
|
||||
$config['first_link'] = '« First';
|
||||
$config['first_tag_open'] = '<li class="prev page">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
|
||||
$config['last_link'] = 'Last »';
|
||||
$config['last_tag_open'] = '<li class="next page">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
|
||||
$config['next_link'] = 'Next →';
|
||||
$config['next_tag_open'] = '<li class="next page">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
|
||||
$config['prev_link'] = '← Previous';
|
||||
$config['prev_tag_open'] = '<li class="prev page">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
|
||||
$config['cur_tag_open'] = '<li class="active"><a href="">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
|
||||
$config['num_tag_open'] = '<li class="page">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$this->pagination->initialize($config);
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
$data['recordCount'] = $recordCount2;
|
||||
|
||||
// switch voir delete
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
$mem_link_new = "";
|
||||
|
||||
//$mem_link_new=anchor('Produits/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||||
|
||||
if ($listactif==1){
|
||||
// $mem_link_new = '<a id="pk_1" data-id="0" class="btn btn-primary btn-circle glyphicon glyphicon-envelope"> </a>';
|
||||
// $mem_link_new = anchor('lots/prepare_lot', ' ', 'class="btn btn-danger btn-circle glyphicon glyphicon-envelope " ');
|
||||
|
||||
$mem_link_new = '<button id="submit_btn_<?php echo($key);?>" type="submit" class="btn btn-danger btn-circle glyphicon glyphicon-envelope "></button><br>Test <input value="1" type="checkbox" id="go[]" name="test_email">' ;
|
||||
|
||||
$ent_date='Date';
|
||||
$ent_lotno=' ';
|
||||
}else{
|
||||
$ent_date="Date d'envoi";
|
||||
$ent_lotno='Lot num';
|
||||
}
|
||||
|
||||
|
||||
$header = array($mem_link_new, 'Type de produit',
|
||||
'Fournisseur',
|
||||
'Client',
|
||||
'Projet',
|
||||
$ent_date,
|
||||
$ent_lotno,
|
||||
'No projet');
|
||||
// prépare les donnés du tableau
|
||||
$nbitem = 0;
|
||||
|
||||
// filter
|
||||
global $mem_data;
|
||||
$data_row = array();
|
||||
$data_row[] = array('data' => 'Filtre', 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'filtre_produits_2';
|
||||
$mem_value = $filtre2;
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_2');
|
||||
$mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||||
//$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'filtre_produits_3';
|
||||
$mem_value = $filtre3;
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresFournisseur('fr', true, 1);
|
||||
// value multipli select
|
||||
//$mem_value = explode(',', $mem_value);
|
||||
$mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_produits_3"');
|
||||
|
||||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
|
||||
$mem_champ = 'filtre_produits_1';
|
||||
$mem_value = $filtre1;
|
||||
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_1');
|
||||
|
||||
$mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
|
||||
// echo form_dropdown($mem_champ,$select[$mem_champ]['choix'],$select[$mem_champ]['value']);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
// prépare les donnés du tableau
|
||||
|
||||
|
||||
foreach ($client_list as $row) {
|
||||
$nbitem++;
|
||||
|
||||
// $mem_link_edit = anchor('Projets/choix_produit/' . $row['des_id'] , ' ', 'class="btn btn-success btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
|
||||
$mem_link_edit = '';
|
||||
|
||||
$mem_link_delete = '';
|
||||
if ($listactif==1){
|
||||
// $mem_link_edit='<a id="pk_'.$row['detail_id'].'" data-id="'.$row['detail_id'].'" class="btn btn-primary btn-circle glyphicon glyphicon-minus-sign"> </a>';
|
||||
|
||||
$mem_link_edit= '<input checked value="'.$row['proj_det_id'].'" type="checkbox" id="go[]" name="go[]">';
|
||||
|
||||
|
||||
} else{
|
||||
// $mem_link_edit='<a id="pk_'.$row['detail_id'].'" data-id="'.$row['detail_id'].'" class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign"> </a>';
|
||||
}
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
$data_row[] = array('data' => $mem_link_edit . ' ' . $mem_link_delete, 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['gen_nom_fr'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['com_compagnie_fou'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['com_compagnie_client'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['proj_nom'], 'align' => 'left');
|
||||
if ($listactif==1){
|
||||
$data_row[] = array('data' => $row['det_res_creation'], 'align' => 'left');
|
||||
$data_row[] = array('data' => " ", 'align' => 'left');
|
||||
}else{
|
||||
$data_row[] = array('data' => $row['det_res_envoi'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['det_res_lot_numero'], 'align' => 'left');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data_row[] = array('data' => $row['proj_numero'], 'align' => 'left');
|
||||
// $data_row[] = array('data' => $row['type'], 'align' => 'left');
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead>',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie = $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
$data['list'] = $tableau_sortie;
|
||||
return $data;
|
||||
}
|
||||
|
||||
function mod_prepare_lot($listeafaire){
|
||||
$mem_list_lot= $this->mod_getRecords_lot($listeafaire);
|
||||
|
||||
if(count( $mem_list_lot)!=0){
|
||||
$mem_test=0;
|
||||
if (isset($listeafaire['test_email']))
|
||||
$mem_test=1;
|
||||
|
||||
|
||||
$mem_fou_id=0;
|
||||
$mem_contact_id=0;
|
||||
$mem_reservation_fou=array();
|
||||
$mem_fou='';
|
||||
$mem_fou_email='';
|
||||
|
||||
// print("<pre>".print_r($mem_list_lot,true)."</pre>");
|
||||
//$mem_email=$this->load->view('lots/email_fr', '', true);
|
||||
foreach ($mem_list_lot as $key => $value ){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// echo($this->lang->line('reservation'));
|
||||
// exit;
|
||||
|
||||
|
||||
if ($mem_fou_id!=$value['proj_fou_id'] || $mem_contact_id!=$value['det_res_contact_id']){
|
||||
|
||||
|
||||
|
||||
// valide si 1er lecture
|
||||
if ($mem_fou_id==0){
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
|
||||
|
||||
// echo($mem_langue.' a<br>');
|
||||
$pdfdoc= $this->Lots_pdf_model->mod_pdf_reservation( $mem_reservation_fou,$mem_langue);
|
||||
$mem_nom=$mem_fou." ".uniqid().'.pdf';
|
||||
$mem_nom= str_replace(' ', '_', $mem_nom) ;
|
||||
$mem_nom = htmlentities($mem_nom, ENT_NOQUOTES, 'utf-8');
|
||||
$mem_nom = preg_replace('#&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring);#', '\1', $mem_nom);
|
||||
$mem_nom = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $mem_nom);
|
||||
$mem_nom = preg_replace('#&[^;]+;#', '', $mem_nom);
|
||||
|
||||
|
||||
file_put_contents(FCPATH.'pdf/pdf2019/reservation/'. $mem_nom, $pdfdoc );
|
||||
|
||||
$data['to_mail']='';
|
||||
$data['to_name']='';
|
||||
if ($mem_test==0){
|
||||
$data['to_mail']=$mem_fou_email;
|
||||
$data['to_name']='';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data['body']=$this->load->view('lots/email_'.$mem_langue, '', true);
|
||||
|
||||
$data['subject']='Reservations ExpressTours '.$mem_fou;
|
||||
|
||||
|
||||
$data['from_mail']=$this->config->item('emailreservation');
|
||||
$data['from_name']='Expresstours';
|
||||
$data['attach'] = FCPATH.'pdf/pdf2019/reservation/'. $mem_nom;
|
||||
|
||||
$data['blnGoDaddy'] = 1;
|
||||
|
||||
$this->Config_model->fxSendMail($data) ;
|
||||
$data['to_mail']=$this->config->item('emailreservationcc');
|
||||
$data['to_name']='reservations';
|
||||
$this->Config_model->fxSendMail($data) ;
|
||||
|
||||
|
||||
|
||||
//
|
||||
$mem_reservation_fou=array();
|
||||
}
|
||||
|
||||
$mem_fou_id=$value['proj_fou_id'];
|
||||
$mem_contact_id=$value['det_res_contact_id'];
|
||||
$mem_fou=$value['com_compagnie_fou'];
|
||||
$mem_fou_email=$value['fou_contact_courriel'];
|
||||
|
||||
|
||||
}
|
||||
// echo('<br>');
|
||||
// echo('----'.$value['com_compagnie_client']);
|
||||
// echo('<br>');
|
||||
if ($value['fou_langue']==2){
|
||||
$mem_langue='en';
|
||||
$this->lang->load("pdf_lang","english");
|
||||
}
|
||||
else{
|
||||
$mem_langue='fr';
|
||||
$this->lang->load("pdf_lang","french");
|
||||
|
||||
}
|
||||
$mem_reservation_fou[]=$value;
|
||||
|
||||
|
||||
}
|
||||
// echo($mem_langue.' b<br>');
|
||||
$pdfdoc= $this->Lots_pdf_model->mod_pdf_reservation( $mem_reservation_fou,$mem_langue);
|
||||
|
||||
$mem_nom=$mem_fou." ".uniqid().'.pdf';
|
||||
$mem_nom= str_replace(' ', '_', $mem_nom) ;
|
||||
$mem_nom = htmlentities($mem_nom, ENT_NOQUOTES, 'utf-8');
|
||||
$mem_nom = preg_replace('#&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring);#', '\1', $mem_nom);
|
||||
$mem_nom = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $mem_nom);
|
||||
$mem_nom = preg_replace('#&[^;]+;#', '', $mem_nom);
|
||||
|
||||
|
||||
file_put_contents(FCPATH.'pdf/pdf2019/reservation/'. $mem_nom, $pdfdoc );
|
||||
$data['to_mail']='';
|
||||
$data['to_name']='';
|
||||
if ($mem_test==0){
|
||||
$data['to_mail']=$mem_fou_email;
|
||||
$data['to_name']='';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data['body']=$this->load->view('lots/email_'.$mem_langue, '', true);
|
||||
|
||||
$data['subject']='Reservations ExpressTours '.$mem_fou;
|
||||
|
||||
|
||||
$data['from_mail']=$this->config->item('emailreservation');
|
||||
$data['from_name']='Expresstours';
|
||||
$data['attach'] = FCPATH.'pdf/pdf2019/reservation/'. $mem_nom;
|
||||
|
||||
$data['blnGoDaddy'] = 1;
|
||||
|
||||
$this->Config_model->fxSendMail($data) ;
|
||||
$data['to_mail']=$this->config->item('emailreservationcc');
|
||||
$data['to_name']='reservations';
|
||||
$this->Config_model->fxSendMail($data) ;
|
||||
|
||||
}
|
||||
// exit;
|
||||
}
|
||||
|
||||
}
|
||||
962
application/models/Lots_pdf_model.php
Normal file
962
application/models/Lots_pdf_model.php
Normal file
@ -0,0 +1,962 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Lots_pdf_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function mod_pdf_reservation($data,$mem_lang='fr'){
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
|
||||
|
||||
if ($mem_lang!='fr')
|
||||
$this->lang->load("pdf_lang","english");
|
||||
else
|
||||
$this->lang->load("pdf_lang","french");
|
||||
|
||||
$this->load->library('PDF');
|
||||
$pdf = new PDF();
|
||||
$pdf->AddPage();
|
||||
|
||||
|
||||
foreach ($data as $key => $value ) {
|
||||
|
||||
// valide si fiche transporteur
|
||||
|
||||
|
||||
switch ($value['des_ref_type']) {
|
||||
// transport
|
||||
case 1:
|
||||
$pdf->SetLineWidth(.5);
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('reservation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$this->u($value['proj_numero']));
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_prenom'].' '.$value['fou_contact_nom']));
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_courriel']);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(30,5,$this->langx('client').$this->u($value['com_compagnie']));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(80);
|
||||
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(22);
|
||||
$pdf->Cell(5,5,$this->u($value['cli_contact_prenom'].' '.$value['cli_contact_nom']));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(80);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Cell(20);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('coutant'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_coutant'].' $');
|
||||
|
||||
|
||||
$pdf->Ln(12);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',11);
|
||||
$pdf->Cell(5,5,$this->langx('embarquement'));
|
||||
$pdf->Ln(5);
|
||||
|
||||
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
$pdf->Cell(5,5,$this->u($value['det_adress']));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('datedepart'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(80);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('destination'));
|
||||
$pdf->Ln(5);
|
||||
|
||||
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
$pdf->Cell(5,5,$this->u($value['det_destination']));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',11);
|
||||
$pdf->Cell(5,5,$this->langx('datedestination'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(80);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_retour'])));
|
||||
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes']),1);
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
|
||||
|
||||
break;
|
||||
// hebergement
|
||||
case 2:
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('reservation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$value['proj_numero']);
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_prenom'].' '.$value['fou_contact_nom']));
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_courriel']);
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(25,5,$this->u($value['com_compagnie']));
|
||||
$pdf->Cell(80);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(22);
|
||||
$pdf->Cell(5,5,$this->u($value['cli_contact_prenom'].' '.$value['cli_contact_nom']));
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datearrive'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datedepart'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_retour'])));
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes'],1));
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
break;
|
||||
default:
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('reservation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$value['proj_numero']);
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_prenom'].' '.$value['fou_contact_nom']));
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_courriel']));
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(25,5,$this->u($value['com_compagnie']));
|
||||
$pdf->Cell(80);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(22);
|
||||
$pdf->Cell(5,5,$this->u($value['cli_contact_prenom']).' '.$this->u($value['cli_contact_nom']));
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datevisite'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes']) ,1 );
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
|
||||
|
||||
}
|
||||
$this->Lots_model->mod_modiflot_send_reservation($value['detail_id'],1);
|
||||
|
||||
}
|
||||
|
||||
// $pdf->Output();
|
||||
|
||||
$pdfdoc = $pdf->Output("", "S");
|
||||
return $pdfdoc;
|
||||
|
||||
|
||||
}
|
||||
function mod_pdf_confirmation($data,$nom_fichier,$mem_lot,$mem_lang){
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
|
||||
if ($mem_lang!='fr')
|
||||
$this->lang->load("pdf_lang","english");
|
||||
else
|
||||
$this->lang->load("pdf_lang","french");
|
||||
|
||||
|
||||
|
||||
|
||||
$this->load->library('PDF');
|
||||
$pdf = new PDF();
|
||||
$pdf->AddPage();
|
||||
$pdf->Ln(1);
|
||||
|
||||
$mem_entete=1;
|
||||
$mem_des_ref_type=0;
|
||||
$numItems = count($data);
|
||||
$i = 0;
|
||||
$counter=0;
|
||||
foreach ($data as $key => $value ) {
|
||||
// valide si fiche transporteur
|
||||
|
||||
$mem_des_ref_type=$value['des_ref_type'];
|
||||
switch ($value['des_ref_type']) {
|
||||
// transport
|
||||
case 1:
|
||||
if ($mem_entete==1){
|
||||
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
// print("<pre>".print_r($value,true)."</pre>");
|
||||
// exit;
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(20,0,$this->langx('confirmation'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(40,0,$this->langx('ent_numeroprojet_confirmation').$value['proj_numero'],0,0,'R');
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(8);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie']));
|
||||
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(0,0,$this->langx('ent_date_confirmation').date("Y-m-d"));
|
||||
|
||||
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_description',0,0,'L'));
|
||||
$pdf->Cell(100);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_qte',0,0,'L'));
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(15,5,$this->langx('ent_produit_tr_depart'),0,0,'L');
|
||||
|
||||
$pdf->Cell(30);
|
||||
$pdf->Cell(15,5,$this->langx('ent_produit_tr_fin'),0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetLineWidth(0.5);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$num=1;
|
||||
$mem_entete=0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(15,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(85);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Cell(10);
|
||||
$pdf->Cell(15,5,date("Y-m-d H:i",strtotime($value['det_depart'])),0,0,'L');
|
||||
|
||||
$pdf->Cell(30);
|
||||
$pdf->Cell(15,5,date("Y-m-d H:i",strtotime($value['det_retour'])),0,0,'L');
|
||||
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_emb').$this->u($value['det_adress']),0,0,'L');
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_des').$this->u($value['det_destination']),0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_res').$this->u($value['det_responsable']),0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes'],1));
|
||||
|
||||
$pdf->Ln(4);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
|
||||
|
||||
break;
|
||||
// pas bon
|
||||
case 99999:
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('confirmation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$value['proj_numero']);
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_prenom'].' '.$value['fou_contact_nom']);
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_courriel']);
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$value['des_nom_'.$mem_lang]);
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$value['com_compagnie']);
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(30);
|
||||
$pdf->Cell(5,5,$value['cli_contact_prenom'].' '.$value['cli_contact_nom']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datearrive'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datedepart'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_retour'])));
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes'],1));
|
||||
$pdf->Ln(10);
|
||||
break;
|
||||
default:
|
||||
if ($mem_entete==1){
|
||||
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
// print("<pre>".print_r($value,true)."</pre>");
|
||||
// exit;
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(20,0,$this->langx('confirmation'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(40,0,$this->langx('ent_numeroprojet_confirmation').$value['proj_numero'],0,0,'R');
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(8);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie']));
|
||||
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(0,0,$this->langx('ent_date_confirmation').date("Y-m-d"));
|
||||
|
||||
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Ln(10);
|
||||
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(20,0,$this->langx('ent_num_confirmation'),0,0,'L');
|
||||
|
||||
$pdf->Cell(60,0,$this->langx('ent_produit_confirmation'),0,0,'L');
|
||||
$pdf->Cell(20);
|
||||
$pdf->Cell(40,0,$this->langx('ent_datedebut_confirmation'),0,0,'L');
|
||||
$pdf->Cell(25);
|
||||
$pdf->Cell(40,0,$this->langx('ent_qte_confirmation'),0,0,'L');
|
||||
|
||||
$num=1;
|
||||
$mem_entete=0;
|
||||
|
||||
|
||||
}
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
|
||||
|
||||
$pdf->Cell(20,5, $num);
|
||||
$num= $num+1;
|
||||
// $pdf->Cell(25);
|
||||
$pdf->Cell(60,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
// $pdf->Cell(70);
|
||||
$pdf->Cell(25);
|
||||
|
||||
|
||||
$pdf->Cell(60,5,date("Y-m-d H:i" ,strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(40,5,$value['det_qte']);
|
||||
|
||||
|
||||
// $pdf->Ln(3);
|
||||
// $pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
// $pdf->MultiCell(190,10,$this->langx('notes').$this->u($value['det_notes']),1);
|
||||
// $pdf->Ln(10);
|
||||
}
|
||||
|
||||
$this->Lots_model->mod_modiflot_pdf_confirmation($value['detail_id'],$nom_fichier,$mem_lot,$value['proj_ent_id']);
|
||||
|
||||
if ($value['des_ref_type']<> $mem_des_ref_type || ++$i === $numItems){
|
||||
if ($value['des_ref_type']<>1){
|
||||
|
||||
$pdf->Ln(60);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(100,20,$this->langx('ent_fot_notea_confirmation'));
|
||||
|
||||
$pdf->Image(FCPATH.'img/pdf/confirmationtable_'.$mem_lang.'.PNG',10,150,190);
|
||||
$pdf->SetY(-55);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(50,20,$this->langx('ent_fot_noteb_confirmation'));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(50,20,$this->langx('ent_fot_notebb_confirmation'));
|
||||
}
|
||||
}
|
||||
|
||||
// changement page
|
||||
if ($pdf->GetY()>170 && $counter != count( $data ) - 1){
|
||||
$pdf->AddPage();
|
||||
$pdf->Ln(1);
|
||||
$mem_entete=1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// a faire
|
||||
// changer pour confirmation
|
||||
|
||||
|
||||
$counter = $counter + 1;
|
||||
}
|
||||
|
||||
// $pdf->Output();
|
||||
|
||||
$pdfdoc = $pdf->Output("", "S");
|
||||
return $pdfdoc;
|
||||
|
||||
|
||||
}
|
||||
function mod_pdf_facturation_ajoutenumero($mem_pdf,$numero)
|
||||
{
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
|
||||
$mem_lang = 'fr';
|
||||
|
||||
//$this->load->library('PDF');
|
||||
require_once( FCPATH.'fpdf/fpdf.php');
|
||||
|
||||
require_once( FCPATH.'fpdf/src/autoload.php');
|
||||
|
||||
$pdf = new \setasign\Fpdi\Fpdi();
|
||||
// $pdf->AddPage();
|
||||
$mem_pdf_path=FCPATH.'pdf/pdf2019/facturation/'.$mem_pdf;
|
||||
|
||||
//Set the source PDF file
|
||||
$pagecount = $pdf->setSourceFile($mem_pdf_path);
|
||||
|
||||
//Import the first page of the file
|
||||
// $tppl = $pdf->importPage(1);
|
||||
|
||||
//Use this page as template
|
||||
// use the imported page and place it at point 20,30 with a width of 170 mm
|
||||
// $pdf->useTemplate($tppl);
|
||||
|
||||
for ($pageNo = 1; $pageNo <= $pagecount; $pageNo++) {
|
||||
$tplIdx = $pdf->importPage($pageNo);
|
||||
|
||||
// add a page
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
if($pageNo == 1)
|
||||
$pdf->Ln(26);
|
||||
else
|
||||
$pdf->Ln(0);
|
||||
$pdf->Cell(155);
|
||||
$pdf->Write(0,$this->langx('ent_facture').$numero);
|
||||
$pdf->useTemplate($tplIdx);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$pdf->Output($mem_pdf_path, "F");
|
||||
|
||||
|
||||
}
|
||||
function mod_pdf_facturation($data,$nom_fichier,$mem_lot,$client,$mem_lang){
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
if ($mem_lang!='fr')
|
||||
$this->lang->load("pdf_lang","english");
|
||||
else
|
||||
$this->lang->load("pdf_lang","french");
|
||||
|
||||
|
||||
// print_r($data[0]);
|
||||
// exit;
|
||||
$this->load->library('PDF');
|
||||
$pdf = new PDF();
|
||||
$pdf->SetMargins(6, 6, 3);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
// entete
|
||||
// print_r($client);
|
||||
//exit;
|
||||
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
$pdf->SetFont('Arial','B',13);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(150,0,$this->u($client->com_compagnie));
|
||||
$pdf->Cell(50);
|
||||
// $pdf->Cell(0,0,$mem_lot);
|
||||
|
||||
$pdf->SetFont('Arial','',13);
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(100,0,$this->u($data[0]['con_prenom'].' '.$data[0]['con_nom']));
|
||||
|
||||
$pdf->Cell(50);
|
||||
$pdf->Cell(0,0,'Projet '.$this->u($data[0]['proj_numero']));
|
||||
$pdf->SetFont('Arial','',13);
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(100,0,$this->u($client->com_adresse));
|
||||
$pdf->Cell(50);
|
||||
$pdf->Cell(0,0,$this->u($client->com_telephone));
|
||||
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(100,0,$this->u($client->com_ville.','.$client->StateOrProvince.' '.$client->com_codepostal));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Cell(25);
|
||||
$pdf->Cell(0,0,$this->langx('ent_date_facturation').date("Y-m-d"));
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(130);
|
||||
$pdf->Cell(0,0,$this->langx('ent_rep').$this->u($data[0]['usa_prenom'].' '.$data[0]['usa_nom']));
|
||||
$pdf->SetFont('Arial','B',13);
|
||||
$pdf->Ln(13);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(150,0,$this->u($data[0]['proj_nom']));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Ln(5);
|
||||
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(20,0,$this->langx('ent_qte_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_prix_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_total_facturation'),0,0,'R');
|
||||
|
||||
$mem_total=0;
|
||||
$mem_sous_total=0;
|
||||
$mem_total_tps=0;
|
||||
$mem_total_tvq=0;
|
||||
$mem_total_tvh=0;
|
||||
$mem_total_opc=0;
|
||||
$mem_tot=0;
|
||||
$mem_depot=0;
|
||||
$mem_max=count($data);
|
||||
$max=1;
|
||||
$mem_page=1;
|
||||
foreach ($data as $key => $value ) {
|
||||
|
||||
// valide si fiche transporteur
|
||||
// echo('-----<br>');
|
||||
// print_r($data);
|
||||
switch ($value['des_ref_type']) {
|
||||
// transport
|
||||
|
||||
default:
|
||||
// si taxe
|
||||
$mem_tx=' ';
|
||||
if ($value['des_tps']==1 || $value['des_tvq'] || $value['des_tvh'])
|
||||
$mem_tx='Tx';
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
|
||||
$mem_titre=$this->u($value['des_nom_'.$mem_lang]);
|
||||
if ($this->u($value['com_compagnie_fou'])!="")
|
||||
{
|
||||
$mem_titre=$this->u($value['des_nom_'.$mem_lang])."-".$this->u($value['com_compagnie_fou']);
|
||||
|
||||
}
|
||||
$pdf->Cell(80,0, $mem_titre);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(35);
|
||||
$pdf->Cell(20,0,$value['det_qte'],0,0,'R');
|
||||
$pdf->Cell(30,0,number_format($value['det_vendant'], 2, '.', ' ').' $ '.$mem_tx,0,0,'R');
|
||||
$tot_ligne=$value['det_qte']*$value['det_vendant'];
|
||||
$pdf->Cell(25,0,number_format($tot_ligne, 2, '.', ' ').' $',0,0,'R');
|
||||
// $pdf->Ln(5);
|
||||
// $pdf->Cell(6);
|
||||
// $pdf->Cell(50,0,$this->u($value['des_nom_'.$mem_lang]));
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(50,0,date("Y-m-d",strtotime($value['det_depart'])));
|
||||
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(5);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(125,5,$this->langx('notes').$this->u($value['det_notes']),0);
|
||||
|
||||
// total et taxe
|
||||
|
||||
$mem_sous_total= $mem_sous_total+$tot_ligne;
|
||||
if ($value['des_tvh']==1){
|
||||
$mem_total_tvh=$mem_total_tvh+$tot_ligne;
|
||||
}else{
|
||||
if ($value['des_tps']==1)
|
||||
$mem_total_tps=$mem_total_tps+$tot_ligne;
|
||||
if ($value['des_tvq']==1)
|
||||
$mem_total_tvq=$mem_total_tvq+$tot_ligne;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($value['des_opc']==1)
|
||||
$mem_total_opc=$mem_total_opc+$tot_ligne;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$this->Lots_model->mod_modiflot_pdf_facturation($value['detail_id'],$nom_fichier,$mem_lot,0);
|
||||
|
||||
|
||||
if ($mem_max<>$max){
|
||||
$pdf->Ln(2);
|
||||
$pdf->Cell(5);
|
||||
$pdf->SetLineWidth(0.5);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
|
||||
}
|
||||
|
||||
if ($pdf->GetY()>180){
|
||||
//if (2==3){
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->SetY(-25);
|
||||
$pdf->Cell(0,0,'Page '.$pdf->PageNo().'/{nb}',0,0,'C');
|
||||
$mem_page=$mem_page+1;
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(20,0,$this->langx('ent_qte_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_prix_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_total_facturation'),0,0,'R');
|
||||
}
|
||||
|
||||
$max=$max+1;
|
||||
|
||||
|
||||
// changer pour confirmation
|
||||
}
|
||||
|
||||
$mem_tax=$this->Config_model->conf_tax_desc('fr');
|
||||
|
||||
// tot
|
||||
$mem_opc=$mem_total_opc*$mem_tax['OPC']['taux'];
|
||||
|
||||
// imprime opc
|
||||
$pdf->Cell(5);
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(130,0,$this->langx('ent_opc_facturation').' ('.number_format($mem_tax['OPC']['taux']*100, 2, '.', ' ').'%)');
|
||||
|
||||
|
||||
|
||||
$pdf->Cell(60,0,number_format($mem_opc, 2, '.', ' ').' $',0,0,'R');
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(130,0,$this->langx('ent_remiseopc_facturation'));
|
||||
|
||||
$pdf->Cell(60,0,number_format($mem_opc*-1, 2, '.', ' ').' $',0,0,'R');
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$mem_opc=0;
|
||||
// sous total
|
||||
$mem_sous_total=$mem_sous_total+$mem_opc;
|
||||
// if ($mem_total_tvh==0){
|
||||
if ($mem_total_tps+$mem_total_tvq != 0){
|
||||
$mem_total_tps=$mem_total_tps+$mem_opc;
|
||||
$mem_total_tvq=$mem_total_tvq +$mem_opc;
|
||||
}
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_soustotal_facturation'),0,0,'L');
|
||||
$pdf->Cell(54,0,number_format($mem_sous_total , 2, '.', ' ').' $',0,0,'R');
|
||||
// tps
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_tps_facturation').' ('.number_format($mem_tax['TPS']['taux'], 3, '.', ' ').'%) :' ,0,0,'L');
|
||||
$mem_tps=$mem_total_tps*($mem_tax['TPS']['taux']/100);
|
||||
$pdf->Cell(54,0,number_format($mem_tps , 2, '.', ' ').' $',0,0,'R');
|
||||
// tvq
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_tvq_facturation').' ('.number_format($mem_tax['TVQ']['taux'], 3, '.', ' ').'%) :' ,0,0,'L');
|
||||
$mem_tvq=($mem_total_tvq)*($mem_tax['TVQ']['taux']/100);
|
||||
$pdf->Cell(54,0,number_format( $mem_tvq, 2, '.', ' ').' $',0,0,'R');
|
||||
// tvh
|
||||
if ($mem_total_tvh<>0){
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_tvh_facturation').' ('.number_format($mem_tax['TVH']['taux'], 3, '.', ' ').'%) :' ,0,0,'L');
|
||||
$mem_total_tvh=$mem_total_tvh +$mem_opc;
|
||||
$mem_tvh=($mem_total_tvh)*($mem_tax['TVH']['taux']/100);
|
||||
|
||||
$pdf->Cell(54,0,number_format( $mem_tvh, 2, '.', ' ').' $',0,0,'R');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// total
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_total_facturation'),0,0,'L');
|
||||
$mem_total=$mem_sous_total+$mem_tvq+$mem_tps+$mem_tvh ;
|
||||
$pdf->Cell(54,0,number_format($mem_total, 2, '.', ' ').' $',0,0,'R');
|
||||
// depot
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_depot_facturation'),0,0,'L');
|
||||
|
||||
$pdf->Cell(54,0,number_format($mem_depot, 2, '.', ' ').' $',0,0,'R');
|
||||
// solde
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_solde_facturation'),0,0,'L');
|
||||
$mem_solde=$mem_total-$mem_depot;
|
||||
$pdf->Cell(54,0,number_format($mem_solde, 2, '.', ' ').' $',0,0,'R');
|
||||
// no taxe
|
||||
$pdf->SetY(-65);
|
||||
// tps
|
||||
$pdf->SetFont('Arial','',7);
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(10,0,$mem_tax['TPSNO']['note'] ,0,0,'L');
|
||||
|
||||
// tvq
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(10,0,$mem_tax['TVQNO']['note'] ,0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
// $pdf->Output();
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,20) ;
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(0,0,$this->langx('ent_note1_facturation') ,0,0,'L');
|
||||
$pdf->Ln(4);
|
||||
$pdf->Cell(5);
|
||||
$pdf->MultiCell(180,3,$this->langx('ent_note2_facturation') ,0,'L');
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
$pdf->SetY(-25);
|
||||
$pdf->Cell(0,0,'Page '.$pdf->PageNo().'/{nb}',0,0,'C');
|
||||
$pdfdoc = $pdf->Output("", "S");
|
||||
|
||||
$mem_montant['det_fac_montant']=$mem_solde;
|
||||
$mem_montant['det_fac_tvq']=$mem_tvq;
|
||||
$mem_montant['det_fac_tps']=$mem_tps;
|
||||
$mem_montant['det_fac_tvh']=$mem_tvh;
|
||||
$mem_montant['det_fac_depot']=$mem_depot;
|
||||
$mem_montant['det_fac_avanttx']=$mem_sous_total;
|
||||
$mem_montant['det_fac_opc']=$mem_opc;
|
||||
$mem_montant['det_fac_opc']=0;
|
||||
// enlever l opc
|
||||
|
||||
|
||||
$mem_montant['det_fac_opc_avant']=$mem_opc;
|
||||
$this->Lots_model->mod_modiflot_pdf_facturation_montant($mem_lot, $mem_montant);
|
||||
|
||||
|
||||
return $pdfdoc;
|
||||
|
||||
|
||||
}
|
||||
function langx($key){
|
||||
return utf8_decode($this->lang->line($key));
|
||||
|
||||
}
|
||||
function u($key){
|
||||
return utf8_decode(($key));
|
||||
|
||||
}
|
||||
}
|
||||
944
application/models/Lots_pdf_modelbbk.php
Normal file
944
application/models/Lots_pdf_modelbbk.php
Normal file
@ -0,0 +1,944 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Lots_pdf_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function mod_pdf_reservation($data,$mem_lang='fr'){
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
|
||||
|
||||
if ($mem_lang!='fr')
|
||||
$this->lang->load("pdf_lang","english");
|
||||
else
|
||||
$this->lang->load("pdf_lang","french");
|
||||
|
||||
$this->load->library('PDF');
|
||||
$pdf = new PDF();
|
||||
$pdf->AddPage();
|
||||
|
||||
|
||||
foreach ($data as $key => $value ) {
|
||||
|
||||
// valide si fiche transporteur
|
||||
|
||||
|
||||
switch ($value['des_ref_type']) {
|
||||
// transport
|
||||
case 1:
|
||||
$pdf->SetLineWidth(.5);
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('reservation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$this->u($value['proj_numero']));
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_prenom'].' '.$value['fou_contact_nom']));
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_courriel']);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(30,5,$this->langx('client').$this->u($value['com_compagnie']));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(80);
|
||||
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(22);
|
||||
$pdf->Cell(5,5,$this->u($value['cli_contact_prenom'].' '.$value['cli_contact_nom']));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(80);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Cell(20);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('coutant'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_coutant'].' $');
|
||||
|
||||
|
||||
$pdf->Ln(12);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',11);
|
||||
$pdf->Cell(5,5,$this->langx('embarquement'));
|
||||
$pdf->Ln(5);
|
||||
|
||||
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
$pdf->Cell(5,5,$this->u($value['det_adress']));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('datedepart'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(80);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(5,5,$this->langx('destination'));
|
||||
$pdf->Ln(5);
|
||||
|
||||
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
$pdf->Cell(5,5,$this->u($value['det_destination']));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',11);
|
||||
$pdf->Cell(5,5,$this->langx('datedestination'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(80);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_retour'])));
|
||||
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes']),1);
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
|
||||
|
||||
break;
|
||||
// hebergement
|
||||
case 2:
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('reservation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$value['proj_numero']);
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_prenom'].' '.$value['fou_contact_nom']));
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_courriel']);
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(25,5,$this->u($value['com_compagnie']));
|
||||
$pdf->Cell(80);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(22);
|
||||
$pdf->Cell(5,5,$this->u($value['cli_contact_prenom'].' '.$value['cli_contact_nom']));
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datearrive'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datedepart'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_retour'])));
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes'],1));
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
break;
|
||||
default:
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('reservation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$value['proj_numero']);
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_prenom'].' '.$value['fou_contact_nom']));
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$this->u($value['fou_contact_courriel']));
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(25,5,$this->u($value['com_compagnie']));
|
||||
$pdf->Cell(80);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(22);
|
||||
$pdf->Cell(5,5,$this->u($value['cli_contact_prenom']).' '.$this->u($value['cli_contact_nom']));
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datevisite'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes']) ,1 );
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
|
||||
|
||||
}
|
||||
$this->Lots_model->mod_modiflot_send_reservation($value['detail_id'],1);
|
||||
|
||||
}
|
||||
|
||||
// $pdf->Output();
|
||||
|
||||
$pdfdoc = $pdf->Output("", "S");
|
||||
return $pdfdoc;
|
||||
|
||||
|
||||
}
|
||||
function mod_pdf_confirmation($data,$nom_fichier,$mem_lot,$mem_lang){
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
|
||||
if ($mem_lang!='fr')
|
||||
$this->lang->load("pdf_lang","english");
|
||||
else
|
||||
$this->lang->load("pdf_lang","french");
|
||||
|
||||
|
||||
|
||||
|
||||
$this->load->library('PDF');
|
||||
$pdf = new PDF();
|
||||
$pdf->AddPage();
|
||||
$pdf->Ln(1);
|
||||
|
||||
$mem_entete=1;
|
||||
$mem_des_ref_type=0;
|
||||
$numItems = count($data);
|
||||
$i = 0;
|
||||
$counter=0;
|
||||
foreach ($data as $key => $value ) {
|
||||
// valide si fiche transporteur
|
||||
|
||||
$mem_des_ref_type=$value['des_ref_type'];
|
||||
switch ($value['des_ref_type']) {
|
||||
// transport
|
||||
case 1:
|
||||
if ($mem_entete==1){
|
||||
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
// print("<pre>".print_r($value,true)."</pre>");
|
||||
// exit;
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(20,0,$this->langx('confirmation'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(40,0,$this->langx('ent_numeroprojet_confirmation').$value['proj_numero'],0,0,'R');
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(8);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie']));
|
||||
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(0,0,$this->langx('ent_date_confirmation').date("Y-m-d"));
|
||||
|
||||
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_description',0,0,'L'));
|
||||
$pdf->Cell(100);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_qte',0,0,'L'));
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(15,5,$this->langx('ent_produit_tr_depart'),0,0,'L');
|
||||
|
||||
$pdf->Cell(30);
|
||||
$pdf->Cell(15,5,$this->langx('ent_produit_tr_fin'),0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetLineWidth(0.5);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$num=1;
|
||||
$mem_entete=0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(15,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
$pdf->Cell(85);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Cell(10);
|
||||
$pdf->Cell(15,5,date("Y-m-d H:i",strtotime($value['det_depart'])),0,0,'L');
|
||||
|
||||
$pdf->Cell(30);
|
||||
$pdf->Cell(15,5,date("Y-m-d H:i",strtotime($value['det_retour'])),0,0,'L');
|
||||
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_emb').$this->u($value['det_adress']),0,0,'L');
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_des').$this->u($value['det_destination']),0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(1,5,$this->langx('ent_produit_tr_res').$this->u($value['det_responsable']),0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes'],1));
|
||||
|
||||
$pdf->Ln(4);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
|
||||
|
||||
break;
|
||||
// pas bon
|
||||
case 99999:
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','B',17);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('confirmation'));
|
||||
$pdf->Cell(150);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(5,5,$this->langx('projet').$value['proj_numero']);
|
||||
|
||||
$pdf->Ln(10);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$this->langx('contact'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_prenom'].' '.$value['fou_contact_nom']);
|
||||
$pdf->Cell(55);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('email'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['fou_contact_courriel']);
|
||||
|
||||
$pdf->Ln(15);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$value['des_nom_'.$mem_lang]);
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('qte'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(5,5,$value['det_qte']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(5,5,$value['com_compagnie']);
|
||||
$pdf->Cell(70);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('responsable'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(30);
|
||||
$pdf->Cell(5,5,$value['cli_contact_prenom'].' '.$value['cli_contact_nom']);
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datearrive'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Ln(7);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Cell(5,5,$this->langx('datedepart'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(70);
|
||||
$pdf->Cell(5,5,date("Y-m-d H:i",strtotime($value['det_retour'])));
|
||||
$pdf->Ln(10);
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(190,5,$this->langx('notes').$this->u($value['det_notes'],1));
|
||||
$pdf->Ln(10);
|
||||
break;
|
||||
default:
|
||||
if ($mem_entete==1){
|
||||
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
// print("<pre>".print_r($value,true)."</pre>");
|
||||
// exit;
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(20,0,$this->langx('confirmation'));
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(40,0,$this->langx('ent_numeroprojet_confirmation').$value['proj_numero'],0,0,'R');
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(8);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie']));
|
||||
|
||||
$pdf->SetFont('Arial','',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(0,0,$this->langx('ent_date_confirmation').date("Y-m-d"));
|
||||
|
||||
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(100,0,$this->u($value['com_compagnie_fou']));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Ln(10);
|
||||
|
||||
$pdf->Cell(1);
|
||||
$pdf->Cell(20,0,$this->langx('ent_num_confirmation'),0,0,'L');
|
||||
|
||||
$pdf->Cell(60,0,$this->langx('ent_produit_confirmation'),0,0,'L');
|
||||
$pdf->Cell(20);
|
||||
$pdf->Cell(40,0,$this->langx('ent_datedebut_confirmation'),0,0,'L');
|
||||
$pdf->Cell(25);
|
||||
$pdf->Cell(40,0,$this->langx('ent_qte_confirmation'),0,0,'L');
|
||||
|
||||
$num=1;
|
||||
$mem_entete=0;
|
||||
|
||||
|
||||
}
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
|
||||
|
||||
$pdf->Cell(20,5, $num);
|
||||
$num= $num+1;
|
||||
// $pdf->Cell(25);
|
||||
$pdf->Cell(60,5,$this->u($value['des_nom_'.$mem_lang]));
|
||||
// $pdf->Cell(70);
|
||||
$pdf->Cell(25);
|
||||
|
||||
|
||||
$pdf->Cell(60,5,date("Y-m-d H:i" ,strtotime($value['det_depart'])));
|
||||
|
||||
$pdf->Cell(15);
|
||||
$pdf->Cell(40,5,$value['det_qte']);
|
||||
|
||||
|
||||
// $pdf->Ln(3);
|
||||
// $pdf->Cell(1);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
// $pdf->MultiCell(190,10,$this->langx('notes').$this->u($value['det_notes']),1);
|
||||
// $pdf->Ln(10);
|
||||
}
|
||||
|
||||
$this->Lots_model->mod_modiflot_pdf_confirmation($value['detail_id'],$nom_fichier,$mem_lot,$value['proj_ent_id']);
|
||||
|
||||
if ($value['des_ref_type']<> $mem_des_ref_type || ++$i === $numItems){
|
||||
if ($value['des_ref_type']<>1){
|
||||
|
||||
$pdf->Ln(60);
|
||||
$pdf->Cell(1);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(100,20,$this->langx('ent_fot_notea_confirmation'));
|
||||
|
||||
$pdf->Image(FCPATH.'img/pdf/confirmationtable_'.$mem_lang.'.PNG',10,150,190);
|
||||
$pdf->SetY(-55);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(50,20,$this->langx('ent_fot_noteb_confirmation'));
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(50,20,$this->langx('ent_fot_notebb_confirmation'));
|
||||
}
|
||||
}
|
||||
|
||||
// changement page
|
||||
if ($pdf->GetY()>170 && $counter != count( $data ) - 1){
|
||||
$pdf->AddPage();
|
||||
$pdf->Ln(1);
|
||||
$mem_entete=1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// a faire
|
||||
// changer pour confirmation
|
||||
|
||||
|
||||
$counter = $counter + 1;
|
||||
}
|
||||
|
||||
// $pdf->Output();
|
||||
|
||||
$pdfdoc = $pdf->Output("", "S");
|
||||
return $pdfdoc;
|
||||
|
||||
|
||||
}
|
||||
function mod_pdf_facturation_ajoutenumero($mem_pdf,$numero)
|
||||
{
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
|
||||
$mem_lang = 'fr';
|
||||
|
||||
//$this->load->library('PDF');
|
||||
require_once( FCPATH.'fpdf/fpdf.php');
|
||||
|
||||
require_once( FCPATH.'fpdf/src/autoload.php');
|
||||
|
||||
$pdf = new \setasign\Fpdi\Fpdi();
|
||||
// $pdf->AddPage();
|
||||
$mem_pdf_path=FCPATH.'pdf/pdf2019/facturation/'.$mem_pdf;
|
||||
|
||||
//Set the source PDF file
|
||||
$pagecount = $pdf->setSourceFile($mem_pdf_path);
|
||||
|
||||
//Import the first page of the file
|
||||
// $tppl = $pdf->importPage(1);
|
||||
|
||||
//Use this page as template
|
||||
// use the imported page and place it at point 20,30 with a width of 170 mm
|
||||
// $pdf->useTemplate($tppl);
|
||||
|
||||
for ($pageNo = 1; $pageNo <= $pagecount; $pageNo++) {
|
||||
$tplIdx = $pdf->importPage($pageNo);
|
||||
|
||||
// add a page
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont('Arial','B',12);
|
||||
if($pageNo == 1)
|
||||
$pdf->Ln(26);
|
||||
else
|
||||
$pdf->Ln(0);
|
||||
$pdf->Cell(155);
|
||||
$pdf->Write(0,$this->langx('ent_facture').$numero);
|
||||
$pdf->useTemplate($tplIdx);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$pdf->Output($mem_pdf_path, "F");
|
||||
|
||||
|
||||
}
|
||||
function mod_pdf_facturation($data,$nom_fichier,$mem_lot,$client,$mem_lang){
|
||||
// require_once FCPATH.'fpdf/fpdf.php';
|
||||
if ($mem_lang!='fr')
|
||||
$this->lang->load("pdf_lang","english");
|
||||
else
|
||||
$this->lang->load("pdf_lang","french");
|
||||
|
||||
|
||||
// print_r($data[0]);
|
||||
// exit;
|
||||
$this->load->library('PDF');
|
||||
$pdf = new PDF();
|
||||
$pdf->SetMargins(6, 6, 3);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
// entete
|
||||
// print_r($client);
|
||||
//exit;
|
||||
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,27) ;
|
||||
$pdf->SetFont('Arial','B',13);
|
||||
$pdf->Ln(6);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(150,0,$this->u($client->com_compagnie));
|
||||
$pdf->Cell(50);
|
||||
// $pdf->Cell(0,0,$mem_lot);
|
||||
|
||||
$pdf->SetFont('Arial','',13);
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(100,0,$this->u($data[0]['con_prenom'].' '.$data[0]['con_nom']));
|
||||
|
||||
$pdf->Cell(50);
|
||||
$pdf->Cell(0,0,'Projet '.$this->u($data[0]['proj_numero']));
|
||||
$pdf->SetFont('Arial','',13);
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(100,0,$this->u($client->com_adresse));
|
||||
$pdf->Cell(50);
|
||||
$pdf->Cell(0,0,$this->u($client->com_telephone));
|
||||
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(100,0,$this->u($client->com_ville.','.$client->StateOrProvince.' '.$client->com_codepostal));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Cell(25);
|
||||
$pdf->Cell(0,0,$this->langx('ent_date_facturation').date("Y-m-d"));
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(130);
|
||||
$pdf->Cell(0,0,$this->langx('ent_rep').$this->u($data[0]['usa_prenom'].' '.$data[0]['usa_nom']));
|
||||
$pdf->SetFont('Arial','B',13);
|
||||
$pdf->Ln(13);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(150,0,$this->u($data[0]['proj_nom']));
|
||||
$pdf->SetFont('Arial','',9);
|
||||
$pdf->Ln(5);
|
||||
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(20,0,$this->langx('ent_qte_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_prix_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_total_facturation'),0,0,'R');
|
||||
|
||||
$mem_total=0;
|
||||
$mem_sous_total=0;
|
||||
$mem_total_tps=0;
|
||||
$mem_total_tvq=0;
|
||||
$mem_total_tvh=0;
|
||||
$mem_total_opc=0;
|
||||
$mem_tot=0;
|
||||
$mem_depot=0;
|
||||
$mem_max=count($data);
|
||||
$max=1;
|
||||
$mem_page=1;
|
||||
foreach ($data as $key => $value ) {
|
||||
|
||||
// valide si fiche transporteur
|
||||
// echo('-----<br>');
|
||||
// print_r($data);
|
||||
switch ($value['des_ref_type']) {
|
||||
// transport
|
||||
|
||||
default:
|
||||
// si taxe
|
||||
$mem_tx=' ';
|
||||
if ($value['des_tps']==1 || $value['des_tvq'] || $value['des_tvh'])
|
||||
$mem_tx='Tx';
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->SetFont('Arial','B',10);
|
||||
|
||||
$mem_titre=$this->u($value['des_nom_'.$mem_lang]);
|
||||
if ($this->u($value['com_compagnie_fou'])!="")
|
||||
{
|
||||
$mem_titre=$this->u($value['des_nom_'.$mem_lang])."-".$this->u($value['com_compagnie_fou']);
|
||||
|
||||
}
|
||||
$pdf->Cell(80,0, $mem_titre);
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(35);
|
||||
$pdf->Cell(20,0,$value['det_qte'],0,0,'R');
|
||||
$pdf->Cell(30,0,number_format($value['det_vendant'], 2, '.', ' ').' $ '.$mem_tx,0,0,'R');
|
||||
$tot_ligne=$value['det_qte']*$value['det_vendant'];
|
||||
$pdf->Cell(25,0,number_format($tot_ligne, 2, '.', ' ').' $',0,0,'R');
|
||||
// $pdf->Ln(5);
|
||||
// $pdf->Cell(6);
|
||||
// $pdf->Cell(50,0,$this->u($value['des_nom_'.$mem_lang]));
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(50,0,date("Y-m-d",strtotime($value['det_depart'])));
|
||||
|
||||
//$pdf->Rect(10,$pdf->GetY() ,190,10) ;
|
||||
$pdf->Ln(3);
|
||||
$pdf->Cell(5);
|
||||
//$pdf->Cell(5,5,$this->langx('notes').$value['det_notes']);
|
||||
$pdf->MultiCell(125,5,$this->langx('notes').$this->u($value['det_notes']),0);
|
||||
|
||||
// total et taxe
|
||||
|
||||
$mem_sous_total= $mem_sous_total+$tot_ligne;
|
||||
if ($value['des_tps']==1)
|
||||
$mem_total_tps=$mem_total_tps+$tot_ligne;
|
||||
if ($value['des_tvq']==1)
|
||||
$mem_total_tvq=$mem_total_tvq+$tot_ligne;
|
||||
if ($value['des_tvh']==1)
|
||||
$mem_total_tvh=$mem_total_tvh+$tot_ligne;
|
||||
if ($value['des_opc']==1)
|
||||
$mem_total_opc=$mem_total_opc+$tot_ligne;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$this->Lots_model->mod_modiflot_pdf_facturation($value['detail_id'],$nom_fichier,$mem_lot,0);
|
||||
|
||||
|
||||
if ($mem_max<>$max){
|
||||
$pdf->Ln(2);
|
||||
$pdf->Cell(5);
|
||||
$pdf->SetLineWidth(0.5);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
|
||||
}
|
||||
|
||||
if ($pdf->GetY()>180){
|
||||
//if (2==3){
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->SetY(-25);
|
||||
$pdf->Cell(0,0,'Page '.$pdf->PageNo().'/{nb}',0,0,'C');
|
||||
$mem_page=$mem_page+1;
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont('Arial','',10);
|
||||
$pdf->Cell(120);
|
||||
$pdf->Cell(20,0,$this->langx('ent_qte_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_prix_facturation'),0,0,'R');
|
||||
$pdf->Cell(25,0,$this->langx('ent_total_facturation'),0,0,'R');
|
||||
}
|
||||
|
||||
$max=$max+1;
|
||||
|
||||
|
||||
// changer pour confirmation
|
||||
}
|
||||
|
||||
$mem_tax=$this->Config_model->conf_tax_desc('fr');
|
||||
|
||||
// tot
|
||||
$mem_opc=$mem_total_opc*$mem_tax['OPC']['taux'];
|
||||
|
||||
// imprime opc
|
||||
$pdf->Cell(5);
|
||||
$pdf->Ln(5);
|
||||
$pdf->SetLineWidth(1);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
$pdf->SetLineWidth(.5);
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(130,0,$this->langx('ent_opc_facturation').' ('.number_format($mem_tax['OPC']['taux']*100, 1, '.', ' ').'%)');
|
||||
|
||||
|
||||
|
||||
$pdf->Cell(60,0,number_format($mem_opc, 2, '.', ' ').' $',0,0,'R');
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(130,0,$this->langx('ent_remiseopc_facturation'));
|
||||
|
||||
$pdf->Cell(60,0,number_format($mem_opc*-1, 2, '.', ' ').' $',0,0,'R');
|
||||
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->line(12,$pdf->GetY(),200,$pdf->GetY()) ;
|
||||
// sous total
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_soustotal_facturation'),0,0,'L');
|
||||
$pdf->Cell(54,0,number_format($mem_sous_total , 2, '.', ' ').' $',0,0,'R');
|
||||
// tps
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_tps_facturation').' ('.number_format($mem_tax['TPS']['taux'], 3, '.', ' ').'%) :' ,0,0,'L');
|
||||
$mem_tps=$mem_total_tps*($mem_tax['TPS']['taux']/100);
|
||||
$pdf->Cell(54,0,number_format($mem_tps , 2, '.', ' ').' $',0,0,'R');
|
||||
// tvq
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_tvq_facturation').' ('.number_format($mem_tax['TVQ']['taux'], 3, '.', ' ').'%) :' ,0,0,'L');
|
||||
$mem_tvq=($mem_total_tvq)*($mem_tax['TVQ']['taux']/100);
|
||||
$pdf->Cell(54,0,number_format( $mem_tvq, 2, '.', ' ').' $',0,0,'R');
|
||||
// tvh
|
||||
if ($mem_total_tvh<>0){
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_tvh_facturation').' ('.number_format($mem_tax['TVH']['taux'], 3, '.', ' ').'%) :' ,0,0,'L');
|
||||
$mem_tvh=($mem_total_tvh)*($mem_tax['TVH']['taux']/100);
|
||||
$pdf->Cell(54,0,number_format( $mem_tvh, 2, '.', ' ').' $',0,0,'R');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// total
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_total_facturation'),0,0,'L');
|
||||
$mem_total=$mem_sous_total+$mem_tvq+$mem_tps ;
|
||||
$pdf->Cell(54,0,number_format($mem_total, 2, '.', ' ').' $',0,0,'R');
|
||||
// depot
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_depot_facturation'),0,0,'L');
|
||||
|
||||
$pdf->Cell(54,0,number_format($mem_depot, 2, '.', ' ').' $',0,0,'R');
|
||||
// solde
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(131);
|
||||
$pdf->Cell(10,0,$this->langx('ent_solde_facturation'),0,0,'L');
|
||||
$mem_solde=$mem_total-$mem_depot;
|
||||
$pdf->Cell(54,0,number_format($mem_solde, 2, '.', ' ').' $',0,0,'R');
|
||||
// no taxe
|
||||
$pdf->SetY(-65);
|
||||
// tps
|
||||
$pdf->SetFont('Arial','',7);
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(10,0,$mem_tax['TPSNO']['note'] ,0,0,'L');
|
||||
|
||||
// tvq
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(10,0,$mem_tax['TVQNO']['note'] ,0,0,'L');
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(1);
|
||||
// $pdf->Output();
|
||||
$pdf->Rect(10,$pdf->GetY() ,190,20) ;
|
||||
$pdf->Ln(5);
|
||||
$pdf->Cell(5);
|
||||
$pdf->Cell(0,0,$this->langx('ent_note1_facturation') ,0,0,'L');
|
||||
$pdf->Ln(4);
|
||||
$pdf->Cell(5);
|
||||
$pdf->MultiCell(180,3,$this->langx('ent_note2_facturation') ,0,'L');
|
||||
$pdf->SetFont('Arial','',10);
|
||||
|
||||
$pdf->SetY(-25);
|
||||
$pdf->Cell(0,0,'Page '.$pdf->PageNo().'/{nb}',0,0,'C');
|
||||
$pdfdoc = $pdf->Output("", "S");
|
||||
|
||||
$mem_montant['det_fac_montant']=$mem_solde;
|
||||
$mem_montant['det_fac_tvq']=$mem_tvq;
|
||||
$mem_montant['det_fac_tps']=$mem_tps;
|
||||
$mem_montant['det_fac_tvh']=$mem_tvh;
|
||||
$mem_montant['det_fac_depot']=$mem_depot;
|
||||
$mem_montant['det_fac_avanttx']=$mem_sous_total;
|
||||
//$mem_montant['det_fac_opc']=$mem_opc;
|
||||
$mem_montant['det_fac_opc']=0;
|
||||
|
||||
$mem_montant['det_fac_opc_avant']=$mem_opc;
|
||||
$this->Lots_model->mod_modiflot_pdf_facturation_montant($mem_lot, $mem_montant);
|
||||
|
||||
|
||||
return $pdfdoc;
|
||||
|
||||
|
||||
}
|
||||
function langx($key){
|
||||
return utf8_decode($this->lang->line($key));
|
||||
|
||||
}
|
||||
function u($key){
|
||||
return utf8_decode(($key));
|
||||
|
||||
}
|
||||
}
|
||||
20
application/models/News_model.php
Normal file
20
application/models/News_model.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
class News_model extends CI_Model {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function get_news($slug = FALSE)
|
||||
{
|
||||
if ($slug === FALSE)
|
||||
{
|
||||
$query = $this->db->get('news');
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
$query = $this->db->get_where('news', array('slug' => $slug));
|
||||
return $query->row_array();
|
||||
}
|
||||
}
|
||||
886
application/models/Paiements_model.php
Normal file
886
application/models/Paiements_model.php
Normal file
@ -0,0 +1,886 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Paiements_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->helper('date');
|
||||
$this->load->model('Projets_model');
|
||||
|
||||
}
|
||||
public function mod_getRecords_paiements($facture)
|
||||
{
|
||||
|
||||
// list la bb client
|
||||
$this->db->select('*');
|
||||
$this->db->from('pai_paiements');
|
||||
$this->db->join('pai_genres', 'pai_genres.gen_id=pai_paiements.pai_gen_id', 'left');
|
||||
$this->db->join('usa_usagers', 'pai_paiements.pai_user = usa_usagers.usa_id ', 'left');
|
||||
|
||||
|
||||
//$this->db->where('det_con_active', 1);
|
||||
|
||||
|
||||
$this->db->where('pai_no_facture', $facture );
|
||||
|
||||
$this->db->order_by("pai_date");
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
public function mod_listpaiement($facture=0,$excel) {
|
||||
|
||||
|
||||
|
||||
// $recordCount = $this->Clients_model->getRecordCount();
|
||||
//$client_list=$this->Config_model->conf_getprojetsclients($record);
|
||||
$client_list=$this->mod_getRecords_paiements($facture);
|
||||
|
||||
// creation du tableau
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
// $mem_link_new='<button id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
$mem_link_new='';
|
||||
//$mem_link_projet=anchor('projets/createRecord/0/'.$record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-briefcase" ');
|
||||
$mem_link_projet='';
|
||||
$header=array(
|
||||
'',
|
||||
'Date',
|
||||
'Créer par',
|
||||
'Type',
|
||||
'note','Montant' );
|
||||
// prépare les donnés du tableau
|
||||
$nbitem=0;
|
||||
$mem_excel['excel']=array();
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit= '<a id="pk_1" data-facture="" data-id="'.$row['pai_id'].'" class="btn btn-primary btn-circle glyphicon glyphicon-pencil"> </a>';
|
||||
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left', 'width' => '2');
|
||||
$data_row[] = array('data'=>$row['pai_date'], 'align' => 'left', 'width' => '13%');
|
||||
$data_row[] = array('data'=>$row['usa_prenom'].''.$row['usa_nom'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['gen_nom_fr'], 'align' => 'left');
|
||||
|
||||
$data_row[] = array('data'=>$row['pai_note'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['pai_montant'], 'align' => 'left','format'=>'argent');
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
if($excel==2){
|
||||
$data_row_excel = array();
|
||||
|
||||
|
||||
$data_row_excel[] = array('data'=>'');
|
||||
$data_row_excel[] = array('data'=>'');
|
||||
$data_row_excel[] = array('data'=>'');
|
||||
$data_row_excel[] = array('data'=>'');
|
||||
$data_row_excel[] = array('data'=>'');
|
||||
$data_row_excel[] = array('data'=>'');
|
||||
|
||||
$data_row_excel[] = array('data'=>$row['pai_date'], 'align' => 'left', 'width' => '13%','color'=>'b3b3ff');
|
||||
// $data_row[] = array('data'=>$row['usa_prenom'].''.$row['usa_nom'], 'align' => 'left');
|
||||
|
||||
$data_row_excel[] = array('data'=>$row['gen_nom_fr'], 'align' => 'left','color'=>'b3b3ff');
|
||||
|
||||
$data_row_excel[] = array('data'=>$row['pai_note'], 'align' => 'left','color'=>'b3b3ff');
|
||||
$data_row_excel[] = array('data'=>number_format($row['pai_montant'],2,'.',''), 'align' => 'left','format'=>'argent','color'=>'b3b3ff');
|
||||
|
||||
$mem_excel['excel'][]=$data_row_excel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$data_row_excel = array();
|
||||
$data_row_excel[] = array('data'=>'');
|
||||
$mem_excel['excel'][]=$data_row_excel;
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th style="background-color: #003333">',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
|
||||
if(!isset($tabular_data))
|
||||
$tabular_data=array();
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
if($nbitem==0)
|
||||
$tableau_sortie='vide';
|
||||
|
||||
|
||||
$mem_sortie['tableau_sortie']=$tableau_sortie;
|
||||
$mem_sortie['excel']=$mem_excel['excel'];
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_loadData_list($record=0,$filtre1='',$filtre2='',$filtre3='',$date_debut="2019-01-01",$date_fin="2025-01-01", $listactif = 1, $model='',$excel) {
|
||||
|
||||
$filtre1=($filtre1=='null'?'':$filtre1);
|
||||
$filtre2=($filtre2=='null'?'':$filtre2);
|
||||
$filtre3=($filtre3=='null'?'':$filtre3);
|
||||
|
||||
$recordPerPage = 9999;
|
||||
|
||||
$config["cur_page"] = $record;
|
||||
if($record != 0){
|
||||
$record = ($record-1) * $recordPerPage;
|
||||
}
|
||||
|
||||
$recordCount2 = $this->Paiements_model->mod_getRecordCount();
|
||||
|
||||
$recordCount = $this->Paiements_model->mod_getRecordCountfilter($filtre1,$filtre2,$filtre3);
|
||||
|
||||
|
||||
|
||||
$client_list = $this->Paiements_model->mod_getRecords($record,$recordPerPage,$filtre1,$filtre2,$filtre3,$date_debut,$date_fin);
|
||||
|
||||
|
||||
//echo '<pre>', print_r($client_list, true), '</pre>';
|
||||
|
||||
$config['base_url'] = base_url().'index.php/Fournisseurs/loadData_list';
|
||||
$config['use_page_numbers'] = TRUE;
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Previous';
|
||||
$config['total_rows'] = $recordCount;
|
||||
$config['per_page'] = $recordPerPage;
|
||||
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["uri_segment"] = 2;
|
||||
$config["num_links"] = 2;
|
||||
$config['full_tag_open'] = '<div ><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></div><!--pagination-->';
|
||||
|
||||
$config['first_link'] = '« First';
|
||||
$config['first_tag_open'] = '<li class="prev page">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
|
||||
$config['last_link'] = 'Last »';
|
||||
$config['last_tag_open'] = '<li class="next page">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
|
||||
$config['next_link'] = 'Next →';
|
||||
$config['next_tag_open'] = '<li class="next page">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
|
||||
$config['prev_link'] = '← Previous';
|
||||
$config['prev_tag_open'] = '<li class="prev page">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
|
||||
$config['cur_tag_open'] = '<li class="active"><a href="">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
|
||||
$config['num_tag_open'] = '<li class="page">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$this->pagination->initialize($config);
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
$data['recordCount']=$recordCount2;
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
|
||||
// if ($model == 'projets'){ $mem_link_new='';
|
||||
// }else{
|
||||
$mem_link_new=anchor('fournisseurs/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||||
|
||||
// }
|
||||
$data['model']=$model;
|
||||
$mem_excel='<a id="excel" data-id="1" class="btn btn-primary btn-circle fa fa-cloud-download"> </a><a id="excel" data-id="2" class="btn btn-success btn-circle fa fa-cloud-download"> </a>';
|
||||
$header=array( $mem_excel,
|
||||
'No facture',
|
||||
'Compagnie',
|
||||
'No projet',
|
||||
'Nom projet',
|
||||
'Date facture',
|
||||
'$$$','','30','60','90','+' );
|
||||
|
||||
if ($excel!=0){
|
||||
$mem_excel_output['header']=array('Client','Date de facturation',
|
||||
'No. de facture',
|
||||
'No. de projet',
|
||||
'Total avant tx',
|
||||
'TPS',
|
||||
'TVQ',
|
||||
'TVH',
|
||||
'OPC',
|
||||
'Total',
|
||||
'Dépôt/paiement',
|
||||
'À recevoir','Nb jours','OPC avant');
|
||||
$mem_excel_output['headerwidth']=array(45,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
|
||||
}
|
||||
$nbitem=0;
|
||||
|
||||
|
||||
// filter
|
||||
global $mem_data;
|
||||
$data_row = array();
|
||||
$data_row[]=array('data'=>'Filtre', 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ='filtre_fournisseurs_1';
|
||||
// $mem_value=trim($filtre1);
|
||||
// $this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_1');
|
||||
|
||||
// $mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
// $data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='filtre_fournisseurs_1';
|
||||
$mem_value=trim($filtre1);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_1',7);
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='filtre_fournisseurs_2';
|
||||
$mem_value=trim($filtre2);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_2');
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// echo form_dropdown($mem_champ,$select[$mem_champ]['choix'],$select[$mem_champ]['value']);
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ='filtre_fournisseurs_3';
|
||||
$mem_value=trim($filtre3);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ,$mem_value,'','','','filtre_fournisseurs_3',4);
|
||||
$mem_filtre=form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[]=array('data'=>$mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
$data_row[]=array('data'=>'', 'align' => 'left');
|
||||
$data_row[]=array('data'=>'', 'align' => 'left');
|
||||
$data_row[]=array('data'=>'', 'align' => 'left');
|
||||
$data_row[]=array('data'=>'', 'align' => 'left');
|
||||
$data_row[]=array('data'=>'', 'align' => 'left');
|
||||
$data_row[]=array('data'=>'', 'align' => 'left');
|
||||
$data_row[]=array('data'=>'', 'align' => 'left');
|
||||
// prépare les donnés du tableau
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
|
||||
|
||||
$idmem=0;
|
||||
if ($client_list!=null){
|
||||
foreach($client_list as $row)
|
||||
{ $nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit="";
|
||||
$idmem=$idmem+1;
|
||||
// $mem_link_edit=anchor('fournisseurs/form/'.$row['com_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
$mem_link_edit = '<a id="pk_1" data-id="0" data-facture="'.$row['det_fac_numero'].'" class="btn btn-primary btn-circle glyphicon glyphicon-pencil"> </a>';
|
||||
|
||||
$mem_link_projet = anchor('projets/form/' . $row['proj_id'], ' ', array('class'=> 'btn btn-primary btn-circle glyphicon glyphicon-edit', 'target' => 'projet' ));
|
||||
|
||||
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_edit.$mem_link_projet, 'align' => 'left');
|
||||
// $data_row[] = array('data'=>$row['com_num_client'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['det_fac_numero'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['com_compagnie'], 'align' => 'left','width'=>15);
|
||||
$data_row[] = array('data'=>$row['proj_numero'], 'align' => 'left','width'=>3);
|
||||
// $data_row[] = array('data'=>$row['rep_prenom']." ".$row['rep_nom'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['proj_nom'], 'align' => 'left','width'=>200);
|
||||
$data_row[] = array('data'=>date("Y-m-d",strtotime($row['det_fac_envoi'])), 'align' => 'left');
|
||||
$data_row[] = array('data'=>number_format($row['det_fac_montant'],2,'.',' '), 'align' => 'left');
|
||||
|
||||
$mem_facture=' <a target="_blank" href="'. base_url().'/pdf/pdf2019/facturation/'. $row['det_fac_pdf'] .'" class="btn btn-primary btn-circle glyphicon glyphicon-list-alt"></a>';
|
||||
|
||||
|
||||
$data_row[] = array('data'=>$mem_facture, 'align' => 'left');
|
||||
|
||||
$bal=$row['det_fac_montant']-$row['tot_montant'];
|
||||
|
||||
if ($row['days']<=30 && $bal<>0){
|
||||
$data_row[] = array('data'=>number_format($bal,2,'.',' '), 'align' => 'left','class' => 'j30');
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
}
|
||||
if ($row['days']>30 && $row['days']<=60 && $bal<>0){
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>number_format($bal,2,'.',' '), 'align' => 'left','class' => 'j60');
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
}
|
||||
if ($row['days']>60 && $row['days']<=90 && $bal<>0){
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>number_format($bal,2,'.',' '), 'align' => 'left','class' => 'j90');
|
||||
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
}
|
||||
if ($row['days']>90 && $bal<>0){
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
$data_row[] = array('data'=>number_format($bal,2,'.',' '), 'align' => 'left','class' => 'jplus');
|
||||
|
||||
$data_row[] = array('data'=>'', 'align' => 'left');
|
||||
}
|
||||
// $data_row[] = array('data'=>$row['days'], 'align' => 'left');
|
||||
$tabular_data[] = $data_row;
|
||||
//print_r( $row);
|
||||
|
||||
$mem_projets=$this->mod_listpaiement($row['det_fac_numero'],$excel);
|
||||
|
||||
if ($excel!=0){
|
||||
$data_row_excel = array();
|
||||
$data_row_excel[] = array('data'=>$row['com_compagnie'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>date("Y-m-d",strtotime($row['det_fac_envoi'])), 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$row['det_fac_numero'], 'align' => 'left');
|
||||
$data_row_excel[] = array('data'=>$row['proj_numero'], 'align' => 'left','width'=>3);
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_avanttx'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
|
||||
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_tps'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_tvq'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_tvh'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_opc'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_montant'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_depot'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
|
||||
|
||||
$data_row_excel[] = array('data'=>number_format($bal,2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
if($bal<>0)
|
||||
$data_row_excel[] = array('data'=>$row['days'], 'align' => 'left','width'=>3);
|
||||
$data_row_excel[] = array('data'=>number_format($row['det_fac_opc_avant'],2,'.',''), 'align' => 'left','format'=>'argent');
|
||||
|
||||
$mem_excel_output['data'][]=$data_row_excel;
|
||||
|
||||
$mem_excel_output['data']=array_merge($mem_excel_output['data'],$mem_projets['excel']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($mem_projets['tableau_sortie']==='vide'){
|
||||
$mem_projets="";
|
||||
$expend="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$mem_projets='<div style="display:none" id="hide_'.$row['proj_id'].'_'. $idmem.'">'.$mem_projets['tableau_sortie'].'</div>';
|
||||
|
||||
$expend='<a id="bt_hide_'.$row['proj_id'].'_'. $idmem.'" data-id="hide_'.$row['proj_id'].'_'. $idmem.'" class="fa fa-fw fa-dot-circle-o"> </a>';
|
||||
|
||||
}
|
||||
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=>$expend );
|
||||
$data_row[] = array('data'=>$mem_projets,'colspan' => 6 );
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead>',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
$this->table->set_heading($header);
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie= $this->table->generate($tabular_data);
|
||||
|
||||
if ($excel!=0){
|
||||
//$mem_excel_output['data']=$tabular_data;
|
||||
|
||||
$data['fichier']="paiement.xls";
|
||||
$mem_excel_output['fichier']="paiement";
|
||||
// $mem_excel_output['titre']="depart du ".$debut.' @ '.$fin;
|
||||
$mem_excel_output['titre']="rapport en date du ".date("Y-m-d H:i");;
|
||||
$mem_parameter=array('premiere_ligne'=>0);
|
||||
|
||||
$this->Config_model->excel($mem_excel_output,$mem_parameter);
|
||||
}
|
||||
|
||||
$data['list'] = $tableau_sortie;
|
||||
|
||||
return $data ;
|
||||
}
|
||||
|
||||
public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "",$date_debut="2019-01-01",$date_fin="2025-01-01", $langue = 'fr')
|
||||
{
|
||||
|
||||
// $this->db->select('*,DATEDIFF( now(),det_fac_envoi) AS days,proj_entete.proj_client_id as cli_id,cli_contacts.con_prenom as cli_contact_prenom,cli_contacts.con_nom as cli_contact_nom,fou_contacts.con_courriel as fou_contact_courriel,fou_contacts.con_prenom as fou_contact_prenom,fou_contacts.con_nom as fou_contact_nom,cli_compte.com_compagnie as com_compagnie_client,fou_compte.com_compagnie as com_compagnie_fou,sum(pai_paiements.pai_montant) as tot_montant');
|
||||
$this->db->select('*,DATEDIFF( now(),det_fac_envoi) AS days,proj_entete.proj_client_id as cli_id,cli_contacts.con_prenom as cli_contact_prenom,cli_contacts.con_nom as cli_contact_nom,fou_contacts.con_courriel as fou_contact_courriel,fou_contacts.con_prenom as fou_contact_prenom,fou_contacts.con_nom as fou_contact_nom,cli_compte.com_compagnie as com_compagnie_client,fou_compte.com_compagnie as com_compagnie_fou');
|
||||
$this->db->from('proj_details_details');
|
||||
// $this->db->join('pai_paiements','pai_paiements.pai_no_facture=proj_details_details.det_fac_numero', 'left');
|
||||
$this->db->join('proj_details', 'proj_details.proj_det_id=proj_details_details.proj_det_id', 'left');
|
||||
$this->db->join('proj_entete', 'proj_entete.proj_id=proj_details.proj_ent_id', 'left');
|
||||
$this->db->join('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||||
$this->db->join('pro_descriptions', 'pro_descriptions.des_id=proj_details.proj_prod_id', 'left');
|
||||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||||
$this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id', 'left');
|
||||
$this->db->join('fou_contacts', 'fou_contacts.con_id=proj_details_details.det_res_contact_id', 'left');
|
||||
$this->db->join('cli_contacts', 'cli_contacts.con_id=proj_entete.proj_contact_principale', 'left');
|
||||
$this->db->group_by('det_fac_lot_numero');
|
||||
$this->db->where('det_fac_lock', 1);
|
||||
$this->db->where("det_fac_envoi between '".$date_debut." 00:00:00' and '".$date_fin." 23:59:00'");
|
||||
$this->db->order_by("proj_details_details.det_fac_numero");
|
||||
$this->db->order_by("proj_details_details.det_fac_montant desc");
|
||||
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("det_fac_numero LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("cli_compte.com_compagnie LIKE '%$filtre2%'");
|
||||
if ($filtre3 != "")
|
||||
$this->db->where("proj_numero LIKE '%$filtre3%'");
|
||||
|
||||
$this->db->limit($rowperpage, $rowno);
|
||||
|
||||
$query = $this->db->get();
|
||||
echo $this->db->last_query();
|
||||
$four = $query->result_array();
|
||||
// ajouter la liste des type
|
||||
$sortie = array();
|
||||
foreach ($four as $row){
|
||||
$this->db->select('sum(pai_paiements.pai_montant) as tot_montant');
|
||||
$this->db->from('pai_paiements');
|
||||
$this->db->where("pai_no_facture='".$row['det_fac_numero']."'");
|
||||
$query = $this->db->get();
|
||||
$montant = $query->result_array();
|
||||
$row['tot_montant']=$montant[0]['tot_montant'];
|
||||
$sortie[]=$row;
|
||||
}
|
||||
|
||||
|
||||
return $sortie;
|
||||
}
|
||||
|
||||
public function mod_getRecords_contacts($id, $langue = 'fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,fou_contacts_roles.rol_nom as role');
|
||||
$this->db->from('fou_contacts');
|
||||
$this->db->join('fou_contacts_roles', 'fou_contacts_roles.rol_id=fou_contacts.con_role_id', 'left');
|
||||
$this->db->where('fou_contacts.ref_id', $id);
|
||||
$this->db->where('fou_contacts.con_actif', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function mod_getRecord($id, $langue = 'fr')
|
||||
{
|
||||
// trouve un enregiestrement
|
||||
$this->db->select('*');
|
||||
$this->db->from('pai_paiements');
|
||||
$this->db->join('pai_genres', 'pai_genres.gen_id=pai_paiements.pai_gen_id', 'left');
|
||||
$this->db->join('usa_usagers', 'pai_paiements.pai_user = usa_usagers.usa_id ', 'left');
|
||||
|
||||
|
||||
$this->db->where('pai_id=' . $id);
|
||||
|
||||
$this->db->limit(1);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
public function mod_saveRecordbd($id, $data, $pref)
|
||||
{
|
||||
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data = array();
|
||||
// ajoute les checkbox
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif'] = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
switch ($key) {
|
||||
case 'com_ref_type':
|
||||
$mem_value = '';
|
||||
foreach ($data['com_ref_type'] as $key2 => $value2) {
|
||||
$mem_value = $mem_value . $value2 . ',';
|
||||
|
||||
}
|
||||
$mem_value = rtrim($mem_value, ",");
|
||||
$mem_data['com_ref_type'] = $mem_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_modif'] = date("Y-m-d H:i:s");
|
||||
$mem_where = "com_id =" . $id;
|
||||
|
||||
$str = $this->db->update('fou_compte', $mem_data, $mem_where);
|
||||
$ok = true;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function mod_createRecordbdcontact($data, $pref, $ref_id)
|
||||
{
|
||||
|
||||
|
||||
$mem_data = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['ref_id'] = $ref_id;
|
||||
$mem_data['con_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['con_actif'] = 1;
|
||||
|
||||
$str = $this->db->insert('fou_contacts', $mem_data);
|
||||
|
||||
$ok = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function mod_deleteRecordbdcontact($id)
|
||||
{
|
||||
|
||||
$mem_data['con_actif'] = 0;
|
||||
$mem_where = "con_id =" . $id;
|
||||
|
||||
$str = $this->db->update('fou_contacts', $mem_data, $mem_where);
|
||||
|
||||
|
||||
$ok = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function mod_getRecordCount()
|
||||
{
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('proj_details_details');
|
||||
$this->db->join('proj_details', 'proj_details.proj_det_id=proj_details_details.proj_det_id', 'left');
|
||||
$this->db->join('proj_entete', 'proj_entete.proj_id=proj_details.proj_ent_id', 'left');
|
||||
$this->db->join('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||||
$this->db->join('pro_descriptions', 'pro_descriptions.des_id=proj_details.proj_prod_id', 'left');
|
||||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||||
$this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id', 'left');
|
||||
$this->db->join('fou_contacts', 'fou_contacts.con_id=proj_details_details.det_res_contact_id', 'left');
|
||||
$this->db->join('cli_contacts', 'cli_contacts.con_id=proj_entete.proj_contact_principale', 'left');
|
||||
$this->db->group_by('det_fac_lot_numero');
|
||||
|
||||
$this->db->where('det_fac_lock', 1);
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "")
|
||||
{
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('proj_details_details');
|
||||
|
||||
$this->db->join('proj_details', 'proj_details.proj_det_id=proj_details_details.proj_det_id', 'left');
|
||||
$this->db->join('proj_entete', 'proj_entete.proj_id=proj_details.proj_ent_id', 'left');
|
||||
$this->db->join('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||||
$this->db->join('pro_descriptions', 'pro_descriptions.des_id=proj_details.proj_prod_id', 'left');
|
||||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||||
$this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id', 'left');
|
||||
$this->db->join('fou_contacts', 'fou_contacts.con_id=proj_details_details.det_res_contact_id', 'left');
|
||||
$this->db->join('cli_contacts', 'cli_contacts.con_id=proj_entete.proj_contact_principale', 'left');
|
||||
$this->db->group_by('det_fac_lot_numero');
|
||||
|
||||
$this->db->where('det_fac_lock', 1);
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_listcontact($record = 0)
|
||||
{
|
||||
|
||||
|
||||
// $recordCount = $this->Fournisseurs_model->getRecordCount();
|
||||
|
||||
$client_list = $this->mod_getRecords_contacts($record);
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
|
||||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
$mem_link_new = '<button id="submit_btn" type="submit" class="btn btn-primary btn-circle glyphicon glyphicon-plus"></button> ';
|
||||
|
||||
|
||||
$header=array('','Prénom',
|
||||
'Nom',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Téléphone bureau',
|
||||
'Ext',
|
||||
'<i class="fa fa-fw fa-phone text-muted hidden-md hidden-sm hidden-xs"></i>Cellulaire',
|
||||
'Courriel',
|
||||
'Role');
|
||||
// prépare les donnés du tableau
|
||||
$nbitem = 0;
|
||||
foreach ($client_list as $row) {
|
||||
$nbitem++;
|
||||
// faire le link pour edit
|
||||
$mem_link_edit = anchor('fournisseurs/deletecontact/' . $row['con_id'] . '/' . $record, ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-trash" ');
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
|
||||
$data_row[] = array('data'=> $mem_link_edit, 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['con_prenom'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['con_nom'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['con_telephone'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['con_ext'],'width'=>'5', 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['con_telephone2'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['con_courriel'], 'align' => 'left');
|
||||
$data_row[] = array('data'=>$row['role'], 'align' => 'left');
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
$data_row = array();
|
||||
$data_row[] = array('data'=> $mem_link_new);
|
||||
$data_row[] = array('data'=> form_input(array('name' => 'con_prenom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => 'con_nom','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => 'con_telephone','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => 'con_ext','size'=>5)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => 'con_telephone2','size'=>15)));
|
||||
$data_row[] = array('data'=> form_input(array('name' => 'con_courriel','size'=>15)));
|
||||
|
||||
$mem_choix = $this->Config_model->conf_getRolesContactsFournisseur();
|
||||
$mem_roles = form_dropdown('con_role_id', $mem_choix);
|
||||
|
||||
|
||||
$data_row[] = array('data' => $mem_roles, 'align' => 'left');
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead >',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie = $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
return $tableau_sortie;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_getforminfo($id)
|
||||
{
|
||||
global $mem_data, $validation;
|
||||
|
||||
$this->load->model('Config_model');
|
||||
$this->load->model('FxForm_model');
|
||||
// vas chercher les info de la fiche
|
||||
|
||||
if ($id != 0)
|
||||
$info = $this->mod_getRecord($id);
|
||||
|
||||
|
||||
// prepare info pour chaque champs utilisé
|
||||
// input
|
||||
$mem_data['mem_id'] = $id;
|
||||
$mem_champ = 'pai_montant';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Montant', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'pai_note';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Note', '');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'pai_date';
|
||||
|
||||
$mem_data['icon'][$mem_champ] = 'icon-append fa fa-calendar';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Date', '', '', '');
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'pai_gen_id';
|
||||
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresPaiement('fr');
|
||||
// value multipli select
|
||||
$mem_value = explode(',', $mem_value);
|
||||
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Type';
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_data['validation'] = $this->FxForm_model->fxValidation($validation['rule'], $validation['message']);
|
||||
|
||||
|
||||
return $mem_data;
|
||||
}
|
||||
public function mod_selectcontact($fournisseur_id,$langue='fr',$choix_vide=true)
|
||||
{
|
||||
|
||||
|
||||
$contacts=$this->Fournisseurs_model->mod_getRecords_contacts($fournisseur_id);
|
||||
// list la bb client
|
||||
|
||||
|
||||
$mem_sortie=array();
|
||||
if ($choix_vide)
|
||||
$mem_sortie[0]='';
|
||||
foreach ($contacts as $pro ){
|
||||
$mem_sortie[$pro['con_id']]=$pro['con_prenom']." ".$pro['con_nom']." (".$pro['rol_nom'].")";
|
||||
|
||||
}
|
||||
return $mem_sortie;
|
||||
|
||||
|
||||
}
|
||||
public function mod_createRecordbd($data, $pref, $id,$no_facture)
|
||||
{
|
||||
|
||||
|
||||
// creation de la chaine de save
|
||||
|
||||
$mem_data = array();
|
||||
|
||||
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($id == 0) {
|
||||
$mem_data['pai_user'] =$this->session->id ;
|
||||
$mem_data['pai_no_facture'] =$no_facture;
|
||||
|
||||
$str = $this->db->insert('pai_paiements', $mem_data);
|
||||
} else {
|
||||
$mem_where = "pai_id =" . $id;
|
||||
|
||||
$str = $this->db->update('pai_paiements', $mem_data, $mem_where);
|
||||
|
||||
}
|
||||
$ok = true;
|
||||
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
}
|
||||
489
application/models/Produits_model.php
Normal file
489
application/models/Produits_model.php
Normal file
@ -0,0 +1,489 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class Produits_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->helper('date');
|
||||
$this->load->model('FxForm_model');
|
||||
$this->load->model('Config_model');
|
||||
|
||||
}
|
||||
|
||||
public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif = 1, $langue = 'fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*,fou_genres.gen_nom_' . $langue . ' as type ');
|
||||
$this->db->from('pro_descriptions');
|
||||
|
||||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||||
$this->db->where('des_actif', $listactif);
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("des_nom_fr LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("des_description_fr LIKE '%$filtre2%'");
|
||||
if ($filtre3 != "")
|
||||
$this->db->where("des_ref_type = " . $filtre3);
|
||||
|
||||
|
||||
$this->db->limit($rowperpage, $rowno);
|
||||
$this->db->order_by("des_nom_fr");
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif)
|
||||
{
|
||||
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('pro_descriptions');
|
||||
|
||||
$this->db->where('des_actif', $listactif);
|
||||
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("des_nom_fr LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("des_description_fr LIKE '%$filtre2%'");
|
||||
if ($filtre3 != "")
|
||||
$this->db->where("des_ref_type = " . $filtre3);
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_getRecord($id, $langue = 'fr')
|
||||
{
|
||||
// trouve un enregiestrement
|
||||
$this->db->select('*');
|
||||
$this->db->from('pro_descriptions');
|
||||
$this->db->where('des_id=' . $id);
|
||||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||||
|
||||
$this->db->limit(1);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
public function mod_saveRecordbd($id, $data, $pref)
|
||||
{
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data = array();
|
||||
// ajoute les checkbox
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif'] = 0;
|
||||
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_modif'] = date("Y-m-d H:i:s");
|
||||
$mem_where = "com_id =" . $id;
|
||||
|
||||
$str = $this->db->update('cli_compte', $mem_data, $mem_where);
|
||||
$ok = true;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
public function mod_desactivateRecordbd($id, $statut)
|
||||
{
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data = array();
|
||||
|
||||
$mem_data['des_actif'] = $statut;
|
||||
|
||||
$mem_where = "des_id =" . $id;
|
||||
|
||||
$str = $this->db->update('pro_descriptions', $mem_data, $mem_where);
|
||||
$ok = true;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
public function mod_createRecordbd($data, $pref, $id)
|
||||
{
|
||||
|
||||
|
||||
// creation de la chaine de save
|
||||
|
||||
$mem_data = array();
|
||||
|
||||
if (!isset($data['des_tps']))
|
||||
$data['des_tps']=0;
|
||||
if (!isset($data['des_tvq']))
|
||||
$data['des_tvq']=0;
|
||||
if (!isset($data['des_tvh']))
|
||||
$data['des_tvh']=0;
|
||||
if (!isset($data['des_opc']))
|
||||
$data['des_opc']=0;
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($id == 0) {
|
||||
$mem_data['des_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['des_actif'] = 1;
|
||||
$str = $this->db->insert('pro_descriptions', $mem_data);
|
||||
} else {
|
||||
$mem_where = "des_id =" . $id;
|
||||
|
||||
$str = $this->db->update('pro_descriptions', $mem_data, $mem_where);
|
||||
|
||||
}
|
||||
$ok = true;
|
||||
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
|
||||
public function mod_getRecordCount()
|
||||
{
|
||||
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('pro_descriptions');
|
||||
$this->db->where('des_actif', 1);
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_getforminfo($id)
|
||||
{
|
||||
global $mem_data, $validation;
|
||||
|
||||
$this->load->model('Config_model');
|
||||
$this->load->model('FxForm_model');
|
||||
// vas chercher les info de la fiche
|
||||
|
||||
if ($id != 0)
|
||||
$info = $this->mod_getRecord($id);
|
||||
|
||||
// prepare info pour chaque champs utilisé
|
||||
// input
|
||||
$mem_data['mem_id'] = $id;
|
||||
$mem_champ = 'des_nom_fr';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Nom Produit', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'des_nom_en';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Nom Produit', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'des_description_fr';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Description', '');
|
||||
//$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'des_note';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Note', '');
|
||||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ = 'des_description_en';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Description', '');
|
||||
//$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'des_ref_type';
|
||||
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresFournisseur('fr', true, 1);
|
||||
// value multipli select
|
||||
// $mem_value = explode(',', $mem_value);
|
||||
|
||||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||||
$mem_data['label'][$mem_champ] = 'Type';
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ='des_tps';
|
||||
$mem_value=($id==0 ? true : ($info->$mem_champ==1 ? true:false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'TPS';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ='des_tvq';
|
||||
$mem_value=($id==0 ? true : ($info->$mem_champ==1 ? true:false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'TVQ';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ='des_tvh';
|
||||
$mem_value=($id==0 ? true : ($info->$mem_champ==1 ? true:false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'TVH';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_champ='des_opc';
|
||||
$mem_value=($id==0 ? true : ($info->$mem_champ==1 ? true:false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'OPC';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_data['validation'] = $this->FxForm_model->fxValidation($validation['rule'], $validation['message']);
|
||||
|
||||
|
||||
return $mem_data;
|
||||
}
|
||||
|
||||
public function mod_loadData_list($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $listactif = 1, $model_de_produits)
|
||||
{
|
||||
$filtre1 = ($filtre1 == 'null' ? '' : $filtre1);
|
||||
$filtre2 = ($filtre2 == 'null' ? '' : $filtre2);
|
||||
$filtre3 = ($filtre3 == 'null' ? '' : $filtre3);
|
||||
|
||||
if ($model_de_produits == "liste")
|
||||
$recordPerPage = 10;
|
||||
else
|
||||
$recordPerPage = 5;
|
||||
$config["cur_page"] = $record;
|
||||
if ($record != 0) {
|
||||
$record = ($record - 1) * $recordPerPage;
|
||||
}
|
||||
|
||||
$recordCount2 = $this->mod_getRecordCount();
|
||||
$recordCount = $this->mod_getRecordCountfilter($filtre1, $filtre2, $filtre3, $listactif);
|
||||
|
||||
$client_list = $this->mod_getRecords($record, $recordPerPage, $filtre1, $filtre2, $filtre3, $listactif);
|
||||
|
||||
$config['base_url'] = base_url() . 'index.php/Produits/loadData_list';
|
||||
$config['use_page_numbers'] = TRUE;
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Previous';
|
||||
$config['total_rows'] = $recordCount;
|
||||
$config['per_page'] = $recordPerPage;
|
||||
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["uri_segment"] = 2;
|
||||
$config["num_links"] = 2;
|
||||
$config['full_tag_open'] = '<div ><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></div><!--pagination-->';
|
||||
|
||||
$config['first_link'] = '« First';
|
||||
$config['first_tag_open'] = '<li class="prev page">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
|
||||
$config['last_link'] = 'Last »';
|
||||
$config['last_tag_open'] = '<li class="next page">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
|
||||
$config['next_link'] = 'Next →';
|
||||
$config['next_tag_open'] = '<li class="next page">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
|
||||
$config['prev_link'] = '← Previous';
|
||||
$config['prev_tag_open'] = '<li class="prev page">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
|
||||
$config['cur_tag_open'] = '<li class="active"><a href="">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
|
||||
$config['num_tag_open'] = '<li class="page">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$this->pagination->initialize($config);
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
$data['recordCount'] = $recordCount2;
|
||||
|
||||
// switch voir delete
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
$mem_link_new = "";
|
||||
if ($model_de_produits == "liste")
|
||||
$mem_link_new = '<a id="pk_1" data-id="0" class="btn btn-primary btn-circle glyphicon glyphicon-pencil"> </a>';
|
||||
//$mem_link_new=anchor('Produits/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||||
$header = array($mem_link_new, 'Nom',
|
||||
'Description',
|
||||
'Type');
|
||||
// prépare les donnés du tableau
|
||||
$nbitem = 0;
|
||||
|
||||
// filter
|
||||
global $mem_data;
|
||||
$data_row = array();
|
||||
$data_row[] = array('data' => 'Filtre', 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'filtre_produits_1';
|
||||
$mem_value = $filtre1;
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_1');
|
||||
|
||||
$mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'filtre_produits_2';
|
||||
$mem_value = $filtre2;
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_2');
|
||||
$mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'filtre_produits_3';
|
||||
$mem_value = $filtre3;
|
||||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresFournisseur('fr', true, 1);
|
||||
// value multipli select
|
||||
//$mem_value = explode(',', $mem_value);
|
||||
$mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_produits_3"');
|
||||
|
||||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
|
||||
// echo form_dropdown($mem_champ,$select[$mem_champ]['choix'],$select[$mem_champ]['value']);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
// prépare les donnés du tableau
|
||||
|
||||
|
||||
foreach ($client_list as $row) {
|
||||
$nbitem++;
|
||||
if($model_de_produits=="liste"){
|
||||
// faire le link pour delete
|
||||
if ($row['des_actif'] == 1) {
|
||||
// faire le link pour edit
|
||||
$mem_link_edit = '<a id="pk_1" data-id="' . $row['des_id'] . '" class="btn btn-primary btn-circle glyphicon glyphicon-pencil"> </a>';
|
||||
|
||||
$mem_link_delete = anchor('Produits/desactivate/' . $row['des_id'] . '/0', ' ', 'class="btn btn-danger btn-circle glyphicon glyphicon-trash " ');
|
||||
}
|
||||
else
|
||||
{
|
||||
$mem_link_edit = '';
|
||||
$mem_link_delete = anchor('Produits/desactivate/' . $row['des_id'] . '/1', ' ', 'class="btn btn-success btn-circle glyphicon glyphicon-thumbs-up " ');
|
||||
}
|
||||
}else{
|
||||
// $mem_link_edit = anchor('Projets/choix_produit/' . $row['des_id'] , ' ', 'class="btn btn-success btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
$databtn = array(
|
||||
'name' => 'button',
|
||||
'id' => 'button',
|
||||
'value' => $row['des_id'],
|
||||
'class' => 'btn btn-success btn-circle glyphicon glyphicon-plus-sign'
|
||||
);
|
||||
$mem_link_edit =form_button($databtn);
|
||||
|
||||
$mem_link_delete = '';
|
||||
|
||||
}
|
||||
// $mem_link_edit='<a id="pk_'.$row['des_id'].'" data-id="1" class="btn btn-primary btn-circle glyphicon glyphicon-edit"> </a>';
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
$data_row[] = array('data' => $mem_link_edit . ' ' . $mem_link_delete, 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['des_nom_fr'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['des_description_fr'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['type'], 'align' => 'left');
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead>',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie = $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
$data['list'] = $tableau_sortie;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2875
application/models/Projets_model.php
Normal file
2875
application/models/Projets_model.php
Normal file
File diff suppressed because it is too large
Load Diff
1090
application/models/Tache_model.php
Normal file
1090
application/models/Tache_model.php
Normal file
File diff suppressed because it is too large
Load Diff
1317
application/models/TachesProjets_model.php
Normal file
1317
application/models/TachesProjets_model.php
Normal file
File diff suppressed because it is too large
Load Diff
426
application/models/User_model.php
Normal file
426
application/models/User_model.php
Normal file
@ -0,0 +1,426 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Utilisateur
|
||||
* Date: 2019-04-23
|
||||
* Time: 10:21
|
||||
*/
|
||||
class User_model extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->load->database();
|
||||
$this->load->helper('date');
|
||||
$this->load->model('FxForm_model');
|
||||
$this->load->model('Config_model');
|
||||
|
||||
}
|
||||
|
||||
public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif = 1, $langue = 'fr')
|
||||
{
|
||||
// list la bb client
|
||||
$this->db->select('*');
|
||||
$this->db->from('usa_usagers');
|
||||
|
||||
$this->db->where('usa_actif', $listactif);
|
||||
// if ($filtre1 != "")
|
||||
// $this->db->where("des_nom_fr LIKE '%$filtre1%'");
|
||||
// if ($filtre2 != "")
|
||||
// $this->db->where("des_description_fr LIKE '%$filtre2%'");
|
||||
// if ($filtre3 != "")
|
||||
// $this->db->where("des_ref_type = " . $filtre3);
|
||||
|
||||
|
||||
$this->db->limit($rowperpage, $rowno);
|
||||
$this->db->order_by("usa_nom");
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif)
|
||||
{
|
||||
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('pro_descriptions');
|
||||
|
||||
$this->db->where('des_actif', $listactif);
|
||||
|
||||
if ($filtre1 != "")
|
||||
$this->db->where("des_nom_fr LIKE '%$filtre1%'");
|
||||
if ($filtre2 != "")
|
||||
$this->db->where("des_description_fr LIKE '%$filtre2%'");
|
||||
if ($filtre3 != "")
|
||||
$this->db->where("des_ref_type = " . $filtre3);
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mod_getRecord($id, $langue = 'fr')
|
||||
{
|
||||
// trouve un enregiestrement
|
||||
$this->db->select('*');
|
||||
$this->db->from('usa_usagers');
|
||||
$this->db->where('usa_id=' . $id);
|
||||
|
||||
$this->db->limit(1);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
public function mod_saveRecordbd($id, $data, $pref)
|
||||
{
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data = array();
|
||||
// ajoute les checkbox
|
||||
if (!isset($data['com_actif']))
|
||||
$data['com_actif'] = 0;
|
||||
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
$mem_data['com_modif'] = date("Y-m-d H:i:s");
|
||||
$mem_where = "com_id =" . $id;
|
||||
|
||||
$str = $this->db->update('cli_compte', $mem_data, $mem_where);
|
||||
$ok = true;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
public function mod_desactivateRecordbd($id, $statut)
|
||||
{
|
||||
|
||||
// creation de la chaine de save
|
||||
$mem_data = array();
|
||||
|
||||
$mem_data['usa_actif'] = $statut;
|
||||
|
||||
$mem_where = "usa_id =" . $id;
|
||||
|
||||
$str = $this->db->update('usa_usagers', $mem_data, $mem_where);
|
||||
$ok = true;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
public function mod_createRecordbd($data, $pref, $id)
|
||||
{
|
||||
|
||||
|
||||
// creation de la chaine de save
|
||||
|
||||
$mem_data = array();
|
||||
|
||||
if (!isset($data['usa_representant']))
|
||||
$data['des_tps']=0;
|
||||
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||||
$mem_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($id == 0) {
|
||||
if ($mem_data['usa_login']!=""){
|
||||
$mem_data['usa_creation'] = date("Y-m-d H:i:s");
|
||||
$mem_data['usa_actif'] = 1;
|
||||
$str = $this->db->insert('usa_usagers', $mem_data);}
|
||||
} else {
|
||||
$mem_where = "usa_id =" . $id;
|
||||
|
||||
$str = $this->db->update('usa_usagers', $mem_data, $mem_where);
|
||||
|
||||
}
|
||||
$ok = true;
|
||||
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
|
||||
public function mod_getRecordCount()
|
||||
{
|
||||
|
||||
$this->db->select('count(*) as allcount');
|
||||
$this->db->from('pro_descriptions');
|
||||
$this->db->where('des_actif', 1);
|
||||
$query = $this->db->get();
|
||||
$result = $query->result_array();
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function mod_getforminfo($id)
|
||||
{
|
||||
global $mem_data, $validation;
|
||||
|
||||
$this->load->model('Config_model');
|
||||
$this->load->model('FxForm_model');
|
||||
// vas chercher les info de la fiche
|
||||
|
||||
if ($id != 0)
|
||||
$info = $this->mod_getRecord($id);
|
||||
|
||||
// prepare info pour chaque champs utilisé
|
||||
// input
|
||||
$mem_data['mem_id'] = $id;
|
||||
$mem_champ = 'usa_prenom';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Prénom', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'usa_nom';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Nom', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'usa_login';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Login', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'usa_password';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Mot de passe', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
// -------------------------------------------------------------------------
|
||||
$mem_champ = 'usa_telephone';
|
||||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Téléphone', '');
|
||||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||||
|
||||
|
||||
$mem_champ='usa_representant';
|
||||
$mem_value=($id==0 ? true : ($info->$mem_champ==1 ? true:false));
|
||||
|
||||
$mem_data['checkbox'][$mem_champ] = array(
|
||||
|
||||
'name' => $mem_champ,
|
||||
'value' => 1,
|
||||
'checked' => $mem_value,
|
||||
);
|
||||
$mem_data['label'][$mem_champ] = 'Répresentant';
|
||||
$mem_data['icon'][$mem_champ] = ' ';
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
$mem_data['validation'] = $this->FxForm_model->fxValidation($validation['rule'], $validation['message']);
|
||||
|
||||
|
||||
return $mem_data;
|
||||
}
|
||||
|
||||
public function mod_loadData_list($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $listactif = 1, $model_de_produits)
|
||||
{
|
||||
$filtre1 = ($filtre1 == 'null' ? '' : $filtre1);
|
||||
$filtre2 = ($filtre2 == 'null' ? '' : $filtre2);
|
||||
$filtre3 = ($filtre3 == 'null' ? '' : $filtre3);
|
||||
|
||||
if ($model_de_produits == "liste")
|
||||
$recordPerPage = 50;
|
||||
else
|
||||
$recordPerPage = 5;
|
||||
$config["cur_page"] = $record;
|
||||
if ($record != 0) {
|
||||
$record = ($record - 1) * $recordPerPage;
|
||||
}
|
||||
|
||||
$recordCount2 = $this->mod_getRecordCount();
|
||||
$recordCount = $this->mod_getRecordCountfilter($filtre1, $filtre2, $filtre3, $listactif);
|
||||
|
||||
$client_list = $this->mod_getRecords($record, $recordPerPage, $filtre1, $filtre2, $filtre3, $listactif);
|
||||
|
||||
$config['base_url'] = base_url() . 'index.php/Produits/loadData_list';
|
||||
$config['use_page_numbers'] = TRUE;
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Previous';
|
||||
//$config['total_rows'] = $recordCount;
|
||||
$config['total_rows'] = 1;
|
||||
$config['per_page'] = $recordPerPage;
|
||||
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["uri_segment"] = 2;
|
||||
$config["num_links"] = 2;
|
||||
$config['full_tag_open'] = '<div ><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></div><!--pagination-->';
|
||||
|
||||
$config['first_link'] = '« First';
|
||||
$config['first_tag_open'] = '<li class="prev page">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
|
||||
$config['last_link'] = 'Last »';
|
||||
$config['last_tag_open'] = '<li class="next page">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
|
||||
$config['next_link'] = 'Next →';
|
||||
$config['next_tag_open'] = '<li class="next page">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
|
||||
$config['prev_link'] = '← Previous';
|
||||
$config['prev_tag_open'] = '<li class="prev page">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
|
||||
$config['cur_tag_open'] = '<li class="active"><a href="">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
|
||||
$config['num_tag_open'] = '<li class="page">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$this->pagination->initialize($config);
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
$data['recordCount'] = $recordCount2;
|
||||
|
||||
// switch voir delete
|
||||
|
||||
|
||||
// creation du tableau
|
||||
|
||||
|
||||
// prepare header
|
||||
$mem_link_new = "";
|
||||
if ($model_de_produits == "liste")
|
||||
$mem_link_new = '<a id="pk_1" data-id="0" class="btn btn-primary btn-circle glyphicon glyphicon-pencil"> </a>';
|
||||
//$mem_link_new=anchor('Produits/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||||
$header = array($mem_link_new, 'Nom','Prénom',
|
||||
'Téléphone' );
|
||||
// prépare les donnés du tableau
|
||||
$nbitem = 0;
|
||||
|
||||
// filter
|
||||
global $mem_data;
|
||||
$data_row = array();
|
||||
// $data_row[] = array('data' => 'Filtre', 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ = 'filtre_produits_1';
|
||||
// $mem_value = $filtre1;
|
||||
// $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_1');
|
||||
|
||||
// $mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||||
// $data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ = 'filtre_produits_2';
|
||||
// $mem_value = $filtre2;
|
||||
// $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_2');
|
||||
// $mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||||
// $data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// $mem_champ = 'filtre_produits_3';
|
||||
// $mem_value = $filtre3;
|
||||
// $mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresFournisseur('fr', true, 1);
|
||||
// value multipli select
|
||||
//$mem_value = explode(',', $mem_value);
|
||||
// $mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_produits_3"');
|
||||
|
||||
// $data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||||
|
||||
// echo form_dropdown($mem_champ,$select[$mem_champ]['choix'],$select[$mem_champ]['value']);
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
// prépare les donnés du tableau
|
||||
|
||||
|
||||
foreach ($client_list as $row) {
|
||||
$nbitem++;
|
||||
if($model_de_produits=="liste"){
|
||||
// faire le link pour delete
|
||||
if ($row['usa_actif'] == 1) {
|
||||
// faire le link pour edit
|
||||
$mem_link_edit = '<a id="pk_1" data-id="' . $row['usa_id'] . '" class="btn btn-primary btn-circle glyphicon glyphicon-pencil"> </a>';
|
||||
|
||||
$mem_link_delete = anchor('user/desactivate/' . $row['usa_id'] . '/0', ' ', 'class="btn btn-danger btn-circle glyphicon glyphicon-trash " ');
|
||||
}
|
||||
else
|
||||
{
|
||||
$mem_link_edit = '';
|
||||
$mem_link_delete = anchor('user/desactivate/' . $row['usa_id'] . '/1', ' ', 'class="btn btn-success btn-circle glyphicon glyphicon-thumbs-up " ');
|
||||
}
|
||||
}else{
|
||||
// $mem_link_edit = anchor('Projets/choix_produit/' . $row['des_id'] , ' ', 'class="btn btn-success btn-circle glyphicon glyphicon-plus-sign" ');
|
||||
|
||||
$databtn = array(
|
||||
'name' => 'button',
|
||||
'id' => 'button',
|
||||
'value' => $row['usa_id'],
|
||||
'class' => 'btn btn-success btn-circle glyphicon glyphicon-plus-sign'
|
||||
);
|
||||
$mem_link_edit =form_button($databtn);
|
||||
|
||||
$mem_link_delete = '';
|
||||
|
||||
}
|
||||
// $mem_link_edit='<a id="pk_'.$row['des_id'].'" data-id="1" class="btn btn-primary btn-circle glyphicon glyphicon-edit"> </a>';
|
||||
// <a href="javascript:void(0);" class="btn btn-primary btn-circle"><i ></i></a> ';
|
||||
$data_row = array();
|
||||
$data_row[] = array('data' => $mem_link_edit . ' ' . $mem_link_delete, 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['usa_nom'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['usa_prenom'], 'align' => 'left');
|
||||
$data_row[] = array('data' => $row['usa_telephone'], 'align' => 'left');
|
||||
|
||||
|
||||
$tabular_data[] = $data_row;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$template = array(
|
||||
'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="table table-striped table-bordered table-hover">',
|
||||
|
||||
'thead_open' => '<thead>',
|
||||
'thead_close' => '</thead>',
|
||||
|
||||
'heading_row_start' => '<tr>',
|
||||
'heading_row_end' => '</tr>',
|
||||
'heading_cell_start' => '<th>',
|
||||
'heading_cell_end' => '</th>',
|
||||
|
||||
'tbody_open' => '<tbody>',
|
||||
'tbody_close' => '</tbody>',
|
||||
|
||||
'row_start' => '<tr>',
|
||||
'row_end' => '</tr>',
|
||||
'cell_start' => '<td>',
|
||||
'cell_end' => '</td>',
|
||||
|
||||
'row_alt_start' => '<tr>',
|
||||
'row_alt_end' => '</tr>',
|
||||
'cell_alt_start' => '<td>',
|
||||
'cell_alt_end' => '</td>',
|
||||
|
||||
'table_close' => '</table>'
|
||||
);
|
||||
|
||||
$this->table->set_template($template);
|
||||
|
||||
$this->table->set_heading($header);
|
||||
$tableau_sortie = $this->table->generate($tabular_data);
|
||||
|
||||
|
||||
$data['list'] = $tableau_sortie;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
application/models/index.html
Normal file
11
application/models/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user