Remove Database and template task #4783
This commit is contained in:
parent
ea03cbf7e2
commit
1520e1075f
5 changed files with 210 additions and 8 deletions
161
html/confirm_remove.php
Normal file
161
html/confirm_remove.php
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
<?
|
||||
/*
|
||||
* 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 confirm the removal of a template , folder and remove it if confirmed
|
||||
*
|
||||
*/
|
||||
include_once("postgres.php");
|
||||
include_once("debug.php");
|
||||
include_once("ac_common.php");
|
||||
|
||||
$rep=DbConnect();
|
||||
include_once ("class_user.php");
|
||||
$User=new cl_user($rep);
|
||||
html_page_start($User->theme,'onLoad="window.focus();"');
|
||||
$User->Check();
|
||||
if ($User->admin != 1) {
|
||||
|
||||
print "<H2 class=\"error\"> Désolé mais vous n' êtes pas administrateur</H2>";
|
||||
|
||||
html_page_stop();
|
||||
return;
|
||||
}
|
||||
if ( ! isset ($_REQUEST['p_type'] ) ||
|
||||
! isset ($_REQUEST['PHPSESSID']) ||
|
||||
! isset ($_REQUEST['ob_id']))
|
||||
{
|
||||
print '<H2 CLASS="error">';
|
||||
print "Désolé vous n'avez pas appelé cette fonction avec les bons paramètres";
|
||||
print '</H2>';
|
||||
print '<INPUT TYPE="BUTTON" VALUE="Fermez la fenêtre" onclick="window.close();">';
|
||||
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 "<h2 class=\"error\"> $msg inexistant</h2>";
|
||||
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 "<h2 class=\"error\"> $msg inexistant</h2>";
|
||||
return;
|
||||
}
|
||||
if ( $_REQUEST['ob_id'] < 3 ) {
|
||||
echo "<h2 class=\"error\">Désolé mais vous ne pouvez pas effacer les modèles de base</H2>";
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
print '<H2 CLASS="error">';
|
||||
print "Désolé mais que voulez-vous effacer ? ";
|
||||
print '</H2>';
|
||||
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 "<h2 class=\"error\">
|
||||
Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord</h2>";
|
||||
exit;
|
||||
}
|
||||
ob_flush();
|
||||
$sql="delete from modeledef where mod_id=".$_POST['ob_id'];
|
||||
ExecSql($cn,$sql);
|
||||
print '<h2 class="info">';
|
||||
print "Voilà le modèle $name est effacé";
|
||||
print "<h2>";
|
||||
break;
|
||||
case 'db':
|
||||
$sql="drop database ".domaine."dossier".$_POST['ob_id'];
|
||||
ob_start();
|
||||
if ( pg_query($cn,$sql)==false) {
|
||||
ob_clean();
|
||||
|
||||
echo "<h2 class=\"error\">
|
||||
Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord</h2>";
|
||||
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 '<h2 class="info">';
|
||||
print "Voilà le modèle $name est effacé";
|
||||
print "<h2>";
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<h2 class="info">';
|
||||
print "$msg $name n'est pas effacé";
|
||||
print '</h2>';
|
||||
print "<hr>";
|
||||
print "Vous n'avez pas coché la case";
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<h2 class=\"info\"> Confirmer vous l'effacement du $msg $name ? <h2> ";
|
||||
?>
|
||||
<FORM METHOD="POST" ACTION="confirm_remove.php">
|
||||
<INPUT TYPE="HIDDEN" NAME="ob_id" value="<?echo $_REQUEST['ob_id'];?>" >
|
||||
<INPUT TYPE="HIDDEN" NAME="p_type" value="<?echo $_REQUEST['p_type'];?>" >
|
||||
<INPUT TYPE="CHECKBOX" NAME="confirm" VALUE="UNCHECKED"> Cochez cette case si vous voulez vraiment effacer <?echo $name;?>
|
||||
<INPUT TYPE="SUBMIT" NAME="remove" value="Oui">
|
||||
<input type="button" name="close" value="Annuler" onclick="window.close();">
|
||||
</FORM>
|
||||
<?
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ if ( isset ($_POST["DATABASE"]) ) {
|
|||
$Res=ShowDossier('all',$offset,$size);
|
||||
$compteur=1;
|
||||
$template="";
|
||||
|
||||
echo JS_CONFIRM;
|
||||
echo '<TABLE BORDER=1>';
|
||||
|
||||
// show all dossiers
|
||||
|
|
@ -149,9 +149,13 @@ if ( isset ($_POST["DATABASE"]) ) {
|
|||
<B>$Dossier[dos_name]</B> </TD>
|
||||
<TD><I> ".$Dossier['dos_description']."</I>
|
||||
</TD>
|
||||
</TR>";
|
||||
<TD>
|
||||
<input type=\"button\" name=\"Effacer\"".
|
||||
'Value="Effacer" onClick="confirm_remove(\''.$_REQUEST['PHPSESSID'].'\',\''.$Dossier['dos_id'].'\',\'db\');" \>'.
|
||||
'</td>'.
|
||||
"</TD></TR>";
|
||||
|
||||
$compteur++;
|
||||
$compteur++;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
35
html/js/confirm.js
Normal file
35
html/js/confirm.js
Normal file
|
|
@ -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');
|
||||
|
||||
}
|
||||
|
|
@ -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",
|
||||
"<SCRIPT language=\"javascript\" src=\"js/confirm.js\"> </SCRIPT>");
|
||||
define ("JS_SEARCH_POSTE",
|
||||
"<SCRIPT language=\"javascript\" src=\"js/search_poste.js\"> </SCRIPT>");
|
||||
|
||||
|
|
|
|||
|
|
@ -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 @@
|
|||
'<TD><b> %s</b> </TD>'.
|
||||
'<TD><I> %s </I></TD>'.
|
||||
'<td> '.
|
||||
'<a class="one" href="?action=modele_mgt&rm&mod_id='.$mod['mod_id'].
|
||||
'" <input type="button" name="Effacer" Value="Effacer">'.
|
||||
'</A></td>'.
|
||||
' <input type="button" name="Effacer" '.
|
||||
' Value="Effacer" onClick="confirm_remove(\''.$_REQUEST['PHPSESSID'].'\',\''.$mod['mod_id'].'\',\'mod\');" \>'.
|
||||
'</td>'.
|
||||
|
||||
'</TR>',
|
||||
$mod['mod_name'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue