[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r4763 - phpcompta/tags/rel600/include
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r4763 - phpcompta/tags/rel600/include |
Date: |
Wed, 8 Feb 2012 17:49:44 +0100 (CET) |
Author: danydb
Date: 2012-02-08 17:49:44 +0100 (Wed, 08 Feb 2012)
New Revision: 4763
Modified:
phpcompta/tags/rel600/include/ac_common.php
phpcompta/tags/rel600/include/action.common.inc.php
phpcompta/tags/rel600/include/class_acc_ledger.php
phpcompta/tags/rel600/include/class_document.php
phpcompta/tags/rel600/include/class_follow_up.php
Log:
Improve : generate document : default argument is an array
Modified: phpcompta/tags/rel600/include/ac_common.php
===================================================================
--- phpcompta/tags/rel600/include/ac_common.php 2012-02-07 17:50:55 UTC (rev
4762)
+++ phpcompta/tags/rel600/include/ac_common.php 2012-02-08 16:49:44 UTC (rev
4763)
@@ -698,15 +698,37 @@
/**
* @brief format the date, when taken from the database the format
* is MM-DD-YYYY
- * @param $p_date format YYYY-MM-DD
+ * @param $p_date format
+ * @param
* @return date in the format DD.MM.YYYY
*/
-function format_date($p_date)
+function format_date($p_date, $p_from_format =
'YYYY-MM-DD',$p_to_format='DD.MM.YYYY')
{
- $date = explode('-', $p_date);
- if (count($date) != 3)
- return $p_date;
- $str_date = $date[2] . '.' . $date[1] . '.' . $date[0];
+ if ($p_from_format == 'YYYY-MM-DD')
+ {
+ $date = explode('-', $p_date);
+ if (count($date) != 3)
+ return $p_date;
+ }
+ if ($p_from_format == 'DD.MM.YYYY')
+ {
+ $temp_date = explode('.', $p_date);
+ if (count($temp_date) != 3)
+ return $p_date;
+ $date[0] = $temp_date[2]; // 0 is year
+ $date[1] = $temp_date[1]; // 1 for month
+ $date[2] = $temp_date[0]; // 2 for day
+ }
+
+ switch ($p_to_format)
+ {
+ case 'DD.MM.YYYY':
+ $str_date = $date[2] . '.' . $date[1] . '.' . $date[0];
+ break;
+ case 'YYYY-MM-DD':
+ $str_date = $date[0] . '-' . $date[1] . '-' . $date[2];
+ break;
+ }
return $str_date;
}
Modified: phpcompta/tags/rel600/include/action.common.inc.php
===================================================================
--- phpcompta/tags/rel600/include/action.common.inc.php 2012-02-07 17:50:55 UTC
(rev 4762)
+++ phpcompta/tags/rel600/include/action.common.inc.php 2012-02-08 16:49:44 UTC
(rev 4763)
@@ -56,7 +56,7 @@
{
$act->Update();
}
- $act->generate_document($_POST['doc_mod']);
+ $act->generate_document($_POST['doc_mod'],$_POST);
$sub_action='detail';
}
/* for delete */
Modified: phpcompta/tags/rel600/include/class_acc_ledger.php
===================================================================
--- phpcompta/tags/rel600/include/class_acc_ledger.php 2012-02-07 17:50:55 UTC
(rev 4762)
+++ phpcompta/tags/rel600/include/class_acc_ledger.php 2012-02-08 16:49:44 UTC
(rev 4763)
@@ -2213,7 +2213,7 @@
$doc->f_id=$e_client;
$doc->md_id=$gen_doc;
$doc->ag_id=0;
- $doc->Generate();
+ $doc->Generate($p_array);
// Move the document to the jrn
$doc->MoveDocumentPj($internal);
// Update the comment with invoice number, if the comment is empty
Modified: phpcompta/tags/rel600/include/class_document.php
===================================================================
--- phpcompta/tags/rel600/include/class_document.php 2012-02-07 17:50:55 UTC
(rev 4762)
+++ phpcompta/tags/rel600/include/class_document.php 2012-02-08 16:49:44 UTC
(rev 4763)
@@ -66,12 +66,12 @@
/*!
* \brief Generate the document, Call $this-\>Replace to replace
* tag by value
+ *\p_array contains the data normally it is the $_POST
*
- *
* \return an array : the url where the generated doc can be found, the
name
* of the file and his mimetype
*/
- function Generate()
+ function Generate($p_array)
{
// create a temp directory in /tmp to unpack file and to parse it
$dirname=tempnam($_ENV['TMP'],'doc_');
@@ -123,7 +123,7 @@
$this->d_number=$this->db->get_next_seq("seq_doc_type_".$row['md_type']);
// parse the document - return the doc number ?
- $this->ParseDocument($dirname,$file_to_parse,$type);
+ $this->ParseDocument($dirname,$file_to_parse,$type,$p_array);
$this->db->commit();
// if the doc is a OOo, we need to re-zip it
@@ -161,8 +161,9 @@
* \param $p_dir directory name
* \param $p_file filename
* \param $p_type For the OOo document the tag are < and > instead of
< and >
+ * \param $p_array variable from $_POST
*/
- function ParseDocument($p_dir,$p_file,$p_type)
+ function ParseDocument($p_dir,$p_file,$p_type,$p_array)
{
/*!\note Replace in the doc the tags by their values.
@@ -239,7 +240,7 @@
// if the pattern if found we replace it
- $value=$this->Replace($pattern);
+ $value=$this->Replace($pattern,$p_array);
if ( strpos($value,'ERROR') != false )
$value="";
// replace into the $buffer
// take the position in the buffer
@@ -494,9 +495,10 @@
* - [BENEF_VAT]
*
* \param $p_tag TAG
+ * \param $p_array data from $_POST
* \return String which must replace the tag
*/
- function Replace($p_tag)
+ function Replace($p_tag,$p_array)
{
$p_tag=strtoupper($p_tag);
$p_tag=str_replace('=','',$p_tag);
@@ -506,13 +508,16 @@
{
case 'DATE':
$r=' Date inconnue ';
- // Date are in $_REQUEST['ag_date']
- // or $_POST['e_date']
- if ( isset ($_REQUEST['ag_timestamp']))
- $r=$_REQUEST['ag_timestamp'];
- if ( isset ($_REQUEST['e_date']))
- $r=$_REQUEST['e_date'];
-
+ // Date are in $p_array['ag_date']
+ // or $p_array['e_date']
+ if ( isset ($p_array['ag_timestamp'])) {
+
$date=format_date($p_array['ag_timestamp'],'DD.MM.YYYY','YYYY-MM-DD');
+ $r=$date;
+ }
+ if ( isset ($p_array['e_date'])) {
+
$date=format_date($p_array['e_date'],'DD.MM.YYYY','YYYY-MM-DD');
+ $r=$date;
+ }
break;
//
// the company priv
@@ -555,12 +560,12 @@
break;
// customer
- /*\note The CUST_* are retrieved thx the $_REQUEST['tiers']
+ /*\note The CUST_* are retrieved thx the $p_array['tiers']
* which contains the quick_code
*/
case 'SOLDE':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$p=$tiers->strAttribut(ATTR_DEF_ACCOUNT);
$poste=new Acc_Account_Ledger($this->db,$p);
@@ -568,13 +573,13 @@
break;
case 'CUST_NAME':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NAME);
break;
case 'CUST_ADDR_1':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_ADRESS);
@@ -582,7 +587,7 @@
case 'CUST_CP':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_CP);
@@ -590,7 +595,7 @@
case 'CUST_CITY':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_CITY);
@@ -599,35 +604,35 @@
case 'CUST_CO':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_PAYS);
break;
- // Marchandise in $_POST['e_march*']
+ // Marchandise in $p_array['e_march*']
// \see user_form_achat.php or user_form_ven.php
case 'CUST_VAT':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NUMTVA);
break;
case 'CUST_NUM':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER);
break;
case 'CUST_BANQUE_NO':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_BQ_NO);
break;
case 'CUST_BANQUE_NAME':
$tiers=new Fiche($this->db);
-
$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client'];
+
$qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client'];
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_BQ_NAME);
break;
@@ -635,7 +640,7 @@
/* BENEFIT (fee notes */
case 'BENEF_NAME':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -646,7 +651,7 @@
break;
case 'BENEF_ADDR_1':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -659,7 +664,7 @@
case 'BENEF_CP':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -672,7 +677,7 @@
case 'BENEF_CITY':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -686,7 +691,7 @@
case 'BENEF_CO':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -696,12 +701,12 @@
$r=$tiers->strAttribut(ATTR_DEF_PAYS);
break;
- // Marchandise in $_POST['e_march*']
+ // Marchandise in $p_array['e_march*']
// \see user_form_achat.php or user_form_ven.php
case 'BENEF_VAT':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -712,7 +717,7 @@
break;
case 'BENEF_NUM':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -723,7 +728,7 @@
break;
case 'BENEF_BANQUE_NO':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -734,7 +739,7 @@
break;
case 'BENEF_BANQUE_NAME':
$tiers=new Fiche($this->db);
- $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
+ $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
if ( $qcode=='')
{
$r='';
@@ -744,7 +749,7 @@
$r=$tiers->strAttribut(ATTR_DEF_BQ_NAME);
break;
- // Marchandise in $_POST['e_march*']
+ // Marchandise in $p_array['e_march*']
// \see user_form_achat.php or user_form_ven.php
case 'NUMBER':
$r=$this->d_number;
@@ -775,10 +780,10 @@
* - [DATE_LIMIT]
*/
case 'DATE_LIMIT':
- extract ($_POST);
+ extract ($p_array);
$id='e_ech' ;
if ( !isset (${$id}) ) return "";
- $r=${$id};
+ $r=format_date(${$id},'DD.MM.YYYY','YYYY-MM-DD');
break;
case 'MARCH_NEXT':
@@ -787,7 +792,7 @@
break;
case 'VEN_ART_NAME':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter;
// check if the march exists
if ( ! isset (${$id})) return "";
@@ -801,7 +806,7 @@
else $r = "";
break;
case 'VEN_ART_LABEL':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter."_label";
// check if the march exists
@@ -826,7 +831,7 @@
break;
case 'VEN_ART_PRICE':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter.'_price' ;
if ( !isset (${$id}) ) return "";
$r=${$id};
@@ -834,7 +839,7 @@
case 'TVA_RATE':
case 'VEN_ART_TVA_RATE':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter.'_tva_id';
if ( !isset (${$id}) ) return "";
if ( ${$id} == -1 || ${$id}=='' ) return "";
@@ -848,7 +853,7 @@
case 'TVA_CODE':
case 'VEN_ART_TVA_CODE':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter.'_tva_id';
if ( !isset (${$id}) ) return "";
if ( ${$id} == -1 ) return "";
@@ -863,7 +868,7 @@
break;
case 'TVA_LABEL':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter.'_tva_id';
if ( !isset (${$id}) ) return "";
$march_id='e_march'.$counter.'_price' ;
@@ -877,7 +882,7 @@
/* total VAT for one sold */
case 'TVA_AMOUNT':
- extract ($_POST);
+ extract ($p_array);
$qt='e_quant'.$counter;
$price='e_march'.$counter.'_price' ;
$tva='e_march'.$counter.'_tva_id';
@@ -893,7 +898,7 @@
break;
/* TVA automatically computed */
case 'VEN_ART_TVA':
- extract ($_POST);
+ extract ($p_array);
$qt='e_quant'.$counter;
$price='e_march'.$counter.'_price' ;
$tva='e_march'.$counter.'_tva_id';
@@ -910,7 +915,7 @@
break;
case 'VEN_ART_TVAC':
- extract ($_POST);
+ extract ($p_array);
$qt='e_quant'.$counter;
$price='e_march'.$counter.'_price' ;
$tva='e_march'.$counter.'_tva_id';
@@ -934,7 +939,7 @@
break;
case 'VEN_ART_QUANT':
- extract ($_POST);
+ extract ($p_array);
$id='e_quant'.$counter;
if ( !isset (${$id}) ) return "";
// check that something is sold
@@ -947,7 +952,7 @@
break;
case 'VEN_HTVA':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter.'_price' ;
$quant='e_quant'.$counter;
if ( !isset (${$id}) ) return "";
@@ -962,7 +967,7 @@
break;
case 'VEN_TVAC':
- extract ($_POST);
+ extract ($p_array);
$id='e_march'.$counter.'_tva_amount' ;
$price='e_march'.$counter.'_price' ;
$quant='e_quant'.$counter;
@@ -985,7 +990,7 @@
break;
case 'TOTAL_VEN_HTVA':
- extract($_POST);
+ extract($p_array);
$sum=0.0;
for ($i=0;$i<$nb_item;$i++)
@@ -1007,7 +1012,7 @@
$r=round($sum,2);
break;
case 'TOTAL_VEN_TVAC':
- extract($_POST);
+ extract($p_array);
$sum=0.0;
for ($i=0;$i<$nb_item;$i++)
{
@@ -1029,7 +1034,7 @@
break;
case 'TOTAL_TVA':
- extract($_POST);
+ extract($p_array);
$sum=0.0;
for ($i=0;$i<$nb_item;$i++)
{
@@ -1046,26 +1051,26 @@
break;
case 'BON_COMMANDE':
- if ( isset($_REQUEST['bon_comm']))
- return $_REQUEST['bon_comm'];
+ if ( isset($p_array['bon_comm']))
+ return $p_array['bon_comm'];
else
return "";
break;
case 'PJ':
- if ( isset($_REQUEST['e_pj']))
- return $_REQUEST['e_pj'];
+ if ( isset($p_array['e_pj']))
+ return $p_array['e_pj'];
else
return "";
case 'OTHER_INFO':
- if ( isset($_REQUEST['other_info']))
- return $_REQUEST['other_info'];
+ if ( isset($p_array['other_info']))
+ return $p_array['other_info'];
else
return "";
break;
case 'COMMENT':
- if ( isset($_REQUEST['e_comm']))
- return $_REQUEST['e_comm'];
+ if ( isset($p_array['e_comm']))
+ return $p_array['e_comm'];
break;
}
return $r;
Modified: phpcompta/tags/rel600/include/class_follow_up.php
===================================================================
--- phpcompta/tags/rel600/include/class_follow_up.php 2012-02-07 17:50:55 UTC
(rev 4762)
+++ phpcompta/tags/rel600/include/class_follow_up.php 2012-02-08 16:49:44 UTC
(rev 4763)
@@ -914,8 +914,9 @@
/*!\brief generate the document and add it to the action
* \param md_id is the id of the document_modele
+ * \param $p_array contains normally the $_POST
*/
- function generate_document($md_id)
+ function generate_document($md_id,$p_array)
{
$doc=new Document($this->db);
$mod=new Document_Modele($this->db,$md_id);
@@ -923,7 +924,7 @@
$doc->f_id=$this->f_id_dest;
$doc->md_id=$md_id;
$doc->ag_id=$this->ag_id;
- $doc->Generate();
+ $doc->Generate($p_array);
}
/*!\brief put an array in the variable member, the indice
* is the member name
---
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] r4763 - phpcompta/tags/rel600/include,
phpcompta-dev <=