[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r4719 - in phpcompta/trunk/include: . template
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r4719 - in phpcompta/trunk/include: . template |
Date: |
Mon, 16 Jan 2012 15:27:52 +0100 (CET) |
Author: danydb
Date: 2012-01-16 15:27:52 +0100 (Mon, 16 Jan 2012)
New Revision: 4719
Modified:
phpcompta/trunk/include/class_periode.php
phpcompta/trunk/include/periode.inc.php
phpcompta/trunk/include/template/periode_add_exercice.php
Log:
Add 12 or 13 periodes
Modified: phpcompta/trunk/include/class_periode.php
===================================================================
--- phpcompta/trunk/include/class_periode.php 2012-01-16 11:27:54 UTC (rev
4718)
+++ phpcompta/trunk/include/class_periode.php 2012-01-16 14:27:52 UTC (rev
4719)
@@ -345,6 +345,9 @@
}
function insert($p_date_start,$p_date_end,$p_exercice)
{
+ try
+ {
+
if (isDate($p_date_start) == null ||
isDate($p_date_end) == null ||
strlen (trim($p_exercice)) == 0 ||
@@ -352,7 +355,7 @@
||$p_exercice < 2000 || $p_exercice > 2099 )
{
- return 1;
+ throw new Exception ("Paramètre invalide");
}
$p_id=$this->cn->get_next_seq('s_periode');
$sql=sprintf(" insert into
parm_periode(p_id,p_start,p_end,p_closed,p_exercice)".
@@ -362,8 +365,6 @@
$p_date_start,
$p_date_end,
$p_exercice);
- try
- {
$this->cn->start();
$Res=$this->cn->exec_sql($sql);
$Res=$this->cn->exec_sql("insert into jrn_periode
(jrn_def_id,p_id,status) ".
@@ -484,19 +485,32 @@
/**
*add a exerice of 13 periode
*/
- function insert_exercice($p_exercice)
+ function insert_exercice($p_exercice,$nb_periode)
{
try
{
+ if ( $nb_periode != 12 && $nb_periode != 13) throw new Exception
('Nombre de période incorrectes');
$this->cn->start();
for ($i=1;$i < 12;$i++)
{
$date_start=sprintf('01.%02d.%d',$i,$p_exercice);
$date_end=$this->cn->get_value("select
to_char(to_date('$date_start','DD.MM.YYYY')+interval '1 month'-interval '1
day','DD.MM.YYYY')");
- $this->insert($date_start,$date_end,$p_exercice);
+ if ( $this->insert($date_start,$date_end,$p_exercice) != 0)
+ {
+ throw new Exception('Erreur insertion période');
+ }
}
- $this->insert('01.12.'.$p_exercice,'31.12.'.$p_exercice,$p_exercice);
+ if ( $nb_periode==12 &&
$this->insert('01.12.'.$p_exercice,'31.12.'.$p_exercice,$p_exercice) != 0 )
+ {
+ throw new Exception('Erreur insertion période');
+ }
+ if ( $nb_periode==13)
+ {
+ if
($this->insert('01.12.'.$p_exercice,'30.12.'.$p_exercice,$p_exercice) != 0 )
throw new Exception('Erreur insertion période');
+ if
($this->insert('31.12.'.$p_exercice,'31.12.'.$p_exercice,$p_exercice) != 0 )
throw new Exception('Erreur insertion période');
+ }
+
$this->cn->commit();
}
catch (Exception $e)
Modified: phpcompta/trunk/include/periode.inc.php
===================================================================
--- phpcompta/trunk/include/periode.inc.php 2012-01-16 11:27:54 UTC (rev
4718)
+++ phpcompta/trunk/include/periode.inc.php 2012-01-16 14:27:52 UTC (rev
4719)
@@ -51,7 +51,7 @@
{
$obj=new Periode($cn);
$exercice=$cn->get_value('select max(p_exercice::float)+1 from
parm_periode');
- if ( $obj->insert_exercice($exercice) == 1 )
+ if ( $obj->insert_exercice($exercice,$_POST['nb_exercice']) == 1 )
{
alert(_('Valeurs invalides'));
}
@@ -102,6 +102,12 @@
$per->set_jrn($jrn);
$per->display_form_periode();
+ $nb_exercice=new ISelect("nb_exercice");
+ $nb_exercice->value=array(
+ array('value'=>12,'label'=>"12 périodes"),
+ array('value'=>13,'label'=>"13 périodes")
+ );
+
require_once('template/periode_add_exercice.php');
}
else
Modified: phpcompta/trunk/include/template/periode_add_exercice.php
===================================================================
--- phpcompta/trunk/include/template/periode_add_exercice.php 2012-01-16
11:27:54 UTC (rev 4718)
+++ phpcompta/trunk/include/template/periode_add_exercice.php 2012-01-16
14:27:52 UTC (rev 4719)
@@ -1,12 +1,16 @@
<fieldset><legend>Ajout d'un exercice</legend>
-Ajout d'un exercice comptable de 12 périodes, commençant le 1 janvier et
terminant le 31 décembre. Si vous souhaitez une 13ième période (le 31/12)
-pour faire tous les écritures de fin d'exercice: amortissements, régulations
de compte... Il vous suffit de raccourcir d'allonger la période de décembre
jusqu'au 30/12
-et d'ajouter une période d'un jour allant du 31/12 au 31/12
+<ul>
+<li>
+Exercice en 12 périodes : Ajout d'un exercice comptable de 12 périodes,
commençant le 1 janvier et terminant le 31 décembre. </li>
+<li> Exercice en 13 périodes: Ajout d'une période d'un jour le 31/12. Cette
période est utilisée
+pour faire tous les écritures de fin d'exercice: amortissements, régulations
de compte... Avec une 13ième période, cela simplifie les prévisions, les
rapports...</li>
+</ul>
+
<form method="post" onsubmit="return confirm('Confirmez vous l\'ajout d\'un
exercice comptable ?')">
<?
echo HtmlInput::hidden("ac",$_REQUEST['ac']);
+echo $nb_exercice->input();
echo HtmlInput::hidden("jrn_def_id","0");
-echo HtmlInput::hidden("jrn_def_id","0");
echo Dossier::hidden();
echo HtmlInput::submit("add_exercice","Ajout d'un exercice comptable");
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r4719 - in phpcompta/trunk/include: . template,
phpcompta-dev <=