noalyss  Version-7
 All Data Structures Namespaces Files Functions Variables Pages
ajax_mod_periode.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * NOALYSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with NOALYSS; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 // Copyright Author Dany De Bontridder danydb@aevalys.eu
22 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
23 require_once NOALYSS_INCLUDE.'/class/periode.class.php';
24 
25 /**\file
26  * \brief display or save a periode
27  * variable received $op, $cn $g_user
28  */
29 $err = 0;
30 $html = '';
31 /* we check the security */
32 switch ($op)
33 {
34  case 'input_per':
35  $per = new Periode($cn, $_GET['p_id']);
36  $per->load();
37  $limit = $per->get_date_limit($_GET['p_id']);
38 
39  $p_start = new IDate('p_start');
40  $p_start->value = $limit['p_start'];
41  $p_end = new IDate('p_end');
42  $p_end->value = $limit['p_end'];
43  $p_exercice = new INum('p_exercice');
44  $p_exercice->value = $per->p_exercice;
45 
46  $html = '';
47  $html.=HtmlInput::anchor_close('mod_periode');
48  $html.=h2info(_('Modification période'));
49  $html.='<p> '._('Modifier les dates de début et fin de période').'</p>';
50  $html.='<p class="notice">'._('Cela pourrait avoir un impact sur les opérations déjà existantes').'</p>';
51  $html.='<form method="post" onsubmit="return save_periode(this)">';
52  $html.=dossier::hidden();
53  $html.='<table>';
54 
55  $html.=tr(td(_(' Début période : ')) . td($p_start->input()));
56  $html.=tr(td(_(' Fin période : ')) . td($p_end->input()));
57  $html.=tr(td(_(' Exercice : ')) . td($p_exercice->input()));
58  $html.='</table>';
59  $html.=HtmlInput::submit('sauver', _('sauver'));
60  $html.=HtmlInput::button('close', _('fermer'), 'onclick="removeDiv(\'mod_periode\')"');
61  $html.=HtmlInput::hidden('p_id', $_GET['p_id']);
62  $html.='</form>';
63  break;
64  case 'save_per':
65  $per = new Periode($cn, $_POST['p_id']);
66  $per->load();
67  if (isDate($_POST['p_start']) == null ||
68  isDate($_POST['p_end'] == null) ||
69  isNumber($_POST['p_exercice']) == 0 ||
70  $_POST['p_exercice'] > 2099 ||
71  $_POST['p_exercice'] < 2000)
72  {
73  $html = '';
74  $html.=HtmlInput::anchor_close('mod_periode');
75  $html.='<h2 class="info">'._('Modifier les dates de début et fin de période').'</h2>';
76  $html.="<div class=\"error\">"._('Erreur date invalide')."</div>";
77 
78  $html.=HtmlInput::button('close', _('fermer'), 'onclick="removeDiv(\'mod_periode\')"');
79  }
80  else
81  {
82  $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";
83  try
84  {
85  $cn->exec_sql($sql, array($_POST['p_start'], $_POST['p_end'], $_POST['p_exercice'], $_POST['p_id']));
86  $html = '<h2 class="info"> Modifier les dates de début et fin de période</h2>';
87  $html.='<h2 class="notice"> Sauvé </h2>';
88 
89  $html.=HtmlInput::button('close', _('Fermer'), 'onclick=" refresh_window();"');
90  }
91  catch (Exception $e)
92  {
93  record_log($e->getTraceAsString());
94  $html = alert($e->getTrace(), true);
95  }
96  }
97  break;
98 }
99 
101 header('Content-type: text/xml; charset=UTF-8');
102 echo '<?xml version="1.0" encoding="UTF-8"?>';
103 echo '<xml>';
104 echo '<data>' . $html . '</data>';
105 echo '</xml>';
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:667
$_GET['qcode']
$_POST['ac']
Definition: do.php:316
if($g_user->check_dossier(dossier::id(), true)=='X') $op
Definition: ajax_ledger.php:96
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
var Periode
Definition: scripts.js:3054
static anchor_close($div, $p_js="")
Return a html string with an anchor which close the inside popup.
h2info($p_string)
Definition: ac_common.php:63
$p_end
isNumber(&$p_int)
Definition: ac_common.php:202
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
$p_start
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character...
isDate($p_date)
Definition: ac_common.php:223
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1296
tr($p_string, $p_extra='')
Definition: ac_common.php:88
$limit
Definition: dashboard.php:157
static hidden($p_name, $p_value, $p_id="")
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:33
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:40