#15: Gestion des opérations prédéfinies

This commit is contained in:
Dany De Bontridder 2011-02-04 23:58:29 +00:00
parent 2ad98470a4
commit eeba4d6363
5 changed files with 165 additions and 4 deletions

View file

@ -450,4 +450,10 @@ case 'input_per':
case 'save_per':
require_once('modify_periode.inc.php');
break;
case 'mod_predf':
require_once('modify_predf_op.php');
break;
case 'save_predf':
require_once('save_predf_op.php');
break;
}

View file

@ -373,11 +373,20 @@ function change_month(obj)
{
var queryString="gDossier="+obj.gDossier+"&op=cal"+"&per="+obj.value;
var action = new Ajax.Request(
"ajax_misc.php" , { method:'get', parameters:queryString,onFailure:ajax_misc_failure,onSuccess:change_month_success}
"ajax_misc.php" , { method:'get', parameters:queryString,onFailure:ajax_misc_failure,onSuccess:success_misc}
);
}
function change_month_success(req)
/**
*@brief basic answer to ajax on success, it will fill the DOMID code with
* the code. In that case, you need to create the object before the Ajax.Request
*The difference with success box is that
*@see add_div removeDiv success_box is that the width and height are not changed ajax_misc.php
*@parameter code is the ID of the object containing the html (div, button...)
*@parameter value is the html code, with it you fill the ctl element
*/
function success_misc(req)
{
try
{
@ -988,3 +997,51 @@ function fill_box(req)
}
/**
*display a popin to let you modified a predefined operation
*@param dossier_id
*@param od_id from table op_predef
*/
function mod_predf_op(dossier_id,od_id)
{
var target="mod_predf_op";
if ( $(target))
{
removeDiv(target);
}
var sx=posY;
var sy=posX;
var str_style="top:"+sx+";left:"+sy;
var div={id:target, cssclass:'op_detail',style:str_style,html:loading(),drag:1};
add_div(div);
var qs="?gDossier="+dossier_id+'&op=mod_predf&id='+od_id;
var action=new Ajax.Request ( 'ajax_misc.php',
{
method:'get',
parameters:qs,
onFailure:null,
onSuccess:fill_box
}
);
}
function save_predf_op(obj)
{
var querystring="?"+$(obj).serialize()+'&op=save_predf';
// Create a ajax request to get all the person
var action = new Ajax.Request ('ajax_misc.php',
{
method: 'get',
parameters: querystring,
onFailure: null,
onSuccess: refresh_window
}
);
return false;
}

View file

@ -0,0 +1,59 @@
<?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
/*!\file
* \brief display a form to change the name of a predefined operation
*/
ob_start();
if ( $user->check_action(PARPREDE)==0)
{
echo alert('Action interdite');
}
else
{
echo HtmlInput::anchor_close('mod_predf_op');
echo h2info('Modification du nom');
echo '
<form method="get" onsubmit="save_predf_op(this);return false;">';
$name=new IText('predf_name');
$name->value=$cn->get_value('select od_name from op_predef where od_id=$1',array($_GET['id']));
$name->size=60;
echo "Nom =".$name->input();
echo dossier::hidden().HtmlInput::hidden('od_id',$_GET['id']);
echo "<hr>";
echo HtmlInput::submit('save','Sauve');
echo HtmlInput::button('close','Annuler','onclick="removeDiv(\'mod_predf_op\')"');
echo '</form>';
}
$html=ob_get_contents();
ob_clean();
$html=escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>mod_predf_op</ctl>
<code>$html</code>
</data>
EOF;

View file

@ -85,10 +85,12 @@ if ( $sa == 'jrn' )
foreach ($array as $row )
{
if ( $count %2 == 0 )
echo '<tr class="even">';
if ( $count %2 == 0 )
echo '<tr class="odd">';
else
echo '<tr>';
$count++;
echo '<td>'.h($row['od_name']).'</td>';
echo '<td>';
echo '<form method="POST">';
@ -105,6 +107,8 @@ if ( $sa == 'jrn' )
echo '</form>';
echo '</td>';
$b=HtmlInput::button('mod'.$row['od_id'],"Modifier","onclick=\"mod_predf_op('".dossier::id()."','".$row['od_id']."');\"");
echo td($b);
echo '</tr>';
}

35
include/save_predf_op.php Normal file
View file

@ -0,0 +1,35 @@
<?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
/*!\file
* \brief save the new predefined operation
* included from ajax_misc
*/
if ( $user->check_action(PARPREDE)==0) exit();
if ( trim($_GET['predf_name']) != '')
{
$cn->exec_sql('update op_predef set od_name =$1 where od_id=$2',
array($_GET['predf_name'],$_GET['od_id']));
$cn->commit();
}