Task #1127 - Ajout évenement depuis tableau de bord ou agenda
Change url for wiki
This commit is contained in:
parent
a2c80a22b4
commit
13ac01afec
11 changed files with 375 additions and 8 deletions
|
|
@ -724,6 +724,14 @@ EOF;
|
|||
case 'action_show':
|
||||
require_once NOALYSS_INCLUDE.'/ajax_gestion.php';
|
||||
break;
|
||||
// From dashboard, display form for a new event
|
||||
case 'action_add':
|
||||
require_once NOALYSS_INCLUDE.'/ajax_gestion.php';
|
||||
break;
|
||||
// Save a event given in the short form
|
||||
case 'action_save':
|
||||
require_once NOALYSS_INCLUDE.'/ajax_gestion.php';
|
||||
break;
|
||||
default:
|
||||
var_dump($_GET);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ function action_show(p_dossier)
|
|||
parameters : {gDossier:p_dossier,'op':'action_show'},
|
||||
onSuccess : function(p_xml, p_text) {
|
||||
remove_waiting_box();
|
||||
add_div({id: 'action_list_div', style:"top:1%;width:90%;margin-left:5%" , cssclass: 'inner_box'});
|
||||
add_div({id: 'action_list_div', style:"top:1%;width:90%;left:5%" , cssclass: 'inner_box'});
|
||||
$('action_list_div').innerHTML=p_xml.responseText;
|
||||
}
|
||||
});
|
||||
|
|
@ -288,4 +288,98 @@ function action_show(p_dossier)
|
|||
{
|
||||
alert('action_show '+e.message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief add a new event
|
||||
* @param {type} p_dossier
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function action_add(p_dossier) {
|
||||
try {
|
||||
if ( $('action_add_div')) {
|
||||
alert('Désolé, événement en cours de création à sauver');
|
||||
return;
|
||||
}
|
||||
waiting_box();
|
||||
var action = new Ajax.Request('ajax_misc.php',
|
||||
{
|
||||
method:'get',
|
||||
parameters : {gDossier:p_dossier,'op':'action_add'},
|
||||
onSuccess : function(p_xml, p_text) {
|
||||
remove_waiting_box();
|
||||
add_div({id: 'action_add_div',
|
||||
style:"top:1%;width:80%;left:10%" ,
|
||||
cssclass: 'inner_box'});
|
||||
$('action_add_div').innerHTML=p_xml.responseText;
|
||||
p_xml.responseText.evalScripts();
|
||||
}
|
||||
});
|
||||
} catch (e)
|
||||
{
|
||||
alert('action_add '+e.message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief The new event is entered into the div action_add_div, we try
|
||||
* to save and receive as answer a XML file with a code of success and possibly
|
||||
* a message
|
||||
* If the message is OK then the div is fading out, otherwise the reason of
|
||||
* failure is shown and the div remains
|
||||
*/
|
||||
function action_save_short()
|
||||
{
|
||||
try {
|
||||
$('action_add_frm_info').innerHTML="";
|
||||
$('action_add_frm')['date_event_action_short'].parentNode.className="";
|
||||
$('action_add_frm')['title_event'].parentNode.className="";
|
||||
$('action_add_frm')['type_event'].parentNode.className="";
|
||||
|
||||
if ( $('action_add_frm')['date_event_action_short'].value.trim() == '') {
|
||||
$('action_add_frm')['date_event_action_short'].parentNode.className="notice";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $('action_add_frm')['title_event'].value.trim()=="") {
|
||||
$('action_add_frm')['title_event'].parentNode.className="notice";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $('action_add_frm')['type_event'].options[$('action_add_frm')['type_event'].selectedIndex].value == -1 )
|
||||
{
|
||||
$('action_add_frm')['type_event'].parentNode.className="notice";
|
||||
return false;
|
||||
}
|
||||
var form=$('action_add_frm').serialize();
|
||||
waiting_box();
|
||||
var action = new Ajax.Request('ajax_misc.php',
|
||||
{
|
||||
method: 'get',
|
||||
parameters: form,
|
||||
onSuccess: function (p_xml, p_text) {
|
||||
remove_waiting_box();
|
||||
var answer=p_xml.responseXML;
|
||||
var code_tags=answer.getElementsByTagName('status');
|
||||
var code=getNodeText(code_tags[0]);
|
||||
var message_tags=answer.getElementsByTagName('content');
|
||||
var message=getNodeText(message_tags[0]);
|
||||
|
||||
if ( code == 'OK') {
|
||||
// Successfully saved
|
||||
$('action_add_frm_info').innerHTML=message;
|
||||
$('action_add_div').remove();
|
||||
|
||||
}
|
||||
else if (code == 'NOK') {
|
||||
// issue while saving
|
||||
$('action_add_frm_info').innerHTML=message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
} catch (e)
|
||||
{
|
||||
alert('action_add ' + e.message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
|
|
@ -15,17 +16,18 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*/
|
||||
|
||||
// Copyright 2015 Author Dany De Bontridder danydb@aevalys.eu
|
||||
/**
|
||||
* @file
|
||||
* @brief display a box containing last actions
|
||||
*/
|
||||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
if ( $op == 'action_show')
|
||||
if (!defined('ALLOWED'))
|
||||
die('Appel direct ne sont pas permis');
|
||||
if ($op=='action_show')
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* display action
|
||||
*/
|
||||
require_once NOALYSS_INCLUDE.'/class_follow_up.php';
|
||||
|
|
@ -33,4 +35,86 @@ if ( $op == 'action_show')
|
|||
$array=$gestion->get_last(25);
|
||||
$len_array=count($array);
|
||||
require_once NOALYSS_INCLUDE.'/template/action_show.php';
|
||||
return;
|
||||
}
|
||||
if ($op=='action_add')
|
||||
{
|
||||
require_once NOALYSS_INCLUDE.'/class_follow_up.php';
|
||||
$gestion=new Follow_Up($cn);
|
||||
$gestion->display_short();
|
||||
return;
|
||||
}
|
||||
if ($op=='action_save')
|
||||
{
|
||||
require_once NOALYSS_INCLUDE.'/class_follow_up.php';
|
||||
|
||||
/**
|
||||
* save info from the get
|
||||
*/
|
||||
$date_event=HtmlInput::default_value_get("date_event", -1);
|
||||
$dest=HtmlInput::default_value_get("dest", "");
|
||||
$event_group=HtmlInput::default_value_get("event_group", 0);
|
||||
$event_priority=HtmlInput::default_value_get("event_priority", 0);
|
||||
$title=HtmlInput::default_value_get("title_event", NULL);
|
||||
$summary=HtmlInput::default_value_get("summary", "");
|
||||
$type_event=HtmlInput::default_value_get('type_event', -1);
|
||||
/*
|
||||
* Check if data are valid
|
||||
*/
|
||||
try
|
||||
{
|
||||
if ($date_event==-1||isDate($date_event)==0)
|
||||
throw new Exception(_('Date invalide'));
|
||||
if (trim($dest)=="")
|
||||
$dest_id=NULL;
|
||||
else
|
||||
{
|
||||
$fiche=new Fiche($cn);
|
||||
$fiche->get_by_qcode($dest);
|
||||
$dest_id=$fiche->id;
|
||||
if ($dest_id==0)
|
||||
throw new Exception(_('Destinataire invalide'));
|
||||
}
|
||||
if ($type_event==-1)
|
||||
throw new Exception(_('Type invalide'));
|
||||
if (trim($title)=="")
|
||||
throw new Exception(_('Aucun titre'));
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
$dom=new DOMDocument('1.0', 'UTF-8');
|
||||
$xml_content=$dom->createElement('content', $ex->getMessage());
|
||||
$xml_status=$dom->createElement('status', "NOK");
|
||||
$root=$dom->createElement("root");
|
||||
$root->appendChild($xml_content);
|
||||
$root->appendChild($xml_status);
|
||||
$dom->appendChild($root);
|
||||
echo $dom->saveXML();
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Save data
|
||||
*/
|
||||
$gestion=new Follow_Up($cn);
|
||||
$gestion->ag_priority=$event_priority;
|
||||
$gestion->ag_title=$title;
|
||||
$gestion->ag_dest=$event_group;
|
||||
$gestion->ag_type=$type_event;
|
||||
$gestion->f_id_dest=$dest_id;
|
||||
$gestion->ag_state=3;
|
||||
$gestion->dt_id=$type_event;
|
||||
$gestion->ag_comment=h($summary);
|
||||
$gestion->ag_timestamp=$date_event;
|
||||
$gestion->save_short();
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
$dom=new DOMDocument('1.0', 'UTF-8');
|
||||
$xml_content=$dom->createElement('content', _("Sauvé"));
|
||||
$xml_status=$dom->createElement('status', "OK");
|
||||
$root=$dom->createElement("root");
|
||||
$root->appendChild($xml_content);
|
||||
$root->appendChild($xml_status);
|
||||
$dom->appendChild($root);
|
||||
echo $dom->saveXML();
|
||||
return;
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ if ($profile->p_id > 0)
|
|||
echo $add_impression;
|
||||
echo '</div>';
|
||||
echo '<div class="myfieldset" style="display:none" id="profile_gestion_div">';
|
||||
echo "<h1 class=\"legend\">".('Action gestion accessible')."</h1>";
|
||||
echo "<h1 class=\"legend\">".('Groupe gestion')."</h1>";
|
||||
$profile_menu->available_profile($p_id);
|
||||
echo '</div>';
|
||||
echo '<div class="myfieldset" style="display:none" id="profile_repo_div">';
|
||||
|
|
|
|||
|
|
@ -1755,5 +1755,64 @@ class Follow_Up
|
|||
echo ' ';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief display a small form to enter a new event
|
||||
*
|
||||
*/
|
||||
function display_short()
|
||||
{
|
||||
$cn=$this->db;
|
||||
include 'template/action_display_short.php';
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function save_short()
|
||||
{
|
||||
// Get The sequence id,
|
||||
$seq_name="seq_doc_type_".$this->dt_id;
|
||||
$str_file="";
|
||||
$add_file='';
|
||||
|
||||
|
||||
$this->ag_id=$this->db->get_next_seq('action_gestion_ag_id_seq');
|
||||
|
||||
// Create the reference
|
||||
$ag_ref=$this->db->get_value('select dt_prefix from document_type '
|
||||
. 'where dt_id=$1', array($this->dt_id))
|
||||
.'-'.$this->db->get_next_seq($seq_name);
|
||||
|
||||
$this->ag_ref=$ag_ref;
|
||||
/**
|
||||
* If ag_ref already exist then compute a new one
|
||||
*/
|
||||
|
||||
// save into the database
|
||||
$this->ag_remind_date=null;
|
||||
$sql="insert into action_gestion".
|
||||
"(ag_id,ag_timestamp,ag_type,ag_title,f_id_dest,ag_ref, ag_dest, ".
|
||||
" ag_priority,ag_owner,ag_state,ag_remind_date) ".
|
||||
" values ($1,to_date($2,'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9,$10,$11)";
|
||||
|
||||
$this->db->exec_sql($sql, array(
|
||||
$this->ag_id, /* 1 */
|
||||
$this->ag_timestamp, /* 2 */
|
||||
$this->dt_id, /* 3 */
|
||||
$this->ag_title, /* 4 */
|
||||
$this->f_id_dest, /* 5 */
|
||||
$ag_ref, /* 6 */
|
||||
$this->ag_dest, /* 7 */
|
||||
$this->ag_priority, /* 8 */
|
||||
$_SESSION['g_user'], /* 9 */
|
||||
$this->ag_state, /* 10 */
|
||||
$this->ag_remind_date /* 11 */
|
||||
)
|
||||
);
|
||||
|
||||
if (trim($this->ag_comment)!='')
|
||||
{
|
||||
$this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment) values ($1,$2,$3)"
|
||||
, array($this->ag_id, $_SESSION['g_user'], $this->ag_comment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -916,4 +916,10 @@ EOF;
|
|||
$js=HtmlInput::button_action(_('Ajout autres'), $javascript);
|
||||
return $js;
|
||||
}
|
||||
static function button_action_add()
|
||||
{
|
||||
$dossier=Dossier::id();
|
||||
$js=HtmlInput::button_action(_('Nouvel événement'),'action_add('.$dossier.')','xx','smallbutton');
|
||||
return $js;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
113
include/template/action_display_short.php
Normal file
113
include/template/action_display_short.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/*
|
||||
* * Copyright (C) 2015 Dany De Bontridder <dany@alchimerys.be>
|
||||
*
|
||||
* 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 2
|
||||
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief call from follow_up::display_short display a small form to
|
||||
* enter a new event
|
||||
*/
|
||||
global $g_user;
|
||||
// Date of the event
|
||||
$date=new IDate("date_event");
|
||||
$date->id="date_event_action_short";
|
||||
$title=new IText('title_event');
|
||||
|
||||
// Description
|
||||
$summary=new ITextarea('summary');
|
||||
$summary->style.='class="itextarea" style="padding:0px;margin:0px"';
|
||||
|
||||
// Type of document / event
|
||||
$type=new ISelect("type_event");
|
||||
$type->name="type_event";
|
||||
$type->value=$cn->make_array("select dt_id,dt_value from document_type order by dt_value", 1);
|
||||
$type->selected=0;
|
||||
|
||||
// Available for the profile
|
||||
$profile=new ISelect('event_group');
|
||||
$profile->value=$cn->make_array("select p_id as value, ".
|
||||
"p_name as label ".
|
||||
" from profile "
|
||||
. "where "
|
||||
. "p_id in "
|
||||
. " (select p_granted "
|
||||
. " from user_sec_action_profile "
|
||||
. " where ua_right='W' and p_id=".$g_user->get_profile().") "
|
||||
. "order by 2");
|
||||
|
||||
// priority
|
||||
$priority=new ISelect('event_priority');
|
||||
$priority->value=array(
|
||||
array('value'=>1, 'label'=>_('Haute')),
|
||||
array('value'=>2, 'label'=>_('Moyenne')),
|
||||
array('value'=>3, 'label'=>_('Basse'))
|
||||
);
|
||||
$priority->selected=2;
|
||||
|
||||
// Card
|
||||
$dest=new ICard('dest');
|
||||
$dest->jrn=0;
|
||||
$dest->name='dest';
|
||||
$dest->value="";
|
||||
$dest->label="";
|
||||
$list_recipient=$cn->make_list('select fd_id from fiche_def where frd_id in (14,25,8,9,16)');
|
||||
$dest->extra=$list_recipient;
|
||||
$dest->set_attribute('typecard', $list_recipient);
|
||||
$dest->set_dblclick("fill_ipopcard(this);");
|
||||
$dest->set_attribute('ipopup', 'ipopcard');
|
||||
$dest->style=' style="vertical-align:0%"';
|
||||
|
||||
echo HtmlInput::title_box(_('Nouvel événement'), 'action_add_div');
|
||||
?>
|
||||
<span class="notice" style="float:right" id="action_add_frm_info"></span>
|
||||
<form method="get" id="action_add_frm" onsubmit="action_save_short(<?php echo Dossier::id()?>);return false">
|
||||
<p>
|
||||
<span>
|
||||
Date<?php echo $date->input()?>
|
||||
</span>
|
||||
<span>
|
||||
Type évenement
|
||||
<?php echo $type->input();?>
|
||||
</span>
|
||||
Priorité
|
||||
<?php echo $priority->input()?>
|
||||
groupe
|
||||
<?php echo $profile->input()?>
|
||||
</p>
|
||||
Destinataire <?php echo $dest->input();?>
|
||||
<p>
|
||||
<span>
|
||||
<?php echo _('Sujet')?>
|
||||
<?php echo $title->input()?>
|
||||
</span>
|
||||
</p>
|
||||
<?php echo "Description"?>
|
||||
<p>
|
||||
<?php echo $summary->input()?>
|
||||
</p>
|
||||
<?php
|
||||
echo HtmlInput::hidden('gDossier',Dossier::id());
|
||||
echo HtmlInput::hidden('op','action_save');
|
||||
?>
|
||||
<p style="text-align: center">
|
||||
<?php echo HtmlInput::submit("action_add_submit", _('Valider'));?>
|
||||
</p>
|
||||
</form>
|
||||
|
|
@ -53,5 +53,5 @@ echo HtmlInput::title_box(_('Suivi'), 'action_list_div');
|
|||
?>
|
||||
</table>
|
||||
<p style="text-align: center">
|
||||
<a class="smallbutton" target="_blank" href="?gDossier=<?php echo Dossier::id()?>&ac=<?php echo $a_default->get('code_follow')?>"><?php echo _('Gestion')?></a>
|
||||
<?php echo HTMLInput::button_action_add()?>
|
||||
</p>
|
||||
|
|
@ -31,6 +31,8 @@
|
|||
$js=sprintf("calendar_zoom({gDossier:%d,invalue:'%s',outvalue:'%s',distype:'%s','notitle':%d})",
|
||||
dossier::id(),'per_div','calendar_zoom_div','cal',$notitle);
|
||||
echo HtmlInput::anchor(_('Calendrier'),''," onclick=\"{$js}\"") ;
|
||||
echo HtmlInput::button_action_add();
|
||||
|
||||
?>
|
||||
<table class="result">
|
||||
<?php
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
$js=sprintf("calendar_zoom({gDossier:%d,invalue:'%s',outvalue:'%s',distype:'%s','notitle':%d})",
|
||||
dossier::id(),'per_div','calendar_zoom_div','list',$notitle);
|
||||
echo HtmlInput::anchor(_('Liste'),''," onclick=\"{$js}\"") ;
|
||||
echo HtmlInput::button_action_add();
|
||||
?>
|
||||
|
||||
<?php if ($zoom == 1 ): ?>
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@
|
|||
</TR>
|
||||
<tr>
|
||||
<TD>
|
||||
<?php echo _('Destinataire')?>
|
||||
<?php echo _('Groupe Gestion')?>
|
||||
</TD>
|
||||
<td>
|
||||
<?php echo $str_ag_dest;?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue