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 >
2023-01-28 04:48:55 +01:00
* Copyright ( C ) 2016 - 2023 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 >
2022-05-20 14:48:37 +02:00
* Copyright ( C ) 2022 Joachim Kueter < jkueter @ gmx . de >
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' ;
2022-05-20 14:58:46 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php' ;
2020-01-23 12:09:01 +01:00
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 ;
2020-10-31 14:32:18 +01:00
public static $EXPORT_TYPE_LDCOMPTA = 110 ;
2020-03-12 11:55:26 +01:00
public static $EXPORT_TYPE_LDCOMPTA10 = 120 ;
2021-01-21 20:55:46 +01:00
public static $EXPORT_TYPE_GESTIMUMV3 = 130 ;
public static $EXPORT_TYPE_GESTIMUMV5 = 135 ;
2021-07-08 16:36:53 +02:00
public static $EXPORT_TYPE_ISUITEEXPERT = 200 ;
// Generic FEC after that
2019-06-20 13:37:06 +02:00
public static $EXPORT_TYPE_FEC = 1000 ;
2020-12-16 05:16:08 +01:00
public static $EXPORT_TYPE_FEC2 = 1010 ;
2017-11-19 19:42:16 +01:00
2022-03-16 20:31:40 +01:00
/**
* @ var DoliDB Database handler
*/
public $db ;
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
*/
2021-11-07 18:54:59 +01:00
public function __construct ( DoliDB $db )
2018-10-08 21:01:21 +02:00
{
2022-05-20 14:48:37 +02:00
global $conf , $hookmanager ;
2016-03-15 08:58:53 +01:00
2021-11-07 18:54:59 +01:00
$this -> db = $db ;
2016-03-15 08:58:53 +01:00
$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 " );
2022-05-20 14:48:37 +02:00
$hookmanager -> initHooks ( array ( 'accountancyexport' ));
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
*/
2022-05-20 14:48:37 +02:00
public function getType ()
2018-10-08 21:01:21 +02:00
{
2022-05-25 08:54:40 +02:00
global $langs , $hookmanager ;
2016-03-15 08:58:53 +01:00
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' ),
2020-10-31 14:32:18 +01: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' ),
2020-12-01 02:41:19 +01:00
self :: $EXPORT_TYPE_CHARLEMAGNE => $langs -> trans ( 'Modelcsv_charlemagne' ),
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' ),
2021-09-16 06:40:43 +02:00
self :: $EXPORT_TYPE_GESTIMUMV3 => $langs -> trans ( 'Modelcsv_Gestinumv3' ),
self :: $EXPORT_TYPE_GESTIMUMV5 => $langs -> trans ( 'Modelcsv_Gestinumv5' ),
2019-06-20 13:37:06 +02:00
self :: $EXPORT_TYPE_FEC => $langs -> trans ( 'Modelcsv_FEC' ),
2020-12-16 05:16:08 +01:00
self :: $EXPORT_TYPE_FEC2 => $langs -> trans ( 'Modelcsv_FEC2' ),
2021-07-07 17:32:48 +02:00
self :: $EXPORT_TYPE_ISUITEEXPERT => 'Export iSuite Expert' ,
2019-02-25 00:56:48 +01:00
);
2019-06-20 13:37:06 +02:00
2022-05-20 14:48:37 +02:00
// allow modules to define export formats
2022-05-25 08:54:40 +02:00
$parameters = array ();
2022-05-20 14:58:46 +02:00
$reshook = $hookmanager -> executeHooks ( 'getType' , $parameters , $listofexporttypes );
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' ,
2020-12-01 02:41:19 +01:00
self :: $EXPORT_TYPE_SAGE50_SWISS => 'sage50ch' ,
self :: $EXPORT_TYPE_CHARLEMAGNE => 'charlemagne' ,
self :: $EXPORT_TYPE_LDCOMPTA => 'ldcompta' ,
self :: $EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10' ,
2021-01-21 20:55:46 +01:00
self :: $EXPORT_TYPE_GESTIMUMV3 => 'gestimumv3' ,
self :: $EXPORT_TYPE_GESTIMUMV5 => 'gestimumv5' ,
2018-10-10 20:01:01 +02:00
self :: $EXPORT_TYPE_FEC => 'fec' ,
2020-12-16 05:16:08 +01:00
self :: $EXPORT_TYPE_FEC2 => 'fec2' ,
2021-07-07 17:32:48 +02:00
self :: $EXPORT_TYPE_ISUITEEXPERT => 'isuiteexpert' ,
2018-10-10 20:01:01 +02:00
);
2022-05-20 14:48:37 +02:00
global $hookmanager ;
$code = $formatcode [ $type ];
$parameters = array ( 'type' => $type );
2022-05-20 14:58:46 +02:00
$reshook = $hookmanager -> executeHooks ( 'getFormatCode' , $parameters , $code );
2022-05-20 14:48:37 +02:00
return $code ;
2018-10-10 20:01:01 +02:00
}
2017-12-09 06:00:13 +01:00
/**
* Array with all export type available ( key + label ) and parameters for config
*
* @ return array of type
*/
2022-05-20 14:48:37 +02:00
public function getTypeConfig ()
2018-10-08 21:01:21 +02:00
{
2017-12-09 06:00:13 +01:00
global $conf , $langs ;
2022-05-20 14:48:37 +02:00
$exporttypes = 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' ),
),
2020-12-01 02:41:19 +01:00
self :: $EXPORT_TYPE_OPENCONCERTO => array (
'label' => $langs -> trans ( 'Modelcsv_openconcerto' ),
),
2019-06-20 13:37:06 +02:00
self :: $EXPORT_TYPE_SAGE50_SWISS => array (
'label' => $langs -> trans ( 'Modelcsv_Sage50_Swiss' ),
2017-12-09 06:00:13 +01:00
),
2020-10-27 16:17:52 +01:00
self :: $EXPORT_TYPE_CHARLEMAGNE => array (
'label' => $langs -> trans ( 'Modelcsv_charlemagne' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
2020-10-31 14:32:18 +01:00
),
2020-12-01 02:41:19 +01:00
self :: $EXPORT_TYPE_LDCOMPTA => array (
'label' => $langs -> trans ( 'Modelcsv_LDCompta' ),
),
2020-03-12 11:55:26 +01:00
self :: $EXPORT_TYPE_LDCOMPTA10 => array (
2020-12-01 02:41:19 +01:00
'label' => $langs -> trans ( 'Modelcsv_LDCompta10' ),
),
2021-01-21 20:55:46 +01:00
self :: $EXPORT_TYPE_GESTIMUMV3 => array (
2020-12-01 02:41:19 +01:00
'label' => $langs -> trans ( 'Modelcsv_Gestinumv3' ),
2021-01-21 20:55:46 +01:00
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
2020-12-01 02:41:19 +01:00
),
2021-01-21 20:55:46 +01:00
self :: $EXPORT_TYPE_GESTIMUMV5 => array (
2020-12-01 02:41:19 +01:00
'label' => $langs -> trans ( 'Modelcsv_Gestinumv5' ),
2021-01-21 20:55:46 +01:00
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
2020-12-01 02:41:19 +01:00
),
2018-10-08 21:01:21 +02:00
self :: $EXPORT_TYPE_FEC => array (
'label' => $langs -> trans ( 'Modelcsv_FEC' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
),
2020-12-16 05:16:08 +01:00
self :: $EXPORT_TYPE_FEC2 => array (
'label' => $langs -> trans ( 'Modelcsv_FEC2' ),
'ACCOUNTING_EXPORT_FORMAT' => 'txt' ,
),
2021-07-07 17:32:48 +02:00
self :: $EXPORT_TYPE_ISUITEEXPERT => array (
'label' => 'iSuite Expert' ,
'ACCOUNTING_EXPORT_FORMAT' => 'csv' ,
),
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 " )
),
);
2022-05-20 14:48:37 +02:00
global $hookmanager ;
$parameters = array ();
2022-05-20 14:58:46 +02:00
$reshook = $hookmanager -> executeHooks ( 'getTypeConfig' , $parameters , $exporttypes );
return $exporttypes ;
2017-12-09 06:00:13 +01:00
}
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-10-31 14:32:18 +01: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 ) {
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_CONFIGURABLE :
2018-10-10 19:45:26 +02:00
$this -> exportConfigurable ( $TData );
2016-03-15 08:58:53 +01:00
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_CEGID :
2016-03-15 08:58:53 +01:00
$this -> exportCegid ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_COALA :
2016-03-15 08:58:53 +01:00
$this -> exportCoala ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_BOB50 :
2016-03-15 08:58:53 +01:00
$this -> exportBob50 ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_CIEL :
2016-03-15 08:58:53 +01:00
$this -> exportCiel ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_QUADRATUS :
2016-03-15 08:58:53 +01:00
$this -> exportQuadratus ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_WINFIC :
2020-05-08 13:50:26 +02:00
$this -> exportWinfic ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_EBP :
2016-05-16 16:37:07 +02:00
$this -> exportEbp ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_COGILOG :
2016-06-29 17:30:47 +02:00
$this -> exportCogilog ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_AGIRIS :
2017-05-04 06:49:29 +02:00
$this -> exportAgiris ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_OPENCONCERTO :
2020-10-31 14:32:18 +01:00
$this -> exportOpenConcerto ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_SAGE50_SWISS :
2019-05-22 10:01:25 +02:00
$this -> exportSAGE50SWISS ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_CHARLEMAGNE :
2019-07-31 17:02:35 +02:00
$this -> exportCharlemagne ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_LDCOMPTA :
2020-12-01 02:41:19 +01:00
$this -> exportLDCompta ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_LDCOMPTA10 :
2020-12-01 02:41:19 +01:00
$this -> exportLDCompta10 ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_GESTIMUMV3 :
2020-12-01 02:41:19 +01:00
$this -> exportGestimumV3 ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_GESTIMUMV5 :
2020-12-01 02:41:19 +01:00
$this -> exportGestimumV5 ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_FEC :
2020-12-01 02:41:19 +01:00
$this -> exportFEC ( $TData );
break ;
2021-02-22 21:36:42 +01:00
case self :: $EXPORT_TYPE_FEC2 :
2020-12-16 05:16:08 +01:00
$this -> exportFEC2 ( $TData );
break ;
2021-07-07 17:32:48 +02:00
case self :: $EXPORT_TYPE_ISUITEEXPERT :
$this -> exportiSuiteExpert ( $TData );
break ;
2016-07-06 11:23:32 +02:00
default :
2022-05-20 14:48:37 +02:00
global $hookmanager ;
2022-05-20 14:58:46 +02:00
$parameters = array ( 'format' => $formatexportset );
2022-05-20 14:48:37 +02:00
// file contents will be created in the hooked function via print
2022-05-20 14:58:46 +02:00
$reshook = $hookmanager -> executeHooks ( 'export' , $parameters , $TData );
2022-05-20 14:48:37 +02:00
if ( $reshook != 1 ) {
$this -> errors [] = $langs -> trans ( 'accountancy_error_modelnotfound' );
2022-05-20 14:58:46 +02:00
}
2016-03-15 08:58:53 +01:00
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 ;
2021-02-26 19:18:03 +01:00
print price2fec ( abs ( $line -> debit - $line -> credit )) . $separator ;
2021-02-11 13:17:20 +01:00
print dol_string_unaccent ( $line -> label_operation ) . $separator ;
print dol_string_unaccent ( $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' ) {
2021-02-26 19:18:03 +01:00
print price ( $line -> debit ) . $separator ;
2019-11-14 12:09:15 +01:00
print '' . $separator ;
2020-05-21 15:05:19 +02:00
} elseif ( $line -> sens == 'C' ) {
2019-11-14 12:09:15 +01:00
print '' . $separator ;
2021-02-26 19:18:03 +01:00
print price ( $line -> credit ) . $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' );
2020-11-09 19:47:25 +01: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 $line -> piece_num . $separator ;
print $line -> doc_ref . $separator ;
print price ( $line -> debit ) . $separator ;
print price ( $line -> credit ) . $separator ;
print 'E' . $separator ;
2020-11-09 19:47:25 +01:00
print length_accounta ( $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
}
/**
2021-07-28 12:02:45 +02:00
* Export format : CIEL ( Format XIMPORT )
* Format since 2003 compatible CIEL version > 2002 / Sage50
2021-09-13 14:08:41 +02:00
* Last review for this format : 2021 - 09 - 13 Alexandre Spangaro ( aspangaro @ open - dsi . fr )
2021-07-28 12:02:45 +02:00
*
* Help : https :// sage50c . online - help . sage . fr / aide - technique /
* In sage software | Use menu : " Exchange " > " Importing entries... "
*
* If you want to force filename to " XIMPORT.TXT " for automatically import file present in a directory :
* use constant ACCOUNTING_EXPORT_XIMPORT_FORCE_FILENAME
2016-03-15 08:58:53 +01:00
*
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 )
{
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 ;
2021-07-28 12:02:45 +02:00
2019-02-02 18:25:01 +01:00
foreach ( $TData as $data ) {
2021-07-28 12:02:45 +02:00
$code_compta = length_accountg ( $data -> numero_compte );
2021-02-22 21:36:42 +01:00
if ( ! empty ( $data -> subledger_account )) {
2021-08-02 19:03:38 +02:00
$code_compta = length_accounta ( $data -> subledger_account );
2021-02-22 21:36:42 +01:00
}
2016-03-15 08:58:53 +01:00
2021-07-28 16:46:57 +02:00
$date_document = dol_print_date ( $data -> doc_date , '%Y%m%d' );
$date_echeance = dol_print_date ( $data -> date_lim_reglement , '%Y%m%d' );
2016-03-15 08:58:53 +01:00
2019-11-14 12:09:15 +01:00
$Tab = array ();
2021-07-28 12:02:45 +02:00
$Tab [ 'num_ecriture' ] = str_pad ( $data -> piece_num , 5 );
2021-09-13 14:08:41 +02:00
$Tab [ 'code_journal' ] = str_pad ( self :: trunc ( $data -> code_journal , 2 ), 2 );
2021-07-28 16:46:57 +02:00
$Tab [ 'date_ecriture' ] = str_pad ( $date_document , 8 , ' ' , STR_PAD_LEFT );
$Tab [ 'date_echeance' ] = str_pad ( $date_echeance , 8 , ' ' , STR_PAD_LEFT );
2021-07-28 12:02:45 +02:00
$Tab [ 'num_piece' ] = str_pad ( self :: trunc ( $data -> doc_ref , 12 ), 12 );
2016-03-15 08:58:53 +01:00
$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 );
2021-08-02 18:31:26 +02:00
$Tab [ 'montant' ] = str_pad ( price2fec ( abs ( $data -> debit - $data -> credit )), 13 , ' ' , STR_PAD_LEFT );
2016-03-15 08:58:53 +01:00
$Tab [ 'type_montant' ] = str_pad ( $data -> sens , 1 );
2021-09-13 14:08:41 +02:00
$Tab [ 'vide' ] = str_repeat ( ' ' , 18 ); // Analytical accounting - Not managed in Dolibarr
2017-11-19 19:42:16 +01:00
$Tab [ 'intitule_compte' ] = str_pad ( self :: trunc ( dol_string_unaccent ( $data -> label_operation ), 34 ), 34 );
2021-09-13 14:08:41 +02:00
$Tab [ 'end' ] = 'O2003' ; // 0 = EUR | 2003 = Format Ciel
2016-03-15 08:58:53 +01:00
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
}
}
/**
2021-09-13 21:12:39 +02:00
* Export format : Quadratus ( Format ASCII )
* Format since 2015 compatible QuadraCOMPTA
2023-01-28 04:48:55 +01:00
* Last review for this format : 2023 / 01 / 28 Alexandre Spangaro ( aspangaro @ open - dsi . fr )
2021-09-13 21:12:39 +02:00
*
* Help : https :// docplayer . fr / 20769649 - Fichier - d - entree - ascii - dans - quadracompta . html
* In QuadraCompta | Use menu : " Outils " > " Suivi des dossiers " > " Import ASCII(Compta) "
2016-03-15 08:58:53 +01:00
*
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 )
{
2021-09-13 21:12:39 +02:00
global $conf , $db ;
2016-03-15 08:58:53 +01:00
2019-11-14 12:09:15 +01:00
$end_line = " \r \n " ;
2016-08-10 17:22:58 +02:00
2020-12-16 05:03:37 +01:00
// 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
2019-02-02 18:25:01 +01:00
foreach ( $TData as $data ) {
2023-01-28 04:48:55 +01:00
// Clean some data
$data -> doc_ref = dol_string_unaccent ( $data -> doc_ref );
$data -> label_operation = dol_string_unaccent ( $data -> label_operation );
$data -> numero_compte = dol_string_unaccent ( $data -> numero_compte );
$data -> label_compte = dol_string_unaccent ( $data -> label_compte );
$data -> subledger_account = dol_string_unaccent ( $data -> subledger_account );
$data -> subledger_label = dol_string_unaccent ( $data -> subledger_label );
2016-03-15 08:58:53 +01:00
$code_compta = $data -> numero_compte ;
2021-02-22 21:36:42 +01:00
if ( ! empty ( $data -> subledger_account )) {
2017-06-15 19:29:00 +02:00
$code_compta = $data -> subledger_account ;
2021-02-22 21:36:42 +01:00
}
2016-03-15 08:58:53 +01:00
2021-09-13 21:12:39 +02:00
$Tab = array ();
2021-09-13 21:21:53 +02:00
if ( ! empty ( $data -> subledger_account )) {
2021-09-13 21:12:39 +02:00
$Tab [ 'type_ligne' ] = 'C' ;
$Tab [ 'num_compte' ] = str_pad ( self :: trunc ( $data -> subledger_account , 8 ), 8 );
$Tab [ 'lib_compte' ] = str_pad ( self :: trunc ( $data -> subledger_label , 30 ), 30 );
if ( $data -> doc_type == 'customer_invoice' ) {
2021-09-13 21:29:31 +02:00
$Tab [ 'lib_alpha' ] = strtoupper ( str_pad ( 'C' . self :: trunc ( $data -> subledger_label , 6 ), 6 ));
$Tab [ 'filler' ] = str_repeat ( ' ' , 52 );
2021-09-13 21:12:39 +02:00
$Tab [ 'coll_compte' ] = str_pad ( self :: trunc ( $conf -> global -> ACCOUNTING_ACCOUNT_CUSTOMER , 8 ), 8 );
} elseif ( $data -> doc_type == 'supplier_invoice' ) {
2021-09-13 21:29:31 +02:00
$Tab [ 'lib_alpha' ] = strtoupper ( str_pad ( 'F' . self :: trunc ( $data -> subledger_label , 6 ), 6 ));
$Tab [ 'filler' ] = str_repeat ( ' ' , 52 );
2021-09-13 21:12:39 +02:00
$Tab [ 'coll_compte' ] = str_pad ( self :: trunc ( $conf -> global -> ACCOUNTING_ACCOUNT_SUPPLIER , 8 ), 8 );
} else {
2021-09-13 21:29:31 +02:00
$Tab [ 'filler' ] = str_repeat ( ' ' , 59 );
2021-09-13 21:12:39 +02:00
$Tab [ 'coll_compte' ] = str_pad ( ' ' , 8 );
}
$Tab [ 'filler2' ] = str_repeat ( ' ' , 110 );
2021-09-13 21:29:31 +02:00
$Tab [ 'Maj' ] = 2 ; // Partial update (alpha key, label, address, collectif, RIB)
2021-09-13 21:12:39 +02:00
if ( $data -> doc_type == 'customer_invoice' ) {
$Tab [ 'type_compte' ] = 'C' ;
} elseif ( $data -> doc_type == 'supplier_invoice' ) {
2023-01-28 04:48:55 +01:00
$Tab [ 'type_compte' ] = 'F' ;
2021-09-13 21:12:39 +02:00
} else {
2023-01-28 04:48:55 +01:00
$Tab [ 'type_compte' ] = 'G' ;
2021-09-13 21:12:39 +02:00
}
$Tab [ 'filler3' ] = str_repeat ( ' ' , 235 );
$Tab [ 'end_line' ] = $end_line ;
print implode ( $Tab );
}
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
2020-12-16 05:03:37 +01: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' ] = ' ' ;
2023-01-28 04:48:55 +01:00
$Tab [ 'libelle_ecriture' ] = str_pad ( self :: trunc ( $data -> doc_ref . ' ' . $data -> label_operation , 20 ), 20 );
2017-11-19 19:42:16 +01:00
2020-12-16 05:03:37 +01:00
// Credit invoice - invert sens
2021-02-26 19:18:03 +01:00
/*
2021-03-01 00:19:52 +01:00
if ( $data -> montant < 0 ) {
if ( $data -> sens == 'C' ) {
$Tab [ 'sens' ] = 'D' ;
} else {
$Tab [ 'sens' ] = 'C' ;
}
$Tab [ 'signe_montant' ] = '-' ;
} else {
$Tab [ 'sens' ] = $data -> sens ; // C or D
$Tab [ 'signe_montant' ] = '+' ;
} */
2021-02-26 19:18:03 +01:00
$Tab [ 'sens' ] = $data -> sens ; // C or D
$Tab [ 'signe_montant' ] = '+' ;
2020-12-16 05:03:37 +01:00
// The amount must be in centimes without decimal points.
2021-04-20 13:56:58 +02:00
$Tab [ 'montant' ] = str_pad ( abs (( $data -> debit - $data -> credit ) * 100 ), 12 , '0' , STR_PAD_LEFT );
2016-03-15 08:58:53 +01:00
$Tab [ 'contrepartie' ] = str_repeat ( ' ' , 8 );
2017-11-19 19:42:16 +01:00
2020-12-16 05:03:37 +01:00
// Force date format : %d%m%y
2021-06-04 11:04:18 +02:00
if ( ! empty ( $data -> date_lim_reglement )) {
//$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab [ 'date_echeance' ] = dol_print_date ( $data -> date_lim_reglement , '%d%m%y' ); // 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
2020-12-16 05:03:37 +01:00
// Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
// $Tab['lettrage'] = str_repeat(' ', 5);
2017-11-19 19:42:16 +01:00
$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
2020-12-16 05:03:37 +01:00
// Keep correct quadra named field instead of anon filler
// $Tab['filler2'] = str_repeat(' ', 20);
2017-11-19 19:42:16 +01:00
$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
2020-12-16 05:03:37 +01:00
// 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
2023-01-28 04:48:55 +01:00
//$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 30), 30);
$Tab [ 'libelle_ecriture2' ] = str_pad ( self :: trunc ( $data -> label_operation , 30 ), 30 );
2017-11-19 19:42:16 +01:00
$Tab [ 'codetva' ] = str_repeat ( ' ' , 2 );
2020-12-16 05:03:37 +01:00
// We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part
// $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
2017-11-19 19:42:16 +01:00
$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
2022-11-01 07:56:24 +01:00
* Last review for this format : 2022 - 11 - 01 Alexandre Spangaro ( aspangaro @ open - dsi . fr )
2020-05-08 13:53:11 +02:00
*
2022-10-28 08:10:39 +02:00
* Help : https :// wiki . gestan . fr / lib / exe / fetch . php ? media = wiki : v15 : compta : accountancy - format_winfic - ewinfic - winsiscompta . pdf
2020-05-08 13:50:26 +02:00
*
* @ param array $TData data
2022-10-28 08:10:39 +02:00
*
2020-05-08 13:50:26 +02:00
* @ return void
*/
public function exportWinfic ( & $TData )
{
global $conf ;
$end_line = " \r \n " ;
2022-11-01 07:56:24 +01:00
$index = 1 ;
2020-05-08 13:50:26 +02:00
//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
2022-11-01 07:56:24 +01:00
// Warning ! When truncation is necessary, no dot because 3 dots = three characters. The columns are shifted
2020-05-08 13:50:26 +02:00
foreach ( $TData as $data ) {
$code_compta = $data -> numero_compte ;
2021-02-22 21:36:42 +01:00
if ( ! empty ( $data -> subledger_account )) {
2020-05-08 13:50:26 +02:00
$code_compta = $data -> subledger_account ;
2021-02-22 21:36:42 +01:00
}
2020-05-08 13:50:26 +02:00
$Tab = array ();
//$Tab['type_ligne'] = 'M';
2022-11-01 08:00:37 +01:00
$Tab [ 'code_journal' ] = str_pad ( dol_trunc ( $data -> code_journal , 2 , 'right' , 'UTF-8' , 1 ), 2 );
2020-05-08 13:50:26 +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 ?
//$Tab['date_ecriture'] = $date_ecriture;
$Tab [ 'date_operation' ] = dol_print_date ( $data -> doc_date , '%d%m%Y' );
$Tab [ 'folio' ] = ' 1' ;
2022-11-01 08:00:37 +01:00
$Tab [ 'num_ecriture' ] = str_pad ( dol_trunc ( $index , 6 , 'right' , 'UTF-8' , 1 ), 6 , ' ' , STR_PAD_LEFT );
2020-05-08 13:50:26 +02:00
$Tab [ 'jour_ecriture' ] = dol_print_date ( $data -> doc_date , '%d%m%y' );
2022-11-01 07:56:24 +01:00
$Tab [ 'num_compte' ] = str_pad ( dol_trunc ( $code_compta , 6 , 'right' , 'UTF-8' , 1 ), 6 , '0' );
2020-05-08 13:50:26 +02:00
2020-05-21 00:02:33 +02:00
if ( $data -> sens == 'D' ) {
2021-02-26 19:18:03 +01:00
$Tab [ 'montant_debit' ] = str_pad ( number_format ( $data -> debit , 2 , ',' , '' ), 13 , ' ' , STR_PAD_LEFT );
2020-05-08 13:50:26 +02:00
$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 );
2021-02-26 19:20:32 +01:00
$Tab [ 'montant_crebit' ] = str_pad ( number_format ( $data -> credit , 2 , ',' , '' ), 13 , ' ' , STR_PAD_LEFT );
2020-05-08 13:50:26 +02:00
}
2022-11-01 07:56:24 +01:00
$Tab [ 'libelle_ecriture' ] = str_pad ( dol_trunc ( dol_string_unaccent ( $data -> doc_ref ) . ' ' . dol_string_unaccent ( $data -> label_operation ), 30 , 'right' , 'UTF-8' , 1 ), 30 );
2020-05-08 13:50:26 +02:00
2022-11-01 08:00:37 +01:00
$Tab [ 'lettrage' ] = str_repeat ( dol_trunc ( $data -> lettering_code , 2 , 'left' , 'UTF-8' , 1 ), 2 );
2020-05-08 13:50:26 +02:00
2022-11-01 08:00:37 +01:00
$Tab [ 'code_piece' ] = str_pad ( dol_trunc ( $data -> piece_num , 5 , 'left' , 'UTF-8' , 1 ), 5 , ' ' , STR_PAD_LEFT );
2020-05-08 13:50:26 +02:00
$Tab [ 'code_stat' ] = str_repeat ( ' ' , 4 );
2021-06-04 11:04:18 +02:00
if ( ! empty ( $data -> date_lim_reglement )) {
//$Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, $conf->global->ACCOUNTING_EXPORT_DATE);
2021-05-26 15:01:31 +02:00
$Tab [ 'date_echeance' ] = dol_print_date ( $data -> date_lim_reglement , '%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 );
2022-11-01 07:56:24 +01:00
$index ++ ;
2020-05-08 13:50:26 +02:00
}
}
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 )) {
2020-10-31 14:32:18 +01:00
print $line -> numero_compte . $separator ;
} else {
print $line -> subledger_account . $separator ;
}
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 ;
2021-02-26 19:18:03 +01:00
print price2num ( abs ( $line -> debit - $line -> credit )) . $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 ;
2021-02-26 19:18:03 +01:00
print price ( abs ( $line -> debit - $line -> credit )) . $separator ;
2019-11-14 12:09:15 +01:00
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
}
}
2020-10-31 14:32:18 +01: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' );
print $date . $separator ;
print $line -> code_journal . $separator ;
if ( empty ( $line -> subledger_account )) {
print length_accountg ( $line -> numero_compte ) . $separator ;
} else {
print length_accounta ( $line -> subledger_account ) . $separator ;
}
print $line -> doc_ref . $separator ;
print $line -> label_operation . $separator ;
print price ( $line -> debit ) . $separator ;
print price ( $line -> credit ) . $separator ;
print $end_line ;
}
}
2019-05-15 12:16:03 +02:00
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 );
2021-02-26 19:18:03 +01:00
$tab [] = price2num ( $line -> debit - $line -> credit );
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 )
{
2021-01-12 05:46:24 +01:00
global $langs ;
2018-10-14 06:16:14 +02:00
$separator = " \t " ;
2020-12-13 14:11:04 +01:00
$end_line = " \r \n " ;
2018-10-08 21:01:21 +02:00
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 ;
2020-12-28 04:12:23 +01:00
print " Idevise " . $separator ;
2021-10-11 22:00:59 +02:00
print " DateLimitReglmt " . $separator ;
2021-12-20 07:04:12 +01:00
print " NumFacture " ;
2018-10-14 06:16:14 +02:00
print $end_line ;
2019-02-02 18:25:01 +01:00
foreach ( $objectLines as $line ) {
2021-02-22 21:36:42 +01:00
if ( $line -> debit == 0 && $line -> credit == 0 ) {
2021-03-01 00:19:52 +01:00
//unset($array[$line]);
} else {
2021-02-22 21:36:42 +01:00
$date_creation = dol_print_date ( $line -> date_creation , '%Y%m%d' );
$date_document = dol_print_date ( $line -> doc_date , '%Y%m%d' );
$date_lettering = dol_print_date ( $line -> date_lettering , '%Y%m%d' );
2021-09-24 12:04:25 +02:00
$date_validation = dol_print_date ( $line -> date_validation , '%Y%m%d' );
2021-02-22 21:36:42 +01:00
$date_limit_payment = dol_print_date ( $line -> date_lim_reglement , '%Y%m%d' );
2018-10-08 21:01:21 +02:00
2021-11-07 18:54:59 +01:00
$refInvoice = '' ;
2021-10-11 22:00:59 +02:00
if ( $line -> doc_type == 'customer_invoice' ) {
// Customer invoice
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
2021-11-07 18:54:59 +01:00
$invoice = new Facture ( $this -> db );
2021-10-11 22:00:59 +02:00
$invoice -> fetch ( $line -> fk_doc );
$refInvoice = $invoice -> ref ;
} elseif ( $line -> doc_type == 'supplier_invoice' ) {
// Supplier invoice
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
2021-11-07 18:54:59 +01:00
$invoice = new FactureFournisseur ( $this -> db );
2021-10-11 22:00:59 +02:00
$invoice -> fetch ( $line -> fk_doc );
$refInvoice = $invoice -> ref_supplier ;
}
2020-12-07 23:53:09 +01:00
// FEC:JournalCode
2021-01-12 05:46:24 +01:00
print $line -> code_journal . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:JournalLib
2021-01-12 05:46:24 +01:00
print dol_string_unaccent ( $langs -> transnoentities ( $line -> journal_label )) . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:EcritureNum
2021-01-12 05:46:24 +01:00
print $line -> piece_num . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:EcritureDate
2021-01-12 05:46:24 +01:00
print $date_document . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:CompteNum
2021-01-12 05:46:24 +01:00
print $line -> numero_compte . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:CompteLib
2021-01-12 05:46:24 +01:00
print dol_string_unaccent ( $line -> label_compte ) . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:CompAuxNum
2021-01-12 05:46:24 +01:00
print $line -> subledger_account . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:CompAuxLib
2021-01-12 05:46:24 +01:00
print dol_string_unaccent ( $line -> subledger_label ) . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:PieceRef
2021-01-12 05:46:24 +01:00
print $line -> doc_ref . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:PieceDate
2021-01-12 05:46:24 +01:00
print dol_string_unaccent ( $date_creation ) . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:EcritureLib
2022-04-27 04:46:09 +02:00
// Clean label operation to prevent problem on export with tab separator & other character
$line -> label_operation = str_replace ( array ( " \t " , " \n " , " \r " ), " " , $line -> label_operation );
2021-01-12 05:46:24 +01:00
print dol_string_unaccent ( $line -> label_operation ) . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:Debit
2021-01-12 05:46:24 +01:00
print price2fec ( $line -> debit ) . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:Credit
2021-01-12 05:46:24 +01:00
print price2fec ( $line -> credit ) . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:EcritureLet
2021-01-12 05:46:24 +01:00
print $line -> lettering_code . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:DateLet
2021-01-12 05:46:24 +01:00
print $date_lettering . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:ValidDate
2021-01-12 05:46:24 +01:00
print $date_validation . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:Montantdevise
2021-01-12 05:46:24 +01:00
print $line -> multicurrency_amount . $separator ;
2018-10-08 21:01:21 +02:00
2020-12-07 23:53:09 +01:00
// FEC:Idevise
2021-12-20 07:04:12 +01:00
print $line -> multicurrency_code . $separator ;
2020-12-28 04:12:23 +01:00
// FEC_suppl:DateLimitReglmt
2021-12-20 07:04:12 +01:00
print $date_limit_payment . $separator ;
2018-10-08 21:01:21 +02:00
2021-10-11 22:00:59 +02:00
// FEC_suppl:NumFacture
2022-04-27 04:46:09 +02:00
// Clean ref invoice to prevent problem on export with tab separator & other character
$refInvoice = str_replace ( array ( " \t " , " \n " , " \r " ), " " , $refInvoice );
2021-12-20 07:04:12 +01:00
print dol_trunc ( self :: toAnsi ( $refInvoice ), 17 , 'right' , 'UTF-8' , 1 );
2021-10-11 22:00:59 +02:00
2020-12-07 23:53:09 +01:00
print $end_line ;
}
2018-10-08 21:01:21 +02:00
}
}
2016-05-16 16:37:07 +02:00
2020-12-16 05:16:08 +01:00
/**
* Export format : FEC2
*
* @ param array $objectLines data
* @ return void
*/
public function exportFEC2 ( $objectLines )
{
2021-01-12 05:46:24 +01:00
global $langs ;
2020-12-16 05:16:08 +01:00
$separator = " \t " ;
$end_line = " \r \n " ;
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 ;
2020-12-28 04:12:23 +01:00
print " Idevise " . $separator ;
2021-10-11 22:00:59 +02:00
print " DateLimitReglmt " . $separator ;
2021-12-20 07:04:12 +01:00
print " NumFacture " ;
2020-12-16 05:16:08 +01:00
print $end_line ;
foreach ( $objectLines as $line ) {
if ( $line -> debit == 0 && $line -> credit == 0 ) {
2021-02-26 19:18:03 +01:00
//unset($array[$line]);
2020-12-16 05:16:08 +01:00
} else {
$date_creation = dol_print_date ( $line -> date_creation , '%Y%m%d' );
$date_document = dol_print_date ( $line -> doc_date , '%Y%m%d' );
$date_lettering = dol_print_date ( $line -> date_lettering , '%Y%m%d' );
2021-09-24 12:04:25 +02:00
$date_validation = dol_print_date ( $line -> date_validation , '%Y%m%d' );
2020-12-28 04:12:23 +01:00
$date_limit_payment = dol_print_date ( $line -> date_lim_reglement , '%Y%m%d' );
2020-12-16 05:16:08 +01:00
2021-11-07 18:54:59 +01:00
$refInvoice = '' ;
2021-10-11 22:00:59 +02:00
if ( $line -> doc_type == 'customer_invoice' ) {
// Customer invoice
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
2021-11-07 18:54:59 +01:00
$invoice = new Facture ( $this -> db );
2021-10-11 22:00:59 +02:00
$invoice -> fetch ( $line -> fk_doc );
$refInvoice = $invoice -> ref ;
} elseif ( $line -> doc_type == 'supplier_invoice' ) {
// Supplier invoice
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
2021-11-07 18:54:59 +01:00
$invoice = new FactureFournisseur ( $this -> db );
2021-10-11 22:00:59 +02:00
$invoice -> fetch ( $line -> fk_doc );
$refInvoice = $invoice -> ref_supplier ;
}
2020-12-16 05:16:08 +01:00
// FEC:JournalCode
print $line -> code_journal . $separator ;
// FEC:JournalLib
2021-01-12 05:46:24 +01:00
print dol_string_unaccent ( $langs -> transnoentities ( $line -> journal_label )) . $separator ;
2020-12-16 05:16:08 +01:00
// FEC:EcritureNum
print $line -> piece_num . $separator ;
// FEC:EcritureDate
print $date_creation . $separator ;
// FEC:CompteNum
2020-12-28 04:12:23 +01:00
print length_accountg ( $line -> numero_compte ) . $separator ;
2020-12-16 05:16:08 +01:00
// FEC:CompteLib
print dol_string_unaccent ( $line -> label_compte ) . $separator ;
// FEC:CompAuxNum
2020-12-28 04:12:23 +01:00
print length_accounta ( $line -> subledger_account ) . $separator ;
2020-12-16 05:16:08 +01:00
// FEC:CompAuxLib
print dol_string_unaccent ( $line -> subledger_label ) . $separator ;
// FEC:PieceRef
print $line -> doc_ref . $separator ;
// FEC:PieceDate
print $date_document . $separator ;
// FEC:EcritureLib
2022-04-27 04:46:09 +02:00
// Clean label operation to prevent problem on export with tab separator & other character
$line -> label_operation = str_replace ( array ( " \t " , " \n " , " \r " ), " " , $line -> label_operation );
2020-12-16 05:16:08 +01:00
print dol_string_unaccent ( $line -> label_operation ) . $separator ;
// FEC:Debit
print price2fec ( $line -> debit ) . $separator ;
// FEC:Credit
print price2fec ( $line -> credit ) . $separator ;
// FEC:EcritureLet
print $line -> lettering_code . $separator ;
// FEC:DateLet
print $date_lettering . $separator ;
// FEC:ValidDate
print $date_validation . $separator ;
// FEC:Montantdevise
print $line -> multicurrency_amount . $separator ;
// FEC:Idevise
2020-12-28 04:12:23 +01:00
print $line -> multicurrency_code . $separator ;
// FEC_suppl:DateLimitReglmt
2021-12-20 07:04:12 +01:00
print $date_limit_payment . $separator ;
2020-12-16 05:16:08 +01:00
2021-10-11 22:00:59 +02:00
// FEC_suppl:NumFacture
2022-04-27 04:46:09 +02:00
// Clean ref invoice to prevent problem on export with tab separator & other character
$refInvoice = str_replace ( array ( " \t " , " \n " , " \r " ), " " , $refInvoice );
2021-12-20 07:04:12 +01:00
print dol_trunc ( self :: toAnsi ( $refInvoice ), 17 , 'right' , 'UTF-8' , 1 );
2021-10-11 22:00:59 +02:00
2020-12-16 05:16:08 +01:00
print $end_line ;
}
}
}
2020-10-31 14:32:18 +01: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 )
{
// 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 ;
$thisPieceNum = " " ;
$thisPieceAccountNr = " " ;
$aSize = count ( $objectLines );
2021-02-22 21:36:42 +01:00
foreach ( $objectLines as $aIndex => $line ) {
2020-10-31 14:32:18 +01:00
$sammelBuchung = false ;
2021-02-22 21:36:42 +01:00
if ( $aIndex - 2 >= 0 && $objectLines [ $aIndex - 2 ] -> piece_num == $line -> piece_num ) {
2020-10-31 14:32:18 +01:00
$sammelBuchung = true ;
2021-02-22 21:36:42 +01:00
} elseif ( $aIndex + 2 < $aSize && $objectLines [ $aIndex + 2 ] -> piece_num == $line -> piece_num ) {
2020-10-31 14:32:18 +01:00
$sammelBuchung = true ;
} elseif ( $aIndex + 1 < $aSize
&& $objectLines [ $aIndex + 1 ] -> piece_num == $line -> piece_num
&& $aIndex - 1 < $aSize
&& $objectLines [ $aIndex - 1 ] -> piece_num == $line -> piece_num
2021-02-22 21:36:42 +01:00
) {
2020-10-31 14:32:18 +01:00
$sammelBuchung = true ;
}
//Blg
print $line -> piece_num . $this -> separator ;
// Datum
$date = dol_print_date ( $line -> doc_date , '%d.%m.%Y' );
print $date . $this -> separator ;
// Kto
print length_accountg ( $line -> numero_compte ) . $this -> separator ;
// S/H
2021-02-22 21:36:42 +01:00
if ( $line -> sens == 'D' ) {
2020-10-31 14:32:18 +01:00
print 'S' . $this -> separator ;
} else {
print 'H' . $this -> separator ;
}
//Grp
print self :: trunc ( $line -> code_journal , 1 ) . $this -> separator ;
// GKto
2021-02-22 21:36:42 +01:00
if ( empty ( $line -> code_tiers )) {
if ( $line -> piece_num == $thisPieceNum ) {
2020-10-31 14:32:18 +01:00
print length_accounta ( $thisPieceAccountNr ) . $this -> separator ;
} else {
print " div " . $this -> separator ;
}
} else {
print length_accounta ( $line -> code_tiers ) . $this -> separator ;
}
//SId
print $this -> separator ;
//SIdx
print " 0 " . $this -> separator ;
//KIdx
print " 0 " . $this -> separator ;
//BTyp
print " 0 " . $this -> separator ;
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
2021-02-22 21:36:42 +01:00
if ( $sammelBuchung ) {
2020-10-31 14:32:18 +01:00
print " 2 " . $this -> separator ;
} else {
print " 1 " . $this -> separator ;
}
// Code
print '""' . $this -> separator ;
// Netto
2021-02-26 19:18:03 +01:00
print abs ( $line -> debit - $line -> credit ) . $this -> separator ;
2020-10-31 14:32:18 +01:00
// Steuer
print " 0.00 " . $this -> separator ;
// FW-Betrag
print " 0.00 " . $this -> separator ;
// Tx1
$line1 = self :: toAnsi ( $line -> label_compte , 29 );
2021-02-22 21:36:42 +01:00
if ( $line1 == " LIQ " || $line1 == " LIQ Beleg ok " || strlen ( $line1 ) <= 3 ) {
2020-10-31 14:32:18 +01:00
$line1 = " " ;
}
$line2 = self :: toAnsi ( $line -> doc_ref , 29 );
2021-02-22 21:36:42 +01:00
if ( strlen ( $line1 ) == 0 ) {
2020-10-31 14:32:18 +01:00
$line1 = $line2 ;
$line2 = " " ;
}
2021-02-22 21:36:42 +01:00
if ( strlen ( $line1 ) > 0 && strlen ( $line2 ) > 0 && ( strlen ( $line1 ) + strlen ( $line2 )) < 27 ) {
2020-10-31 14:32:18 +01:00
$line1 = $line1 . ' / ' . $line2 ;
$line2 = " " ;
}
print '"' . self :: toAnsi ( $line1 ) . '"' . $this -> separator ;
// Tx2
print '"' . self :: toAnsi ( $line2 ) . '"' . $this -> separator ;
//PkKey
print " 0 " . $this -> separator ;
//OpId
print $this -> separator ;
// Flag
print " 0 " ;
print $this -> end_line ;
2021-02-22 21:36:42 +01:00
if ( $line -> piece_num !== $thisPieceNum ) {
2020-10-31 14:32:18 +01:00
$thisPieceNum = $line -> piece_num ;
$thisPieceAccountNr = $line -> numero_compte ;
}
}
}
/**
* Export format : LD Compta version 9
* http :// www . ldsysteme . fr / fileadmin / telechargement / np / ldcompta / Documentation / IntCptW9 . pdf
*
* @ 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' ) {
2021-02-26 19:18:03 +01:00
if (( $line -> debit - $line -> credit ) > 0 ) {
2019-10-09 16:33:57 +02:00
$nature_piece = 'AF' ;
} else {
$nature_piece = 'FF' ;
}
} elseif ( $line -> doc_type == 'customer_invoice' ) {
2021-02-26 19:18:03 +01:00
if (( $line -> debit - $line -> credit ) < 0 ) {
2019-10-09 16:33:57 +02:00
$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
2021-02-26 19:18:03 +01:00
print price ( abs ( $line -> debit - $line -> credit ), 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
2021-08-15 11:12:14 +02:00
* Last review for this format : 08 - 15 - 2021 Alexandre Spangaro ( aspangaro @ open - dsi . fr )
*
* Help : http :// www . ldsysteme . fr / fileadmin / telechargement / np / ldcompta / Documentation / IntCptW10 . pdf
2020-03-12 11:55:26 +01:00
*
* @ 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-09-19 20:11:04 +02:00
$sql = " SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM " . MAIN_DB_PREFIX . " societe " ;
$sql .= " WHERE code_client = ' " . $this -> db -> escape ( $line -> thirdparty_code ) . " ' " ;
2020-03-12 11:55:26 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-22 21:36:42 +01:00
if ( $resql && $this -> db -> num_rows ( $resql ) > 0 ) {
2020-03-12 11:55:26 +01:00
$soc = $this -> db -> fetch_object ( $resql );
2020-10-31 14:32:18 +01:00
$address = array ( '' , '' , '' );
if ( strpos ( $soc -> address , " \n " ) !== false ) {
$address = explode ( " \n " , $soc -> address );
if ( is_array ( $address ) && count ( $address ) > 0 ) {
2021-02-22 21:36:42 +01:00
foreach ( $address as $key => $data ) {
2020-10-31 14:32:18 +01:00
$address [ $key ] = str_replace ( array ( " \t " , " \n " , " \r " ), " " , $data );
$address [ $key ] = dol_trunc ( $address [ $key ], 40 , 'right' , 'UTF-8' , 1 );
}
}
} else {
$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-12 11:55:26 +01:00
$type_enregistrement = 'C' ;
2020-10-31 14:32:18 +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-10-31 14:32:18 +01:00
print $separator ;
2020-03-12 11:55:26 +01:00
//RSSO
print $soc -> nom . $separator ;
//CAD1
2020-10-31 14:32:18 +01:00
print $address [ 0 ] . $separator ;
2020-03-12 11:55:26 +01:00
//CAD2
2020-10-31 14:32:18 +01:00
print $address [ 1 ] . $separator ;
2020-03-12 11:55:26 +01:00
//CAD3
2020-10-31 14:32:18 +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-10-31 14:32:18 +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' ) {
2021-08-17 01:08:18 +02:00
if (( $line -> amount ) < 0 ) { // Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign.
2020-03-12 11:55:26 +01:00
$nature_piece = 'AF' ;
} else {
$nature_piece = 'FF' ;
}
} elseif ( $line -> doc_type == 'customer_invoice' ) {
2021-08-16 05:47:25 +02:00
if (( $line -> amount ) < 0 ) {
2021-08-17 01:08:18 +02:00
$nature_piece = 'AC' ; // Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign.
2020-03-12 11:55:26 +01:00
} 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
2021-02-26 19:18:03 +01:00
print price ( abs ( $line -> debit - $line -> credit ), 0 , '' , 1 , 2 ) . $separator ;
2020-03-12 11:55:26 +01:00
// 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
2021-02-22 21:36:42 +01:00
if ( ! empty ( $line -> subledger_account )) {
$account = $line -> subledger_account ;
} else {
2020-05-21 00:02:33 +02:00
$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
2022-04-27 04:46:09 +02:00
// Clean label operation to prevent problem on export with tab separator & other character
$line -> label_operation = str_replace ( array ( " \t " , " \n " , " \r " ), " " , $line -> label_operation );
2019-11-14 12:09:15 +01:00
print self :: trunc ( $line -> label_operation , 60 ) . $separator ; //Operation label
2021-02-26 19:18:03 +01:00
print price ( abs ( $line -> debit - $line -> credit )) . $separator ; //Amount
2019-11-14 12:09:15 +01:00
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 ;
}
}
2020-12-01 02:41:19 +01:00
/**
* Export format : Gestimum V3
*
* @ param array $objectLines data
*
* @ return void
*/
public function exportGestimumV3 ( $objectLines )
2020-10-27 16:20:34 +01:00
{
2020-12-01 02:41:19 +01:00
global $langs ;
$this -> separator = ',' ;
$invoices_infos = array ();
$supplier_invoices_infos = array ();
foreach ( $objectLines as $line ) {
2021-01-21 20:55:46 +01:00
if ( $line -> debit == 0 && $line -> credit == 0 ) {
2021-02-26 19:18:03 +01:00
//unset($array[$line]);
2021-01-21 20:55:46 +01:00
} else {
$date = dol_print_date ( $line -> doc_date , '%d/%m/%Y' );
$invoice_ref = $line -> doc_ref ;
$company_name = " " ;
if (( $line -> doc_type == 'customer_invoice' || $line -> doc_type == 'supplier_invoice' ) && $line -> fk_doc > 0 ) {
if (( $line -> doc_type == 'customer_invoice' && ! isset ( $invoices_infos [ $line -> fk_doc ])) ||
( $line -> doc_type == 'supplier_invoice' && ! isset ( $supplier_invoices_infos [ $line -> fk_doc ]))) {
if ( $line -> doc_type == 'customer_invoice' ) {
// Get new customer invoice ref and company name
$sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f' ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid' ;
2021-03-30 11:36:50 +02:00
$sql .= ' WHERE f.rowid = ' . (( int ) $line -> fk_doc );
2021-01-21 20:55:46 +01:00
$resql = $this -> db -> query ( $sql );
if ( $resql ) {
if ( $obj = $this -> db -> fetch_object ( $resql )) {
// Save invoice infos
$invoices_infos [ $line -> fk_doc ] = array ( 'ref' => $obj -> ref , 'company_name' => $obj -> nom );
$invoice_ref = $obj -> ref ;
$company_name = $obj -> nom ;
}
2020-12-01 02:41:19 +01:00
}
2021-01-21 20:55:46 +01:00
} else {
// Get new supplier invoice ref and company name
$sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff' ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid' ;
2021-03-30 11:36:50 +02:00
$sql .= ' WHERE ff.rowid = ' . (( int ) $line -> fk_doc );
2021-01-21 20:55:46 +01:00
$resql = $this -> db -> query ( $sql );
if ( $resql ) {
if ( $obj = $this -> db -> fetch_object ( $resql )) {
// Save invoice infos
$supplier_invoices_infos [ $line -> fk_doc ] = array ( 'ref' => $obj -> ref , 'company_name' => $obj -> nom );
$invoice_ref = $obj -> ref ;
$company_name = $obj -> nom ;
}
2020-12-01 02:41:19 +01:00
}
}
2021-01-21 20:55:46 +01:00
} elseif ( $line -> doc_type == 'customer_invoice' ) {
// Retrieve invoice infos
$invoice_ref = $invoices_infos [ $line -> fk_doc ][ 'ref' ];
$company_name = $invoices_infos [ $line -> fk_doc ][ 'company_name' ];
} else {
// Retrieve invoice infos
$invoice_ref = $supplier_invoices_infos [ $line -> fk_doc ][ 'ref' ];
$company_name = $supplier_invoices_infos [ $line -> fk_doc ][ 'company_name' ];
2020-12-01 02:41:19 +01:00
}
}
2021-01-21 20:55:46 +01:00
print $line -> id . $this -> separator ;
print $date . $this -> separator ;
print substr ( $line -> code_journal , 0 , 4 ) . $this -> separator ;
2020-12-01 02:41:19 +01:00
2021-01-21 20:55:46 +01:00
if (( substr ( $line -> numero_compte , 0 , 3 ) == '411' ) || ( substr ( $line -> numero_compte , 0 , 3 ) == '401' )) {
print length_accountg ( $line -> subledger_account ) . $this -> separator ;
} else {
print substr ( length_accountg ( $line -> numero_compte ), 0 , 15 ) . $this -> separator ;
}
//Libellé Auto
print $this -> separator ;
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
//Libellé manuel
print dol_trunc ( str_replace ( '"' , '' , $invoice_ref . ( ! empty ( $company_name ) ? ' - ' : '' ) . $company_name ), 40 , 'right' , 'UTF-8' , 1 ) . $this -> separator ;
//Numéro de pièce
print dol_trunc ( str_replace ( '"' , '' , $line -> piece_num ), 10 , 'right' , 'UTF-8' , 1 ) . $this -> separator ;
//Devise
print 'EUR' . $this -> separator ;
2021-02-26 19:18:03 +01:00
//Amount
print price2num ( abs ( $line -> debit - $line -> credit )) . $this -> separator ;
2021-01-21 20:55:46 +01:00
//Sens
print $line -> sens . $this -> separator ;
//Code lettrage
print $this -> separator ;
//Date Echéance
print $date ;
print $this -> end_line ;
2020-12-01 02:41:19 +01:00
}
}
}
/**
* Export format : Gestimum V5
*
* @ param array $objectLines data
*
* @ return void
*/
public function exportGestimumV5 ( $objectLines )
2020-10-27 16:20:34 +01:00
{
2020-10-27 16:13:07 +01:00
2020-12-01 02:41:19 +01:00
$this -> separator = ',' ;
foreach ( $objectLines as $line ) {
2021-01-21 20:55:46 +01:00
if ( $line -> debit == 0 && $line -> credit == 0 ) {
2021-02-26 19:18:03 +01:00
//unset($array[$line]);
2020-12-01 02:41:19 +01:00
} else {
2021-01-21 20:55:46 +01:00
$date = dol_print_date ( $line -> doc_date , '%d%m%Y' );
print $line -> id . $this -> separator ;
print $date . $this -> separator ;
print substr ( $line -> code_journal , 0 , 4 ) . $this -> separator ;
2021-02-26 19:18:03 +01:00
if (( substr ( $line -> numero_compte , 0 , 3 ) == '411' ) || ( substr ( $line -> numero_compte , 0 , 3 ) == '401' )) { // TODO No hard code value
2021-01-21 20:55:46 +01:00
print length_accountg ( $line -> subledger_account ) . $this -> separator ;
} else {
print substr ( length_accountg ( $line -> numero_compte ), 0 , 15 ) . $this -> separator ;
}
print $this -> separator ;
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
print '"' . dol_trunc ( str_replace ( '"' , '' , $line -> doc_ref ), 40 , 'right' , 'UTF-8' , 1 ) . '"' . $this -> separator ;
print '"' . dol_trunc ( str_replace ( '"' , '' , $line -> piece_num ), 10 , 'right' , 'UTF-8' , 1 ) . '"' . $this -> separator ;
2021-02-26 19:18:03 +01:00
print price2num ( abs ( $line -> debit - $line -> credit )) . $this -> separator ;
2021-01-21 20:55:46 +01:00
print $line -> sens . $this -> separator ;
print $date . $this -> separator ;
print $this -> separator ;
print $this -> separator ;
print 'EUR' ;
print $this -> end_line ;
2020-12-01 02:41:19 +01:00
}
}
}
2019-07-31 17:02:35 +02:00
2021-07-07 17:32:48 +02:00
/**
* Export format : iSuite Expert
*
2021-07-07 17:55:07 +02:00
* by OpenSolus [ https :// opensolus . fr ]
2021-07-07 17:32:48 +02:00
*
* @ param array $objectLines data
*
* @ return void
*/
public function exportiSuiteExpert ( $objectLines )
{
$this -> separator = ';' ;
2021-07-07 17:55:07 +02:00
$this -> end_line = " \r \n " ;
2021-07-07 17:32:48 +02:00
foreach ( $objectLines as $line ) {
$tab = array ();
$date = dol_print_date ( $line -> doc_date , '%d/%m/%Y' );
$tab [] = $line -> piece_num ;
$tab [] = $date ;
2021-07-07 17:55:07 +02:00
$tab [] = substr ( $date , 6 , 4 );
$tab [] = substr ( $date , 3 , 2 );
$tab [] = substr ( $date , 0 , 2 );
2021-07-07 17:32:48 +02:00
$tab [] = $line -> doc_ref ;
//Conversion de chaine UTF8 en Latin9
2021-07-07 17:55:07 +02:00
$tab [] = mb_convert_encoding ( str_replace ( ' - Compte auxiliaire' , '' , $line -> label_operation ), " Windows-1252 " , 'UTF-8' );
2021-07-07 17:32:48 +02:00
2021-07-07 17:53:10 +02:00
//Calcul de la longueur des numéros de comptes
$taille_numero = strlen ( length_accountg ( $line -> numero_compte ));
//Création du numéro de client générique
$numero_cpt_client = '411' ;
2021-07-07 17:55:07 +02:00
for ( $i = 1 ; $i <= ( $taille_numero - 3 ); $i ++ ) {
2021-07-07 17:53:10 +02:00
$numero_cpt_client .= '0' ;
}
2021-07-07 17:32:48 +02:00
//Création des comptes auxiliaire des clients
2021-07-07 17:55:07 +02:00
if ( length_accountg ( $line -> numero_compte ) == $numero_cpt_client ) {
$tab [] = rtrim ( length_accounta ( $line -> subledger_account ), " 0 " );
2021-07-07 17:32:48 +02:00
} else {
$tab [] = length_accountg ( $line -> numero_compte );
}
2021-07-07 17:55:07 +02:00
$nom_client = explode ( " - " , $line -> label_operation );
$tab [] = mb_convert_encoding ( $nom_client [ 0 ], " Windows-1252 " , 'UTF-8' );
2021-07-07 17:32:48 +02:00
$tab [] = price ( $line -> debit );
$tab [] = price ( $line -> credit );
$tab [] = price ( $line -> montant );
$tab [] = $line -> code_journal ;
$separator = $this -> separator ;
print implode ( $separator , $tab ) . $this -> 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
2020-10-31 14:32:18 +01:00
* @ 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 )
2020-10-31 14:32:18 +01:00
{
2019-11-14 12:09:15 +01:00
$retVal = dol_string_nohtmltag ( $str , 1 , 'Windows-1251' );
2021-02-22 21:36:42 +01:00
if ( $retVal >= 0 && $size >= 0 ) {
2020-10-31 14:32:18 +01:00
$retVal = mb_substr ( $retVal , 0 , $size , 'Windows-1251' );
}
return $retVal ;
2019-05-22 10:01:25 +02:00
}
2016-03-15 08:58:53 +01:00
}