noalyss Version-9
ajax_forecast.php
Go to the documentation of this file.
1<?php
2/*
3* This file is part of NOALYSS.
4*
5* NOALYSS is free software; you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation; either version 2 of the License, or
8* (at your option) any later version.
9*
10* NOALYSS is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with NOALYSS; if not, write to the Free Software
17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@noalyss.eu
21
22if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
23
24require_once NOALYSS_INCLUDE . "/database/forecast_sql.class.php";
25
26if ($g_user->check_module("FORECAST")==0) die();
27
29$input = $http->request("input");
30$action = $http->request("ieaction", "string", "display");
31
32if ($action == "display") {
34 $f_id = $http->request("f_id", "number");
35
36 $ajax->set_callback("ajax_misc.php");
37 $ajax->add_json_param("op", "forecast");
38 $ajax->add_json_param("gDossier", Dossier::id());
39 $ajax->add_json_param("f_id", $f_id);
40 echo $ajax->ajax_input();
41}
42if ($action == "ok") {
43 $f_id = $http->request("f_id", "number");
45 $ajax->set_callback("ajax_misc.php");
46 $ajax->add_json_param("op", "forecast");
47 $ajax->add_json_param("gDossier", Dossier::id());
48 $ajax->add_json_param("f_id", $f_id);
49
50 $value = $http->request("value");
51 $ajax->set_value($value);
52 $input = $ajax->get_input();
53
54 $data_sql = new Forecast_SQL($cn, $f_id);
55 switch ($input->name) {
56 case 'f_name':
57 if ( trim($value)!="") {
58 $data_sql->setp($input->name, $value);
59 } else {
60 $value=$data_sql->getp('f_name');
61 $ajax->set_value($value);
62 }
63 break;
64 case 'p_start':
65 $data_sql->setp("f_start_date", $value);
66 break;
67 case 'p_end':
68 $data_sql->setp("f_end_date", $value);
69 break;
70 }
71
72 $data_sql->update();
73 echo $ajax->value();
74}
75if ($action == "cancel") {
77 $f_id = $http->request("f_id", "number");
78
79 $ajax->set_callback("ajax_misc.php");
80 $ajax->add_json_param("op", "forecast");
81 $ajax->add_json_param("gDossier", Dossier::id());
82 $f_id = $http->request("f_id", "number");
83 $ajax->add_json_param("f_id", $f_id);
84
85 echo $ajax->value();
86}
global $g_user
if no group available , then stop
$input
$http
$action
static id()
return the 'gDossier' value after a check
ORM abstract of the table public.forecast.
manage the http input (get , post, request) and extract from an array
static build($p_serialize)
build a Inplace_Edit object from a serialized string (ajax json parameter = input)
$ajax
Definition: popup.php:124