Purchase can generate all type of document, new tag BENEF_X

This commit is contained in:
Dany De Bontridder 2010-07-31 14:46:31 +00:00
parent 076aa7d1bf
commit 61f253e18c
6 changed files with 104 additions and 20 deletions

Binary file not shown.

View file

@ -1957,7 +1957,7 @@ function get_last_date()
$doc->f_id=$e_client;
$doc->md_id=$gen_doc;
$doc->ag_id=0;
$str_file=$doc->Generate();
$doc->Generate();
// Move the document to the jrn
$doc->MoveDocumentPj($internal);
// Update the comment with invoice number, if the comment is empty
@ -1965,7 +1965,7 @@ function get_last_date()
$sql="update jrn set jr_comment=' document ".$doc->d_number."' where jr_internal='$internal'";
$this->db->exec_sql($sql);
}
return '<h2 class="info">'.$str_file.'</h2>';
return h($doc->d_name.' ('.$doc->d_filename.')');
}
/*!\brief check if the payment method is valid

View file

@ -577,10 +577,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
$str_file="";
/* Generate an document and save it into the database (Note de frais only)
*/
if ( isset($_POST['gen_invoice']) && $e_mp != 0) {
$this->create_document($internal,$p_array);
if ( isset($_POST['gen_invoice']) ) {
$ref_doc= $this->create_document($internal,$p_array);
$this->doc= _('Document généré');
$this->doc.='<A style="display:inline" HREF="show_pj.php?'.dossier::get().'&jr_grpt_id='.$seq.'&jrn='.$this->id.'">'._('Note de frais').'</A>';
$this->doc.='<A style="display:inline" HREF="show_pj.php?'.dossier::get().'&jr_grpt_id='.$seq.'&jrn='.$this->id.'">'.$ref_doc.'</A>';
}
//----------------------------------------
@ -1273,7 +1273,7 @@ array
$r.=HtmlInput::hidden('e_mp_qcode_'.$e_mp,${'e_mp_qcode_'.$e_mp});
/* needed for generating a invoice */
$r.=HtmlInput::hidden('qcode_dest',${'e_mp_qcode_'.$e_mp});
$r.=HtmlInput::hidden('qcode_benef',${'e_mp_qcode_'.$e_mp});
$r.="Payé par ".${'e_mp_qcode_'.$e_mp};
$r.='<br>';
@ -1316,7 +1316,7 @@ array
$r.='<hr>';
$r.=_('ou générer un document').' <input type="checkbox" name="gen_invoice" CHECKED>';
// We propose to generate the note of fee
// We propose to generate the fee note
$doc_gen=new ISelect();
$doc_gen->name="gen_doc";
$doc_gen->value=$this->db->make_array(

View file

@ -421,9 +421,9 @@ class Acc_Ledger_Sold extends Acc_Ledger {
else
/* Generate an invoice and save it into the database */
if ( isset($_POST['gen_invoice'])) {
$this->create_document($internal,$p_array);
$file=$this->create_document($internal,$p_array);
$this->doc= _('Document généré');
$this->doc.='<A STYLE="display:inline;" HREF="show_pj.php?'.dossier::get().'&jr_grpt_id='.$seq.'&jrn='.$this->id.'">Facture</A>';
$this->doc.='<A STYLE="display:inline;" HREF="show_pj.php?'.dossier::get().'&jr_grpt_id='.$seq.'&jrn='.$this->id.'">'.$file.'</A>';
}
}
//----------------------------------------

View file

@ -80,7 +80,7 @@ class Document
mkdir ($dirname);
// Retrieve the lob and save it into $dirname
$this->db->start();
$dm_info="select md_type,md_lob,md_filename,md_mimetype
$dm_info="select md_name,md_type,md_lob,md_filename,md_mimetype
from document_modele where md_id=".$this->md_id;
$Res=$this->db->exec_sql($dm_info);
@ -88,6 +88,7 @@ class Document
$this->d_lob=$row['md_lob'];
$this->d_filename=$row['md_filename'];
$this->d_mimetype=$row['md_mimetype'];
$this->d_name=$row['md_name'];
chdir($dirname);
@ -424,7 +425,6 @@ class Document
* - [CUST_CP] customer's ZIP code
* - [CUST_CO] customer's country
* - [CUST_CITY] customer's city
* - [CUST_COUNTRY]
* - [CUST_VAT] customer's VAT
* - [MARCH_NEXT] end this item and increment the counter $i
* - [DATE_LIMIT]
@ -446,15 +446,23 @@ class Document
* - [MY_TVA]
* - [MY_STREET]
* - [MY_NUMBER]
* - TVA_CODE
* - TVA_RATE
* - BON_COMMANDE
* - OTHER_INFO
* - CUST_NUM
* - CUST_BANQUE_NAME
* - CUST_BANQUE_NO
* - USER
* - REFERENCE
* - [TVA_CODE]
* - [TVA_RATE]
* - [BON_COMMANDE]
* - [OTHER_INFO]
* - [CUST_NUM]
* - [CUST_BANQUE_NAME]
* - [CUST_BANQUE_NO]
* - [USER]
* - [REFERENCE]
* - [BENEF_NAME]
* - [BENEF_BANQUE_NAME]
* - [BENEF_BANQUE_NO]
* - [BENEF_ADDR_1]
* - [BENEF_CP]
* - [BENEF_CO]
* - [BENEF_CITY]
* - [BENEF_VAT]
*
* \param $p_tag TAG
* \return String which must replace the tag
@ -594,6 +602,82 @@ class Document
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_BQ_NAME);
break;
/* -------------------------------------------------------------------------------- */
/* BENEFIT (fee notes */
case 'BENEF_NAME':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NAME);
break;
case 'BENEF_ADDR_1':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_ADRESS);
break ;
case 'BENEF_CP':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_CP);
break;
case 'BENEF_CITY':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_CITY);
break;
case 'BENEF_CO':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_PAYS);
break;
// Marchandise in $_POST['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']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NUMTVA);
break;
case 'BENEF_NUM':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER);
break;
case 'BENEF_BANQUE_NO':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_BQ_NO);
break;
case 'BENEF_BANQUE_NAME':
$tiers=new Fiche($this->db);
$qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:'';
if ( $qcode=='') {$r='';break;}
$tiers->get_by_qcode($qcode,false);
$r=$tiers->strAttribut(ATTR_DEF_BQ_NAME);
break;
// Marchandise in $_POST['e_march*']
// \see user_form_achat.php or user_form_ven.php