[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r600 - in trunk/rapport_avance: include sql
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r600 - in trunk/rapport_avance: include sql |
Date: |
Sun, 8 Dec 2013 21:41:47 +0100 (CET) |
Author: danydb
Date: 2013-12-08 21:41:46 +0100 (Sun, 08 Dec 2013)
New Revision: 600
Added:
trunk/rapport_avance/sql/2-trigger.sql
Modified:
trunk/rapport_avance/include/class_rapav_listing_compute.php
trunk/rapport_avance/include/class_rapav_listing_formula.php
trunk/rapport_avance/include/class_rapport_avance_sql.php
trunk/rapport_avance/include/declaration.inc.php
trunk/rapport_avance/sql/2-listing_compute_detail.sql
Log:
Add order, comment and code into listing_compute_detail
Add fct Rapav_Listing_Formula::display , Rapav_Listing_Formula::keep
Modified: trunk/rapport_avance/include/class_rapav_listing_compute.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_compute.php
2013-12-03 20:40:13 UTC (rev 599)
+++ trunk/rapport_avance/include/class_rapav_listing_compute.php
2013-12-08 20:41:46 UTC (rev 600)
@@ -45,72 +45,80 @@
function compute(RAPAV_Listing &$rapav_listing, $p_date_start, $p_date_end)
{
global $cn;
- // save an object Listing_Compute with the flag to_keep to N
- $this->data->l_start = $p_date_start;
- $this->data->l_end = $p_date_end;
- $this->data->l_keep = 'N';
- $this->data->l_id = $rapav_listing->Data->l_id;
- $this->data->insert();
+ try
+ {
+ // save an object Listing_Compute with the flag to_keep to N
+ $this->data->l_start = $p_date_start;
+ $this->data->l_end = $p_date_end;
+ $this->data->l_keep = 'N';
+ $this->data->l_id = $rapav_listing->Data->l_id;
+ $this->data->insert();
- // retrieve all the code from $rapav_listing
- $rapav_listing->load_detail();
- $a_code = $rapav_listing->a_detail;
+ // retrieve all the code from $rapav_listing
+ $rapav_listing->load_detail();
+ $a_code = $rapav_listing->a_detail;
- // for each code, compute the value must end with the
rapav_listing_compute objects
- $nb = count($a_code);
+ // for each code, compute the value must end with the
rapav_listing_compute objects
+ $nb = count($a_code);
- // ------------------------------------------------------
- // For each card
- $fiche_def = new Fiche_Def($cn);
- $fiche_def->id = $rapav_listing->Data->getp('fiche_def_id');
- $a_fiche = $fiche_def->get_by_type();
- $nb_fiche = count($a_fiche);
- for ($e = 0; $e < $nb_fiche; $e++)
- {
- /*
- * save a listing_compute_fiche
- */
- $fiche=new RAPAV_Listing_Compute_Fiche_SQL();
- $fiche->f_id=$a_fiche[$e]['f_id'];
- $this->lc_id = $this->data->lc_id;
- $fiche->insert();
-
- $a_later = array();
- for ($i = 0; $i < $nb; $i++)
+ // ------------------------------------------------------
+ // For each card
+ $fiche_def = new Fiche_Def($cn);
+ $fiche_def->id = $rapav_listing->Data->getp('fiche_def_id');
+ $a_fiche = $fiche_def->get_by_type();
+ $nb_fiche = count($a_fiche);
+ for ($e = 0; $e < $nb_fiche; $e++)
{
- //Compute if an object either Rapav_Formula_Account,
Rapav_Formula_Attribute,
- // Rapav_Formula_Compute or Rapav_Formula_Formula,
- unset($compute);
- $compute =
RAPAV_Listing_Formula::make_object($a_code[$i]->Param);
- $compute->fiche=$fiche;
-
- if ($compute->sig == 'COMP')
+ /*
+ * save a listing_compute_fiche
+ */
+ $fiche = new RAPAV_Listing_Compute_Fiche_SQL();
+ $fiche->f_id = $a_fiche[$e]['f_id'];
+ $this->lc_id = $this->data->lc_id;
+ $fiche->insert();
+
+ $a_later = array();
+ for ($i = 0; $i < $nb; $i++)
{
- $a_later[] = clone $compute;
- } else
+ //Compute if an object either Rapav_Formula_Account,
Rapav_Formula_Attribute,
+ // Rapav_Formula_Compute or Rapav_Formula_Formula,
+ unset($compute);
+ $compute =
RAPAV_Listing_Formula::make_object($a_code[$i]->Param);
+ $compute->fiche = $fiche;
+
+ if ($compute->sig == 'COMP')
+ {
+ $a_later[] = clone $compute;
+ } else
+ {
+ $compute->set_listing_compute($this->data->lc_id);
+ $compute->filter_operation($this->type_operation);
+
+
+ //compute
+ $compute->compute($p_date_start, $p_date_end);
+ // save computed
+ $compute->save_computed();
+ }
+ }
+ $nb_later = count($a_later);
+
+ /**
+ * for Listing_Formula_compute
+ */
+ for ($i = 0; $i < $nb_later; $i++)
{
$compute->set_listing_compute($this->data->lc_id);
- $compute->filter_operation($this->type_operation);
-
-
- //compute
- $compute->compute($p_date_start, $p_date_end);
- // save computed
- $compute->save_computed();
+ $a_later[$i]->compute($p_date_start, $p_date_end);
+ $a_later[$i]->save_computed();
}
}
- $nb_later = count($a_later);
-
- /**
- * for Listing_Formula_compute
- */
- for ($i = 0; $i < $nb_later; $i++)
- {
- $compute->set_listing_compute($this->data->lc_id);
- $a_later[$i]->compute($p_date_start, $p_date_end);
- $a_later[$i]->save_computed();
- }
+ } catch (Exception $e)
+ {
+ $cn->rollback();
+ throw $e;
}
+ $cn->commit();
}
/**
@@ -127,7 +135,51 @@
function display()
{
-
+ global $cn;
+ $ofiche=new RAPAV_Listing_Compute_Fiche_SQL();
+ $r_fiche=$ofiche->seek (" where lc_id = $1",array($this->data->lc_id));
+ $nb_fiche=Database::num_row($r_fiche);
+
+ /* For each card */
+ for ($i = 0;$i < $nb_fiche;$i++)
+ {
+ $fiche=$ofiche->next($r_fiche,$i);
+
+ $odetail=new RAPAV_Listing_Compute_Detail_SQL();
+ $r_detail=$odetail->seek(" where lf_id=$1 order by
lc_order",array($fiche->lf_id));
+ $nb_detail=Database::num_row($r_detail);
+ // table header
+ if ($nb_detail > 0 && $i == 0)
+ {
+ echo '<table style="min-width:100%" class="result">';
+ echo '<tr>';
+ for ($e=0;$e<$nb_detail;$e++)
+ {
+ $detail=$odetail->next($r_detail,$e);
+ echo th( $detail->lc_code);
+ }
+ echo '</tr>';
+ }
+ /** for each detail */
+ echo '<tr>';
+ for ($e=0;$e <$nb_detail;$e++)
+ {
+ $detail=$odetail->next($r_detail,$e);
+
+ echo (($detail->ld_value_numeric !==
null)?td(nbm($detail->ld_value_numeric),'class="num"'):"");
+ echo (($detail->ld_value_text !==
null)?td($detail->ld_value_text):"");
+ echo (($detail->ld_value_date!==
null)?td($detail->ld_value_date):"");
+ }
+ echo '</tr>';
+ }
+ echo '</table>';
}
+ function keep($p_id)
+ {
+ $this->data->lc_id=$p_id;
+ $this->data->load();
+ $this->data->l_keep='Y';
+ $this->data->save();
+ }
}
Modified: trunk/rapport_avance/include/class_rapav_listing_formula.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_formula.php
2013-12-03 20:40:13 UTC (rev 599)
+++ trunk/rapport_avance/include/class_rapav_listing_formula.php
2013-12-08 20:41:46 UTC (rev 600)
@@ -28,7 +28,11 @@
{
$this->detail->lf_id = $this->fiche->lf_id;
$this->detail->lp_id = $this->data->lp_id;
+ $this->detail->lc_code = $this->data->lp_code;
+ $this->detail->lc_comment = $this->data->lp_comment;
+ $this->detail->lc_order = $this->data->l_order;
$this->detail->save();
+ $this->fiche->save();
}
function set_listing_compute($param)
@@ -106,10 +110,6 @@
$this->fiche->f_id = $f_id;
}
- function save_fiche()
- {
- $this->fiche->save();
- }
function filter_operation($param)
{
Modified: trunk/rapport_avance/include/class_rapport_avance_sql.php
===================================================================
--- trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-12-03
20:40:13 UTC (rev 599)
+++ trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-12-08
20:41:46 UTC (rev 600)
@@ -544,6 +544,9 @@
var $ld_value_text;
var $lp_id;
var $lf_id;
+ var $lc_code;
+ var $lc_comment;
+ var $lc_order;
/* example private
$variable=array("easy_name"=>column_name,"email"=>"column_name_email","val3"=>0);
*/
@@ -561,6 +564,9 @@
, "ld_value_text" => "ld_value_text"
, "lp_id" => "lp_id"
, "lf_id" => "lf_id"
+ ,'code'=>'lc_code'
+ ,'comment'=>'lc_comment'
+ ,'order'=>'lc_order'
);
$this->type = array(
@@ -571,6 +577,9 @@
, "ld_value_text" => "text"
, "lp_id" => "numeric"
, "lf_id" => "numeric"
+ , 'lc_code'=>"text"
+ , 'lc_comment'=>"text"
+ , 'lc_order'=>"numeric"
);
$this->default = array(
Modified: trunk/rapport_avance/include/declaration.inc.php
===================================================================
--- trunk/rapport_avance/include/declaration.inc.php 2013-12-03 20:40:13 UTC
(rev 599)
+++ trunk/rapport_avance/include/declaration.inc.php 2013-12-08 20:41:46 UTC
(rev 600)
@@ -84,6 +84,16 @@
exit();
}
}
+/**
+ * Save listing now you can export them to csv and generate file if any
+ */
+if ( isset($_POST['save_listing']))
+{
+ $listing=new RAPAV_Listing_Compute();
+ $listing->keep($_POST['lc_id']);
+ $listing->display();
+ exit();
+}
/*
* compute listing
*/
@@ -100,6 +110,7 @@
$listing->filter_operation($_GET['p_operation_paid']);
$listing->compute($p_listing, $_GET['p_start'], $_GET['p_end']);
echo '<form class="print" method="POST">';
+ echo HtmlInput::hidden('lc_id',$listing->lc_id);
$listing->display();
echo HtmlInput::submit('save_listing', 'Sauver');
echo '</form>';
@@ -150,12 +161,12 @@
?>
<div id="Choix">
<h2>Choisissez ce que vous souhaitez générer</h2>
- <table style="border-collapse: collapse;width: 40%">
+ <table style="border-collapse: separate;width: 40%">
<tr >
- <td id="rapport_td_id" class="mtitle" style="border-radius:0">
+ <td id="rapport_td_id" class="mtitle"
style="border-radius:0;border-bottom:
2;border-top:0;border-left:0;border-right:0">
<A class="mtitle" HREF="javascript:void(0)"
onclick="select_rapport();"> Rapport</A>
</td>
- <td id="listing_td_id" class="mtitle" style="border-radius:0">
+ <td id="listing_td_id" class="mtitle"
style="border-radius:0;border-bottom:
2;border-top:0;border-left:0;border-right:0">
<A class="mtitle"
HREF="javascript:void(0)"onclick="select_listing();"> Listing / Documents</A>
</td>
</tr>
Modified: trunk/rapport_avance/sql/2-listing_compute_detail.sql
===================================================================
--- trunk/rapport_avance/sql/2-listing_compute_detail.sql 2013-12-03
20:40:13 UTC (rev 599)
+++ trunk/rapport_avance/sql/2-listing_compute_detail.sql 2013-12-08
20:41:46 UTC (rev 600)
@@ -11,6 +11,9 @@
ld_value_text text, -- Used when computed value is a text
lp_id bigint, -- fk to listing_param, used for the condition
lf_id bigint, -- FK to listing_compute_fiche
+ lc_code text,
+ lc_comment text,
+ lc_order bigint,
CONSTRAINT listing_compute_detail_pkey PRIMARY KEY (ld_id ),
CONSTRAINT listing_compute_detail_lc_id_fkey FOREIGN KEY (lc_id)
REFERENCES rapport_advanced.listing_compute (lc_id) MATCH SIMPLE
@@ -33,6 +36,9 @@
COMMENT ON COLUMN rapport_advanced.listing_compute_detail.ld_value_text IS
'Used when computed value is a text';
COMMENT ON COLUMN rapport_advanced.listing_compute_detail.lp_id IS 'fk to
listing_param, used for the condition';
COMMENT ON COLUMN rapport_advanced.listing_compute_detail.lf_id IS 'FK to
listing_compute_fiche';
+COMMENT ON COLUMN rapport_advanced.listing_compute_detail.lc_code IS 'code
from listing_param';
+COMMENT ON COLUMN rapport_advanced.listing_compute_detail.lc_comment IS
'comment from listing_param';
+COMMENT ON COLUMN rapport_advanced.listing_compute_detail.lc_order IS 'order
from listing_param';
-- Index: rapport_advanced.fki_listing_compute_fiche_lf_id2_fk
Added: trunk/rapport_avance/sql/2-trigger.sql
===================================================================
--- trunk/rapport_avance/sql/2-trigger.sql (rev 0)
+++ trunk/rapport_avance/sql/2-trigger.sql 2013-12-08 20:41:46 UTC (rev
600)
@@ -0,0 +1,15 @@
+CREATE OR REPLACE FUNCTION rapport_advanced.listing_compute_trg()
+ returns trigger
+ as
+$_BODY_$
+declare
+begin
+ NEW.l_timestamp=now() ;
+return NEW;
+end;
+$_BODY_$ LANGUAGE plpgsql;
+CREATE TRIGGER listing_compute_trg
+ BEFORE
+ INSERT OR UPDATE
+ on rapport_advanced.listing_compute
+ FOR EACH ROW EXECUTE PROCEDURE rapport_advanced.listing_compute_trg();
---
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] r600 - in trunk/rapport_avance: include sql,
phpcompta-dev <=