noalyss Version-9
ajax_gestion.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 2015 Author Dany De Bontridder danydb@aevalys.eu
22/**
23 * @file
24 * @brief display a box containing last actions
25 */
26if (!defined('ALLOWED'))
27 die('Appel direct ne sont pas permis');
28
30
31if ($op=='action_show')
32{
33 /**
34 * display action
35 */
36 $gestion=new Follow_Up($cn);
37 $array=$gestion->get_last(35);
38 $len_array=count($array);
39 require_once NOALYSS_TEMPLATE.'/action_show.php';
40 return;
41}
42if ($op=='action_add')
43{
44 $gestion=new Follow_Up($cn);
45 $gestion->display_short();
46 return;
47}
48if ($op=='action_save')
49{
50
51 /**
52 * save info from the get
53 */
54 try
55 {
56 $date_event=$http->get("date_event","string","");
57 $dest=$http->get("dest","string", "");
58 $event_group=$http->get("event_group", "string",0);
59 $event_priority=$http->get("event_priority", "string",0);
60 $title=$http->get("title_event","string", NULL);
61 $summary=$http->get("summary","string", "");
62 $type_event=$http->get('type_event', "string",-1);
63 $hour_event=$http->get('hour_event', "string",null);
64 if ($date_event==-1||isDate($date_event)==0)
65 throw new Exception(_('Date invalide'));
66 if (trim($dest)=="")
67 $dest_id=NULL;
68 else
69 {
70 $fiche=new Fiche($cn);
71 $fiche->get_by_qcode($dest);
72 $dest_id=$fiche->id;
73 if ($dest_id==0)
74 throw new Exception(_('Destinataire invalide'));
75 }
76 if ($type_event==-1)
77 throw new Exception(_('Type invalide'));
78 if (trim($title)=="")
79 throw new Exception(_('Aucun titre'));
80 }
81 catch (Exception $ex)
82 {
83 record_log($ex->getTraceAsString());
84 header('Content-type: text/xml; charset=UTF-8');
85 $dom=new DOMDocument('1.0', 'UTF-8');
86 $xml_content=$dom->createElement('content', $ex->getMessage());
87 $xml_status=$dom->createElement('status', "NOK");
88 $root=$dom->createElement("root");
89 $root->appendChild($xml_content);
90 $root->appendChild($xml_status);
91 $dom->appendChild($root);
92 echo $dom->saveXML();
93 return;
94 }
95 /*
96 * Save data
97 */
98 $gestion=new Follow_Up($cn);
99 $gestion->ag_priority=$event_priority;
100 $gestion->ag_title=$title;
101 $gestion->ag_dest=$event_group;
102 $gestion->ag_type=$type_event;
103 $gestion->f_id_dest=$dest_id;
104 $gestion->ag_state=3;
105 $gestion->dt_id=$type_event;
106 $gestion->ag_comment=h($summary);
107 $gestion->ag_timestamp=$date_event;
108 $gestion->ag_remind_date=$date_event;
109 $gestion->ag_hour=$hour_event;
110 $content=_('Sauvé');
111 $status='OK';
112 try {
113 $gestion->save_short();
114 } catch (Exception $ex)
115 {
116 record_log($ex->getTraceAsString());
117 $content=$ex->getMessage();
118 $status='NOK';
119 }
120 header('Content-type: text/xml; charset=UTF-8');
121 $dom=new DOMDocument('1.0', 'UTF-8');
122 $xml_content=$dom->createElement('content', $content);
123 $xml_status=$dom->createElement('status', $status);
124 $root=$dom->createElement("root");
125 $root->appendChild($xml_content);
126 $root->appendChild($xml_status);
127 $dom->appendChild($root);
128 echo $dom->saveXML();
129 return;
130}
isDate($p_date)
Definition: ac_common.php:236
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
$op
Definition: ajax_admin.php:38
h( $row[ 'oa_description'])
$http
$ex
Definition: balance.inc.php:45
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
manage the http input (get , post, request) and extract from an array
$dom
Definition: xml.php:15
$content
Definition: xml.php:17