From 1520e1075ff66b9ade4f00ddcc73115fe9c7da4d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 24 Mar 2007 19:01:43 +0000 Subject: [PATCH] Remove Database and template task #4783 --- html/confirm_remove.php | 161 ++++++++++++++++++++++++++++++++++++++++ html/dossier.inc.php | 10 ++- html/js/confirm.js | 35 +++++++++ include/constant.php | 2 + include/modele.inc.php | 10 +-- 5 files changed, 210 insertions(+), 8 deletions(-) create mode 100644 html/confirm_remove.php create mode 100644 html/js/confirm.js diff --git a/html/confirm_remove.php b/html/confirm_remove.php new file mode 100644 index 000000000..5db9996e2 --- /dev/null +++ b/html/confirm_remove.php @@ -0,0 +1,161 @@ +theme,'onLoad="window.focus();"'); +$User->Check(); +if ($User->admin != 1) { + +print "

Désolé mais vous n' êtes pas administrateur

"; + + html_page_stop(); + return; +} +if ( ! isset ($_REQUEST['p_type'] ) || + ! isset ($_REQUEST['PHPSESSID']) || + ! isset ($_REQUEST['ob_id'])) +{ + print '

'; + print "Désolé vous n'avez pas appelé cette fonction avec les bons paramètres"; + print '

'; + print ''; + return; +} +$cn=DbConnect(); + +switch($_REQUEST['p_type']) +{ + case 'db': + $msg="dossier"; + $name=getDbValue($cn,"select dos_name from ac_dossier where dos_id=".$_REQUEST['ob_id']); + if ( strlen(trim($name)) == 0 ) + { + echo "

$msg inexistant

"; + return; + } + + break; + case 'mod': + $msg="modèle"; + $name=getDbValue($cn,"select mod_name from modeledef where mod_id=".$_REQUEST['ob_id']); + if ( strlen(trim($name)) == 0 ) + { + echo "

$msg inexistant

"; + return; + } + if ( $_REQUEST['ob_id'] < 3 ) { + echo "

Désolé mais vous ne pouvez pas effacer les modèles de base

"; + return; + } + break; + default: + print '

'; + print "Désolé mais que voulez-vous effacer ? "; + print '

'; + return; + +} + +if ( isset($_POST['remove']) ) +{ + // Check if the radio is checked + // if yes removed the template and show a confirmation message + if ( isset($_POST['confirm']) ) + { + switch( $_POST['p_type'] ) + { + // Drop Modele + case 'mod': + $sql="drop database ".domaine."mod".$_POST['ob_id']; + ob_start(); + if ( pg_query($cn,$sql)==false) { + ob_clean(); + + echo "

+ Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord

"; + exit; + } + ob_flush(); + $sql="delete from modeledef where mod_id=".$_POST['ob_id']; + ExecSql($cn,$sql); + print '

'; + print "Voilà le modèle $name est effacé"; + print "

"; + break; + case 'db': + $sql="drop database ".domaine."dossier".$_POST['ob_id']; + ob_start(); + if ( pg_query($cn,$sql)==false) { + ob_clean(); + + echo "

+ Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord

"; + exit; + } + ob_flush(); + $sql="delete from priv_user where priv_id in (select jnt_id from jnt_use_dos where dos_id=".$_REQUEST['ob_id'].")"; + ExecSql($cn,$sql); + $sql="delete from jnt_use_dos where dos_id=".$_REQUEST['ob_id']; + ExecSql($cn,$sql); + $sql="delete from ac_dossier where dos_id=".$_REQUEST['ob_id']; + ExecSql($cn,$sql); + print '

'; + print "Voilà le modèle $name est effacé"; + print "

"; + + } + } + else + { + print '

'; + print "$msg $name n'est pas effacé"; + print '

'; + print "
"; + print "Vous n'avez pas coché la case"; + + } +} +else +{ + print "

Confirmer vous l'effacement du $msg $name ?

"; +?> +
+ + + Cochez cette case si vous voulez vraiment effacer + + +
+'; // show all dossiers @@ -149,9 +149,13 @@ if ( isset ($_POST["DATABASE"]) ) { $Dossier[dos_name] ".$Dossier['dos_description']." -"; + +'. + ''. +""; - $compteur++; + $compteur++; } diff --git a/html/js/confirm.js b/html/js/confirm.js new file mode 100644 index 000000000..e953caeff --- /dev/null +++ b/html/js/confirm.js @@ -0,0 +1,35 @@ +/* + * 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 ddebontridder@yahoo.fr + +/* !\file + */ + +/* \brief Manage the confirmation process + * + */ + +// \brief Confirm the removal of a template +function confirm_remove(p_phpsessid,p_obj_id,p_type) { + alert ("Effacement demandé"); + var + a=open('confirm_remove.php?PHPSESSID='+p_phpsessid+'&ob_id='+p_obj_id+'&p_type='+p_type,'Confirmez effacement','toolbar=no,width=500,height=400,scrollbars=yes,resizable=yes'); + +} \ No newline at end of file diff --git a/include/constant.php b/include/constant.php index 5f8415e15..330447fbe 100644 --- a/include/constant.php +++ b/include/constant.php @@ -142,6 +142,8 @@ define ("ATTR_DEF_DEPENSE_NON_DEDUCTIBLE",20); define ("ATTR_DEF_TVA_NON_DEDUCTIBLE",21); define ("ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP",22); define ("ATTR_DEF_QUICKCODE",23); +define ("JS_CONFIRM", +""); define ("JS_SEARCH_POSTE", ""); diff --git a/include/modele.inc.php b/include/modele.inc.php index 458a67e57..7fe93fefe 100644 --- a/include/modele.inc.php +++ b/include/modele.inc.php @@ -26,7 +26,7 @@ /* \brief concerne only the template * */ - +echo JS_CONFIRM; $cn=DbConnect(); if ( isset($_GET['rm']) && isset($_GET['mod_id'])) { @@ -58,7 +58,7 @@ $Res=ExecSql($cn_mod,"truncate table centralized"); $Res=ExecSql($cn_mod,"truncate table stock_goods"); $Res=ExecSql($cn_mod,"truncate table jrn_rapt"); -// Reset the closed periode + // Reset the closed periode $Res=ExecSql($cn_mod,"update parm_periode set p_closed='f'"); // Reset Sequence $a_seq=array('s_jrn','s_jrn_op','s_centralized','s_stock_goods'); @@ -99,9 +99,9 @@ ' %s '. ' %s '. ' '. - ''. - ''. + ' '. + ''. '', $mod['mod_name'],