PCMN update in a box, not a popup windows
This commit is contained in:
parent
71f0695a7f
commit
05d7f55962
4 changed files with 81 additions and 125 deletions
|
|
@ -39,9 +39,16 @@ function set_jrn_parent(p_ctl,p_value) {
|
|||
|
||||
|
||||
function PcmnUpdate(p_value,p_lib,p_parent,p_type,p_dossier)
|
||||
{
|
||||
var win=window.open('line_update.php?l='+p_value+'&n='+p_lib+'&p='+p_parent+'&m'+p_type+'&gDossier='+p_dossier,'Modifie','toolbar=no,width=500,height=400,scrollbars=yes,resizable=yes');
|
||||
}
|
||||
{
|
||||
$('p_valu').value=p_value;
|
||||
$('p_oldu').value=p_value;
|
||||
$('p_libu').value=p_lib;
|
||||
$('p_parentu').value=p_parent;
|
||||
$('p_typeu').value=p_type;
|
||||
$('acc_update').style.top=posY+offsetY;
|
||||
$('acc_update').style.left=posX+offsetX;
|
||||
$('acc_update').show();
|
||||
}
|
||||
/**
|
||||
*@brief show the popup for search an accounting item
|
||||
*@param object this, it must contains some attribute as
|
||||
|
|
|
|||
|
|
@ -1,119 +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
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
// $Revision$
|
||||
/*! \file
|
||||
* \brief Modify the "Plan Comptable"
|
||||
*/
|
||||
include_once ("ac_common.php");
|
||||
require_once('class_dossier.php');
|
||||
$gDossier=dossier::id();
|
||||
require_once('class_database.php');
|
||||
require_once ('class_acc_account.php');
|
||||
/* Admin. Dossier */
|
||||
$rep=new Database();
|
||||
include_once ("class_user.php");
|
||||
$User=new User($rep);
|
||||
$User->Check();
|
||||
html_page_start($User->theme,"onLoad='window.focus();'");
|
||||
$cn=new Database($gDossier);
|
||||
$User->can_request(PARPCMN);
|
||||
|
||||
|
||||
include ("user_menu.php");
|
||||
/* Modif d'une ligne */
|
||||
if ( isset ($_POST["update"] ) ) {
|
||||
|
||||
echo JS_ACCOUNTING_ITEM;
|
||||
|
||||
$p_val=trim($_POST["p_val"]);
|
||||
$p_lib=trim($_POST["p_lib"]);
|
||||
$p_parent=trim($_POST["p_parent"]);
|
||||
$old_line=trim($_POST["p_old"]);
|
||||
$p_type=htmlentities($_POST['p_type']);
|
||||
$acc=new Acc_Account($cn);
|
||||
$acc->set_parameter('libelle',$p_lib);
|
||||
$acc->set_parameter('value',$p_val);
|
||||
$acc->set_parameter('parent',$p_parent);
|
||||
$acc->set_parameter('type',$p_type);
|
||||
// Check if the data are correct
|
||||
try {
|
||||
$acc->check() ;
|
||||
}catch (Exception $e) {
|
||||
$message="Valeurs invalides, pas de changement \n ".
|
||||
$e->getMessage();
|
||||
echo '<script> alert(\''.$message.'\');
|
||||
</script>';
|
||||
echo "<script>
|
||||
window.close();
|
||||
self.opener.RefreshMe();
|
||||
|
||||
</script>";
|
||||
exit();
|
||||
|
||||
}
|
||||
if ( strlen ($p_val) != 0 && strlen ($p_lib) != 0 && strlen($old_line)!=0 ) {
|
||||
if (strlen ($p_val) == 1 ) {
|
||||
$p_parent=0;
|
||||
} else {
|
||||
if ( strlen($p_parent)==0 ) {
|
||||
$p_parent=substr($p_val,0,strlen($p_val)-1);
|
||||
}
|
||||
}
|
||||
/* Parent existe */
|
||||
$Ret=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val=$1",array($p_parent));
|
||||
if ( ($p_parent != 0 && Database::num_row($Ret) == 0) || $p_parent==$old_line ) {
|
||||
echo '<SCRIPT> alert(" Ne peut pas modifier; aucun poste parent"); </SCRIPT>';
|
||||
} else {
|
||||
$acc->update($old_line);
|
||||
}
|
||||
} else {
|
||||
echo '<script> alert(\'Update Valeurs invalides\'); </script>';
|
||||
}
|
||||
|
||||
echo "<script>
|
||||
window.close();
|
||||
self.opener.RefreshMe();
|
||||
|
||||
</script>";
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<FORM ACTION="line_update.php" METHOD="POST">
|
||||
<?
|
||||
$acc=new Acc_Account($cn);
|
||||
$acc->set_parameter('value',$_GET['l']);
|
||||
$acc->load();
|
||||
|
||||
echo $acc->form(true);
|
||||
?>
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD><INPUT TYPE="Submit" VALUE="Sauve">
|
||||
<INPUT TYPE="HIDDEN" name="update">
|
||||
<?php printf ('<INPUT TYPE="HIDDEN" name="p_old" value="%s">',h($acc->get_parameter('value'))); ?>
|
||||
</TD><TD><input type="button" class="button" Value="Retour sans sauver" onClick='window.close();'></TD></TR>
|
||||
</TABLE>
|
||||
</FORM>
|
||||
|
||||
|
||||
<?php
|
||||
html_page_stop();
|
||||
?>
|
||||
|
|
@ -38,7 +38,7 @@ class Acc_Account {
|
|||
private $pcm_type;
|
||||
private $pcm_parent;
|
||||
private $pcm_lib;
|
||||
static private $type=array(
|
||||
static public $type=array(
|
||||
array('label'=>'Actif','value'=>'ACT'),
|
||||
array('label'=>'Passif','value'=>'PAS'),
|
||||
array('label'=>'Actif c. inverse','value'=>'ACTINV'),
|
||||
|
|
|
|||
|
|
@ -25,11 +25,13 @@ require_once ('class_acc_account.php');
|
|||
include_once ("ac_common.php");
|
||||
require_once("constant.php");
|
||||
require_once('class_dossier.php');
|
||||
require_once('function_javascript.php');
|
||||
|
||||
$gDossier=dossier::id();
|
||||
|
||||
echo js_include('infobulle.js');
|
||||
require_once('class_database.php');
|
||||
/* Admin. Dossier */
|
||||
|
||||
/* Admin. Dossier */
|
||||
$cn=new Database($gDossier);
|
||||
|
||||
include_once ("class_user.php");
|
||||
|
|
@ -39,6 +41,30 @@ $User->check_dossier($gDossier);
|
|||
|
||||
include_once ("user_menu.php");
|
||||
|
||||
echo '<div id="acc_update" style="border:1px solid blue;width:40%;display:none;background-color:lightgrey;padding:3;position:absolute;text-align:left;line-height:3em;z-index:1">';
|
||||
echo '<form method="post">';
|
||||
$val=new IText('p_valu');
|
||||
$parent=new IText('p_parentu');
|
||||
$lib=new IText('p_libu');
|
||||
$lib->size=50;
|
||||
$type=new ISelect('p_typeu');
|
||||
$type->value=Acc_Account::$type;
|
||||
echo '<table>';
|
||||
$r= td(_('Poste comptable')).td($val->input());
|
||||
echo tr($r);
|
||||
$r= td(_('Description')).td($lib->input());
|
||||
echo tr($r);
|
||||
$r= td(_('Parent')).td($parent->input());
|
||||
echo tr($r);
|
||||
$r= td(_('Type ')).td($type->input());
|
||||
echo tr($r);
|
||||
echo '</table>';
|
||||
echo HtmlInput::hidden('p_oldu','');
|
||||
echo dossier::hidden();
|
||||
echo HtmlInput::submit('update',_('Sauve'));
|
||||
echo HtmlInput::button('hide',_('Annuler'),'onClick="$(\'acc_update\').hide();return true;"');
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
|
||||
|
||||
|
|
@ -88,6 +114,48 @@ if (isset ($_GET['action'])) {
|
|||
} // isset ($l)
|
||||
} //$action == del
|
||||
} // isset action
|
||||
//----------------------------------------------------------------------
|
||||
// Modification
|
||||
//----------------------------------------------------------------------
|
||||
if ( isset ($_POST['update'])) {
|
||||
$p_val=trim($_POST["p_valu"]);
|
||||
$p_lib=trim($_POST["p_libu"]);
|
||||
$p_parent=trim($_POST["p_parentu"]);
|
||||
$old_line=trim($_POST["p_oldu"]);
|
||||
$p_type=htmlentities($_POST['p_typeu']);
|
||||
$acc=new Acc_Account($cn);
|
||||
$acc->set_parameter('libelle',$p_lib);
|
||||
$acc->set_parameter('value',$p_val);
|
||||
$acc->set_parameter('parent',$p_parent);
|
||||
$acc->set_parameter('type',$p_type);
|
||||
// Check if the data are correct
|
||||
try {
|
||||
$acc->check() ;
|
||||
}catch (Exception $e) {
|
||||
$message="Valeurs invalides, pas de changement \n ".
|
||||
$e->getMessage();
|
||||
echo '<script> alert(\''.$message.'\');
|
||||
</script>';
|
||||
}
|
||||
if ( strlen ($p_val) != 0 && strlen ($p_lib) != 0 && strlen($old_line)!=0 ) {
|
||||
if (strlen ($p_val) == 1 ) {
|
||||
$p_parent=0;
|
||||
} else {
|
||||
if ( strlen($p_parent)==0 ) {
|
||||
$p_parent=substr($p_val,0,strlen($p_val)-1);
|
||||
}
|
||||
}
|
||||
/* Parent existe */
|
||||
$Ret=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val=$1",array($p_parent));
|
||||
if ( ($p_parent != 0 && Database::num_row($Ret) == 0) || $p_parent==$old_line ) {
|
||||
echo '<SCRIPT> alert(" Ne peut pas modifier; aucun poste parent"); </SCRIPT>';
|
||||
} else {
|
||||
$acc->update($old_line);
|
||||
}
|
||||
} else {
|
||||
echo '<script> alert(\'Update Valeurs invalides\'); </script>';
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
/* Ajout d'une ligne */
|
||||
if ( isset ( $_POST["Ajout"] ) ) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue