Subversion Repositories portal2

Rev

Rev 707 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*  emg - Energy Monitoring & Graphing
*  Copyright (C) 2006-2012 Romain Lievin
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

?>

<?php
include_once('auth_check.php');
?>

<?php

/* We will need JavaScript to get control values and store them thru session mechanism so
to avoid resetting of fields when adding/removing groups
*/


$form_token = md5(uniqid('auth', true));
$_SESSION['form_token_2'] = $form_token;

if(isset($_GET['form_datum_key']))
{
        $form_datum_key = $_GET['form_datum_key'];
        unset($_SESSION['form_datum_key']);
}
else
{
        $data           = $_SESSION['data'];
        $data_keys      = $data->getKeys();
        $form_datum_key = $data_keys[0];
}

if(isset($_GET['form_datum_type']))
{
        $form_datum_type = $_GET['form_datum_type'];
        unset($_GET['form_datum_type']);
}
else
{
        $form_datum_type = DatumFactory::SUM;
}

if(isset($_GET['form_external_name']))
{
        $form_external_name = $_GET['form_external_name'];
        unset($_GET['form_external_name']);
}
else
{
        $data               = $_SESSION['data'];
        $data_names         = $data->getKeys();
        $form_external_name = $data_names[0];
}
?>

<div id="page_form_data_add">
        <h1>
                <?php echo _('Add data'); ?>
        </h1>

        <?php

        $id = link_get_id_from_filename("form_data_add_submit.php");
        echo "<form action=\"index.php?id_page=$id\" method=\"post\">";

        $form_datum_name = isset($_POST['form_datum_name']) ? $_POST['form_datum_name'] : "Maison Electricite";
        ?>
        <fieldset>
                <legend>
                        <?php echo _('Information'); ?>
                </legend>

                <label for="form_datum_name">
                        <?php echo _('Name'); ?>:
                </label>
                <input type="text" id="form_datum_name" name="form_datum_name" value=<?php echo "\"$form_datum_name\""; ?> placeholder="Ma sonde" />
                <br/>

                <label for="form_datum_unit">
                        <?php echo _('Unit'); ?>:
                </label>
                <input type="text" id="form_datum_unit" name="form_datum_unit" value="" />
                <br/>

                <label for="form_datum_a">
                        <?php echo _('Step'); ?>:
                </label>
                <input type="text" id="form_datum_a" name="form_datum_a" value="1.0" />
                <br/>

                <label for="form_datum_b">
                        <?php echo _('Offset'); ?>:
                </label>
                <input type="text" id="form_datum_b" name="form_datum_b" value="0" />
                <br/>

                <label for="form_datum_type">
                        <?php echo _('Type'); ?>:
                </label>
                <select name="form_datum_type" id="form_datum_type">
                        ;
                        <?php
                        $array = Datumfactory::getListOfTypes();
                        foreach($array as $key => $elt)
                        {
                                if($key == DatumFactory::SINGLE || $key == DatumFactory::CUSTOM)
                                {
                                        continue;
                                }
                               
                                echo "  <option label=\"$key\" value=\"$key\" $selected > $elt </option>\n";
                        }
                        ?>
                </select>
                <br/>

                <hr/>
                <div class="buttons">
                        <input type="hidden" name="form_token_2" value="<?php echo $form_token; ?>" />
                        <input type="hidden" name="form_data" value="none" />
                        <input type="submit" value=<?php echo _('OK');?> id="form_add" alt="add" />
                        <input type="submit" value=<?php echo _('Cancel');?> id="data_cancel" name="form_cancel" alt="cancel" />
                </div>

        </fieldset>

        <?php
        if(isset($_SESSION['message']))
        echo $_SESSION['message'];
        ?>

        </form>
</div>

<p>
        <?php include_once('form_groups_list.php'); ?>
</p>