public function lecture_rapport_recu($id_attente, $origin, $cas)
 {
     $mes_infos = requetemysql::mes_infos();
     if (empty($mes_infos)) {
         throw new Exception("Vous êtes introuvables dans la bdd identification!");
     }
     $mes_infos = json_decode($mes_infos, true);
     $tva = $mes_infos[0]['tva'];
     $marge_medic = $mes_infos[0]['marge'];
     $mes_infos2 = requetemysql::mes_infos2();
     if (empty($mes_infos2)) {
         throw new Exception("Vous êtes introuvables dans la bdd identification!");
     }
     $mes_infos2 = json_decode($mes_infos2, true);
     $afficher_facture = $mes_infos2[0]['facture'];
     $afficher_resume = $mes_infos2[0]['resume'];
     if ($cas == "rapport_recus") {
         $salle_attente = requetemysql::rapport_ref($id_attente);
     } elseif ($cas == "envoi_refere") {
         $salle_attente = requetemysql::rapport_refere($id_attente);
     }
     if (empty($salle_attente)) {
         throw new Exception("Aucun animal dans la salle d'attente !");
     }
     $salle_attente2 = json_decode($salle_attente, true);
     $id_pro = $salle_attente2[0]['id_pro'];
     $id_ani = $salle_attente2[0]['id_ani'];
     $animal = requetemysql::findunanimal(array('id_pro' => $id_pro, 'id_ani' => $id_ani));
     if (empty($animal)) {
         throw new Exception("Aucun animal de cet id dans la base de donnée !");
     }
     $historique = requetemysql::historique(array('id' => $id_ani));
     if (empty($historique)) {
         throw new Exception("Erreur dans la recherche des antécédents de l animal");
     }
     $client = requetemysql::findunclient2(array('id' => $id_pro));
     if (empty($client)) {
         throw new Exception("Aucun client dans la base de donnée !");
     }
     $animal2 = json_decode($animal, true);
     $datenais = $animal2[0]['datenais'];
     $tarif = requetemysql::info_tarif();
     if (empty($tarif)) {
         throw new Exception("Aucun tarif dans la base de donnée !");
     }
     // recherche dans la base de donnee les differents règlements pour le client
     $restedu = requetemysql::restedu(array('id_pro' => $id_pro));
     if (empty($restedu)) {
         throw new Exception("Pas de règlement dans la base");
     }
     $vetos = requetemysql::listevetos();
     if (empty($vetos)) {
         throw new Exception("Pas de vetos dans la base");
     }
     $liste_resume = array(array(nom => "Vaccin", valeur => 5), array(nom => "Gastrite", valeur => 3), array(nom => "Enterite", valeur => 4), array(nom => "Abattement", valeur => 2), array(nom => "boiterie", valeur => 4), array(nom => "Certificat", valeur => 1), array(nom => "Anorexie", valeur => 3), array(nom => "Otite", valeur => 2), array(nom => "Piroplasmose", valeur => 2), array(nom => "Epillet oreille", valeur => 3), array(nom => "Ovarioectomie", valeur => 1), array(nom => "Castration", valeur => 1), array(nom => "Difficultés respiratoires", valeur => 1), array(nom => "Cardiaque", valeur => 3), array(nom => "Achat", valeur => 5), array(nom => "Arthrose", valeur => 3));
     $liste_motif_relance = array(array(nom => "Vaccin", valeur => 1), array(nom => "Anovulatoire", valeur => 2), array(nom => "Vermifuge", valeur => 3));
     $liste_analyse = array(array(nom => "Urée", unite => "g/l", base => "< 0.7g/l", methode => "reflotron"), array(nom => "Glucose", unite => "g/l", base => "< 1.3g/l", methode => "reflotron"), array(nom => "PAL", unite => "UI/l", base => "< 200UI/l", methode => "reflotron"), array(nom => "Globules Blancs", unite => "m/l", base => "< 15000m/l", methode => "MS4"), array(nom => "Hémathocrite", unite => "g/l", base => "> 8g/l", methode => "MS4"));
     $liste_radio = array(array(nom => "thorax profil petit chien", kV => "70", mAS => "5", sec => "5"), array(nom => "abdomen face petit chien", kV => "80", mAS => "10", sec => "6"), array(nom => "Carpe gros chien", kV => "20", mAS => "3", sec => "7"), array(nom => "bassin petit chat", kV => "60", mAS => "7", sec => "8"));
     //	$efface_salle_attente = requetemysql::supr_salle_attente($id_attente);
     //	if(empty($efface_salle_attente)){
     //	throw new Exception("Effaçage de la salle d attente impossible !");
     //	}
     render('_nouvelleconsultation', array('title' => 'Fiche Animal', 'id_pro' => $id_pro, 'id_ani' => $id_ani, 'animal' => $animal, 'client' => $client, 'origin' => $origin, 'liste_resume' => $liste_resume, 'liste_motif_relance' => $liste_motif_relance, 'liste_analyse' => $liste_analyse, 'liste_radio' => $liste_radio, 'liste_vetos' => $vetos, 'veto' => $_SESSION['login'], 'historique' => $historique, 'datenaissance' => $datenais, 'tarif' => $tarif, 'tva' => $tva, 'restedu' => $restedu, 'marge_medic' => $marge_medic, 'afficher_facture' => $afficher_facture, 'afficher_resume' => $afficher_resume, 'salle_attente_donnee' => $salle_attente, 'themechargement' => 'b', 'cas' => $cas, 'consult' => 0, 'veto_repartition' => 0, 'liste_tournures' => ordo_settings_tourn(), 'liste_cat_delivre' => ordo_settings_cat(), 'info_veto' => info_clini(), 'textechargement' => 'enregistrement en cours'));
 }
 public function find()
 {
     try {
         $mes_infos2 = requetemysql::mes_infos();
         if (empty($mes_infos2)) {
             throw new Exception("Vous êtes introuvables dans la bdd identification!");
         }
         $mes_infos = json_decode($mes_infos2, true);
         $afficher_telecom = $mes_infos[0]['telecom'];
         if ($afficher_telecom == 1) {
             $telephone = requetemysql::mes_appels_entrants();
             if (empty($telephone)) {
                 throw new Exception("Error in mes_appels_entrants function");
             }
         } else {
             $telephone = json_encode('');
         }
         $utiliser_sms = $mes_infos[0]['sms'];
         $afficher_ecran_def = $mes_infos[0]['ecran_def'];
         $video_attente = $mes_infos[0]['video_attente'];
         if ($mes_infos[0]['ecran_def'] == 1) {
             $ecran_def = requetemysql::mes_messages_defilant(array('permission' => $_SESSION['login']));
             if (empty($ecran_def)) {
                 throw new Exception("Error in mes_messages_defilant function");
             }
         } else {
             $ecran_def = json_encode('');
         }
         if ($mes_infos[0]['video_attente'] == 1) {
             $camera_adresse = requetemysql::search_list_cam_ip($_SESSION['login']);
             if (empty($camera_adresse)) {
                 throw new Exception("Error in search_list_cam_ip function");
             }
         } else {
             $camera_adresse = json_encode('');
         }
         $client = requetemysql::findclient("client");
         if (empty($client)) {
             throw new Exception("Error in findclient function , client part !");
         }
         $animaux = requetemysql::findclient("ax");
         if (empty($animaux)) {
             throw new Exception("Error in findclient function, ax part !");
         }
         $salle_attente = requetemysql::salle_attente("general");
         if (empty($salle_attente)) {
             throw new Exception("Error in salle_attente function, general part !");
         }
         $rapport_ref = requetemysql::rapport_ref("general");
         if (empty($rapport_ref)) {
             throw new Exception("Error in rapport_ref function, general part !");
         }
         $rapport_redige = requetemysql::rapport_redige("general");
         if (empty($rapport_redige)) {
             throw new Exception("Error in rapport_redige function, general part !");
         }
         $rapport_refere = requetemysql::rapport_refere("general");
         if (empty($rapport_refere)) {
             throw new Exception("Error in rapport_refere fonction, general part !");
         }
         $liste_mur = requetemysql::liste_mur("general");
         if (empty($liste_mur)) {
             throw new Exception("Error in liste_mur fonction, general part !");
         }
         // liste des vétos du tour de garde
         $vetos = requetemysql::listevetos();
         if (empty($vetos)) {
             throw new Exception("Error in listevetos fonction !");
         }
         $liste_message_recu_perso = requetemysql::liste_message(array('login' => $_SESSION['login2'], 'choix' => 'recu'));
         if (empty($liste_message_recu_perso)) {
             throw new Exception("Error in liste_message function ! param : login: "******" choix: recu");
         }
         $liste_message_recu_garde = requetemysql::liste_message(array('login' => $_SESSION['login'], 'choix' => 'recu'));
         if (empty($liste_message_recu_garde)) {
             throw new Exception("Error in liste_message function ! param : login: "******" choix: recu");
         }
         $liste_message_emis = requetemysql::liste_message(array('login' => $_SESSION['login2'], 'choix' => 'emis'));
         if (empty($liste_message_emis)) {
             throw new Exception("Error in liste_message function ! param : login: "******" choix: emis");
         }
         $historique = requetemysql::brouillard(array('choix' => 'historique2'));
         if (empty($historique)) {
             throw new Exception("Error in brouillard function ! param : choix : historique");
         }
         $date_debut = mktime(0, 0, 0, date("m"), 1, date("Y"));
         $date_fin = mktime(0, 0, 0, date("m") + 1, 1, date("Y"));
         $planning = requetemysql::liste_garde(array('debut' => $date_debut, 'fin' => $date_fin));
         $info_tour = requetemysql::info_tour2(array('login' => $_SESSION['tour']));
         if (empty($info_tour)) {
             throw new Exception("Aucun tour dans la base de donnée !");
         }
         $info_tour_deco = json_decode($info_tour, true);
         if ($info_tour_deco[0]['envoi_mail'] == 0) {
             $date_envoi_mail = mktime(0, 0, 0, date("m"), date("d") + $info_tour_deco[0]['jour'], date("Y"));
             $deja_envoye = requetemysql::mail_allready_send(array('ma_date' => $date_envoi_mail));
             if (count($deja_envoye) == 0 && date("H") >= 7 && date("H") <= 23) {
                 $envoyer_mail = requetemysql::envoyer_mail(array('ma_date' => $date_envoi_mail));
                 $mail_envoye = requetemysql::mail_send(array('ma_date' => $date_envoi_mail));
             }
         }
         //envoi sms automatique au veterinaire de garde
         $liste_cat_planning = array(array(nom => "garde", abr => "G", valeur => 0), array(nom => "astreinte", abr => "A", valeur => 1));
         if ($mes_infos[0]['sms'] == 1 && $info_tour_deco[0]['envoi_sms'] == 0) {
             $date_envoi_sms = mktime(0, 0, 0, date("m"), date("d") + $info_tour_deco[0]['jour2'], date("Y"));
             $deja_envoye_sms = requetemysql::sms_allready_send(array('ma_date' => $date_envoi_sms, 'nature' => 1));
             if (count($deja_envoye_sms) == 0 && date("H") >= 7 && date("H") <= 23) {
                 $envoyer_sms = requetemysql::envoyer_sms(array('ma_date' => $date_envoi_sms, 'liste_cat' => $liste_cat_planning));
                 $sms_envoye = requetemysql::sms_send(array('ma_date' => $date_envoi_sms));
             }
         }
         $liste_choix_ecran = array(array(nom => TXT_RECHERCHECLIENT_CONTROLLER_WAIT2MIN, choix => 0, temps => 2), array(nom => TXT_RECHERCHECLIENT_CONTROLLER_WAIT5MIN, choix => 0, temps => 5), array(nom => TXT_RECHERCHECLIENT_CONTROLLER_WAIT10MIN, choix => 0, temps => 10), array(nom => TXT_RECHERCHECLIENT_CONTROLLER_WAIT20MIN, choix => 0, temps => 20), array(nom => TXT_RECHERCHECLIENT_CONTROLLER_WAIT30MIN, choix => 0, temps => 30), array(nom => TXT_RECHERCHECLIENT_CONTROLLER_WAIT60MIN, choix => 0, temps => 60), array(nom => TXT_RECHERCHECLIENT_CONTROLLER_CONSULTATION_RENDEZ_VOUS, choix => 1, temps => 300));
         //	$planning = requetemysql::planning(array('tour'=>$_SESSION['tour'], 'date_debut'=>$date_debut, 'date_fin'=>$date_fin, 'nature'=>1));
         //		if(empty($planning)){
         //			throw new Exception("Error in planning function ! param : tour :"+$_SESSION['tour']+" date_debut : "+$date_debut+" date_fin : "+$date_fin+" nature : 1");
         //		}
         //	$planning2 = requetemysql::planning(array('tour'=>$_SESSION['tour'], 'date_debut'=>$date_debut, 'date_fin'=>$date_fin, 'nature'=>2));
         //		if(empty($planning2)){
         //			throw new Exception("Error in planning function ! param : tour :"+$_SESSION['tour']+" date_debut : "+$date_debut+" date_fin : "+$date_fin+" nature : 2");
         //		}
         render('_accueil', array('title' => TXT_RECHERCHECLIENT_CONTROLLER_TITTLE, 'texte_recherche' => TXT_RECHERCHECLIENT_CONTROLLER_SEARCH1, 'texte_recherche2' => TXT_RECHERCHECLIENT_CONTROLLER_SEARCH2, 'client' => $client, 'animaux' => $animaux, 'salle_attente' => $salle_attente, 'rapport_ref' => $rapport_ref, 'rapport_redige' => $rapport_redige, 'casrefere' => $rapport_refere, 'liste_vetos' => $vetos, 'liste_message_recu_perso' => $liste_message_recu_perso, 'liste_message_recu_garde' => $liste_message_recu_garde, 'liste_message_emis' => $liste_message_emis, 'planning' => $planning, 'historique' => $historique, 'liste_mur' => $liste_mur, 'info_veto' => $mes_infos2, 'telecom' => $afficher_telecom, 'telephone' => $telephone, 'afficher_ecran_def' => $afficher_ecran_def, 'liste_ecran_def' => $liste_choix_ecran, 'ecran_def' => $ecran_def, 'utiliser_sms' => $utiliser_sms, 'video_attente' => $video_attente, 'liste_cat_planning' => $liste_cat_planning, 'camera_adresse' => $camera_adresse));
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }