function listeFourni() { global $cnx, $liste; $cnx = ouvresylob(1); //on selectionne tous les champs qui seront utiles $sQuery = "SELECT distinct (f.no_frn) as id, f.rais_soc as raison_sociale, a.nom as contact, f.telph as tel, telex as email, \r\n CONCAT(a.adr1,a.adr2) as adresse, CONCAT(a.cd_post,a.ville) as ville\r\n FROM (informix.bas_frn f \r\n INNER JOIN informix.bas_adrfrn a ON a.no_frn = f.no_frn) \r\n LEFT JOIN informix.zz_materiel m ON m.frn_materiel = f.no_frn\r\n WHERE f.no_frn is not null\r\n AND a.no_adr = 1\r\n ORDER BY f.rais_soc asc, a.nom asc"; //echo $sQuery; $res = odbc_exec($cnx, $sQuery); $i = 0; while (odbc_fetch_row($res)) { for ($j = 1; $j <= odbc_num_fields($res); $j++) { $liste[$i][odbc_field_name($res, $j)] = odbc_result($res, $j); } $i++; } //odbc_close($cnx); return $liste; }
function preavisContrat($id) { global $cnx, $ladate; $cnx = ouvresylob(1); $select = "select fin_contratmat, preavis_contratmat from informix.zz_contratmat where id_contratmat = '" . $id . "'"; $res = odbc_exec($cnx, $select); while (odbc_fetch_row($res)) { $datefin = odbc_result($res, 1); $lepreavis = odbc_result($res, 2); } $ladate = new DateTime($datefin); $formule = "P" . $lepreavis . "M"; $ladate->sub(new DateInterval($formule)); if ($ladate->format('D') == 'Sat') { $ladate->sub(new DateInterval('P1D')); } if ($ladate->format('D') == 'Sun') { $ladate->sub(new DateInterval('P2D')); } return $ladate->format('Y-m-d'); }
include 'functions.php'; include '..\\classes\\materiel.class.php'; include '..\\classes\\contrat.class.php'; include '..\\classes\\intervention.class.php'; include '..\\classes\\fournisseur.class.php'; include '..\\classes\\user.class.php'; include '..\\classes\\service.class.php'; echo '<div id="conteneur" style="display:none; background-color:transparent; position:absolute; top:100px; left:45%; margin-right:5%; height:50px; width:20%; border:0px solid #000000;"> <div id="barre" style="display:block; background-color:#CCCCCC; width:0%; height:100%;"> <div id="pourcentage" style="text-align:right; height:100%; font-size:1.8em;"> <img src="images/gif-load.gif" alt="Nouveau Contrat" /> </div> </div> </div>'; //connexion base sylob $cnx = ouvresylob(1); //recup entite concernee pr entités déjà sélectionnées (en modif uniquement) if (isset($_POST['entite'])) { $entite = $_POST['entite']; } else { $entite = ""; } //print_r($_POST); //selon entite on applique les filtres switch ($entite) { /*****************************************************************************/ /* UTILISATEUR */ /*****************************************************************************/ case "users": //filtre sur GROUPE (service) if (isset($_POST['groupe']) and $_POST['groupe'] != '') {
function getMatInterOld($inter) { global $cnx; $cnx = ouvresylob(1); $select = "SELECT id_materiel FROM informix.zz_intervention WHERE id_inter = " . $inter; $sql = odbc_exec($cnx, $select); $matos = array(); while (odbc_fetch_row($sql)) { $matos[] = odbc_result($sql, 1); } odbc_free_result($sql); //odbc_close($cnx); return $matos; }
function afficheForm($entite, $titre, $id, $event = null, $source = null) { include_once 'classes/materiel.class.php'; include_once 'classes/fournisseur.class.php'; //initialise disabled global $disabled; $disabled = ''; $cnx = ouvresylob(1); //recup table pr chq entité switch ($entite) { case "contrat": $latable = "informix.zz_contratmat"; $lajointure = ""; $leschamps = "*"; $lechamp = "id_contratmat"; $obligatoires = array("num", "debut", "fin", "preavis", "ent"); break; case "intervention": $latable = "informix.zz_inter"; $lajointure = ""; $leschamps = "id_inter as id,debut_inter as debut, fin_inter as fin, \r\n presta_inter as prestataire, intervenant_inter as intervenant,\r\n etat_inter, type_inter, \r\n periodicite_inter as periodicite, priorite_inter as priorite, \r\n domaine_inter as domaine, cout_inter as cout,\r\n detail_inter as detail, supp_inter as supp"; $lechamp = "id_inter"; $obligatoires = array("debut", "fin", "intervenant", "type_inter", "domaine"); break; case "materiel": $latable = "informix.zz_materiel"; $lajointure = " left join informix.zz_misservice on informix.zz_misservice.id_materiel = informix.zz_materiel.id_materiel\r\n left join informix.zz_destruction on informix.zz_destruction.id_materiel = informix.zz_materiel.id_materiel\r\n left join informix.bas_postrav on informix.bas_postrav.no_poste= informix.zz_materiel.id_posttrav"; $leschamps = "informix.zz_materiel.id_materiel as id, sn_materiel as sn, desig_materiel as designation,\r\n zone_materiel as zonemateriel, famille_materiel as fammat, id_posttrav as poste,\r\n type_materiel as typemateriel, marq_materiel as marque_materiel, frn_materiel as fournisseur,\r\n dteha_materiel as achat, etat_materiel as etatmateriel, contrat_materiel as contratmat, \r\n informix.zz_materiel.usage_materiel as usagemateriel, dte_misservice, dte_destruction"; $lechamp = "informix.zz_materiel.id_materiel"; $obligatoires = array("designation", "zonemateriel", "fammat", "typemateriel", "etatmateriel", "dte_misservice"); break; default: $latable = "informix.zz_" . $entite; $lechamp = "id_" . $entite; $obligatoires = array(""); break; } //on recupere les champs de l'entite $sql = "select " . $leschamps . " from " . $latable; if ($lajointure != '') { $sql .= $lajointure; } if ($id != null) { //on a un id => recup entite pr modif $sql = $sql . " where " . $lechamp . " = " . $id . ""; } else { $sql = $sql . " where 1=2"; //recup dernier id renseigné $sql0 = "SELECT max(" . $lechamp . ") FROM " . $latable; //echo $sql0; $res = odbc_exec($cnx, $sql0) or die('Erreur : ' . $sql); if (odbc_result($res, 1) > 0) { $no = odbc_result($res, 1) + 1; } else { $no = 1; } } $result = odbc_exec($cnx, $sql) or die('Erreur : ' . $sql); $ncols = odbc_num_fields($result); for ($i = 0; $i < odbc_num_fields($result); $i++) { $champs[] = odbc_field_name($result, $i + 1); $typeChamp[] = odbc_field_type($result, $i + 1); } $nb_champs = odbc_num_fields($result); //initialise tableau de valeurs a vide $valeurs = array(); for ($i = 0; $i < $nb_champs; $i++) { $valeurs[$i] = ''; } //si id renseigné => on est en modif : on recup donnees table if ($id) { while (odbc_fetch_row($result)) { for ($i = 0; $i < $nb_champs; $i++) { $valeurs[$i] = odbc_result($result, $i + 1); } //si etat = 3 on disabled if ($entite == 'intervention' and $valeurs[5] == 3 or $entite == 'materiel' and $valeurs[10] == 3) { $disabled = 'disabled'; } } $no = $id; } elseif (isset($_POST['id'])) { for ($i = 0; $i < $nb_champs; $i++) { if (isset($_POST[$champs[$i]]) and $_POST[$champs[$i]] != '') { $valeurs[$i] = $_POST[$champs[$i]]; } } $no = $_POST['id']; //on recup n° entite pr affichage } elseif (isset($_GET['materiel']) and $_GET['materiel'] != '') { for ($i = 0; $i < $nb_champs; $i++) { if (isset($_GET[$champs[$i]]) and $_GET[$champs[$i]] != '') { $valeurs[$i] = utf8_decode($_GET[$champs[$i]]); //on a encode pr passer en param ds calendar => on decode } } } //odbc_close($cnx); echo "<br>"; echo "<div id='edit'>"; echo "<TABLE align=center style=background:#fdf2db;color:#135356>\r\n <TR>\r\n <TD colspan=6 style='background:#519085' width=1090 align=right>\r\n <a href='" . $entite . ".php' ><img border=0 src='images/list.png' title='Affichage liste'></a>\r\n </td>\r\n </tr>\r\n </table>"; //affichage different pour materiel_infos if ($entite != 'materiel_infos') { //si contrat ou inter on doit recup liste materiels concernés if ($entite == "contrat" or $entite == "intervention") { $java = "onSubmit='javascript: soumettre_1liste(document.forms[0].choisi);'"; } else { $java = ""; } //affichage du formulaire echo " <form name='" . $entite . "' " . $java . " action = 'edit_" . $entite . ".php' \r\n method='post' onfocus='trie(this," . $entite . ",2);');'>\r\n <TABLE align=center style=background:#fdf2db;color:#135356>\r\n <TR>\r\n <TD colspan = 6 style='background:#519085' width=1090>\r\n <span>" . strtoupper(utf8_decode($titre)) . "</span>\r\n </TD>\r\n </TR>\r\n <tr><td colspan=6> </td></tr>\r\n <TR>\r\n <TD colspan = 6 align=center>\r\n <font color=#135356 size=5><b>" . str_replace("MATERIEL", "ENTITE", strtoupper(utf8_decode(str_replace("informix.zz_", "", $entite)))) . " N°" . $no . "</b></font>\r\n </TD>\r\n </TR>\r\n <tr><td colspan=6> </td></tr>\r\n <TR>\r\n <TD></TD><TD></TD>\r\n </TR>"; } //si form contrat ou inter on choisi le(s) materiel(s) concerné(s) if ($entite == 'contrat' or $entite == 'intervention') { afficheFiltre($entite); //liste materiel selectionné if ($id != '') { switch ($entite) { case 'contrat': $listemateriels = getMatContrat($id); break; case 'intervention': $listemateriels = getMatInter($id); break; default: break; } } else { $listemateriels = array(); } echo "<tr><td colspan=6><table border=0 align=center><tr> \r\n <th>Entités disponibles </th><th></th><th></th><th>Entité(s) concernée(s) </th></tr><tr>\r\n <td><select size = 10 style='width:300' name=dispo[] id=dispo " . $disabled . " multiple onDblClick='javascript: deplacer(this.form.dispo, this.form.choisi);'>"; //contenu liste materiel dispo renseigné par script echo " </select></td>"; echo " <td></td><td>\r\n <input type=button " . $disabled . " value=Ajouter onclick='javascript: deplacer(this.form.dispo, this.form.choisi);'><br><br>\r\n <input type=button " . $disabled . " value=Retirer onclick='javascript: deplacer(this.form.choisi, this.form.dispo);'>\r\n </td>"; echo " <td><select size = 10 style='width:300' class='obligatoire' name=choisi[] id=choisi " . $disabled . " multiple onDblClick='javascript: deplacer(this.form.choisi, this.form.dispo);'>"; foreach ($listemateriels as $materiel) { echo " <option value ='" . $materiel . "' >" . $materiel . " - " . utf8_encode(getNomMat($materiel)) . "</option>"; } echo " </select></td></tr></table>"; } echo " <TR><tr><td colspan=6> </td></tr>"; //on boucle sur ts les champs de l'entite pour faire le formulaire for ($i = 0; $i < $nb_champs; $i++) { $champs[$i] = str_replace("_contratmat", "", $champs[$i]); if (in_array($champs[$i], $obligatoires)) { $classe = "class=obligatoire"; } else { $classe = ""; } $label = formatLabel($champs[$i]); //on cree les champs de formulaire selon leur type switch ($typeChamp[$i]) { case "INTEGER": //int sylob formInteger($champs[$i], $valeurs[$i], $disabled, $classe); break; case "SERIAL": //id $id = $valeurs[$i]; //recupere l'id echo "<input type=hidden name=id value='" . $id . "'>"; break; case "FLOAT": //duree ou prix if ($champs[$i] == "duree") { echo "<td>" . $label . " </td><td><input type=text " . $disabled . " " . $classe . " name=" . $champs[$i] . " value = '" . $valeurs[$i] . "' onKeyPress='return chiffres(event);'> heure(s)</td>"; } else { echo "<td>" . $label . " </td><td><input type=text " . $disabled . " " . $classe . " name=" . $champs[$i] . " value = '" . $valeurs[$i] . "' onKeyPress='return chiffres(event);'> € HT</td>"; } break; case "DATE": //date sylob formDate($champs[$i], $valeurs[$i], $disabled); break; case "DATETIME YEAR TO MINUTE": //date + heure sylob if (isset($_GET['debut'])) { //echo $_GET['debut']; formHeure($champs[$i], $_GET['debut'], $disabled); } else { //echo $valeurs[$i]; formHeure($champs[$i], $valeurs[$i], $disabled); } break; case "CHAR": //char sylob formChar($champs[$i], $valeurs[$i], $disabled, $classe); break; case "VARCHAR": //textarea echo "</TR><TR><td>" . $label . " </td><td colspan=5><textarea " . $disabled . " name=" . $champs[$i] . " cols=50 rows=5>" . utf8_encode($valeurs[$i]) . "</textarea></td></TR><TR>"; break; default: echo "pas traité :" . $champs[$i] . " - " . $typeChamp[$i]; break; } if ($i % 3 == 0) { echo "<tr><td colspan=6> </td></tr>"; } } //si on vient du calendrier on recuperre source if (isset($source) and $source == "calendrier") { echo "<input type=hidden " . $disabled . " name=source value=" . $source . ">"; } if ($entite != "materiel_infos") { echo " </TR> \r\n <TR>\r\n <TD COLSPAN=6 align = center>\r\n <input type=button " . $disabled . " id=monform name=monform onclick=verifForm(this.form); value=Valider />\r\n </TD>\r\n </TR>\r\n </TABLE> \r\n </form>\r\n </div>"; } }
function getNomMat($id) { global $cnx, $nom; $cnx = ouvresylob(1); //on selectionne tous les champs qui seront utiles $sQuery = "SELECT desig_materiel\r\n FROM informix.zz_materiel \r\n WHERE id_materiel = '" . Trim($id) . "'"; //echo $sQuery; $res = odbc_exec($cnx, $sQuery); $i = 0; while (odbc_fetch_row($res)) { $nom = odbc_result($res, 1); } //odbc_close($cnx); return $nom; }