load->database(); } public function conf_getProvinces($langue='fr') { // list la bb client $this->db->select('pro_id,pro_nom_'.$langue.' as nom'); $this->db->from('config_provinces'); $this->db->order_by('pro_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); foreach ($mem_result as $pro ){ $mem_sortie[$pro['pro_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getPays($langue='fr') { // list la bb client $this->db->select('pay_id,pay_nom_'.$langue.' as nom'); $this->db->from('config_pays'); $this->db->order_by('pay_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); foreach ($mem_result as $pro ){ $mem_sortie[$pro['pay_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getLangues($langue='fr') { // list la bb client $this->db->select('lang_id,lang_nom_'.$langue.' as nom'); $this->db->from('config_langues'); $this->db->order_by('lang_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); foreach ($mem_result as $pro ){ $mem_sortie[$pro['lang_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getRolesContacts($langue='fr') { // list la bb client $this->db->select('rol_id,rol_nom'); $this->db->from('cli_contacts_roles'); $this->db->order_by('rol_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); foreach ($mem_result as $pro ){ $mem_sortie[$pro['rol_id']]=$pro['rol_nom']; } return $mem_sortie; } public function conf_getRolesContactsFournisseur($langue='fr') { // list la bb client $this->db->select('rol_id,rol_nom'); $this->db->from('fou_contacts_roles'); $this->db->order_by('rol_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); foreach ($mem_result as $pro ){ $mem_sortie[$pro['rol_id']]=$pro['rol_nom']; } return $mem_sortie; } public function conf_getGenresClient($langue='fr',$choix_vide=false) { // list la bb client $this->db->select('gen_id,gen_nom_'.$langue.' as nom'); $this->db->from('cli_genres'); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['gen_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getFiltreData($usa_id,$page,$var,$vardefault,$update=0,$typenum=1) { // list la bb client $this->db->select('*'); $this->db->from('usa_filtre'); $this->db->where('fil_usa_id',$usa_id); $this->db->where('fil_page',$page); $this->db->where('fil_var',$var); $query = $this->db->get(); $sortie=$query->row(); if ($sortie==null){ $mem_data['fil_usa_id'] = $usa_id ; $mem_data['fil_page']=$page; $mem_data['fil_var']=$var; $mem_data['fil_value']=$vardefault; $str = $this->db->insert('usa_filtre', $mem_data); $mem_return=$vardefault; }else{ if ($update==1){ $mem_data['fil_value']=$vardefault; $mem_where = "fil_usa_id=".$usa_id." and "."fil_page='".$page."' and fil_var='".$var."'"; $str = $this->db->update('usa_filtre', $mem_data, $mem_where); $mem_return=$vardefault; }else{ $mem_return=$sortie->fil_value; } } if ($typenum==0) $mem_return='"'.$mem_return.'"'; return $mem_return; } public function conf_getGenresFournisseur($langue='fr',$choix_vide=false,$produit=0) { // list la bb client $this->db->select('gen_id,gen_nom_'.$langue.' as nom'); $this->db->from('fou_genres'); if ($produit==0) $this->db->where('gen_actif_fournisseur',1); else $this->db->where('gen_actif_produit',1); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['gen_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getGenresPaiement($langue='fr',$choix_vide=false) { // list la bb client $this->db->select('gen_id,gen_nom_'.$langue.' as nom'); $this->db->from('pai_genres'); $this->db->where('gen_actif',1); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['gen_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getClient($langue='fr',$choix_vide=false) { // list la bb client $this->db->select('com_id,com_compagnie as nom'); $this->db->from('cli_compte'); $this->db->order_by('com_compagnie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['com_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getContactClient($langue='fr',$choix_vide=false,$mem_com_id) { // list la bb client $this->db->select('con_id,con_prenom,con_nom'); $this->db->from('cli_contacts'); $this->db->where('con_actif',1); $this->db->where('ref_id',$mem_com_id); $this->db->order_by('con_nom'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['con_id']]=$pro['con_prenom'].' '.$pro['con_nom']; } return $mem_sortie; } public function conf_getGenresProjet($type='a',$langue='fr',$choix_vide=false) { // list la bb client $this->db->select('gen_id,gen_nom_'.$langue.' as nom'); $this->db->from('proj_genres'); $this->db->where('gen_actif',1); $this->db->where('gen_cat',$type); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['gen_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getGenresProjetid( $id,$langue='fr' ) { // list la bb client $this->db->select('gen_id,gen_nom_'.$langue.' as nom'); $this->db->from('proj_genres'); $this->db->where('gen_id',$id); $query = $this->db->get(); $mem_result = $query->row()->nom; return $mem_result; } public function conf_getListeevenement() { $db2 = $this->load->database('ms1inscription', TRUE); // On sélectionne l'année de fin pour trier et afficher si besoin $db2->select('eve_id, eve_nom_fr, eve_date_fin, YEAR(eve_date_fin) AS annee', FALSE); $db2->from('inscriptions_evenements'); $db2->where('eve_actif', 1); $db2->where('eve_nom_fr != ""'); // uniquement ceux qui ont un nom (FR ou pas) // Tri: par année DESC puis par nom FR ASC $db2->order_by('YEAR(eve_date_fin) DESC', '', FALSE); $db2->order_by('eve_nom_fr ASC'); $query = $db2->get(); $mem_result = $query->result_array(); $mem_sortie = array(); // Option vide en première position $mem_sortie[0] = ''; foreach ($mem_result as $row) { $annee = !empty($row['annee']) ? (string)$row['annee'] : ''; $nom = trim($row['eve_nom_fr']); if ($nom === '') { $libelle = 'Événement sans nom' . ($annee !== '' ? ' (' . $annee . ')' : ''); } else { $libelle = '(' . $annee . ') '.$nom; } $mem_sortie[$row['eve_id']] = $libelle; } return $mem_sortie; } public function conf_getGenresTache_id($id,$langue='fr') { // list la bb client $this->db->select('gen_nom_'.$langue.' as nom'); $this->db->from('tach_genres'); $this->db->where('gen_id',$id); $query = $this->db->get(); $mem_result = $query->row()->nom; return $mem_result; } public function conf_getGenresTache($langue='fr',$choix_vide=false,$cat='a',$gen_fonction='t') { // list la bb client $this->db->select('gen_id,gen_nom_'.$langue.' as nom'); $this->db->from('tach_genres'); $this->db->where('gen_actif',1); if($cat!="") $this->db->where('gen_cat',$cat); $this->db->where('gen_fonction',$gen_fonction); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['gen_id']]=$pro['nom']; } return $mem_sortie; } public function conf_getGenresSection($langue='fr',$choix_vide=false) { // list la bb client $this->db->select('gen_id,gen_nom_'.$langue.' as nom'); $this->db->from('tach_section'); $this->db->where('gen_actif',1); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); if ($choix_vide) $mem_sortie[0]=''; foreach ($mem_result as $pro ){ $mem_sortie[$pro['nom']]=$pro['nom']; } return $mem_sortie; } public function conf_csscouleurprojets(){ // list la bb client $this->db->select('*'); $this->db->from('proj_genres'); $this->db->where('gen_actif',1); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=''; return $mem_sortie; } public function conf_csscouleurtaches(){ // list la bb client $this->db->select('*'); $this->db->from('tach_genres'); $this->db->where('gen_actif',1); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=''; return $mem_sortie; } public function conf_javacouleurprojets(){ // list la bb client $this->db->select('*'); $this->db->from('proj_genres'); $this->db->where('gen_actif',1); $this->db->order_by('gen_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=''; foreach ($mem_result as $pro ){ $mem_sortie=$mem_sortie.'mcolor['.$pro['gen_id'].']="'.$pro['gen_color'].'";tcolor['.$pro['gen_id'].']="'.$pro['gen_text_color'].'";'; } return $mem_sortie; } public function conf_getRepresentantsClient() { // list la bb client $this->db->select('usa_id,usa_prenom,usa_nom'); $this->db->from('usa_usagers'); $this->db->where('usa_actif',1); $this->db->where('usa_representant',1); $this->db->order_by('usa_representant_trie'); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); $mem_sortie[0]=' '; foreach ($mem_result as $pro ){ $mem_sortie[$pro['usa_id']]=$pro['usa_prenom'].' '.$pro['usa_nom']; } return $mem_sortie; } public function conf_getLastnumprojets() { // list la bb client $this->db->select('proj_numero'); $this->db->from('proj_entete'); $this->db->order_by('proj_numero desc'); $query = $this->db->get(); $sortie=$query->row(); return $sortie->proj_numero ; } public function conf_getprojetsclients($client_id,$mem_projetsactive,$filtre3="") { // list la bb client $this->db->select('*,if(proj_date_debut="0000-00-00","9999-99-99",proj_date_debut) as trie, cli_contacts.con_prenom as con_prenom, cli_contacts.con_nom as con_nom,usa_usagers.usa_prenom as rep_prenom,usa_usagers.usa_nom as rep_nom,cli_compte.com_compagnie as compagnie,proj_genres.gen_nom_fr as etape'); $this->db->from('proj_entete'); $this->db->join('cli_compte', 'cli_compte.com_id=proj_entete.proj_client_id ','left'); $this->db->join('cli_contacts', 'proj_entete.proj_contact_principale=cli_contacts.con_id ','left'); $this->db->join('proj_genres', 'proj_genres.gen_id=proj_entete.proj_etape','left'); $this->db->join('usa_usagers', 'usa_usagers.usa_id=proj_entete.proj_representant_id','left'); if ($mem_projetsactive==1){ $this->db->where('proj_genres.gen_id != 4'); $this->db->where('proj_genres.gen_id != 6'); $this->db->where('proj_genres.gen_id != 7'); } if ($filtre3 != '') { $needle = '%' . mb_strtolower($filtre3, 'UTF-8') . '%'; $this->db->where("LOWER(CONCAT(con_nom, ' ', con_prenom)) LIKE", $needle); } $this->db->where('proj_client_id',$client_id); $this->db->order_by('trie'); $query = $this->db->get(); $mem_result=$query->result_array(); return $mem_result ; } public function conf_tax_desc($langue='fr') { $this->db->select('*'); $this->db->from('proj_taux'); $this->db->where('tau_actif',1); $query = $this->db->get(); $mem_result=$query->result_array(); $mem_sortie=array(); foreach ($mem_result as $pro ){ $mem_sortie[$pro['tau_nom_fr']]['taux']=$pro['tau_taux']; $mem_sortie[$pro['tau_nom_fr']]['nom']=$pro['tau_nom_'.$langue]; $mem_sortie[$pro['tau_nom_fr']]['note']=$pro['tau_note']; } return $mem_sortie; } public function conf_numero_facture() { $this->db->select('*'); $this->db->from('config_variable'); $this->db->where('config_varname','code_facture'); $query = $this->db->get(); $sortie=$query->row(); $mem_fact= $sortie->config_valeur; $this->db->select('*'); $this->db->from('config_variable'); $this->db->where('config_varname','numero_facture'); $query = $this->db->get(); $sortie=$query->row(); $mem_fact=$mem_fact.$sortie->config_valeur; $mem_data['config_valeur']= $sortie->config_valeur+1 ; $mem_where = "config_varname ="."'numero_facture'"; $str = $this->db->update('config_variable', $mem_data, $mem_where); return $mem_fact; } public function conf_var_html($clef,$langue='fr') { $this->db->select('*'); $this->db->from('config_variable'); $this->db->where('config_varname',$clef.'_'.$langue); $query = $this->db->get(); $sortie=$query->row(); //$mem_html= $sortie->config_html_fr; $mem_html= $sortie->{'config_html_'.$langue}; return $mem_html; } public function conf_email($data,$langue='fr') { $this->load->library('email'); $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'smtpout.secureserver.net', 'smtp_port' => 25, 'smtp_user' => 'send@progiweb.us', 'smtp_pass' => 'ProgiwebAirstream' ); //$config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'UTF-8'; $config['wordwrap'] = TRUE; $this->email->initialize($config); // $this->email->set_mailtype("html"); //$this->email->from('info@progiweb.ca','test' ); $this->email->from('your@example.com','test','email'); $this->email->to($data['mem_fou_email']); // $this->email->bcc('stephan@progiweb.ca'); $this->email->subject($data['mem_sujet']); // $this->email->message("Bonjour,\nVoici de nouvelles réservations.\nMerci de me confirmer que vous avez bien reçu le fichier.\n\n\nHello,\nHere are some new reservations.\nThank you to confirm that you received the file.\n"); $this->email->message($data['mem_email']); $this->email->send(); if ( ! $this->email->send()) { echo $this->email->print_debugger(); echo('error'); } echo('fin'); } function fxSendMail($data) { $blnGoDaddy = $data['blnGoDaddy']; $error = 0; $strError = ''; $arrSmtp = $GLOBALS['strDebug'] = array(); require_once 'mailer/PHPMailer.php'; require_once 'mailer/SMTP.php'; require_once 'mailer/Exception.php'; $mail = new PHPMailer\PHPMailer\PHPMailer(); $mail->isSMTP(); $mail->Host = 'localhost'; $mail->Port = 25; $mail->SMTPAuth = false; // PAS d'authentification $mail->CharSet = 'UTF-8'; $mail->SMTPDebug = 0; // ou 2 pour déboguer // Options SSL pour éviter les erreurs de certificat $mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); $arrSmtp['host'] = $mail->Host; $arrSmtp['port'] = $mail->Port; $mail->SetFrom($data['from_mail'],''); // $from_mail="ms1inscription@progiweb.ca"; // $mail->SetFrom($from_mail, fxRemoveHtml($GLOBALS['vClient'])); $mail->Subject = $data['subject']; $mail->CharSet = "UTF-8"; $mail->AddReplyTo($data['from_mail'], $data['from_name']); if ($data['attach'] != '') { $mail->AddAttachment($data['attach']); //$mail->AddStringAttachment($data['attach'],'reservation.pdf',"utf-8",'application/pdf'); } $mail->isHTML(true); $mail->Body = $data['body']; if ($data['to_mail']==''){ }else{ $mail->AddAddress($data['to_mail'], $data['to_name']); // if ( $data['to_mail_bcc']!='') // $mail->addCC($data['to_mail_bcc']); } // $mail->addCC($data['to_mail_bcc2']); $mail->SMTPDebug = 0; $mail->Debugoutput = function($str, $level) { $GLOBALS['strDebug'][] = "debug level $level; message: $str\n"; }; if (!$mail->send()) { echo('erreur'); $error = 1; $strError = print_r($mail->ErrorInfo, true); } // print_r($GLOBALS['strDebug']); $this->fxLogMail($data['to_mail'], $data['to_name'], $error, $strError, print_r($GLOBALS['strDebug'], true), print_r($arrSmtp, true), $data['subject'], $data['body'],$data['attach']); // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); if ($error == 0) return true; else { //fxcreer_log("Erreur lors de l'envoi du mail. (TO: $to_mail, FROM $from_mail:, SUJET: $subject)"); return false; } } function fxLogMail($to_mail, $to_name, $error, $strError, $strDebug, $strSmtp, $subject, $body,$attch) { $mem_data['log_error'] = intval($error) ; $mem_data['log_error_msg']=$strError; $mem_data[' log_smtp_connect']=$strSmtp; $mem_data['log_smtp_debug']=$strDebug; $mem_data['log_subject']=$subject; $mem_data['log_message']=$body; $mem_data['log_mailto']=$to_mail; $mem_data['log_nameto']=$to_name; $mem_data['log_attch']=$attch; $str = $this->db->insert('email_logs', $mem_data); return ; } function fx_info_google_calendar($id){ $this->db->select(" td.*, CONCAT(aqui.usa_prenom,' ',aqui.usa_nom) AS usa_aqui, CONCAT(cr.usa_prenom,' ',cr.usa_nom) AS usa_create, CONCAT(fin.usa_prenom,' ',fin.usa_nom) AS usa_fin, aqui.usa_courriel as email, client.com_compagnie AS com_client, projet.com_compagnie AS com_projet, fournisseur.com_compagnie AS fournisseur, COALESCE(client.com_compagnie, projet.com_compagnie) AS com_client_affiche ", false); $this->db->from('tach_details td'); $this->db->join('usa_usagers aqui', 'td.tach_aqui_id = aqui.usa_id', 'left'); $this->db->join('usa_usagers cr', 'td.tach_create_user_id = cr.usa_id', 'left'); $this->db->join('usa_usagers fin', 'td.tach_fin_user_id = fin.usa_id', 'left'); // ajuste si besoin $this->db->join('tach_genres', 'td.tach_type = gen_id', 'left'); $sec = "LOWER(REPLACE(REPLACE(td.tach_section,'-',''),' ',''))"; $this->db->join( 'proj_entete', "td.tach_section_id = proj_id AND $sec IN ('projets','projet','projetsclient','projetsfournisseur','projetclient','projetfournisseur')", 'left' ); $this->db->join( 'cli_compte client', "td.tach_section_id = client.com_id AND $sec IN ('clients','client')", 'left' ); $this->db->join( 'cli_compte projet', "projet.com_id = proj_entete.proj_client_id AND $sec IN ('projets','projet','projetsclient','projetsfournisseur','projetclient','projetfournisseur')", 'left' ); $this->db->join( 'fou_compte fournisseur', "td.tach_section_id = fournisseur.com_id AND $sec IN ('fournisseurs','fournisseur')", 'left' ); $this->db->where('td.tach_id', $id); $row = $this->db->get()->row_array(); return $row; } // fonction pour formatter une valeur sous la forme $ 9,999.99 public function excel($data,$mem_parameter=array()){ $mem_premiere_ligne=1; if (isset($mem_parameter['premiere_ligne'])) $mem_premiere_ligne=$mem_parameter['premiere_ligne']; // print("
".print_r($data,true).""); // exit; $memexcfichier = $data['fichier']; include 'php/Classes/PHPExcel.php'; /** PHPExcel_Writer_Excel2007 */ //include 'php/Classes/PHPExcel/Writer/Excel2007.php'; require_once 'php/Classes/PHPExcel.php'; // header('Cache-Control: max-age=0'); // Instantiate a new PHPExcel object $objPHPExcel = new PHPExcel(); // Set the active Excel worksheet to sheet 0 $objPHPExcel->getProperties()->setCreator("Progiweb"); // $objPHPExcel->getProperties()->setLastModifiedBy("Stephan Leith"); $objPHPExcel->getProperties()->setTitle("Rapport"); // $objPHPExcel->getProperties()->setSubject("Rapport de temps"); // $objPHPExcel->getProperties()->setDescription("Rapport"); // $objPHPExcel->getProperties()->setKeywords("Temps"); // $objPHPExcel->getProperties()->setCategory("Rapport"); $objPHPExcel->setActiveSheetIndex(0); // Initialise the Excel row number $objPHPExcel->getActiveSheet()->setCellValue('A1', $data['titre']); $column = 'A'; foreach($data['headerwidth'] as $header){ $objPHPExcel->getActiveSheet()->getColumnDimension($column)->setWidth($header); $column++; } $column = 'A'; foreach($data['header'] as $header){ $objPHPExcel->getActiveSheet()->getStyle($column.'3')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->setCellValue($column.'3', $header); $column++; } $column = 'A'; $mem_ligne=4; $mem_x=0; foreach($data['data'] as $row){ if($mem_x>=$mem_premiere_ligne){ foreach($row as $col){ if (isset($col['format'])){ switch ($col['format']) { case 'argent': $objPHPExcel->getActiveSheet()->getStyle($column.$mem_ligne)->getNumberFormat()->setFormatCode('# ##0.00'); break; } } if (isset($col['bold']) && $col['bold'] == true) { $objPHPExcel->getActiveSheet() ->getStyle($column.$mem_ligne) ->getFont() ->setBold(true); } if (isset($col['color'])){ $objPHPExcel->getActiveSheet()->getStyle($column.$mem_ligne)->applyFromArray( array( 'fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => $col['color']) ) ) ); } $col['data'] = preg_replace('/