set_empr_id($empr->id_empr); $evth = events_handler::get_instance(); $evth->send($evt); $lock_validation = false; if($evt->get_result()){ $lock_validation = $evt->get_result()["lock_validation"]; } $rqt_maj = "update resa set resa_confirmee=1 where id_resa in (".$id_resa.") AND resa_cb is not null and resa_cb!=''" ; if ($id_empr_concerne) $rqt_maj .= " and resa_idempr=$id_empr_concerne "; pmb_mysql_query($rqt_maj, $dbh); if ($lock_validation || $pdflettreresa_priorite_email==3) continue; if (($pdflettreresa_priorite_email==1 || $pdflettreresa_priorite_email==2) && $empr->empr_mail) { //S'il n'y à pas de paramètre de $lock_validation pour bloquer l'envoi du mail if (!$lock_validation){ $to = $empr->empr_prenom." ".$empr->empr_nom." <".$empr->empr_mail.">"; $mail_reader_resa = new mail_reader_resa(); $res_envoi = $mail_reader_resa->send_mail($empr); } if (empty($res_envoi) || $pdflettreresa_priorite_email==2) { if(is_resa_confirme($empr->id_resa)) { $tab_resa[] = $empr->id_resa; } } } elseif ($pdflettreresa_priorite_email!=3) { if(is_resa_confirme($empr->id_resa)) { $tab_resa[] = $empr->id_resa; } } if(is_resa_confirme($empr->id_resa) && $empr->empr_tel1 && $empr->empr_sms && $empr_sms_msg_resa_dispo && !$lock_validation){ $res_envoi_sms=send_sms(1, 0, $empr->empr_tel1,$empr_sms_msg_resa_dispo); } } // end while if (empty($lock_validation) || $pdflettreresa_priorite_email != 3){ $valeur_tab = implode(',',$tab_resa); if($valeur_tab && !$print_mode) print ""; } } //Fonction de test si la resa est valide ou non function is_resa_confirme($id_resa=0){ global $dbh; $rqt = "select * from resa where id_resa=$id_resa and resa_cb is not null and resa_cb!='' order by resa_idempr "; $res = pmb_mysql_query($rqt, $dbh) ; while ($resa_lue = pmb_mysql_fetch_object($res)) { if ($resa_lue->resa_confirmee) { // archivage $rqt_arch = "UPDATE resa_archive, resa, exemplaires SET resarc_confirmee = 1, resarc_loc_retrait = resa_loc_retrait, resarc_cb = resa_cb, resarc_debut = resa_date_debut, resarc_fin = resa_date_fin, resarc_expl_typdoc = expl_typdoc, resarc_expl_cote = expl_cote, resarc_expl_statut = expl_statut, resarc_expl_location = expl_location, resarc_expl_codestat =expl_codestat, resarc_expl_owner = expl_owner, resarc_expl_section = expl_section WHERE id_resa = $id_resa AND resa_arc = resarc_id AND resa_cb = expl_cb "; pmb_mysql_query($rqt_arch, $dbh); return true; } } return false; }