diff --git a/contrib/document_test/note-de-frais.odt b/contrib/document_test/note-de-frais.odt index 4f6993459..8b5c5d475 100644 Binary files a/contrib/document_test/note-de-frais.odt and b/contrib/document_test/note-de-frais.odt differ diff --git a/doc/manuel-fr.odt b/doc/manuel-fr.odt index d7cf23afb..33b46d01a 100644 Binary files a/doc/manuel-fr.odt and b/doc/manuel-fr.odt differ diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 8deccb040..cfb6e5327 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -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 '

'.$str_file.'

'; + return h($doc->d_name.' ('.$doc->d_filename.')'); } /*!\brief check if the payment method is valid diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index 91249e733..86b49f558 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -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.=''._('Note de frais').''; + $this->doc.=''.$ref_doc.''; } //---------------------------------------- @@ -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.='
'; @@ -1316,7 +1316,7 @@ array $r.='
'; $r.=_('ou générer un document').' '; - // 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( diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php index 16b4cb944..7879f7f7c 100644 --- a/include/class_acc_ledger_sold.php +++ b/include/class_acc_ledger_sold.php @@ -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.='Facture'; + $this->doc.=''.$file.''; } } //---------------------------------------- diff --git a/include/class_document.php b/include/class_document.php index 0ac99ae35..a0691ab31 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -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