[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r595 - in trunk/rapport_avance: . include sql
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r595 - in trunk/rapport_avance: . include sql |
Date: |
Tue, 3 Dec 2013 03:28:16 +0100 (CET) |
Author: danydb
Date: 2013-12-03 03:28:15 +0100 (Tue, 03 Dec 2013)
New Revision: 595
Added:
trunk/rapport_avance/include/class_rapav_listing_compute.php
trunk/rapport_avance/sql/2-add-compute.sql
trunk/rapport_avance/sql/2-listing_compute.sql
trunk/rapport_avance/sql/2-listing_compute_detail.sql
trunk/rapport_avance/sql/2-listing_compute_fiche.sql
trunk/rapport_avance/sql/2-listing_condition.sql
Modified:
trunk/rapport_avance/ajax_listing_param_add.php
trunk/rapport_avance/ajax_save_param_listing.php
trunk/rapport_avance/include/class_formulaire_param_detail.php
trunk/rapport_avance/include/class_rapav.php
trunk/rapport_avance/include/class_rapav_declaration.php
trunk/rapport_avance/include/class_rapav_listing.php
trunk/rapport_avance/include/class_rapav_listing_formula.php
trunk/rapport_avance/include/class_rapav_listing_param.php
trunk/rapport_avance/include/class_rapport_avance_sql.php
trunk/rapport_avance/include/declaration.inc.php
trunk/rapport_avance/rapav_constant.php
Log:
Listing : progress
can compute and save for attribute
Modified: trunk/rapport_avance/ajax_listing_param_add.php
===================================================================
--- trunk/rapport_avance/ajax_listing_param_add.php 2013-12-01 19:54:09 UTC
(rev 594)
+++ trunk/rapport_avance/ajax_listing_param_add.php 2013-12-03 02:28:15 UTC
(rev 595)
@@ -8,7 +8,7 @@
ob_start();
echo HtmlInput::title_box("Nouveau paramètre", $cin);
$obj=new RAPAV_Listing($id);
-$obj->add_parameter();
+$obj->add_parameter($id);
$response = ob_get_contents();
ob_end_clean();
$html = escape_xml($response);
Modified: trunk/rapport_avance/ajax_save_param_listing.php
===================================================================
--- trunk/rapport_avance/ajax_save_param_listing.php 2013-12-01 19:54:09 UTC
(rev 594)
+++ trunk/rapport_avance/ajax_save_param_listing.php 2013-12-03 02:28:15 UTC
(rev 595)
@@ -109,7 +109,7 @@
break;
case 'new_attribute_id':
ob_start();
- $attr = new RAPAV_Formula_Attribute($formula, $listing_id);
+ $attr = new RAPAV_Formula_Attribute($formula);
$attr->save($_GET);
$attr->load();
$lp_id = $attr->data->getp("lp_id");
@@ -117,8 +117,8 @@
$html = "";
echo td($attr->display_code());
echo td($attr->display_comment());
+ echo td($attr->display());
echo td($attr->display_order());
- echo td($attr->display());
$html.=ob_get_contents();
ob_end_clean();
$html.='<td>';
Modified: trunk/rapport_avance/include/class_formulaire_param_detail.php
===================================================================
--- trunk/rapport_avance/include/class_formulaire_param_detail.php
2013-12-01 19:54:09 UTC (rev 594)
+++ trunk/rapport_avance/include/class_formulaire_param_detail.php
2013-12-03 02:28:15 UTC (rev 595)
@@ -72,17 +72,10 @@
function verify()
{
- if (Impress::check_formula($this->fp_formula) == false)
- {
- $this->errcode = "Erreur dans votre formule";
- return 1;
- }
- if (trim($this->fp_formula) == "")
- {
- $this->errcode = " Aucune formule trouvée";
- return 1;
- }
- return 0;
+ global $errcode;
+ $ret = RAPAV::verify_compute($this->fp_formula);
+ $this->errocode=$errcode;
+ return $ret;
}
}
@@ -176,30 +169,10 @@
function verify()
{
-
- if (trim($this->fp_formula) == "")
- {
- $this->errcode = " Aucune formule trouvée";
- return 1;
- }
-
- // copy $this->form->fp_formula to a variable
- $formula = $this->fp_formula;
-
- // remove the valid
- preg_match_all("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", $formula, $e);
- $formula = preg_replace("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", '',
$formula);
- $formula = preg_replace('/([0-9]+.{0,1}[0.9]*)*(\+|-|\*|\/)*/', '',
$formula);
- $formula = preg_replace('/(\(|\))/', '', $formula);
- $formula = preg_replace('/\s/', '', $formula);
-
- // if something remains it should be a mistake
- if ($formula != '')
- {
- $this->errcode = " Erreur dans la formule " . $formula;
- return 1;
- }
- return 0;
+ global $errcode;
+ $ret = RAPAV::verify_compute($this->p_formula);
+ $this->errocode=$errcode;
+ return $ret;
}
}
Modified: trunk/rapport_avance/include/class_rapav.php
===================================================================
--- trunk/rapport_avance/include/class_rapav.php 2013-12-01 19:54:09 UTC
(rev 594)
+++ trunk/rapport_avance/include/class_rapav.php 2013-12-03 02:28:15 UTC
(rev 595)
@@ -33,6 +33,7 @@
}
return $ledger;
}
+
/**
* display a choice of ledger
* @global cn
@@ -47,6 +48,7 @@
echo '<p> Filtrage par journal ' . $select->input() . '</p>';
}
+
/**
* Display a select for the date
*/
@@ -54,7 +56,7 @@
{
$s_date = new ISelect('p_paid');
$s_date->value = array();
- $s_date->value[] = array("value" => 0, "label" => 'Date calendrier');
+ $s_date->value[] = array("value" => 0, "label" => 'Date d\'opération');
$s_date->value[] = array("value" => 1, "label" => 'Date de paiement');
$s_date->value[] = array("value" => 2, "label" => 'Date d\'échéance');
echo '<p> Si la date donnée concerne la date de paiement ou
d\'écheance, cela limitera la recherche aux journaux VEN et ACH ';
@@ -62,6 +64,7 @@
echo $s_date->input();
echo '</p>';
}
+
/**
* Compute the string to display for date
* @param $p_type
@@ -127,4 +130,55 @@
return $sql_date;
}
+ /**
+ * @brief check if the formula is valid, return 1 for an error
+ * and set errcode to the error msg
+ * errcode is global variable
+ */
+ static function verify_compute($p_formula)
+ {
+ global $errcode;
+ $errcode = "";
+ if (trim($p_formula) == "")
+ {
+ $errcode = " Aucune formule trouvée";
+ return 1;
+ }
+
+ // copy $this->form->fp_formula to a variable
+ $formula = $p_formula;
+
+ // remove the valid
+ preg_match_all("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", $formula, $e);
+ $formula = preg_replace("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", '',
$formula);
+ $formula = preg_replace('/([0-9]+.{0,1}[0.9]*)*(\+|-|\*|\/)*/', '',
$formula);
+ $formula = preg_replace('/(\(|\))/', '', $formula);
+ $formula = preg_replace('/\s/', '', $formula);
+
+ // if something remains it should be a mistake
+ if ($formula != '')
+ {
+ $errcode = " Erreur dans la formule " . $formula;
+ return 1;
+ }
+ return 0;
+ }
+
+ static function verify_formula($p_formula)
+ {
+ global $errcode;
+ $errcode = "";
+ if (Impress::check_formula($p_formula) == false)
+ {
+ $errcode = "Erreur dans votre formule";
+ return 1;
+ }
+ if (trim($p_formula) == "")
+ {
+ $errcode = " Aucune formule trouvée";
+ return 1;
+ }
+ return 0;
+ }
+
}
Modified: trunk/rapport_avance/include/class_rapav_declaration.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_declaration.php 2013-12-01
19:54:09 UTC (rev 594)
+++ trunk/rapport_avance/include/class_rapav_declaration.php 2013-12-03
02:28:15 UTC (rev 595)
@@ -832,22 +832,7 @@
$filter_ledger = " and j_jrn_def = " .
sql_string($this->form->jrn_def_id);
}
$sql_date=RAPAV::get_sql_date($this->form->date_paid );
-/*
- if ($this->form->date_paid == 1)
- {
- $sql_date=" and j_id in
- (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
- where
- coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY'))
>= to_date($2,'DD.MM.YYYY')
- and
coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY')) <=
to_date($3,'DD.MM.YYYY')
- )
- ";
-
- }
- else
- {
- $sql_date="and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <=
to_date($3,'DD.MM.YYYY'))";
- }*/
+
if ($this->form->jrn_def_type == 'ACH')
{
@@ -899,22 +884,7 @@
$filter_ledger = " and j_jrn_def = " .
sql_string($this->form->jrn_def_id);
}
$sql_date=RAPAV::get_sql_date($this->form->date_paid );
-/*
- if ($this->form->date_paid == 1)
- {
- $sql_date=" and j_id in
- (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
- where
- coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY'))
>= to_date($2,'DD.MM.YYYY')
- and
coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY')) <=
to_date($3,'DD.MM.YYYY')
- )
- ";
-
- }
- else
- {
- $sql_date="and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <=
to_date($3,'DD.MM.YYYY'))";
- }*/
+
if ($this->form->jrn_def_type == 'ACH')
{
$sql = "select coalesce(sum(qp_price),0) as amount from
quant_purchase join jrnx as jrn1 using (j_id)
@@ -1009,21 +979,7 @@
}
$sql_date=RAPAV::get_sql_date($this->form->date_paid );
- /*if ($this->form->date_paid == 1)
- {
- $sql_date=" and j_id in
- (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
- where
- coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY'))
>= to_date($3,'DD.MM.YYYY')
- and
coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY')) <=
to_date($4,'DD.MM.YYYY')
- )
- ";
-
- }
- else
- {
- $sql_date="and (jrn1.j_date >= to_date($3,'DD.MM.YYYY') and
jrn1.j_date <= to_date($4,'DD.MM.YYYY'))";
- }*/
+
bcscale(2);
switch ($this->form->type_sum_account)
{
Modified: trunk/rapport_avance/include/class_rapav_listing.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing.php 2013-12-01
19:54:09 UTC (rev 594)
+++ trunk/rapport_avance/include/class_rapav_listing.php 2013-12-03
02:28:15 UTC (rev 595)
@@ -13,18 +13,26 @@
*/
require_once 'class_rapport_avance_sql.php';
require_once 'class_rapav_listing_param.php';
-class Rapav_Listing {
- private $Data; /*!< RAPAV_Listing_SQL */
- private $a_detail; /*!< array of RAPAV_Listing_Param corresponding to the
listing*/
- function __construct($p_id = -1) {
+
+class Rapav_Listing
+{
+
+ public $Data; /* !< RAPAV_Listing_SQL */
+ public $a_detail; /* !< array of RAPAV_Listing_Param corresponding to the
listing */
+
+
+
+ function __construct($p_id = -1)
+ {
$this->Data = new RAPAV_Listing_SQL($p_id);
- $this->a_detail=array();
+ $this->a_detail = array();
}
/**
* display a list of the existing list
*/
- function to_list() {
+ function to_list()
+ {
$res = $this->Data->seek('join fiche_def using (fd_id) order by
l_name');
require 'template/rapav_listing_to_list.php';
}
@@ -32,7 +40,8 @@
/**
* Display a button for adding a new listing
*/
- static function Button_Add_Listing() {
+ static function Button_Add_Listing()
+ {
$arg = array(
'gDossier' => Dossier::id(),
'ac' => $_REQUEST['ac'],
@@ -48,11 +57,12 @@
* @brief display a form to save a new list
*
*/
- function form_modify() {
+ function form_modify()
+ {
global $cn;
$name = new IText('name');
$description = new ITextArea('description');
- $description->style=' style="margin:0px;width:100%" class="itextarea"';
+ $description->style = ' style="margin:0px;width:100%"
class="itextarea"';
$file = new IFile('listing_mod');
$fichedef = new ISelect('fiche_def');
$fichedef->value = $cn->make_array('select fd_id,fd_label from
fiche_def order by fd_label');
@@ -60,14 +70,16 @@
/*
* if $this->l_id <> -1 then modification otherwise add
*/
- if ($this->Data->l_id <> -1) {
+ if ($this->Data->l_id <> -1)
+ {
$name->value = $this->Data->l_name;
$description->value = $this->Data->l_description;
$fichedef->selected = $this->Data->fd_id;
$ck = new ICheckBox('remove');
$str_remove = " Cochez pour effacer " . $ck->input();
// If there is a file
- if ($this->Data->l_filename != "") {
+ if ($this->Data->l_filename != "")
+ {
$file = new ISpan('listing_mod_id');
// Add js for removing
$arg = array(
@@ -91,11 +103,14 @@
* @param type $p_array
* @throws Exception
*/
- function save($p_array) {
+ function save($p_array)
+ {
global $cn;
- try {
+ try
+ {
$cn->start();
- if (strlen(trim($p_array['name'])) == 0) {
+ if (strlen(trim($p_array['name'])) == 0)
+ {
throw new Exception('Le nom ne peut pas être vide');
}
@@ -105,7 +120,8 @@
$this->Data->save();
$this->load_file();
$cn->commit();
- } catch (Exception $ex) {
+ } catch (Exception $ex)
+ {
$cn->rollback();
}
}
@@ -115,21 +131,26 @@
* @global type $cn
* @return int
*/
- function load_file() {
+ function load_file()
+ {
global $cn;
// nothing to save
if (sizeof($_FILES) == 0)
return;
- try {
+ try
+ {
$name = $_FILES['listing_mod']['name'];
$new_name = tempnam($_ENV['TMP'], 'fiche_def');
// check if a file is submitted
- if (strlen($_FILES['listing_mod']['tmp_name']) != 0) {
+ if (strlen($_FILES['listing_mod']['tmp_name']) != 0)
+ {
// upload the file and move it to temp directory
- if (move_uploaded_file($_FILES['listing_mod']['tmp_name'],
$new_name)) {
+ if (move_uploaded_file($_FILES['listing_mod']['tmp_name'],
$new_name))
+ {
$oid = $cn->lo_import($new_name);
// check if the lob is in the database
- if ($oid == false) {
+ if ($oid == false)
+ {
$cn->rollback();
return 1;
}
@@ -143,21 +164,25 @@
// update rapav
$this->Data->update();
}
- } catch (Exception $ex) {
+ } catch (Exception $ex)
+ {
$cn->rollback();
throw $ex;
}
}
-/**
- * @brief remove a document template
- * @global type $cn database connection
- * @return type
- */
- function remove_modele() {
+
+ /**
+ * @brief remove a document template
+ * @global type $cn database connection
+ * @return type
+ */
+ function remove_modele()
+ {
global $cn;
if ($this->Data->l_lob == null)
return;
- try {
+ try
+ {
$cn->start();
$this->Data->cn->lo_unlink($this->Data->l_lob);
$this->Data->l_filename = null;
@@ -166,27 +191,30 @@
$this->Data->l_mimetype = null;
$this->Data->update();
$cn->commit();
- } catch (Exception $e) {
+ } catch (Exception $e)
+ {
$cn->rollback;
throw $ex;
-
}
}
+
/**
* @brief delete a listing + lobs
* @throws type
*/
function delete()
{
- try {
+ try
+ {
$this->remove_modele();
- $this->Data->delete();
- } catch (Exception $e) {
+ $this->Data->delete();
+ } catch (Exception $e)
+ {
$cn->rollback;
throw $ex;
-
}
}
+
/**
* @brief display the parameter of a listing
* let add or remove detail
@@ -196,9 +224,9 @@
require_once 'class_rapav_listing_formula.php';
// Load all listing_parameter
$this->load_detail();
-
+
// Button for modifing
- $button=new IButton('listing_mod_bt_id','Modifie');
+ $button = new IButton('listing_mod_bt_id', 'Modifie');
$arg = array(
'gDossier' => Dossier::id(),
'ac' => $_REQUEST['ac'],
@@ -207,46 +235,50 @@
'cin' => 'listing_tb_id',
'cout' => 'listing_mod_div');
$json = 'listing_modify(' . str_replace('"', "'", json_encode($arg)) .
')';
- $button->javascript=$json;
-
-
+ $button->javascript = $json;
+
+
// Display them avec an anchor to update / delete (javascript)
include_once 'template/rapav_listing_definition.php';
}
+
/**
* @brief Load the detail of a listing
* @throws Exception Undefined object
*/
function load_detail()
{
- if ( $this->Data->getp('id') == -1)
- throw new Exception ("Undefined objet ".__FILE__.':'.__LINE__);
- $this->a_detail=
RAPAV_Listing_Param::get_listing_detail($this->Data->getp('id'));
-
+ if ($this->Data->getp('id') == -1)
+ throw new Exception("Undefined objet " . __FILE__ . ':' .
__LINE__);
+ $this->a_detail =
RAPAV_Listing_Param::get_listing_detail($this->Data->getp('id'));
}
+
/**
* @brief Display button for adding detail to a list definition, it means
*/
- function button_add_param()
+ function button_add_param()
{
- $button=new IButton('detail_add_bt','Ajout','detail_add_bt');
- $arg= json_encode(array(
- 'cin'=>'listing_param_input_div_id',
- 'gDossier'=>Dossier::id(),
- 'id'=>$this->Data->getp('id'),
- 'tb_id'=>'definition_tb_id',
- 'ac'=>$_REQUEST['ac'],
- 'pc'=>$_REQUEST['plugin_code'])
- );
- $arg=str_replace('"',"'",$arg);
- $button->javascript='listing_param_add('.$arg.')';
+ $button = new IButton('detail_add_bt', 'Ajout', 'detail_add_bt');
+ $arg = json_encode(array(
+ 'cin' => 'listing_param_input_div_id',
+ 'gDossier' => Dossier::id(),
+ 'id' => $this->Data->getp('id'),
+ 'tb_id' => 'definition_tb_id',
+ 'ac' => $_REQUEST['ac'],
+ 'pc' => $_REQUEST['plugin_code'])
+ );
+ $arg = str_replace('"', "'", $arg);
+ $button->javascript = 'listing_param_add(' . $arg . ')';
echo $button->input();
}
- function add_parameter()
+
+ function add_parameter($l_id)
{
- $param=new RAPAV_Listing_Param();
+ $param = new RAPAV_Listing_Param();
+ $param->Param->l_id=$l_id;
$param->input($this->Data->getp("id"));
}
+
/**
* Return the name of the description of the category of the cards
*
@@ -255,10 +287,12 @@
function get_categorie_name()
{
global $cn;
- if ($this->Data->getp('id')==0) return;
- $cat=$cn->get_value('select fd_label from fiche_def where
fd_id=$1',array($this->Data->getp('fiche_def_id')));
+ if ($this->Data->getp('id') == 0)
+ return;
+ $cat = $cn->get_value('select fd_label from fiche_def where fd_id=$1',
array($this->Data->getp('fiche_def_id')));
return $cat;
}
+
/**
* Return the name of the description of the category of the cards
*
@@ -267,8 +301,11 @@
function get_categorie_description()
{
global $cn;
- if ($this->Data->getp('id')==0) return;
- $cat=$cn->get_value('select fd_description from fiche_def where
fd_id=$1',array($this->Data->getp('fiche_def_id')));
+ if ($this->Data->getp('id') == 0)
+ return;
+ $cat = $cn->get_value('select fd_description from fiche_def where
fd_id=$1', array($this->Data->getp('fiche_def_id')));
return $cat;
}
+
+
}
Added: trunk/rapport_avance/include/class_rapav_listing_compute.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_compute.php
(rev 0)
+++ trunk/rapport_avance/include/class_rapav_listing_compute.php
2013-12-03 02:28:15 UTC (rev 595)
@@ -0,0 +1,126 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of class_rapav_listing_compute
+ *
+ * @author dany
+ */
+require_once 'class_rapav_listing.php';
+require_once 'class_rapav_listing_formula.php';
+require_once 'class_rapport_avance_sql.php';
+
+class RAPAV_Listing_Compute
+{
+
+ /**
+ * < Data point to listing_compute
+ */
+ var $data;
+
+ /**
+ * Type of operation
+ * - 0 all operations
+ * - 1 only paid operations
+ * - 2 only UNpaid operations
+ */
+ private $type_operation;
+
+ function __construct()
+ {
+ $this->data = new RAPAV_Listing_Compute_SQL();
+ }
+
+ /**
+ * Compute all the values and save them in the table rapav_listing_compute
+ * @param RAPAV_Listing $rapav_listing
+ * @param type $p_date_start
+ * @param type $p_date_end
+ */
+ 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();
+
+ // 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 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++)
+ {
+
+ $a_later = array();
+ for ($i = 0; $i < $nb; $i++)
+ {
+ //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->set_fiche($a_fiche[$e]['f_id']);
+
+ if ($compute->sig == 'COMP')
+ {
+ $a_later[] = clone $compute;
+ } else
+ {
+ $compute->set_listing_compute($this->data->lc_id);
+ $compute->filter_operation($this->type_operation);
+
+ if ( $i == 0 ) $compute->save_fiche();
+ //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++)
+ {
+ $a_later[$i]->set_fiche($a_fiche[$e]['f_id']);
+ $compute->set_listing_compute($this->data->lc_id);
+ if ( $i == 0 ) $a_later[$i]->save_fiche();
+ $a_later[$i]->compute($p_date_start, $p_data_end);
+ $a_later[$i]->save_computed();
+ }
+ }
+ }
+ /**
+ * Filter the operations
+ * - 0 all operations
+ * - 1 only paid operations - only VEN & ACH
+ * - 2 only UNpaid operations - only VEN & ACH
+ * @param $p_type
+ */
+ function filter_operation($p_type)
+ {
+ $this->type_operation = $p_type;
+ }
+ function display()
+ {
+
+ }
+
+}
Modified: trunk/rapport_avance/include/class_rapav_listing_formula.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_formula.php
2013-12-01 19:54:09 UTC (rev 594)
+++ trunk/rapport_avance/include/class_rapav_listing_formula.php
2013-12-03 02:28:15 UTC (rev 595)
@@ -12,6 +12,8 @@
* @author dany
*/
require_once 'class_impress.php';
+require_once 'class_rapav.php';
+require_once 'class_rapport_avance_sql.php';
abstract class RAPAV_Listing_Formula
{
@@ -24,44 +26,15 @@
function save_computed()
{
-
+ $this->detail->lf_id=$this->fiche->lf_id;
+ $this->detail->lp_id=$this->data->lp_id;
+ $this->detail->save();
}
-
- function get_ledger_name()
+ function set_listing_compute($param)
{
- global $cn;
- $ledger = "";
- if ($this->data->jrn_def_id == null || $this->data->jrn_def_id == -1)
- {
- $ledger = " tous les journaux";
- } else
- {
- $tledger = $cn->get_value('select jrn_def_name from jrn_def where
jrn_def_id=$1', array($this->data->jrn_def_id));
- $ledger.=" le journal " . $tledger;
- }
- return $ledger;
+ $this->detail->lc_id=$param;
+ $this->fiche->lc_id=$param;
}
-
- static function input_ledger()
- {
- global $cn;
- $select = new ISelect('p_ledger');
- $a_ledger = $cn->make_array('select jrn_def_id,jrn_def_name from
jrn_def order by 2', 1);
- $a_ledger[0]['label'] = '-- Tous les journaux -- ';
- $select->value = $a_ledger;
-
- echo '<p> Filtrage par journal ' . $select->input() . '</p>';
- }
-
- static function input_date_paiement()
- {
- $ck_paid = new ICheckBox('p_paid');
- echo '<p> La date donnée concerne la date de paiement, ce qui limitera
la recherche aux journaux VEN et ACH ';
- echo HtmlInput::infobulle(36);
- echo $ck_paid->input();
- echo '</p>';
- }
-
function set($p_array)
{
$this->data->setp("code", $p_array["code_id"]);
@@ -95,7 +68,7 @@
break;
default:
- throw new Exception('Object ' .var_export( $obj,true) . '
invalide ');
+ throw new Exception('Object ' . var_export($obj, true) . '
invalide ');
break;
}
return $ret;
@@ -120,11 +93,27 @@
{
$this->data->load();
}
+
function set_listing($p_id)
{
- $this->data->setp('listing_id',$p_id);
+ $this->data->setp('listing_id', $p_id);
}
+ function set_fiche($f_id)
+ {
+ $this->fiche->f_id = $f_id;
+ }
+
+
+ function save_fiche()
+ {
+ $this->fiche->save();
+ }
+ function filter_operation($param)
+ {
+ $this->type_operation=$param;
+ }
+
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -143,6 +132,14 @@
var $data;
/**
+ * < RAPAV_Listing_Compute_SQL object */
+ var $fiche;
+
+ /**
+ * < RAPAV_Listing_Detail_SQL object */
+ var $detail;
+
+ /**
* categorie id */
var $cat;
@@ -150,11 +147,11 @@
* Object signature */
var $sig;
- function __construct(RAPAV_Listing_Param_SQL $obj, $p_cat_id = 0)
+ function __construct(RAPAV_Listing_Param_SQL $obj)
{
global $cn;
$this->data = $obj;
- if ($p_cat_id == 0)
+ if ($this->data->getp('lp_id') > 0)
{
$this->cat = $cn->get_value('select fd_id
from rapport_advanced.listing
@@ -164,11 +161,9 @@
if ($this->cat == "")
throw new Exception(__FILE__ . ':' . __LINE__ . 'Aucune
catégorie définie');
}
- else
- {
- $this->cat = $p_cat_id;
- }
$this->sig = 'ATTR';
+ $this->fiche = new RAPAV_Listing_Compute_Fiche_SQL();
+ $this->detail = new RAPAV_Listing_Compute_Detail_SQL();
}
function display()
@@ -180,7 +175,26 @@
function compute($p_start, $p_end)
{
- return 0;
+ global $cn;
+ $value=$cn->get_value("select ad_value from fiche_detail "
+ . "where "
+ . "f_id=$1 and ad_id=$2",array($this->fiche->f_id,
+ $this->data->getp('attribut_card')));
+ $type=$cn->get_value('select ad_type from attr_def where
+ ad_id=$1',array($this->data->getp('attribut_card')));
+ switch ($type)
+ {
+ case "numeric":
+ $this->detail->ld_value_numeric=$value;
+ break;
+ case "date":
+ $this->detail->ld_value_date=$value;
+ break;
+ default:
+ $this->detail->ld_value_text=$value;
+ break;
+ }
+
}
function input()
@@ -192,10 +206,10 @@
from
attr_def as a join jnt_fic_attr as j
on (a.ad_id=j.ad_id)
where
- fd_id=' . $this->cat . ' order by 2');
+ fd_id=' .
$this->data->getp('listing_id') . ' order by 2');
$select->selected = $this->data->getp('attribut_card');
- return "Attribut à afficher pour chaque fiche ".$select->input();
+ return "Attribut à afficher pour chaque fiche " . $select->input();
}
function save($p_array)
@@ -213,6 +227,7 @@
$this->data->save();
}
+
}
///////////////////////////////////////////////////////////////////////////////
@@ -234,21 +249,32 @@
var $data;
/**
+ * < RAPAV_Listing_Detail_SQL object */
+ var $fiche;
+
+ /**
* < Object signature
*/
var $sig;
- function __construct(RAPAV_Listing_Param_SQL $obj,$p_cat_id = 0)
+ /**
+ * < RAPAV_Listing_Detail_SQL object */
+ var $detail;
+
+ function __construct(RAPAV_Listing_Param_SQL $obj, $p_cat_id = 0)
{
global $cn;
$this->data = $obj;
$this->sig = 'FORM';
+ $this->fiche = new RAPAV_Listing_Compute_Fiche_SQL();
+ $this->detail = new RAPAV_Listing_Compute_Detail_SQL();
}
function display()
{
- $ledger = $this->get_ledger_name();
- $paid = ( $this->data->date_paid != 0 ) ? "la date concerne la date de
paiement, la recherche sera limitée au journaux de type ACH & VEN" : "";
+ $ledger = RAPAV::get_ledger_name($this->data->jrn_def_id);
+ ;
+ $paid = RAPAV::str_date_type($this->data->date_paid);
$str = sprintf("Résultat de la formule %s utilisant $ledger %s",
$this->data->fp_formula, $paid);
return $str;
}
@@ -269,8 +295,8 @@
$account->set_attribute('noquery', 1);
$account->set_attribute('account', "formula_input_id");
echo $account->input();
- parent::input_date_paiement();
- parent::input_ledger();
+ RAPAV::input_date_paiement();
+ RAPAV::input_ledger();
}
function save($p_array)
@@ -286,14 +312,7 @@
parent::set_to_null($a_toclean);
$this->data->setp('with_card', 'N');
$this->data->setp('formula', $p_array['p_formula']);
- if (isset($p_array['p_paid']))
- {
- $this->data->setp('date_paid', 1);
- } else
- {
- $this->data->setp('date_paid', null);
-
- }
+ $this->data->setp('date_paid', $p_array['p_paid']);
$this->data->setp('jrn_def_id', $p_array['p_ledger']);
$this->data->setp('formula_type', 'FORM');
$this->data->save();
@@ -305,20 +324,14 @@
*/
function verify()
{
- if (Impress::check_formula($this->data->fp_formula) == false)
- {
- $this->errcode = "Erreur dans votre formule";
- return 1;
- }
- if (trim($this->data->fp_formula) == "")
- {
- $this->errcode = " Aucune formule trouvée";
- return 1;
- }
- return 0;
+ global $errcode;
+ $ret = RAPAV::verify_compute($this->data->fp_formula);
+ $this->errocode = $errcode;
+ return $ret;
}
}
+
///////////////////////////////////////////////////////////////////////////////
// RAPAV_Formula_Compute
///////////////////////////////////////////////////////////////////////////////
@@ -338,15 +351,25 @@
var $data;
/**
+ * < RAPAV_Listing_Detail_SQL object */
+ var $fiche;
+
+ /**
* < Object signature
*/
var $sig;
+ /**
+ * < RAPAV_Listing_Detail_SQL object */
+ var $detail;
+
function __construct(RAPAV_Listing_Param_SQL $obj)
{
global $cn;
$this->data = $obj;
$this->sig = 'COMP';
+ $this->fiche = new RAPAV_Listing_Compute_Fiche_SQL();
+ $this->detail = new RAPAV_Listing_Compute_Detail_SQL();
}
function display()
@@ -363,7 +386,7 @@
function input()
{
global $cn;
- $f_id=$this->data->getp('listing_id');
+ $f_id = $this->data->getp('listing_id');
$account = new IText("form_compute");
$account->size = 50;
echo $account->input();
@@ -376,11 +399,11 @@
$this->data->setp('listing_id', $p_array['listing_id']);
/* Clean everything but keep the lp_id, l_id, ad_id + common */
- $a_toclean=explode (',','operation_pcm_val,with_tmp_val,'
+ $a_toclean = explode(',', 'operation_pcm_val,with_tmp_val,'
. 'tmp_val,date_paid,jrn_def_id,type_sum_account,type_detail,'
. 'tt_id,jrn_def_type,fp_signed,tva_id,lp_with_card,'
. 'lp_card_saldo,ad_id');
-
+
parent::set_to_null($a_toclean);
$this->data->setp('formula', $p_array['form_compute']);
$this->data->setp('formula_type', 'COMP');
@@ -393,32 +416,15 @@
*/
function verify()
{
- if (trim($this->data->fp_formula) == "")
- {
- $this->errcode = " Aucune formule trouvée";
- return 1;
- }
+ global $errcode;
+ $ret = RAPAV::verify_compute($this->data->fp_formula);
+ $this->errocode = $errcode;
+ return $ret;
+ }
- // copy $this->form->fp_formula to a variable
- $formula = $this->data->fp_formula;
- // remove the valid
- preg_match_all("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", $formula, $e);
- $formula = preg_replace("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", '',
$formula);
- $formula = preg_replace('/([0-9]+.{0,1}[0.9]*)*(\+|-|\*|\/)*/', '',
$formula);
- $formula = preg_replace('/(\(|\))/', '', $formula);
- $formula = preg_replace('/\s/', '', $formula);
+}
- // if something remains it should be a mistake
- if ($formula != '')
- {
- $this->errcode = " Erreur dans la formule " . $formula;
- return 1;
- }
- return 0;
- }
-
-}
///////////////////////////////////////////////////////////////////////////////
// RAPAV_Formula_Saldo
///////////////////////////////////////////////////////////////////////////////
@@ -447,21 +453,32 @@
var $data;
/**
+ * < RAPAV_Listing_Detail_SQL object */
+ var $fiche;
+
+ /**
* < Object signature
*/
var $sig;
+ /**
+ * < RAPAV_Listing_Detail_SQL object */
+ var $detail;
+
function __construct(RAPAV_Listing_Param_SQL $obj)
{
global $cn;
$this->data = $obj;
$this->sig = 'ACCOUNT';
+ $this->fiche = new RAPAV_Listing_Compute_Fiche_SQL();
+ $this->detail = new RAPAV_Listing_Compute_Detail_SQL();
}
function display()
{
- $ledger = $this->get_ledger_name();
- $paid = ( $this->data->date_paid != 0 ) ? "la date concerne la date de
paiement, la recherche sera limitée au journaux de type ACH & VEN" : "";
+ $ledger = RAPAV::get_ledger_name($this->data->jrn_def_id);
+ ;
+ $paid = RAPAV::str_date_type($this->data->date_paid);
$str = sprintf("Résultat de la formule %s utilisant $ledger %s",
$this->data->fp_formula, $paid);
return $str;
}
@@ -478,21 +495,21 @@
$account->label = _("Recherche poste");
$account->set_attribute('gDossier', dossier::id());
$account->set_attribute('account', "formula_acc_input_id");
- echo "Poste comptable utilisée avec chaque fiche ".$account->input();
- $sel_total_type_row=new ISelect ('tt_id');
- $sel_total_type_row->value=$cn->make_array('select tt_id,tt_label from
'
+ echo "Poste comptable utilisée avec chaque fiche " . $account->input();
+ $sel_total_type_row = new ISelect('tt_id');
+ $sel_total_type_row->value = $cn->make_array('select tt_id,tt_label
from '
. ' rapport_advanced.total_type_account order by 2');
-
+
echo '<p>';
- echo "type de total : ".$sel_total_type_row->input();
+ echo "type de total : " . $sel_total_type_row->input();
echo '</p>';
-
- $ck=new ICheckBox('card_saldo');
+
+ $ck = new ICheckBox('card_saldo');
echo '<p>';
- echo 'Prendre le total de la fiche '.$ck->input();
+ echo 'Prendre le total de la fiche ' . $ck->input();
echo '</p>';
- parent::input_date_paiement();
- parent::input_ledger();
+ RAPAV::input_date_paiement();
+ RAPAV::input_ledger();
}
function save($p_array)
@@ -508,14 +525,7 @@
parent::set_to_null($a_toclean);
$this->data->setp('with_card', 'N');
$this->data->setp('formula', $p_array['p_formula']);
- if (isset($p_array['p_paid']))
- {
- $this->data->setp('date_paid', 1);
- } else
- {
- $this->data->setp('date_paid', null);
-
- }
+ $this->data->setp('date_paid', $p_array['p_paid']);
$this->data->setp('jrn_def_id', $p_array['p_ledger']);
$this->data->setp('formula_type', 'ACCOUNT');
$this->data->save();
Modified: trunk/rapport_avance/include/class_rapav_listing_param.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_param.php 2013-12-01
19:54:09 UTC (rev 594)
+++ trunk/rapport_avance/include/class_rapav_listing_param.php 2013-12-03
02:28:15 UTC (rev 595)
@@ -75,15 +75,21 @@
*/
function input($p_id)
{
+ global $cn;
$code=new IText('code_id');
$comment=new IText('comment');
$order=new INum('order');
- $order->value=10;
- $attribute=new RAPAV_Formula_Attribute($this->Param,$p_id);
+ $order->value=$cn->get_value("select coalesce(max(l_order),0)+10 from
+ rapport_advanced.listing_param
+ where
+ l_id=$1
+ ",array($this->Param->l_id));
+ $attribute=new RAPAV_Formula_Attribute($this->Param);
$formula=new RAPAV_Formula_Formula($this->Param);
$compute=new RAPAV_Formula_Compute($this->Param);
$account=new RAPAV_Formula_Account($this->Param);
$account->set_listing($p_id);
+ $attribute->set_listing($p_id);
require 'template/listing_param_input.php';
}
}
Modified: trunk/rapport_avance/include/class_rapport_avance_sql.php
===================================================================
--- trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-12-01
19:54:09 UTC (rev 594)
+++ trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-12-03
02:28:15 UTC (rev 595)
@@ -27,260 +27,271 @@
*
*/
require_once 'class_phpcompta_sql.php';
-class formulaire_param_sql extends phpcompta_sql
+
+class formulaire_param_sql extends Phpcompta_SQL
{
- function __construct($p_id=-1)
- {
+ function __construct($p_id = -1)
+ {
- $this->table = "rapport_advanced.formulaire_param";
- $this->primary_key = "p_id";
+ $this->table = "rapport_advanced.formulaire_param";
+ $this->primary_key = "p_id";
- $this->name = array(
- "p_id" => "p_id",
- "p_code" => "p_code",
- "p_libelle" => "p_libelle",
- "p_type" => "p_type",
- "p_order" => "p_order",
- "f_id" => "f_id",
- "t_id" => "t_id"
- );
+ $this->name = array(
+ "p_id" => "p_id",
+ "p_code" => "p_code",
+ "p_libelle" => "p_libelle",
+ "p_type" => "p_type",
+ "p_order" => "p_order",
+ "f_id" => "f_id",
+ "t_id" => "t_id"
+ );
- $this->type = array(
- "p_id" => "numeric",
- "p_code" => "text",
- "p_libelle" => "text",
- "p_type" => "numeric",
- "p_order" => "numeric",
- "f_id" => "numeric",
- "t_id" => "numeric"
- );
+ $this->type = array(
+ "p_id" => "numeric",
+ "p_code" => "text",
+ "p_libelle" => "text",
+ "p_type" => "numeric",
+ "p_order" => "numeric",
+ "f_id" => "numeric",
+ "t_id" => "numeric"
+ );
- $this->default = array(
- "p_id" => "auto"
- );
- global $cn;
+ $this->default = array(
+ "p_id" => "auto"
+ );
+ global $cn;
- parent::__construct($cn, $p_id);
- }
+ parent::__construct($cn, $p_id);
+ }
}
-class formulaire_sql extends phpcompta_sql
+
+class formulaire_sql extends Phpcompta_SQL
{
- function __construct($p_id=-1)
- {
+ function __construct($p_id = -1)
+ {
- $this->table = "rapport_advanced.formulaire";
- $this->primary_key = "f_id";
+ $this->table = "rapport_advanced.formulaire";
+ $this->primary_key = "f_id";
- $this->name = array(
- "f_id" => "f_id",
- "f_title" => "f_title",
- "f_description" => "f_description",
- "f_lob"=>"f_lob",
- "f_mimetype"=>"f_mimetype",
- "f_filename"=>"f_filename",
- "f_size"=>"f_size"
- );
+ $this->name = array(
+ "f_id" => "f_id",
+ "f_title" => "f_title",
+ "f_description" => "f_description",
+ "f_lob" => "f_lob",
+ "f_mimetype" => "f_mimetype",
+ "f_filename" => "f_filename",
+ "f_size" => "f_size"
+ );
- $this->type = array(
- "f_id" => "numeric",
- "f_title" => "text",
- "f_description" => "text",
- "f_lob"=>"oid",
- "f_mimetype"=>"text",
- "f_filename"=>"text",
- "f_size"=>"numeric"
- );
+ $this->type = array(
+ "f_id" => "numeric",
+ "f_title" => "text",
+ "f_description" => "text",
+ "f_lob" => "oid",
+ "f_mimetype" => "text",
+ "f_filename" => "text",
+ "f_size" => "numeric"
+ );
- $this->default = array(
- "f_id" => "auto"
- );
- global $cn;
+ $this->default = array(
+ "f_id" => "auto"
+ );
+ global $cn;
- parent::__construct($cn, $p_id);
- }
+ parent::__construct($cn, $p_id);
+ }
}
-class Formulaire_Param_Detail_SQL extends phpcompta_sql
+
+class Formulaire_Param_Detail_SQL extends Phpcompta_SQL
{
- function __construct($p_id=-1)
- {
+ function __construct($p_id = -1)
+ {
- $this->table = "rapport_advanced.formulaire_param_detail";
- $this->primary_key = "fp_id";
+ $this->table = "rapport_advanced.formulaire_param_detail";
+ $this->primary_key = "fp_id";
- $this->name = array(
- "fp_id" => "fp_id",
- "p_id" => "p_id",
- "tmp_val" => "tmp_val",
- "tva_id"=>"tva_id",
- "fp_formula"=>"fp_formula",
- "fp_signed"=>"fp_signed",
- "jrn_def_type"=>"jrn_def_type",
- "tt_id"=>"tt_id",
- "type_detail"=>"type_detail",
- "with_tmp_val"=>"with_tmp_val",
- "type_sum_account"=>"type_sum_account",
- "operation_pcm_val"=>"operation_pcm_val",
- "jrn_def_id"=>"jrn_def_id",
- "date_paid"=>"date_paid"
- );
+ $this->name = array(
+ "fp_id" => "fp_id",
+ "p_id" => "p_id",
+ "tmp_val" => "tmp_val",
+ "tva_id" => "tva_id",
+ "fp_formula" => "fp_formula",
+ "fp_signed" => "fp_signed",
+ "jrn_def_type" => "jrn_def_type",
+ "tt_id" => "tt_id",
+ "type_detail" => "type_detail",
+ "with_tmp_val" => "with_tmp_val",
+ "type_sum_account" => "type_sum_account",
+ "operation_pcm_val" => "operation_pcm_val",
+ "jrn_def_id" => "jrn_def_id",
+ "date_paid" => "date_paid"
+ );
- $this->type = array(
- "fp_id" => "numeric",
- "p_id" => "numeric",
- "tmp_val" => "text",
- "tva_id"=>"numeric",
- "fp_formula"=>"text",
- "fp_signed"=>"numeric",
- "jrn_def_type"=>"text",
- "tt_id"=>"numeric",
- "type_detail"=>"numeric",
- "with_tmp_val"=>"text",
- "type_sum_account"=>"numeric",
- "operation_pcm_val"=>"text",
- "jrn_def_id"=>"numeric",
- "date_paid"=>"numeric"
+ $this->type = array(
+ "fp_id" => "numeric",
+ "p_id" => "numeric",
+ "tmp_val" => "text",
+ "tva_id" => "numeric",
+ "fp_formula" => "text",
+ "fp_signed" => "numeric",
+ "jrn_def_type" => "text",
+ "tt_id" => "numeric",
+ "type_detail" => "numeric",
+ "with_tmp_val" => "text",
+ "type_sum_account" => "numeric",
+ "operation_pcm_val" => "text",
+ "jrn_def_id" => "numeric",
+ "date_paid" => "numeric"
+ );
- );
+ $this->default = array(
+ "fp_id" => "auto"
+ );
+ global $cn;
- $this->default = array(
- "fp_id" => "auto"
- );
- global $cn;
+ parent::__construct($cn, $p_id);
+ }
- parent::__construct($cn, $p_id);
- }
+}
-}
-class RAPAV_Declaration_SQL extends phpcompta_sql
+class RAPAV_Declaration_SQL extends Phpcompta_SQL
{
- function __construct($p_id=-1)
- {
+ function __construct($p_id = -1)
+ {
- $this->table = "rapport_advanced.declaration";
- $this->primary_key = "d_id";
- $this->name = array(
- "d_id"=>"d_id",
- "d_title"=>"d_title",
- "d_description"=>'d_description',
- "d_start"=>"d_start",
- "d_end"=>"d_end",
- "to_keep"=>"to_keep",
- "d_generated"=>"d_generated",
- "d_lob"=>"d_lob",
- "d_filename"=>"d_filename",
- "d_mimetype"=>"d_mimetype",
- "d_size"=>"d_size",
- "f_id"=>"f_id",
- 'd_step'=>'d_step'
- );
+ $this->table = "rapport_advanced.declaration";
+ $this->primary_key = "d_id";
- $this->type = array(
- "d_id"=>"numeric",
- "d_title"=>"text",
- "d_description"=>'text',
- "d_start"=>"date",
- "d_end"=>"date",
- "to_keep"=>"text",
- "d_generated"=>"date",
- "f_id"=>"numeric",
- "d_lob"=>"oid",
- "d_filename"=>"text",
- "d_mimetype"=>"text",
- "d_size"=>"numeric",
- 'd_step'=>'numeric'
- );
+ $this->name = array(
+ "d_id" => "d_id",
+ "d_title" => "d_title",
+ "d_description" => 'd_description',
+ "d_start" => "d_start",
+ "d_end" => "d_end",
+ "to_keep" => "to_keep",
+ "d_generated" => "d_generated",
+ "d_lob" => "d_lob",
+ "d_filename" => "d_filename",
+ "d_mimetype" => "d_mimetype",
+ "d_size" => "d_size",
+ "f_id" => "f_id",
+ 'd_step' => 'd_step'
+ );
- $this->default = array(
- "d_id" => "auto",
- "d_generated"=>"auto"
- );
- global $cn;
+ $this->type = array(
+ "d_id" => "numeric",
+ "d_title" => "text",
+ "d_description" => 'text',
+ "d_start" => "date",
+ "d_end" => "date",
+ "to_keep" => "text",
+ "d_generated" => "date",
+ "f_id" => "numeric",
+ "d_lob" => "oid",
+ "d_filename" => "text",
+ "d_mimetype" => "text",
+ "d_size" => "numeric",
+ 'd_step' => 'numeric'
+ );
- $this->date_format = "DD.MM.YYYY";
- parent::__construct($cn, $p_id);
- }
+ $this->default = array(
+ "d_id" => "auto",
+ "d_generated" => "auto"
+ );
+ global $cn;
+ $this->date_format = "DD.MM.YYYY";
+ parent::__construct($cn, $p_id);
+ }
+
}
-class RAPAV_Declaration_Row_SQL extends phpcompta_sql
+
+class RAPAV_Declaration_Row_SQL extends Phpcompta_SQL
{
-function __construct($p_id=-1)
- {
+ function __construct($p_id = -1)
+ {
- $this->table = "rapport_advanced.declaration_row";
- $this->primary_key = "dr_id";
- $this->name = array(
- "dr_id"=>"dr_id",
- "d_id"=>"d_id",
- "dr_libelle"=>"dr_libelle",
- "dr_order"=>"dr_order",
- "dr_code"=>"dr_code",
- "dr_amount"=>"dr_amount",
- "dr_type"=>"dr_type",
- "dr_start"=>"dr_start",
- "dr_end"=>"dr_end"
- );
+ $this->table = "rapport_advanced.declaration_row";
+ $this->primary_key = "dr_id";
- $this->type = array(
- "dr_id"=>"numeric",
- "d_id"=>"numeric",
- "dr_libelle"=>"text",
- "dr_order"=>"text",
- "dr_code"=>"numeric",
- "dr_amount"=>"numeric",
- "dr_type"=>"numeric",
- "dr_start"=>"date",
- "dr_end"=>"date"
- );
+ $this->name = array(
+ "dr_id" => "dr_id",
+ "d_id" => "d_id",
+ "dr_libelle" => "dr_libelle",
+ "dr_order" => "dr_order",
+ "dr_code" => "dr_code",
+ "dr_amount" => "dr_amount",
+ "dr_type" => "dr_type",
+ "dr_start" => "dr_start",
+ "dr_end" => "dr_end"
+ );
- $this->default = array(
- );
- global $cn;
- $this->date_format='DD.MM.YYYY';
- parent::__construct($cn, $p_id);
- }
+ $this->type = array(
+ "dr_id" => "numeric",
+ "d_id" => "numeric",
+ "dr_libelle" => "text",
+ "dr_order" => "text",
+ "dr_code" => "numeric",
+ "dr_amount" => "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);
+ }
+
}
-class RAPAV_Declaration_Row_Detail_SQL extends phpcompta_sql
+
+class RAPAV_Declaration_Row_Detail_SQL extends Phpcompta_SQL
{
- function __construct($p_id=-1)
- {
+ function __construct($p_id = -1)
+ {
- $this->table = "rapport_advanced.declaration_row_detail";
- $this->primary_key = "ddr_id";
- $this->name = array(
- "ddr_id"=>"ddr_id",
- "ddr_amount"=>"ddr_amount",
- "dr_id"=>"dr_id"
- );
+ $this->table = "rapport_advanced.declaration_row_detail";
+ $this->primary_key = "ddr_id";
- $this->type = array(
- "ddr_id"=>"numeric",
- "ddr_amount"=>"numeric",
- "dr_id"=>"numeric"
- );
+ $this->name = array(
+ "ddr_id" => "ddr_id",
+ "ddr_amount" => "ddr_amount",
+ "dr_id" => "dr_id"
+ );
- $this->default = array(
- "ddr_id" => "auto"
- );
- global $cn;
+ $this->type = array(
+ "ddr_id" => "numeric",
+ "ddr_amount" => "numeric",
+ "dr_id" => "numeric"
+ );
- parent::__construct($cn, $p_id);
- }
+ $this->default = array(
+ "ddr_id" => "auto"
+ );
+ global $cn;
+
+ parent::__construct($cn, $p_id);
+ }
+
}
-class RAPAV_Listing_SQL extends phpcompta_sql
+
+class RAPAV_Listing_SQL extends Phpcompta_SQL
{
function __construct($p_id = -1)
@@ -290,7 +301,7 @@
$this->name = array(
"id" => "l_id",
"description" => "l_description",
- "name"=>'l_name',
+ "name" => 'l_name',
"lob" => "l_lob",
"filename" => "l_filename",
"mimetype" => "l_mimetype",
@@ -299,10 +310,10 @@
);
$this->type = array(
"l_id" => "numeric",
- "l_name"=>'text',
+ "l_name" => 'text',
"l_description" => "text",
"l_lob" => "oid",
- "l_filename" => "text",
+ "l_filename" => "text",
"l_mimetype" => "text",
"l_size" => "numeric",
"fd_id" => "numeric"
@@ -317,11 +328,12 @@
}
-class RAPAV_Listing_Param_SQL extends Phpcompta_Sql
+class RAPAV_Listing_Param_SQL extends Phpcompta_SQL
{
-/*
- *
operation_pcm_val,with_tmp_val,tmp_val,date_paid,jrn_def_id,type_sum_account,type_detail,tt_id,jrn_def_type,fp_signed,fp_formula,tva_id,lp_with_card,lp_card_saldo,ad_id,l_order,l_card,lp_comment,lp_code,l_id,lp_id
- */
+ /*
+ *
operation_pcm_val,with_tmp_val,tmp_val,date_paid,jrn_def_id,type_sum_account,type_detail,tt_id,jrn_def_type,fp_signed,fp_formula,tva_id,lp_with_card,lp_card_saldo,ad_id,l_order,l_card,lp_comment,lp_code,l_id,lp_id
+ */
+
function __construct($p_id = -1)
{
@@ -385,5 +397,198 @@
}
+/**
+ * @brief Manage the table rapport_advanced.listing_compute
+ */
+class RAPAV_Listing_Compute_SQL extends Phpcompta_SQL
+{
+ //------ Attributes-----
+ var $lc_id;
+ var $l_id;
+ var $l_description;
+ var $l_start;
+ var $l_end;
+ var $l_keep;
+ var $l_timestamp;
+
+ /* example private
$variable=array("easy_name"=>column_name,"email"=>"column_name_email","val3"=>0);
*/
+
+ function __construct($p_id = -1)
+ {
+
+
+ $this->table = "rapport_advanced.listing_compute";
+ $this->primary_key = "lc_id";
+
+ $this->name = array(
+ "lc_id" => "lc_id"
+ , "l_id" => "l_id"
+ , "description" => "l_description"
+ , "l_start" => "l_start"
+ , "l_end" => "l_end"
+ , "l_keep" => "l_keep"
+ , "l_timestamp" => "l_timestamp"
+ );
+
+ $this->type = array(
+ "lc_id" => "lc_id",
+ "l_id" => "numeric"
+ , "l_description" => "text"
+ , "l_start" => "date"
+ , "l_end" => "date"
+ , "l_keep" => "text"
+ , "l_timestamp" => "date"
+ );
+
+ $this->default = array(
+ "lc_id" => "auto"
+ , "l_timestamp" => "auto"
+ );
+ global $cn;
+ $this->date_format = "DD.MM.YYYY";
+ parent::__construct($cn, $p_id);
+ }
+
+ /**
+ * @brief Add here your own code: verify is always call BEFORE insert or
update
+ */
+ public function verify()
+ {
+ parent::verify();
+ }
+
+}
+
+/**
+ * @brief Manage the table rapport_advanced.listing_compute_fiche
+ */
+class RAPAV_Listing_Compute_Fiche_SQL extends Phpcompta_SQL
+{
+
+ //------ Attributes-----
+ var $lf_id;
+ var $f_id;
+ var $lf_lob;
+ var $lf_filename;
+ var $lf_mimetype;
+ var $lc_id;
+
+ /* example private
$variable=array("easy_name"=>column_name,"email"=>"column_name_email","val3"=>0);
*/
+
+ function __construct($p_id = -1)
+ {
+
+
+ $this->table = "rapport_advanced.listing_compute_fiche";
+ $this->primary_key = "lf_id";
+
+ $this->name = array(
+ "lf_id" => "lf_id",
+ "f_id" => "f_id",
+ "lc_id" => "lc_id"
+ , "lf_lob" => "lf_lob"
+ , "lf_filename" => "lf_filename"
+ , "lf_mimetype" => "lf_mimetype"
+ );
+
+ $this->type = array(
+ "lf_id" => "numeric",
+ "lc_id" => "numeric",
+ "f_id" => "numeric"
+ , "lf_lob" => "set_me"
+ , "lf_filename" => "text"
+ , "lf_mimetype" => "text"
+ );
+
+ $this->default = array(
+ "lf_id" => "auto"
+ );
+ global $cn;
+ $this->date_format = "DD.MM.YYYY";
+ parent::__construct($cn, $p_id);
+ }
+
+ /**
+ * @brief Add here your own code: verify is always call BEFORE insert or
update
+ */
+ public function verify()
+ {
+ parent::verify();
+ }
+
+}
+
+/**
+ * @file
+ * @brief Manage the table rapport_advanced.listing_compute_detail
+ *
+ *
+ Example
+ @code
+
+ @endcode
+ */
+require_once('class_phpcompta_sql.php');
+
+/**
+ * @brief Manage the table rapport_advanced.listing_compute_detail
+ */
+class RAPAV_Listing_Compute_Detail_SQL extends Phpcompta_SQL
+{
+
+ //------ Attributes-----
+ var $lc_id;
+ var $ld_value_date;
+ var $ld_value_numeric;
+ var $ld_value_text;
+ var $lp_id;
+ var $lf_id;
+
+ /* example private
$variable=array("easy_name"=>column_name,"email"=>"column_name_email","val3"=>0);
*/
+
+ function __construct($p_id = -1)
+ {
+
+
+ $this->table = "rapport_advanced.listing_compute_detail";
+ $this->primary_key = "ld_id";
+
+ $this->name = array(
+ "ld_id" => "ld_id", "lc_id" => "lc_id"
+ , "ld_value_date" => "ld_value_date"
+ , "ld_value_numeric" => "ld_value_numeric"
+ , "ld_value_text" => "ld_value_text"
+ , "lp_id" => "lp_id"
+ , "lf_id" => "lf_id"
+ );
+
+ $this->type = array(
+ "ld_id" => "numeric",
+ "lc_id" => "numeric"
+ , "ld_value_date" => "date"
+ , "ld_value_numeric" => "numeric"
+ , "ld_value_text" => "text"
+ , "lp_id" => "numeric"
+ , "lf_id" => "numeric"
+ );
+
+ $this->default = array(
+ "ld_id" => "auto"
+ );
+ global $cn;
+ $this->date_format = "DD.MM.YYYY";
+ parent::__construct($cn, $p_id);
+ }
+
+ /**
+ * @brief Add here your own code: verify is always call BEFORE insert or
update
+ */
+ public function verify()
+ {
+ parent::verify();
+ }
+
+}
+
?>
Modified: trunk/rapport_avance/include/declaration.inc.php
===================================================================
--- trunk/rapport_avance/include/declaration.inc.php 2013-12-01 19:54:09 UTC
(rev 594)
+++ trunk/rapport_avance/include/declaration.inc.php 2013-12-03 02:28:15 UTC
(rev 595)
@@ -26,6 +26,8 @@
*
*/
require_once 'class_rapav_declaration.php';
+require_once 'class_rapav_listing.php';
+require_once 'class_rapav_listing_compute.php';
global $cn;
/*
@@ -33,118 +35,274 @@
*/
if (isset($_POST['save']))
{
- $decl = new Rapav_Declaration();
- $decl->d_id = $_POST['d_id'];
- $decl->load();
- $decl->to_keep = 'Y';
- $decl->f_id = $_POST['p_form'];
- $decl->save();
- if ( $decl->d_step == 0 ) {
- $decl->generate_document();
- } else
- {
- // get empty lob
- $decl->d_filename = null;
- $decl->d_size = null;
- $decl->d_mimetype = null;
- $decl->d_lob = null;
- $decl->update();
- }
- $decl->display();
- echo '<p class="notice">'._(' Sauvé ').date('d-m-Y H:i').'</p>';
+ $decl = new Rapav_Declaration();
+ $decl->d_id = $_POST['d_id'];
+ $decl->load();
+ $decl->to_keep = 'Y';
+ $decl->f_id = $_POST['p_form'];
+ $decl->save();
+ if ($decl->d_step == 0)
+ {
+ $decl->generate_document();
+ } else
+ {
+ // get empty lob
+ $decl->d_filename = null;
+ $decl->d_size = null;
+ $decl->d_mimetype = null;
+ $decl->d_lob = null;
+ $decl->update();
+ }
+ $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 != '' && $decl->d_step==0) echo
$decl->anchor_document();
- exit();
+ $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 != '' && $decl->d_step == 0)
+ echo $decl->anchor_document();
+ exit();
}
/*
* compute and propose to modify and save
*/
if (isset($_GET['compute']))
{
- $decl = new Rapav_Declaration();
- if (isDate($_GET['p_start']) == 0 || isDate($_GET['p_end']) == 0)
- {
- alert('Date invalide');
- }
- else
- {
- $decl->d_description=$_GET['p_description'];
- $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();
- echo HtmlInput::submit('save', 'Sauver');
- echo '</form>';
- exit();
- }
+ $decl = new Rapav_Declaration();
+ if (isDate($_GET['p_start']) == 0 || isDate($_GET['p_end']) == 0)
+ {
+ alert('Date invalide');
+ } else
+ {
+ $decl->d_description = $_GET['p_description'];
+ $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();
+ echo HtmlInput::submit('save', 'Sauver');
+ echo '</form>';
+ exit();
+ }
}
+/*
+ * compute listing
+ */
+if (isset($_GET['compute_listing']))
+{
+ $listing = new RAPAV_Listing_Compute();
+ if (isDate($_GET['p_start']) == 0 || isDate($_GET['p_end']) == 0)
+ {
+ alert('Date invalide');
+ } else
+ {
+ $listing->data->setp('description', $_GET['p_description']);
+ $p_listing = new Rapav_Listing($_GET['p_listing']);
+ $listing->filter_operation($_GET['p_operation_paid']);
+ $listing->compute($p_listing, $_GET['p_start'], $_GET['p_end']);
+ echo '<form class="print" method="POST">';
+ $listing->display();
+ echo HtmlInput::submit('save_listing', 'Sauver');
+ echo '</form>';
+ exit();
+ }
+}
+/*
+ * For rapport
+ */
$date_start = new IDate('p_start');
$date_end = new IDate('p_end');
$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 ITextArea('p_description');
-$description->heigh=2;
-$description->width=80;
+$description = new ITextArea('p_description');
+$description->heigh = 2;
+$description->style = ' class="itextarea" style="margin:0"';
-$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' => '2 mois', 'value' => 4),
- array('label' => '3 mois', 'value' => 5)
+$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' => '2 mois', 'value' => 4),
+ array('label' => '3 mois', 'value' => 5)
);
+/*
+ * For listing
+ */
+$date_start_listing = new IDate('p_start');
+$date_end_listing = new IDate('p_end');
+$select_listing = new ISelect('p_listing');
+$select_listing->value = $cn->make_array("select l_id, l_name||'
'||coalesce(l_description,'') from rapport_advanced.listing order by 2");
+$description_listing = new ITextArea('p_description');
+$description_listing->heigh = 2;
+$description_listing->style = ' class="itextarea" style="margin:0"';
+$description_listing->width = 80;
+$operation_paid = new ISelect('p_operation_paid');
+
+$operation_paid->value = array(
+ array('value' => 0, 'label' => 'Toutes les opérations'),
+ array('value' => 1, 'label' => 'Uniquement les opérations payées'),
+ array('value' => 2, 'label' => 'Uniquement les opérations non payées')
+);
?>
-<form id="declaration_form_id" method="GET" onsubmit="return validate()">
- <?php echo $hidden?>
- <table>
- <tr>
- <td>
- Déclaration
- </td>
- <td>
- <?php echo $select->input()?>
- </td>
- </tr>
- <tr>
- <td> Description</td><td> <?php echo $description->input()?></td>
- </tr>
- <tr>
- <td>
- Date de début
- </td>
- <td>
- <?php echo $date_start->input()?>
- </td>
- </tr>
- <tr>
- <td>
- Date de fin
- </td>
- <td>
- <?php echo $date_end->input()?>
- </td>
- </tr>
- <tr>
- <td>
- Etape de
- </td>
- <td>
- <?php echo $istep->input()?>
- </td>
- </tr>
- </table>
- </p>
- <?php echo HtmlInput::submit('compute', 'Générer')?>
-</form>
+<div id="Choix">
+ <h2>Choisissez ce que vous souhaitez générer</h2>
+ <table style="border-collapse: collapse;width: 40%">
+ <tr >
+ <td id="rapport_td_id" class="mtitle" style="border-radius: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">
+ <A class="mtitle"
HREF="javascript:void(0)"onclick="select_listing();"> Listing / Documents</A>
+ </td>
+ </tr>
+ </table>
+</div>
+
+<div id="id_rapport_div" style="display: none">
+ <form id="declaration_form_id" method="GET" onsubmit="return validate()">
+ <?php echo $hidden ?>
+ <input type="hidden" name="form" value="rapport">
+ <table style="min-width: 40%">
+ <tr>
+ <td>
+ Déclaration
+ </td>
+ <td>
+ <?php echo $select->input() ?>
+ </td>
+ </tr>
+ <tr>
+ <td> Description</td><td> <?php echo $description->input()
?></td>
+ </tr>
+ <tr>
+ <td>
+ Date de début
+ </td>
+ <td>
+ <?php echo $date_start->input() ?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Date de fin
+ </td>
+ <td>
+ <?php echo $date_end->input() ?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Etape de
+ </td>
+ <td>
+ <?php echo $istep->input() ?>
+ </td>
+ </tr>
+ </table>
+ </p>
+ <?php echo HtmlInput::submit('compute', 'Générer') ?>
+ </form>
+</div>
+<div id="id_listing_div" style="display: none">
+ <form method="GET" onsubmit="return validate_listing()">
+ <?php echo $hidden ?>
+ <input type="hidden" name="form" value="rapport">
+
+ <table style="min-width: 40%">
+ <tr>
+ <td>
+ Déclaration
+ </td>
+ <td>
+ <?php echo $select_listing->input() ?>
+ </td>
+ </tr>
+ <tr>
+ <td> Description</td><td> <?php echo
$description_listing->input() ?></td>
+ </tr>
+ <tr>
+ <td>
+ Date de début
+ </td>
+ <td>
+ <?php echo $date_start_listing->input() ?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Date de fin
+ </td>
+ <td>
+ <?php echo $date_end_listing->input() ?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Opérations
+ </td>
+ <td>
+ <?php echo $operation_paid->input(); ?>
+ </td>
+ </tr>
+ </table>
+ </p>
+ <?php echo HtmlInput::submit('compute_listing', 'Générer') ?>
+ </form>
+</div>
<script charset="UTF8" lang="javascript">
- function validate() {
- if ( check_date_id('<?php echo $date_start->id?>') == false )
{alert('Date de début incorrecte');$('<?php echo
$date_start->id?>').style.borderColor='red';$('<?php echo
$date_start->id?>').style.borderWidth=2;return false;}
- if ( check_date_id('<?php echo $date_end->id?>') == false )
{alert('Date de fin incorrecte');$('<?php echo
$date_end->id?>').style.borderColor='red';$('<?php echo
$date_end->id?>').style.borderWidth=2;return false;}
- }
+ function validate() {
+ if (check_date_id('<?php echo $date_start->id ?>') == false) {
+ alert('Date de début incorrecte');
+ $('<?php echo $date_start->id ?>').style.borderColor = 'red';
+ $('<?php echo $date_start->id ?>').style.borderWidth = 2;
+ return false;
+ }
+ if (check_date_id('<?php echo $date_end->id ?>') == false) {
+ alert('Date de fin incorrecte');
+ $('<?php echo $date_end->id ?>').style.borderColor = 'red';
+ $('<?php echo $date_end->id ?>').style.borderWidth = 2;
+ return false;
+ }
+ return true;
+ }
+ function validate_listing() {
+ /**
+ * @todo to adapt to listing
+ */
+ console.log("in validate_listing");
+ if (check_date_id('<?php echo $date_start_listing->id ?>') == false) {
+ alert('Date de début incorrecte');
+ $('<?php echo $date_start_listing->id ?>').style.borderColor =
'red';
+ $('<?php echo $date_start_listing->id ?>').style.borderWidth = 2;
+ return false;
+ }
+ if (check_date_id('<?php echo $date_end_listing->id ?>') == false) {
+ alert('Date de fin incorrecte');
+ $('<?php echo $date_end_listing->id ?>').style.borderColor = 'red';
+ $('<?php echo $date_end_listing->id ?>').style.borderWidth = 2;
+ return false;
+ }
+ return true;
+ }
+ function select_rapport() {
+ $('id_rapport_div').show();
+ $('id_listing_div').hide();
+ $('rapport_td_id').addClassName('selectedcell');
+ if ($('listing_td_id').hasClassName('selectedcell')) {
+ $('listing_td_id').removeClassName('selectedcell');
+ }
+ }
+ function select_listing() {
+ $('id_rapport_div').hide();
+ $('id_listing_div').show();
+ $('listing_td_id').addClassName('selectedcell');
+ if ($('rapport_td_id').hasClassName('selectedcell')) {
+ $('rapport_td_id').removeClassName('selectedcell');
+ }
+
+ }
</script>
\ No newline at end of file
Modified: trunk/rapport_avance/rapav_constant.php
===================================================================
--- trunk/rapport_avance/rapav_constant.php 2013-12-01 19:54:09 UTC (rev
594)
+++ trunk/rapport_avance/rapav_constant.php 2013-12-03 02:28:15 UTC (rev
595)
@@ -9,7 +9,7 @@
require_once ('class_database.php');
-global $cn,$rapav_version;
+global $cn,$rapav_version,$errcode;
$cn=new Database (dossier::id());
$rapav_version=4;
?>
Added: trunk/rapport_avance/sql/2-add-compute.sql
===================================================================
--- trunk/rapport_avance/sql/2-add-compute.sql (rev 0)
+++ trunk/rapport_avance/sql/2-add-compute.sql 2013-12-03 02:28:15 UTC (rev
595)
@@ -0,0 +1,6 @@
+-- for computing we need several new tables
+-- TABLES are :
+-- 1. listing_compute
+-- 2. listing_compute_detail
+-- 3. listing_condition
+-- 4. listing_compute_fiche
Added: trunk/rapport_avance/sql/2-listing_compute.sql
===================================================================
--- trunk/rapport_avance/sql/2-listing_compute.sql
(rev 0)
+++ trunk/rapport_avance/sql/2-listing_compute.sql 2013-12-03 02:28:15 UTC
(rev 595)
@@ -0,0 +1,33 @@
+-- Table: rapport_advanced.listing_compute
+
+-- DROP TABLE rapport_advanced.listing_compute;
+
+CREATE TABLE rapport_advanced.listing_compute
+(
+ lc_id bigserial NOT NULL, -- PK
+ l_id bigint, -- FK to listing
+ l_description text, -- Description or note
+ l_start date, -- start data
+ l_end date, -- end_date
+ l_keep character(1) NOT NULL DEFAULT 'N'::bpchar, -- If yes, it is keeped
with N it will deleted
+ l_timestamp timestamp without time zone DEFAULT now(),
+ CONSTRAINT listing_compute_pkey PRIMARY KEY (lc_id ),
+ CONSTRAINT listing_fk FOREIGN KEY (l_id)
+ REFERENCES rapport_advanced.listing (l_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE rapport_advanced.listing_compute
+ OWNER TO phpcompta;
+COMMENT ON TABLE rapport_advanced.listing_compute
+ IS 'Parent of listing_compute_detail
+';
+COMMENT ON COLUMN rapport_advanced.listing_compute.lc_id IS 'PK';
+COMMENT ON COLUMN rapport_advanced.listing_compute.l_id IS 'FK to listing';
+COMMENT ON COLUMN rapport_advanced.listing_compute.l_description IS
'Description or note';
+COMMENT ON COLUMN rapport_advanced.listing_compute.l_start IS 'start data';
+COMMENT ON COLUMN rapport_advanced.listing_compute.l_end IS 'end_date';
+COMMENT ON COLUMN rapport_advanced.listing_compute.l_keep IS 'If yes, it is
keeped with N it will deleted';
+
Added: trunk/rapport_avance/sql/2-listing_compute_detail.sql
===================================================================
--- trunk/rapport_avance/sql/2-listing_compute_detail.sql
(rev 0)
+++ trunk/rapport_avance/sql/2-listing_compute_detail.sql 2013-12-03
02:28:15 UTC (rev 595)
@@ -0,0 +1,55 @@
+-- Table: rapport_advanced.listing_compute_detail
+
+-- DROP TABLE rapport_advanced.listing_compute_detail;
+
+CREATE TABLE rapport_advanced.listing_compute_detail
+(
+ ld_id bigserial NOT NULL, -- PK
+ lc_id bigint, -- fk to listing_compute
+ ld_value_date date, -- Used when computed value is a date
+ ld_value_numeric numeric(20,4), -- Used when computed value is numeric
+ 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
+ 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
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT listing_compute_detail_lp_id_fkey FOREIGN KEY (lp_id)
+ REFERENCES rapport_advanced.listing_param (lp_id) MATCH SIMPLE
+ ON UPDATE SET NULL ON DELETE SET NULL
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE rapport_advanced.listing_compute_detail
+ OWNER TO phpcompta;
+COMMENT ON TABLE rapport_advanced.listing_compute_detail
+ IS 'Detail of computing listing_param';
+COMMENT ON COLUMN rapport_advanced.listing_compute_detail.ld_id IS 'PK';
+COMMENT ON COLUMN rapport_advanced.listing_compute_detail.lc_id IS 'fk to
listing_compute';
+COMMENT ON COLUMN rapport_advanced.listing_compute_detail.ld_value_date IS
'Used when computed value is a date';
+COMMENT ON COLUMN rapport_advanced.listing_compute_detail.ld_value_numeric IS
'Used when computed value is numeric';
+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';
+
+
+-- Index: rapport_advanced.fki_listing_compute_fiche_lf_id2_fk
+
+-- DROP INDEX rapport_advanced.fki_listing_compute_fiche_lf_id2_fk;
+
+CREATE INDEX fki_listing_compute_fiche_lf_id2_fk
+ ON rapport_advanced.listing_compute_detail
+ USING btree
+ (lf_id );
+
+-- Index: rapport_advanced.fki_listing_compute_fiche_lf_id_fk
+
+-- DROP INDEX rapport_advanced.fki_listing_compute_fiche_lf_id_fk;
+
+CREATE INDEX fki_listing_compute_fiche_lf_id_fk
+ ON rapport_advanced.listing_compute_detail
+ USING btree
+ (lf_id );
+
Added: trunk/rapport_avance/sql/2-listing_compute_fiche.sql
===================================================================
--- trunk/rapport_avance/sql/2-listing_compute_fiche.sql
(rev 0)
+++ trunk/rapport_avance/sql/2-listing_compute_fiche.sql 2013-12-03
02:28:15 UTC (rev 595)
@@ -0,0 +1,31 @@
+-- Table: rapport_advanced.listing_compute_fiche
+
+-- DROP TABLE rapport_advanced.listing_compute_fiche;
+
+CREATE TABLE rapport_advanced.listing_compute_fiche
+(
+ lf_id serial NOT NULL, -- PK
+ f_id bigint NOT NULL, -- FK to fiche
+ lf_lob oid, -- Generated file if any
+ lf_filename text, -- Name of the generated file. It should be based on the
name of the template + unique id
+ lf_mimetype text, -- Same mimetype as in table listing
+ CONSTRAINT listing_compute_fiche_pkey PRIMARY KEY (lf_id ),
+ CONSTRAINT listing_compute_fiche_f_id_fkey FOREIGN KEY (f_id)
+ REFERENCES fiche (f_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE rapport_advanced.listing_compute_fiche
+ OWNER TO phpcompta;
+COMMENT ON TABLE rapport_advanced.listing_compute_fiche
+ IS 'Content :
+card
+document to generate';
+COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_id IS 'PK';
+COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.f_id IS 'FK to fiche';
+COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_lob IS 'Generated
file if any';
+COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_filename IS 'Name
of the generated file. It should be based on the name of the template + unique
id';
+COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_mimetype IS 'Same
mimetype as in table listing';
+
Added: trunk/rapport_avance/sql/2-listing_condition.sql
===================================================================
--- trunk/rapport_avance/sql/2-listing_condition.sql
(rev 0)
+++ trunk/rapport_avance/sql/2-listing_condition.sql 2013-12-03 02:28:15 UTC
(rev 595)
@@ -0,0 +1,18 @@
+-- Table: rapport_advanced.listing_condition
+
+-- DROP TABLE rapport_advanced.listing_condition;
+
+CREATE TABLE rapport_advanced.listing_condition
+(
+ lc_id bigserial NOT NULL, -- PK
+ CONSTRAINT listing_condition_pkey PRIMARY KEY (lc_id )
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE rapport_advanced.listing_condition
+ OWNER TO phpcompta;
+COMMENT ON TABLE rapport_advanced.listing_condition
+ IS 'Content condition for a generation';
+COMMENT ON COLUMN rapport_advanced.listing_condition.lc_id IS 'PK';
+
---
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] r595 - in trunk/rapport_avance: . include sql,
phpcompta-dev <=