noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
ajax_mod_periode.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00023 require_once('class_periode.php');
00024 
00025 /**\file
00026  * \brief display or save a periode
00027  * variable received $op, $cn $g_user
00028  */
00029 $err = 0;
00030 $html = '';
00031 /* we check the security */
00032 switch ($op)
00033 {
00034     case 'input_per':
00035         $per = new Periode($cn, $_GET['p_id']);
00036         $per->load();
00037         $limit = $per->get_date_limit($_GET['p_id']);
00038 
00039         $p_start = new IDate('p_start');
00040         $p_start->value = $limit['p_start'];
00041         $p_end = new IDate('p_end');
00042         $p_end->value = $limit['p_end'];
00043         $p_exercice = new INum('p_exercice');
00044         $p_exercice->value = $per->p_exercice;
00045 
00046         $html = '';
00047         $html.=HtmlInput::anchor_close('mod_periode');
00048         $html.=h2info('Modification période');
00049         $html.='<p> Modifier les dates de début et fin de période</p>';
00050         $html.='<p class="notice">Cela pourrait avoir un impact sur les opérations déjà existantes</p>';
00051         $html.='<form method="post" onsubmit="return save_periode(this)">';
00052         $html.=dossier::hidden();
00053         $html.='<table>';
00054 
00055         $html.=tr(td(' Début période : ') . td($p_start->input()));
00056         $html.=tr(td(' Fin période : ') . td($p_end->input()));
00057         $html.=tr(td(' Exercice : ') . td($p_exercice->input()));
00058         $html.='</table>';
00059         $html.=HtmlInput::submit('sauver', 'sauver');
00060         $html.=HtmlInput::button('close', 'Fermer', 'onclick="removeDiv(\'mod_periode\')"');
00061         $html.=HtmlInput::hidden('p_id', $_GET['p_id']);
00062         $html.='</form>';
00063         break;
00064     case 'save_per':
00065         $per = new Periode($cn, $_POST['p_id']);
00066         $per->load();
00067         if (isDate($_POST['p_start']) == null ||
00068                 isDate($_POST['p_end'] == null) ||
00069                 isNumber($_POST['p_exercice']) == 0 ||
00070                 $_POST['p_exercice'] > 2099 ||
00071                 $_POST['p_exercice'] < 2000)
00072         {
00073             $html = '';
00074             $html.=HtmlInput::anchor_close('mod_periode');
00075             $html.='<h2 class="info"> Modifier les dates de début et fin de période</h2>';
00076             $html.="<div class=\"error\">Erreur date invalide</div>";
00077 
00078             $html.=HtmlInput::button('close', 'Fermer', 'onclick="removeDiv(\'mod_periode\')"');
00079         }
00080         else
00081         {
00082             $sql = "update parm_periode set p_start=to_date($1,'DD.MM.YYYY'),p_end=to_date($2,'DD.MM.YYYY'),p_exercice=$3 where p_id=$4";
00083             try
00084             {
00085                 $cn->exec_sql($sql, array($_POST['p_start'], $_POST['p_end'], $_POST['p_exercice'], $_POST['p_id']));
00086                 $html = '<h2 class="info"> Modifier les dates de début et fin de période</h2>';
00087                 $html.='<h2 class="notice"> Sauvé </h2>';
00088 
00089                 $html.=HtmlInput::button('close', 'Fermer', 'onclick="  refresh_window();"');
00090             }
00091             catch (Exception $e)
00092             {
00093                 $html = alert($e->getTrace(), true);
00094             }
00095         }
00096         break;
00097 }
00098 
00099 $html = escape_xml($html);
00100 header('Content-type: text/xml; charset=UTF-8');
00101 echo '<?xml version="1.0" encoding="UTF-8"?>';
00102 echo '<xml>';
00103 echo '<data>' . $html . '</data>';
00104 echo '</xml>';
 All Data Structures Namespaces Files Functions Variables Enumerations