Author: danydb Date: 2011-11-15 11:41:26 +0100 (Tue, 15 Nov 2011) New Revision: 4353
Added: phpcompta/trunk/html/ajax_todo_list.php Removed: phpcompta/trunk/html/todo_list.php Modified: phpcompta/trunk/html/js/todo_list.js phpcompta/trunk/html/show_document.php phpcompta/trunk/include/class_calendar.php phpcompta/trunk/include/class_database.php phpcompta/trunk/include/class_todo_list.php phpcompta/trunk/include/constant.security.php phpcompta/trunk/include/template/security_list_action.php phpcompta/trunk/sql/upgrade.sql Log: #450 s?\195?\169curit?\195?\169 ajax : ajout d'action code cleaning : renommage de fichier pour ajax Copied: phpcompta/trunk/html/ajax_todo_list.php (from rev 4352, phpcompta/trunk/html/todo_list.php) =================================================================== --- phpcompta/trunk/html/ajax_todo_list.php (rev 0) +++ phpcompta/trunk/html/ajax_todo_list.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -0,0 +1,66 @@ +<?php +/* + * This file is part of PhpCompta. + * + * PhpCompta 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. + * + * PhpCompta 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 PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder [email protected] + +/*!\file + * \brief handle the ajax request for the todo_list (delete, update + * and insert) + * for add, needed parameters + * - gDossier + * - d date, + * - t title + * - de description + * for update, same as ADD + + * - i id + * for delete + * - gDossier + * - i id + */ +require_once ('class_dossier.php'); +require_once ('class_todo_list.php'); +require_once ('class_database.php'); + +$cn=new Database($gDossier); +$user=new User($cn); +$user->check(true); +$user->check_dossier($gDossier,true); +ajax_disconnected('add_todo_list'); + +if (isset($_REQUEST['show'])) +{ + $cn=new Database(dossier::id()); + $todo=new Todo_list($cn); + $todo->set_parameter('id',$_REQUEST['id']); + $todo->load(); + header('Content-type: text/xml; charset=UTF-8'); + header ('<?xml version="1.0" encoding="UTF-8"?>'); + echo $todo->toXML(); + exit(); +} + +if (isset($_REQUEST['del'])) +{ + $cn=new Database(dossier::id()); + $todo=new Todo_list($cn); + $todo->set_parameter('id',$_REQUEST['id']); + $todo->delete(); + exit(); +} Modified: phpcompta/trunk/html/js/todo_list.js =================================================================== --- phpcompta/trunk/html/js/todo_list.js 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/html/js/todo_list.js 2011-11-15 10:41:26 UTC (rev 4353) @@ -34,7 +34,7 @@ try { var action=new Ajax.Request( - 'todo_list.php', + 'ajax_todo_list.php', { method:'get', parameters: @@ -107,7 +107,7 @@ var gDossier=$('gDossier').value; var action=new Ajax.Request( - 'todo_list.php', + 'ajax_todo_list.php', { method:'get', parameters: Modified: phpcompta/trunk/html/show_document.php =================================================================== --- phpcompta/trunk/html/show_document.php 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/html/show_document.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -39,16 +39,22 @@ /* Show the document */ if ( $action == 'sh') { - // retrieve the document - $doc=new Document($cn,$_REQUEST['d_id']); - $doc->Send(); + if ( $User->check_action(VIEWDOC)==1) + { + // retrieve the document + $doc=new Document($cn,$_REQUEST['d_id']); + $doc->Send(); + } } /* remove the document */ if ( $action == 'rm' ) { - $doc=new Document($cn,$_REQUEST['d_id']); - $doc->remove(); - $json=sprintf('{"d_id":"%s"}',$_REQUEST['d_id']); - header("Content-type: text/html; charset: utf8",true); - print $json; + if ($User->check_action(RMDOC)==1) + { + $doc=new Document($cn,$_REQUEST['d_id']); + $doc->remove(); + $json=sprintf('{"d_id":"%s"}',$_REQUEST['d_id']); + header("Content-type: text/html; charset: utf8",true); + print $json; + } } Deleted: phpcompta/trunk/html/todo_list.php =================================================================== --- phpcompta/trunk/html/todo_list.php 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/html/todo_list.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -1,61 +0,0 @@ -<?php -/* - * This file is part of PhpCompta. - * - * PhpCompta 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. - * - * PhpCompta 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 PhpCompta; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* $Revision$ */ - -// Copyright Author Dany De Bontridder [email protected] - -/*!\file - * \brief handle the ajax request for the todo_list (delete, update - * and insert) - * for add, needed parameters - * - gDossier - * - d date, - * - t title - * - de description - * for update, same as ADD + - * - i id - * for delete - * - gDossier - * - i id - */ -require_once ('class_dossier.php'); -require_once ('class_todo_list.php'); -require_once ('class_database.php'); - -/*!\todo needs security for the users */ -if (isset($_REQUEST['show'])) -{ - $cn=new Database(dossier::id()); - $todo=new Todo_list($cn); - $todo->set_parameter('id',$_REQUEST['id']); - $todo->load(); - header('Content-type: text/xml; charset=UTF-8'); - header ('<?xml version="1.0" encoding="UTF-8"?>'); - echo $todo->toXML(); - exit(); -} -/*!\todo needs security for the users */ -if (isset($_REQUEST['del'])) -{ - $cn=new Database(dossier::id()); - $todo=new Todo_list($cn); - $todo->set_parameter('id',$_REQUEST['id']); - $todo->delete(); - exit(); -} Modified: phpcompta/trunk/include/class_calendar.php =================================================================== --- phpcompta/trunk/include/class_calendar.php 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/include/class_calendar.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -135,9 +135,21 @@ function get_preference() { $cn=new Database(dossier::id()); - $user=new User($cn); - $this->default_periode=$user->get_periode(); - return $this->default_periode; + $today=date('d.m.Y'); + $p_id=$cn->get_value(" + select p_id from parm_periode + where + p_start <= to_date($1,'DD.MM.YYYY') + and + p_end >= to_date($1,'DD.MM.YYYY')", + array($today)); + if ( $p_id == '') + { + $user=new User($cn); + $this->default_periode=$user->get_periode(); + $p_id=$this->default_periode; + } + return $p_id; } /** *@brief set the periode to the parameter, change the value of $this->default_periode Modified: phpcompta/trunk/include/class_database.php =================================================================== --- phpcompta/trunk/include/class_database.php 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/include/class_database.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -160,8 +160,8 @@ print_r($p_array); echo $a->getMessage(); echo $a->getTrace(); - echo $a->getTraceAsString(); - echo pg_last_error($this->db); + echo $a->getTraceAsString(); + echo pg_last_error($this->db); } throw ($a); } Modified: phpcompta/trunk/include/class_todo_list.php =================================================================== --- phpcompta/trunk/include/class_todo_list.php 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/include/class_todo_list.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -198,11 +198,11 @@ { $sql="select tl_id,tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as tl_date - from todo_list where tl_id=$1"; + from todo_list where tl_id=$1 and use_login=$2"; $res=$this->cn->exec_sql( $sql, - array($this->tl_id) + array($this->tl_id,$_SESSION['g_user']) ); if ( Database::num_row($res) == 0 ) return; @@ -215,8 +215,8 @@ } public function delete() { - $sql="delete from todo_list where tl_id=$1"; - $res=$this->cn->exec_sql($sql,array($this->tl_id)); + $sql="delete from todo_list where tl_id=$1 and use_login=$2"; + $res=$this->cn->exec_sql($sql,array($this->tl_id,$_SESSION['g_user'])); } /** Modified: phpcompta/trunk/include/constant.security.php =================================================================== --- phpcompta/trunk/include/constant.security.php 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/include/constant.security.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -2,5 +2,7 @@ define ('FICADD',800); /* Ajout de fiche */ define ("FIC",805); //Création, modification et effacement de fiche define ("FICCAT",910); //création, modification et effacement de catégorie de fiche +define ('RMDOC',1020); // Effacement de document pour follow up +define ('VIEWDOC',1010); // Voir document pour follow up global $audit; $audit=true; ?> Modified: phpcompta/trunk/include/template/security_list_action.php =================================================================== --- phpcompta/trunk/include/template/security_list_action.php 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/include/template/security_list_action.php 2011-11-15 10:41:26 UTC (rev 4353) @@ -49,3 +49,6 @@ <?php $array=$cn->get_array("select ac_id, ac_description from action where ac_id >=$1 and ac_id <=$2 order by ac_id ", array(800,1000)); display_security_fieldset(_('Fiche'),$array,$sec_User); ?> + <?php $array=$cn->get_array("select ac_id, ac_description from action where ac_id >=$1 and ac_id <=$2 order by ac_id ", + array(1050,1100)); + display_security_fieldset(_('Suivi'),$array,$sec_User); ?> Modified: phpcompta/trunk/sql/upgrade.sql =================================================================== --- phpcompta/trunk/sql/upgrade.sql 2011-11-15 09:51:13 UTC (rev 4352) +++ phpcompta/trunk/sql/upgrade.sql 2011-11-15 10:41:26 UTC (rev 4353) @@ -6,7 +6,8 @@ drop table public.format_csv_banque; insert into parameter values ('MY_ALPHANUM','N'); delete from action where ac_id not in (800,805,910); - +insert into action (ac_id,ac_description, ac_module, ac_code) values(1020,'Effacer les documents du suivi','followup','RMDOC'); +insert into action (ac_id,ac_description, ac_module, ac_code) values(1010,'Voir les documents du suivi','followup','VIEWDOC'); /* script SQL to run */ _______________________________________________ Phpcompta-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/phpcompta-dev
