diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 97462e875..3b7b63079 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -2855,5 +2855,31 @@ class Acc_Ledger ); return $r; } + /** + *Retrieve the third : supplier for purchase, customer for sale, bank for fin, + *@param $p_jrn_type type of the ledger FIN, VEN ACH or ODS + */ + function get_tiers($p_jrn_type,$jr_id) + { + if ( $p_jrn_type == 'ODS') return ' '; + $tiers=''; + switch ($p_jrn_type) + { + case 'VEN': + $tiers=$this->db->get_value('select max(qs_client) from quant_sold join jrnx using (j_id) join jrn on (jr_grpt_id=j_grpt) where jrn.jr_id=$1',array($jr_id)); + break ; + case 'ACH': + $tiers=$this->db->get_value('select max(qp_supplier) from quant_purchase join jrnx using (j_id) join jrn on (jr_grpt_id=j_grpt) where jrn.jr_id=$1',array($jr_id)); + break ; + case 'FIN': + $tiers=$this->db->get_value('select qf_bank from quant_fin where jr_id=$1',array($jr_id)); + break ; + + } + if ($this->db->count()==0) return ''; + $name=$this->db->get_value('select ad_value from fiche_detail where ad_id=1 and f_id=$1',array($tiers)); + $first_name=$this->db->get_value('select ad_value from fiche_detail where ad_id=32 and f_id=$1',array($tiers)); + return $name.' '.$first_name; + } } diff --git a/include/class_print_ledger_fin.php b/include/class_print_ledger_fin.php index 738efd200..e2f094c84 100644 --- a/include/class_print_ledger_fin.php +++ b/include/class_print_ledger_fin.php @@ -22,6 +22,7 @@ /*!\file * \brief print a listing of financial + *\todo Must add the third part */ require_once('class_pdf.php'); class Print_Ledger_Financial extends PDF diff --git a/include/class_print_ledger_simple.php b/include/class_print_ledger_simple.php index e21f1cd51..e1885342d 100644 --- a/include/class_print_ledger_simple.php +++ b/include/class_print_ledger_simple.php @@ -23,6 +23,7 @@ /*!\file * \brief this class extends PDF and let you export the detailled printing * of any ledgers + *\todo Must add the third part */ require_once('class_pdf.php'); diff --git a/include/class_print_ledger_simple_without_vat.php b/include/class_print_ledger_simple_without_vat.php index bb4471a78..629973831 100644 --- a/include/class_print_ledger_simple_without_vat.php +++ b/include/class_print_ledger_simple_without_vat.php @@ -23,6 +23,7 @@ /*!\file * \brief this class extends PDF and let you export the detailled printing * of any ledgers + * *\todo Must add the third part */ require_once('class_pdf.php'); diff --git a/include/export_ledger_csv.php b/include/export_ledger_csv.php index 08505cefd..7fb17b45a 100644 --- a/include/export_ledger_csv.php +++ b/include/export_ledger_csv.php @@ -99,6 +99,7 @@ else printf ('" operation";'. '"Date";'. '"N° Pièce";'. + '"Tiers";'. '"commentaire";'. '"internal";'. '"montant";'. @@ -109,6 +110,7 @@ else echo $line['num'].";"; echo $line['date'].";"; echo $line['jr_pj_number'].";"; + echo $Jrn->get_tiers($line['jrn_def_type'],$line['jr_id']).";"; echo $line['comment'].";"; echo $line['jr_internal'].";"; // echo "".$line['pj'].";"; @@ -151,7 +153,7 @@ else printf('"%s";"%s";"%s";"%s";"%s";%s;', $line['date'], $line['num'], - $line['client'], + $Jrn->get_tiers($line['jrn_def_type'],$line['jr_id']), $line['comment'], $line['jr_internal'], nb($line['HTVA'])); diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index 609345144..cf9bf5ef0 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -238,6 +238,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) "Date". " n° de pièce ". "internal". + th('Tiers'). "Commentaire". " montant". ""; @@ -250,8 +251,11 @@ if ( isset( $_REQUEST['bt_html'] ) ) echo "".$line['date'].""; echo "".h($line['jr_pj_number']).""; echo "".HtmlInput::detail_op($line['jr_id'],$line['jr_internal']).""; + $tiers=$Jrn->get_tiers($line['jrn_def_type'],$line['jr_id']); + echo td($tiers); echo "".h($line['comment']).""; + // echo "".$line['pj'].""; // If the ledger is financial : // the credit must be negative and written in red