2876 lines
122 KiB
PHP
2876 lines
122 KiB
PHP
<?php
|
||
|
||
/**
|
||
* Created by PhpStorm.
|
||
* User: Utilisateur
|
||
* Date: 2019-04-23
|
||
* Time: 10:21
|
||
*/
|
||
class Projets_model extends CI_Model
|
||
{
|
||
|
||
public function __construct()
|
||
{
|
||
$this->load->database();
|
||
$this->load->helper('date');
|
||
$this->load->model('FxForm_model');
|
||
$this->load->model('Lots_pdf_model');
|
||
$this->load->model('Clients_model');
|
||
|
||
|
||
}
|
||
|
||
public function mod_loadData_list($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $filtre4 = '', $trie = '', $listactive = 1, $excel = 0, $filtre5 = '', $date_debut, $date_fin, $filtre6 = '')
|
||
{
|
||
|
||
|
||
$filtre1 = ($filtre1 == 'null' ? '' : $filtre1);
|
||
$filtre2 = ($filtre2 == 'null' ? '' : $filtre2);
|
||
$filtre3 = ($filtre3 == 'null' ? '' : $filtre3);
|
||
$filtre4 = ($filtre4 == 'null' ? '' : $filtre4);
|
||
$filtre5 = ($filtre5 == 'null' ? '' : $filtre5);
|
||
$filtre6 = ($filtre6 == 'null' ? '' : $filtre6);
|
||
|
||
$recordPerPage = 500;
|
||
$config["cur_page"] = $record;
|
||
if ($record != 0) {
|
||
$record = ($record - 1) * $recordPerPage;
|
||
}
|
||
|
||
$recordCount2 = $this->mod_getRecordCount();
|
||
$recordCount2 = 0;
|
||
$recordCount = $this->mod_getRecordCountfilter($filtre1, $filtre2, $filtre3, $filtre4, $listactive);
|
||
|
||
$client_list = $this->mod_getRecords($record, $recordPerPage, $filtre1, $filtre2, $filtre3, $filtre4, $trie, $listactive, $filtre5, $date_debut, $date_fin, $langue = 'fr', $hebergement = 2, $filtre6);
|
||
|
||
$config['base_url'] = base_url() . 'index.php/Projets/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
|
||
|
||
|
||
$etape = $this->lang->line('txt_Type');
|
||
$destination = $this->lang->line('txt_Destination');
|
||
$destination2 = $this->lang->line('txt_Destination2');
|
||
$dateannulation = $this->lang->line('txt_Date_annulation');
|
||
//$mem_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||
$header = array('', 'Compagnie', $etape, $destination, $destination2 . " ", $dateannulation . " ", 'Nom', 'Num.',
|
||
'Représentant',
|
||
'Contact',
|
||
|
||
'Date début', 'Confirmation', '$$$');
|
||
|
||
|
||
if ($excel == 1) {
|
||
$mem_excel_output['header'] = array('', 'Compagnie', $etape, 'Nom', 'Num.', 'Représentant',
|
||
'Date début', 'contact', 'date annulation', 'date confirmation', 'destination', 'type', 'Héber.', '$$$');
|
||
$mem_excel_output['headerwidth'] = array(5, 50, 15, 40, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30);
|
||
|
||
}
|
||
|
||
|
||
$nbitem = 0;
|
||
|
||
// filter
|
||
global $mem_data;
|
||
$data_row = array();
|
||
$mem_excel = '<a id="excel" data-id="1" class="btn btn-primary btn-circle fa fa-cloud-download"> </a>';
|
||
|
||
$data_row[] = array('data' => $mem_excel . '<a id="trie" data-id="null" class="btn btn-info btn-circle fa fa-mail-reply-all"> </a>Tri', 'align' => 'left');
|
||
// -------------------------------------------------------------------------
|
||
$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');
|
||
// -------------------------------------------------------------------------
|
||
|
||
|
||
$mem_champ = 'filtre_3';
|
||
$mem_value = $filtre3;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet('a', 'fr', true);
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
|
||
// $mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresTache('fr',false);
|
||
|
||
$mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_3"');
|
||
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
// -------------------------------------------------------------------------
|
||
|
||
|
||
$mem_champ = 'filtre_5';
|
||
$mem_value = $filtre5;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet('b', '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_5"');
|
||
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
// -------------------------------------------------------------------------
|
||
// if($this->config->item('pw_client')=="ms1") {
|
||
// $data_row[] = array('data' => "", 'align' => 'left');
|
||
// }else{
|
||
$mem_champ = 'filtre_4';
|
||
$mem_value = $filtre4;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet('c', 'fr', true);
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
|
||
// $mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresTache('fr',false);
|
||
|
||
$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');
|
||
//}
|
||
$data_row[] = array('data' => "", 'align' => 'left');
|
||
$data_row[] = array('data' => "", 'align' => 'left');
|
||
|
||
|
||
// if($this->config->item('pw_client')=="ms1") {
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'filtre_6';
|
||
$mem_value = $filtre6;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_6', 3);
|
||
$mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
// -------------------------------------------------------------------------
|
||
// }else{
|
||
// $data_row[] = array('data' => "", 'align' => 'left');
|
||
// }
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
|
||
$mem_champ = 'filtre_1';
|
||
$mem_value = $filtre1;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getRepresentantsClient();
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
$mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_1"');
|
||
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => "", 'align' => 'left');
|
||
// -------------------------------------------------------------------------
|
||
$mem_data = '<a id="trie" data-id="proj_date_debut" class="btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"><a id="trie" data-id="proj_date_debut desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
$data_row[] = array('data' => $mem_data, 'align' => 'left', 'width' => '90');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_data = '<a id="trie" data-id="proj_date_confirmation" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a><a id="trie" data-id="proj_date_confirmation desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
$data_row[] = array('data' => $mem_data, 'align' => 'left');
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_data = '<a id="trie" data-id="null" class="btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a> ';
|
||
$data_row[] = array('data' => $mem_data, 'align' => 'left', 'width' => '90');
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
$tabular_data[] = $data_row;
|
||
$mem_total = 0;
|
||
|
||
|
||
// echo '<pre>';
|
||
// print_r($client_list);
|
||
// echo '</pre>';
|
||
|
||
foreach ($client_list as $row) {
|
||
$nbitem++;
|
||
// faire le link pour edit
|
||
$mem_link_edit = anchor('projets/form/' . $row['proj_id'], ' ', array('class' => 'btn btn-primary btn-circle glyphicon glyphicon-edit', 'target' => '_blank'));
|
||
// <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['compagnie'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['etape'], 'align' => 'left', 'class' => 'statut_' . $row['proj_etape']);
|
||
$data_row[] = array('data' => $row['type'], 'align' => 'left', 'class' => 'statut_' . $row['proj_type']);
|
||
$data_row[] = array('data' => $row['dest'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['proj_date_annule'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['proj_nom'], 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => $row['proj_numero'], '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_debut'], 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => $row['proj_date_confirmation'], 'align' => 'left');
|
||
|
||
|
||
$data_row[] = array('data' => number_format($row['total'], 2, '.', ' '), 'width' => '100', 'align' => 'right');
|
||
$mem_total = $mem_total + $row['total'];
|
||
|
||
if ($excel != 0) {
|
||
$data_row_excel = array();
|
||
$data_row_excel[] = array('data' => '', 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['compagnie'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['etape'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['proj_nom'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['proj_numero'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['rep_prenom'] . " " . $row['rep_nom'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['proj_date_debut'], 'align' => 'left');
|
||
|
||
|
||
$data_row_excel[] = array('data' => $row['con_prenom'] . " " . $row['con_nom'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['proj_date_annule'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['proj_date_confirmation'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['dest'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['type'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['proj_hebergement'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => number_format($row['total'], 2, '.', ''), 'align' => 'left');
|
||
|
||
//$data_row_excel[] = array('data'=>$mem_heb, 'align' => 'left');
|
||
$data_row_excel[] = array('data' => '', 'align' => 'left');
|
||
|
||
|
||
$mem_excel_output['data'][] = $data_row_excel;
|
||
|
||
}
|
||
|
||
|
||
// $data_row[] = array('data'=>$row['list_contacts'], 'align' => 'left');
|
||
|
||
$tabular_data[] = $data_row;
|
||
|
||
}
|
||
$data_row = array();
|
||
$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');
|
||
$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' => number_format($mem_total, 2, '.', ' '), 'align' => 'right');
|
||
$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['empData'] = $tableau_sortie;
|
||
if ($excel != 0) {
|
||
// $mem_excel_output['data']=$tabular_data;
|
||
|
||
|
||
$data['fichier'] = "projets.xls";
|
||
$mem_excel_output['fichier'] = "projets";
|
||
// $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);
|
||
|
||
}
|
||
return $data;
|
||
}
|
||
|
||
public function mod_getRecordCount()
|
||
{
|
||
$this->db->select('count(*) as allcount');
|
||
$this->db->from('proj_entete');
|
||
|
||
|
||
$query = $this->db->get();
|
||
$result = $query->result_array();
|
||
return $result[0]['allcount'];
|
||
}
|
||
|
||
public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "", $filtre4 = "", $listactive)
|
||
{
|
||
// list la bb client
|
||
$this->db->select('count(*) as allcount');
|
||
// $this->db->select('*,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 ($filtre1 != "")
|
||
$this->db->where("usa_id=" . $filtre1);
|
||
if ($filtre2 != "")
|
||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||
|
||
if ($filtre4 != "")
|
||
$this->db->where("proj_numero LIKE '%$filtre4%'");
|
||
if ($filtre3 != "") {
|
||
$this->db->where("proj_etape=" . $filtre3);
|
||
} else {
|
||
if ($listactive == 1)
|
||
$this->db->where("proj_etape not in (7,4,6)");
|
||
|
||
}
|
||
|
||
|
||
$query = $this->db->get();
|
||
|
||
$result = $query->result_array();
|
||
|
||
|
||
return $result[0]['allcount'];
|
||
}
|
||
|
||
public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $filtre4 = "", $trie = "null", $listactive = 1, $filtre5 = "", $date_debut, $date_fin, $langue = 'fr', $hebergement = 2, $filtre6 = "")
|
||
{
|
||
|
||
|
||
// list la bb client
|
||
$this->db->select('*,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,type.gen_nom_fr as type,dest.gen_nom_fr as dest,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('proj_genres type', 'type.gen_id=proj_entete.proj_type', 'left');
|
||
$this->db->join('proj_genres dest', 'dest.gen_id=proj_entete.proj_dest', 'left');
|
||
|
||
$this->db->join('usa_usagers', 'usa_usagers.usa_id=proj_entete.proj_representant_id', 'left');
|
||
|
||
$this->db->limit($rowperpage, $rowno);
|
||
if ($trie != "null") {
|
||
$this->db->order_by($trie);
|
||
} else {
|
||
|
||
}
|
||
if ($hebergement != 2)
|
||
$this->db->where("proj_hebergement=" . $hebergement);
|
||
if ($filtre1 != "" && $filtre1 != 0)
|
||
$this->db->where("usa_id=" . $filtre1);
|
||
if ($filtre2 != "")
|
||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||
|
||
if ($filtre6 != "")
|
||
$this->db->where("proj_numero LIKE '%$filtre6%'");
|
||
|
||
if ($filtre4 != "")
|
||
$this->db->where("proj_dest=" . $filtre4);
|
||
|
||
|
||
if ($filtre3 != "") {
|
||
$this->db->where("proj_etape=" . $filtre3);
|
||
} else {
|
||
if ($listactive == 1)
|
||
$this->db->where("proj_etape not in (7,4,6)");
|
||
|
||
}
|
||
|
||
if ($filtre5 != "") {
|
||
$this->db->where("proj_type=" . $filtre5);
|
||
}
|
||
|
||
$this->db->where("proj_date_debut>=", $date_debut);
|
||
$this->db->where("proj_date_debut<=", $date_fin);
|
||
|
||
$query = $this->db->get();
|
||
|
||
$clients = $query->result_array();
|
||
|
||
foreach ($clients as $key => $value) {
|
||
$clients[$key]['total'] = $this->mod_tot_projet($value['proj_id']);
|
||
|
||
}
|
||
|
||
|
||
return $clients;
|
||
}
|
||
|
||
public function mod_tot_projet($id)
|
||
{
|
||
$this->db->select('*');
|
||
$this->db->from('proj_details');
|
||
$this->db->join('proj_details_details', 'proj_details_details.proj_det_id=proj_details.proj_det_id', 'left');
|
||
$this->db->where('proj_ent_id=' . $id);
|
||
$this->db->where('det_etape not in (7,4,6)');
|
||
$query = $this->db->get();
|
||
$mem_return = $query->result_array();
|
||
$mem_tot = 0;
|
||
foreach ($mem_return as $row) {
|
||
$qte = (float)$row['det_qte'];
|
||
$vend = (float)$row['det_vendant'];
|
||
$mem_tot += $qte * $vend;
|
||
}
|
||
|
||
return $mem_tot;
|
||
|
||
}
|
||
|
||
public function mod_loadData_list_depart($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $filtre4 = '', $trie = '', $listactive = 1, $debut, $fin, $excel = 0)
|
||
{
|
||
|
||
|
||
$filtre1 = ($filtre1 == 'null' ? '' : $filtre1);
|
||
$filtre2 = ($filtre2 == 'null' ? '' : $filtre2);
|
||
$filtre3 = ($filtre3 == 'null' ? '' : $filtre3);
|
||
$filtre4 = ($filtre4 == 'null' ? '' : $filtre4);
|
||
$recordPerPage = 9999;
|
||
$config["cur_page"] = $record;
|
||
if ($record != 0) {
|
||
$record = ($record - 1) * $recordPerPage;
|
||
}
|
||
|
||
$recordCount2 = $this->mod_getRecordCount();
|
||
$recordCount2 = 0;
|
||
//$recordCount = $this->mod_getRecordCountfilter_depart($filtre1, $filtre2, $filtre3, $filtre4,$listactive);
|
||
$recordCount = 9999;
|
||
$client_list = $this->mod_getRecords_filter_depart($filtre1, $filtre2, $filtre3, $filtre4, $trie, $listactive, $debut, $fin);
|
||
|
||
|
||
$config['base_url'] = base_url() . 'index.php/Projets/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="excel" 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, 'Nom du client', 'Étape', 'Nom du projet', 'Représentant', 'No projet', 'Responsable de la journée (client)',
|
||
'Date de départ',
|
||
'',
|
||
'Fournisseur autobus',
|
||
'Bus', 'Nom du produit', 'Nom du chauffeur');
|
||
|
||
if ($excel == 1) {
|
||
|
||
$mem_excel_output['header'] = array('', 'Nom du client', 'Nom du projet', 'Représentant', 'No projet', 'Responsable de la journée (client)',
|
||
'Date de départ',
|
||
'',
|
||
'Fournisseur autobus',
|
||
'Bus', 'Nom du produit', 'Nom du chauffeur');
|
||
$mem_excel_output['headerwidth'] = array(5, 30, 30, 30, 10, 30, 20, 10, 30, 5, 30, 30);
|
||
}
|
||
|
||
|
||
$nbitem = 0;
|
||
|
||
// filter
|
||
global $mem_data;
|
||
$data_row = array();
|
||
$data_row[] = array('data' => '', 'align' => 'left');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'filtre_1';
|
||
$mem_value = $filtre1;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_1');
|
||
$mem_filtre = form_input($mem_data['input'][$mem_champ]);
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'filtre_2';
|
||
$mem_value = $filtre2;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet("a", "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_2"');
|
||
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
|
||
|
||
$data_row[] = array('data' => '', 'align' => 'left');
|
||
|
||
|
||
$mem_champ = 'filtre_4';
|
||
$mem_value = $filtre4;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getRepresentantsClient();
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
$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');
|
||
$data_row[] = array('data' => "", 'align' => 'left');
|
||
|
||
|
||
// $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');
|
||
|
||
$data_row[] = array('data' => '', 'align' => 'left');
|
||
|
||
$mem_trie = '<a id="trie" data-id="det_depart" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a><a id="trie" data-id="det_depart desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
|
||
$data_row[] = array('data' => $mem_trie, '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', 6);
|
||
$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');
|
||
// -------------------------------------------------------------------------
|
||
// $mem_data='<a id="trie" data-id="proj_date_confirmation" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a><a id="trie" data-id="proj_date_confirmation desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
// $data_row[] = array('data' => $mem_data, 'align' => 'left');
|
||
// -------------------------------------------------------------------------
|
||
// $mem_data='<a id="trie" data-id="proj_date_debut" class="btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"><a id="trie" data-id="proj_date_debut desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
// $data_row[] = array('data' => $mem_data, 'align' => 'left','width'=>'90');
|
||
// -------------------------------------------------------------------------
|
||
// $mem_data='<a id="trie" data-id="null" class="btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a> ';
|
||
// $data_row[] = array('data' => $mem_data, 'align' => 'left','width'=>'90');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$tabular_data[] = $data_row;
|
||
|
||
foreach ($client_list as $row) {
|
||
$nbitem++;
|
||
$mem_link_edit = anchor('projets/form/' . $row['proj_numero'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-edit" ');
|
||
|
||
// faire le link pour edit
|
||
// $mem_link_edit = anchor('projets/form/' . $row['proj_id'], ' ', array('class'=> 'btn btn-primary btn-circle glyphicon glyphicon-edit', 'target' => '_blank' ));
|
||
// <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' => $mem_link_edit, 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => $row['compagnie'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['statut'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['proj_nom'], 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => $row['usa_prenom'] . " " . $row['usa_nom'], 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => $row['proj_numero'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['det_responsable'], 'align' => 'left');
|
||
$data_row[] = array('data' => date("Y-m-d", strtotime($row['det_depart'])), 'align' => 'left', 'width' => '100');
|
||
$data_row[] = array('data' => date("H:i", strtotime($row['det_depart'])), 'align' => 'left');
|
||
$data_row[] = array('data' => $row['fournisseur'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['det_qte'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['des_nom_fr'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['det_chauffeur'], 'align' => 'left');
|
||
// $data_row[] = array('data'=>$row['list_contacts'], '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['empData'] = $tableau_sortie;
|
||
|
||
if ($excel == 1) {
|
||
$mem_excel_output['data'] = $tabular_data;
|
||
|
||
$data['fichier'] = "depart.xls";
|
||
$mem_excel_output['fichier'] = "depart";
|
||
$mem_excel_output['titre'] = "depart du " . $debut . ' @ ' . $fin;
|
||
$this->Config_model->excel($mem_excel_output);
|
||
}
|
||
|
||
|
||
return $data;
|
||
}
|
||
|
||
public function mod_getRecords_filter_depart($filtre1 = "", $filtre2 = "", $filtre3 = "", $filtre4 = "", $trie, $listactive, $debut, $fin)
|
||
{
|
||
// list la bb client
|
||
$this->db->select('*,proj_genres.gen_nom_fr as statut,if(det_depart="0000-00-00","9999-99-99",det_depart) as trie,cli_compte.com_compagnie as compagnie,fou_compte.com_compagnie as fournisseur');
|
||
$this->db->from('proj_details');
|
||
$this->db->join('proj_details_details', 'proj_details_details.proj_det_id=proj_details.proj_det_id', 'left');
|
||
$this->db->join('proj_entete', 'proj_details.proj_ent_id=proj_entete.proj_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('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||
$this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id ', 'left');
|
||
$this->db->join('usa_usagers', 'usa_usagers.usa_id=proj_entete.proj_representant_id', 'left');
|
||
|
||
$this->db->join('proj_genres', 'proj_entete.proj_etape=proj_genres.gen_id', 'left');
|
||
|
||
$this->db->where("des_ref_type=1");
|
||
$this->db->where("det_etape not in (7,4,6)");
|
||
|
||
if ($trie != 'null')
|
||
$this->db->order_by($trie);
|
||
$this->db->where("det_depart between '" . $debut . " 00:00:00' and '" . $fin . " 23:59:00'");
|
||
if ($filtre1 != "")
|
||
$this->db->where("cli_compte.com_compagnie LIKE '%" . $filtre1 . "%'");
|
||
if ($filtre3 != "")
|
||
$this->db->where("fou_compte.com_compagnie LIKE '%" . $filtre3 . "%'");
|
||
if ($filtre2 != "")
|
||
$this->db->where("proj_entete.proj_etape=" . $filtre2);
|
||
|
||
// $this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||
|
||
if ($filtre4 != "")
|
||
$this->db->where("usa_id=" . $filtre4);
|
||
|
||
|
||
$query = $this->db->get();
|
||
|
||
$result = $query->result_array();
|
||
|
||
return $result;
|
||
}
|
||
|
||
public function mod_loadData_list_taches($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $filtre4 = '', $trie = '', $listactive = 1, $excel = 0)
|
||
{
|
||
|
||
$filtre1 = ($filtre1 == 'null' ? '' : $filtre1);
|
||
$filtre2 = ($filtre2 == 'null' ? '' : $filtre2);
|
||
$filtre3 = ($filtre3 == 'null' ? '' : $filtre3);
|
||
$filtre4 = ($filtre4 == 'null' ? '' : $filtre4);
|
||
$recordPerPage = 9999;
|
||
$config["cur_page"] = $record;
|
||
if ($record != 0) {
|
||
$record = ($record - 1) * $recordPerPage;
|
||
}
|
||
|
||
$recordCount2 = $this->Tache_model->mod_getRecordCount();
|
||
$recordCount2 = 0;
|
||
$recordCount = $this->Tache_model->mod_getRecordCountfilter($filtre1, $filtre2, $filtre3, $filtre4, $listactive);
|
||
|
||
$client_list = $this->Tache_model->mod_getRecordstache($record, $recordPerPage, $filtre1, $filtre2, $filtre3, $filtre4, $trie, $listactive);
|
||
|
||
$config['base_url'] = base_url() . 'index.php/Projets/loadData_list_taches';
|
||
|
||
$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_link_new=anchor('clients/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" ');
|
||
$header = array(' ', 'Nom', 'Projet', 'Action', 'Statut ', ' À qui', 'Date échéance', 'De qui', 'Nb jours');
|
||
if ($excel == 1) {
|
||
$mem_excel_output['header'] = array("Nom", "Projet", "Action", "Statut", "À qui", "Date échéance", "De qui", "Nb jours");
|
||
$mem_excel_output['headerwidth'] = array(5, 50, 15, 40, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30);
|
||
|
||
}
|
||
$nbitem = 0;
|
||
|
||
// filter
|
||
global $mem_data;
|
||
$data_row = array();
|
||
$mem_excel = '<a id="excel" data-id="1" class="btn btn-primary btn-circle fa fa-cloud-download"> </a>';
|
||
$data_row[] = array('data' => $mem_excel, 'align' => 'left');
|
||
$data_row[] = array('data' => "", 'align' => 'left');
|
||
|
||
|
||
$mem_champ = 'filtre_3';
|
||
$mem_value = $filtre3;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresTache('fr', true, "", "t");
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
$mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_3"');
|
||
$data_row[] = array('data' => "", 'align' => 'left');
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
|
||
|
||
$mem_champ = 'filtre_1';
|
||
$mem_value = $filtre1;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresTache('fr', true, "b", "s");
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
$mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_1"');
|
||
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
|
||
|
||
if (1 == 2) {
|
||
$mem_data2 = '<a id="trie" data-id="tach_statut" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a><a id="trie" data-id="tach_statut desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
$data_row[] = array('data' => $mem_data2, 'align' => 'left');
|
||
}
|
||
|
||
|
||
$mem_champ = 'filtre_2';
|
||
$mem_value = $filtre2;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getRepresentantsClient();
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
$mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_2"');
|
||
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
|
||
$mem_data2 = '<a id="trie" data-id="tach_echeance_date" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a><a id="trie" data-id="tach_echeance_date desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
$data_row[] = array('data' => $mem_data2, 'align' => 'left');
|
||
|
||
|
||
$mem_champ = 'filtre_4';
|
||
$mem_value = $filtre4;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getRepresentantsClient();
|
||
// value multipli select
|
||
//$mem_value = explode(',', $mem_value);
|
||
$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');
|
||
if (1 == 2) {
|
||
$mem_champ = 'filtre_1';
|
||
$mem_value = $filtre1;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresSection('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_1"');
|
||
|
||
$data_row[] = array('data' => $mem_filtre, 'align' => 'left');
|
||
}
|
||
// -------------------------------------------------------------------------
|
||
$mem_data = '<a id="trie" data-id="days" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a><a id="trie" data-id="days desc" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes-alt"> </a>';
|
||
$data_row[] = array('data' => $mem_data, 'align' => 'left');
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
// $mem_data='<a id="trie" data-id="proj_date_confirmation" class="trie btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a>';
|
||
// $data_row[] = array('data' => $mem_data, 'align' => 'left');
|
||
// -------------------------------------------------------------------------
|
||
// $mem_data='<a id="trie" data-id="proj_date_debut" class="btn btn-primary btn-circle glyphicon glyphicon-sort-by-attributes"> </a>';
|
||
// $data_row[] = array('data' => $mem_data, 'align' => 'left');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$tabular_data[] = $data_row;
|
||
|
||
foreach ($client_list as $row) {
|
||
|
||
// bnt tache
|
||
$mem_color = 'btn-warning';
|
||
if ($row['tach_active'] == 0) {
|
||
$mem_color = 'btn-success';
|
||
} else {
|
||
if ($row['tach_echeance_date'] < date("Y-m-d")) {
|
||
$mem_color = 'btn-danger';
|
||
}
|
||
}
|
||
$goto = $row['tach_section'];
|
||
if ($row['tach_section'] == 'projetsclient' || $row['tach_section'] == 'projetsfournisseur') {
|
||
$goto = 'projets';
|
||
}
|
||
//$mem_titre=$row['gen_nom_fr'].' 
Responsable :'.$row['usa_aqui'].'
Echeance :'.$row['tach_echeance_date'];
|
||
$mem_titre = $row['gen_nom_fr'] . ' 
Demande :
' . $row['tach_note_demande'] . '
Suivie :
' . $row['tach_note_suivie'];
|
||
|
||
|
||
$mem_link_edit = '<a id="tache" data-toggle="modal" data-section="' . $row['tach_section'] . '" data-id="' . $row['tach_id'] . '" data-section_id="' . $row['tach_section_id'] . '" class="btn ' . $mem_color . ' btn-circle glyphicon glyphicon-bell popup" title="' . $mem_titre . '"></a>';
|
||
//
|
||
// btn go
|
||
$mem_link_go = anchor($goto . '/form/' . $row['tach_section_id'], ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$nbitem++;
|
||
// faire le link pour edit
|
||
// $mem_link_edit = anchor('projets/form/' . $row['proj_id'], ' ', array('class'=> 'btn btn-primary btn-circle glyphicon glyphicon-edit', 'target' => '_blank' ));
|
||
|
||
// <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_go, 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => $row['com_compagnie'] . $row['compagnie'] . $row['fournisseur'], 'align' => 'left');
|
||
// sl
|
||
$data_row[] = array('data' => $row['proj_nom'] . '(' . $row['des_nom_fr'] . ')', 'align' => 'left');
|
||
|
||
// $data_row[] = array('data' => $row['usa_aqui'], 'align' => 'left', 'class' => 'statut_' . $row['proj_etape']);
|
||
$data_row[] = array('data' => $row['type_fr'] . '<br>(' . $row['tach_section'] . ')', 'align' => 'left', 'class' => 'statut_' . $row['tach_type']);;
|
||
$data_row[] = array('data' => $row['statut_fr'] . '', 'align' => 'left', 'class' => 'statuttach_' . $row['tach_statut']);;
|
||
|
||
$data_row[] = array('data' => $row['usa_aqui'], 'align' => 'left');
|
||
|
||
$data_row[] = array('data' => $row['tach_echeance_date'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['usa_create'], 'align' => 'left');
|
||
|
||
|
||
// $data_row[] = array('data' => $row['tach_section'], 'align' => 'left');
|
||
$data_row[] = array('data' => $row['days'], 'align' => 'left', 'width' => '8%');
|
||
|
||
// $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');
|
||
// $data_row[] = array('data' => $row['proj_date_fin'], 'align' => 'left');
|
||
|
||
|
||
// $data_row[] = array('data'=>$row['list_contacts'], 'align' => 'left');
|
||
|
||
$tabular_data[] = $data_row;
|
||
if ($excel != 0) {
|
||
$data_row_excel = array();
|
||
$data_row_excel[] = array('data' => $row['com_compagnie'] . $row['compagnie'] . $row['fournisseur'], 'align' => 'left');
|
||
// sl
|
||
$data_row_excel[] = array('data' => $row['proj_nom'] . '(' . $row['des_nom_fr'] . ')', 'align' => 'left');
|
||
|
||
// $data_row[] = array('data' => $row['usa_aqui'], 'align' => 'left', 'class' => 'statut_' . $row['proj_etape']);
|
||
$data_row_excel[] = array('data' => $row['type_fr'] . '<br>(' . $row['tach_section'] . ')', 'align' => 'left', 'class' => 'statut_' . $row['tach_type']);;
|
||
$data_row_excel[] = array('data' => $row['statut_fr'] . '', 'align' => 'left', 'class' => 'statuttach_' . $row['tach_statut']);;
|
||
|
||
$data_row_excel[] = array('data' => $row['usa_aqui'], 'align' => 'left');
|
||
|
||
$data_row_excel[] = array('data' => $row['tach_echeance_date'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['usa_create'], 'align' => 'left');
|
||
|
||
|
||
// $data_row[] = array('data' => $row['tach_section'], 'align' => 'left');
|
||
$data_row_excel[] = array('data' => $row['days'], 'align' => 'left', 'width' => '8%');
|
||
|
||
|
||
$mem_excel_output['data'][] = $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>',
|
||
'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['empData'] = $tableau_sortie;
|
||
|
||
if ($excel != 0) {
|
||
// $mem_excel_output['data']=$tabular_data;
|
||
|
||
$data['fichier'] = "taches.xls";
|
||
$mem_excel_output['fichier'] = "taches";
|
||
// $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);
|
||
|
||
}
|
||
return $data;
|
||
}
|
||
|
||
public function mod_getRecordCountfilter_depart($filtre1 = "", $filtre2 = "", $filtre3 = "", $filtre4 = "", $listactive)
|
||
{
|
||
// list la bb client
|
||
$this->db->select('count(*) as allcount');
|
||
$this->db->from('proj_details');
|
||
$this->db->join('proj_details_details', 'proj_details_details.proj_det_id=proj_details.proj_det_id', 'left');
|
||
$this->db->join('proj_entete', 'proj_details.proj_ent_id=proj_entete.proj_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('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||
|
||
if ($filtre1 != "")
|
||
$this->db->where("usa_id=" . $filtre1);
|
||
if ($filtre2 != "")
|
||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||
if ($filtre4 != "")
|
||
$this->db->where("usa_id=" . $filtre4);
|
||
if ($filtre3 != "") {
|
||
$this->db->where("proj_etape=" . $filtre3);
|
||
} else {
|
||
if ($listactive == 1)
|
||
$this->db->where("proj_etape not in (7,4,6)");
|
||
|
||
}
|
||
|
||
|
||
$query = $this->db->get();
|
||
|
||
$result = $query->result_array();
|
||
|
||
|
||
return $result[0]['allcount'];
|
||
}
|
||
|
||
public function mod_getforminfo($id)
|
||
{
|
||
$mem_data = array();
|
||
|
||
$mem_data = $this->mod_getformprojet($id);
|
||
return $mem_data;
|
||
}
|
||
|
||
public function mod_getformprojet($id)
|
||
{
|
||
global $mem_data, $validation;
|
||
|
||
$this->load->model('Config_model');
|
||
$this->load->model('FxForm_model');
|
||
$this->lang->load("text_" . config_item('pw_client'), "french");
|
||
// vas chercher les info de la fiche
|
||
|
||
if ($id != 0)
|
||
$info = $this->mod_getRecord($id);
|
||
$mem_data['total'] = $this->mod_tot_projet($id);
|
||
|
||
$mem_data['titre'] = $info->proj_numero . " " . $info->proj_nom;
|
||
$mem_data['contact'] = $info->con_prenom . " " . $info->con_nom;
|
||
$mem_data['contactinfo'] = $info->con_telephone . " " . $info->con_courriel;
|
||
$mem_data['adresse'] = $info->com_adresse . " " . $info->com_ville . " " . $info->com_codepostal;
|
||
$mem_data['id_client'] = $info->com_id;
|
||
// prepare info pour chaque champs utilisé
|
||
// input
|
||
$mem_data['mem_id'] = $id;
|
||
$mem_data['mem_numero'] = $info->proj_numero;
|
||
$mem_data['proj_google_rep_id'] = $info->proj_google_rep_id;
|
||
$mem_data['proj_google_rep_id_root'] = $info->proj_google_rep_id_root;
|
||
$mem_data['proj_google_date_lien_doc'] = $info->proj_google_date_lien_doc;
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
//$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 = 'proj_client_id';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['retour_client'] = $mem_value;
|
||
$mem_proj_client_id = $mem_value;
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'com_compagnie';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
|
||
// $mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getClient();
|
||
// // value multipli select
|
||
// $mem_value = explode(',', $mem_value);
|
||
|
||
// $mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
|
||
$mem_data['label'][$mem_champ] = 'Client';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
// $mem_data['icon'][$mem_champ] = '';
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_hebergement';
|
||
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_choix[0] = 'NON';
|
||
$mem_choix[1] = 'OUI';
|
||
$mem_data['select'][$mem_champ]['choix'] = $mem_choix;
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = $this->lang->line('txt_hebergement');
|
||
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
// -------------------------------------------------------------------------
|
||
|
||
if ($this->config->item('pw_client') == "ms1") {
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_contrat';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet('e');
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = $this->lang->line('txt_contrat');
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
// -------------------------------------------------------------------------
|
||
}
|
||
|
||
$mem_champ = 'proj_date_annule';
|
||
|
||
$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, $this->lang->line('txt_Date_annulation'), '', '', '');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_nom';
|
||
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Projet', '');
|
||
$this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_date_debut';
|
||
|
||
$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 début', '', '', '');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_date_fin';
|
||
|
||
$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 fin', '', '', '');
|
||
|
||
// -----------------------------------
|
||
$mem_champ = 'proj_date_confirmation';
|
||
|
||
$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, $this->lang->line('txt_Date_confirmation'), '', '', '');
|
||
|
||
// -----------------------------------
|
||
$mem_champ = 'proj_representant_id';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getRepresentantsClient();
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Représentant';
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
// -----------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_etape';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet();
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Étape';
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
// -----------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_type';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet('b');
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = $this->lang->line('txt_Type');
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
if ($this->config->item('pw_client') == "ms1") {
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_eve_id';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getListeevenement();
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = $this->lang->line('txt_evenements inscription');
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'proj_transfert';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet('d');
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = $this->lang->line('txt_transfert');
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
}
|
||
|
||
// -----------------------------------------
|
||
// -----------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_dest';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet('c');
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = $this->lang->line('txt_Destination');
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
// -----------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_contact_principale';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
|
||
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getContactClient('fr', true, $mem_proj_client_id);
|
||
|
||
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Contact';
|
||
$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 = 'proj_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 = 'proj_notes';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Notes', '', 'Notes');
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'proj_postmortem';
|
||
$mem_value = ($id == 0 ? '' : $info->$mem_champ);
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Post-mortem', '', 'Post-mortem');
|
||
|
||
|
||
$mem_data['validation'] = $this->FxForm_model->fxValidation($validation['rule'], $validation['message']);
|
||
|
||
return $mem_data;
|
||
}
|
||
|
||
public function mod_getRecord($id, $langue = 'fr')
|
||
{
|
||
|
||
// trouve un enregiestrement
|
||
|
||
$this->db->select('*,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');
|
||
|
||
|
||
$this->db->where('proj_id=' . $id);
|
||
|
||
$this->db->limit(1);
|
||
|
||
$query = $this->db->get();
|
||
|
||
|
||
return $query->row();
|
||
|
||
|
||
}
|
||
|
||
public function mod_getforminfo_details($id)
|
||
{
|
||
|
||
$mem_data = $this->mod_getRecords_produits($id);
|
||
$mem_return = array();
|
||
|
||
foreach ($mem_data as $key => $info) {
|
||
//print_r($info);
|
||
$mem_return[$key]['type'] = $info['gen_nom_fr'];
|
||
$mem_return[$key]['type_icone'] = $info['gen_icone'];
|
||
$mem_return[$key]['type_color'] = $info['gen_color'];
|
||
$mem_return[$key]['ent_des_nom'] = $info['des_nom_fr'];
|
||
$mem_return[$key]['ent_com_compagnie'] = $info['com_compagnie'];
|
||
// $mem_return[$key]['proj_date_debut'] = $info['proj_date_debut'];
|
||
|
||
|
||
$mem_return[$key]['form'] = $this->mod_getform_projet_produit_detail($info['proj_det_id'], $info['des_ref_type'], $info['com_id']);
|
||
|
||
}
|
||
|
||
return $mem_return;
|
||
}
|
||
|
||
public function mod_getRecords_produits($id)
|
||
{
|
||
// list produits
|
||
$this->db->select('*,if(det_depart="0000-00-00","9999-99-99",det_depart) as trie');
|
||
$this->db->from('proj_details');
|
||
$this->db->join('proj_details_details', 'proj_details_details.proj_det_id=proj_details.proj_det_id', 'left');
|
||
$this->db->join('proj_entete', 'proj_details.proj_ent_id=proj_entete.proj_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('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left');
|
||
|
||
|
||
$this->db->where('proj_details.proj_ent_id', $id);
|
||
$this->db->order_by('trie,fou_compte.com_id');
|
||
|
||
$query = $this->db->get();
|
||
|
||
$produits = $query->result_array();
|
||
return ($produits);
|
||
|
||
}
|
||
|
||
public function mod_getform_projet_produit_detail($detail_produit_id, $type, $fournisseur_id)
|
||
{
|
||
|
||
global $mem_data, $validation;
|
||
$mem_data = "";
|
||
$validation = "";
|
||
$this->load->model('Config_model');
|
||
$this->load->model('FxForm_model');
|
||
$this->load->model('Fournisseurs_model');
|
||
// vas chercher les info de la fiche
|
||
|
||
|
||
$info = $this->mod_getRecord_projet_produit_detail($detail_produit_id);
|
||
|
||
switch ($type) {
|
||
|
||
case 1:
|
||
|
||
//print_r($info);
|
||
if (!is_array($mem_data)) {
|
||
$mem_data = array();
|
||
}
|
||
// prepare info pour chaque champs utilisé
|
||
// input
|
||
$mem_data['etape_color'] = $info->gen_color;;
|
||
$mem_data['mem_id'] = $detail_produit_id;
|
||
$mem_data['mem_type_fiche'] = 'transporteur';
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_contrat';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['label'][$mem_champ] = 'Contrat';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_responsable';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['label'][$mem_champ] = 'Responsable';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_chauffeur';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['label'][$mem_champ] = 'Chauffeur';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_desc';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = 'Infos complémentaires';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Infos complémentaires', '', '', '', '', '', false, 2);
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_depart';
|
||
|
||
$mem_data['icon'][$mem_champ] = 'icon-append fa fa-calendar';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Date de début/heure', '', '', 'form_datetime', '', '');
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_retour';
|
||
|
||
$mem_data['icon'][$mem_champ] = 'icon-append fa fa-calendar';
|
||
$mem_value = $info->$mem_champ;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Date de fin/heure', '', '', 'form_datetime', '', '');
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_qte';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = "Quantité";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_coutant';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = "Coûtant";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_adress';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = "Adresse d'embarquement";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_destination';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = "Destination";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_etape';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet();
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Étape';
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
$mem_champ = 'det_vendant';
|
||
$mem_value = $info->$mem_champ;;
|
||
$mem_data['label'][$mem_champ] = "Vendant";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_notes';
|
||
$mem_value = $info->$mem_champ;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Notes', '', 'Notes', '', '', false);
|
||
|
||
|
||
break;
|
||
|
||
|
||
default:
|
||
//print_r($info);
|
||
|
||
// prepare info pour chaque champs utilisé
|
||
// input
|
||
if (!is_array($mem_data)) {
|
||
$mem_data = array();
|
||
}
|
||
$mem_data['etape_color'] = $info->gen_color;;
|
||
$mem_data['mem_id'] = $detail_produit_id;
|
||
$mem_data['mem_type_fiche'] = 'autre';
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_desc';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = 'Infos complémentaires';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Infos complémentaires', '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_contrat';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['label'][$mem_champ] = 'Contrat';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_responsable';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['label'][$mem_champ] = 'Responsable';
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_etape';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresProjet();
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Étape';
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_depart';
|
||
|
||
$mem_data['icon'][$mem_champ] = 'icon-append fa fa-calendar';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Date de début/heure', '', '', 'form_datetime', '', '');
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_retour';
|
||
|
||
$mem_data['icon'][$mem_champ] = 'icon-append fa fa-calendar';
|
||
$mem_value = $info->$mem_champ;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Date de fin/heure', '', '', 'form_datetime', '', '');
|
||
// -------------------------------------------------------------------------
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_qte';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = "Quantité";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_coutant';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = "Coûtant";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
// -------------------------------------------------------------------------
|
||
|
||
$mem_champ = 'det_vendant';
|
||
$mem_value = $info->$mem_champ;
|
||
|
||
|
||
$mem_data['label'][$mem_champ] = "Vendant";
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, $mem_data['label'][$mem_champ], '', '', '', '', '');
|
||
// $this->FxForm_model->fxvaliderequired($mem_champ);
|
||
|
||
|
||
// -------------------------------------------------------------------------
|
||
$mem_champ = 'det_notes';
|
||
$mem_value = $info->$mem_champ;
|
||
$this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Notes', '', 'Notes', '', '', '');
|
||
|
||
|
||
break;
|
||
|
||
}
|
||
// champ pour tout les formulaire
|
||
|
||
|
||
// ---------- reservation ----
|
||
|
||
if ($info->det_res_creation != '0000-00-00 00:00:00')
|
||
$mem_data['det_res_creation'] = $info->det_res_creation;
|
||
else
|
||
$mem_data['det_res_creation'] = "";
|
||
|
||
if ($info->det_res_envoi != '0000-00-00 00:00:00')
|
||
$mem_data['det_res_envoi'] = $info->det_res_envoi;
|
||
else
|
||
$mem_data['det_res_envoi'] = "";
|
||
$mem_champ = 'det_res_contact_id';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Fournisseurs_model->mod_selectcontact($fournisseur_id);
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Contact';
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
|
||
$mem_champ = 'det_res_active';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Lot';
|
||
$this->FxForm_model->fxcheckbox($mem_champ, $mem_value, 'Lot', '', 'Lot', '', 30, '');
|
||
|
||
|
||
// ---------- confirmation ----
|
||
|
||
$mem_data['det_con_lot_fait'] = $info->det_con_lot_fait;
|
||
$mem_data['det_fac_lot_fait'] = $info->det_fac_lot_fait;
|
||
$mem_data['det_res_lot_fait'] = $info->det_res_lot_fait;
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
|
||
|
||
if ($info->det_con_creation != '0000-00-00 00:00:00')
|
||
$mem_data['det_con_creation'] = $info->det_con_creation;
|
||
else
|
||
$mem_data['det_con_creation'] = "";
|
||
|
||
if ($info->det_con_envoi != '0000-00-00 00:00:00')
|
||
$mem_data['det_con_envoi'] = $info->det_con_envoi;
|
||
else
|
||
$mem_data['det_con_envoi'] = "";
|
||
$mem_champ = 'det_con_contact_id';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Fournisseurs_model->mod_selectcontact($fournisseur_id);
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Contact';
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
|
||
$mem_champ = 'det_con_active';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Lot';
|
||
$this->FxForm_model->fxcheckbox($mem_champ, $mem_value, 'Lot', '', 'Lot', '', 30, '');
|
||
|
||
// ---------- factureation ----
|
||
|
||
if ($info->det_fac_creation != '0000-00-00 00:00:00')
|
||
$mem_data['det_fac_creation'] = $info->det_fac_creation;
|
||
else
|
||
$mem_data['det_fac_creation'] = "";
|
||
|
||
if ($info->det_fac_envoi != '0000-00-00 00:00:00')
|
||
$mem_data['det_fac_envoi'] = $info->det_fac_envoi;
|
||
else
|
||
$mem_data['det_fac_envoi'] = "";
|
||
$mem_champ = 'det_fac_contact_id';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['select'][$mem_champ]['choix'] = $this->Fournisseurs_model->mod_selectcontact($fournisseur_id);
|
||
// value multipli select
|
||
$mem_value = explode(',', $mem_value);
|
||
|
||
$mem_data['select'][$mem_champ]['value'] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Contact';
|
||
$mem_data['icon'][$mem_champ] = '';
|
||
|
||
|
||
$mem_champ = 'det_fac_active';
|
||
$mem_value = $info->$mem_champ;
|
||
$mem_data['value'][$mem_champ] = $mem_value;
|
||
$mem_data['label'][$mem_champ] = 'Lot';
|
||
$this->FxForm_model->fxcheckbox($mem_champ, $mem_value, 'Lot', '', 'Lot', '', 30, '');
|
||
|
||
|
||
//$mem_data2['validation']=$this->FxForm_model->fxValidation($validation2['rule'],$validation2['message']);
|
||
|
||
return $mem_data;
|
||
}
|
||
|
||
public function mod_getRecord_projet_produit_detail($id)
|
||
{
|
||
// trouve un enregiestrement
|
||
$bd = 'proj_details_details';
|
||
$this->db->select('*');
|
||
$this->db->from("proj_details_details");
|
||
$this->db->join('proj_genres', 'proj_genres.gen_id=proj_details_details.det_etape', 'left');
|
||
|
||
|
||
$this->db->where('proj_det_id=' . $id);
|
||
|
||
$this->db->limit(1);
|
||
|
||
$query = $this->db->get();
|
||
$mem_return = $query->row();
|
||
|
||
return $mem_return;
|
||
}
|
||
|
||
public function mod_save_proj_details($id, $data)
|
||
{
|
||
echo($id);
|
||
print_r($data);
|
||
|
||
|
||
$pref = 'det_';
|
||
if (isset($data['det_res_active'])) {
|
||
if ($data['val_det_res_active'] <> 1) {
|
||
$data['det_res_active'] = 1;
|
||
$data['det_res_creation'] = date("Y-m-d H:i:s");
|
||
}
|
||
} else {
|
||
$data['det_res_creation'] = "0000-00-00 00:00:00";
|
||
$data['det_res_active'] = 0;
|
||
}
|
||
|
||
if (isset($data['det_con_active'])) {
|
||
if ($data['val_det_con_active'] <> 1) {
|
||
$data['det_con_active'] = 1;
|
||
$data['det_con_creation'] = date("Y-m-d H:i:s");
|
||
}
|
||
} else {
|
||
$data['det_con_creation'] = "0000-00-00 00:00:00";
|
||
$data['det_con_active'] = 0;
|
||
}
|
||
|
||
if (isset($data['det_fac_active'])) {
|
||
|
||
if ($data['val_det_fac_active'] <> 1) {
|
||
$data['det_fac_active'] = 1;
|
||
$data['det_fac_creation'] = date("Y-m-d H:i:s");
|
||
}
|
||
|
||
} else {
|
||
$data['det_fac_creation'] = "0000-00-00 00:00:00";
|
||
$data['det_fac_active'] = 0;
|
||
$data['det_fac_montant'] = 0;
|
||
|
||
}
|
||
|
||
|
||
foreach ($data as $key => $value) {
|
||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||
$mem_data[$key] = $value;
|
||
}
|
||
|
||
}
|
||
$mem_data[$pref . 'modif'] = date("Y-m-d H:i:s");
|
||
$mem_where = 'proj_det_id =' . $id;
|
||
|
||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||
$ok = true;
|
||
|
||
return $ok;
|
||
|
||
}
|
||
|
||
public function mod_create_proj_details($proj_ent_id, $proj_prod_id, $proj_fou_id)
|
||
{
|
||
|
||
|
||
$info = $this->mod_getRecord($proj_ent_id);
|
||
|
||
$mem_data['proj_ent_id'] = $proj_ent_id;
|
||
$mem_data['proj_prod_id'] = $proj_prod_id;
|
||
$mem_data['proj_fou_id'] = $proj_fou_id;
|
||
|
||
$mem_data['proj_creation'] = date("Y-m-d H:i:s");
|
||
$mem_data['proj_actif'] = 1;
|
||
$str = $this->db->insert('proj_details', $mem_data);
|
||
$return_id = $this->db->insert_id();
|
||
|
||
$produit = $this->mod_getunRecord_produits($proj_prod_id);
|
||
|
||
$mem_data2['det_creation'] = date("Y-m-d H:i:s");
|
||
$mem_data2['det_depart'] = $info->proj_date_debut;
|
||
// $mem_data2['det_retour'] =$info->proj_date_fin;
|
||
$mem_data2['det_retour'] = $info->proj_date_debut;
|
||
$mem_data2['det_etape'] = 1;
|
||
$mem_data2['proj_det_id'] = $return_id;
|
||
$str = $this->db->insert('proj_details_details', $mem_data2);
|
||
return $return_id;
|
||
}
|
||
|
||
public function mod_getunRecord_produits($id)
|
||
{
|
||
// list produits
|
||
$this->db->select('*');
|
||
$this->db->from('pro_descriptions');
|
||
//$this->db->join('proj_entete', 'proj_details.proj_ent_id=proj_entete.proj_id','left');
|
||
|
||
$this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left');
|
||
|
||
|
||
$this->db->where('pro_descriptions.des_id', $id);
|
||
|
||
|
||
$this->db->limit(1);
|
||
|
||
$query = $this->db->get();
|
||
$produit = $query->row();
|
||
|
||
|
||
return ($produit);
|
||
|
||
}
|
||
|
||
public function mod_deleteproduits($id)
|
||
{
|
||
$this->db->where('proj_det_id =' . $id);
|
||
|
||
$this->db->delete('proj_details_details');
|
||
$this->db->where('proj_det_id =' . $id);
|
||
$this->db->delete('proj_details');
|
||
return;
|
||
}
|
||
|
||
public function mod_choix_produit($id)
|
||
{
|
||
$this->load->model('Produits_model');
|
||
$this->load->model('Fournisseurs_model');
|
||
$info_produit = $this->Produits_model->mod_getRecord($id);
|
||
$data['details_produit'] = $info_produit->des_nom_fr . ' ' . $info_produit->gen_nom_fr;
|
||
$data['des_ref_type'] = $info_produit->des_ref_type;
|
||
$data['des_id'] = $id;
|
||
$data['gen_actif_fournisseur'] = $info_produit->gen_actif_fournisseur;
|
||
//$data['choix_fournisseurs']=$this->Fournisseurs_model->mod_loadData_list(0,null,null,null,1,'projets');
|
||
|
||
|
||
return $data;
|
||
}
|
||
|
||
public function list_info_pro_auto($type_infos = 1,$pro_auto_desc_id=0)
|
||
{
|
||
switch ($type_infos) {
|
||
// tout actif
|
||
case 1:
|
||
|
||
|
||
// 1️⃣ Parents : pro_auto_type = 1
|
||
$this->db->select('*')
|
||
->from('pro_auto')
|
||
->where('pro_auto_actif', 1)
|
||
->where('pro_auto_type', 1);
|
||
|
||
if ($pro_auto_desc_id != 0) {
|
||
$this->db->where('pro_auto_desc_id', $pro_auto_desc_id);
|
||
}
|
||
|
||
$this->db->order_by('pro_auto_desc_id, pro_auto_id');
|
||
$parents = $this->db->get()->result_array();
|
||
|
||
if (empty($parents)) {
|
||
return [];
|
||
}
|
||
|
||
// 2️⃣ Enfants : pro_auto_type = 2
|
||
$this->db->select('*')
|
||
->from('pro_auto')
|
||
->where('pro_auto_actif', 1)
|
||
->where('pro_auto_type', 2);
|
||
|
||
$children = $this->db->get()->result_array();
|
||
|
||
// 3️⃣ Index enfants par pro_auto_tache_produit_id
|
||
$children_by_parent = [];
|
||
foreach ($children as $child) {
|
||
if (!empty($child['pro_auto_tache_produit_id'])) {
|
||
$children_by_parent[$child['pro_auto_tache_produit_id']][] = $child;
|
||
}
|
||
}
|
||
|
||
// 4️⃣ Injection des enfants dans chaque parent
|
||
foreach ($parents as &$parent) {
|
||
$parent_id = $parent['pro_auto_id'];
|
||
$parent['children'] = $children_by_parent[$parent_id] ?? [];
|
||
}
|
||
unset($parent);
|
||
|
||
$mem_return=$parents;
|
||
|
||
|
||
|
||
break;
|
||
|
||
// bouton
|
||
case 2:
|
||
|
||
$this->db->select('*');
|
||
$this->db->from("pro_auto");
|
||
|
||
$this->db->order_by('pro_auto_desc_id,pro_auto_type');
|
||
$this->db->where('pro_auto_actif', 1);
|
||
$this->db->group_by('pro_auto_desc_id', 1);
|
||
|
||
|
||
$query = $this->db->get();
|
||
$mem_return = $query->result_array();
|
||
|
||
|
||
break;
|
||
}
|
||
return $mem_return;
|
||
|
||
}
|
||
|
||
|
||
public function cree_pro_auto($pro_auto_desc_id,$proj_id)
|
||
{
|
||
$liste=$this->list_info_pro_auto(1,$pro_auto_desc_id);
|
||
// echo '<pre>', print_r($liste, true), '</pre>';
|
||
|
||
foreach ($liste as $parent) {
|
||
// echo("<br>parent<br>");
|
||
// ===== TRAITEMENT DU PARENT =====
|
||
$parent_id = $parent['pro_auto_id'];
|
||
$produit_id = $parent['pro_auto_produit'];
|
||
$fournisseur = $parent['pro_auto_fournisseur'];
|
||
//echo( $parent_id );
|
||
// 👉 ton traitement parent ici
|
||
// ex: préparer une action, une insertion, un calcul, etc.
|
||
$parent_produit=$this->Projets_model->mod_create_proj_details($proj_id, $produit_id , $fournisseur );
|
||
|
||
|
||
// ===== TRAITEMENT DES ENFANTS (SI PRÉSENTS) =====
|
||
if (!empty($parent['children'])) {
|
||
|
||
foreach ($parent['children'] as $child) {
|
||
//echo("<br>enfant<br>");
|
||
$children_id = $child['pro_auto_id'];
|
||
|
||
$tache_produit_id = $child['pro_auto_tache_produit_id'];
|
||
|
||
$raw = $child['pro_auto_tache_macro'];
|
||
|
||
$raw = trim($raw);
|
||
$raw = preg_replace('/^Array\s*\(|\)$/', '', $raw);
|
||
|
||
preg_match_all('/\[(.*?)\]\s*=>\s*([^[]*)/', $raw, $matches);
|
||
|
||
$post = [];
|
||
|
||
foreach ($matches[1] as $i => $key) {
|
||
$post[$key] = trim($matches[2][$i]);
|
||
}
|
||
|
||
|
||
|
||
//echo( $children_id);
|
||
|
||
$id=$this->Tache_model->mod_createRecordbd( $post ,'projetsclient',$proj_id, $parent_produit);
|
||
|
||
|
||
|
||
// 👉 ton traitement enfant ici
|
||
// ex:
|
||
// - créer une tâche
|
||
// - appliquer une macro
|
||
// - déclencher un workflow
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
public function mod_saveRecordbdbad($id, $data, $pref)
|
||
{
|
||
|
||
// creation de la chaine de save
|
||
$mem_data = array();
|
||
// ajoute les checkbox
|
||
if (!isset($data[$pref . 'actif']))
|
||
$data[$pref . 'actif'] = 0;
|
||
foreach ($data as $key => $value) {
|
||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||
$mem_data[$key] = $value;
|
||
}
|
||
|
||
}
|
||
|
||
$mem_data[$pref . 'modif'] = date("Y-m-d H:i:s");
|
||
$mem_where = $pref . 'id =' . $id;
|
||
|
||
$str = $this->db->update('proj_entete', $mem_data, $mem_where);
|
||
$ok = true;
|
||
|
||
return $ok;
|
||
}
|
||
|
||
public function mod_createRecordbd($data, $pref, $client_id, $projet_id = 0)
|
||
{
|
||
$mem_data = array();
|
||
|
||
|
||
foreach ($data as $key => $value) {
|
||
if (substr($key, 0, strlen($pref)) == $pref) {
|
||
$mem_data[$key] = $value;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
if ($projet_id == 0) {
|
||
//trouve le dernier projets
|
||
|
||
$num = $this->Config_model->conf_getLastnumprojets();
|
||
|
||
$mem_data[$pref . 'numero'] = $num + 1;
|
||
$mem_data[$pref . 'client_id'] = $client_id;
|
||
$mem_data[$pref . 'creation'] = date("Y-m-d H:i:s");
|
||
$mem_data[$pref . 'actif'] = 1;
|
||
$str = $this->db->insert('proj_entete', $mem_data);
|
||
$return_id = $this->db->insert_id();
|
||
} else {
|
||
$mem_where = "proj_id =" . $projet_id;
|
||
$mem_data[$pref . 'modif'] = date("Y-m-d H:i:s");
|
||
$return_id = $projet_id;
|
||
|
||
$str = $this->db->update('proj_entete', $mem_data, $mem_where);
|
||
|
||
}
|
||
|
||
|
||
$ok = true;
|
||
|
||
return $return_id;
|
||
|
||
}
|
||
|
||
function prepare_bouton_confirmation($id)
|
||
{
|
||
$list = $this->Projets_model->mod_getRecord_projet_produit_details_multiple($id, true);
|
||
|
||
if (count($list) > 0) {
|
||
|
||
$mem_nbproduit = count($list);
|
||
$mem_return = ' <div class="row"><section class="col col-4">' . $mem_nbproduit . ' produit à confirmer ';
|
||
|
||
$mem_return .= '<button id="submit_btn_confirmation" type="submit" class="btn btn-danger btn-circle glyphicon glyphicon-envelope "></button>';
|
||
|
||
|
||
$mem_return .= '</section> </div>';
|
||
|
||
return $mem_return;
|
||
|
||
|
||
}
|
||
return '';
|
||
|
||
}
|
||
|
||
public function mod_getRecord_projet_produit_details_multiple($id, $confirmation = false)
|
||
{
|
||
|
||
$this->db->select('*');
|
||
$this->db->from("proj_details");
|
||
$this->db->join('proj_details_details', 'proj_details.proj_det_id=proj_details_details.detail_id', 'left');
|
||
|
||
if ($confirmation) {
|
||
$this->db->where('proj_details_details.det_con_active', 1);
|
||
}
|
||
$this->db->where('proj_details.proj_ent_id=' . $id);
|
||
|
||
|
||
$query = $this->db->get();
|
||
$mem_return = $query->result_array();
|
||
|
||
|
||
return $mem_return;
|
||
}
|
||
|
||
function prepare_bouton_facturation($id)
|
||
{
|
||
$list = $this->Projets_model->mod_getRecord_projet_produit_details_multiple_fac($id, true);
|
||
|
||
if (count($list) > 0) {
|
||
|
||
$mem_nbproduit = count($list);
|
||
$mem_return = ' <div class="row"><section class="col col-4">' . $mem_nbproduit . ' produit à facturer ';
|
||
|
||
$mem_return .= '<button id="submit_btn_facturation" type="submit" class="btn btn-danger btn-circle glyphicon glyphicon-envelope "></button>';
|
||
|
||
|
||
$mem_return .= '</section> </div>';
|
||
|
||
return $mem_return;
|
||
|
||
|
||
}
|
||
return '';
|
||
|
||
}
|
||
|
||
public function mod_getRecord_projet_produit_details_multiple_fac($id, $confirmation = false)
|
||
{
|
||
|
||
$this->db->select('*');
|
||
$this->db->from("proj_details");
|
||
$this->db->join('proj_details_details', 'proj_details.proj_det_id=proj_details_details.detail_id', 'left');
|
||
|
||
if ($confirmation) {
|
||
$this->db->where('proj_details_details.det_fac_active', 1);
|
||
}
|
||
$this->db->where('proj_details.proj_ent_id=' . $id);
|
||
|
||
|
||
$query = $this->db->get();
|
||
$mem_return = $query->result_array();
|
||
|
||
|
||
return $mem_return;
|
||
}
|
||
|
||
function prepare_list_confirmation($id)
|
||
{
|
||
$list = $this->Projets_model->mod_getRecord_projet_confirmation_lot_pdf($id);
|
||
//print("<pre>".print_r( $list,true)."</pre>");
|
||
|
||
$mem_return = '';
|
||
if (count($list) > 0) {
|
||
$lotnum = 0;
|
||
$lotdate = "";
|
||
$lotpdf = "";
|
||
$mem_return = '<table width="100%">';
|
||
foreach ($list as $key => $value) {
|
||
if ($lotpdf <> $value['proj_con_pdf']) {
|
||
// print_r($value);
|
||
|
||
$lotdate = $value['proj_con_pdf_creation'];
|
||
$lotpdf = "";
|
||
$x = 1;
|
||
if ($lotnum <> $value['proj_con_pdf_lot_numero']) {
|
||
$mem_return .= ' <tr><td colspan="3" > </td> </tr><tr style="border: 2px solid #000;"><td width="20%"> ' . $lotdate . '</td> ';
|
||
//$mem_return.=' <td width="5%"> <a href="/index.php/Projets/desactivate_confirmation/'. $lotnum.'/'.$id.'" class="btn btn-danger btn-circle glyphicon glyphicon-trash "> </a></td> ';
|
||
$mem_return .= ' <td width="5%">' . $value['proj_con_pdf_lot_numero'] . ' </td>';
|
||
$mem_return .= ' <td width="80%"> <section></td></tr>';
|
||
}
|
||
$lotnum = $value['proj_con_pdf_lot_numero'];
|
||
|
||
// echo($lotnum.'<br>');
|
||
|
||
|
||
$lotpdf = $value['proj_con_pdf'];
|
||
|
||
// a faire
|
||
// path pdf
|
||
$mem_return .= ' <tr><td width="10%"></td><td width="5%"> ';
|
||
$mem_return .= '<button class="fa fa-tag" type="reset" id="cliptext" value="' . 'Confirmation ' . $value['client'] . ' ' . $value['proj_nom'] . ' ' . $value['proj_date_debut'] . '"></button> ';
|
||
|
||
$mem_return .= ' </td><td width="80%"><a target="_blank" href="' . base_url() . '/pdf/pdf2019/confirmation/' . htmlentities($lotpdf) . ' ">' . $lotpdf . '</a> </td></tr> ';
|
||
//echo($lotpdf.'<br>');
|
||
|
||
}
|
||
$lotpdf = $value['proj_con_pdf'];
|
||
}
|
||
$mem_return .= '</table>';
|
||
}
|
||
return $mem_return;
|
||
|
||
}
|
||
|
||
public function mod_getRecord_projet_confirmation_lot_pdf($id)
|
||
{
|
||
|
||
// $this->db->select('*');
|
||
// $this->db->from("proj_details");
|
||
// $this->db->join('proj_details_details', 'proj_details.proj_det_id=proj_details_details.detail_id', 'left');
|
||
// $this->db->order_by('det_con_lot_numero');
|
||
// $this->db->order_by('det_con_pdf');
|
||
// $this->db->where('proj_details_details.det_con_lot_fait', 1);
|
||
|
||
// $this->db->where('proj_details.proj_ent_id=' . $id);
|
||
$this->db->select('*,cli_compte.com_compagnie as client');
|
||
$this->db->from("proj_con_pdf");
|
||
$this->db->join('proj_details_details', 'proj_con_pdf.proj_con_pdf_detail_detail_id =proj_details_details.detail_id', 'left');
|
||
$this->db->join('proj_details', 'proj_con_pdf.proj_con_pdf_detail_detail_id =proj_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('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id ', 'left');
|
||
|
||
$this->db->order_by('proj_con_pdf_lot_numero');
|
||
$this->db->order_by('proj_con_pdf');
|
||
$this->db->where('proj_con_pdf_ent_id=' . $id);
|
||
$query = $this->db->get();
|
||
$mem_return = $query->result_array();
|
||
|
||
|
||
return $mem_return;
|
||
}
|
||
|
||
function prepare_list_facturation($id)
|
||
{
|
||
$list = $this->Projets_model->mod_getRecord_projet_facturation_lot_pdf($id);
|
||
|
||
$mem_return = '';
|
||
if (count($list) > 0) {
|
||
$lotnum = 0;
|
||
$lotdate = "";
|
||
$lotpdf = "";
|
||
$mem_return = '<table width="100%">';
|
||
foreach ($list as $key => $value) {
|
||
if ($lotnum <> $value['det_fac_lot_numero']) {
|
||
$lotnum = $value['det_fac_lot_numero'];
|
||
$lotdate = $value['det_fac_envoi'];
|
||
$numerofacture = $value['det_fac_numero'];
|
||
$lotpdf = "";
|
||
|
||
$x = 1;
|
||
|
||
$mem_return .= ' <tr><td colspan="4" > </td> </tr><tr style="border: 2px solid #000;"><td width="20%"> ' . $lotdate . '</td> ';
|
||
$mem_return .= ' <td width="15%">' . $lotnum . ' </td> ';
|
||
if ($value['det_fac_lock'] == 0) {
|
||
$mem_return .= ' <td width="5%"> <a href="/index.php/Projets/desactivate_facturation/' . $lotnum . '/' . $id . '" class="btn btn-danger btn-circle glyphicon glyphicon-trash "> </a></td><td></td><td><a href="/index.php/Projets/lock_facturation/' . $lotnum . '/' . $id . '" class="btn btn-danger btn-circle glyphicon glyphicon-lock "> </a> </td> ';
|
||
|
||
} else {
|
||
$mem_return .= ' <td width="5%">' . $numerofacture . ' </td> ';
|
||
|
||
}
|
||
|
||
|
||
$mem_return .= ' <td width="80%"> <section></td></tr>';
|
||
|
||
|
||
// echo($lotnum.'<br>');
|
||
} else {
|
||
|
||
}
|
||
if ($lotpdf <> $value['det_fac_pdf']) {
|
||
$return[$lotnum] = $value['det_fac_pdf'];
|
||
$lotpdf = $value['det_fac_pdf'];
|
||
$montant = $value['det_fac_montant'];
|
||
// a faire
|
||
// path pdf
|
||
$mem_return .= ' <tr><td width="10%"></td><td width="5%"><i class="btn-circle glyphicon glyphicon-list-alt"></td>';
|
||
$mem_return .= '<td width="5%">' . $montant . ' </td> ';
|
||
|
||
$mem_return .= '<td width="80%"><a target="_blank" href="' . base_url() . '/pdf/pdf2019/facturation/' . htmlentities($lotpdf) . ' ">' . $lotpdf . '</a> </td></tr> ';
|
||
//echo($lotpdf.'<br>');
|
||
}
|
||
|
||
|
||
}
|
||
$mem_return .= '</table>';
|
||
}
|
||
return $mem_return;
|
||
|
||
}
|
||
|
||
public function mod_getRecord_projet_facturation_lot_pdf($id)
|
||
{
|
||
|
||
$this->db->select('*');
|
||
$this->db->from("proj_details");
|
||
$this->db->join('proj_details_details', 'proj_details.proj_det_id=proj_details_details.detail_id', 'left');
|
||
$this->db->order_by('det_fac_lot_numero');
|
||
$this->db->order_by('det_fac_pdf');
|
||
$this->db->where('proj_details_details.det_fac_lot_fait', 1);
|
||
|
||
$this->db->where('proj_details.proj_ent_id=' . $id);
|
||
|
||
|
||
$query = $this->db->get();
|
||
$mem_return = $query->result_array();
|
||
|
||
|
||
return $mem_return;
|
||
}
|
||
|
||
public function mod_getRecords_produits_fournisseur($id, $listactive = 1)
|
||
{
|
||
|
||
|
||
// list la bb client
|
||
$this->db->select('*,proj_etape,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');
|
||
|
||
|
||
//$this->db->where('det_con_active', 1);
|
||
|
||
|
||
$this->db->where('proj_fou_id', $id);
|
||
|
||
$this->db->order_by("proj_date_debut,des_nom_fr");
|
||
if ($listactive == 1)
|
||
$this->db->where("proj_etape not in (7,4,6)");
|
||
$query = $this->db->get();
|
||
|
||
return $query->result_array();
|
||
}
|
||
|
||
function mod_prepare_confirmation($id)
|
||
{
|
||
// echo($id);
|
||
$mem_lang = 'fr';
|
||
$mem_lot = time();
|
||
$mem_list_lot = $this->Projets_model->mod_getRecords_confirmations($id);
|
||
|
||
//$mem_list_lot= $this->mod_getRecords_lot($listeafaire);
|
||
//print_r($mem_list_lot);
|
||
$mem_fou_id = 0;
|
||
$mem_contact_id = 0;
|
||
$mem_reservation_fou = array();
|
||
$mem_fou = '';
|
||
$mem_proj_num = '';
|
||
$mem_client = '';
|
||
$mem_fou_email = '';
|
||
// $this->lang->load("pdf_lang","french");
|
||
|
||
// print("<pre>".print_r($mem_list_lot,true)."</pre>");
|
||
// exit;
|
||
foreach ($mem_list_lot as $key => $value) {
|
||
// echo($value['proj_fou_id']);
|
||
// echo($mem_fou_id);
|
||
// print("<pre>".print_r($value,true)."</pre>");
|
||
if ($mem_fou_id != $value['proj_fou_id'] && $mem_fou_id != 0) {
|
||
// echo('post</br>');
|
||
// valide si 1er lecture
|
||
// if ($mem_fou_id==0){
|
||
|
||
// }else{
|
||
$mem_nom = $mem_fou . ' ' . $mem_client . " " . $mem_proj_num . '-' . $mem_lot . '.pdf';
|
||
// echo($mem_nom);
|
||
$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);
|
||
$pdfdoc = $this->Lots_pdf_model->mod_pdf_confirmation($mem_reservation_fou, $mem_nom, $mem_lot, $mem_lang);
|
||
// print_r($mem_reservation_fou);
|
||
// a faire
|
||
// coriger le path
|
||
|
||
file_put_contents(FCPATH . 'pdf/pdf2019/confirmation/' . $mem_nom, $pdfdoc);
|
||
|
||
$mem_reservation_fou = array();
|
||
}
|
||
// print("<pre>".print_r($value,true)."</pre>");
|
||
if ($value['fou_langue'] == 2) {
|
||
$mem_lang = 'en';
|
||
$this->lang->load("pdf_lang", "english");
|
||
} else {
|
||
$mem_lang = 'fr';
|
||
$this->lang->load("pdf_lang", "french");
|
||
|
||
}
|
||
|
||
$mem_reservation_fou[] = $value;
|
||
|
||
$mem_contact_id = $value['det_res_contact_id'];
|
||
if ($value['com_compagnie_fou'] != '')
|
||
$mem_fou = $value['com_compagnie_fou'];
|
||
else
|
||
$mem_fou = $value['des_nom_' . $mem_lang];
|
||
|
||
|
||
$mem_client = $value['com_compagnie_client'];
|
||
$mem_fou_email = $value['fou_contact_courriel'];
|
||
$mem_proj_num = $value['proj_numero'];
|
||
// nouveau fournisseurs
|
||
// echo('<br>');
|
||
// echo($value['com_compagnie_fou'].' '.$value['det_res_contact_id']);
|
||
// echo('<br>');
|
||
|
||
$mem_fou_id = $value['proj_fou_id'];
|
||
// echo('<br>');
|
||
// echo('----'.$value['com_compagnie_client']);
|
||
// echo('<br>');
|
||
|
||
|
||
}
|
||
|
||
if (1 == 1) {
|
||
$mem_nom = $mem_fou . ' ' . $mem_client . " " . $mem_proj_num . '-' . $mem_lot . '.pdf';
|
||
// echo($mem_nom);
|
||
$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);
|
||
$pdfdoc = $this->Lots_pdf_model->mod_pdf_confirmation($mem_reservation_fou, $mem_nom, $mem_lot, $mem_lang);
|
||
// print_r($mem_reservation_fou);
|
||
// a faire
|
||
// coriger le path
|
||
|
||
file_put_contents(FCPATH . 'pdf/pdf2019/confirmation/' . $mem_nom, $pdfdoc);
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
public function mod_getRecords_confirmations($id)
|
||
{
|
||
|
||
|
||
// 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');
|
||
|
||
|
||
$this->db->where('det_con_active', 1);
|
||
|
||
|
||
$this->db->where('proj_ent_id', $id);
|
||
|
||
$this->db->order_by("fou_compte.com_id,pro_descriptions.des_ref_type ");
|
||
|
||
$query = $this->db->get();
|
||
|
||
return $query->result_array();
|
||
}
|
||
|
||
function mod_prepare_facturation($id)
|
||
{
|
||
|
||
|
||
$mem_lot = time();
|
||
$mem_fact_list = $this->Projets_model->mod_getRecords_facturation($id);
|
||
//print_r($mem_fact_list);
|
||
//exit;
|
||
$client = $this->Clients_model->mod_getRecord($mem_fact_list[0]['cli_id']);
|
||
// echo ($mem_fact_list[0]['con_prenom'].'<br>');
|
||
// print_r($mem_fact_list);
|
||
// echo('---------------<br><br><br><br>');
|
||
|
||
|
||
if ($client->com_langue == 2) {
|
||
$mem_lang = 'en';
|
||
$this->lang->load("pdf_lang", "english");
|
||
} else {
|
||
$mem_lang = 'fr';
|
||
$this->lang->load("pdf_lang", "french");
|
||
|
||
}
|
||
|
||
|
||
$mem_nom = $mem_fact_list[0]['com_compagnie_client'] . " " . $mem_fact_list[0]['proj_numero'] . '-' . $mem_lot . '.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);
|
||
$pdfdoc = $this->Lots_pdf_model->mod_pdf_facturation($mem_fact_list, $mem_nom, $mem_lot, $client, $mem_lang);
|
||
// print_r($mem_reservation_fou);
|
||
// a faire
|
||
// coriger le path
|
||
|
||
|
||
file_put_contents(FCPATH . 'pdf/pdf2019/facturation/' . $mem_nom, $pdfdoc);
|
||
|
||
|
||
}
|
||
|
||
public function mod_getRecords_facturation($id)
|
||
{
|
||
|
||
|
||
// list la bb client
|
||
$this->db->select('*,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('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->join('usa_usagers', 'usa_usagers.usa_id=proj_entete.proj_representant_id', 'left');
|
||
|
||
|
||
$this->db->where('det_fac_active', 1);
|
||
|
||
|
||
$this->db->where('proj_ent_id', $id);
|
||
|
||
$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();
|
||
}
|
||
|
||
function mod_desactivate_confirmation($lot_numero)
|
||
{
|
||
$mem_data['det_con_envoi'] = "0000-00-00 00:00:00";
|
||
$mem_data['det_con_active'] = 1;
|
||
$mem_data['det_con_lot_fait'] = 0;
|
||
$mem_data['det_con_pdf'] = '';
|
||
$mem_data['det_con_lot_numero'] = 0;
|
||
$mem_where = "det_con_lot_numero =" . $lot_numero;
|
||
|
||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||
}
|
||
|
||
function mod_lock_facturation($lot_numero)
|
||
{
|
||
// ajoute numero de facture
|
||
$this->db->select('*');
|
||
$this->db->from('proj_details_details');
|
||
$this->db->where("det_fac_lot_numero =" . $lot_numero);
|
||
|
||
$query = $this->db->get();
|
||
$sortie = $query->row();
|
||
|
||
$mem_fact = $this->Config_model->conf_numero_facture();
|
||
|
||
$mem_pdf = $sortie->det_fac_pdf;
|
||
$this->Lots_pdf_model->mod_pdf_facturation_ajoutenumero($mem_pdf, $mem_fact);
|
||
|
||
// lock projet
|
||
$mem_data['det_fac_lock'] = 1;
|
||
$mem_data['det_etape'] = 3;
|
||
$mem_data['det_fac_numero'] = $mem_fact;
|
||
$mem_where = "det_fac_lot_numero =" . $lot_numero;
|
||
|
||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||
|
||
}
|
||
|
||
function mod_desactivate_facturation($lot_numero)
|
||
{
|
||
$mem_data['det_fac_envoi'] = "0000-00-00 00:00:00";
|
||
$mem_data['det_fac_active'] = 1;
|
||
// test stephan
|
||
// $mem_data['det_fac_montant']=0;
|
||
$mem_data['det_fac_lot_fait'] = 0;
|
||
$mem_data['det_fac_pdf'] = '';
|
||
$mem_data['det_fac_lot_numero'] = 0;
|
||
$mem_where = "det_fac_lot_numero =" . $lot_numero;
|
||
|
||
$str = $this->db->update('proj_details_details', $mem_data, $mem_where);
|
||
|
||
}
|
||
|
||
function mod_listprojet_count_jour($filtre1, $filtre2, $filtre3, $filtre4, $hebergement)
|
||
{
|
||
$result = $this->mod_getRecordsold(0, 9999, $filtre1, $filtre2, $filtre3, $filtre4, 'proj_date_confirmation', 1, 'fr', $hebergement);
|
||
|
||
|
||
$sortie['details'] = $result;
|
||
$sortie['jour'] = array();
|
||
$index_date = 0;
|
||
$mem_date = '';
|
||
foreach ($sortie['details'] as $key => $row) {
|
||
if ($mem_date != $row['proj_date_confirmation']) {
|
||
$index_date++;
|
||
$mem_date = $row['proj_date_confirmation'];
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_confirmation'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
$sortie['jour'][$index_date]['details'] = '';
|
||
}
|
||
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . '
' . '<br>';
|
||
|
||
|
||
}
|
||
if ($sortie['details'] != null) {
|
||
if ($mem_date != $row['proj_date_confirmation']) {
|
||
$index_date++;
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_confirmation'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
}
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . '
' . '<br>';
|
||
|
||
}
|
||
|
||
return $sortie;
|
||
}
|
||
|
||
public function mod_getRecordsold($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $filtre4 = "", $trie = "null", $listactive = 1, $langue = 'fr', $hebergement = 2)
|
||
{
|
||
// list la bb client
|
||
$this->db->select('*,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');
|
||
|
||
$this->db->limit($rowperpage, $rowno);
|
||
if ($trie != "null") {
|
||
$this->db->order_by($trie);
|
||
} else {
|
||
|
||
}
|
||
if ($hebergement != 2)
|
||
$this->db->where("proj_hebergement=" . $hebergement);
|
||
if ($filtre1 != "" && $filtre1 != 0)
|
||
$this->db->where("usa_id=" . $filtre1);
|
||
if ($filtre2 != "")
|
||
$this->db->where("com_compagnie LIKE '%$filtre2%'");
|
||
if ($filtre4 != "")
|
||
$this->db->where("proj_numero LIKE '%$filtre4%'");
|
||
|
||
if ($filtre3 != "") {
|
||
$this->db->where("proj_etape=" . $filtre3);
|
||
} else {
|
||
if ($listactive == 1)
|
||
$this->db->where("proj_etape not in (7,4,6)");
|
||
|
||
}
|
||
$query = $this->db->get();
|
||
|
||
$clients = $query->result_array();
|
||
|
||
foreach ($clients as $key => $value) {
|
||
$clients[$key]['total'] = $this->mod_tot_projet($value['proj_id']);
|
||
|
||
}
|
||
|
||
|
||
return $clients;
|
||
}
|
||
|
||
function mod_listprojetdebut_count_jour($filtre1, $filtre2, $filtre3, $filtre4, $hebergement)
|
||
{
|
||
$result = $this->mod_getRecordsold(0, 9999, $filtre1, $filtre2, $filtre3, $filtre4, 'proj_date_debut', 1, 'fr', $hebergement);
|
||
|
||
|
||
$sortie['details'] = $result;
|
||
$sortie['jour'] = array();
|
||
$index_date = 0;
|
||
$mem_date = '';
|
||
foreach ($sortie['details'] as $key => $row) {
|
||
if ($mem_date != $row['proj_date_debut']) {
|
||
$index_date++;
|
||
$mem_date = $row['proj_date_debut'];
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_debut'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
$sortie['jour'][$index_date]['details'] = '';
|
||
}
|
||
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . ' ' . '<br>';
|
||
|
||
|
||
}
|
||
if ($sortie['details'] != null) {
|
||
if ($mem_date != $row['proj_date_debut']) {
|
||
$index_date++;
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_debut'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
}
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . ' ' . '<br>';
|
||
|
||
}
|
||
|
||
return $sortie;
|
||
}
|
||
|
||
function mod_listprojetdebut_count_jour_dossard($filtre1, $filtre2, $filtre3, $filtre4, $hebergement)
|
||
{
|
||
$result = $this->mod_getRecordsold(0, 9999, $filtre1, $filtre2, $filtre3, $filtre4, 'proj_date_debut', 1, 'fr', $hebergement);
|
||
|
||
|
||
$sortie['details'] = $result;
|
||
$sortie['jour'] = array();
|
||
$index_date = 0;
|
||
$mem_date = '';
|
||
foreach ($sortie['details'] as $key => $row) {
|
||
if ($mem_date != $row['proj_date_confirmation']) {
|
||
$index_date++;
|
||
$mem_date = $row['proj_date_confirmation'];
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_confirmation'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
$sortie['jour'][$index_date]['details'] = '';
|
||
}
|
||
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . ' ' . '<br>';
|
||
|
||
|
||
}
|
||
if ($sortie['details'] != null) {
|
||
if ($mem_date != $row['proj_date_confirmation']) {
|
||
$index_date++;
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_confirmation'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
}
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . ' ' . '<br>';
|
||
|
||
}
|
||
|
||
return $sortie;
|
||
}
|
||
|
||
function mod_listprojetdate_annule_count_jour($filtre1, $filtre2, $filtre3, $filtre4, $hebergement)
|
||
{
|
||
$result = $this->mod_getRecordsold(0, 9999, $filtre1, $filtre2, $filtre3, $filtre4, 'proj_date_annule', 1, 'fr', $hebergement);
|
||
|
||
|
||
$sortie['details'] = $result;
|
||
$sortie['jour'] = array();
|
||
$index_date = 0;
|
||
$mem_date = '';
|
||
// print_r($result);
|
||
foreach ($sortie['details'] as $key => $row) {
|
||
if ($mem_date != $row['proj_date_annule']) {
|
||
|
||
$index_date++;
|
||
$mem_date = $row['proj_date_annule'];
|
||
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_annule'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
$sortie['jour'][$index_date]['details'] = '';
|
||
}
|
||
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . ' ' . '<br>';
|
||
|
||
|
||
}
|
||
if ($sortie['details'] != null) {
|
||
if ($mem_date != $row['proj_date_annule']) {
|
||
$index_date++;
|
||
$sortie['jour'][$index_date]['start'] = $row['proj_date_annule'];
|
||
$sortie['jour'][$index_date]['qte'] = 0;
|
||
}
|
||
$mem_link_go = anchor('projets/form/' . $row['proj_id'], ' ', 'target="tache" class="btn btn-primary btn-circle glyphicon glyphicon-circle-arrow-right " ');
|
||
|
||
|
||
$sortie['jour'][$index_date]['qte'] = $sortie['jour'][$index_date]['qte'] + 1;
|
||
$sortie['jour'][$index_date]['details'] = $sortie['jour'][$index_date]['details'] . ' ' . $mem_link_go . ' ' . $row['compagnie'] . ' <i class="fa fa-circle"></i> ' . $row['proj_nom'] . ' <i class="fa fa-user"></i> ' . $row['rep_prenom'] . ' ' . $row['rep_nom'] . ' ' . '<br>';
|
||
|
||
}
|
||
|
||
return $sortie;
|
||
}
|
||
}
|