PageRenderTime 54ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/2.071.0/_interfaces.class.php

https://github.com/crepeausucre/soothERP
PHP | 1052 lines | 831 code | 162 blank | 59 comment | 89 complexity | e58224230dc533abb0ab33b0b44f4878 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0
  1. <?php
  2. // *************************************************************************************************************
  3. // CLASSE REGISSANT LES INFORMATIONS D'une interface
  4. // *************************************************************************************************************
  5. class interfaces {
  6. private $id_interface;
  7. private $lib_interface;
  8. private $dossier;
  9. private $url;
  10. private $id_profil;
  11. private $defaut_id_theme;
  12. function __construct ($id_interface = 0, $infos_interface) {
  13. global $bdd;
  14. // Controle si objet crיי depuis une requete
  15. if (isset($infos_interface)) {
  16. $this->charger_from_object($infos_interface);
  17. return true;
  18. }
  19. if (!$id_interface || $is_numeric($id_interface)) {
  20. return false;
  21. }
  22. $query = "SELECT id_interface, lib_interface, dossier, url, id_profil, defaut_id_theme
  23. FROM interfaces
  24. WHERE id_interface = '".$id_interface."' ";
  25. $resultat = $bdd->query ($query);
  26. if (!$interfaces = $resultat->fetchObject()) {
  27. return false;
  28. }
  29. $this->id_interface = $interfaces->id_interface;
  30. $this->lib_interface = $interfaces->lib_interface;
  31. $this->dossier = $interfaces->dossier;
  32. $this->url = $interfaces->url;
  33. $this->id_profil = $interfaces->id_profil;
  34. $this->defaut_id_theme = $interfaces->defaut_id_theme;
  35. return true;
  36. }
  37. function charger_from_object($interface) {
  38. // Attribution des informations
  39. $this->id_interface = $interface->id_interface;
  40. $this->lib_interface = $interface->lib_interface;
  41. $this->dossier = $interface->dossier;
  42. $this->url = $interface->url;
  43. $this->id_profil = $interface->id_profil;
  44. $this->defaut_id_theme = $interface->defaut_id_theme;
  45. return true;
  46. }
  47. // Ajoute une nouvelle interface
  48. public function create_interface ($id_interface, $lib_interface, $dossier, $url, $id_profil, $defaut_id_theme) {
  49. global $bdd;
  50. if ($lib_interface == "") {
  51. $GLOBALS['_ALERTES']['lib_interface'] = 1;
  52. }
  53. // *************************************************
  54. // Verification qu'il n'y a pas eu d'erreur
  55. if (count($GLOBALS['_ALERTES'])) {
  56. return false;
  57. }
  58. $query = "INSERT INTO interfaces (id_interface, lib_interface, dossier, url, id_profil, defaut_id_theme)
  59. VALUES (".$id_interface.", '".addslashes($lib_interface)."', '".addslashes($dossier)."', '".addslashes($url)."',
  60. '".num_or_null($id_profil)."', '".$num_or_null($defaut_id_theme)."' ";
  61. $bdd->exec ($query);
  62. $this->id_interface = $bdd->lastInsertId();
  63. $this->lib_interface = $lib_interface;
  64. $this->dossier = $dossier;
  65. $this->url = $url;
  66. $this->id_profil = $id_profil;
  67. $this->defaut_id_theme = $defaut_id_theme;
  68. return true;
  69. }
  70. // *************************************************************************************************************
  71. // Fonctions de modification
  72. // *************************************************************************************************************
  73. public function maj_interface ($lib_interface, $url) {
  74. global $bdd;
  75. $query = "UPDATE interfaces
  76. SET lib_interface = '".addslashes($lib_interface)."', url = '".addslashes($url)."'
  77. WHERE id_interface = '".$this->id_interface."' ";
  78. $bdd->exec ($query);
  79. $this->lib_interface = $lib_interface;
  80. $this->url = $url;
  81. return true;
  82. }
  83. // *************************************************************************************************************
  84. // Fonctions de rיception de donnיes supplיmentaires
  85. // *************************************************************************************************************
  86. //envoi du mail permettant א l'utilisateur de changer son mot de passe
  87. function mdp_oublie($identifiant){
  88. global $bdd;
  89. global $REF_CONTACT_ENTREPRISE;
  90. global $SUJET_MDP_OUBLIE;
  91. global $CONTENU_MDP_OUBLIE;
  92. $contact_entreprise = new contact($REF_CONTACT_ENTREPRISE);
  93. $nom_entreprise = str_replace (CHR(13), " " ,str_replace (CHR(10), " " , $contact_entreprise->getNom()));
  94. $query = "SELECT u.ref_contact
  95. FROM users u
  96. JOIN coordonnees c ON c.ref_contact = u.ref_contact
  97. WHERE u.pseudo = '".$identifiant."'
  98. OR c.email = '".$identifiant."';";
  99. $resultat = $bdd->query ($query);
  100. if (!$annuaire_tmp = $resultat->fetchObject()) {
  101. return false;
  102. }
  103. $email = $annuaire_tmp->email;
  104. $CONTENU_MDP_OUBLIE_2 = "
  105. <a href='".$_SERVER['HTTP_HOST'].$this->dossier."mdp_valide.php?modif=1&ref=".$identifiant."'>".$_SERVER['HTTP_HOST'].$this->dossier."mdp_valide.php?modif=1&ref=".$identifiant."</a>
  106. <br /><br />
  107. ".$nom_entreprise."
  108. <br /><br />
  109. -------------------------------------------------------------------------------------------------------------------------<br />
  110. ";
  111. $message = $CONTENU_MDP_OUBLIE.$CONTENU_MDP_OUBLIE_2;
  112. $this->envoi_email_templated ($email,$SUJET_MDP_OUBLIE,$message);
  113. return true;
  114. }
  115. // enregistrement d'un nouvel inscrit en attente de confirmation
  116. public function inscription_contact($liste_reponse, $email) {
  117. global $bdd;
  118. global $INSCRIPTION_ALLOWED;
  119. global $REF_CONTACT_ENTREPRISE;
  120. global $CONTENU_INSCRIPTION_VALIDATION;
  121. global $SUJET_INSCRIPTION_VALIDATION;
  122. $contact_entreprise = new contact($REF_CONTACT_ENTREPRISE);
  123. $nom_entreprise = str_replace (CHR(13), " " ,str_replace (CHR(10), " " , $contact_entreprise->getNom()));
  124. $code_validation = creer_code_unique ($email, $this->id_interface) ;
  125. $query = "INSERT INTO annuaire_tmp (id_interface, infos, date_demande, code_validation, validation_email )
  126. VALUES (".$this->id_interface.", '".addslashes(implode(";", $liste_reponse))."', NOW(), '".$code_validation."', 0)
  127. ";
  128. $bdd->exec ($query);
  129. $id_contact_tmp = $bdd->lastInsertId();
  130. $CONTENU_INSCRIPTION_VALIDATION_2 = "http:".$_SERVER['HTTP_HOST'].str_replace($this->dossier."_inscription_envoi.php", "", $_SERVER['PHP_SELF']).$this->dossier."_inscription_valide.php?id_contact_tmp=".$id_contact_tmp."&code_validation=".$code_validation."
  131.  
  132. ".$nom_entreprise."
  133.  
  134. -------------------------------------------------------------------------------------------------------------------------
  135. ";
  136. $message = $CONTENU_INSCRIPTION_VALIDATION.$CONTENU_INSCRIPTION_VALIDATION_2;
  137. $this->envoi_email_templated ($email , $SUJET_INSCRIPTION_VALIDATION , $message );
  138. return $message;
  139. }
  140. // enregistrement d'un nouvel inscrit en attente de confirmation
  141. public function inscription_avec_valid($liste_reponse, $email) {
  142. global $bdd;
  143. global $INSCRIPTION_ALLOWED;
  144. global $REF_CONTACT_ENTREPRISE;
  145. global $CONTENU_INSCRIPTION_VALIDATION;
  146. global $SUJET_INSCRIPTION_VALIDATION;
  147. $contact_entreprise = new contact($REF_CONTACT_ENTREPRISE);
  148. $nom_entreprise = str_replace (CHR(13), " " ,str_replace (CHR(10), " " , $contact_entreprise->getNom()));
  149. $coordonnees_entreprise = $contact_entreprise->getCoordonnees();
  150. $i = 0;
  151. while (!$coordonnees_entreprise[$i]->getEmail()) {
  152. $i++;
  153. }
  154. $mail_entreprise = $coordonnees_entreprise[$i]->getEmail();
  155. $query = "INSERT INTO annuaire_tmp (id_interface, infos, date_demande, code_validation, validation_email )
  156. VALUES (".$this->id_interface.", '".addslashes(implode(";", $liste_reponse))."', NOW(), '', 1)
  157. ";
  158. $bdd->exec ($query);
  159. $SUJET_INSCRIPTION_AVEC_VALID = "Inscription sur ".$_SERVER['HTTP_HOST'];
  160. $CONTENU_INSCRIPTION_AVEC_VALID = "Bonjour et bienvenue,<br />
  161. Vous venez de vous inscrire sur notre site et nous vous en remercions.
  162. <br />
  163. <br />
  164. Un de nos collaborateurs va prochainement valider votre fiche. Vous recevrez alors un email de confirmation.<br />
  165. <br />
  166. <br />
  167. ".$nom_entreprise."
  168. <br />
  169. <br />
  170. -------------------------------------------------------------------------------------------------------------------------<br />
  171. ";
  172. $message = $CONTENU_INSCRIPTION_AVEC_VALID;
  173. $this->envoi_email_templated ($email , $SUJET_INSCRIPTION_AVEC_VALID , $message );
  174. $SUJET_INSCRIPTION_AVEC_VALID_2 = "Inscription sur ".$_SERVER['HTTP_HOST'];
  175. $CONTENU_INSCRIPTION_AVEC_VALID_2 = "Bonjour,<br />
  176. Un nouvel inscrit s'est enregistrי sur ".$_SERVER['HTTP_HOST']."
  177. Vous devez valider son inscription א partir de votre interface collaborateur.
  178. <br />
  179. <br />
  180. <br />
  181. ".$nom_entreprise."
  182. <br />
  183. <br />
  184. -------------------------------------------------------------------------------------------------------------------------<br />
  185. ";
  186. $message_2 = $CONTENU_INSCRIPTION_AVEC_VALID_2;
  187. $this->envoi_email_templated ($mail_entreprise, $SUJET_INSCRIPTION_AVEC_VALID_2, $message_2);
  188. return true;
  189. }
  190. /*
  191. * Fonction permettant de valider l'inscription (commune aux diffיrents modes de validation)
  192. */
  193. function valider_inscription($liste_reponse){
  194. global $bdd;
  195. global $INSCRIPTION_ALLOWED;
  196. global $REF_CONTACT_ENTREPRISE;
  197. global $SUJET_INSCRIPTION_VALIDATION;
  198. global $CONTENU_INSCRIPTION_VALIDATION;
  199. global $SUJET_INSCRIPTION_VALIDATION_FINAL;
  200. global $CONTENU_INSCRIPTION_VALIDATION_FINAL;
  201. global $MAIL_ENVOI_INSCRIPTIONS;
  202. $infos_generales['id_civilite'] = "";
  203. if (isset($liste_reponse['civilite'])) {
  204. $infos_generales['id_civilite'] = $liste_reponse['civilite'];
  205. }
  206. $infos_generales['nom'] = "";
  207. if (isset($liste_reponse['nom'])) {
  208. $infos_generales['nom'] = $liste_reponse['nom'];
  209. }
  210. $infos_generales['siret'] = "";
  211. if (isset($liste_reponse['siret'])) {
  212. $infos_generales['siret'] = $liste_reponse['siret'];
  213. }
  214. $infos_generales['tva_intra'] = "";
  215. if (isset($liste_reponse['tva_intra'])) {
  216. $infos_generales['tva_intra'] = $liste_reponse['tva_intra'];
  217. }
  218. $infos_generales['id_categorie'] = "";
  219. if (isset($liste_reponse['id_categorie'])) {
  220. $infos_generales['id_categorie'] = $liste_reponse['id_categorie'];
  221. }
  222. $infos_generales['note'] = "";
  223. if (isset($liste_reponse['note'])) {
  224. $infos_generales['note'] = $liste_reponse['note'];
  225. }
  226. $infos_generales['adresses'] = array();
  227. $infos_generales['coordonnees'] = array();
  228. $infos_generales['sites'] = array();
  229. if (isset($liste_reponse['livraison_adresse'])) {
  230. $infos_generales['adresses'][] = array('lib_adresse' => "", 'text_adresse' => $liste_reponse['livraison_adresse'], 'code_postal' => $liste_reponse['livraison_code'], 'ville' => $liste_reponse['livraison_ville'], 'id_pays' => $liste_reponse['id_pays_livraison'], 'note' => "");
  231. }
  232. if (isset($liste_reponse['adresse_adresse'])) {
  233. $infos_generales['adresses'][] = array('lib_adresse' => "", 'text_adresse' => $liste_reponse['adresse_adresse'], 'code_postal' => $liste_reponse['adresse_code'], 'ville' => $liste_reponse['adresse_ville'], 'id_pays' => $liste_reponse['id_pays_contact'], 'note' => "");
  234. }
  235. if (isset($liste_reponse['coordonnee_tel1'])) {
  236. $infos_generales['coordonnees'][] = array('lib_coord' => "", 'tel1' => $liste_reponse['coordonnee_tel1'], 'tel2' => $liste_reponse['coordonnee_tel2'], 'fax' => $liste_reponse['coordonnee_fax'], 'email' => $liste_reponse['admin_emaila'], 'note' => "", 'ref_coord_parent' => NULL, 'email_user_creation' => 0 );
  237. }
  238. $infos_profils = array();
  239. if (isset($liste_reponse['profils_inscription'])) {
  240. if (is_array($liste_reponse['profils_inscription'])) {
  241. foreach ($liste_reponse['profils_inscription'] as $id_profil) {
  242. if (!isset($_SESSION['profils'][$id_profil])) { continue; }
  243. $infos_profils[$id_profil]['id_profil'] = $id_profil;
  244. include_once ("./profil_create_".$_SESSION['profils'][$id_profil]->getCode_profil().".inc.php");
  245. }
  246. } else {
  247. if (isset($_SESSION['profils'][$liste_reponse['profils_inscription']])) {
  248. $infos_profils[$liste_reponse['profils_inscription']]['id_profil'] = $liste_reponse['profils_inscription'];
  249. $id_profil = $liste_reponse['profils_inscription'];
  250. include_once ("./profil_create_".$_SESSION['profils'][$id_profil]->getCode_profil().".inc.php");
  251. }
  252. }
  253. }
  254. // *************************************************
  255. // Crיation du contact
  256. $contact = new contact ();
  257. $contact->create ($infos_generales, $infos_profils);
  258. $coord = $contact->getCoordonnees ();
  259. // Gיnיrer un utilisateur pour ce contact
  260. if (isset($coord[0])) {
  261. $utilisateur = new utilisateur ();
  262. $utilisateur->create ($contact->getRef_contact(), $coord[0]->getRef_coord (), $liste_reponse['admin_pseudo'], 1, $liste_reponse['admin_passworda'], 1);
  263. // Connecter l'utilisateur
  264. $_SESSION['user']->login ($liste_reponse['admin_pseudo'], $liste_reponse['admin_passworda'], "", $liste_reponse['profils_inscription']);
  265. }
  266. return true;
  267. }
  268. /*
  269. * Validation de l'inscription depuis le panier
  270. */
  271. function inscription_valide_panier ($liste_reponse, $email) {
  272. global $bdd;
  273. global $INSCRIPTION_ALLOWED;
  274. global $REF_CONTACT_ENTREPRISE;
  275. global $SUJET_INSCRIPTION_VALIDATION;
  276. global $CONTENU_INSCRIPTION_VALIDATION;
  277. global $SUJET_INSCRIPTION_VALIDATION_FINAL;
  278. global $CONTENU_INSCRIPTION_VALIDATION_FINAL;
  279. global $MAIL_ENVOI_INSCRIPTIONS;
  280. $contact_entreprise = new contact($REF_CONTACT_ENTREPRISE);
  281. $nom_entreprise = str_replace (CHR(13), " " ,str_replace (CHR(10), " " , $contact_entreprise->getNom()));
  282. if ($INSCRIPTION_ALLOWED == 2 ) {
  283. $this->valider_inscription($liste_reponse);
  284. //confirmation de l'inscription par email et rappel des identifiants
  285. $CONTENU_INSCRIPTION_VALIDATION_FINAL_2 = "<br />
  286. Votre identifiant: ".$liste_reponse['admin_pseudo']." ou ".$liste_reponse['admin_emaila']."<br />
  287. Votre mot de passe: ".$liste_reponse['admin_passworda']."
  288.  <br /><br />
  289. ".$nom_entreprise."
  290.  <br />
  291. -------------------------------------------------------------------------------------------------------------------------<br />
  292. ";
  293. $message = $CONTENU_INSCRIPTION_VALIDATION_FINAL.$CONTENU_INSCRIPTION_VALIDATION_FINAL_2;
  294. $this->envoi_email_templated ($email, $SUJET_INSCRIPTION_VALIDATION_FINAL , $message );
  295. return true;
  296. }
  297. return false;
  298. }
  299. function inscription_valide ($id_contact_tmp, $code ) {
  300. global $bdd;
  301. global $INSCRIPTION_ALLOWED;
  302. global $REF_CONTACT_ENTREPRISE;
  303. global $SUJET_INSCRIPTION_VALIDATION;
  304. global $CONTENU_INSCRIPTION_VALIDATION;
  305. global $SUJET_INSCRIPTION_VALIDATION_FINAL;
  306. global $CONTENU_INSCRIPTION_VALIDATION_FINAL;
  307. global $MAIL_ENVOI_INSCRIPTIONS;
  308. $query = "SELECT id_contact_tmp, infos, date_demande, code_validation, validation_email
  309. FROM annuaire_tmp
  310. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  311. $resultat = $bdd->query ($query);
  312. if (!$annuaire_tmp = $resultat->fetchObject()) {
  313. return false;
  314. }
  315. $annuaire_resultat = array();
  316. $tmp_resultat_ann = explode (";",$annuaire_tmp->infos);
  317. foreach ($tmp_resultat_ann as $tmp_ann) {
  318. $tmp = explode("=", $tmp_ann);
  319. if (count($tmp)==2) {
  320. $annuaire_resultat[$tmp[0]] = $tmp[1];
  321. if ($tmp[0] == "admin_emaila") {$email = $tmp[1];}
  322. }
  323. }
  324. //si le code est bon on valide l'inscription
  325. if (verifier_code_unique ($code, $email, $this->id_interface)) {
  326. // si inscription auto on crי le contact on crי l'user, on log l'utilisateur, on vire le tmp
  327. if ($INSCRIPTION_ALLOWED == 2 ) {
  328. $this->valider_inscription($annuaire_resultat);
  329. //supprimer l'inscription
  330. $this->supprimer_inscription ($id_contact_tmp);
  331. //confirmation de l'inscription par email et rappel des identifiants
  332. $CONTENU_INSCRIPTION_VALIDATION_FINAL_2 = "<br />
  333. Votre identifiant: ".$annuaire_resultat['admin_pseudo']." ou ".$annuaire_resultat['admin_emaila']."<br />
  334. Votre mot de passe: ".$annuaire_resultat['admin_passworda']."<br /><br />
  335. http:".$_SERVER['HTTP_HOST'].str_replace($this->dossier."_inscription_valide.php", "", $_SERVER['PHP_SELF'])."
  336.  <br /><br />
  337. ".$nom_entreprise."
  338.  <br />
  339. -------------------------------------------------------------------------------------------------------------------------<br />
  340. ";
  341. $message = $CONTENU_INSCRIPTION_VALIDATION_FINAL.$CONTENU_INSCRIPTION_VALIDATION_FINAL_2;
  342. $this->envoi_email_templated ($coord[0]->getEmail() , $SUJET_INSCRIPTION_VALIDATION_FINAL , $message );
  343. return true;
  344. }
  345. //si inscription auto, on met le tmp en valide, on envoie un mail aux collab dיsignיs pour la validation
  346. if ($INSCRIPTION_ALLOWED == 1 ) {
  347. if ($MAIL_ENVOI_INSCRIPTIONS){
  348. $this->envoi_email_templated ($MAIL_ENVOI_INSCRIPTIONS , "Nouvelle inscription sur le site" , "Rendez-vous dans l'interface Collaborateur > Annuaire > Valider les inscriptions. pour confirmer les nouvelles inscriptions" );
  349. }
  350. $query = "UPDATE annuaire_tmp SET validation_email = 1
  351. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  352. $bdd->exec ($query);
  353. return true;
  354. }
  355. }
  356. return false;
  357. }
  358. function inscription_contact_valide ($id_contact_tmp) {
  359. global $bdd;
  360. global $INSCRIPTION_ALLOWED;
  361. global $REF_CONTACT_ENTREPRISE;
  362. global $SUJET_INSCRIPTION_VALIDATION;
  363. global $CONTENU_INSCRIPTION_VALIDATION;
  364. global $SUJET_INSCRIPTION_VALIDATION_FINAL;
  365. global $CONTENU_INSCRIPTION_VALIDATION_FINAL;
  366. global $MAIL_ENVOI_INSCRIPTIONS;
  367. $contact_entreprise = new contact($REF_CONTACT_ENTREPRISE);
  368. $nom_entreprise = str_replace (CHR(13), " " ,str_replace (CHR(10), " " , $contact_entreprise->getNom()));
  369. $query = "SELECT id_contact_tmp, infos, date_demande, code_validation, validation_email
  370. FROM annuaire_tmp
  371. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  372. $resultat = $bdd->query ($query);
  373. if (!$annuaire_tmp = $resultat->fetchObject()) {
  374. return false;
  375. }
  376. $annuaire_resultat = array();
  377. $tmp_resultat_ann = explode (";",$annuaire_tmp->infos);
  378. foreach ($tmp_resultat_ann as $tmp_ann) {
  379. $tmp = explode("=", $tmp_ann);
  380. if (count($tmp)==2) {
  381. $annuaire_resultat[$tmp[0]] = $tmp[1];
  382. if ($tmp[0] == "admin_emaila") {$email = $tmp[1];}
  383. if ($tmp[0] == "ref_contact") {$ref_contact = $tmp[1];}
  384. }
  385. }
  386. $infos_generales['id_civilite'] = "";
  387. if (isset($annuaire_resultat['civilite'])) { $infos_generales['id_civilite'] = $annuaire_resultat['civilite']; }
  388. $infos_generales['nom'] = "";
  389. if (isset($annuaire_resultat['nom'])) { $infos_generales['nom'] = $annuaire_resultat['nom']; }
  390. $infos_generales['siret'] = "";
  391. if (isset($annuaire_resultat['siret'])) { $infos_generales['siret'] = $annuaire_resultat['siret']; }
  392. $infos_generales['tva_intra'] = "";
  393. if (isset($annuaire_resultat['tva_intra'])) { $infos_generales['tva_intra'] = $annuaire_resultat['tva_intra']; }
  394. $infos_generales['id_categorie'] = "";
  395. if (isset($annuaire_resultat['id_categorie'])) { $infos_generales['id_categorie'] = $annuaire_resultat['id_categorie']; }
  396. $infos_generales['note'] = "";
  397. if (isset($annuaire_resultat['note'])) { $infos_generales['note'] = $annuaire_resultat['note']; }
  398. $infos_generales['adresses'] = array();
  399. $infos_generales['coordonnees'] = array();
  400. $infos_generales['sites'] = array();
  401. if (isset($annuaire_resultat['livraison_adresse'])) {
  402. $infos_generales['adresses'][] = array('lib_adresse' => "", 'text_adresse' => $annuaire_resultat['livraison_adresse'], 'code_postal' => $annuaire_resultat['livraison_code'], 'ville' => $annuaire_resultat['livraison_ville'], 'id_pays' => $annuaire_resultat['id_pays_livraison'], 'note' => "");
  403. }
  404. if (isset($annuaire_resultat['adresse_adresse'])) {
  405. $infos_generales['adresses'][] = array('lib_adresse' => "", 'text_adresse' => $annuaire_resultat['adresse_adresse'], 'code_postal' => $annuaire_resultat['adresse_code'], 'ville' => $annuaire_resultat['adresse_ville'], 'id_pays' => $annuaire_resultat['id_pays_contact'], 'note' => "");
  406. }
  407. if (isset($annuaire_resultat['coordonnee_tel1'])) {
  408. $infos_generales['coordonnees'][] = array('lib_coord' => "", 'tel1' => $annuaire_resultat['coordonnee_tel1'], 'tel2' => $annuaire_resultat['coordonnee_tel2'], 'fax' => $annuaire_resultat['coordonnee_fax'], 'email' => $annuaire_resultat['admin_emaila'], 'note' => "", 'ref_coord_parent' => NULL, 'email_user_creation' => 0 );
  409. }
  410. $infos_profils = array();
  411. if (isset($annuaire_resultat['profils_inscription'])) {
  412. if (is_array($annuaire_resultat['profils_inscription'])) {
  413. foreach ($annuaire_resultat['profils_inscription'] as $id_profil) {
  414. if (!isset($_SESSION['profils'][$id_profil])) { continue; }
  415. $infos_profils[$id_profil]['id_profil'] = $id_profil;
  416. include_once ("./profil_create_".$_SESSION['profils'][$id_profil]->getCode_profil().".inc.php");
  417. }
  418. } else {
  419. if (!isset($_SESSION['profils'][$annuaire_resultat['profils_inscription']])) {
  420. $infos_profils[$annuaire_resultat['profils_inscription']]['id_profil'] = $annuaire_resultat['profils_inscription'];
  421. include_once ("./profil_create_".$_SESSION['profils'][$id_profil]->getCode_profil().".inc.php");
  422. }
  423. }
  424. }
  425. // *************************************************
  426. // Crיation du contact
  427. $contact = new contact ();
  428. $contact->create ($infos_generales, $infos_profils);
  429. $coord = $contact->getCoordonnees ();
  430. //gיnיrer un utilisateur pour ce contact
  431. if (isset($coord[0])) {
  432. $utilisateur = new utilisateur ();
  433. $utilisateur->create ($contact->getRef_contact(), $coord[0]->getRef_coord (), $annuaire_resultat['admin_pseudo'], 1, $annuaire_resultat['admin_passworda'], 1);
  434. //connecter l'utilisateur
  435. $_SESSION['user']->login ($annuaire_resultat['admin_pseudo'], $annuaire_resultat['admin_passworda'], "", $annuaire_resultat['profils_inscription']);
  436. }
  437. //supprimer l'inscription
  438. $this->supprimer_inscription ($id_contact_tmp);
  439. //confirmation de l'inscription par email et rappel des identifiants
  440. $CONTENU_INSCRIPTION_VALIDATION_FINAL_2 = "
  441. Votre identifiant: ".$annuaire_resultat['admin_pseudo']." ou ".$annuaire_resultat['admin_emaila']."
  442. Votre mot de passe: ".$annuaire_resultat['admin_passworda']."
  443. http:".$_SERVER['HTTP_HOST'].str_replace($this->dossier."_inscription_valide.php", "", $_SERVER['PHP_SELF'])."
  444.  
  445. ".$nom_entreprise."
  446.  
  447. -------------------------------------------------------------------------------------------------------------------------
  448. ";
  449. $message = $CONTENU_INSCRIPTION_VALIDATION_FINAL.$CONTENU_INSCRIPTION_VALIDATION_FINAL_2;
  450. $this->envoi_email_templated ($coord[0]->getEmail() , $SUJET_INSCRIPTION_VALIDATION_FINAL , $message );
  451. return true;
  452. }
  453. function valider_inscription_contact ($id_contact_tmp) {
  454. global $bdd;
  455. global $INSCRIPTION_ALLOWED;
  456. global $REF_CONTACT_ENTREPRISE;
  457. global $SUJET_INSCRIPTION_VALIDATION;
  458. global $CONTENU_INSCRIPTION_VALIDATION;
  459. global $SUJET_INSCRIPTION_VALIDATION_FINAL;
  460. global $CONTENU_INSCRIPTION_VALIDATION_FINAL;
  461. global $MAIL_ENVOI_INSCRIPTIONS;
  462. $contact_entreprise = new contact($REF_CONTACT_ENTREPRISE);
  463. $nom_entreprise = str_replace (CHR(13), " " ,str_replace (CHR(10), " " , $contact_entreprise->getNom()));
  464. $query = "SELECT id_contact_tmp, infos, date_demande, code_validation, validation_email
  465. FROM annuaire_tmp
  466. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  467. $resultat = $bdd->query ($query);
  468. if (!$annuaire_tmp = $resultat->fetchObject()) {
  469. return false;
  470. }
  471. $annuaire_resultat = array();
  472. $tmp_resultat_ann = explode (";",$annuaire_tmp->infos);
  473. foreach ($tmp_resultat_ann as $tmp_ann) {
  474. $tmp = explode("=", $tmp_ann);
  475. if (count($tmp)==2) {
  476. $annuaire_resultat[$tmp[0]] = $tmp[1];
  477. if ($tmp[0] == "admin_emaila") {$email = $tmp[1];}
  478. if ($tmp[0] == "ref_contact") {$ref_contact = $tmp[1];}
  479. }
  480. }
  481. $infos_generales['id_civilite'] = "";
  482. if (isset($annuaire_resultat['civilite'])) { $infos_generales['id_civilite'] = $annuaire_resultat['civilite']; }
  483. $infos_generales['nom'] = "";
  484. if (isset($annuaire_resultat['nom'])) { $infos_generales['nom'] = $annuaire_resultat['nom']; }
  485. $infos_generales['siret'] = "";
  486. if (isset($annuaire_resultat['siret'])) { $infos_generales['siret'] = $annuaire_resultat['siret']; }
  487. $infos_generales['tva_intra'] = "";
  488. if (isset($annuaire_resultat['tva_intra'])) { $infos_generales['tva_intra'] = $annuaire_resultat['tva_intra']; }
  489. $infos_generales['id_categorie'] = "";
  490. if (isset($annuaire_resultat['id_categorie'])) { $infos_generales['id_categorie'] = $annuaire_resultat['id_categorie']; }
  491. $infos_generales['note'] = "";
  492. if (isset($annuaire_resultat['note'])) { $infos_generales['note'] = $annuaire_resultat['note']; }
  493. $infos_generales['adresses'] = array();
  494. $infos_generales['coordonnees'] = array();
  495. $infos_generales['sites'] = array();
  496. if (isset($annuaire_resultat['livraison_adresse'])) {
  497. $infos_generales['adresses'][] = array('lib_adresse' => "", 'text_adresse' => $annuaire_resultat['livraison_adresse'], 'code_postal' => $annuaire_resultat['livraison_code'], 'ville' => $annuaire_resultat['livraison_ville'], 'id_pays' => $annuaire_resultat['id_pays_livraison'], 'note' => "");
  498. }
  499. if (isset($annuaire_resultat['adresse_adresse'])) {
  500. $infos_generales['adresses'][] = array('lib_adresse' => "", 'text_adresse' => $annuaire_resultat['adresse_adresse'], 'code_postal' => $annuaire_resultat['adresse_code'], 'ville' => $annuaire_resultat['adresse_ville'], 'id_pays' => $annuaire_resultat['id_pays_contact'], 'note' => "");
  501. }
  502. if (isset($annuaire_resultat['coordonnee_tel1'])) {
  503. $infos_generales['coordonnees'][] = array('lib_coord' => "", 'tel1' => $annuaire_resultat['coordonnee_tel1'], 'tel2' => $annuaire_resultat['coordonnee_tel2'], 'fax' => $annuaire_resultat['coordonnee_fax'], 'email' => $annuaire_resultat['admin_emaila'], 'note' => "", 'ref_coord_parent' => NULL, 'email_user_creation' => 0 );
  504. }
  505. $infos_profils = array();
  506. if (isset($annuaire_resultat['profils_inscription'])) {
  507. if (is_array($annuaire_resultat['profils_inscription'])) {
  508. foreach ($annuaire_resultat['profils_inscription'] as $id_profil) {
  509. if (!isset($_SESSION['profils'][$id_profil])) { continue; }
  510. $infos_profils[$id_profil]['id_profil'] = $id_profil;
  511. include_once ("./profil_create_".$_SESSION['profils'][$id_profil]->getCode_profil().".inc.php");
  512. }
  513. } else {
  514. if (isset($_SESSION['profils'][$annuaire_resultat['profils_inscription']])) {
  515. $infos_profils[$annuaire_resultat['profils_inscription']]['id_profil'] = $annuaire_resultat['profils_inscription'];
  516. $id_profil = $annuaire_resultat['profils_inscription'];
  517. $infos_profils[$id_profil]['id_client_categ'] = "1";
  518. $infos_profils[$id_profil]['type_client'] = "client";
  519. $infos_profils[$id_profil]['id_tarif'] = "1";
  520. $infos_profils[$id_profil]['ref_adr_livraison'] = "";
  521. $infos_profils[$id_profil]['ref_adr_facturation'] = "";
  522. $infos_profils[$id_profil]['app_tarifs'] = "HT";
  523. $infos_profils[$id_profil]['facturation_periodique'] = "0";
  524. $infos_profils[$id_profil]['encours'] = "0";
  525. $infos_profils[$id_profil]['delai_reglement'] = "";
  526. $infos_profils[$id_profil]['ref_commercial'] = "";
  527. //include_once ("./profil_create_".$_SESSION['profils'][$id_profil]->getCode_profil().".inc.php");
  528. }
  529. }
  530. }
  531. // *************************************************
  532. // Crיation du contact
  533. $contact = new contact ();
  534. $contact->create ($infos_generales, $infos_profils);
  535. $coord = $contact->getCoordonnees ();
  536. //confirmation de l'inscription par email et rappel des identifiants
  537. $SUJET_VALIDATION_INSCRIPTION = "Inscription sur ".$_SERVER['HTTP_HOST'];
  538. $CONTENU_VALIDATION_INSCRIPTION = "Bonjour,<br />
  539. <br />
  540. Votre compte client sur ".$_SERVER['HTTP_HOST']." vient d&ecirc;tre activ&eacute;.<br />
  541. <br />
  542. Rappel de vos identifiants : <br />
  543. Votre identifiant: ".$annuaire_resultat['admin_pseudo']." ou ".$annuaire_resultat['admin_emaila']."<br />
  544. Votre mot de passe: ".$annuaire_resultat['admin_passworda']."<br />
  545. <br />
  546. Vous pouvez maintenant vous connecter sur <a href='http://".$_SERVER['HTTP_HOST']."'>".$_SERVER['HTTP_HOST']."</a><br />
  547. A tr&egrave;s bient&ocirc;t sur notre site!<br />
  548. <br />
  549. Nous vous conseillons de conserver cet e-mail.<br />
  550. <br />
  551. ".$nom_entreprise."<br />
  552. <br />
  553. -------------------------------------------------------------------------------------------------------------------------<br />
  554. ";
  555. $message = $CONTENU_VALIDATION_INSCRIPTION;
  556. //gיnיrer un utilisateur pour ce contact
  557. if (isset($coord[0])) {
  558. $utilisateur = new utilisateur ();
  559. $utilisateur->create ($contact->getRef_contact(), $coord[0]->getRef_coord (), $annuaire_resultat['admin_pseudo'], 1, $annuaire_resultat['admin_passworda'], 1);
  560. //connecter l'utilisateur
  561. //$_SESSION['user']->login ($annuaire_resultat['admin_pseudo'], $annuaire_resultat['admin_passworda'], "", $annuaire_resultat['profils_inscription']);
  562. $this->envoi_email_templated ($coord[0]->getEmail() , $SUJET_VALIDATION_INSCRIPTION , $message );
  563. }
  564. //supprimer l'inscription
  565. $this->supprimer_inscription ($id_contact_tmp);
  566. return true;
  567. }
  568. // enregistrement des modifications d'un inscrit
  569. public function modification_contact ($liste_reponse, $ref_contact, $email) {
  570. global $bdd;
  571. global $MODIFICATION_ALLOWED;
  572. global $REF_CONTACT_ENTREPRISE;
  573. global $CONTENU_MODIFICATION_VALIDATION;
  574. global $SUJET_MODIFICATION_VALIDATION;
  575. $contact_entreprise = new contact($REF_CONTACT_ENTREPRISE);
  576. $nom_entreprise = str_replace (CHR(13), " " ,str_replace (CHR(10), " " , $contact_entreprise->getNom()));
  577. $contact = new contact ($ref_contact);
  578. $liste_coordonnees = $contact->getCoordonnees();
  579. $code_validation = creer_code_unique ($email, $this->id_interface) ;
  580. $query = "INSERT INTO annuaire_tmp (id_interface, infos, date_demande, code_validation, validation_email, mode )
  581. VALUES (".$this->id_interface.", '".addslashes(implode(";", $liste_reponse))."', NOW(), '".$code_validation."', 0, 'modification')
  582. ";
  583. $bdd->exec ($query);
  584. $id_contact_tmp = $bdd->lastInsertId();
  585. if ($liste_coordonnees[0]->getEmail() != $email) {
  586. $CONTENU_MODIFICATION_VALIDATION_2 = "http:".$_SERVER['HTTP_HOST'].str_replace($this->dossier."_inscription_envoi.php", "", $_SERVER['PHP_SELF']).$this->dossier."_modification_valide.php?id_contact_tmp=".$id_contact_tmp."&code_validation=".$code_validation."
  587.  
  588. ".$nom_entreprise."
  589.  
  590. -------------------------------------------------------------------------------------------------------------------------
  591. ";
  592. $message = $CONTENU_MODIFICATION_VALIDATION.$CONTENU_MODIFICATION_VALIDATION_2;
  593. $this->envoi_email_templated ($email , $SUJET_MODIFICATION_VALIDATION , $message );
  594. $GLOBALS['_INFOS']["mail_change"] = 1;
  595. } else {
  596. if ($MODIFICATION_ALLOWED == 1) {
  597. $GLOBALS['_INFOS']["verification_collab"] = 1;
  598. $this->modification_contact_confirmation ($id_contact_tmp, $code_validation);
  599. }
  600. if ($MODIFICATION_ALLOWED == 2) {
  601. $this->modification_contact_valide ($id_contact_tmp);
  602. }
  603. }
  604. return true;
  605. }
  606. function modification_contact_confirmation ($id_contact_tmp, $code_validation) {
  607. global $bdd;
  608. global $MAIL_ENVOI_INSCRIPTIONS;
  609. $query = "SELECT id_contact_tmp, infos, date_demande, code_validation, validation_email
  610. FROM annuaire_tmp
  611. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  612. $resultat = $bdd->query ($query);
  613. if (!$annuaire_tmp = $resultat->fetchObject()) {
  614. return false;
  615. }
  616. $annuaire_resultat = array();
  617. $tmp_resultat_ann = explode (";",$annuaire_tmp->infos);
  618. foreach ($tmp_resultat_ann as $tmp_ann) {
  619. $tmp = explode("=", $tmp_ann);
  620. if (count($tmp)==2) {
  621. $annuaire_resultat[$tmp[0]] = $tmp[1];
  622. if ($tmp[0] == "admin_emaila") {$email = $tmp[1];}
  623. }
  624. }
  625. if (verifier_code_unique ($code_validation, $email, $this->id_interface)) {
  626. //confirmation de l'inscription
  627. $query = "UPDATE annuaire_tmp SET validation_email = 1
  628. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  629. $bdd->exec ($query);
  630. //mail au collaborateurs
  631. if ($MAIL_ENVOI_INSCRIPTIONS){
  632. $this->envoi_email_templated ($MAIL_ENVOI_INSCRIPTIONS , "Nouvelle inscription sur le site" , "Rendez-vous dans l'interface Collaborateur > Annuaire > Valider les inscriptions. pour confirmer les nouvelles inscriptions" );
  633. }
  634. }
  635. }
  636. function modification_contact_valide ($id_contact_tmp) {
  637. global $bdd;
  638. global $MODIFICATION_ALLOWED;
  639. global $SUJET_MODIFICATION_VALIDATION_FINAL;
  640. global $CONTENU_MODIFICATION_VALIDATION_FINAL;
  641. global $CLIENT_ID_PROFIL;
  642. $query = "SELECT id_contact_tmp, infos, date_demande, code_validation, validation_email
  643. FROM annuaire_tmp
  644. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  645. $resultat = $bdd->query ($query);
  646. if (!$annuaire_tmp = $resultat->fetchObject()) {
  647. return false;
  648. }
  649. $annuaire_resultat = array();
  650. $tmp_resultat_ann = explode (";",$annuaire_tmp->infos);
  651. foreach ($tmp_resultat_ann as $tmp_ann) {
  652. $tmp = explode("=", $tmp_ann);
  653. if (count($tmp)==2) {
  654. $annuaire_resultat[$tmp[0]] = $tmp[1];
  655. if ($tmp[0] == "admin_emaila") {$email = $tmp[1];}
  656. if ($tmp[0] == "ref_contact") {$ref_contact = $tmp[1];}
  657. }
  658. }
  659. //modification des infos du contact
  660. $contact = new contact ($ref_contact);
  661. $profil_client = $contact->getProfil ($CLIENT_ID_PROFIL);
  662. $infos_generales = array();
  663. $infos_profils= array();
  664. $infos_generales['id_civilite'] = $contact->getId_civilite();
  665. if (isset($annuaire_resultat['civilite'])) { $infos_generales['id_civilite'] = $annuaire_resultat['civilite']; }
  666. $infos_generales['nom'] = $contact->getNom();
  667. if (isset($annuaire_resultat['nom'])) { $infos_generales['nom'] = $annuaire_resultat['nom']; }
  668. $infos_generales['siret'] = $contact->getSiret();
  669. if (isset($annuaire_resultat['siret'])) { $infos_generales['siret'] = $annuaire_resultat['siret']; }
  670. $infos_generales['tva_intra'] = $contact->getTva_intra();
  671. if (isset($annuaire_resultat['tva_intra'])) { $infos_generales['tva_intra'] = $annuaire_resultat['tva_intra']; }
  672. $infos_generales['id_categorie'] = $contact->getId_categorie();
  673. if (isset($annuaire_resultat['id_categorie'])) { $infos_generales['id_categorie'] = $annuaire_resultat['id_categorie']; }
  674. if (isset($annuaire_resultat['ref_adr_livraison']) && isset($annuaire_resultat['ref_adr_facturation'])) {
  675. if ($annuaire_resultat['ref_adr_livraison'] && $annuaire_resultat['ref_adr_facturation'] != $annuaire_resultat['ref_adr_livraison'] ) {
  676. $adresse = new adresse ($annuaire_resultat['ref_adr_livraison']);
  677. $adresse->modification($adresse->getLib_adresse (), $annuaire_resultat['livraison_adresse'], $annuaire_resultat['livraison_code'], $annuaire_resultat['livraison_ville'], $annuaire_resultat['id_pays_livraison'], $adresse->getNote ());
  678. } else {
  679. $adresse = new adresse ();
  680. $adresse->create ($ref_contact, "", $annuaire_resultat['livraison_adresse'], $annuaire_resultat['livraison_code'], $annuaire_resultat['livraison_ville'], $annuaire_resultat['id_pays_livraison'], "");
  681. if (isset($GLOBALS['_INFOS']['Crיation_adresse'])) {
  682. $profil_client->maj_ref_adr_livraison($GLOBALS['_INFOS']['Crיation_adresse']);
  683. unset ($GLOBALS['_INFOS']['Crיation_adresse']);
  684. }
  685. }
  686. unset($adresse);
  687. if ($annuaire_resultat['ref_adr_facturation'] && ($annuaire_resultat['ref_adr_facturation'] != $annuaire_resultat['ref_adr_livraison'] || !$annuaire_resultat['ref_adr_livraison']) ) {
  688. $adresse = new adresse ($annuaire_resultat['ref_adr_facturation']);
  689. $adresse->modification($adresse->getLib_adresse (), $annuaire_resultat['adresse_adresse'], $annuaire_resultat['adresse_code'], $annuaire_resultat['adresse_ville'], $annuaire_resultat['id_pays_contact'], $adresse->getNote ());
  690. } else {
  691. $adresse = new adresse ();
  692. $adresse->create ($ref_contact, "", $annuaire_resultat['adresse_adresse'], $annuaire_resultat['adresse_code'], $annuaire_resultat['adresse_ville'], $annuaire_resultat['id_pays_contact'], "");
  693. if (isset($GLOBALS['_INFOS']['Crיation_adresse'])) {
  694. $profil_client->maj_ref_adr_facturation($GLOBALS['_INFOS']['Crיation_adresse']);
  695. unset ($GLOBALS['_INFOS']['Crיation_adresse']);
  696. }
  697. }
  698. }
  699. if (isset($annuaire_resultat['ref_coordonnee'])) {
  700. if ($annuaire_resultat['ref_coordonnee']) {
  701. $coordonnee = new coordonnee ($annuaire_resultat['ref_coordonnee']);
  702. $coordonnee->modification ($coordonnee->getLib_coord(), $annuaire_resultat['coordonnee_tel1'], $annuaire_resultat['coordonnee_tel2'], $annuaire_resultat['coordonnee_fax'], $annuaire_resultat['admin_emaila'], $coordonnee->getNote(), "");
  703. } else {
  704. $coordonnee = new coordonnee ($annuaire_resultat['ref_coordonnee']);
  705. $coordonnee->create ($ref_contact, "", $annuaire_resultat['coordonnee_tel1'], $annuaire_resultat['coordonnee_tel2'], $annuaire_resultat['coordonnee_fax'], $annuaire_resultat['admin_emaila'], "", "", 0);
  706. }
  707. }
  708. $contact->modification ($infos_generales, $infos_profils);
  709. $infos_profils = array();
  710. //supprimer l'inscription
  711. $this->supprimer_inscription ($id_contact_tmp);
  712. //envoi email confirmation au contact si validation par collab
  713. if ($MODIFICATION_ALLOWED == 1) {
  714. //confirmation par email et rappel des identifiants
  715. $CONTENU_INSCRIPTION_VALIDATION_FINAL_2 = "
  716. Votre identifiant: ".$annuaire_resultat['admin_pseudo']." ou ".$annuaire_resultat['admin_emaila']."
  717. Votre mot de passe: ".$annuaire_resultat['admin_passworda']."
  718. ".$nom_entreprise."
  719.  
  720. -------------------------------------------------------------------------------------------------------------------------
  721. ";
  722. $message = $CONTENU_MODIFICATION_VALIDATION_FINAL.$CONTENU_MODIFICATION_VALIDATION_FINAL_2;
  723. $this->envoi_email_templated ($email , $SUJET_MODIFICATION_VALIDATION_FINAL , $message );
  724. }
  725. return true;
  726. }
  727. //supprimer l'inscription
  728. function supprimer_inscription ($id_contact_tmp) {
  729. global $bdd;
  730. $query = "DELETE FROM annuaire_tmp
  731. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  732. $bdd->exec ($query);
  733. }
  734. //fonction d'envoi des mail avec template
  735. function envoi_email_templated ($to, $sujet, $message) {
  736. // Envoi de l'email
  737. $mail = new email();
  738. $mail->prepare_envoi(0, 1);
  739. return $mail->envoi_email_templated ($to, $sujet, $message);
  740. }
  741. // *************************************************************************************************************
  742. // Fonctions d'accטs aux donnיes
  743. // *************************************************************************************************************
  744. // Retourne l'identifiant du id_interface
  745. final public function getId_interface () {
  746. return $this->id_interface;
  747. }
  748. // Retourne lib_interface
  749. final public function getLib_interface () {
  750. return $this->lib_interface;
  751. }
  752. // Retourne le dossier
  753. final public function getDossier () {
  754. return $this->dossier;
  755. }
  756. // Retourne l'url
  757. final public function getUrl () {
  758. return $this->url;
  759. }
  760. // Retourne l'identifiant du profil
  761. final public function getId_profil () {
  762. return $this->id_profil;
  763. }
  764. // Retourne defaut_id_theme
  765. final public function getDefaut_id_theme () {
  766. return $this->defaut_id_theme;
  767. }
  768. }
  769. //chargement de la liste des interfaces
  770. function charger_all_interfaces () {
  771. global $bdd;
  772. $interfaces_liste = array();
  773. $query = "SELECT id_interface, dossier, url, lib_interface, id_profil, defaut_id_theme
  774. FROM interfaces ";
  775. $resultat = $bdd->query ($query);
  776. while ($interface = $resultat->fetchObject()) {
  777. $interfaces_liste[] = $interface;
  778. }
  779. return $interfaces_liste;
  780. }
  781. // Charge la liste des documents en cours
  782. function get_liste_doc($id_type_doc, $liste_id_etat_doc, $ref_contact ) {
  783. global $bdd;
  784. $documents = array();
  785. $query = "SELECT d.ref_doc
  786. FROM documents d
  787. WHERE d.id_type_doc = '".$id_type_doc."' ";
  788. if($liste_id_etat_doc != ""){
  789. $query .= " && d.id_etat_doc IN (".$liste_id_etat_doc.") ";
  790. }
  791. $query .= " && ref_contact = '". $ref_contact ."'
  792. GROUP BY d.ref_doc
  793. ORDER BY d.id_etat_doc ASC, d.date_creation_doc DESC ";
  794. $resultat = $bdd->query ($query);
  795. while ($doc = $resultat->fetchObject()) {
  796. $documents[] = open_doc($doc->ref_doc);
  797. }
  798. return $documents;
  799. }
  800. function loadValidInProgress($email = 1, $id = null) {
  801. global $bdd;
  802. $query = "SELECT id_contact_tmp, id_interface, infos, date_demande, code_validation, validation_email, mode
  803. FROM annuaire_tmp";
  804. if ($email != 2 && $id == null)
  805. $query .= " WHERE validation_email='".$email."'";
  806. if ($id != null)
  807. $query .= " WHERE id_contact_tmp='".$id."'";
  808. $query .= ";";
  809. $res = $bdd->query($query);
  810. $wait_valids = array();
  811. $wait_modifs = array();
  812. while ($tmp = $res->fetchObject()) { if (strpos($tmp->infos, "ref_contact") < 0) $wait_valids[] = $tmp; else $wait_modifs[] = $tmp; }
  813. foreach ($wait_valids as &$wait_valid) {
  814. $infos = explode(";", $wait_valid->infos);
  815. $tab_tmp = array();
  816. foreach ($infos as $info) {
  817. $tab_tmp2 = explode("=", $info);
  818. $tab_tmp[$tab_tmp2[0]] = (isset($tab_tmp2[1])) ? $tab_tmp2[1] : "";
  819. }
  820. $wait_valid->infos = $tab_tmp;
  821. }
  822. foreach ($wait_modifs as &$wait_modif) {
  823. $infos = explode(";", $wait_modif->infos);
  824. $tab_tmp = array();
  825. foreach ($infos as $info) {
  826. $tab_tmp2 = explode("=", $info);
  827. $tab_tmp[$tab_tmp2[0]] = (isset($tab_tmp2[1])) ? $tab_tmp2[1] : "";
  828. }
  829. $wait_modif->infos = $tab_tmp;
  830. }
  831. return array($wait_valids, $wait_modifs);
  832. }
  833. function getAllLibProfils() {
  834. global $bdd;
  835. $query = "SELECT id_profil, lib_profil FROM profils";
  836. $res = $bdd->query($query);
  837. $tab_tmp = array();
  838. while ($tmp = $res->fetchObject()) { $tab_tmp [$tmp->id_profil] = $tmp->lib_profil; }
  839. return $tab_tmp;
  840. }
  841. function getAllLibAnnuCategs() {
  842. global $bdd;
  843. $query = "SELECT id_categorie, lib_categorie FROM annuaire_categories";
  844. $res = $bdd->query($query);
  845. $tab_tmp = array();
  846. while ($tmp = $res->fetchObject()) { $tab_tmp [$tmp->id_categorie] = $tmp->lib_categorie; }
  847. return $tab_tmp;
  848. }
  849. ?>