Task 198 : add a button to change year in history of a card or account
This commit is contained in:
parent
60bc07d293
commit
3dc23f6720
4 changed files with 220 additions and 39 deletions
|
|
@ -1,36 +1,37 @@
|
|||
<?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$ */
|
||||
/*
|
||||
* 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
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
* \brief show the history of a card of an accounting
|
||||
* for the card f_id is set and for an accounting : pcm_val
|
||||
*/
|
||||
/*!\file
|
||||
* \brief show the history of a card of an accounting
|
||||
* for the card f_id is set and for an accounting : pcm_val
|
||||
*/
|
||||
require_once('class_database.php');
|
||||
require_once('class_user.php');
|
||||
require_once('class_dossier.php');
|
||||
require_once('class_periode.php');
|
||||
require_once('class_html_input.php');
|
||||
require_once('class_acc_account.php');
|
||||
|
||||
require_once('class_exercice.php');
|
||||
//var_dump($_GET);
|
||||
$cn=new Database(dossier::id());
|
||||
$user=new User($cn);
|
||||
/* security */
|
||||
|
|
@ -42,57 +43,132 @@ $div=$_REQUEST['div'];
|
|||
/* first detail for a card */
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
if ( isset($_GET['f_id']))
|
||||
{
|
||||
{
|
||||
$exercice=new Exercice($cn);
|
||||
$old='';
|
||||
$fiche=new Fiche($cn,$_GET['f_id']);
|
||||
$year=$user->get_exercice();
|
||||
if ( $year == 0 )
|
||||
{
|
||||
{
|
||||
$html="erreur aucune période par défaut, allez dans préférence pour en choisir une";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$per=new Periode($cn);
|
||||
$limit_periode=$per->get_limit($year);
|
||||
$array['from_periode']=$limit_periode[0]->first_day();
|
||||
$array['to_periode']=$limit_periode[1]->last_day();
|
||||
if (isset($_GET['ex']))
|
||||
{
|
||||
$limit_periode=$per->get_limit($_GET['ex']);
|
||||
$array['from_periode']=$limit_periode[0]->first_day();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add button to select another year
|
||||
*/
|
||||
if ($exercice->count() > 1 )
|
||||
{
|
||||
$default=(isset($_GET['ex']))?$_GET['ex']:$year;
|
||||
$dossier=dossier::id();
|
||||
if ( $div != 'popup')
|
||||
{
|
||||
$obj="{div:'$div',f_id:'".$_GET['f_id']."',gDossier:'$dossier',select:this}";
|
||||
$is=$exercice->select('p_exercice',$default,' onchange="update_history_card('.$obj.');"');
|
||||
$old="Autre exercice ".$is->input();
|
||||
}
|
||||
else
|
||||
{
|
||||
$old='<form method="get" action="popup.php">';
|
||||
$is=$exercice->select('ex',$default,'onchange = "submit(this)"');
|
||||
$old.="Autre exercice ".$is->input();
|
||||
$old.=HtmlInput::hidden('div','popup');
|
||||
$old.=HtmlInput::hidden('act',$_GET['act']);
|
||||
$old.=HtmlInput::hidden('f_id',$_GET['f_id']);
|
||||
$old.=HtmlInput::hidden('ajax',$_GET['ajax']);
|
||||
$old.=dossier::hidden();
|
||||
$old.='</form>';
|
||||
}
|
||||
}
|
||||
|
||||
ob_start();
|
||||
require_once('template/history_top.php');
|
||||
if ( $fiche->HtmlTable($array)==-1){
|
||||
echo h2info("Aucun opération pour l'exercice courant");
|
||||
echo h2info( $fiche->getName().'['.$fiche->strAttribut(ATTR_DEF_QUICKCODE).']');
|
||||
echo h2("Aucun opération pour l'exercice courant",'class="error"');
|
||||
}
|
||||
echo $old;
|
||||
|
||||
$html=ob_get_contents();
|
||||
ob_clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// for an account
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
if ( isset($_REQUEST['pcm_val']))
|
||||
{
|
||||
{
|
||||
$poste=new Acc_Account_Ledger($cn,$_REQUEST['pcm_val']);
|
||||
$year=$user->get_exercice();
|
||||
if ( $year == 0 )
|
||||
{
|
||||
{
|
||||
$html="erreur aucune période par défaut, allez dans préférence pour en choisir une";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$exercice=new Exercice($cn);
|
||||
$old='';
|
||||
$per=new Periode($cn);
|
||||
$limit_periode=$per->get_limit($year);
|
||||
$array['from_periode']=$limit_periode[0]->first_day();
|
||||
$array['to_periode']=$limit_periode[1]->last_day();
|
||||
if (isset($_GET['ex']))
|
||||
{
|
||||
$limit_periode=$per->get_limit($_GET['ex']);
|
||||
$array['from_periode']=$limit_periode[0]->first_day();
|
||||
}
|
||||
/*
|
||||
* Add button to select another year
|
||||
*/
|
||||
if ($exercice->count() > 1 )
|
||||
{
|
||||
$default=(isset($_GET['ex']))?$_GET['ex']:$year;
|
||||
$dossier=dossier::id();
|
||||
if ( $div != 'popup')
|
||||
{
|
||||
$obj="{div:'$div',pcm_val:'".$_GET['pcm_val']."',gDossier:'$dossier',select:this}";
|
||||
$is=$exercice->select('p_exercice',$default,' onchange="update_history_account('.$obj.');"');
|
||||
$old="Autre exercice ".$is->input();
|
||||
}
|
||||
else
|
||||
{
|
||||
$old='<form method="get" action="popup.php">';
|
||||
$is=$exercice->select('ex',$default,'onchange = "submit(this)"');
|
||||
$old.="Autre exercice ".$is->input();
|
||||
$old.=HtmlInput::hidden('div','popup');
|
||||
$old.=HtmlInput::hidden('act',$_GET['act']);
|
||||
$old.=HtmlInput::hidden('pcm_val',$_GET['pcm_val']);
|
||||
$old.=HtmlInput::hidden('ajax',$_GET['ajax']);
|
||||
$old.=dossier::hidden();
|
||||
$old.='</form>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
require_once('template/history_top.php');
|
||||
|
||||
if ( $poste->HtmlTable($array) == -1)
|
||||
{
|
||||
echo h2info("Aucun opération pour l'exercice courant");
|
||||
echo h2info($poste->id." ".$poste->name);
|
||||
echo h2("Aucun opération pour l'exercice courant",'class="error"');
|
||||
}
|
||||
echo $old;
|
||||
|
||||
$html=ob_get_contents();
|
||||
ob_clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$html=escape_xml($html);
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo <<<EOF
|
||||
|
|
|
|||
|
|
@ -611,6 +611,26 @@ function view_history_account(p_value,dossier)
|
|||
g(id).style.left=posX-10;
|
||||
|
||||
}
|
||||
|
||||
function update_history_account(obj)
|
||||
{
|
||||
try{
|
||||
var querystring="?div="+obj.div+"&gDossier="+obj.gDossier+"&pcm_val="+obj.pcm_val+"&ex="+obj.select.options[obj.select.selectedIndex].text;
|
||||
var action=new Ajax.Request(
|
||||
"ajax_history.php",
|
||||
{
|
||||
method:'get',
|
||||
parameters:querystring,
|
||||
onFailure:error_box,
|
||||
onSuccess:success_box
|
||||
});
|
||||
} catch (e)
|
||||
{
|
||||
alert("update_history_account error "+e.message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/*!\brief
|
||||
* \param p_value f_id of the card
|
||||
*/
|
||||
|
|
@ -639,6 +659,26 @@ var popup={'id':
|
|||
g(id).style.left=posX-10;
|
||||
|
||||
}
|
||||
|
||||
function update_history_card(obj)
|
||||
{
|
||||
try{
|
||||
var querystring="?div="+obj.div+"&gDossier="+obj.gDossier+"&f_id="+obj.f_id+"&ex="+obj.select.options[obj.select.selectedIndex].text;
|
||||
var action=new Ajax.Request(
|
||||
"ajax_history.php",
|
||||
{
|
||||
method:'get',
|
||||
parameters:querystring,
|
||||
onFailure:error_box,
|
||||
onSuccess:success_box
|
||||
});
|
||||
} catch (e)
|
||||
{
|
||||
alert("update_history_account error "+e.message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* remove an Operation
|
||||
*@param p_jr_id is the jrn.jr_id
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ require_once('class_periode.php');
|
|||
echo '<div style="float:left;">'.HtmlInput::print_window();
|
||||
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
if ( basename($_GET['ajax']) == 'ajax_history.php' )
|
||||
{
|
||||
$href=dossier::get();
|
||||
|
|
@ -24,7 +25,12 @@ if ( basename($_GET['ajax']) == 'ajax_history.php' )
|
|||
|
||||
$from_periode='from_periode='.format_date($limit[0]->p_start);
|
||||
$to_periode='to_periode='.format_date($limit[1]->p_end);
|
||||
|
||||
if (isset($_GET['ex']))
|
||||
{
|
||||
$limit_periode=$periode->get_limit($_GET['ex']);
|
||||
$from_periode='from_periode='.format_date($limit_periode[0]->p_start);
|
||||
}
|
||||
|
||||
if (isset($_GET['pcm_val']) )
|
||||
{
|
||||
$href_csv="poste_csv.php?".$href.'&poste_id='.$_GET['pcm_val'].'&ople=0&type=poste&'.$from_periode.'&'.$to_periode;
|
||||
|
|
|
|||
59
include/class_exercice.php
Normal file
59
include/class_exercice.php
Normal 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 about the accountant exercice
|
||||
*/
|
||||
require_once('class_database.php');
|
||||
require_once('class_iselect.php');
|
||||
class Exercice
|
||||
{
|
||||
function __construct(&$cn)
|
||||
{
|
||||
$this->cn=$cn;
|
||||
}
|
||||
/**
|
||||
*return the number of different exercices into a folder
|
||||
*@param $cn is the database connexion object database
|
||||
*@return the count of exercice
|
||||
*/
|
||||
function count()
|
||||
{
|
||||
$count=$this->cn->get_value('select count(distinct p_exercice) from parm_periode');
|
||||
return $count;
|
||||
}
|
||||
/**
|
||||
*Show a ISelect with the different exercices
|
||||
*@param $name of the iselect
|
||||
*@param $selected the selected year (default = '')
|
||||
*@param $js javascript (default = '')
|
||||
*@return ISelect object
|
||||
*/
|
||||
function select($name,$selected='',$js='')
|
||||
{
|
||||
$iselect=new ISelect($name);
|
||||
$iselect->value=$this->cn->make_array('select distinct p_exercice,p_exercice from parm_periode order by 1');
|
||||
$iselect->selected=$selected;
|
||||
$iselect->javascript=$js;
|
||||
return $iselect;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue