2016-03-15 08:58:53 +01:00
< ? php
2016-05-16 16:37:07 +02:00
/*
2018-04-07 06:21:49 +02:00
* Copyright ( C ) 2007 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2014 Juanjo Menent < jmenent @ 2 byte . 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 >
2020-05-08 13:50:26 +02:00
* Copyright ( C ) 2016 - 2020 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2018-04-07 06:21:49 +02:00
* Copyright ( C ) 2013 - 2017 Olivier Geffroy < jeff @ jeffinfo . com >
* Copyright ( C ) 2017 Elarifr . Ari Elbaz < github @ accedinfo . com >
2019-02-25 00:56:48 +01:00
* Copyright ( C ) 2017 - 2019 Frédéric France < frederic . france @ netlogic . fr >
2019-05-22 10:01:25 +02:00
* Copyright ( C ) 2017 André Schild < a . schild @ aarboard . ch >
2020-05-08 13:50:26 +02:00
* Copyright ( C ) 2020 Guillaume Alexandre < guillaume @ tag - info . fr >
2016-03-15 08:58:53 +01:00
*
* 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
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
2016-05-16 16:37:07 +02:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
2016-03-15 08:58:53 +01:00
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2016-03-15 08:58:53 +01:00
*/
/**
2016-09-20 21:12:28 +02:00
* \file htdocs / accountancy / class / accountancyexport . class . php
2019-05-13 22:25:15 +02:00
* \ingroup Accountancy ( Double entries )
2016-09-20 21:12:28 +02:00
* \brief Class accountancy export
2016-03-15 08:58:53 +01:00
*/
2019-11-14 12:09:15 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php' ;
2020-01-23 12:09:01 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2019-03-15 16:09:20 +01:00
2016-03-15 08:58:53 +01:00
/**
* Manage the different format accountancy export
*/
class AccountancyExport
{
2019-03-15 16:09:20 +01:00
// Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV
2019-11-14 12:09:15 +01:00
public static $EXPORT_TYPE_CONFIGURABLE = 1 ; // CSV
2019-06-20 13:37:06 +02:00
public static $EXPORT_TYPE_AGIRIS = 10 ;
public static $EXPORT_TYPE_EBP = 15 ;
public static $EXPORT_TYPE_CEGID = 20 ;
public static $EXPORT_TYPE_COGILOG = 25 ;
public static $EXPORT_TYPE_COALA = 30 ;
public static $EXPORT_TYPE_BOB50 = 35 ;
public static $EXPORT_TYPE_CIEL = 40 ;
public static $EXPORT_TYPE_SAGE50_SWISS = 45 ;
2019-07-31 17:02:35 +02:00
public static $EXPORT_TYPE_CHARLEMAGNE = 50 ;
2019-06-20 13:37:06 +02:00
public static $EXPORT_TYPE_QUADRATUS = 60 ;
2020-05-08 13:50:26 +02:00
public static $EXPORT_TYPE_WINFIC = 70 ;
2019-06-20 13:37:06 +02:00
public static $EXPORT_TYPE_OPENCONCERTO = 100 ;
2019-07-19 17:07:55 +02:00
public static $EXPORT_TYPE_LDCOMPTA = 110 ;
2020-03-12 11:55:26 +01:00
public static $EXPORT_TYPE_LDCOMPTA10 = 120 ;
2019-06-20 13:37:06 +02:00
public static $EXPORT_TYPE_FEC = 1000 ;
2017-11-19 19:42:16 +01:00
2018-08-21 19:08:11 +02:00
2016-03-15 08:58:53 +01:00
/**
* @ var string [] Error codes ( or messages )
*/
2018-08-21 19:08:11 +02:00
public $errors = array ();
2016-03-15 08:58:53 +01:00
/**
2016-05-16 16:37:07 +02:00
*
2016-03-15 08:58:53 +01:00
* @ var string Separator
*/
public $separator = '' ;
/**
2016-05-16 16:37:07 +02:00
*
2016-03-15 08:58:53 +01:00
* @ var string End of line
*/
public $end_line = '' ;
/**
* Constructor
*
* @ param DoliDb $db Database handler
*/
2018-10-08 21:01:21 +02:00
public function __construct ( DoliDB & $db )
{
2016-03-15 08:58:53 +01:00
global $conf ;
$this -> db = & $db ;
$this -> separator = $conf -> global -> ACCOUNTING_EXPORT_SEPARATORCSV ;
2019-11-14 12:09:15 +01:00
$this -> end_line = empty ( $conf -> global -> ACCOUNTING_EXPORT_ENDLINE ) ? " \n " : ( $conf -> global -> ACCOUNTING_EXPORT_ENDLINE == 1 ? " \n " : " \r \n " );
2016-03-15 08:58:53 +01:00
}
/**
2017-11-05 11:48:41 +01:00
* Array with all export type available ( key + label )
2016-03-15 08:58:53 +01:00
*
* @ return array of type
*/
2018-10-08 21:01:21 +02:00
public static function getType ()
{
2016-03-15 08:58:53 +01:00
global $langs ;
2019-06-20 13:37:06 +02:00
$listofexporttypes = array (
2019-02-25 00:56:48 +01:00
self :: $EXPORT_TYPE_CONFIGURABLE => $langs -> trans ( 'Modelcsv_configurable' ),
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' ),
2020-05-08 13:50:26 +02:00
self :: $EXPORT_TYPE_WINFIC => $langs -> trans ( 'Modelcsv_winfic' ),
2019-02-25 00:56:48 +01:00
self :: $EXPORT_TYPE_EBP => $langs -> trans ( 'Modelcsv_ebp' ),
self :: $EXPORT_TYPE_COGILOG => $langs -> trans ( 'Modelcsv_cogilog' ),
self :: $EXPORT_TYPE_AGIRIS => $langs -> trans ( 'Modelcsv_agiris' ),
2019-05-15 12:16:03 +02:00
self :: $EXPORT_TYPE_OPENCONCERTO => $langs -> trans ( 'Modelcsv_openconcerto' ),
2019-05-22 10:01:25 +02:00
self :: $EXPORT_TYPE_SAGE50_SWISS => $langs -> trans ( 'Modelcsv_Sage50_Swiss' ),
2019-07-19 17:07:55 +02:00
self :: $EXPORT_TYPE_LDCOMPTA => $langs -> trans ( 'Modelcsv_LDCompta' ),
2020-03-12 11:55:26 +01:00
self :: $EXPORT_TYPE_LDCOMPTA10 => $langs -> trans ( 'Modelcsv_LDCompta10' ),
2019-06-20 13:37:06 +02:00
self :: $EXPORT_TYPE_FEC => $langs -> trans ( 'Modelcsv_FEC' ),
2020-03-12 11:55:26 +01:00
self :: $EXPORT_TYPE_CHARLEMAGNE => $langs -> trans ( 'Modelcsv_charlemagne' ),
2019-02-25 00:56:48 +01:00
);
2019-06-20 13:37:06 +02:00
ksort ( $listofexporttypes , SORT_NUMERIC );
return $listofexporttypes ;
2016-03-15 08:58:53 +01:00
}
2018-10-10 20:01:01 +02:00
/**
* Return string to summarize the format ( Used to generated export filename )
*
* @ param int $type Format id
* @ return string Format code
*/
2020-02-05 16:08:00 +01:00
public static function getFormatCode ( $type )
2018-10-10 20:01:01 +02:00
{
2019-11-14 12:09:15 +01:00
$formatcode = array (
2018-10-10 20:01:01 +02:00
self :: $EXPORT_TYPE_CONFIGURABLE => 'csv' ,
self :: $EXPORT_TYPE_CEGID => 'cegid' ,
self :: $EXPORT_TYPE_COALA => 'coala' ,
self :: $EXPORT_TYPE_BOB50 => 'bob50' ,
self :: $EXPORT_TYPE_CIEL => 'ciel' ,
self :: $EXPORT_TYPE_QUADRATUS => 'quadratus' ,
2020-05-08 13:50:26 +02:00
self :: $EXPORT_TYPE_WINFIC => 'winfic' ,
2018-10-10 20:01:01 +02:00
self :: $EXPORT_TYPE_EBP => 'ebp' ,
self :: $EXPORT_TYPE_COGILOG => 'cogilog' ,
self :: $EXPORT_TYPE_AGIRIS => 'agiris' ,
2019-05-15 12:16:03 +02:00
self :: $EXPORT_TYPE_OPENCONCERTO => 'openconcerto' ,
2019-06-20 13:37:06 +02:00
self :: $EXPORT_TYPE_SAGE50_SWISS => 'sage50ch' ,
2019-07-19 17:07:55 +02:00
self :: $EXPORT_TYPE_LDCOMPTA => 'ldcompta' ,
2020-03-12 11:55:26 +01:00
self :: $EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10' ,
2018-10-10 20:01:01 +02:00
self :: $EXPORT_TYPE_FEC => 'fec' ,
);
return $formatcode [ $type ];
}
2017-12-09 06:00:13 +01:00
/**
* Array with all export type available ( key + label ) and parameters for config
*
* @ return array of type
*/
2018-10-08 21:01:21 +02:00
public static function getTypeConfig ()
{
2017-12-09 06:00:13 +01:00
global $conf , $langs ;
2019-11-14 12:09:15 +01:00
return array (
2017-12-09 06:00:13 +01:00
'param' => array (
2019-06-20 13:37:06 +02:00
self :: $EXPORT_TYPE_CONFIGURABLE => array (
'label' => $langs -> trans ( 'Modelcsv_configurable' ),
2019-11-14 12:09:15 +01:00
'ACCOUNTING_EXPORT_FORMAT' => empty ( $conf -> global -> ACCOUNTING_EXPORT_FORMAT ) ? 'txt' : $conf -> global -> ACCOUNTING_EXPORT_FORMAT ,
'ACCOUNTING_EXPORT_SEPARATORCSV' => empty ( $conf -> global -> ACCOUNTING_EXPORT_SEPARATORCSV ) ? ',' : $conf -> global -> ACCOUNTING_EXPORT_SEPARATORCSV ,
'ACCOUNTING_EXPORT_ENDLINE' => empty ( $conf -> global -> ACCOUNTING_EXPORT_ENDLINE ) ? 1 : $conf -> global -> ACCOUNTING_EXPORT_ENDLINE ,
'ACCOUNTING_EXPORT_DATE' => empty ( $conf -> global -> ACCOUNTING_EXPORT_DATE ) ? '%d%m%Y' : $conf -> global -> ACCOUNTING_EXPORT_DATE ,
2019-06-20 13:37:06 +02:00
),
2017-12-09 06:00:13 +01:00
self :: $EXPORT_TYPE_CEGID => array (
'label' => $langs -> trans ( 'Modelcsv_CEGID' ),
),
self :: $EXPORT_TYPE_COALA => array (
'label' => $langs -> trans ( 'Modelcsv_COALA' ),
),
self :: $EXPORT_TYPE_BOB50 => array (
'label' => $langs -> trans ( 'Modelcsv_bob50' ),
),
self :: $EXPORT_TYPE_CIEL => array (
'label' => $langs -> trans ( 'Modelcsv_ciel' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
),
self :: $EXPORT_TYPE_QUADRATUS => array (
'label' => $langs -> trans ( 'Modelcsv_quadratus' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
),
2020-05-08 13:50:26 +02:00
self :: $EXPORT_TYPE_WINFIC => array (
'label' => $langs -> trans ( 'Modelcsv_winfic' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
),
2017-12-09 06:00:13 +01:00
self :: $EXPORT_TYPE_EBP => array (
'label' => $langs -> trans ( 'Modelcsv_ebp' ),
),
self :: $EXPORT_TYPE_COGILOG => array (
'label' => $langs -> trans ( 'Modelcsv_cogilog' ),
),
self :: $EXPORT_TYPE_AGIRIS => array (
'label' => $langs -> trans ( 'Modelcsv_agiris' ),
),
2019-06-20 13:37:06 +02:00
self :: $EXPORT_TYPE_OPENCONCERTO => array (
'label' => $langs -> trans ( 'Modelcsv_openconcerto' ),
'ACCOUNTING_EXPORT_FORMAT' => 'csv' ,
),
self :: $EXPORT_TYPE_SAGE50_SWISS => array (
'label' => $langs -> trans ( 'Modelcsv_Sage50_Swiss' ),
'ACCOUNTING_EXPORT_FORMAT' => 'csv' ,
2017-12-09 06:00:13 +01:00
),
2019-07-19 17:07:55 +02:00
self :: $EXPORT_TYPE_LDCOMPTA => array (
'label' => $langs -> trans ( 'Modelcsv_LDCompta' ),
'ACCOUNTING_EXPORT_FORMAT' => 'csv' ,
2020-03-12 11:55:26 +01:00
),
self :: $EXPORT_TYPE_LDCOMPTA10 => array (
'label' => $langs -> trans ( 'Modelcsv_LDCompta10' ),
'ACCOUNTING_EXPORT_FORMAT' => 'csv' ,
2019-07-19 17:07:55 +02:00
),
2018-10-08 21:01:21 +02:00
self :: $EXPORT_TYPE_FEC => array (
'label' => $langs -> trans ( 'Modelcsv_FEC' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
),
2019-07-31 17:02:35 +02:00
self :: $EXPORT_TYPE_CHARLEMAGNE => array (
'label' => $langs -> trans ( 'Modelcsv_charlemagne' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
),
2017-12-09 06:00:13 +01:00
),
2019-11-14 12:09:15 +01:00
'cr' => array (
2017-12-09 06:00:13 +01:00
'1' => $langs -> trans ( " Unix " ),
'2' => $langs -> trans ( " Windows " )
),
2019-11-14 12:09:15 +01:00
'format' => array (
2017-12-09 06:00:13 +01:00
'csv' => $langs -> trans ( " csv " ),
'txt' => $langs -> trans ( " txt " )
),
);
}
2017-11-05 11:48:41 +01:00
2016-03-15 08:58:53 +01:00
/**
2018-10-21 16:22:56 +02:00
* Function who chose which export to use with the default config , and make the export into a file
2016-03-15 08:58:53 +01:00
*
2019-10-16 16:17:51 +02:00
* @ param array $TData Array with data
* @ param int $formatexportset Id of export format
* @ return void
2016-03-15 08:58:53 +01:00
*/
2019-10-16 16:17:51 +02:00
public function export ( & $TData , $formatexportset )
2018-10-08 21:01:21 +02:00
{
2016-03-15 08:58:53 +01:00
global $conf , $langs ;
2019-11-14 12:09:15 +01:00
global $search_date_end ; // Used into /accountancy/tpl/export_journal.tpl.php
2016-03-15 08:58:53 +01:00
2018-10-21 16:22:56 +02:00
// Define name of file to save
2019-10-16 16:17:51 +02:00
$filename = 'general_ledger-' . $this -> getFormatCode ( $formatexportset );
2018-11-01 07:24:48 +01:00
$type_export = 'general_ledger' ;
2018-10-21 16:22:56 +02:00
2020-05-08 13:50:26 +02:00
global $db ; // The tpl file use $db
2019-11-14 12:09:15 +01:00
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php' ;
2018-10-10 20:01:01 +02:00
2016-05-16 17:05:34 +02:00
2019-10-16 16:17:51 +02:00
switch ( $formatexportset ) {
2018-10-10 19:45:26 +02:00
case self :: $EXPORT_TYPE_CONFIGURABLE :
$this -> exportConfigurable ( $TData );
2016-03-15 08:58:53 +01:00
break ;
2016-05-16 16:37:07 +02:00
case self :: $EXPORT_TYPE_CEGID :
2016-03-15 08:58:53 +01:00
$this -> exportCegid ( $TData );
break ;
2016-05-16 16:37:07 +02:00
case self :: $EXPORT_TYPE_COALA :
2016-03-15 08:58:53 +01:00
$this -> exportCoala ( $TData );
break ;
2016-05-16 16:37:07 +02:00
case self :: $EXPORT_TYPE_BOB50 :
2016-03-15 08:58:53 +01:00
$this -> exportBob50 ( $TData );
break ;
2016-05-16 16:37:07 +02:00
case self :: $EXPORT_TYPE_CIEL :
2016-03-15 08:58:53 +01:00
$this -> exportCiel ( $TData );
break ;
2016-05-16 16:37:07 +02:00
case self :: $EXPORT_TYPE_QUADRATUS :
2016-03-15 08:58:53 +01:00
$this -> exportQuadratus ( $TData );
break ;
2020-05-08 13:50:26 +02:00
case self :: $EXPORT_TYPE_WINFIC :
$this -> exportWinfic ( $TData );
break ;
2016-05-16 16:37:07 +02:00
case self :: $EXPORT_TYPE_EBP :
$this -> exportEbp ( $TData );
break ;
2016-06-29 17:30:47 +02:00
case self :: $EXPORT_TYPE_COGILOG :
$this -> exportCogilog ( $TData );
break ;
2017-05-04 06:49:29 +02:00
case self :: $EXPORT_TYPE_AGIRIS :
$this -> exportAgiris ( $TData );
break ;
2019-05-15 12:16:03 +02:00
case self :: $EXPORT_TYPE_OPENCONCERTO :
$this -> exportOpenConcerto ( $TData );
break ;
2019-05-22 10:01:25 +02:00
case self :: $EXPORT_TYPE_SAGE50_SWISS :
$this -> exportSAGE50SWISS ( $TData );
break ;
2019-07-19 17:07:55 +02:00
case self :: $EXPORT_TYPE_LDCOMPTA :
$this -> exportLDCompta ( $TData );
break ;
2020-03-12 11:55:26 +01:00
case self :: $EXPORT_TYPE_LDCOMPTA10 :
$this -> exportLDCompta10 ( $TData );
break ;
2019-07-19 17:07:55 +02:00
case self :: $EXPORT_TYPE_FEC :
$this -> exportFEC ( $TData );
break ;
2019-07-31 17:02:35 +02:00
case self :: $EXPORT_TYPE_CHARLEMAGNE :
$this -> exportCharlemagne ( $TData );
break ;
2016-07-06 11:23:32 +02:00
default :
2016-03-15 08:58:53 +01:00
$this -> errors [] = $langs -> trans ( 'accountancy_error_modelnotfound' );
break ;
}
}
/**
* Export format : CEGID
*
2016-05-16 17:07:36 +02:00
* @ param array $objectLines data
2016-03-15 08:58:53 +01:00
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportCegid ( $objectLines )
{
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2016-05-16 16:37:07 +02:00
$date = dol_print_date ( $line -> doc_date , '%d%m%Y' );
2017-12-09 06:00:13 +01:00
$separator = " ; " ;
$end_line = " \n " ;
2016-09-20 21:12:28 +02:00
2019-11-14 12:09:15 +01:00
print $date . $separator ;
print $line -> code_journal . $separator ;
print length_accountg ( $line -> numero_compte ) . $separator ;
print length_accounta ( $line -> subledger_account ) . $separator ;
print $line -> sens . $separator ;
print price ( $line -> montant ) . $separator ;
print $line -> label_operation . $separator ;
2016-09-20 21:12:28 +02:00
print $line -> doc_ref ;
2017-11-05 11:48:41 +01:00
print $end_line ;
2016-05-16 16:37:07 +02:00
}
2016-03-15 08:58:53 +01:00
}
2016-06-29 17:30:47 +02:00
/**
* Export format : COGILOG
*
* @ param array $objectLines data
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportCogilog ( $objectLines )
{
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2016-06-29 17:30:47 +02:00
$date = dol_print_date ( $line -> doc_date , '%d%m%Y' );
2017-12-09 06:00:13 +01:00
$separator = " ; " ;
$end_line = " \n " ;
2016-06-29 17:30:47 +02:00
2019-11-14 12:09:15 +01:00
print $line -> code_journal . $separator ;
print $date . $separator ;
print $line -> piece_num . $separator ;
print length_accountg ( $line -> numero_compte ) . $separator ;
print '' . $separator ;
print $line -> label_operation . $separator ;
print $date . $separator ;
if ( $line -> sens == 'D' ) {
print price ( $line -> montant ) . $separator ;
print '' . $separator ;
2020-05-21 15:05:19 +02:00
} elseif ( $line -> sens == 'C' ) {
2019-11-14 12:09:15 +01:00
print '' . $separator ;
print price ( $line -> montant ) . $separator ;
2016-06-29 17:30:47 +02:00
}
2019-11-14 12:09:15 +01:00
print $line -> doc_ref . $separator ;
print $line -> label_operation . $separator ;
2017-11-05 11:48:41 +01:00
print $end_line ;
2016-06-29 17:30:47 +02:00
}
}
2016-03-15 08:58:53 +01:00
/**
* Export format : COALA
*
2016-05-16 17:07:36 +02:00
* @ param array $objectLines data
2016-03-15 08:58:53 +01:00
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportCoala ( $objectLines )
{
2016-05-16 16:37:07 +02:00
// Coala export
2017-12-09 06:00:13 +01:00
$separator = " ; " ;
$end_line = " \n " ;
2017-11-05 11:48:41 +01:00
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2016-05-16 16:37:07 +02:00
$date = dol_print_date ( $line -> doc_date , '%d/%m/%Y' );
2019-11-14 12:09:15 +01:00
print $date . $separator ;
print $line -> code_journal . $separator ;
print length_accountg ( $line -> numero_compte ) . $separator ;
print $line -> piece_num . $separator ;
print $line -> doc_ref . $separator ;
print price ( $line -> debit ) . $separator ;
print price ( $line -> credit ) . $separator ;
print 'E' . $separator ;
print length_accountg ( $line -> subledger_account ) . $separator ;
2017-11-05 11:48:41 +01:00
print $end_line ;
2016-05-16 16:37:07 +02:00
}
2016-03-15 08:58:53 +01:00
}
/**
* Export format : BOB50
*
2016-05-16 17:07:36 +02:00
* @ param array $objectLines data
2016-03-15 08:58:53 +01:00
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportBob50 ( $objectLines )
{
2016-05-16 16:37:07 +02:00
// Bob50
2017-12-09 06:00:13 +01:00
$separator = " ; " ;
$end_line = " \n " ;
2017-11-05 11:48:41 +01:00
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2019-11-14 12:09:15 +01:00
print $line -> piece_num . $separator ;
2016-05-16 16:37:07 +02:00
$date = dol_print_date ( $line -> doc_date , '%d/%m/%Y' );
2019-11-14 12:09:15 +01:00
print $date . $separator ;
2016-05-16 16:37:07 +02:00
2017-06-15 19:29:00 +02:00
if ( empty ( $line -> subledger_account )) {
2019-11-14 12:09:15 +01:00
print 'G' . $separator ;
print length_accounta ( $line -> numero_compte ) . $separator ;
2016-05-16 16:37:07 +02:00
} else {
if ( substr ( $line -> numero_compte , 0 , 3 ) == '411' ) {
2019-11-14 12:09:15 +01:00
print 'C' . $separator ;
2016-05-16 16:37:07 +02:00
}
if ( substr ( $line -> numero_compte , 0 , 3 ) == '401' ) {
2019-11-14 12:09:15 +01:00
print 'F' . $separator ;
2016-05-16 16:37:07 +02:00
}
2019-11-14 12:09:15 +01:00
print length_accountg ( $line -> subledger_account ) . $separator ;
2016-05-16 16:37:07 +02:00
}
2019-11-14 12:09:15 +01:00
print price ( $line -> debit ) . $separator ;
print price ( $line -> credit ) . $separator ;
print dol_trunc ( $line -> label_operation , 32 ) . $separator ;
2017-11-05 11:48:41 +01:00
print $end_line ;
2016-05-16 16:37:07 +02:00
}
2016-03-15 08:58:53 +01:00
}
/**
* Export format : CIEL
*
2016-05-16 17:07:36 +02:00
* @ param array $TData data
2016-03-15 08:58:53 +01:00
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportCiel ( & $TData )
{
2016-03-15 08:58:53 +01:00
global $conf ;
2019-11-14 12:09:15 +01:00
$end_line = " \r \n " ;
2016-08-10 17:22:58 +02:00
2016-05-16 16:37:07 +02:00
$i = 1 ;
2017-06-15 19:29:00 +02:00
$date_ecriture = dol_print_date ( dol_now (), $conf -> global -> ACCOUNTING_EXPORT_DATE ); // format must be yyyymmdd
2019-02-02 18:25:01 +01:00
foreach ( $TData as $data ) {
2016-03-15 08:58:53 +01:00
$code_compta = $data -> numero_compte ;
2019-11-14 12:09:15 +01:00
if ( ! empty ( $data -> subledger_account ))
2017-06-15 19:29:00 +02:00
$code_compta = $data -> subledger_account ;
2016-03-15 08:58:53 +01:00
2019-11-14 12:09:15 +01:00
$Tab = array ();
2016-03-15 08:58:53 +01:00
$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 );
2019-11-14 12:09:15 +01:00
$Tab [ 'libelle_ecriture' ] = str_pad ( self :: trunc ( dol_string_unaccent ( $data -> doc_ref ) . dol_string_unaccent ( $data -> label_operation ), 25 ), 25 );
2016-03-15 08:58:53 +01:00
$Tab [ 'montant' ] = str_pad ( abs ( $data -> montant ), 13 , ' ' , STR_PAD_LEFT );
$Tab [ 'type_montant' ] = str_pad ( $data -> sens , 1 );
$Tab [ 'vide' ] = str_repeat ( ' ' , 18 );
2017-11-19 19:42:16 +01:00
$Tab [ 'intitule_compte' ] = str_pad ( self :: trunc ( dol_string_unaccent ( $data -> label_operation ), 34 ), 34 );
2016-03-15 08:58:53 +01:00
$Tab [ 'end' ] = 'O2003' ;
2017-11-05 11:48:41 +01:00
$Tab [ 'end_line' ] = $end_line ;
2016-03-15 08:58:53 +01:00
print implode ( $Tab );
2019-11-14 12:09:15 +01:00
$i ++ ;
2016-03-15 08:58:53 +01:00
}
}
/**
* Export format : Quadratus
*
2016-05-16 17:07:36 +02:00
* @ param array $TData data
2016-03-15 08:58:53 +01:00
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportQuadratus ( & $TData )
{
2016-03-15 08:58:53 +01:00
global $conf ;
2019-11-14 12:09:15 +01:00
$end_line = " \r \n " ;
2016-08-10 17:22:58 +02:00
2018-10-08 21:01:21 +02:00
//We should use dol_now function not time however this is wrong date to transfert in accounting
2017-11-19 19:42:16 +01:00
//$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
//$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
2019-02-02 18:25:01 +01:00
foreach ( $TData as $data ) {
2016-03-15 08:58:53 +01:00
$code_compta = $data -> numero_compte ;
2019-11-14 12:09:15 +01:00
if ( ! empty ( $data -> subledger_account ))
2017-06-15 19:29:00 +02:00
$code_compta = $data -> subledger_account ;
2016-03-15 08:58:53 +01:00
2019-11-14 12:09:15 +01:00
$Tab = array ();
2016-03-15 08:58:53 +01:00
$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' ;
2017-11-19 19:42:16 +01:00
2018-10-08 21:01:21 +02:00
//We use invoice date $data->doc_date not $date_ecriture which is the transfert date
//maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
2017-11-19 19:42:16 +01:00
//$Tab['date_ecriture'] = $date_ecriture;
$Tab [ 'date_ecriture' ] = dol_print_date ( $data -> doc_date , '%d%m%y' );
2016-03-15 08:58:53 +01:00
$Tab [ 'filler' ] = ' ' ;
2019-11-14 12:09:15 +01:00
$Tab [ 'libelle_ecriture' ] = str_pad ( self :: trunc ( dol_string_unaccent ( $data -> doc_ref ) . ' ' . dol_string_unaccent ( $data -> label_operation ), 20 ), 20 );
2016-03-15 08:58:53 +01:00
$Tab [ 'sens' ] = $data -> sens ; // C or D
$Tab [ 'signe_montant' ] = '+' ;
2017-11-19 19:42:16 +01:00
2018-10-08 21:01:21 +02:00
//elarifr le montant doit etre en centimes sans point decimal !
2019-11-14 12:09:15 +01:00
$Tab [ 'montant' ] = str_pad ( abs ( $data -> montant * 100 ), 12 , '0' , STR_PAD_LEFT ); // TODO manage negative amount
2018-10-08 21:01:21 +02:00
// $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
2016-03-15 08:58:53 +01:00
$Tab [ 'contrepartie' ] = str_repeat ( ' ' , 8 );
2017-11-19 19:42:16 +01:00
2018-10-08 21:01:21 +02:00
// elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting
2020-05-21 00:02:33 +02:00
if ( ! empty ( $data -> date_echeance )) {
2017-11-19 19:42:16 +01:00
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
2019-11-14 12:09:15 +01:00
$Tab [ 'date_echeance' ] = dol_print_date ( $data -> date_echeance , '%d%m%y' ); // elarifr: format must be ddmmyy
2020-05-21 00:02:33 +02:00
} else {
2016-05-16 16:37:07 +02:00
$Tab [ 'date_echeance' ] = '000000' ;
2020-05-21 00:02:33 +02:00
}
2017-11-19 19:42:16 +01:00
2018-10-08 21:01:21 +02:00
//elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
2017-11-19 19:42:16 +01:00
//$Tab['lettrage'] = str_repeat(' ', 5);
$Tab [ 'lettrage' ] = str_repeat ( ' ' , 2 );
$Tab [ 'codestat' ] = str_repeat ( ' ' , 3 );
2016-03-15 08:58:53 +01:00
$Tab [ 'num_piece' ] = str_pad ( self :: trunc ( $data -> piece_num , 5 ), 5 );
2017-11-19 19:42:16 +01:00
2018-10-08 21:01:21 +02:00
//elarifr keep correct quadra named field instead of anon filler
2017-11-19 19:42:16 +01:00
//$Tab['filler2'] = str_repeat(' ', 20);
$Tab [ 'affaire' ] = str_repeat ( ' ' , 10 );
$Tab [ 'quantity1' ] = str_repeat ( ' ' , 10 );
2016-03-15 08:58:53 +01:00
$Tab [ 'num_piece2' ] = str_pad ( self :: trunc ( $data -> piece_num , 8 ), 8 );
$Tab [ 'devis' ] = str_pad ( $conf -> currency , 3 );
$Tab [ 'code_journal2' ] = str_pad ( self :: trunc ( $data -> code_journal , 3 ), 3 );
$Tab [ 'filler3' ] = str_repeat ( ' ' , 3 );
2017-11-19 19:42:16 +01:00
2018-10-08 21:01:21 +02:00
//elarifr keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!!
//as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec
//todo we should filter more than only accent to avoid wrong line size
//TODO: remove invoice number doc_ref in libelle,
//TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software
2017-11-19 19:42:16 +01:00
//$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30);
$Tab [ 'libelle_ecriture2' ] = str_pad ( self :: trunc ( dol_string_unaccent ( $data -> label_operation ), 30 ), 30 );
$Tab [ 'codetva' ] = str_repeat ( ' ' , 2 );
2018-10-08 21:01:21 +02:00
//elarifr we need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
2017-11-19 19:42:16 +01:00
//$Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
$Tab [ 'num_piece3' ] = substr ( self :: trunc ( $data -> doc_ref , 20 ), - 10 );
2016-03-15 08:58:53 +01:00
$Tab [ 'filler4' ] = str_repeat ( ' ' , 73 );
2017-11-05 11:48:41 +01:00
$Tab [ 'end_line' ] = $end_line ;
2016-03-15 08:58:53 +01:00
print implode ( $Tab );
}
}
2020-05-08 13:50:26 +02:00
/**
* Export format : WinFic - eWinfic - WinSis Compta
2020-05-08 13:53:11 +02:00
*
2020-05-08 13:50:26 +02:00
*
* @ param array $TData data
* @ return void
*/
public function exportWinfic ( & $TData )
{
global $conf ;
$end_line = " \r \n " ;
//We should use dol_now function not time however this is wrong date to transfert in accounting
//$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
//$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
foreach ( $TData as $data ) {
$code_compta = $data -> numero_compte ;
if ( ! empty ( $data -> subledger_account ))
$code_compta = $data -> subledger_account ;
$Tab = array ();
//$Tab['type_ligne'] = 'M';
$Tab [ 'code_journal' ] = str_pad ( self :: trunc ( $data -> code_journal , 2 ), 2 );
//We use invoice date $data->doc_date not $date_ecriture which is the transfert date
//maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ?
//$Tab['date_ecriture'] = $date_ecriture;
$Tab [ 'date_operation' ] = dol_print_date ( $data -> doc_date , '%d%m%Y' );
$Tab [ 'folio' ] = ' 1' ;
$Tab [ 'num_ecriture' ] = str_pad ( self :: trunc ( $data -> piece_num , 6 ), 6 , ' ' , STR_PAD_LEFT );
$Tab [ 'jour_ecriture' ] = dol_print_date ( $data -> doc_date , '%d%m%y' );
$Tab [ 'num_compte' ] = str_pad ( self :: trunc ( $code_compta , 6 ), 6 , '0' );
2020-05-21 00:02:33 +02:00
if ( $data -> sens == 'D' ) {
2020-05-08 13:50:26 +02:00
$Tab [ 'montant_debit' ] = str_pad ( number_format ( abs ( $data -> montant ), 2 , ',' , '' ), 13 , ' ' , STR_PAD_LEFT );
$Tab [ 'montant_crebit' ] = str_pad ( number_format ( 0 , 2 , ',' , '' ), 13 , ' ' , STR_PAD_LEFT );
2020-05-21 15:05:19 +02:00
} else {
2020-05-08 13:50:26 +02:00
$Tab [ 'montant_debit' ] = str_pad ( number_format ( 0 , 2 , ',' , '' ), 13 , ' ' , STR_PAD_LEFT );
$Tab [ 'montant_crebit' ] = str_pad ( number_format ( abs ( $data -> montant ), 2 , ',' , '' ), 13 , ' ' , STR_PAD_LEFT );
}
$Tab [ 'libelle_ecriture' ] = str_pad ( self :: trunc ( dol_string_unaccent ( $data -> doc_ref ) . ' ' . dol_string_unaccent ( $data -> label_operation ), 30 ), 30 );
$Tab [ 'lettrage' ] = str_repeat ( ' ' , 2 );
$Tab [ 'code_piece' ] = str_repeat ( ' ' , 5 );
$Tab [ 'code_stat' ] = str_repeat ( ' ' , 4 );
2020-05-21 00:02:33 +02:00
if ( ! empty ( $data -> date_echeance )) {
2020-05-08 13:50:26 +02:00
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab [ 'date_echeance' ] = dol_print_date ( $data -> date_echeance , '%d%m%Y' );
2020-05-21 00:02:33 +02:00
} else {
2020-05-08 13:50:26 +02:00
$Tab [ 'date_echeance' ] = dol_print_date ( $data -> doc_date , '%d%m%Y' );
2020-05-21 00:02:33 +02:00
}
2020-05-08 13:50:26 +02:00
$Tab [ 'monnaie' ] = '1' ;
$Tab [ 'filler' ] = ' ' ;
$Tab [ 'ind_compteur' ] = ' ' ;
$Tab [ 'quantite' ] = '0,000000000' ;
$Tab [ 'code_pointage' ] = str_repeat ( ' ' , 2 );
$Tab [ 'end_line' ] = $end_line ;
print implode ( '|' , $Tab );
}
}
2016-05-16 16:37:07 +02:00
/**
2017-05-04 06:49:29 +02:00
* Export format : EBP
2016-05-16 16:37:07 +02:00
*
2016-05-16 17:07:36 +02:00
* @ param array $objectLines data
2016-05-16 16:37:07 +02:00
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportEbp ( $objectLines )
{
2016-05-16 16:37:07 +02:00
2017-11-05 11:48:41 +01:00
$separator = ',' ;
2017-12-09 06:00:13 +01:00
$end_line = " \n " ;
2016-05-16 16:37:07 +02:00
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2016-05-16 16:37:07 +02:00
$date = dol_print_date ( $line -> doc_date , '%d%m%Y' );
2019-11-14 12:09:15 +01:00
print $line -> id . $separator ;
print $date . $separator ;
print $line -> code_journal . $separator ;
2019-03-08 10:57:14 +01:00
if ( empty ( $line -> subledger_account )) {
2019-11-14 12:09:15 +01:00
print $line -> numero_compte . $separator ;
2019-03-08 10:57:14 +01:00
} else {
2019-11-14 12:09:15 +01:00
print $line -> subledger_account . $separator ;
2019-03-08 10:57:14 +01:00
}
2019-03-14 14:20:34 +01:00
//print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
2019-11-14 12:09:15 +01:00
print '"' . dol_trunc ( $line -> label_operation , 40 , 'right' , 'UTF-8' , 1 ) . '"' . $separator ;
2019-01-27 11:55:16 +01:00
print '"' . dol_trunc ( $line -> piece_num , 15 , 'right' , 'UTF-8' , 1 ) . '"' . $separator ;
2019-03-25 14:52:30 +01:00
print price2num ( abs ( $line -> montant )) . $separator ;
2017-11-05 11:48:41 +01:00
print $line -> sens . $separator ;
2019-11-14 12:09:15 +01:00
print $date . $separator ;
2019-03-08 10:57:14 +01:00
//print 'EUR';
2017-11-05 11:48:41 +01:00
print $end_line ;
2016-05-16 16:37:07 +02:00
}
}
2017-05-04 06:49:29 +02:00
/**
2017-09-30 06:58:31 +02:00
* Export format : Agiris Isacompta
2017-05-04 06:49:29 +02:00
*
* @ param array $objectLines data
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportAgiris ( $objectLines )
{
2017-05-04 06:49:29 +02:00
2017-11-05 11:48:41 +01:00
$separator = ';' ;
2017-12-09 06:00:13 +01:00
$end_line = " \n " ;
2017-05-04 06:49:29 +02:00
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2017-05-04 06:49:29 +02:00
$date = dol_print_date ( $line -> doc_date , '%d%m%Y' );
2019-11-14 12:09:15 +01:00
print $line -> piece_num . $separator ;
print self :: toAnsi ( $line -> label_operation ) . $separator ;
print $date . $separator ;
print self :: toAnsi ( $line -> label_operation ) . $separator ;
2017-06-15 19:29:00 +02:00
if ( empty ( $line -> subledger_account )) {
2019-11-14 12:09:15 +01:00
print length_accountg ( $line -> numero_compte ) . $separator ;
print self :: toAnsi ( $line -> label_compte ) . $separator ;
2017-05-04 06:49:29 +02:00
} else {
2019-11-14 12:09:15 +01:00
print length_accounta ( $line -> subledger_account ) . $separator ;
print self :: toAnsi ( $line -> subledger_label ) . $separator ;
2017-05-04 06:49:29 +02:00
}
2017-06-15 19:29:00 +02:00
2019-11-14 12:09:15 +01:00
print self :: toAnsi ( $line -> doc_ref ) . $separator ;
print price ( $line -> debit ) . $separator ;
print price ( $line -> credit ) . $separator ;
print price ( $line -> montant ) . $separator ;
print $line -> sens . $separator ;
print $line -> lettering_code . $separator ;
2017-09-30 06:58:31 +02:00
print $line -> code_journal ;
2017-11-05 11:48:41 +01:00
print $end_line ;
2017-05-04 06:49:29 +02:00
}
}
2019-05-15 12:16:03 +02:00
/**
* Export format : OpenConcerto
*
* @ param array $objectLines data
* @ return void
*/
public function exportOpenConcerto ( $objectLines )
{
$separator = ';' ;
$end_line = " \n " ;
foreach ( $objectLines as $line ) {
$date = dol_print_date ( $line -> doc_date , '%d/%m/%Y' );
2019-11-14 12:09:15 +01:00
print $date . $separator ;
print $line -> code_journal . $separator ;
2019-05-15 12:16:03 +02:00
if ( empty ( $line -> subledger_account )) {
2019-11-14 12:09:15 +01:00
print length_accountg ( $line -> numero_compte ) . $separator ;
2019-05-15 12:16:03 +02:00
} else {
2019-11-14 12:09:15 +01:00
print length_accounta ( $line -> subledger_account ) . $separator ;
2019-05-15 12:16:03 +02:00
}
2019-11-14 12:09:15 +01:00
print $line -> doc_ref . $separator ;
print $line -> label_operation . $separator ;
print price ( $line -> debit ) . $separator ;
print price ( $line -> credit ) . $separator ;
2019-05-15 12:16:03 +02:00
print $end_line ;
}
}
2017-12-09 06:00:13 +01:00
/**
2019-08-01 13:27:07 +02:00
* Export format : Configurable CSV
2017-12-09 06:00:13 +01:00
*
* @ param array $objectLines data
* @ return void
*/
2018-10-08 21:01:21 +02:00
public function exportConfigurable ( $objectLines )
{
2017-12-09 06:00:13 +01:00
global $conf ;
2019-08-01 13:27:07 +02:00
$separator = $this -> separator ;
2017-12-09 06:00:13 +01:00
foreach ( $objectLines as $line ) {
$tab = array ();
// export configurable
$date = dol_print_date ( $line -> doc_date , $conf -> global -> ACCOUNTING_EXPORT_DATE );
2017-12-09 06:14:34 +01:00
$tab [] = $line -> piece_num ;
2017-12-09 06:00:13 +01:00
$tab [] = $date ;
$tab [] = $line -> doc_ref ;
2019-08-01 13:27:07 +02:00
$tab [] = preg_match ( '/' . $separator . '/' , $line -> label_operation ) ? " ' " . $line -> label_operation . " ' " : $line -> label_operation ;
2018-10-10 19:45:26 +02:00
$tab [] = length_accountg ( $line -> numero_compte );
$tab [] = length_accounta ( $line -> subledger_account );
2019-08-01 13:27:07 +02:00
$tab [] = price2num ( $line -> debit );
$tab [] = price2num ( $line -> credit );
$tab [] = price2num ( $line -> montant );
2018-10-10 19:45:26 +02:00
$tab [] = $line -> code_journal ;
2017-12-09 06:00:13 +01:00
2019-11-14 12:09:15 +01:00
print implode ( $separator , $tab ) . $this -> end_line ;
2017-12-09 06:00:13 +01:00
}
}
2017-11-05 11:48:41 +01:00
2018-10-08 21:01:21 +02:00
/**
* Export format : FEC
*
* @ param array $objectLines data
* @ return void
*/
public function exportFEC ( $objectLines )
{
2018-10-14 06:16:14 +02:00
$separator = " \t " ;
2018-10-08 21:01:21 +02:00
$end_line = " \n " ;
2019-11-14 12:09:15 +01:00
print " JournalCode " . $separator ;
print " JournalLib " . $separator ;
print " EcritureNum " . $separator ;
print " EcritureDate " . $separator ;
print " CompteNum " . $separator ;
print " CompteLib " . $separator ;
print " CompAuxNum " . $separator ;
print " CompAuxLib " . $separator ;
print " PieceRef " . $separator ;
print " PieceDate " . $separator ;
print " EcritureLib " . $separator ;
print " Debit " . $separator ;
print " Credit " . $separator ;
print " EcritureLet " . $separator ;
print " DateLet " . $separator ;
print " ValidDate " . $separator ;
print " Montantdevise " . $separator ;
2018-10-14 06:16:14 +02:00
print " Idevise " ;
print $end_line ;
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2020-01-13 13:52:48 +01:00
$date_creation = dol_print_date ( $line -> date_creation , '%Y%m%d' );
$date_doc = dol_print_date ( $line -> doc_date , '%Y%m%d' );
$date_valid = dol_print_date ( $line -> date_validated , '%Y%m%d' );
2018-10-08 21:01:21 +02:00
// FEC:JournalCode
2019-11-14 12:09:15 +01:00
print $line -> code_journal . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:JournalLib
2019-11-14 12:09:15 +01:00
print $line -> journal_label . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:EcritureNum
2019-11-14 12:09:15 +01:00
print $line -> piece_num . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:EcritureDate
2019-11-14 12:09:15 +01:00
print $date_creation . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:CompteNum
2019-11-14 12:09:15 +01:00
print $line -> numero_compte . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:CompteLib
2019-11-14 12:09:15 +01:00
print $line -> label_compte . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:CompAuxNum
2019-11-14 12:09:15 +01:00
print $line -> subledger_account . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:CompAuxLib
2019-11-14 12:09:15 +01:00
print $line -> subledger_label . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:PieceRef
2019-11-14 12:09:15 +01:00
print $line -> doc_ref . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:PieceDate
2019-11-14 12:09:15 +01:00
print $date_doc . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:EcritureLib
2019-11-14 12:09:15 +01:00
print $line -> label_operation . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:Debit
2020-01-23 12:09:01 +01:00
print price2fec ( $line -> debit ) . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:Credit
2020-01-23 12:09:01 +01:00
print price2fec ( $line -> credit ) . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:EcritureLet
2019-11-14 12:09:15 +01:00
print $line -> lettering_code . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:DateLet
2019-11-14 12:09:15 +01:00
print $line -> date_lettering . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:ValidDate
2019-11-14 12:09:15 +01:00
print $date_valid . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:Montantdevise
2019-11-14 12:09:15 +01:00
print $line -> multicurrency_amount . $separator ;
2018-10-08 21:01:21 +02:00
// FEC:Idevise
print $line -> multicurrency_code ;
print $end_line ;
}
}
2016-05-16 16:37:07 +02:00
2019-05-24 21:48:36 +02:00
/**
* Export format : SAGE50SWISS
*
* https :// onlinehelp . sageschweiz . ch / default . aspx ? tabid = 19984
* http :// media . topal . ch / Public / Schnittstellen / TAF / Specification / Sage50 - TAF - format . pdf
*
* @ param array $objectLines data
*
* @ return void
*/
public function exportSAGE50SWISS ( $objectLines )
2019-05-22 11:40:58 +02:00
{
2019-05-24 21:48:36 +02:00
// SAGE50SWISS
$this -> separator = ',' ;
$this -> end_line = " \r \n " ;
// Print header line
print " Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag " ;
print $this -> end_line ;
2019-11-14 12:09:15 +01:00
$thisPieceNum = " " ;
$thisPieceAccountNr = " " ;
$aSize = count ( $objectLines );
2019-05-24 21:48:36 +02:00
foreach ( $objectLines as $aIndex => $line )
{
2019-11-14 12:09:15 +01:00
$sammelBuchung = false ;
if ( $aIndex - 2 >= 0 && $objectLines [ $aIndex - 2 ] -> piece_num == $line -> piece_num )
2019-05-24 21:48:36 +02:00
{
2019-11-14 12:09:15 +01:00
$sammelBuchung = true ;
2020-05-21 15:05:19 +02:00
} elseif ( $aIndex + 2 < $aSize && $objectLines [ $aIndex + 2 ] -> piece_num == $line -> piece_num )
2019-05-24 21:48:36 +02:00
{
2019-11-14 12:09:15 +01:00
$sammelBuchung = true ;
2020-05-21 15:05:19 +02:00
} elseif ( $aIndex + 1 < $aSize
2019-11-14 12:09:15 +01:00
&& $objectLines [ $aIndex + 1 ] -> piece_num == $line -> piece_num
&& $aIndex - 1 < $aSize
&& $objectLines [ $aIndex - 1 ] -> piece_num == $line -> piece_num
2019-05-24 21:48:36 +02:00
)
{
2019-11-14 12:09:15 +01:00
$sammelBuchung = true ;
2019-05-24 21:48:36 +02:00
}
//Blg
2019-11-14 12:09:15 +01:00
print $line -> piece_num . $this -> separator ;
2019-05-24 21:48:36 +02:00
// Datum
$date = dol_print_date ( $line -> doc_date , '%d.%m.%Y' );
2019-11-14 12:09:15 +01:00
print $date . $this -> separator ;
2019-05-24 21:48:36 +02:00
// Kto
2019-11-14 12:09:15 +01:00
print length_accountg ( $line -> numero_compte ) . $this -> separator ;
2019-05-24 21:48:36 +02:00
// S/H
if ( $line -> sens == 'D' )
{
2019-11-14 12:09:15 +01:00
print 'S' . $this -> separator ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-14 12:09:15 +01:00
print 'H' . $this -> separator ;
2019-05-24 21:48:36 +02:00
}
//Grp
2019-11-14 12:09:15 +01:00
print self :: trunc ( $line -> code_journal , 1 ) . $this -> separator ;
2019-05-24 21:48:36 +02:00
// GKto
if ( empty ( $line -> code_tiers ))
{
if ( $line -> piece_num == $thisPieceNum )
2019-05-22 10:34:39 +02:00
{
2019-11-14 12:09:15 +01:00
print length_accounta ( $thisPieceAccountNr ) . $this -> separator ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-14 12:09:15 +01:00
print " div " . $this -> separator ;
2019-05-24 21:48:36 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2019-11-14 12:09:15 +01:00
print length_accounta ( $line -> code_tiers ) . $this -> separator ;
2019-05-24 21:48:36 +02:00
}
//SId
print $this -> separator ;
//SIdx
2019-11-14 12:09:15 +01:00
print " 0 " . $this -> separator ;
2019-05-24 21:48:36 +02:00
//KIdx
2019-11-14 12:09:15 +01:00
print " 0 " . $this -> separator ;
2019-05-24 21:48:36 +02:00
//BTyp
2019-11-14 12:09:15 +01:00
print " 0 " . $this -> separator ;
2019-05-24 21:48:36 +02:00
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
if ( $sammelBuchung )
{
2019-11-14 12:09:15 +01:00
print " 2 " . $this -> separator ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-14 12:09:15 +01:00
print " 1 " . $this -> separator ;
2019-05-24 21:48:36 +02:00
}
// Code
2019-11-14 12:09:15 +01:00
print '""' . $this -> separator ;
2019-05-24 21:48:36 +02:00
// Netto
if ( $line -> montant >= 0 )
{
2019-11-14 12:09:15 +01:00
print $line -> montant . $this -> separator ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-14 12:42:44 +01:00
print ( $line -> montant * - 1 ) . $this -> separator ;
2019-05-24 21:48:36 +02:00
}
// Steuer
2019-11-14 12:09:15 +01:00
print " 0.00 " . $this -> separator ;
2019-05-24 21:48:36 +02:00
// FW-Betrag
2019-11-14 12:09:15 +01:00
print " 0.00 " . $this -> separator ;
2019-05-24 21:48:36 +02:00
// Tx1
2019-11-14 12:09:15 +01:00
$line1 = self :: toAnsi ( $line -> label_compte , 29 );
2019-05-24 21:48:36 +02:00
if ( $line1 == " LIQ " || $line1 == " LIQ Beleg ok " || strlen ( $line1 ) <= 3 )
{
2019-11-14 12:09:15 +01:00
$line1 = " " ;
2019-05-24 21:48:36 +02:00
}
2019-11-14 12:09:15 +01:00
$line2 = self :: toAnsi ( $line -> doc_ref , 29 );
2019-05-24 21:48:36 +02:00
if ( strlen ( $line1 ) == 0 )
{
2019-11-14 12:09:15 +01:00
$line1 = $line2 ;
$line2 = " " ;
2019-05-24 21:48:36 +02:00
}
if ( strlen ( $line1 ) > 0 && strlen ( $line2 ) > 0 && ( strlen ( $line1 ) + strlen ( $line2 )) < 27 )
{
2019-11-14 12:09:15 +01:00
$line1 = $line1 . ' / ' . $line2 ;
$line2 = " " ;
2019-05-24 21:48:36 +02:00
}
2019-11-14 12:09:15 +01:00
print '"' . self :: toAnsi ( $line1 ) . '"' . $this -> separator ;
2019-05-24 21:48:36 +02:00
// Tx2
2019-11-14 12:09:15 +01:00
print '"' . self :: toAnsi ( $line2 ) . '"' . $this -> separator ;
2019-05-24 21:48:36 +02:00
//PkKey
2019-11-14 12:09:15 +01:00
print " 0 " . $this -> separator ;
2019-05-24 21:48:36 +02:00
//OpId
print $this -> separator ;
// Flag
print " 0 " ;
print $this -> end_line ;
if ( $line -> piece_num !== $thisPieceNum )
{
2019-11-14 12:09:15 +01:00
$thisPieceNum = $line -> piece_num ;
$thisPieceAccountNr = $line -> numero_compte ;
2019-05-24 21:48:36 +02:00
}
2019-05-22 11:40:58 +02:00
}
2019-05-24 21:48:36 +02:00
}
2019-05-22 10:01:25 +02:00
2019-07-19 17:07:55 +02:00
/**
2020-05-08 13:50:26 +02:00
* Export format : LD Compta version 9
2020-03-12 12:25:19 +01:00
* http :// www . ldsysteme . fr / fileadmin / telechargement / np / ldcompta / Documentation / IntCptW9 . pdf
2019-07-19 17:07:55 +02:00
*
* @ param array $objectLines data
*
* @ return void
*/
2019-10-09 16:33:57 +02:00
public function exportLDCompta ( $objectLines )
{
2019-07-19 17:07:55 +02:00
2019-10-09 16:33:57 +02:00
$separator = ';' ;
$end_line = " \r \n " ;
2019-07-19 17:07:55 +02:00
2019-10-09 16:33:57 +02:00
foreach ( $objectLines as $line ) {
$date_document = dol_print_date ( $line -> doc_date , '%Y%m%d' );
2019-11-14 12:09:15 +01:00
$date_creation = dol_print_date ( $line -> date_creation , '%Y%m%d' );
2020-02-11 15:57:49 +01:00
$date_lim_reglement = dol_print_date ( $line -> date_lim_reglement , '%Y%m%d' );
2019-10-09 16:33:57 +02:00
// TYPE
$type_enregistrement = 'E' ; // For write movement
2019-11-14 12:09:15 +01:00
print $type_enregistrement . $separator ;
2019-10-09 16:33:57 +02:00
// JNAL
2019-11-14 12:09:15 +01:00
print substr ( $line -> code_journal , 0 , 2 ) . $separator ;
2019-10-09 16:33:57 +02:00
// NECR
2019-11-14 12:09:15 +01:00
print $line -> id . $separator ;
2019-10-09 16:33:57 +02:00
// NPIE
2019-11-14 12:09:15 +01:00
print $line -> piece_num . $separator ;
2019-10-09 16:33:57 +02:00
// DATP
2019-11-14 12:09:15 +01:00
print $date_document . $separator ;
2019-10-09 16:33:57 +02:00
// LIBE
2019-11-14 12:09:15 +01:00
print $line -> label_operation . $separator ;
2019-10-09 16:33:57 +02:00
// DATH
2020-02-11 15:57:49 +01:00
print $date_lim_reglement . $separator ;
2019-10-09 16:33:57 +02:00
// CNPI
if ( $line -> doc_type == 'supplier_invoice' ) {
if ( $line -> montant < 0 ) {
$nature_piece = 'AF' ;
} else {
$nature_piece = 'FF' ;
}
} elseif ( $line -> doc_type == 'customer_invoice' ) {
if ( $line -> montant < 0 ) {
$nature_piece = 'AC' ;
} else {
$nature_piece = 'FC' ;
}
} else {
$nature_piece = '' ;
}
2019-11-14 12:09:15 +01:00
print $nature_piece . $separator ;
2019-10-09 16:33:57 +02:00
// RACI
2020-02-11 15:57:49 +01:00
// if (! empty($line->subledger_account)) {
2020-02-11 16:20:46 +01:00
// if ($line->doc_type == 'supplier_invoice') {
// $racine_subledger_account = '40';
// } elseif ($line->doc_type == 'customer_invoice') {
// $racine_subledger_account = '41';
// } else {
// $racine_subledger_account = '';
// }
// } else {
2020-02-11 15:57:49 +01:00
$racine_subledger_account = '' ; // for records of type E leave this field blank
2020-02-11 16:20:46 +01:00
// }
2020-02-11 15:57:49 +01:00
2020-02-21 17:53:37 +01:00
print $racine_subledger_account . $separator ; // deprecated CPTG & CPTA use instead
2019-10-09 16:33:57 +02:00
// MONT
2020-06-16 11:40:01 +02:00
print price ( abs ( $line -> montant ), 0 , '' , 1 , 2 , 2 ) . $separator ;
2019-10-09 16:33:57 +02:00
// CODC
2019-11-14 12:09:15 +01:00
print $line -> sens . $separator ;
2019-10-09 16:33:57 +02:00
// CPTG
2019-11-14 12:09:15 +01:00
print length_accountg ( $line -> numero_compte ) . $separator ;
2019-10-09 16:33:57 +02:00
// DATE
2019-11-14 12:09:15 +01:00
print $date_creation . $separator ;
2019-10-09 16:33:57 +02:00
// CLET
2019-11-14 12:09:15 +01:00
print $line -> lettering_code . $separator ;
2019-10-09 16:33:57 +02:00
// DATL
2019-11-14 12:09:15 +01:00
print $line -> date_lettering . $separator ;
2019-10-09 16:33:57 +02:00
// CPTA
2019-11-14 12:09:15 +01:00
if ( ! empty ( $line -> subledger_account )) {
print length_accounta ( $line -> subledger_account ) . $separator ;
2019-10-09 16:33:57 +02:00
} else {
print $separator ;
}
// CNAT
2019-11-14 12:09:15 +01:00
if ( $line -> doc_type == 'supplier_invoice' && ! empty ( $line -> subledger_account )) {
print 'F' . $separator ;
} elseif ( $line -> doc_type == 'customer_invoice' && ! empty ( $line -> subledger_account )) {
print 'C' . $separator ;
2019-10-09 16:33:57 +02:00
} else {
print $separator ;
}
// SECT
print $separator ;
// CTRE
print $separator ;
// NORL
print $separator ;
// DATV
print $separator ;
// REFD
2019-11-14 12:09:15 +01:00
print $line -> doc_ref . $separator ;
2019-10-09 16:33:57 +02:00
// CODH
print $separator ;
// NSEQ
print $separator ;
// MTDV
2019-11-14 12:09:15 +01:00
print '0' . $separator ;
2019-10-09 16:33:57 +02:00
// CODV
print $separator ;
// TXDV
2019-11-14 12:09:15 +01:00
print '0' . $separator ;
2019-10-09 16:33:57 +02:00
// MOPM
print $separator ;
// BONP
print $separator ;
// BQAF
print $separator ;
// ECES
print $separator ;
// TXTL
print $separator ;
// ECRM
print $separator ;
// DATK
print $separator ;
// HEUK
print $separator ;
print $end_line ;
}
}
2019-07-19 17:07:55 +02:00
2020-03-12 11:55:26 +01:00
/**
* Export format : LD Compta version 10 & higher
* http :// www . ldsysteme . fr / fileadmin / telechargement / np / ldcompta / Documentation / IntCptW10 . pdf
*
* @ param array $objectLines data
*
* @ return void
*/
public function exportLDCompta10 ( $objectLines )
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
$separator = ';' ;
$end_line = " \r \n " ;
$last_codeinvoice = '' ;
foreach ( $objectLines as $line ) {
// TYPE C
2020-04-10 10:59:32 +02:00
if ( $last_codeinvoice != $line -> doc_ref ) {
2020-03-12 11:55:26 +01:00
//recherche societe en fonction de son code client
2020-04-10 10:59:32 +02:00
$sql = " SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM " . MAIN_DB_PREFIX . " societe WHERE code_client = ' " . $line -> thirdparty_code . " ' " ;
2020-03-12 11:55:26 +01:00
$resql = $this -> db -> query ( $sql );
2020-04-10 10:59:32 +02:00
if ( $resql && $this -> db -> num_rows ( $resql ) > 0 )
2020-03-12 11:55:26 +01:00
{
$soc = $this -> db -> fetch_object ( $resql );
2020-04-10 10:59:32 +02:00
$address = array ( '' , '' , '' );
if ( strpos ( $soc -> address , " \n " ) !== false ) {
2020-03-16 17:34:28 +01:00
$address = explode ( " \n " , $soc -> address );
2020-04-10 10:59:32 +02:00
if ( is_array ( $address ) && count ( $address ) > 0 ) {
foreach ( $address as $key => $data ) {
$address [ $key ] = str_replace ( array ( " \t " , " \n " , " \r " ), " " , $data );
$address [ $key ] = dol_trunc ( $address [ $key ], 40 , 'right' , 'UTF-8' , 1 );
2020-03-16 17:31:16 +01:00
}
}
} else {
2020-04-10 10:59:32 +02:00
$address [ 0 ] = substr ( str_replace ( array ( " \t " , " \r " ), " " , $soc -> address ), 0 , 40 );
$address [ 1 ] = substr ( str_replace ( array ( " \t " , " \r " ), " " , $soc -> address ), 41 , 40 );
$address [ 2 ] = substr ( str_replace ( array ( " \t " , " \r " ), " " , $soc -> address ), 82 , 40 );
2020-03-16 17:31:16 +01:00
}
2020-03-12 11:55:26 +01:00
$type_enregistrement = 'C' ;
2020-03-16 17:31:16 +01:00
//TYPE
2020-03-12 11:55:26 +01:00
print $type_enregistrement . $separator ;
//NOCL
print $soc -> code_client . $separator ;
//NMCM
print $separator ;
//LIBI
print $separator ;
//TITR
2020-03-16 17:31:16 +01:00
print $separator ;
2020-03-12 11:55:26 +01:00
//RSSO
print $soc -> nom . $separator ;
//CAD1
2020-03-16 17:31:16 +01:00
print $address [ 0 ] . $separator ;
2020-03-12 11:55:26 +01:00
//CAD2
2020-03-16 17:31:16 +01:00
print $address [ 1 ] . $separator ;
2020-03-12 11:55:26 +01:00
//CAD3
2020-03-16 17:31:16 +01:00
print $address [ 2 ] . $separator ;
2020-03-12 11:55:26 +01:00
//COPO
print $soc -> zip . $separator ;
//BUDI
print substr ( $soc -> town , 0 , 40 ) . $separator ;
//CPAY
print $separator ;
//PAYS
print substr ( getCountry ( $soc -> fk_pays ), 0 , 40 ) . $separator ;
//NTEL
print $soc -> phone . $separator ;
//TLEX
print $separator ;
//TLPO
print $separator ;
//TLCY
print $separator ;
//NINT
print $separator ;
//COMM
print $separator ;
//SIRE
2020-03-16 17:31:16 +01:00
print str_replace ( " " , " " , $soc -> siret ) . $separator ;
2020-03-12 11:55:26 +01:00
//RIBP
print $separator ;
//DOBQ
print $separator ;
//IBBQ
print $separator ;
//COBQ
print $separator ;
//GUBQ
print $separator ;
//CPBQ
print $separator ;
//CLBQ
print $separator ;
//BIBQ
print $separator ;
//MOPM
print $separator ;
//DJPM
print $separator ;
//DMPM
print $separator ;
//REFM
print $separator ;
//SLVA
print $separator ;
//PLCR
print $separator ;
//ECFI
print $separator ;
//CREP
print $separator ;
//NREP
print $separator ;
//TREP
print $separator ;
//MREP
print $separator ;
//GRRE
print $separator ;
//LTTA
print $separator ;
//CACT
print $separator ;
//CODV
print $separator ;
//GRTR
print $separator ;
//NOFP
print $separator ;
//BQAF
print $separator ;
//BONP
print $separator ;
//CESC
print $separator ;
print $end_line ;
}
}
$date_document = dol_print_date ( $line -> doc_date , '%Y%m%d' );
$date_creation = dol_print_date ( $line -> date_creation , '%Y%m%d' );
$date_lim_reglement = dol_print_date ( $line -> date_lim_reglement , '%Y%m%d' );
// TYPE E
$type_enregistrement = 'E' ; // For write movement
print $type_enregistrement . $separator ;
// JNAL
print substr ( $line -> code_journal , 0 , 2 ) . $separator ;
// NECR
print $line -> id . $separator ;
// NPIE
print $line -> piece_num . $separator ;
// DATP
print $date_document . $separator ;
// LIBE
2020-03-12 11:59:08 +01:00
print dol_trunc ( $line -> label_operation , 25 , 'right' , 'UTF-8' , 1 ) . $separator ;
2020-03-12 11:55:26 +01:00
// DATH
print $date_lim_reglement . $separator ;
// CNPI
if ( $line -> doc_type == 'supplier_invoice' ) {
if ( $line -> montant < 0 ) {
$nature_piece = 'AF' ;
} else {
$nature_piece = 'FF' ;
}
} elseif ( $line -> doc_type == 'customer_invoice' ) {
if ( $line -> montant < 0 ) {
$nature_piece = 'AC' ;
} else {
$nature_piece = 'FC' ;
}
} else {
$nature_piece = '' ;
}
print $nature_piece . $separator ;
// RACI
// if (! empty($line->subledger_account)) {
// if ($line->doc_type == 'supplier_invoice') {
// $racine_subledger_account = '40';
// } elseif ($line->doc_type == 'customer_invoice') {
// $racine_subledger_account = '41';
// } else {
// $racine_subledger_account = '';
// }
// } else {
$racine_subledger_account = '' ; // for records of type E leave this field blank
// }
2020-04-10 10:59:32 +02:00
print $racine_subledger_account . $separator ; // deprecated CPTG & CPTA use instead
2020-03-12 11:55:26 +01:00
// MONT
print price ( abs ( $line -> montant ), 0 , '' , 1 , 2 ) . $separator ;
// CODC
print $line -> sens . $separator ;
// CPTG
print length_accountg ( $line -> numero_compte ) . $separator ;
// DATE
print $date_document . $separator ;
// CLET
print $line -> lettering_code . $separator ;
// DATL
print $line -> date_lettering . $separator ;
// CPTA
if ( ! empty ( $line -> subledger_account )) {
print length_accounta ( $line -> subledger_account ) . $separator ;
} else {
print $separator ;
}
// CNAT
if ( $line -> doc_type == 'supplier_invoice' && ! empty ( $line -> subledger_account )) {
print 'F' . $separator ;
} elseif ( $line -> doc_type == 'customer_invoice' && ! empty ( $line -> subledger_account )) {
print 'C' . $separator ;
} else {
print $separator ;
}
// CTRE
print $separator ;
// NORL
print $separator ;
// DATV
print $separator ;
// REFD
print $line -> doc_ref . $separator ;
// NECA
print '0' . $separator ;
// CSEC
print $separator ;
// CAFF
print $separator ;
// CDES
print $separator ;
// QTUE
print $separator ;
2020-03-16 17:31:16 +01:00
// MTDV
2020-03-12 11:55:26 +01:00
print '0' . $separator ;
2020-03-16 17:31:16 +01:00
// CODV
2020-03-12 11:55:26 +01:00
print $separator ;
2020-03-16 17:31:16 +01:00
// TXDV
print '0' . $separator ;
2020-03-12 11:55:26 +01:00
// MOPM
print $separator ;
// BONP
print $separator ;
// BQAF
print $separator ;
// ECES
print $separator ;
// TXTL
print $separator ;
// ECRM
print $separator ;
// DATK
print $separator ;
// HEUK
print $separator ;
print $end_line ;
$last_codeinvoice = $line -> doc_ref ;
}
}
2019-07-31 17:02:35 +02:00
/**
* Export format : Charlemagne
*
* @ param array $objectLines data
* @ return void
*/
2019-08-04 13:08:38 +02:00
public function exportCharlemagne ( $objectLines )
2019-07-31 17:02:35 +02:00
{
global $langs ;
$langs -> load ( 'compta' );
2019-08-04 13:08:38 +02:00
2019-07-31 17:02:35 +02:00
$separator = " \t " ;
$end_line = " \n " ;
/*
* Charlemagne export need header
*/
2019-11-14 12:09:15 +01:00
print $langs -> transnoentitiesnoconv ( 'Date' ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'Journal' ), 6 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'Account' ), 15 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'LabelAccount' ), 60 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'Piece' ), 20 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'LabelOperation' ), 60 ) . $separator ;
print $langs -> transnoentitiesnoconv ( 'Amount' ) . $separator ;
print 'S' . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'Analytic' ) . ' 1' , 15 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'AnalyticLabel' ) . ' 1' , 60 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'Analytic' ) . ' 2' , 15 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'AnalyticLabel' ) . ' 2' , 60 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'Analytic' ) . ' 3' , 15 ) . $separator ;
print self :: trunc ( $langs -> transnoentitiesnoconv ( 'AnalyticLabel' ) . ' 3' , 60 ) . $separator ;
2019-07-31 17:02:35 +02:00
print $end_line ;
2019-08-04 13:08:38 +02:00
2019-11-14 12:09:15 +01:00
foreach ( $objectLines as $line ) {
2019-07-31 17:02:35 +02:00
$date = dol_print_date ( $line -> doc_date , '%Y%m%d' );
2019-11-14 12:09:15 +01:00
print $date . $separator ; //Date
2019-07-31 17:02:35 +02:00
2019-11-14 12:09:15 +01:00
print self :: trunc ( $line -> code_journal , 6 ) . $separator ; //Journal code
2019-07-31 17:02:35 +02:00
2019-11-14 12:09:15 +01:00
if ( ! empty ( $line -> subledger_account )) $account = $line -> subledger_account ;
2020-05-21 00:02:33 +02:00
else {
$account = $line -> numero_compte ;
}
2019-11-14 12:09:15 +01:00
print self :: trunc ( $account , 15 ) . $separator ; //Account number
print self :: trunc ( $line -> label_compte , 60 ) . $separator ; //Account label
print self :: trunc ( $line -> doc_ref , 20 ) . $separator ; //Piece
print self :: trunc ( $line -> label_operation , 60 ) . $separator ; //Operation label
print price ( abs ( $line -> montant )) . $separator ; //Amount
print $line -> sens . $separator ; //Direction
print $separator ; //Analytic
print $separator ; //Analytic
print $separator ; //Analytic
print $separator ; //Analytic
print $separator ; //Analytic
print $separator ; //Analytic
2019-07-31 17:02:35 +02:00
print $end_line ;
}
}
2016-03-15 09:01:02 +01:00
/**
2019-06-20 13:37:06 +02:00
* trunc
2016-03-15 09:01:02 +01:00
*
2019-06-20 13:37:06 +02:00
* @ param string $str String
* @ param integer $size Data to trunc
2018-10-08 21:01:21 +02:00
* @ return string
2016-03-15 09:01:02 +01:00
*/
2018-10-08 21:01:21 +02:00
public static function trunc ( $str , $size )
{
2016-03-15 08:58:53 +01:00
return dol_trunc ( $str , $size , 'right' , 'UTF-8' , 1 );
}
2019-05-22 10:01:25 +02:00
/**
2019-06-20 13:37:06 +02:00
* toAnsi
2019-05-22 10:01:25 +02:00
*
2019-06-20 13:37:06 +02:00
* @ param string $str Original string to encode and optionaly truncate
* @ param integer $size Truncate string after $size characters
* @ return string String encoded in Windows - 1251 charset
2019-05-22 10:01:25 +02:00
*/
2019-05-22 10:34:39 +02:00
public static function toAnsi ( $str , $size = - 1 )
2019-05-22 11:40:58 +02:00
{
2019-11-14 12:09:15 +01:00
$retVal = dol_string_nohtmltag ( $str , 1 , 'Windows-1251' );
2019-05-22 11:40:58 +02:00
if ( $retVal >= 0 && $size >= 0 )
{
2019-11-14 12:09:15 +01:00
$retVal = mb_substr ( $retVal , 0 , $size , 'Windows-1251' );
2019-05-22 11:40:58 +02:00
}
return $retVal ;
2019-05-22 10:01:25 +02:00
}
2016-03-15 08:58:53 +01:00
}