function dupliqueInter($id) { global $cnx, $liste; $cnx = ouvresylob(1); //recup infos à dupliquer $select = " select * from informix.zz_inter \r\n where informix.zz_inter.id_inter = " . $id; $sql = odbc_exec($cnx, $select); while ($row = odbc_fetch_array($sql)) { $debut = $row['debut_inter']; $fin = $row['fin_inter']; $presta = $row['presta_inter']; $interventant = $row['intervenant_inter']; $etat = $row['etat_inter']; $type = $row['type_inter']; $parent = $row['parent_inter']; $periodicite = $row['periodicite_inter']; $priorite = $row['priorite_inter']; $domaine = $row['domaine_inter']; $cout = $row['cout_inter']; $detail = $row['detail_inter']; $supp = $row['supp_inter']; } $nouv_deb = new DateTime($debut); $nouv_fin = new DateTime($fin); $nouv_deb = $nouv_deb->add(new DateInterval('PT1H'))->format('Y-m-d H:i'); $nouv_fin = $nouv_fin->add(new DateInterval('PT1H'))->format('Y-m-d H:i'); //insert nouvelle inter $UID = insertInter($nouv_deb, $nouv_fin, $presta, $interventant, 1, $type, $parent, $periodicite, $priorite, $domaine, $cout, formatChaine($detail)); //recup matos inter à dupliquer $select2 = "select id_materiel from informix.zz_matinter where id_inter = " . $id; $sql2 = odbc_exec($cnx, $select2); while (odbc_fetch_row($sql2)) { //lie materiel à nouvelle inter $res3 = addMatInter($UID, odbc_result($sql2, 1)); } //odbc_close($cnx); return $UID; }
} else { $contrat = $_POST['contratmat']; } if ($valide == 1) { //on peut traiter //on a un id -> modif if (isset($_POST['id']) and $_POST['id'] != '') { $res = updateMateriel($_POST['id'], $_POST['sn'], formatChaine($_POST['designation']), $_POST['zonemateriel'], $_POST['fammat'], $_POST['poste'], $_POST['typemateriel'], $_POST['marque_materiel'], $_POST['fournisseur'], $_POST['achat'], $_POST['etatmateriel'], $contrat, $_POST['usagemateriel'], $_POST['dte_misservice'], $_POST['dte_destruction']); $texte = "Modification entité terminée."; } else { //recherche doublon avant ajout $doublon = doublonMateriel($_POST['sn']); if ($doublon == 1) { echo "<script language=javascript> alert ('Doublon pour cette entité !');</script>"; } else { $res = insertMateriel($_POST['sn'], formatChaine($_POST['designation']), $_POST['zonemateriel'], $_POST['fammat'], $_POST['poste'], $_POST['typemateriel'], $_POST['marque_materiel'], $_POST['fournisseur'], $_POST['achat'], $_POST['etatmateriel'], $contrat, $_POST['usagemateriel'], $_POST['dte_misservice'], $_POST['dte_destruction']); $texte = "Ajout entité terminé."; } } //si etat=inactif => destruction if ($_POST['etatmateriel'] == '3') { $res = deleteMateriel($_POST['id'], $_POST['dte_destruction']); } //affichage apres traitement echo "<script language=javascript> alert ('" . $texte . "');</script>"; //si on est dans un popup on le ferme if (isset($_POST['source']) and $_POST['source'] == "calendrier") { echo "<script type='text/javascript'>window.parent.opener.location.reload();window.self.close();</script>"; } elseif (isset($res) and $res == true) { echo "<script type='text/javascript'>document.location.replace('materiel.php');</script>"; }
if (isset($_POST['id']) and $_POST['id'] != '') { $res = updateContrat($_POST['id'], $_POST['num'], $_POST['debut'], $_POST['fin'], formatChaine($_POST['desc']), $_POST['preavis'], $_POST['renouv'], $_POST['ent'], formatChaine($_POST['nom']), formatChaine($_POST['prenom']), $_POST['email'], $_POST['tel'], $_POST['cout']); //RAZ association materiel(s) - contrat $raz = razMatContrat($_POST['id']); //association materiel(s) - contrat foreach ($_POST['choisi'] as $mat) { $res2 = modMatContrat($_POST['id'], $mat); } $texte = "Modification contrat terminée."; } else { //recherche doublon avant ajout $doublon = doublonContrat($_POST['num']); if ($doublon == 1) { echo "<script language=javascript> alert ('Doublon pour ce contrat !');</script>"; } else { $res = insertContrat($_POST['num'], $_POST['debut'], $_POST['fin'], formatChaine($_POST['desc']), $_POST['preavis'], $_POST['renouv'], $_POST['ent'], formatChaine($_POST['nom']), formatChaine($_POST['prenom']), $_POST['email'], $_POST['tel'], $_POST['cout']); //association materiel(s) - contrat foreach ($_POST['choisi'] as $mat) { $res2 = modMatContrat($res, $mat); } $texte = "Ajout contrat terminé."; } } //affichage apres traitement echo "<script language=javascript> alert ('" . $texte . "');</script>"; //si on est dans un popup on le ferme if (isset($_POST['source']) and $_POST['source'] == "calendrier") { echo "<script type='text/javascript'>window.parent.opener.location.reload();window.self.close();</script>"; } elseif (isset($res) and $res == true) { echo "<script type='text/javascript'>document.location.replace('contrat.php');</script>"; }
//lien intervention - entite(s) foreach ($_POST['choisi'] as $mat) { $res4 = addMatInter($res3, $mat); } $texte .= " - prochaine échéance créée."; } } } else { //recherche doublon avant ajout $doublon = doublonInter($debut, $_POST['type_inter'], $_POST['prestataire']); if ($doublon > 0) { //message doublon echo "<script language=javascript> alert ('Doublon pour cette intervention !');</script>"; } else { // on peut insérer $res = insertInter($debut, $fin, $_POST['prestataire'], $_POST['intervenant'], $_POST['etat_inter'], $_POST['type_inter'], 0, $_POST['periodicite'], $_POST['priorite'], $_POST['domaine'], $_POST['cout'], formatChaine($_POST['detail'])); $texte = "Ajout intervention terminé."; //lien intervention - entite(s) foreach ($_POST['choisi'] as $mat) { $res2 = addMatInter($res, $mat); } //si fini (etat=3) => log inter + si periodicite => cree prochaine echeance if ($_POST['etat_inter'] == 3) { $log = logInter($res); $texte .= " - cloture loggée."; if ($_POST['periodicite'] > 1) { //calcul dates prochaine echeance $nouv_deb = echeance($debut, $_POST['periodicite'])->format('Y-m-d H:i'); $nouv_fin = echeance($fin, $_POST['periodicite'])->format('Y-m-d H:i'); $res3 = insertInter($nouv_deb, $nouv_fin, $_POST['prestataire'], $_POST['intervenant'], 1, $_POST['type_inter'], $res, $_POST['periodicite'], $_POST['priorite'], $_POST['domaine'], $_POST['cout'], ''); //lien intervention - entite(s)