load->database(); $this->load->helper('date'); $this->load->model('FxForm_model'); $this->load->model('Config_model'); $this->load->model('Lots_pdf_model'); } public function mod_getRecordCount() { $this->db->select('count(*) as allcount'); $this->db->from('proj_details_details'); $this->db->where('det_res_active',1); $query = $this->db->get(); $result = $query->result_array(); return $result[0]['allcount']; } public function mod_modiflot($id,$choix){ if ($choix==1){ $mem_data['det_res_creation'] = date("Y-m-d H:i:s"); $mem_data['det_res_active'] = $choix; }else{ $mem_data['det_res_creation'] = "0000-00-00 00:00:00"; $mem_data['det_res_active'] = $choix; } $mem_where = 'detail_id =' . $id; $str = $this->db->update('proj_details_details', $mem_data, $mem_where); return; } public function mod_modiflot_send_reservation($id,$lotnum){ $mem_data['det_res_envoi'] = date("Y-m-d H:i:s"); $mem_data['det_res_active'] = 0; $mem_data['det_res_lot_fait'] = 1; $mem_data['det_res_lot_numero'] = $lotnum; $mem_where = 'detail_id =' . $id; $str = $this->db->update('proj_details_details', $mem_data, $mem_where); return; } public function mod_modiflot_pdf_confirmation($id,$nom,$mem_lot,$proj_ent_id){ $mem_data['det_con_envoi'] = date("Y-m-d H:i:s"); $mem_data['det_con_lot_fait'] = 1; $mem_data['det_con_active'] = 0; $mem_data['det_con_pdf'] = utf8_encode($nom); $mem_data['det_con_lot_numero'] = $mem_lot; $mem_where = 'detail_id =' . $id; $str = $this->db->update('proj_details_details', $mem_data, $mem_where); // bd unique $mem_data2['proj_con_pdf_creation'] = date("Y-m-d H:i:s"); // $mem_data['det_con_envoi'] = date("Y-m-d H:i:s"); $mem_data2['proj_con_pdf'] = utf8_encode($nom); $mem_data2['proj_con_pdf_lot_numero'] = $mem_lot; $mem_data2['proj_con_pdf_detail_detail_id'] = $id; $mem_data2['proj_con_pdf_ent_id'] = $proj_ent_id; $str = $this->db->insert('proj_con_pdf', $mem_data2); return; } public function mod_modiflot_pdf_facturation($id,$nom,$mem_lot,$mem_montant=123){ $mem_data['det_fac_envoi'] = date("Y-m-d H:i:s"); $mem_data['det_fac_lot_fait'] = 1; $mem_data['det_fac_active'] = 0; $mem_data['det_fac_montant'] =$mem_montant; $mem_data['det_fac_pdf'] = utf8_encode($nom); $mem_data['det_fac_lot_numero'] = $mem_lot; $mem_where = 'detail_id =' . $id; $str = $this->db->update('proj_details_details', $mem_data, $mem_where); return; } public function mod_modiflot_pdf_facturation_montant($mem_lot,$mem_montant){ $mem_data=$mem_montant; $mem_where = 'det_fac_lot_numero =' . $mem_lot; $str = $this->db->update('proj_details_details', $mem_data, $mem_where); return; } public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif=1) { $this->db->select('count(*) as allcount'); $this->db->from('proj_details_details'); if ($listactif==1) $this->db->where('det_res_active', 1); else $this->db->where('det_res_lot_fait', 1); // if ($filtre1 != "") // $this->db->where("des_nom_fr LIKE '%$filtre1%'"); // if ($filtre2 != "") // $this->db->where("des_description_fr LIKE '%$filtre2%'"); // if ($filtre3 != "") // $this->db->where("des_ref_type = " . $filtre3); $query = $this->db->get(); $result = $query->result_array(); return $result[0]['allcount']; } public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif = 1, $langue = 'fr') { // list la bb client $this->db->select('*,fou_compte.com_langue as fou_langue,cli_contacts.con_prenom as cli_contact_prenom,cli_contacts.con_nom as cli_contact_nom,fou_contacts.con_courriel as fou_contact_courriel,fou_contacts.con_prenom as fou_contact_prenom,fou_contacts.con_nom as fou_contact_nom,cli_compte.com_compagnie as com_compagnie_client,fou_compte.com_compagnie as com_compagnie_fou'); $this->db->from('proj_details_details'); $this->db->join('proj_details', 'proj_details.proj_det_id=proj_details_details.proj_det_id', 'left'); $this->db->join('proj_entete', 'proj_entete.proj_id=proj_details.proj_ent_id', 'left'); $this->db->join('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left'); $this->db->join('pro_descriptions', 'pro_descriptions.des_id=proj_details.proj_prod_id', 'left'); $this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left'); $this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id', 'left'); $this->db->join('fou_contacts', 'fou_contacts.con_id=proj_details_details.det_res_contact_id', 'left'); $this->db->join('cli_contacts', 'cli_contacts.con_id=proj_entete.proj_contact_principale', 'left'); if ($listactif==1) $this->db->where('det_res_active', 1); else $this->db->where('det_res_lot_fait', 1); if ($filtre1 != "") $this->db->where("fou_compte.com_compagnie LIKE '%$filtre1%'"); if ($filtre2 != "") $this->db->where("des_description_fr LIKE '%$filtre2%'"); if ($filtre3 != "") $this->db->where("des_ref_type = " . $filtre3); $this->db->limit($rowperpage, $rowno); $this->db->order_by("fou_compte.com_id,proj_details_details.det_res_contact_id,proj_details_details.det_res_creation"); $query = $this->db->get(); return $query->result_array(); } public function mod_getRecords_lot($listafaire,$listactif=1) { if (isset($listafaire['go'])){ $liste = implode(',',$listafaire['go']); // list la bb client $this->db->select('*,fou_compte.com_langue as fou_langue,cli_contacts.con_prenom as cli_contact_prenom,cli_contacts.con_nom as cli_contact_nom,fou_contacts.con_courriel as fou_contact_courriel,fou_contacts.con_prenom as fou_contact_prenom,fou_contacts.con_nom as fou_contact_nom,cli_compte.com_compagnie as com_compagnie_client,fou_compte.com_compagnie as com_compagnie_fou'); $this->db->from('proj_details_details'); $this->db->join('proj_details', 'proj_details.proj_det_id=proj_details_details.proj_det_id', 'left'); $this->db->join('proj_entete', 'proj_entete.proj_id=proj_details.proj_ent_id', 'left'); $this->db->join('fou_compte', 'fou_compte.com_id=proj_details.proj_fou_id', 'left'); $this->db->join('pro_descriptions', 'pro_descriptions.des_id=proj_details.proj_prod_id', 'left'); $this->db->join('fou_genres', 'fou_genres.gen_id=pro_descriptions.des_ref_type', 'left'); $this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id', 'left'); $this->db->join('fou_contacts', 'fou_contacts.con_id=proj_details_details.det_res_contact_id', 'left'); $this->db->join('cli_contacts', 'cli_contacts.con_id=proj_entete.proj_contact_principale', 'left'); if ($listactif==1) $this->db->where('det_res_active', 1); else $this->db->where('det_res_lot_fait', 1); $this->db->where('FIND_IN_SET(proj_details.proj_det_id ,"'. $liste.'") '); $this->db->order_by("fou_compte.com_id,proj_details_details.det_res_contact_id,proj_details_details.det_res_creation"); $query = $this->db->get(); return $query->result_array(); } } public function mod_loadData_list($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $listactif = 1 ) { // $config['suffix'] = '/'.$filtre1.'/'. $filtre2.'/'.$filtre3.'/'. $listactif; $filtre1 = ($filtre1 == 'null' ? '' : $filtre1); $filtre2 = ($filtre2 == 'null' ? '' : $filtre2); $filtre3 = ($filtre3 == 'null' ? '' : $filtre3); //echo($listactif); $recordPerPage = 10000; $config["cur_page"] = $record; if ($record != 0) { $record = ($record - 1) * $recordPerPage; } $recordCount2 = $this->mod_getRecordCount(); $recordCount = $this->mod_getRecordCountfilter($filtre1, $filtre2, $filtre3, $listactif); $client_list = $this->mod_getRecords($record, $recordPerPage, $filtre1, $filtre2, $filtre3, $listactif); $config['base_url'] = base_url() . 'index.php/Lots/loadData_list'; $config['use_page_numbers'] = TRUE; $config['next_link'] = 'Next'; $config['prev_link'] = 'Previous'; $config['total_rows'] = $recordCount; $config['per_page'] = $recordPerPage; $choice = $config["total_rows"] / $config["per_page"]; $config["uri_segment"] = 2; $config["num_links"] = 2; $config['full_tag_open'] = '
'; $config['first_link'] = '« First'; $config['first_tag_open'] = ''; $config['last_link'] = 'Last »'; $config['last_tag_open'] = ''; $config['next_link'] = 'Next →'; $config['next_tag_open'] = ''; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = ''; $config['cur_tag_open'] = '
  • '; $config['cur_tag_close'] = '
  • '; $config['num_tag_open'] = '
  • '; $config['num_tag_close'] = '
  • '; $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); $data['recordCount'] = $recordCount2; // switch voir delete // creation du tableau // prepare header $mem_link_new = ""; //$mem_link_new=anchor('Produits/form/0' , ' ', 'class="btn btn-primary btn-circle glyphicon glyphicon-pencil" '); if ($listactif==1){ // $mem_link_new = ' '; // $mem_link_new = anchor('lots/prepare_lot', ' ', 'class="btn btn-danger btn-circle glyphicon glyphicon-envelope " '); $mem_link_new = '
    Test ' ; $ent_date='Date'; $ent_lotno=' '; }else{ $ent_date="Date d'envoi"; $ent_lotno='Lot num'; } $header = array($mem_link_new, 'Type de produit', 'Fournisseur', 'Client', 'Projet', $ent_date, $ent_lotno, 'No projet'); // prépare les donnés du tableau $nbitem = 0; // filter global $mem_data; $data_row = array(); $data_row[] = array('data' => 'Filtre', 'align' => 'left'); // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- $mem_champ = 'filtre_produits_2'; $mem_value = $filtre2; $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_2'); $mem_filtre = form_input($mem_data['input'][$mem_champ]); //$data_row[] = array('data' => $mem_filtre, 'align' => 'left'); // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- $mem_champ = 'filtre_produits_3'; $mem_value = $filtre3; $mem_data['select'][$mem_champ]['choix'] = $this->Config_model->conf_getGenresFournisseur('fr', true, 1); // value multipli select //$mem_value = explode(',', $mem_value); $mem_filtre = form_dropdown($mem_champ, $mem_data['select'][$mem_champ]['choix'], $mem_value, 'class="filtre_produits_3"'); $data_row[] = array('data' => $mem_filtre, 'align' => 'left'); $mem_champ = 'filtre_produits_1'; $mem_value = $filtre1; $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, '', '', '', 'filtre_produits_1'); $mem_filtre = form_input($mem_data['input'][$mem_champ]); $data_row[] = array('data' => $mem_filtre, 'align' => 'left'); // echo form_dropdown($mem_champ,$select[$mem_champ]['choix'],$select[$mem_champ]['value']); // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- $tabular_data[] = $data_row; // prépare les donnés du tableau foreach ($client_list as $row) { $nbitem++; // $mem_link_edit = anchor('Projets/choix_produit/' . $row['des_id'] , ' ', 'class="btn btn-success btn-circle glyphicon glyphicon-plus-sign" '); $mem_link_edit = ''; $mem_link_delete = ''; if ($listactif==1){ // $mem_link_edit=' '; $mem_link_edit= ''; } else{ // $mem_link_edit=' '; } // '; $data_row = array(); $data_row[] = array('data' => $mem_link_edit . ' ' . $mem_link_delete, 'align' => 'left'); $data_row[] = array('data' => $row['gen_nom_fr'], 'align' => 'left'); $data_row[] = array('data' => $row['com_compagnie_fou'], 'align' => 'left'); $data_row[] = array('data' => $row['com_compagnie_client'], 'align' => 'left'); $data_row[] = array('data' => $row['proj_nom'], 'align' => 'left'); if ($listactif==1){ $data_row[] = array('data' => $row['det_res_creation'], 'align' => 'left'); $data_row[] = array('data' => " ", 'align' => 'left'); }else{ $data_row[] = array('data' => $row['det_res_envoi'], 'align' => 'left'); $data_row[] = array('data' => $row['det_res_lot_numero'], 'align' => 'left'); } $data_row[] = array('data' => $row['proj_numero'], 'align' => 'left'); // $data_row[] = array('data' => $row['type'], 'align' => 'left'); $tabular_data[] = $data_row; } $template = array( 'table_open' => '', 'thead_open' => '', 'thead_close' => '', 'heading_row_start' => '', 'heading_row_end' => '', 'heading_cell_start' => '', 'tbody_open' => '', 'tbody_close' => '', 'row_start' => '', 'row_end' => '', 'cell_start' => '', 'row_alt_start' => '', 'row_alt_end' => '', 'cell_alt_start' => '', 'table_close' => '
    ', 'heading_cell_end' => '
    ', 'cell_end' => '
    ', 'cell_alt_end' => '
    ' ); $this->table->set_template($template); $this->table->set_heading($header); $tableau_sortie = $this->table->generate($tabular_data); $data['list'] = $tableau_sortie; return $data; } function mod_prepare_lot($listeafaire){ $mem_list_lot= $this->mod_getRecords_lot($listeafaire); if(count( $mem_list_lot)!=0){ $mem_test=0; if (isset($listeafaire['test_email'])) $mem_test=1; $mem_fou_id=0; $mem_contact_id=0; $mem_reservation_fou=array(); $mem_fou=''; $mem_fou_email=''; // print("
    ".print_r($mem_list_lot,true)."
    "); //$mem_email=$this->load->view('lots/email_fr', '', true); foreach ($mem_list_lot as $key => $value ){ // echo($this->lang->line('reservation')); // exit; if ($mem_fou_id!=$value['proj_fou_id'] || $mem_contact_id!=$value['det_res_contact_id']){ // valide si 1er lecture if ($mem_fou_id==0){ }else{ // echo($mem_langue.' a
    '); $pdfdoc= $this->Lots_pdf_model->mod_pdf_reservation( $mem_reservation_fou,$mem_langue); $mem_nom=$mem_fou." ".uniqid().'.pdf'; $mem_nom= str_replace(' ', '_', $mem_nom) ; $mem_nom = htmlentities($mem_nom, ENT_NOQUOTES, 'utf-8'); $mem_nom = preg_replace('#&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring);#', '\1', $mem_nom); $mem_nom = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $mem_nom); $mem_nom = preg_replace('#&[^;]+;#', '', $mem_nom); file_put_contents(FCPATH.'pdf/pdf2019/reservation/'. $mem_nom, $pdfdoc ); $data['to_mail']=''; $data['to_name']=''; if ($mem_test==0){ $data['to_mail']=$mem_fou_email; $data['to_name']=''; } $data['body']=$this->load->view('lots/email_'.$mem_langue, '', true); $data['subject']='Reservations ExpressTours '.$mem_fou; $data['from_mail']=$this->config->item('emailreservation'); $data['from_name']='Expresstours'; $data['attach'] = FCPATH.'pdf/pdf2019/reservation/'. $mem_nom; $data['blnGoDaddy'] = 1; $this->Config_model->fxSendMail($data) ; $data['to_mail']=$this->config->item('emailreservationcc'); $data['to_name']='reservations'; $this->Config_model->fxSendMail($data) ; // $mem_reservation_fou=array(); } $mem_fou_id=$value['proj_fou_id']; $mem_contact_id=$value['det_res_contact_id']; $mem_fou=$value['com_compagnie_fou']; $mem_fou_email=$value['fou_contact_courriel']; } // echo('
    '); // echo('----'.$value['com_compagnie_client']); // echo('
    '); if ($value['fou_langue']==2){ $mem_langue='en'; $this->lang->load("pdf_lang","english"); } else{ $mem_langue='fr'; $this->lang->load("pdf_lang","french"); } $mem_reservation_fou[]=$value; } // echo($mem_langue.' b
    '); $pdfdoc= $this->Lots_pdf_model->mod_pdf_reservation( $mem_reservation_fou,$mem_langue); $mem_nom=$mem_fou." ".uniqid().'.pdf'; $mem_nom= str_replace(' ', '_', $mem_nom) ; $mem_nom = htmlentities($mem_nom, ENT_NOQUOTES, 'utf-8'); $mem_nom = preg_replace('#&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring);#', '\1', $mem_nom); $mem_nom = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $mem_nom); $mem_nom = preg_replace('#&[^;]+;#', '', $mem_nom); file_put_contents(FCPATH.'pdf/pdf2019/reservation/'. $mem_nom, $pdfdoc ); $data['to_mail']=''; $data['to_name']=''; if ($mem_test==0){ $data['to_mail']=$mem_fou_email; $data['to_name']=''; } $data['body']=$this->load->view('lots/email_'.$mem_langue, '', true); $data['subject']='Reservations ExpressTours '.$mem_fou; $data['from_mail']=$this->config->item('emailreservation'); $data['from_name']='Expresstours'; $data['attach'] = FCPATH.'pdf/pdf2019/reservation/'. $mem_nom; $data['blnGoDaddy'] = 1; $this->Config_model->fxSendMail($data) ; $data['to_mail']=$this->config->item('emailreservationcc'); $data['to_name']='reservations'; $this->Config_model->fxSendMail($data) ; } // exit; } }