diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 973086e95b936f6f8c2ed88ea8af2a73cca98af9..e89799d765e7d7c4e69f76f2f0590147089bfd76 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -79,7 +79,7 @@ if (empty($search_date_start)) { if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") - $sortfield = "t.rowid"; + $sortfield = "t.numero_compte"; $options = ''; $filter = array (); @@ -151,16 +151,16 @@ else { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result); - + print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<div class="tabsAction">' . "\n"; print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>'; print '</div>'; $moreforfilter=''; - + $moreforfilter.='<div class="divsearchfield">'; $moreforfilter.=$langs->trans('DateStart') . ': '; $moreforfilter.=$form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); @@ -177,7 +177,7 @@ else { print $hookmanager->resPrint; print '</div>'; } - + print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">'; print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 6100e54c9a373eb2e18ddeed7ac12c86e5f28b83..557143164a9492b1f062597f13e2aa80f78c42e4 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -236,91 +236,13 @@ if ($action == 'export_csv') { } else { - if (in_array($conf->global->ACCOUNTING_EXPORT_MODELCSV, array(5,6))) // TODO remove the conditional and keep the code in the "else" - { - $accountancyexport = new AccountancyExport($db); - $accountancyexport->export($object->lines); - if (!empty($accountancyexport->errors)) setEventMessages('', $accountancyexport->errors, 'errors'); - else exit; + $accountancyexport = new AccountancyExport($db); + $accountancyexport->export($object->lines); + if (!empty($accountancyexport->errors)) { + setEventMessages('', $accountancyexport->errors, 'errors'); } + exit; } - - - // TODO remove next 3 lines and foreach to implement the AccountancyExport method for each model - $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $journal = 'bookkepping'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - - foreach ( $object->lines as $line ) { - - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { - $sep = ";"; - // Model Cegid Expert Export - $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accountg($line->numero_compte) . $sep; - print ' ' . $sep; - print $line->sens . $sep; - print price($line->montant) . $sep; - print dol_trunc($line->label_compte, 32) . $sep; - print $line->doc_ref . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - - // Std export - $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); - print $date . $sep; - print $line->doc_ref . $sep; - print length_accountg($line->numero_compte) . $sep; - print length_accounta($line->code_tiers) . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print $line->code_journal . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - - // Coala export - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accountg($line->numero_compte) . $sep; - print $line->piece_num . $sep; - print $line->doc_ref . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print 'E' . $sep; - print length_accountg($line->code_tiers) . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 4) { - - // Bob50 - print $line->piece_num . $sep; - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $sep; - - if (empty($line->code_tiers)) { - print 'G' . $sep; - print length_accounta($line->numero_compte) . $sep; - } else { - if (substr($line->numero_compte,0,3)=='411') { - print 'C' . $sep; - } - if (substr($line->numero_compte,0,3)=='401') { - print 'F' . $sep; - } - print length_accountg($line->code_tiers) . $sep; - - } - - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print dol_trunc($line->label_compte, 32) . $sep; - print "\n"; - } - } - - exit; } /* diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index ad5ecd3d1bf7930aa5f9a691a9cd742cf002c0b9..c7920577adcc508e772fe33350735d0882fa4835 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1,9 +1,10 @@ <?php -/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> - * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr> +/* + * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> + * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> + * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -12,7 +13,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -20,7 +21,7 @@ */ /** - * \file htdocs/accountancy/class/accountancyexport.class.php + * \file htdocs/accountancy/class/accountancyexport.class.php */ /** @@ -29,30 +30,34 @@ * Manage the different format accountancy export */ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; - class AccountancyExport { /** + * * @var Type of export */ - public static $EXPORT_TYPE_NORMAL = 1; - public static $EXPORT_TYPE_CEGID = 2; - public static $EXPORT_TYPE_COALA = 3; - public static $EXPORT_TYPE_BOB50 = 4; - public static $EXPORT_TYPE_CIEL = 5; - public static $EXPORT_TYPE_QUADRATUS = 6; + public static $EXPORT_TYPE_NORMAL = 1; + public static $EXPORT_TYPE_CEGID = 2; + public static $EXPORT_TYPE_COALA = 3; + public static $EXPORT_TYPE_BOB50 = 4; + public static $EXPORT_TYPE_CIEL = 5; + public static $EXPORT_TYPE_QUADRATUS = 6; + public static $EXPORT_TYPE_EBP = 7; /** + * * @var string[] Error codes (or messages) */ - public $errors = array(); + public $errors = array (); /** + * * @var string Separator */ public $separator = ''; /** + * * @var string End of line */ public $end_line = ''; @@ -62,8 +67,7 @@ class AccountancyExport * * @param DoliDb $db Database handler */ - public function __construct(DoliDB &$db) - { + public function __construct(DoliDB &$db) { global $conf; $this->db = &$db; @@ -76,17 +80,17 @@ class AccountancyExport * * @return array of type */ - public static function getType() - { + public static function getType() { global $langs; return array ( - self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), - self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), - self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), - self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), - self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), - self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus') + self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), + self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), + self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), + self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), + self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), + self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), + self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), ); } @@ -95,8 +99,7 @@ class AccountancyExport * * @return void */ - public static function downloadFile() - { + public static function downloadFile() { global $conf; $journal = 'bookkepping'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; @@ -107,111 +110,168 @@ class AccountancyExport * * @param unknown $TData data */ - public function export(&$TData) - { + public function export(&$TData) { global $conf, $langs; + self::downloadFile(); + switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) { - case self::$EXPORT_TYPE_NORMAL: + case self::$EXPORT_TYPE_NORMAL : $this->exportNormal($TData); break; - case self::$EXPORT_TYPE_CEGID: + case self::$EXPORT_TYPE_CEGID : $this->exportCegid($TData); break; - case self::$EXPORT_TYPE_COALA: + case self::$EXPORT_TYPE_COALA : $this->exportCoala($TData); break; - case self::$EXPORT_TYPE_BOB50: + case self::$EXPORT_TYPE_BOB50 : $this->exportBob50($TData); break; - case self::$EXPORT_TYPE_CIEL: + case self::$EXPORT_TYPE_CIEL : $this->exportCiel($TData); break; - case self::$EXPORT_TYPE_QUADRATUS: + case self::$EXPORT_TYPE_QUADRATUS : $this->exportQuadratus($TData); break; - default: + case self::$EXPORT_TYPE_EBP : + $this->exportEbp($TData); + break; + default : $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; } - - if (empty($this->errors)) self::downloadFile(); } /** * Export format : Normal * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportNormal(&$TData) - { - + public function exportNormal($objectLines) { + foreach ( $objectLines as $line ) { + // Std export + $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); + print $date . $this->separator; + print $line->doc_ref . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print length_accounta($line->code_tiers) . $this->separator; + print price($line->debit) . $this->separator; + print price($line->credit) . $this->separator; + print $line->code_journal . $this->separator; + print $this->end_line; + } } /** * Export format : CEGID * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportCegid(&$TData) - { - + public function exportCegid($objectLines) { + foreach ( $objectLines as $line ) { + $date = dol_print_date($line->doc_date, '%d%m%Y'); + + print $date . $this->separator; + print $line->code_journal . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print ' ' . $this->separator; + print $line->sens . $this->separator; + print price($line->montant) . $this->separator; + print dol_trunc($line->label_compte, 32) . $this->separator; + print $line->doc_ref . $this->separator; + print $this->end_line; + } } /** * Export format : COALA * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportCoala(&$TData) - { - + public function exportCoala($objectLines) { + // Coala export + foreach ( $objectLines as $line ) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $this->separator; + print $line->code_journal . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print $line->piece_num . $this->separator; + print $line->doc_ref . $this->separator; + print price($line->debit) . $this->separator; + print price($line->credit) . $this->separator; + print 'E' . $this->separator; + print length_accountg($line->code_tiers) . $this->separator; + print $this->end_line; + } } /** * Export format : BOB50 * - * @param unknown $TData data + * @param array $objectLines data * * @return void */ - public function exportBob50(&$TData) - { - + public function exportBob50($objectLines) { + + // Bob50 + foreach ( $objectLines as $line ) { + print $line->piece_num . $this->separator; + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $this->separator; + + if (empty($line->code_tiers)) { + print 'G' . $this->separator; + print length_accounta($line->numero_compte) . $this->separator; + } else { + if (substr($line->numero_compte, 0, 3) == '411') { + print 'C' . $this->separator; + } + if (substr($line->numero_compte, 0, 3) == '401') { + print 'F' . $this->separator; + } + print length_accountg($line->code_tiers) . $this->separator; + } + + print price($line->debit) . $this->separator; + print price($line->credit) . $this->separator; + print dol_trunc($line->label_compte, 32) . $this->separator; + print $this->end_line; + } } /** * Export format : CIEL * - * @param unknown $TData data + * @param array $TData data * * @return void */ - public function exportCiel(&$TData) - { + public function exportCiel(&$TData) { global $conf; - $i=1; + $i = 1; $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd - foreach ($TData as $data) - { + foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (!empty($data->code_tiers)) $code_compta = $data->code_tiers; + if (! empty($data->code_tiers)) + $code_compta = $data->code_tiers; - $Tab = array(); + $Tab = array (); $Tab['num_ecriture'] = str_pad($i, 5); $Tab['code_journal'] = str_pad($data->code_journal, 2); $Tab['date_ecriture'] = $date_ecriture; $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.$data->label_compte, 25), 25); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_compte, 25), 25); $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); @@ -221,41 +281,42 @@ class AccountancyExport $Tab['end_line'] = $this->end_line; print implode($Tab); - $i++; + $i ++; } } /** * Export format : Quadratus * - * @param unknown $TData data + * @param array $TData data * * @return void */ - public function exportQuadratus(&$TData) - { + public function exportQuadratus(&$TData) { global $conf; $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy - foreach ($TData as $data) - { + foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (!empty($data->code_tiers)) $code_compta = $data->code_tiers; + if (! empty($data->code_tiers)) + $code_compta = $data->code_tiers; - $Tab = array(); + $Tab = array (); $Tab['type_ligne'] = 'M'; $Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8); $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2); $Tab['folio'] = '000'; $Tab['date_ecriture'] = $date_ecriture; $Tab['filler'] = ' '; - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.' '.$data->label_compte, 20), 20); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 20), 20); $Tab['sens'] = $data->sens; // C or D $Tab['signe_montant'] = '+'; - $Tab['montant'] = str_pad(abs($data->montant)*100, 12, '0', STR_PAD_LEFT); // TODO manage negative amount + $Tab['montant'] = str_pad(abs($data->montant) * 100, 12, '0', STR_PAD_LEFT); // TODO manage negative amount $Tab['contrepartie'] = str_repeat(' ', 8); - if (!empty($data->date_echeance)) $Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); - else $Tab['date_echeance'] = '000000'; + if (! empty($data->date_echeance)) + $Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); + else + $Tab['date_echeance'] = '000000'; $Tab['lettrage'] = str_repeat(' ', 5); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5); $Tab['filler2'] = str_repeat(' ', 20); @@ -263,7 +324,7 @@ class AccountancyExport $Tab['devis'] = str_pad($conf->currency, 3); $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['filler3'] = str_repeat(' ', 3); - $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref.' '.$data->label_compte, 32), 32); + $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 32), 32); $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['filler4'] = str_repeat(' ', 73); @@ -273,14 +334,45 @@ class AccountancyExport } } + + /** + * Export format : Normal + * + * @param array $objectLines data + * + * @return void + */ + public function exportEbp($objectLines) { + + $this->separator = ','; + + foreach ( $objectLines as $line ) { + + $date = dol_print_date($line->doc_date, '%d%m%Y'); + + print $line->id . $this->separator; + print $date . $this->separator; + print $line->code_journal . $this->separator; + print length_accountg($line->numero_compte) . $this->separator; + print substr(length_accountg($line->numero_compte),0,2) . $this->separator; + print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1)."'".$this->separator; + print price2num($line->montant).$this->separator; + print $line->sens.$this->separator; + print $date . $this->separator; + print 'EUR'; + print $this->end_line; + } + } + + + /** * * @param unknown $str data * @param integer $size data */ - public static function trunc($str, $size) - { + public static function trunc($str, $size) { return dol_trunc($str, $size, 'right', 'UTF-8', 1); } - } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c360c1ce4cbc6547f5b5e2e540722a6415a654c1..5ca1197b3e24f0e6a8154a2af08ba57681d4e775 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -22,9 +22,9 @@ */ /** - * \file htdocs/accountancy/journal/purchasesjournal.php - * \ingroup Advanced accountancy - * \brief Page with purchases journal + * \file htdocs/accountancy/journal/purchasesjournal.php + * \ingroup Advanced accountancy + * \brief Page with purchases journal */ require '../../main.inc.php'; @@ -117,13 +117,14 @@ if ($result) { $tabfac = array (); $tabht = array (); $tabtva = array (); + $def_tva = array (); $tabttc = array (); $tabcompany = array (); $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - // contr�les + // contrôles $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_prod = $obj->compte; if (empty($compta_prod)) { @@ -134,11 +135,13 @@ if ($result) { } $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + //Define array for display vat tx + $def_tva[$obj->rowid]=price($obj->tva_tx); + $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; - $tabfac[$obj->rowid]["refsologest"] = $obj->ref ; - $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier ; - + $tabfac[$obj->rowid]["refsologest"] = $obj->ref; + $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->description; @@ -164,19 +167,21 @@ if ($action == 'writebookkeeping') { $error = 0; foreach ( $tabfac as $key => $val ) { - - $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; - $invoicestatic->ref = $val["refsologest"]; - $invoicestatic->refsupplier = $val["refsuppliersologest"]; - $invoicestatic->type = $val["type"]; - $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; - - + + $companystatic = new Societe($db); + $invoicestatic = new FactureFournisseur($db); + + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + foreach ( $tabttc[$key] as $k => $mt ) { // get compte id and label @@ -188,7 +193,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; @@ -206,7 +211,7 @@ if ($action == 'writebookkeeping') { // Product / Service foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); + $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); if ($mt) { // get compte id and label @@ -220,7 +225,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode($accountingaccount->label); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode($accountingaccount->label); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -251,7 +256,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->refsupplier .' - '. $langs->trans("VAT"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -282,124 +287,123 @@ $companystatic = new Fournisseur($db); // Export if ($action == 'export_csv') { - $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - - // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) - { - $sep = ";"; - - foreach ( $tabfac as $key => $val ) { - $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - - // Product / Service - foreach ( $tabht[$key] as $k => $mt ) { - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; + + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + + // Model Cegid Expert Export + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { + $sep = ";"; + + foreach ( $tabfac as $key => $val ) { + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + if ($mt) { + print $date . $sep; + print $purchase_journal . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print dol_trunc($val["description"], 32) . $sep; + print $val["ref"]; + print "\n"; + } + } - if ($mt) { - print $date . $sep; - print $purchase_journal . $sep; - print length_accountg(html_entity_decode($k)) . $sep; - print $sep; - print ($mt < 0 ? 'C' : 'D') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($val["description"], 32) . $sep; - print $val["ref"]; - print "\n"; + // VAT + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $purchase_journal . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $langs->trans("VAT") . $sep; + print $val["ref"]; + print "\n"; + } } - } - // VAT - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { + foreach ( $tabttc[$key] as $k => $mt ) { print $date . $sep; print $purchase_journal . $sep; - print length_accountg(html_entity_decode($k)) . $sep; - print $sep; - print ($mt < 0 ? 'C' : 'D') . $sep; + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print $langs->trans("VAT") . $sep; + print utf8_decode($companystatic->name) . $sep; print $val["ref"]; print "\n"; } } + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + // Model Classic Export + foreach ( $tabfac as $key => $val ) { - foreach ( $tabttc[$key] as $k => $mt ) { - print $date . $sep; - print $purchase_journal . $sep; - print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; - print length_accounta(html_entity_decode($k)) . $sep; - print ($mt < 0 ? 'D' : 'C') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode($companystatic->name) . $sep; - print $val["ref"]; - print "\n"; - } - } - } else { - // Model Classic Export - foreach ( $tabfac as $key => $val ) { - - $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; - $invoicestatic->ref = $val["refsologest"]; - $invoicestatic->refsupplier = $val["refsuppliersologest"]; - $invoicestatic->type = $val["type"]; - $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - $date = dol_print_date($db->jdate($val["date"]), 'day'); + $date = dol_print_date($db->jdate($val["date"]), 'day'); - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; - // Product / Service - foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k); - if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; - //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; - print "\n"; + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; + // print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } } - } - // VAT - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { + // VAT + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + // print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } + } + + // Third party + foreach ( $tabttc[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - //print '"' . $langs->trans("VAT") . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; - print "\n"; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + // print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; } + print "\n"; } - - // Third party - foreach ( $tabttc[$key] as $k => $mt ) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - //print '"' . utf8_decode($companystatic->name) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; - } - print "\n"; } - } } else { llxHeader('', $langs->trans("PurchasesJournal")); @@ -423,7 +427,11 @@ if ($action == 'export_csv') { 'action' => '' )); - print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 || $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { + print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabeld="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>'; + } else { + print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; + } print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; @@ -468,7 +476,6 @@ if ($action == 'export_csv') { $invoicestatic->ref = $val["refsologest"]; $invoicestatic->refsupplier = $val["refsuppliersologest"]; - $invoicestatic->type = $val["type"]; $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); @@ -486,8 +493,8 @@ if ($action == 'export_csv') { print "<td>" . length_accountg($k) . "</td>"; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16). ' - ' .$invoicestatic->refsupplier .' - '. $accountingaccount->label . "</td>"; - //print "<td>" . $accountingaccount->label . "</td>"; + print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>"; + // print "<td>" . $accountingaccount->label . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "</tr>"; @@ -499,8 +506,8 @@ if ($action == 'export_csv') { print "<tr " . $bc[$var] . " >"; print "<td>" . $date . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; - print "<td>" . length_accountg($k) . "</td>" ; - print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("VAT") . "</td>"; + print "<td>" . length_accountg($k) . "</td>"; + print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "</tr>"; @@ -514,11 +521,11 @@ if ($action == 'export_csv') { print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "<td>" . length_accounta($k)."</td>"; - print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("Code_tiers")."</td>"; - //print "</td><td>" . $langs->trans("ThirdParty"); - //print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; - //print "</td>"; + print "<td>" . length_accounta($k) . "</td>"; + print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "</td>"; + // print "</td><td>" . $langs->trans("ThirdParty"); + // print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; + // print "</td>"; print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index a88d60b8376940aa536ed9e9815bad283619e6df..5da210ca09acee9e2ea506d6c2e36461aa1655e7 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -7,7 +7,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> - * Copyright (C) 2014 Rapha�l Doursenaud <rdoursenaud@gpcsolutions.fr> + * Copyright (C) 2014 Rapha�l Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,9 +24,9 @@ */ /** - * \file htdocs/accountancy/journal/sellsjournal.php - * \ingroup Advanced accountancy - * \brief Page with sells journal + * \file htdocs/accountancy/journal/sellsjournal.php + * \ingroup Advanced accountancy + * \brief Page with sells journal */ require '../../main.inc.php'; @@ -118,6 +118,7 @@ if ($result) { $tabfac = array (); $tabht = array (); $tabtva = array (); + $def_tva = array (); $tabttc = array (); $tabcompany = array (); @@ -140,10 +141,14 @@ if ($result) { $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + + //Define array for display vat tx + $def_tva[$obj->rowid]=price($obj->tva_tx); + // Situation invoices handling $line = new FactureLigne($db); - $line->fetch($obj->rowid); - $prev_progress = $line->get_prev_progress(); + $line->fetch($obj->fdid); + $prev_progress = $line->get_prev_progress($obj->fdid); if ($obj->type == Facture::TYPE_SITUATION) { // Avoid divide by 0 if ($obj->situation_percent == 0) { @@ -193,14 +198,17 @@ if ($action == 'writebookkeeping') { $error = 0; foreach ( $tabfac as $key => $val ) { - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; -$invoicestatic->id = $key; + $companystatic = new Societe($db); + $invoicestatic = new Facture($db); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; - - + foreach ( $tabttc[$key] as $k => $mt ) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -211,8 +219,8 @@ $invoicestatic->id = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - //$bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); + // $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -242,7 +250,7 @@ $invoicestatic->id = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -272,7 +280,7 @@ $invoicestatic->id = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -296,6 +304,7 @@ $invoicestatic->id = $key; // Export if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; @@ -304,8 +313,7 @@ if ($action == 'export_csv') { $companystatic = new Client($db); // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) - { + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; foreach ( $tabfac as $key => $val ) { @@ -313,9 +321,9 @@ if ($action == 'export_csv') { $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; -$invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; - + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); foreach ( $tabttc[$key] as $k => $mt ) { @@ -325,8 +333,8 @@ $invoicestatic->id = $key; print length_accounta(html_entity_decode($k)) . $sep; print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; - //print utf8_decode($companystatic->name) . $sep; + print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; + // print utf8_decode($companystatic->name) . $sep; print $val["ref"]; print "\n"; } @@ -341,8 +349,8 @@ $invoicestatic->id = $key; print $sep; print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount_static->label)) . $sep; - //print dol_trunc($accountingaccount_static->label, 32) . $sep; + print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount_static->label)) . $sep; + // print dol_trunc($accountingaccount_static->label, 32) . $sep; print $val["ref"]; print "\n"; } @@ -357,22 +365,22 @@ $invoicestatic->id = $key; print $sep; print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . $sep; - //print $langs->trans("VAT") . $sep; + print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep; + // print $langs->trans("VAT") . $sep; print $val["ref"]; print "\n"; } } } - } else { + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { // Model Classic Export foreach ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["ref"]; $date = dol_print_date($db->jdate($val["date"]), 'day'); @@ -380,8 +388,8 @@ $invoicestatic->id = $key; print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; - //print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + // print '"' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -396,8 +404,8 @@ $invoicestatic->id = $key; print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. utf8_decode ( dol_trunc($accountingaccount->label, 32)) . '"' . $sep; - //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; + // print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -410,8 +418,8 @@ $invoicestatic->id = $key; print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . '"' . $sep; - //print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep; + // print '"' . $langs->trans("VAT") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -440,7 +448,11 @@ $invoicestatic->id = $key; 'action' => '' )); - print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 || $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { + print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabeld="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>'; + } else { + print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; + } print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; @@ -496,9 +508,9 @@ $invoicestatic->id = $key; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; print "<td>" . length_accounta($k); - //print "</td><td>" . $langs->trans("ThirdParty"); - //print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; - print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"). "</td>"; + // print "</td><td>" . $langs->trans("ThirdParty"); + // print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; + print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "</td>"; print "</td><td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; } @@ -514,8 +526,8 @@ $invoicestatic->id = $key; print "<td>" . $date . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . length_accountg($k) . "</td>"; - //print "<td>" . $accountingaccount->label . "</td>"; - print "<td>" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)) . "</td>"; + // print "<td>" . $accountingaccount->label . "</td>"; + print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount->label)) . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "</tr>"; @@ -529,8 +541,8 @@ $invoicestatic->id = $key; print "<td>" . $date . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . length_accountg($k) . "</td>"; - print "<td>" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . "</td>"; - //print "<td>" . $langs->trans("VAT") . "</td>"; + print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "</td>"; + // print "<td>" . $langs->trans("VAT") . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "</tr>"; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 46375e49ff970ece58aac345b9aed55ed490941e..20640733cd43769a42209554e9d9eecc9c453989 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -164,6 +164,7 @@ Modelcsv_COALA=Export towards Sage Coala Modelcsv_bob50=Export towards Sage BOB 50 Modelcsv_ciel=Export towards Sage Ciel Compta or Compta Evolution Modelcsv_quadratus=Export towards Quadratus QuadraCompta +Modelcsv_ebp=Export towards EBP ## Tools - Init accounting account on product / service InitAccountancy=Init accountancy @@ -181,4 +182,5 @@ Calculated=Calculated Formula=Formula ## Error -ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country \ No newline at end of file +ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country +ExportNotSupported=The export format setuped is not supported into this page \ No newline at end of file