960 lines
36 KiB
PHP
960 lines
36 KiB
PHP
<?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;
|
|
|
|
|
|
}
|
|
|
|
} |