[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r494 - in trunk/rapport_avance/include: . template
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r494 - in trunk/rapport_avance/include: . template |
Date: |
Wed, 8 May 2013 01:57:45 +0200 (CEST) |
Author: danydb
Date: 2013-05-08 01:57:44 +0200 (Wed, 08 May 2013)
New Revision: 494
Modified:
trunk/rapport_avance/include/class_rapav_declaration.php
trunk/rapport_avance/include/class_rapav_formulaire.php
trunk/rapport_avance/include/class_rapport_avance_sql.php
trunk/rapport_avance/include/declaration.inc.php
trunk/rapport_avance/include/template/declaration_display.php
trunk/rapport_avance/include/template/formulaire_definition.php
Log:
Task #0000818: Possibilit?\195?\169 d'avoir des ?\195?\169tapes dans
d?\195?\169claration
Ajout 7 jours, 14 jours, 1 mois, 3 mois
Modified: trunk/rapport_avance/include/class_rapav_declaration.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_declaration.php 2013-05-06
23:50:07 UTC (rev 493)
+++ trunk/rapport_avance/include/class_rapav_declaration.php 2013-05-07
23:57:44 UTC (rev 494)
@@ -50,8 +50,9 @@
static function to_csv($p_id)
{
global $cn;
- $a_row=$cn->get_array('select dr_code,dr_libelle,dr_amount from
rapport_advanced.declaration_row
- where d_id=$1 order by dr_order',array($p_id));
+ $a_row=$cn->get_array('select
dr_code,dr_libelle,dr_amount,dr_start,dr_end
+ from rapport_advanced.declaration_row
+ where d_id=$1 order by dr_order,dr_start',array($p_id));
$a_title=$cn->get_array("select d_title
,to_char(d_start,'DD.MM.YYYY') as start
@@ -72,10 +73,12 @@
for ($i = 0; $i < count($a_row); $i++)
{
- printf ('"%s";"%s";%s'."\r\n",
+ printf ('"%s";"%s";%s;"%s";"%s"'."\r\n",
$a_row[$i]['dr_code'],
$a_row[$i]['dr_libelle'],
- nb($a_row[$i]['dr_amount'])
+ nb($a_row[$i]['dr_amount']),
+ format_date($a_row[$i]['dr_start']),
+ format_date($a_row[$i]['dr_end'])
);
}
}
@@ -315,7 +318,15 @@
}
- function compute($p_id, $p_start, $p_end)
+ /**
+ *
+ * @global $cn $cn
+ * @param type $p_id
+ * @param type $p_start
+ * @param type $p_end
+ * @param type $p_step
+ */
+ function compute($p_id, $p_start, $p_end,$p_step)
{
global $cn;
$cn->start();
@@ -333,6 +344,7 @@
$this->d_filename=$this->form->f_filename;
$this->d_mimetype=$this->form->f_mimetype;
$this->d_size=$this->form->f_size;
+ $this->d_step=$p_step;
$this->insert();
/*
* First we compute the formula and tva_code for each detail
@@ -341,38 +353,90 @@
from rapport_advanced.formulaire_param
where
f_id=$1
- and p_type =3
order by p_order", array($p_id));
- for ($i = 0; $i < count($array); $i++)
- {
- $row = new Rapav_Declaration_Param();
- $row->d_id = $this->d_id;
- $row->dr_id =
$cn->get_next_seq('rapport_advanced.declaration_param_seq');
- $row->from_array($array[$i]);
- $row->compute($p_start, $p_end);
- $row->insert();
- }
-
/**
- * Add the lines missing lines
+ * if step != 0, recompute the date
*/
- $array = $cn->get_array("select
fp.p_id,p_code,p_libelle,p_type,p_order,f_id,t_id
- from rapport_advanced.formulaire_param as fp
- where
- f_id=$1
- and p_type in (1,2,6,7,8)", array($p_id));
- for ($i = 0; $i < count($array); $i++)
+ if ($p_step == 0)
{
- $row = new Rapav_Declaration_Param();
- $row->d_id = $this->d_id;
- $row->dr_id =
$cn->get_next_seq('rapport_advanced.declaration_param_seq');
- $row->from_array($array[$i]);
- $row->amount = 0;
- $row->insert();
+ // compute each row
+ for ($i = 0; $i < count($array); $i++)
+ {
+ $row = new Rapav_Declaration_Param();
+ $row->d_id = $this->d_id;
+ $row->dr_id =
$cn->get_next_seq('rapport_advanced.declaration_param_seq');
+ $row->from_array($array[$i]);
+ if ( $array[$i]['p_type']==3) {
+ $row->compute($p_start, $p_end);
+ } else {
+ $row->amount = 0;
+ }
+ $row->dr_start=$p_start;
+ $row->dr_end=$p_end;
+ $row->insert();
+ }
}
+ else
+ {
+ // compute new date, stored in $this->start and
$this->end
+ while ($this->compute_interval($p_start, $p_end,
$p_step) == 1)
+ {
+ for ($i = 0; $i < count($array); $i++)
+ {
+ $row = new Rapav_Declaration_Param();
+ $row->d_id = $this->d_id;
+ $row->dr_id =
$cn->get_next_seq('rapport_advanced.declaration_param_seq');
+ $row->from_array($array[$i]);
+ if ($array[$i]['p_type'] == 3)
+ {
+ $row->compute($this->start,
$this->end);
+ $row->dr_start=$this->start;
+ $row->dr_end=$this->end;
+ $row->insert();
+ }
+ }
+ }
+
+ }
$cn->commit();
}
+ function compute_interval($p_start, $p_end, $p_step)
+ {
+ static $s_start = "";
+ static $s_count = 0;
+
+ if ($s_start == "")
+ {
+ $s_start = $p_start;
+ }
+ $s_count++;
+ // initialize datetime object
+ $date_start = new DateTime(format_date($s_start, 'DD.MM.YYYY',
'YYYY/MM/DD'));
+ $date_end = new DateTime(format_date($s_start, 'DD.MM.YYYY',
'YYYY/MM/DD'));
+ $date_finish = new DateTime(format_date($p_end, 'DD.MM.YYYY',
'YYYY/MM/DD'));
+
+ $add = $this->get_interval($p_step);
+
+
+ if ($s_count > 1) { $date_start->add($add);
$date_end->add($add);}
+ // compute date_end
+ $date_end->add($add);
+ $date_end->sub(new DateInterval('P1D'));
+
+ // if date_end > date_finish then stop
+ if ($date_end > $date_finish) return 0;
+
+ $this->start = $date_start->format("d.m.Y");
+ $this->end = $date_end->format("d.m.Y");
+ $s_start = $this->start;
+ return 1;
+ }
+ function get_interval($p_step)
+ {
+ $array_interval=array("","P7D","P14D","P1M","P3M");
+ return new DateInterval($array_interval[$p_step]);
+ }
function anchor_document()
{
$url=HtmlInput::request_to_string(array('gDossier','ac','plugin_code'));
@@ -382,7 +446,7 @@
function display()
{
global $cn;
- $array = $cn->get_array('select * from
rapport_advanced.declaration_row where d_id=$1 order by dr_order',
array($this->d_id));
+ $array = $cn->get_array('select * from
rapport_advanced.declaration_row where d_id=$1 order by dr_order,dr_start',
array($this->d_id));
require_once 'template/declaration_display.php';
}
@@ -430,6 +494,8 @@
$data->d_id = $this->d_id;
$data->dr_id = $this->dr_id;
$data->dr_type = $this->param->p_type;
+ $data->dr_start=$this->dr_start;
+ $data->dr_end=$this->dr_end;
$data->insert();
}
@@ -469,55 +535,55 @@
function compute_date($p_start, $p_end)
{
global $g_user;
- switch ($this->param->t_id)
- {
- case 1:
- $this->start = $p_start;
- $this->end = $p_end;
+ switch ($this->param->t_id)
+ {
+ case 1:
+ $this->start = $p_start;
+ $this->end = $p_end;
return;
- break;
- case 2:
- list($this->start, $this->end) =
$g_user->get_limit_current_exercice();
+ break;
+ case 2:
+ list($this->start, $this->end) =
$g_user->get_limit_current_exercice();
return;
- break;
- case 3:
- $exercice = $g_user->get_exercice();
- $exercice--;
- break;
- case 4:
- $exercice = $g_user->get_exercice();
- $exercice-=2;
- break;
- case 5:
- $exercice = $g_user->get_exercice();
- $exercice-=3;
- break;
- case 6:
- list($this->start, $this->end) =
$g_user->get_limit_current_exercice();
+ break;
+ case 3:
+ $exercice = $g_user->get_exercice();
+ $exercice--;
+ break;
+ case 4:
+ $exercice = $g_user->get_exercice();
+ $exercice-=2;
+ break;
+ case 5:
+ $exercice = $g_user->get_exercice();
+ $exercice-=3;
+ break;
+ case 6:
+ list($this->start, $this->end) =
$g_user->get_limit_current_exercice();
$this->end=$p_end;
return;
- break;
- default:
- throw new Exception('compute_date : t_id est
incorrect');
- }
- global $cn;
+ break;
+ default:
+ throw new Exception('compute_date :
t_id est incorrect');
+ }
+ global $cn;
- // If exercice does not exist then
- // set the date end and start to 01.01.1900
+ // If exercice does not exist then
+ // set the date end and start to 01.01.1900
- $exist_exercice = $cn->get_value('select count(p_id) from
parm_periode where p_exercice=$1', array($exercice));
- if ($exist_exercice == 0)
- {
- $this->start = '01.01.1900';
- $this->end = '01.01.1900';
+ $exist_exercice = $cn->get_value('select count(p_id)
from parm_periode where p_exercice=$1', array($exercice));
+ if ($exist_exercice == 0)
+ {
+ $this->start = '01.01.1900';
+ $this->end = '01.01.1900';
return;
+ }
+ // Retrieve start & end date
+ $periode = new Periode($cn);
+ list($per_start, $per_end) =
$periode->get_limit($exercice);
+ $this->start = $per_start->first_day();
+ $this->end = $per_end->last_day();
}
- // Retrieve start & end date
- $periode = new Periode($cn);
- list($per_start, $per_end) = $periode->get_limit($exercice);
- $this->start = $per_start->first_day();
- $this->end = $per_end->last_day();
- }
/* * *
* @brief compute amount of all the detail of
apport_advanced.formulaire_param
Modified: trunk/rapport_avance/include/class_rapav_formulaire.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_formulaire.php 2013-05-06
23:50:07 UTC (rev 493)
+++ trunk/rapport_avance/include/class_rapav_formulaire.php 2013-05-07
23:57:44 UTC (rev 494)
@@ -148,7 +148,6 @@
{
for ($i=0;$i<count($p_array['del_row']);$i++)
{
- echo $p_array['del_row'][$i];
if (isNumber($p_array['del_row'][$i]) == 1 &&
$p_array['del_row'][$i]!=-1) {
$cn->exec_sql('delete from
rapport_advanced.formulaire_param where
p_id=$1',array($p_array['del_row'][$i]));
}
Modified: trunk/rapport_avance/include/class_rapport_avance_sql.php
===================================================================
--- trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-05-06
23:50:07 UTC (rev 493)
+++ trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-05-07
23:57:44 UTC (rev 494)
@@ -176,7 +176,8 @@
"d_filename"=>"d_filename",
"d_mimetype"=>"d_mimetype",
"d_size"=>"d_size",
- "f_id"=>"f_id"
+ "f_id"=>"f_id",
+ 'd_step'=>'d_step'
);
$this->type = array(
@@ -192,7 +193,7 @@
"d_filename"=>"text",
"d_mimetype"=>"text",
"d_size"=>"numeric",
-
+ 'd_step'=>'numeric'
);
$this->default = array(
@@ -222,7 +223,9 @@
"dr_order"=>"dr_order",
"dr_code"=>"dr_code",
"dr_amount"=>"dr_amount",
- "dr_type"=>"dr_type"
+ "dr_type"=>"dr_type",
+ "dr_start"=>"dr_start",
+ "dr_end"=>"dr_end"
);
$this->type = array(
@@ -232,14 +235,15 @@
"dr_order"=>"text",
"dr_code"=>"numeric",
"dr_amount"=>"numeric",
- "dr_type"=>"numeric"
-
+ "dr_type"=>"numeric",
+ "dr_start"=>"date",
+ "dr_end"=>"date"
);
$this->default = array(
);
global $cn;
-
+ $this->date_format='DD.MM.YYYY';
parent::__construct($cn, $p_id);
}
}
Modified: trunk/rapport_avance/include/declaration.inc.php
===================================================================
--- trunk/rapport_avance/include/declaration.inc.php 2013-05-06 23:50:07 UTC
(rev 493)
+++ trunk/rapport_avance/include/declaration.inc.php 2013-05-07 23:57:44 UTC
(rev 494)
@@ -39,14 +39,14 @@
$decl->to_keep = 'Y';
$decl->f_id = $_POST['p_form'];
$decl->save();
- $decl->generate_document();
+ if ( $decl->d_step == 0 ) $decl->generate_document();
$decl->display();
echo '<p class="notice">'._(' Sauvé ').date('d-m-Y H:i').'</p>';
$ref_csv = HtmlInput::array_to_string(array('gDossier', 'plugin_code',
'd_id'), $_REQUEST, 'extension.raw.php?');
$ref_csv.="&act=export_decla_csv";
echo HtmlInput::button_anchor("Export CSV", $ref_csv, 'export_id');
- if ( $decl->d_filename != '' ) echo $decl->anchor_document();
+ if ( $decl->d_filename != '' && $decl->d_step==0) echo
$decl->anchor_document();
exit();
}
/*
@@ -62,7 +62,7 @@
else
{
$decl->d_description=$_GET['p_description'];
- $decl->compute($_GET['p_form'], $_GET['p_start'],
$_GET['p_end']);
+ $decl->compute($_GET['p_form'], $_GET['p_start'],
$_GET['p_end'],$_GET['p_step']);
echo '<form class="print" method="POST">';
echo HtmlInput::hidden('p_form', $_GET['p_form']);
$decl->display();
@@ -76,8 +76,18 @@
$hidden = HtmlInput::array_to_hidden(array('gDossier', 'ac', 'plugin_code',
'sa'), $_GET);
$select = new ISelect('p_form');
$select->value = $cn->make_array('select f_id,f_title from
rapport_advanced.formulaire order by 2');
-$description=new IText('p_description');
-$description->size=80;
+$description=new ITextArea('p_description');
+$description->heigh=2;
+$description->width=80;
+
+$istep=new ISelect('p_step');
+$istep->value=array(
+ array('label'=>'Aucun','value'=>0),
+ array('label'=>'7 jours','value'=>1),
+ array('label'=>'14 jours','value'=>2),
+ array('label'=>'1 mois','value'=>3),
+ array('label'=>'3 mois','value'=>4)
+ );
?>
<form id="declaration_form_id" method="GET" onsubmit="return validate()">
<?= $hidden?>
@@ -90,9 +100,9 @@
<?= $select->input()?>
</td>
</tr>
- </table>
- <p> Description <?=$description->input()?>
- <table>
+ <tr>
+ <td> Description</td><td> <?=$description->input()?></td>
+ </tr>
<tr>
<td>
Date de début
@@ -109,6 +119,14 @@
<?= $date_end->input()?>
</td>
</tr>
+ <tr>
+ <td>
+ Etape de
+ </td>
+ <td>
+ <?= $istep->input()?>
+ </td>
+ </tr>
</table>
</p>
<?= HtmlInput::submit('compute', 'Générer')?>
Modified: trunk/rapport_avance/include/template/declaration_display.php
===================================================================
--- trunk/rapport_avance/include/template/declaration_display.php
2013-05-06 23:50:07 UTC (rev 493)
+++ trunk/rapport_avance/include/template/declaration_display.php
2013-05-07 23:57:44 UTC (rev 494)
@@ -39,6 +39,7 @@
echo HtmlInput::hidden('d_id',$this->d_id);
for ($i=0;$i<count($array);$i++):
$row=$array[$i];
+if ($this->d_step <> 0 ) $per= $row['dr_start']." : ".$row['dr_end'];
switch($row['dr_type'])
{
case 1:
@@ -54,7 +55,7 @@
$input=new INum('amount[]',$row['dr_amount']);
$input->size=15;
echo HtmlInput::hidden('code[]',$row['dr_id']);
- echo '<p>'.$row['dr_code']." ".$row['dr_libelle']." =
".$input->input().'</p>';
+ echo '<p>'.$row['dr_code']." ".$row['dr_libelle']." =
".$input->input()." $per ".' </p>';
break;
case 7:
echo '<p>'.$row['dr_libelle'].'</p>';
@@ -64,5 +65,6 @@
break;
}
+
endfor;
?>
\ No newline at end of file
Modified: trunk/rapport_avance/include/template/formulaire_definition.php
===================================================================
--- trunk/rapport_avance/include/template/formulaire_definition.php
2013-05-06 23:50:07 UTC (rev 493)
+++ trunk/rapport_avance/include/template/formulaire_definition.php
2013-05-07 23:57:44 UTC (rev 494)
@@ -33,7 +33,7 @@
<thead>
<tr>
<th>
- A effacer
+ Effacer
</th>
<th style="width:92px">
Code <?=HtmlInput::infobulle(200)?>
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r494 - in trunk/rapport_avance/include: . template,
phpcompta-dev <=