12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418 |
- <?php
- /*
- * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
- * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
- * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
- * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
- * Copyright (C) 2016-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
- * Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
- * Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
- * Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
- * Copyright (C) 2017 André Schild <a.schild@aarboard.ch>
- *
- * 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
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/accountancy/class/accountancyexport.class.php
- * \ingroup Accountancy (Double entries)
- * \brief Class accountancy export
- */
- require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- /**
- * Manage the different format accountancy export
- */
- class AccountancyExport
- {
- // Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV
- public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
- 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;
- public static $EXPORT_TYPE_CHARLEMAGNE = 50;
- public static $EXPORT_TYPE_QUADRATUS = 60;
- public static $EXPORT_TYPE_OPENCONCERTO = 100;
- public static $EXPORT_TYPE_LDCOMPTA = 110;
- public static $EXPORT_TYPE_LDCOMPTA10 = 120;
- public static $EXPORT_TYPE_FEC = 1000;
- /**
- * @var string[] Error codes (or messages)
- */
- public $errors = array();
- /**
- *
- * @var string Separator
- */
- public $separator = '';
- /**
- *
- * @var string End of line
- */
- public $end_line = '';
- /**
- * Constructor
- *
- * @param DoliDb $db Database handler
- */
- public function __construct(DoliDB &$db)
- {
- global $conf;
- $this->db = &$db;
- $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
- $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n");
- }
- /**
- * Array with all export type available (key + label)
- *
- * @return array of type
- */
- public static function getType()
- {
- global $langs;
- $listofexporttypes = array(
- 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'),
- self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'),
- self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'),
- self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'),
- self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'),
- self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'),
- self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
- self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'),
- self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
- self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'),
- );
- ksort($listofexporttypes, SORT_NUMERIC);
- return $listofexporttypes;
- }
- /**
- * Return string to summarize the format (Used to generated export filename)
- *
- * @param int $type Format id
- * @return string Format code
- */
- public static function getFormatCode($type)
- {
- $formatcode = array(
- 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',
- self::$EXPORT_TYPE_EBP => 'ebp',
- self::$EXPORT_TYPE_COGILOG => 'cogilog',
- self::$EXPORT_TYPE_AGIRIS => 'agiris',
- self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto',
- self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
- self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
- self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10',
- self::$EXPORT_TYPE_FEC => 'fec',
- );
- return $formatcode[$type];
- }
- /**
- * Array with all export type available (key + label) and parameters for config
- *
- * @return array of type
- */
- public static function getTypeConfig()
- {
- global $conf, $langs;
- return array(
- 'param' => array(
- self::$EXPORT_TYPE_CONFIGURABLE => array(
- 'label' => $langs->trans('Modelcsv_configurable'),
- '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,
- ),
- 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',
- ),
- 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'),
- ),
- 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',
- ),
- self::$EXPORT_TYPE_LDCOMPTA => array(
- 'label' => $langs->trans('Modelcsv_LDCompta'),
- 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
- ),
- self::$EXPORT_TYPE_LDCOMPTA10 => array(
- 'label' => $langs->trans('Modelcsv_LDCompta10'),
- 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
- ),
- self::$EXPORT_TYPE_FEC => array(
- 'label' => $langs->trans('Modelcsv_FEC'),
- 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
- ),
- self::$EXPORT_TYPE_CHARLEMAGNE => array(
- 'label' => $langs->trans('Modelcsv_charlemagne'),
- 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
- ),
- ),
- 'cr'=> array(
- '1' => $langs->trans("Unix"),
- '2' => $langs->trans("Windows")
- ),
- 'format' => array(
- 'csv' => $langs->trans("csv"),
- 'txt' => $langs->trans("txt")
- ),
- );
- }
- /**
- * Function who chose which export to use with the default config, and make the export into a file
- *
- * @param array $TData Array with data
- * @param int $formatexportset Id of export format
- * @return void
- */
- public function export(&$TData, $formatexportset)
- {
- global $conf, $langs;
- global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
- // Define name of file to save
- $filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
- $type_export = 'general_ledger';
- global $db; // The tpl file use $db
- include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
- switch ($formatexportset) {
- case self::$EXPORT_TYPE_CONFIGURABLE :
- $this->exportConfigurable($TData);
- break;
- case self::$EXPORT_TYPE_CEGID :
- $this->exportCegid($TData);
- break;
- case self::$EXPORT_TYPE_COALA :
- $this->exportCoala($TData);
- break;
- case self::$EXPORT_TYPE_BOB50 :
- $this->exportBob50($TData);
- break;
- case self::$EXPORT_TYPE_CIEL :
- $this->exportCiel($TData);
- break;
- case self::$EXPORT_TYPE_QUADRATUS :
- $this->exportQuadratus($TData);
- break;
- case self::$EXPORT_TYPE_EBP :
- $this->exportEbp($TData);
- break;
- case self::$EXPORT_TYPE_COGILOG :
- $this->exportCogilog($TData);
- break;
- case self::$EXPORT_TYPE_AGIRIS :
- $this->exportAgiris($TData);
- break;
- case self::$EXPORT_TYPE_OPENCONCERTO :
- $this->exportOpenConcerto($TData);
- break;
- case self::$EXPORT_TYPE_SAGE50_SWISS :
- $this->exportSAGE50SWISS($TData);
- break;
- case self::$EXPORT_TYPE_LDCOMPTA :
- $this->exportLDCompta($TData);
- break;
- case self::$EXPORT_TYPE_LDCOMPTA10 :
- $this->exportLDCompta10($TData);
- break;
- case self::$EXPORT_TYPE_FEC :
- $this->exportFEC($TData);
- break;
- case self::$EXPORT_TYPE_CHARLEMAGNE :
- $this->exportCharlemagne($TData);
- break;
- default:
- $this->errors[] = $langs->trans('accountancy_error_modelnotfound');
- break;
- }
- }
- /**
- * Export format : CEGID
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportCegid($objectLines)
- {
- foreach ($objectLines as $line) {
- $date = dol_print_date($line->doc_date, '%d%m%Y');
- $separator = ";";
- $end_line = "\n";
- 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;
- print $line->doc_ref;
- print $end_line;
- }
- }
- /**
- * Export format : COGILOG
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportCogilog($objectLines)
- {
- foreach ($objectLines as $line) {
- $date = dol_print_date($line->doc_date, '%d%m%Y');
- $separator = ";";
- $end_line = "\n";
- 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;
- }elseif ($line->sens == 'C') {
- print ''.$separator;
- print price($line->montant).$separator;
- }
- print $line->doc_ref.$separator;
- print $line->label_operation.$separator;
- print $end_line;
- }
- }
- /**
- * Export format : COALA
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportCoala($objectLines)
- {
- // Coala export
- $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;
- 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;
- print $end_line;
- }
- }
- /**
- * Export format : BOB50
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportBob50($objectLines)
- {
- // Bob50
- $separator = ";";
- $end_line = "\n";
- foreach ($objectLines as $line) {
- print $line->piece_num.$separator;
- $date = dol_print_date($line->doc_date, '%d/%m/%Y');
- print $date.$separator;
- if (empty($line->subledger_account)) {
- print 'G'.$separator;
- print length_accounta($line->numero_compte).$separator;
- } else {
- if (substr($line->numero_compte, 0, 3) == '411') {
- print 'C'.$separator;
- }
- if (substr($line->numero_compte, 0, 3) == '401') {
- print 'F'.$separator;
- }
- print length_accountg($line->subledger_account).$separator;
- }
- print price($line->debit).$separator;
- print price($line->credit).$separator;
- print dol_trunc($line->label_operation, 32).$separator;
- print $end_line;
- }
- }
- /**
- * Export format : CIEL
- *
- * @param array $TData data
- * @return void
- */
- public function exportCiel(&$TData)
- {
- global $conf;
- $end_line = "\r\n";
- $i = 1;
- $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
- foreach ($TData as $data) {
- $code_compta = $data->numero_compte;
- if (!empty($data->subledger_account))
- $code_compta = $data->subledger_account;
- $Tab = array();
- $Tab['num_ecriture'] = str_pad($i, 5);
- $Tab['code_journal'] = str_pad($data->code_journal, 2);
- $Tab['date_ecriture'] = $date_ecriture;
- $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
- $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
- $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
- $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
- $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT);
- $Tab['type_montant'] = str_pad($data->sens, 1);
- $Tab['vide'] = str_repeat(' ', 18);
- $Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34);
- $Tab['end'] = 'O2003';
- $Tab['end_line'] = $end_line;
- print implode($Tab);
- $i++;
- }
- }
- /**
- * Export format : Quadratus
- *
- * @param array $TData data
- * @return void
- */
- public function exportQuadratus(&$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['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';
- //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_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
- $Tab['filler'] = ' ';
- $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
- $Tab['sens'] = $data->sens; // C or D
- $Tab['signe_montant'] = '+';
- //elarifr le montant doit etre en centimes sans point decimal !
- $Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
- // $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
- $Tab['contrepartie'] = str_repeat(' ', 8);
- // elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting
- if (!empty($data->date_echeance))
- //$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'); // elarifr: format must be ddmmyy
- else
- $Tab['date_echeance'] = '000000';
- //elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5)
- //$Tab['lettrage'] = str_repeat(' ', 5);
- $Tab['lettrage'] = str_repeat(' ', 2);
- $Tab['codestat'] = str_repeat(' ', 3);
- $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5);
- //elarifr keep correct quadra named field instead of anon filler
- //$Tab['filler2'] = str_repeat(' ', 20);
- $Tab['affaire'] = str_repeat(' ', 10);
- $Tab['quantity1'] = str_repeat(' ', 10);
- $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);
- //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
- //$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);
- //elarifr 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);
- $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10);
- $Tab['filler4'] = str_repeat(' ', 73);
- $Tab['end_line'] = $end_line;
- print implode($Tab);
- }
- }
- /**
- * Export format : EBP
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportEbp($objectLines)
- {
- $separator = ',';
- $end_line = "\n";
- foreach ($objectLines as $line) {
- $date = dol_print_date($line->doc_date, '%d%m%Y');
- print $line->id.$separator;
- print $date.$separator;
- print $line->code_journal.$separator;
- if (empty($line->subledger_account)) {
- print $line->numero_compte.$separator;
- } else {
- print $line->subledger_account.$separator;
- }
- //print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
- print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
- print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
- print price2num(abs($line->montant)).$separator;
- print $line->sens.$separator;
- print $date.$separator;
- //print 'EUR';
- print $end_line;
- }
- }
- /**
- * Export format : Agiris Isacompta
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportAgiris($objectLines)
- {
- $separator = ';';
- $end_line = "\n";
- foreach ($objectLines as $line) {
- $date = dol_print_date($line->doc_date, '%d%m%Y');
- print $line->piece_num.$separator;
- print self::toAnsi($line->label_operation).$separator;
- print $date.$separator;
- print self::toAnsi($line->label_operation).$separator;
- if (empty($line->subledger_account)) {
- print length_accountg($line->numero_compte).$separator;
- print self::toAnsi($line->label_compte).$separator;
- } else {
- print length_accounta($line->subledger_account).$separator;
- print self::toAnsi($line->subledger_label).$separator;
- }
- 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;
- print $line->code_journal;
- print $end_line;
- }
- }
- /**
- * 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;
- }
- }
- /**
- * Export format : Configurable CSV
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportConfigurable($objectLines)
- {
- global $conf;
- $separator = $this->separator;
- foreach ($objectLines as $line) {
- $tab = array();
- // export configurable
- $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
- $tab[] = $line->piece_num;
- $tab[] = $date;
- $tab[] = $line->doc_ref;
- $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation;
- $tab[] = length_accountg($line->numero_compte);
- $tab[] = length_accounta($line->subledger_account);
- $tab[] = price2num($line->debit);
- $tab[] = price2num($line->credit);
- $tab[] = price2num($line->montant);
- $tab[] = $line->code_journal;
- print implode($separator, $tab).$this->end_line;
- }
- }
- /**
- * Export format : FEC
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportFEC($objectLines)
- {
- $separator = "\t";
- $end_line = "\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;
- print "Idevise";
- print $end_line;
- foreach ($objectLines as $line) {
- $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');
- // FEC:JournalCode
- print $line->code_journal.$separator;
- // FEC:JournalLib
- print $line->journal_label.$separator;
- // FEC:EcritureNum
- print $line->piece_num.$separator;
- // FEC:EcritureDate
- print $date_creation.$separator;
- // FEC:CompteNum
- print $line->numero_compte.$separator;
- // FEC:CompteLib
- print $line->label_compte.$separator;
- // FEC:CompAuxNum
- print $line->subledger_account.$separator;
- // FEC:CompAuxLib
- print $line->subledger_label.$separator;
- // FEC:PieceRef
- print $line->doc_ref.$separator;
- // FEC:PieceDate
- print $date_doc.$separator;
- // FEC:EcritureLib
- print $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 $line->date_lettering.$separator;
- // FEC:ValidDate
- print $date_valid.$separator;
- // FEC:Montantdevise
- print $line->multicurrency_amount.$separator;
- // FEC:Idevise
- print $line->multicurrency_code;
- print $end_line;
- }
- }
- /**
- * 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);
- foreach ($objectLines as $aIndex=>$line)
- {
- $sammelBuchung = false;
- if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
- {
- $sammelBuchung = true;
- }
- elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
- {
- $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
- )
- {
- $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
- if ($line->sens == 'D')
- {
- print 'S'.$this->separator;
- }
- else
- {
- print 'H'.$this->separator;
- }
- //Grp
- print self::trunc($line->code_journal, 1).$this->separator;
- // GKto
- if (empty($line->code_tiers))
- {
- if ($line->piece_num == $thisPieceNum)
- {
- 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
- if ($sammelBuchung)
- {
- print "2".$this->separator;
- }
- else
- {
- print "1".$this->separator;
- }
- // Code
- print '""'.$this->separator;
- // Netto
- if ($line->montant >= 0)
- {
- print $line->montant.$this->separator;
- }
- else
- {
- print ($line->montant * -1).$this->separator;
- }
- // Steuer
- print "0.00".$this->separator;
- // FW-Betrag
- print "0.00".$this->separator;
- // Tx1
- $line1 = self::toAnsi($line->label_compte, 29);
- if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3)
- {
- $line1 = "";
- }
- $line2 = self::toAnsi($line->doc_ref, 29);
- if (strlen($line1) == 0)
- {
- $line1 = $line2;
- $line2 = "";
- }
- if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
- {
- $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;
- if ($line->piece_num !== $thisPieceNum)
- {
- $thisPieceNum = $line->piece_num;
- $thisPieceAccountNr = $line->numero_compte;
- }
- }
- }
- /**
- * Export format : LD Compta version 9 & higher
- * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf
- *
- * @param array $objectLines data
- *
- * @return void
- */
- public function exportLDCompta($objectLines)
- {
- $separator = ';';
- $end_line = "\r\n";
- foreach ($objectLines as $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
- $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
- print $line->label_operation.$separator;
- // 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
- // }
- print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
- // 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_creation.$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;
- }
- // SECT
- print $separator;
- // CTRE
- print $separator;
- // NORL
- print $separator;
- // DATV
- print $separator;
- // REFD
- print $line->doc_ref.$separator;
- // CODH
- print $separator;
- // NSEQ
- print $separator;
- // MTDV
- print '0'.$separator;
- // CODV
- print $separator;
- // TXDV
- print '0'.$separator;
- // 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;
- }
- }
- /**
- * 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
- if ($last_codeinvoice != $line->doc_ref) {
- //recherche societe en fonction de son code client
- $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."'";
- $resql = $this->db->query($sql);
- if ($resql && $this->db->num_rows($resql) > 0)
- {
- $soc = $this->db->fetch_object($resql);
- $address = array('', '', '');
- if (strpos($soc->address, "\n") !== false) {
- $address = explode("\n", $soc->address);
- 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);
- }
- }
- } 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);
- }
- $type_enregistrement = 'C';
- //TYPE
- print $type_enregistrement.$separator;
- //NOCL
- print $soc->code_client.$separator;
- //NMCM
- print $separator;
- //LIBI
- print $separator;
- //TITR
- print $separator;
- //RSSO
- print $soc->nom.$separator;
- //CAD1
- print $address[0].$separator;
- //CAD2
- print $address[1].$separator;
- //CAD3
- print $address[2].$separator;
- //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
- print str_replace(" ", "", $soc->siret).$separator;
- //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
- print dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1).$separator;
- // 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
- // }
- print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
- // 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;
- // MTDV
- print '0'.$separator;
- // CODV
- print $separator;
- // TXDV
- print '0'.$separator;
- // 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;
- }
- }
- /**
- * Export format : Charlemagne
- *
- * @param array $objectLines data
- * @return void
- */
- public function exportCharlemagne($objectLines)
- {
- global $langs;
- $langs->load('compta');
- $separator = "\t";
- $end_line = "\n";
- /*
- * Charlemagne export need header
- */
- 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;
- print $end_line;
- foreach ($objectLines as $line) {
- $date = dol_print_date($line->doc_date, '%Y%m%d');
- print $date.$separator; //Date
- print self::trunc($line->code_journal, 6).$separator; //Journal code
- if (!empty($line->subledger_account)) $account = $line->subledger_account;
- else $account = $line->numero_compte;
- 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
- print $end_line;
- }
- }
- /**
- * trunc
- *
- * @param string $str String
- * @param integer $size Data to trunc
- * @return string
- */
- public static function trunc($str, $size)
- {
- return dol_trunc($str, $size, 'right', 'UTF-8', 1);
- }
- /**
- * toAnsi
- *
- * @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
- */
- public static function toAnsi($str, $size = -1)
- {
- $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
- if ($retVal >= 0 && $size >= 0)
- {
- $retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
- }
- return $retVal;
- }
- }
|