Example #1
0
                    echo "<TD>" . utf8_encode($ligne[$key]) . $post . "</TD>";
                    break;
            }
        }
        //affichage entités liées au contrat ou a l'inter
        if ($titre == "Contrats") {
            echo "<td><div style='overflow:auto; height: 20px; width: 250px;' white-space: nowrap>";
            $materiels = getMatContrat($ligne['id']);
            foreach ($materiels as $materiel) {
                echo utf8_encode(getNomMat($materiel)) . "<br>";
            }
            echo "</div></td>";
        }
        if ($titre == 'Interventions') {
            echo "<td><div style='overflow:auto; height: 20px; width: 250px;' white-space: nowrap>";
            $materiels = getMatInter($ligne['id']);
            foreach ($materiels as $materiel) {
                echo utf8_encode(getNomMat($materiel)) . "<br>";
            }
            echo "</div></td>";
        }
    }
    echo "</tbody>";
    ?>
            </TABLE>
        </DIV>
    </DIV>
    <?php 
} else {
    echo "<h2>Aucun(e) " . $titre . " pour l'instant.</h2>";
}
Example #2
0
 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>&nbsp;</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>&nbsp;</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&eacute;s disponibles </th><th></th><th></th><th>Entit&eacute;(s) concern&eacute;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>&nbsp;</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);'> &euro; 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>&nbsp;</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>";
     }
 }
Example #3
0
function creerEvents($uneliste, $titre)
{
    //initialise tableaux
    $eventArray = array();
    $lesevents = array();
    foreach ($uneliste as $evenement) {
        $eventArray['id'] = $evenement['id'];
        //description
        $description = "";
        //si titre=contrat => on est ds contrat
        if ($titre == 'Contrat') {
            $eventArray['title'] = trim($evenement['num']);
            $eventArray['start'] = preavisContrat($evenement['id']);
            if ($evenement['ent'] != "") {
                $description .= "<u>Entreprise</u> : " . $evenement['ent'] . "<br>";
            }
            if ($evenement['contact'] != "") {
                $description .= "<u>Contact</u> : " . utf8_encode($evenement['contact']) . "<br>";
            }
            if ($evenement['email'] != "") {
                $description .= "email : " . utf8_encode($evenement['email']) . "<br>";
            }
            if ($evenement['tel'] != "") {
                $description .= "tel : " . utf8_encode($evenement['tel']) . "<br>";
            }
            $materiels = array();
            $materiels = getMatContrat($evenement['id']);
            $eventArray['url'] = "javascript:affichage_popup1('edit_contrat.php?source=calendrier&id=" . $evenement['id'] . "','popup_1')";
            $eventArray['color'] = "#0000FF";
        } elseif ($titre == 'Intervention') {
            $eventArray['title'] = "Inter. n°" . $evenement['id'] . " " . utf8_encode(trim($evenement['type_inter']));
            $eventArray['start'] = $evenement['debut'];
            $eventArray['end'] = $evenement['fin'];
            if ($evenement['prestataire'] != "") {
                $description .= "<u>Prestataire</u> : " . $evenement['prestataire'] . "<br>";
            }
            if ($evenement['interlocuteur'] != "") {
                $description .= "<u>Interlocuteur</u> : " . utf8_encode($evenement['interlocuteur']) . "<br>";
            }
            //couleur de l'event
            switch ($evenement['etat']) {
                case '1':
                    //a faire => rouge
                    $eventArray['color'] = "#FF0000";
                    break;
                case '2':
                    //en cours => orange
                    $eventArray['color'] = "#FF8C00";
                    break;
                case '3':
                    //Fait => vert
                    $eventArray['color'] = "#339900";
                    break;
                default:
                    //autre (anciennes inter) => gris
                    $eventArray['color'] = "#808080";
                    break;
            }
            $materiels = array();
            if ($evenement['supp'] == 2) {
                $materiels[0] = $evenement['id_materiel'];
                $eventArray['url'] = "";
            } else {
                $materiels = getMatInter($evenement['id']);
                $eventArray['url'] = "javascript:affichage_popup1('edit_intervention.php?source=calendrier&id=" . $evenement['id'] . "','popup_1')";
            }
        }
        $lemateriel = array();
        //initialise tableau materiels inter
        foreach ($materiels as $materiel) {
            $lemateriel[] = utf8_encode(trim(getNomMat($materiel)));
        }
        //recupere description
        $eventArray['description'] = $description;
        //ajout materiels a description
        $eventArray['description'] .= "<u>Matériel lié</u> : " . implode(", ", $lemateriel);
        //ajoute ligne au tableau d'events
        $lesevents[] = $eventArray;
    }
    return $lesevents;
}