0000159: Changement de période devrait être un popup en html
This commit is contained in:
parent
8328a7237b
commit
710d4bbf27
5 changed files with 216 additions and 18 deletions
|
|
@ -53,7 +53,7 @@ foreach ($var as $v)
|
|||
}
|
||||
}
|
||||
if ( $cont != 0 ) exit();
|
||||
extract($_GET );
|
||||
extract($_REQUEST );
|
||||
set_language();
|
||||
|
||||
$cn=new Database($gDossier);
|
||||
|
|
@ -442,4 +442,10 @@ EOF;
|
|||
case 'mod_doc':
|
||||
require_once('modify_mod_document.inc.php');
|
||||
break;
|
||||
case 'input_per':
|
||||
require_once('modify_periode.inc.php');
|
||||
break;
|
||||
case 'save_per':
|
||||
require_once('modify_periode.inc.php');
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -859,11 +859,90 @@ function show_calc()
|
|||
shtml+='<form name="calc_line" method="GET" onSubmit="cal();return false;" >Cette calculatrice vous permet de calculer, écrivez simplement les opérations que vous voulez puis la touche retour. exemple : 1+2+3*(1/5) <input class="input_text" type="text" size="30" id="inp" name="calculator"> <input type="button" value="Efface tout" onClick="Clean();return false;" > <input type="button" value="Fermer" onClick="removeDiv(\'calc1\')" >';
|
||||
shtml+='</form><span id="result"> </span><br><span id="sub_total"> Taper une formule (ex 20*5.1) puis enter </span><br><span id="listing"> </span>';
|
||||
|
||||
var obj={id:
|
||||
sid,html:
|
||||
shtml,drag:
|
||||
true,style:'position:absolute;display:block;top:30px;left:150px;width:250px;border:1px solid black;background-color:#99b1df;font-size:12;padding: 2 2 2 2;'
|
||||
};
|
||||
var obj={id:sid,html:shtml,
|
||||
drag:true,style:'position:absolute;display:block;top:30px;left:150px;width:250px;border:1px solid black;background-color:#99b1df;font-size:12;padding: 2 2 2 2;'
|
||||
};
|
||||
add_div(obj);
|
||||
this.document.getElementById('inp').focus();
|
||||
}
|
||||
function display_periode(p_dossier,p_id)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var queryString="gDossier="+p_dossier+"&op=input_per"+"&p_id="+p_id;
|
||||
var popup={'id': 'mod_periode','cssclass':'op_detail','html':loading(),'style':'position:fixed;top:45%;left:45%',
|
||||
'drag':true};
|
||||
if ( ! $('mod_periode') ) {
|
||||
add_div(popup);
|
||||
}
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php" ,
|
||||
{ method:'get',
|
||||
parameters:queryString,
|
||||
onFailure:ajax_misc_failure,
|
||||
onSuccess:success_display_periode
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
alert("display_periode "+e.message);
|
||||
}
|
||||
|
||||
}
|
||||
function success_display_periode(req)
|
||||
{ try
|
||||
{
|
||||
|
||||
var answer=req.responseXML;
|
||||
var html=answer.getElementsByTagName('data');
|
||||
|
||||
if ( html.length == 0 )
|
||||
{
|
||||
var rec=req.responseText;
|
||||
alert ('erreur :'+rec);
|
||||
}
|
||||
|
||||
var code_html=getNodeText(html[0]);
|
||||
code_html=unescape_xml(code_html);
|
||||
|
||||
$('mod_periode').innerHTML=code_html;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
alert("success_display_periode".e.message);
|
||||
}
|
||||
try
|
||||
{
|
||||
code_html.evalScripts();
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
alert("success_display_periode Impossible executer script de la reponse\n"+e.message);
|
||||
}
|
||||
|
||||
}
|
||||
function save_periode(obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
var queryString="?"+$(obj).serialize()+"&op=save_per";
|
||||
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php" ,
|
||||
{ method:'post',
|
||||
parameters:queryString,
|
||||
onFailure:ajax_misc_failure,
|
||||
onSuccess:success_display_periode
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
alert("display_periode "+e.message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -372,4 +372,11 @@ class HtmlInput
|
|||
ob_clean();
|
||||
return $r;
|
||||
}
|
||||
static function display_periode($p_id)
|
||||
{
|
||||
$r=sprintf('<a href="javascript:void(0)" onclick="display_periode(%d,%d)">Modifier</a>',
|
||||
dossier::id(),
|
||||
$p_id);
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,16 +133,8 @@ class Periode
|
|||
$this->cn->exec_sql("update jrn_periode set status='OP' ".
|
||||
" where jrn_def_id=".$this->jrn_def_id." and ".
|
||||
" p_id = ".$this->p_id);
|
||||
/* if all ledgers have this periode open then synchro with
|
||||
the table parm_periode
|
||||
*/
|
||||
$nJrn=$this->cn->count_sql( "select * from jrn_periode where ".
|
||||
" p_id=".$this->p_id);
|
||||
$nJrnPeriode=$this->cn->count_sql( "select * from jrn_periode where ".
|
||||
" p_id=".$this->p_id." and status='OP'");
|
||||
|
||||
if ( $nJrnPeriode==$nJrn)
|
||||
$this->cn->exec_sql("update parm_periode set p_closed=false where p_id=".$this->p_id);
|
||||
/* if one ledger is open then the periode is open */
|
||||
$this->cn->exec_sql("update parm_periode set p_closed=false where p_id=".$this->p_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -244,12 +236,22 @@ class Periode
|
|||
{
|
||||
$closed='<TD class="mtitle">';
|
||||
$closed.='<A class="mtitle" HREF="?p_action=periode&action=closed&p_per='.$l_line['p_id'].'&'.$str_dossier.'" onclick="return confirm(\''._('Confirmez cloture').' ?\')"> Cloturer</A></td>';
|
||||
$change='<TD class="mtitle">';
|
||||
|
||||
if ($l_line['count_op'] == 0 )
|
||||
{
|
||||
$change=HtmlInput::display_periode($l_line['p_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$change="Non modifiable";
|
||||
}
|
||||
$change=td($change);
|
||||
/*
|
||||
$change.='<A class="mtitle" HREF="?p_action=periode&action=change_per&p_per='.
|
||||
$l_line['p_id']."&p_date_start=".$l_line['date_start'].
|
||||
"&p_date_end=".$l_line['date_end']."&p_exercice=".
|
||||
$l_line['p_exercice']."&$str_dossier\"> Changer</A></td>";
|
||||
|
||||
*/
|
||||
$reopen=td("");
|
||||
|
||||
|
||||
|
|
|
|||
104
include/modify_periode.inc.php
Normal file
104
include/modify_periode.inc.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?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 ddebontridder@yahoo.fr
|
||||
require_once('class_periode.php');
|
||||
|
||||
/*!\file
|
||||
* \brief display or save a periode
|
||||
* variable received $op, $cn $user
|
||||
*/
|
||||
$err=0;$html='';
|
||||
/* we check the security */
|
||||
if ( $user->check_action(PARPER) == 0 )
|
||||
{
|
||||
$html='<div class="error">Accès interdit</div>';
|
||||
$err=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ($op)
|
||||
{
|
||||
case 'input_per':
|
||||
$per=new Periode($cn,$_GET['p_id']);
|
||||
$per->load();
|
||||
$limit=$per->get_date_limit($_GET['p_id']);
|
||||
|
||||
$p_start=new IDate('p_start');
|
||||
$p_start->value=$limit['p_start'];
|
||||
$p_end = new IDate('p_end');
|
||||
$p_end->value = $limit['p_end'];
|
||||
$p_exercice=new INum('p_exercice');
|
||||
$p_exercice->value=$per->p_exercice;
|
||||
|
||||
$html='<h2 class="info"> Modifier les dates de début et fin de période</h2>';
|
||||
$html.='<p class="notice">Cela pourrait avoir un impact sur les opérations déjà existantes</p>';
|
||||
$html.='<form method="post" onsubmit="return save_periode(this)">';
|
||||
$html.=dossier::hidden();
|
||||
$html.='<table>';
|
||||
|
||||
$html.=tr(td(' Début période : ').td($p_start->input()));
|
||||
$html.=tr(td(' Fin période : ').td($p_end->input()));
|
||||
$html.=tr(td(' Exercice : ').td($p_exercice->input()));
|
||||
|
||||
$html.=HtmlInput::submit('sauver','sauver');
|
||||
$html.=HtmlInput::button('close','Fermer','onclick="removeDiv(\'mod_periode\')"');
|
||||
$html.=HtmlInput::hidden('p_id',$_GET['p_id']);
|
||||
$html.='</form>';
|
||||
break;
|
||||
case 'save_per':
|
||||
$per=new Periode($cn,$_POST['p_id']);
|
||||
$per->load();
|
||||
if ( isDate($_POST['p_start']) == null ||
|
||||
isDate($_POST['p_end'] == null ) ||
|
||||
isNumber($_POST['p_exercice']) == 0 ||
|
||||
$_POST['p_exercice'] > 2099 ||
|
||||
$_POST['p_exercice'] < 2000 )
|
||||
{
|
||||
$html='<h2 class="info"> Modifier les dates de début et fin de période</h2>';
|
||||
$html.="<div class=\"error\">Erreur date invalide</div>";
|
||||
|
||||
$html.=HtmlInput::button('close','Fermer','onclick="removeDiv(\'mod_periode\')"');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql="update parm_periode set p_start=to_date($1,'DD.MM.YYYY'),p_end=to_date($2,'DD.MM.YYYY'),p_exercice=$3 where p_id=$4";
|
||||
try {
|
||||
$cn->exec_sql($sql,array($_POST['p_start'],$_POST['p_end'],$_POST['p_exercice'],$_POST['p_id']));
|
||||
$html='<h2 class="info"> Modifier les dates de début et fin de période</h2>';
|
||||
$html.='<h2 class="notice"> Sauvé </h2>';
|
||||
|
||||
$html.=HtmlInput::button('close','Fermer','onclick=" refresh_window();"');
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$html=alert($e->getTrace(),true);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$html=escape_xml($html);
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
echo '<xml>';
|
||||
echo '<data>'.$html.'</data>';
|
||||
echo '</xml>';
|
||||
Loading…
Add table
Add a link
Reference in a new issue