Démo de l'interface PHP xr-web
Thu 02 Sep 2010 21:13:01 CEST
Choix de la mesure
Moyenne attendue  Quart Horaire  Horaire  Journalière  Mensuelle  Annuelle
Date de début
Date de fin

Code du script

<?

$HomeDir = "/home/web_site/htdocs";//$HTTP_SERVER_VARS["DOCUMENT_ROOT"];
$HomeReskit = $_ResKitHome = $HomeDir."/reskit";
$URL_Reskit = "reskit";


require "$HomeReskit/html/html.inc.php";
require "$HomeReskit/html/htmlPage.inc.php";
require "$HomeReskit/html/htmlImage.inc.php";
require "$HomeReskit/html/htmlLayer.inc.php";
require "$HomeReskit/html/htmlCalendarBox.inc.php";
require "$HomeReskit/html/htmlText.inc.php";
require "$HomeReskit/locale/locale.inc.php";
require "$HomeReskit/database/database.inc.php";
//require "$HomeReskit/database/oracle.inc.php";
require "$HomeReskit/database/mysql.inc.php";
require "$HomeReskit/iseo/xr-web.inc.php";

$EtatStyle = array(
    'A'=>"{background-color:lightgreen;}",
    'R'=>"{background-color:darkgreen;}",
    'O'=>"{background-color:green;}",
    'Z'=>"{background-color:yellow;}",
    'D'=>"{background-color:red;color:white;}",
    'C'=>"{background-color:orange;}",
    'N'=>"{}",
    'W'=>"{background-color:purple;}",
    'P'=>"{background-color:blue;}",
);

//Fonction qui retourne un tableau contenant la liste des liens vers la documentation.
function & showDoc($root="doc", $title="Documentation", $url="") { // création du tableau $tab = new htmlTable("showDoc");
    $tab->setHeader();
    $tab->addOneRow(array($title));
    $tab->setTableFormatBorder(0);
    //$tab->setTableFormatWidth("100%");
    $tab->setTableFormatCellSpacing(0);
    $tab->SetHtmlProperty("style","{font-size:small}");
    $tab->SetHtmlProperty("align","center");
    
    //Ouverture d'un répertoire
    $d = dir($root);
    // recupération des nom de fichier
    while($entry=$d->read())
    {
        if (preg_match("/\\.html/i",$entry))
            $tab->addOneRow(array(new htmlLink(str_replace('.html','',$entry), concatpath(concatpath($url, $root), $entry), _blank)));
    }
    $tab->sortRows();
    return $tab;
}

$Page = new htmlPage("xr-web-demo");

$zone = new htmlZone();
$zone->addElement(strftime("%c"));

$XrWeb = new XRWEB("ADMIN_SLK", "x78q34c5b");
if (!$XrWeb->noError())
{
    echo "<p>Error :<br>".$XrWeb->getLastErrormessage()."</p>";
    exit;
}

//Object
// Préparation d'un formulaire qui demande le choix d'une mesure les dates de début et de fin des données et
// la moyenne attendues.
//à l'exécution du formulaire il ajjoute un tableu qui contient les données.
$stations = $XrWeb->getStations("");
for($i=0; $i<$stations->count(); $i++)
{
    $row = $stations->get($i); //lecture d'une ligne
    $lstStations[$row["NSIT"]]=chop($row["ISIT"]);
}
unset($stations);
$mesures = $XrWeb->getMesures();
for($i=0; $i<$mesures->count(); $i++)
{
    $row = $mesures->get($i); //lecture d'une ligne
    $key = $row["NRESSURV"]."|".$row["NSIT"]."|".$row["NOPOL"]."|".$row["CMET"];
    $lstMesures[$key]=array($lstStations[$row["NSIT"]]."(".$row["NSIT"]."-".$row["NOPOL"]."-".$row["CMET"].") : ".chop($row["NCON"])."(".chop($row["CCHIM"]).")", ($key==$_mesure?true:false));
}
//unset($mesures);
$form = & new htmlForm("question",$PHP_SELF, true, "Confirmez vous l'envoi de la demande ?", true,true);
$form->addItem(new htmlListBox("_mesure", 1, $lstMesures, false, "Choix de la mesure", false)); //Le choix de la mesure
if (!isset($_moyenne))
    $_moyenne=_XRWEB_Hour;
$form->addItem(new htmlRadioGroup(
    "_moyenne",
    array(
        array("Quart Horaire", _XRWEB_QuaterHour, (_XRWEB_QuaterHour==$_moyenne)),
        array("Horaire", _XRWEB_Hour, (_XRWEB_Hour==$_moyenne)),
        array("Journalière", _XRWEB_Day, (_XRWEB_Day==$_moyenne)),
        array("Mensuelle", _XRWEB_Month, (_XRWEB_Month==$_moyenne)),
        array("Annuelle", _XRWEB_Year, (_XRWEB_Year==$_moyenne)),
    ),
    "Moyenne attendue"
));

if (!isset($_bdate))
{
    //Envoi direct d'une requete sur la base de données
    $query = "SELECT date_format(max(DERNIER_QH),'%Y-%m-%d %H:%i') as BDATE from MESURE where nressurv=".$XrWeb->NRESSURV;
    $res = $XrWeb->DB->executeQuery($query);
    if ($res->count()==1)
    {
        $_edate = $res->getCol(0,"BDATE");
        $_bdate = strftime("%Y-%m-%d %H:%M", strtotime("-1 day", strtotime($_edate)));
    }
    else
        $res->out();
    unset($res);
}
$form->addItem(new htmlCalendarBox("_bdate", 15, $_bdate, "%Y-%m-%d %H:%M", true, false, "Date de début")); //Date de début
$form->addItem(new htmlCalendarBox("_edate", 15, $_edate, "%Y-%m-%d %H:%M", true, false, "Date de fin")); //Date de fin
$form->addItem(new htmlSubmitButton("ok","Envoi"));
$zone->addElement($form);

// Preparation des données
if (isset($_mesure))
{
    list($nres, $nsit, $nopol, $cmet) = explode("|", $_mesure);
    //$XrWeb->Debug=1;
    $data = $XrWeb->getData($_moyenne, strtotime($_bdate), strtotime($_edate), array(array("NSIT"=>$nsit, "NOPOL"=>$nopol, "CMET"=>$cmet)));
    $tabData = new htmlTable("data");
    $tabData->setTableFormatBorder(1);
    $tabData->setTableFormatCellSpacing(0);
    $tabData->setTableFormatCellpadding(1);
    $tabData->setHeader();
    $tabData->addOneRow(array(new htmlTableCell("Liste des données pour ".$lstMesures[$_mesure][0]."<br>du $_bdate au $_edate", "colspan=5")));
    $tabData->addOneRow(array(
        new htmlTableCell("Date", "", false, true),
        new htmlTableCell("Valeur", "", false, true),
        new htmlTableCell("Unitée", "", false, true),
        new htmlTableCell("Etat", "", false, true),
        new htmlTableCell("Valide", "", false, true),
    ));
    for($i=0; $i<$data->count(); $i++)
    {
        $row = $data->get($i);
        $tabData->addOneRow(array(
            new htmlTableCell($row["BDATE"],"align=left"),
            new htmlTableCell(is_float($row["VALEUR"])?number_format($row["VALEUR"],$row["FMUL"]):" ", "align=right style=".$EtatStyle[$row["ETAT"]]),
            new htmlTableCell(($row["UNITE"]==null?" ":$row["UNITE"]),"align=left"),
            new htmlTableCell(($row["ETAT"]==null?" ":$row["ETAT"]),"align=center"),
            new htmlTableCell(($row["VALID"]==null?" ":$row["VALID"]),"align=center"),
        ));
    }
    unset($data);
    $zone->addElement($tabData);
    //$zone->addElement($data);
}


//Ajout du code de la page...
$zone->addElement(new htmltext("@p@b@uCode du script@/u@/b@/p".addescape(join( '', file( $PATH_TRANSLATED ) ))));


//La page est un tableau avec a gauche les doc et à droite l'exemple
$table = & new htmlTable("table");
$table->setTableFormatBorder(0);
$table->setTableFormatWidth("100%");
$table->setHeader();
$table->addOneRow(array(new htmlTableCell("Démo de l'interface PHP xr-web", "colspan=2")));
$table->addOneRow(array(
    new htmlTableCell($zone,"width=90% valign=top align=left"),
    new htmlTableCell(showDoc("doc","Documentation Reskit"),"width=10% valign=top align=left"),
));
$Page->addElement($table);
//Sortie effective de la page
$Page->out();
?>

Documentation Reskit
database.inc.php
edi.inc.php
flash.inc.php
html.inc.php
html.mime.mail.inc.php
htmlAbout.inc.php
htmlApplet.inc.php
htmlBarGraph.inc.php
htmlCalendarBox.inc.php
htmlDefinition.inc.php
htmlFrame.inc.php
htmlFromFile.inc.php
htmlImage.inc.php
htmlLayer.inc.php
htmlList.inc.php
htmlMap.inc.php
htmlMenu.inc.php
htmlPage.inc.php
htmlSlide.inc.php
htmlText.inc.php
htmlTree.inc.php
htmlWindow.inc.php
imap.inc.php
language.inc.php
locale.inc.php
log.inc.php
mail.inc.php
mailsrv.inc.php
mimePart.inc.php
mysql.inc.php
oracle.inc.php
query.inc.php
remote.inc.php
smtp.inc.php
xr-web.inc.php