├── config.php ├── .gitignore ├── img ├── gplv3.png ├── logo.png ├── ATM_logo.jpg ├── bankimport.png ├── object_bankimport.png ├── Dolibarr_Preferred_Partner_logo.png ├── object_module.svg └── logo.svg ├── script ├── create-maj-base.php └── interface.php ├── sample └── CA20131028_1154.csv ├── config.default.php ├── tpl ├── bankimport.end.tpl.php ├── bankimport.new.tpl.php └── bankimport.check.tpl.php ├── README.md ├── lib └── bankimport.lib.php ├── ChangeLog.md ├── admin ├── bankimport_about.php └── bankimport_setup.php ├── import.php ├── langs ├── en_US │ └── bankimport.lang ├── de_DE │ └── bankimport.lang ├── fr_FR │ └── bankimport.lang ├── ca_ES │ └── bankimport.lang └── es_ES │ └── bankimport.lang ├── class ├── techatm.class.php └── bankimport.class.php ├── core └── modules │ └── modBankImport.class.php ├── releve.php └── COPYING /config.php: -------------------------------------------------------------------------------- 1 | init_db_by_vars($PDOdb); 20 | -------------------------------------------------------------------------------- /sample/CA20131028_1154.csv: -------------------------------------------------------------------------------- 1 | date;label;debit;credit 2 | 22/10/2017;Carte xxxxxxxxxxx xxxxxxxxx 21/10 Commission;0,2; 3 | 22/10/2017;Carte xxxxxxxxxxx xxxxxxxxx 21/10 Remise Carte;;21,8 4 | 18/10/2017;Carte xxxxxxxxxxx xxxxxxxxx 17/10 Commission;0,2; 5 | 18/10/2017;Carte xxxxxxxxxxx xxxxxxxxx 17/10 Remise Carte;;21,8 6 | 14/10/2017;Orange Valence 002305 Prelevement;88,36; 7 | 11/10/2017;Hébergement Sa 999999 Prelevement;10,73; 8 | 02/10/2017;Regul Int Deb N°1399999999 Prelevement;0,1; 9 | 02/10/2017;Interets Debit N°1399999999 Frais;2,63; 10 | 07/10/2017;Facture 09/2013 N°13999999 Prelevement;45,13; 11 | 07/10/2017;Carte xxxxxxxxxxx xxxxxxxxx 06/10 Commission;0,22; 12 | 07/10/2017;Carte xxxxxxxxxxx xxxxxxxxx 06/10 Remise Carte;;24,8 13 | -------------------------------------------------------------------------------- /config.default.php: -------------------------------------------------------------------------------- 1 | trans('AbricotNotFound'). ' : Abricot'; 27 | exit; 28 | } 29 | -------------------------------------------------------------------------------- /tpl/bankimport.end.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
trans("BankAccount") ?>account->getNomUrl(1) ?>trans("DateStart") ?>dateStart, 'day') ?>trans("AccountStatement") ?>numReleve ?>
trans("BankImportFile") ?>file) ?>trans("DateEnd") ?>dateEnd, 'day') ?>trans("FileHasHeader") ?>hasHeader == 1 ? $langs->trans('Yes') : $langs->trans('No') ?>
19 |
20 |
21 | 22 | trans('StatementCreatedAndDataImported', $import->numReleve, $import->nbReconciled, $import->nbCreated) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | Bank import 3 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4 | 5 | A module for Dolibarr. Activate it in Home > Setup > Modules > Other modules > Multi-modules tools. 6 | Allow to import csv files from your bank and automatically seek for ... 7 | 8 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | Import banque 10 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | Module complémentaire Dolibarr. A activer dans Accueil > Configuration > Modules > Modules complémentaires > Outils multi-modules. 13 | Permet d'importer des fichiers csv provenant de la banque afin de réaliser automatiquement les rapprochements et de créer les écritures manquantes. 14 | 15 | -------------------------------------------------------------------------------- /lib/bankimport.lib.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file lib/bankimport.lib.php 21 | * \ingroup bankimport 22 | * \brief This file is an example module library 23 | * Put some comments here 24 | */ 25 | 26 | function bankimportAdminPrepareHead() 27 | { 28 | global $langs, $conf; 29 | 30 | $langs->load("bankimport@bankimport"); 31 | 32 | $h = 0; 33 | $head = array(); 34 | 35 | $head[$h][0] = dol_buildpath("/bankimport/admin/bankimport_setup.php", 1); 36 | $head[$h][1] = $langs->trans("Parameters"); 37 | $head[$h][2] = 'settings'; 38 | $h++; 39 | $head[$h][0] = dol_buildpath("/bankimport/admin/bankimport_about.php", 1); 40 | $head[$h][1] = $langs->trans("About"); 41 | $head[$h][2] = 'about'; 42 | $h++; 43 | 44 | // Show more tabs from modules 45 | // Entries must be declared in modules descriptor with line 46 | //$this->tabs = array( 47 | // 'entity:+tabname:Title:@bankimport:/bankimport/mypage.php?id=__ID__' 48 | //); // to add new tab 49 | //$this->tabs = array( 50 | // 'entity:-tabname:Title:@bankimport:/bankimport/mypage.php?id=__ID__' 51 | //); // to remove a tab 52 | complete_head_from_modules($conf, $langs, null, $head, $h, 'bankimport'); 53 | 54 | return $head; 55 | } 56 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | ## Unreleased 5 | 6 | ## Release 2.8 7 | - FIX : Compat V22 - *2025-10-02* - 2.8.3 8 | - FIX remove echoing select_comptes *2025-08-12* - 2.8.2 9 | - FIX : DA026669 Depends - *2025-06-26* - 2.8.1 10 | - NEW : add german langs - *17/06/2025* - 2.8.0 11 | 12 | ## Release 2.7 13 | - FIX : Compat v21 *07/01/2025* - 2.7.1 14 | - FIX : Compat v20 15 | Changed Dolibarr compatibility range to 16 min - 20 max - *04/08/2024* - 2.7.0 16 | 17 | ## Release 2.6 18 | - FIX : Ticket DA025234 - Fix undefined variable in conf.php - *11/07/2024* - 2.6.3 19 | - FIX : Ticket DA024988 - bankline date was convert twice - *24/05/2024* - 2.6.2 20 | - FIX : Update include path for main.inc.php in setup page - *19/04/2024* - 2.6.1 21 | - NEW : TechATM + Page About + logo + fix visu tpl - *07/12/2023* - 2.6.0 22 | - NEW : COMPATV19 - *07/12/2023* - 2.5.0 23 | 24 | ## Release 2.4 25 | 26 | - FIX : PHP8.2 transtypage *28/06/2023* - 2.4.1 27 | - NEW : Hooks *03/05/2023* - 2.4.0 28 | - FIX (contrib by mkdgs): regex for parsing CSV format options - *29/07/2022* - 2.3.1 29 | - NEW (contrib by caos30): Spanish translation - *29/07/2022* - 2.3.0 30 | 31 | ## Release 2.2 32 | 33 | - FIX: CompatibilityV17 - *12/01/2023* - 2.2.9 34 | - FIX: CompatibilityV16 - Change family - *30/06/2022* - 2.2.8 35 | - FIX : Import keep saving PRE on new paiement but user doesn't selected this paiement *24/01/2022* 2.2.7 36 | - FIX : V12 Compatibility card url for paiement *24/01/2022* 2.2.6 37 | - FIX : Compatibility V13 - newToken() replaces $_SESSION['newtoken'] and add token renewal - *17/12/2021* - 2.2.5 38 | - FIX : Uniformize module descriptor's editor, editor_url and family fields * 08/06/2021* - 2.2.4 39 | - FIX : V13 Compatibility societe_id / socid *10/05/2021* 2.2.3 40 | - FIX : V13 Compatibility No Token Renewal *10/05/2021* - 2.2.2 41 | - FIX : V13 Compatibility after num_paiement property changed to num_payment *03/03/2021* - 2.2.1 42 | 43 | ## Release 1.0 44 | 45 | - NEW : Automatic bank statement reconciliation *16/09/2013* - 1.0 46 | - NEW : Automatic bank transaction creation when missing *16/09/2013* - 1.0 47 | - NEW : Date format, file separator and file mapping can be defined in setup *16/09/2013* - 1.0 48 | 49 | -------------------------------------------------------------------------------- /admin/bankimport_about.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file admin/about.php 21 | * \ingroup bankimport 22 | * \brief This file is an example about page 23 | * Put some comments here 24 | */ 25 | 26 | // Load Dolibarr environment 27 | $res = 0; 28 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 29 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 30 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 31 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 32 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 33 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 34 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 35 | // Try main.inc.php using relative path 36 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 37 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 38 | if (!$res) die("Include of main fails"); 39 | 40 | // Libraries 41 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 42 | require_once '../lib/bankimport.lib.php'; 43 | 44 | // Translations 45 | $langs->load("bankimport@bankimport"); 46 | 47 | // Access control 48 | if (!$user->admin) accessforbidden(); 49 | 50 | // Parameters 51 | $action = GETPOST('action', 'aZ09'); 52 | $backtopage = GETPOST('backtopage', 'alpha'); 53 | 54 | 55 | /* 56 | * Actions 57 | */ 58 | 59 | // None 60 | 61 | 62 | /* 63 | * View 64 | */ 65 | $form = new Form($db); 66 | 67 | $page_name = "BankImportAbout"; 68 | llxHeader('', $langs->trans($page_name)); 69 | 70 | // Subheader 71 | $linkback = ''.$langs->trans("BackToModuleList").''; 72 | 73 | print load_fiche_titre($langs->trans($page_name), $linkback, 'tools'); 74 | 75 | // Configuration header 76 | $head = bankimportAdminPrepareHead(); 77 | print dol_get_fiche_head( 78 | $head, 79 | 'about', 80 | $langs->trans("Module104020Name"), 81 | 0, 82 | 'bankimport@bankimport' 83 | ); 84 | 85 | require_once __DIR__ . '/../class/techatm.class.php'; 86 | $techATM = new \bankimport\TechATM($db); 87 | 88 | require_once __DIR__ . '/../core/modules/modBankImport.class.php'; 89 | $moduleDescriptor = new modBankImport($db); 90 | 91 | print $techATM->getAboutPage($moduleDescriptor); 92 | 93 | llxFooter(); 94 | 95 | $db->close(); 96 | -------------------------------------------------------------------------------- /import.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2013 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | // Permet de gérer les fichier ayant une fin de ligne MAC (suite retour client) (http://stackoverflow.com/questions/4541749/fgetcsv-fails-to-read-line-ending-in-mac-formatted-csv-file-any-better-solution) 20 | 21 | require 'config.php'; 22 | require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; 23 | 24 | dol_include_once('/bankimport/class/bankimport.class.php'); 25 | dol_include_once('/compta/facture/class/facture.class.php'); 26 | 27 | global $db, $langs; 28 | 29 | $langs->load('bills'); 30 | $hookmanager = new HookManager($db); 31 | $hookmanager->initHooks('bankimport'); 32 | 33 | ini_set("auto_detect_line_endings", true); 34 | 35 | $mesg = ""; 36 | $form = new Form($db); 37 | $tpl = 'tpl/bankimport.new.tpl.php'; 38 | 39 | $import = new BankImport($db); 40 | 41 | if(GETPOST('compare','alphanohtml')) { 42 | $action = "compare"; 43 | $parameters = array("moduleName" => "bankimport"); 44 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $import, $action); 45 | if($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 46 | 47 | $datestart = dol_mktime(0, 0, 0, GETPOST('dsmonth','int'), GETPOST('dsday','int'), GETPOST('dsyear','int')); 48 | $dateend = dol_mktime(0, 0, 0, GETPOST('demonth','int'), GETPOST('deday','int'), GETPOST('deyear','int')); 49 | $numreleve = GETPOST('numreleve','alphanohtml'); 50 | $hasHeader = GETPOST('hasheader','alphanohtml'); 51 | 52 | if($import->analyse(GETPOST('accountid','int'), 'bankimportfile', $datestart, $dateend, $numreleve, $hasHeader)) { 53 | $import->load_transactions(GETPOST('bankimportseparator','alphanohtml'), GETPOST('bankimportdateformat','alphanohtml'), GETPOST('bankimportmapping','alphanohtml')); 54 | $import->compare_transactions(); 55 | 56 | $TTransactions = $import->TFile; 57 | 58 | global $bc; 59 | 60 | $langs->load('bankimport@bankimport'); 61 | $var = true; 62 | $tpl = 'tpl/bankimport.check.tpl.php'; 63 | } 64 | } else if(GETPOST('import','alphanohtml')) { 65 | 66 | if( 67 | $import->analyse( 68 | GETPOST('accountid','int'), 69 | GETPOST('filename','alpha'), 70 | GETPOST('datestart','int'), 71 | GETPOST('dateend','int'), 72 | GETPOST('numreleve','alphanohtml'), 73 | GETPOST('hasheader','alphanohtml') 74 | ) 75 | ) { 76 | $import->load_transactions(GETPOST('bankimportseparator','alpha'), GETPOST('bankimportdateformat','alphanohtml'), GETPOST('bankimportmapping','alphanohtml')); 77 | $import->import_data(GETPOST('TLine','array')); 78 | $tpl = 'tpl/bankimport.end.tpl.php'; 79 | } 80 | } 81 | 82 | llxHeader('', $langs->trans('TitleBankImport')); 83 | 84 | print_fiche_titre($langs->trans("TitleBankImport")); 85 | 86 | include($tpl); 87 | 88 | $action = "index"; 89 | $parameters = array("moduleName" => "bankimport", "tpl" => $tpl); 90 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $import, $action); 91 | if($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 92 | 93 | llxFooter(); 94 | $db->close(); 95 | -------------------------------------------------------------------------------- /tpl/bankimport.new.tpl.php: -------------------------------------------------------------------------------- 1 |
2 | trans("ImportBankFile"); ?> 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 35 | 36 | 41 | 42 | 43 | 44 |
select_comptes( ($import->account) ? $import->account->id : -1,'accountid',0,'courant <> 2',1) ?>select_date($import->dateStart, 'ds') ?>
select_date($import->dateEnd, 'de') ?> />
textwithpicto( 25 | '', 26 | $langs->trans("BankImportMappingHelp") 27 | ); ?> 28 | textwithpicto( 31 | '', 32 | $langs->trans("BankImportDateFormatHelp") 33 | ); ?> 34 | textwithpicto( 37 | '', 38 | $langs->trans("BankImportSeparatorHelp") 39 | ); ?> 40 |
45 |
46 | 47 |
48 | "> 49 |
50 |
51 |
52 | 75 | -------------------------------------------------------------------------------- /script/interface.php: -------------------------------------------------------------------------------- 1 | load('compta'); 30 | 31 | $r=''; 32 | 33 | if($type == 'facture') { 34 | 35 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture 36 | WHERE fk_statut IN ("; 37 | if(getDolGlobalString('BANKIMPORT_ALLOW_DRAFT_INVOICE')) $sql.= "0,"; 38 | $sql.= "1,3) AND fk_soc=".$fk_soc." 39 | AND paye = 0 40 | ORDER BY datef"; 41 | 42 | $res = $db->query($sql); 43 | 44 | while($obj = $db->fetch_object($res)) { 45 | 46 | $f=new Facture($db); 47 | $f->fetch($obj->rowid); 48 | 49 | $s = new Societe($db); 50 | $s->fetch($f->socid); 51 | 52 | $r.='
' 53 | .$f->getNomUrl(1).' ('.date('d/m/Y', $f->date).') '.$s->getNomUrl(1, '', 12).' '.price($f->total_ttc).'' 54 | .'' 55 | .img_picto($langs->trans('AddRemind'),'rightarrow.png', 'id="TLine[piece]['.$i.'][facture]['.$f->id.']" class="auto_price"') 56 | .'
'; 57 | 58 | 59 | } 60 | 61 | } 62 | else if($type == 'fournfacture') { 63 | 64 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_fourn 65 | WHERE fk_statut IN ("; 66 | if(getDolGlobalString('BANKIMPORT_ALLOW_DRAFT_INVOICE')) $sql.= "0,"; 67 | $sql.= "1) AND fk_soc=".$fk_soc." 68 | AND paye = 0 69 | ORDER BY datef"; 70 | 71 | $res = $db->query($sql); 72 | 73 | while($obj = $db->fetch_object($res)) { 74 | 75 | $f=new FactureFournisseur($db); 76 | $f->fetch($obj->rowid); 77 | 78 | $s = new Societe($db); 79 | $s->fetch($f->socid); 80 | 81 | $r.='
' 82 | .$f->getNomUrl(1).' ('.date('d/m/Y', $f->date).') '.$s->getNomUrl(1, '', 17).' '.price($f->total_ttc).'' 83 | .'' 84 | .img_picto($langs->trans('AddRemind'),'rightarrow.png', 'id="TLine[piece]['.$i.'][fournfacture]['.$f->id.']" class="auto_price"') 85 | .'
'; 86 | 87 | 88 | } 89 | } 90 | 91 | else if($type == 'charge') { 92 | 93 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."chargesociales 94 | WHERE paye=0 AND date_ech<=NOW() ORDER BY date_ech"; 95 | 96 | $res = $db->query($sql); 97 | 98 | while($obj = $db->fetch_object($res)) { 99 | 100 | $f=new ChargeSociales($db); 101 | $f->fetch($obj->rowid); 102 | 103 | $r.='
'. $f->getNomUrl(1).' '.$f->lib.' '.price($f->amount) .'
'; 104 | 105 | 106 | } 107 | } 108 | 109 | 110 | 111 | return $r; 112 | 113 | } 114 | -------------------------------------------------------------------------------- /langs/en_US/bankimport.lang: -------------------------------------------------------------------------------- 1 | Module104020Name = Bank import 2 | Module104020Desc = Allow importing bank statement CSV files for automatic reconciliation 3 | 4 | ATMAbout = This module has been developed by ATM Consulting
You can find the documentation on our wiki

For any question or feedback, contact us on support@atm-consulting.fr

For any commercial question, contact us on contact@atm-consulting.fr or at +33 9 77 19 50 70

Find our other modules on Dolistore 5 | 6 | BankImportSetup = Bank import module setup 7 | BankImportAbout = About bank import module 8 | 9 | # ADMIN 10 | BankImportSeparator = Data separator in CSV file 11 | BankImportMapping = CSV file mapping 12 | BankImportDateFormat = CSV file date format 13 | BankImportSeparatorHelp = Character used to separate your CSV file columns (Usually "," or ";". A single character). 14 | BankImportMappingHelp = Column correspondence in your CSV file. Codes "date", "label", "debit" and "credit" must be in this data mapping.
If your file contains only one column for the amount, use "amount" and possibly "direction=Debit token" (eg. "direction=DEBIT" or "direction=-") instead of "debit" and "credit".
If your file contains other columns, name them "null" in the correspondence. 15 | BankImportDateFormatHelp = Date format used in your CSV file (%%d is the day on two characters, %%m month on two characters and %%Y year on four characters). For example, the date 07/25/2013 matches the date format %%m/%%d/%%Y. 16 | UseMacCompatibility= 17 | bankImportUseHistory=Enable the import history with the file content (Carreful: a header line must be exists in you file) 18 | bankImportAllowInvoiceFromSeveralThird=Allow to pay / reconcile payments from different third parties 19 | bankImportAllowDraftInvoice=Allow to reconcile draft invoice payments (invoices will be validated and payments created) 20 | UseMacCompatibility=Enable Mac compatibility 21 | 22 | # MENU 23 | LeftMenuBankImport = Bank import 24 | 25 | # PAGE 26 | TitleBankImport = Bank import 27 | BankImportFile = File to import 28 | BankCompareTransactions = Compare transactions 29 | BankImport = Do automatic reconciliations and transactions creation 30 | FileTransactions = Bank transactions from CSV file 31 | DolibarrTransactions = Bank transactions from Dolibarr 32 | RelatedItem = Related element 33 | Action = Planned action 34 | DoAction = Validate 35 | StatementCreatedAndDataImported = Statement %s created with %s transactions reconciliated, including %s created 36 | FileHasHeader = File has a header line 37 | bankImport_selectCompanyPls=Select company 38 | bankImport_selectPaymentTypePls=select payment 39 | bankImportNoReccordFound=No reccord found 40 | 41 | bankImportFieldBankAccountRequired=Bank account required 42 | bankImportFieldNumReleveRequired=Account statement required 43 | bankImportFieldBankImportFileRequired=File required 44 | bankImportFieldCompanyRequired=Company required 45 | bankImportFieldPaymentRequired=Payment type required 46 | 47 | # DATA 48 | BankTransactionWillBeCreatedAndReconciled = Transaction will be created and reconciliated 49 | WillBeReconciledWithStatement = Transaction will be reconciliated with statement %s 50 | AlreadyReconciledWithStatement = Transaction already reconciliated with statement %s 51 | LineDoesNotMatchWithMapping = File line doesn't match mapping 52 | 53 | BankImport_FatalError_PaymentType_NotPossible=Error : type of payment [%s] is not possible 54 | 55 | bankimport_no_customer_selected_click_to_select_one=No thirdparty found, click here to choose one 56 | bankimport_customer_selected_click_to_select_another_one=%s (click here to choose another thirdparty)BankImportSetupPage = Configuring the bank import module 57 | BankImportAboutPage = About the bank import module 58 | bankImportUncheckAllLines = Uncheck all lines when displaying transactions from the 59 | bankImportAutoCreateDiscount = Automatically convert down payments into future reductions if fully settled 60 | bankImportMatchBanklinesByAmountAndLabel = Search for bank entry lines by amount AND name 61 | bankImportAllowFreelines = Authorize the creation of free bank entries (not linked to a settlement) 62 | PlannedAction = Planned action 63 | bankImportCretaFreeLine = Free banking entry 64 | SupplierInvoices = Supplier invoices 65 | ImportBankFile = Bank file import 66 | -------------------------------------------------------------------------------- /img/object_module.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 27 | 45 | Bank 47 | Created with Sketch. 49 | 54 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | Bank 77 | -------------------------------------------------------------------------------- /img/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 27 | 45 | Bank 47 | Created with Sketch. 49 | 54 | 59 | 60 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | Bank 88 | -------------------------------------------------------------------------------- /langs/de_DE/bankimport.lang: -------------------------------------------------------------------------------- 1 | Module104020Name = Bankimport 2 | Module104020Desc = Ermöglicht das Importieren von Bankkontoauszugs-CSV-Dateien zum automatischen Abgleich 3 | 4 | ATMAbout = Dieses Modul wurde von ATM Consulting entwickelt.
Sie finden die Dokumentation in unserem Wiki.

Für Fragen oder Feedback kontaktieren Sie uns unter support@atm-consulting.fr

Für kommerzielle Anfragen kontaktieren Sie uns unter contact@atm-consulting.fr oder unter +33 9 77 19 50 70

Entdecken Sie unsere weiteren Module auf Dolistore. 5 | 6 | BankImportSetup = Konfiguration des Bankimport-Moduls 7 | BankImportAbout = Über das Bankimport-Modul 8 | 9 | # ADMIN 10 | BankImportSeparator = Trennzeichen in der CSV-Datei 11 | BankImportMapping = CSV-Datei Spaltenzuorndung 12 | BankImportDateFormat = Datumsformat in der CSV-Datei 13 | BankImportSeparatorHelp = Zeichen, das zur Trennung der Spalten in der CSV-Datei verwendet wird (normalerweise "," oder ";". Nur ein einzelnes Zeichen). 14 | BankImportMappingHelp = Spaltenzuordnung in Ihrer CSV-Datei. Die Codes "date", "label", "debit" und "credit" müssen in dieser Zuordnung zwingend enthalten sein.
Wenn Ihre Datei nur eine Spalte für den Transaktionsbetrag enthält, verwenden Sie "amount" und gegebenenfalls, wenn Sie eine Richtungsspalte haben, "direction=Debit token" (z. B. "direction=DEBIT" oder "direction=-") anstelle von "debit" und "credit".
Wenn Ihre Datei weitere Spalten enthält, benennen Sie diese in der Zuordnung als "null". 15 | BankImportDateFormatHelp = Datumsformat, das in Ihrer CSV-Datei verwendet wird (%%d steht für den Tag mit zwei Zeichen, %%m für den Monat mit zwei Zeichen und %%Y steht für das Jahr mit vier Zeichen). Beispielsweise entspricht das Datum 07/25/2013 dem Datumsformat %%m/%%d/%%Y. 16 | bankImportUseHistory = Den Importverlauf mit dem Dateiinhalt aktivieren (Vorsicht: Die Datei muss eine Kopfzeile enthalten) 17 | bankImportAllowInvoiceFromSeveralThird = Abgleich/Zahlung von Rechnungen verschiedener Geschäftspartner erlauben 18 | bankImportAllowDraftInvoice = Abgleich mit Rechnungen im Entwurfsstatus erlauben (Rechnung validieren und Zahlung erstellen) 19 | UseMacCompatibility = Mac-Kompatibilität aktivieren 20 | 21 | 22 | # MENU 23 | LeftMenuBankImport = Bankimport 24 | 25 | # PAGE 26 | TitleBankImport = Bankimport 27 | BankImportFile = Datei zum Importieren 28 | BankCompareTransactions = Buchungen abgleichen 29 | BankImport = Automatischen Abgleich und Buchungserstellung durchführen 30 | FileTransactions = Banktransaktionen aus der CSV-Datei 31 | DolibarrTransactions = Banktransaktionen aus Dolibarr 32 | RelatedItem = Zugehöriges Element 33 | Action = Geplante Aktion 34 | DoAction = Bestätigen 35 | StatementCreatedAndDataImported = Kontoauszug %s erstellt mit %s abgeglichenen Buchungen, davon %s neu erstellt 36 | FileHasHeader = Datei enthält eine Kopfzeile 37 | bankImport_selectCompanyPls = Bitte wählen Sie ein Unternehmen aus 38 | bankImport_selectPaymentTypePls = Bitte wählen Sie eine Zahlungsmethode aus 39 | bankImportNoReccordFound = Kein Eintrag gefunden 40 | 41 | bankImportFieldBankAccountRequired = Bankkonto erforderlich 42 | bankImportFieldNumReleveRequired = Kontoauszug erforderlich 43 | bankImportFieldBankImportFileRequired = Datei erforderlich 44 | bankImportFieldCompanyRequired = Unternehmen erforderlich 45 | bankImportFieldPaymentRequired = Zahlungsart erforderlich 46 | 47 | # DATA 48 | BankTransactionWillBeCreatedAndReconciled = Buchung wird erstellt und mit dem Kontoauszug %s abgeglichen 49 | WillBeReconciledWithStatement = Buchung wird mit Kontoauszug %s abgeglichen 50 | AlreadyReconciledWithStatement = Buchung ist bereits mit Kontoauszug %s abgeglichen 51 | LineDoesNotMatchWithMapping = Zeile der Datei stimmt nicht mit der Zuorndung überein 52 | 53 | BankImport_FatalError_PaymentType_NotPossible = Fehler: Die Zahlungsart [%s] ist nicht möglich 54 | 55 | bankimport_no_customer_selected_click_to_select_one = Kein Geschäftspartner gefunden, klicken Sie hier, um einen auszuwählen 56 | bankimport_customer_selected_click_to_select_another_one = %s (klicken Sie hier, um einen anderen Geschäftspartner auszuwählen) 57 | BankImportSetupPage = Konfiguration des Bankimport-Moduls 58 | BankImportAboutPage = Über das Bankimport-Modul 59 | bankImportUncheckAllLines = Alle Zeilen deaktivieren, wenn Sie Transaktionen aus der Datei anzeigen 60 | bankImportAutoCreateDiscount = Anzahlungen automatisch in zukünftige Rabatte umwandeln, wenn vollständig beglichen 61 | bankImportMatchBanklinesByAmountAndLabel = Bankbuchungen anhand von Betrag UND Bezeichnung suchen 62 | bankImportAllowFreelines = Erstellen von freien Bankbuchungen erlauben (nicht mit einer Zahlung verknüpft) 63 | PlannedAction = Geplante Aktion 64 | bankImportCretaFreeLine = Freier Banking-Eintrag 65 | SupplierInvoices = Lieferantenrechnungen 66 | ImportBankFile = Import von Bankdateien -------------------------------------------------------------------------------- /langs/fr_FR/bankimport.lang: -------------------------------------------------------------------------------- 1 | Module104020Name = Import bancaire 2 | Module104020Desc = Permet d'importer des fichiers bancaire CSV pour rapprochement automatique 3 | 4 | ATMAbout = Ce module a été développé par ATM Consulting
Vous pouvez retrouver la documentation sur notre wiki

Pour toute question technique ou retour, contactez-nous sur support@atm-consulting.fr

Pour toute question commerciale, contactez-nous sur contact@atm-consulting.fr ou au +33 9 77 19 50 70

Retrouvez nos autres modules sur Dolistore 5 | 6 | BankImportSetupPage = Configuration du module d'import bancaire 7 | BankImportAboutPage = A propos du module d'import bancaire 8 | 9 | # ADMIN 10 | BankImportSeparator = Séparateur des données du fichier 11 | BankImportMapping = Mapping du fichier CSV 12 | BankImportDateFormat = Format de date du fichier CSV 13 | BankImportSeparatorHelp = Caractère utilisé pour séparer les colonnes de votre fichier CSV (habituellement ";" ou ",". Un seul caractère). 14 | BankImportMappingHelp = Correspondance des colonnes de votre fichier CSV. Attention, la correspondance doit forcément contenir les codes "date", "label", "debit" et "credit".
Si votre fichier ne contient qu'une seule colonne pour le montant de la transaction, utiliser "amount" et éventuellement, si vous avez une colonne sens, "direction=Mot clé pour débit" (par example "direction=DÉBIT" ou "direction=-") au lieu de "debit" et "credit".
Si votre fichier contient d'autres colonnes, nommez-les "null" dans la correspondance. 15 | BankImportDateFormatHelp = Format de date utilisé dans votre fichier CSV (d correspond au jour sur deux caractères, m au mois sur deux caractère et Y l'année sur 4 caractères). Par exemple la date 25/07/2013 correspond au format d/m/Y. 16 | UseMacCompatibility= 17 | bankImportUseHistory=Activer l'historisation des imports avec le contenu du fichier (Attention : une ligne d'en-tête doit être présent dans votre fichier) 18 | bankImportAllowInvoiceFromSeveralThird=Autoriser le règlement / rapprochement sur des factures appartenant à différents tiers 19 | bankImportAllowDraftInvoice=Autoriser le rapprochement sur des factures au statut brouillon (validation de la facture et création du règlement) 20 | bankImportUncheckAllLines=Décocher toutes les lignes lors de l'affichage des transactions provenant du fichier 21 | bankImportAutoCreateDiscount=Convertir automatiquement les acomptes en reduction future si totalement réglés 22 | bankImportMatchBanklinesByAmountAndLabel=Chercher les lignes d'écritures bancaires par montant ET par libellé 23 | bankImportAllowFreelines=Autoriser la création d'écritures bancaires libres (non liées à un règlement) 24 | UseMacCompatibility=Activer la compatibilité Mac 25 | 26 | # MENU 27 | LeftMenuBankImport = Import bancaire 28 | 29 | # PAGE 30 | TitleBankImport = Import bancaire 31 | BankImportFile = Fichier à importer 32 | BankCompareTransactions = Comparer les écritures 33 | BankImport = Procéder aux rapprochements automatiques et aux créations d'écritures 34 | FileTransactions = Transaction bancaires provenant du fichier 35 | DolibarrTransactions = Transaction bancaires existantes dans Dolibarr 36 | RelatedItem = Élément associé 37 | PlannedAction = Action prévue 38 | DoAction = Valider 39 | StatementCreatedAndDataImported = Relevé %s créé avec %s écritures rapprochées, dont %s créées 40 | FileHasHeader = Le fichier contient une ligne d'en-tête 41 | bankImport_selectCompanyPls=Sélectionnez une société 42 | bankImport_selectPaymentTypePls=Sélectionnez paiement 43 | bankImportNoReccordFound=Aucune information trouvée 44 | 45 | bankImportFieldBankAccountRequired=Compte bancaire obligatoire 46 | bankImportFieldNumReleveRequired=Numéro de relevé obligatoire 47 | bankImportFieldBankImportFileRequired=Fichier obligatoire 48 | bankImportFieldCompanyRequired=Société obligatoire 49 | bankImportFieldPaymentRequired=Type de règlement obligatoire 50 | bankImportCretaFreeLine=Ecriture bancaire libre 51 | 52 | # DATA 53 | BankTransactionWillBeCreatedAndReconciled = L'écriture sera créée et rapprochée sur le relevé %s 54 | WillBeReconciledWithStatement = L'écriture sera rapprochée sur le relevé %s 55 | AlreadyReconciledWithStatement = L'écriture est déjà rapprochée sur le relevé %s 56 | LineDoesNotMatchWithMapping = La ligne du fichier ne correspond pas à la correspondance déclarée 57 | 58 | BankImport_FatalError_PaymentType_NotPossible=Erreur : le type de paiement [%s] n'est pas possible 59 | 60 | SupplierInvoices=Factures fournisseur 61 | 62 | bankimport_no_customer_selected_click_to_select_one=Aucun tiers associé, cliquez ici pour un choisir un 63 | bankimport_customer_selected_click_to_select_another_one=%s (cliquez ici pour choisir un autre tiers) 64 | ImportBankFile = Import de fichier banqueBankImportSetup = Configuration du module d'importation bancaire 65 | BankImportAbout = A propos du module d'importation bancaire 66 | Action = Action prévue 67 | -------------------------------------------------------------------------------- /langs/ca_ES/bankimport.lang: -------------------------------------------------------------------------------- 1 | Module104020Name = Importació de moviments bancaris 2 | Module104020Desc = Permet importar moviments bancaris mitjançant fitxers CSV per a conciliació automàtica amb pagaments de factures de client i proveïdor 3 | 4 | ATMAbout = Aquest mòdul ha estat desenvolupat per ATM Consulting
Podeu trobar documentació en aquest portal wiki wiki

Per a preguntes o valoracions, contacteu-nos a support@atm-consulting.fr

Per a preguntes comercials, contacteu-nos a contact@atm-consulting.fr o al +33 9 77 19 50 70

Conegueu els nostres altres mòduls a Dolistore. 5 | 6 | BankImportSetup = Configuració del mòdul d'importació de moviments bancaris 7 | BankImportAbout = Quant al mòdul d'importació de moviments bancaris 8 | 9 | # ADMIN 10 | BankImportSeparator = Separador de dades al fitxer CSV 11 | BankImportMapping = Mapeig de columnes del fitxer CSV 12 | BankImportDateFormat = Format de les dates al fitxer CSV 13 | BankImportSeparatorHelp = Caràcter usat com a separador de columnes al fitxer CSV. (Habitualment "," o ";". Un sol caràcter) 14 | BankImportMappingHelp = Correspondència de cada columna al vostre fitxer CSV amb un "concepte bancari clau a Dolibarr" (emprant les següents paraules clau).

Els codis "date", "label", "debit" and "credit" han d'existir en aquest mapeig de columnes.

Si el vostre fitxer conté una única columna per a l'import, utilitzeu “amount” i possiblement "direction=Debit token" (eg. "direction=DEBIT" or "direction=-") en lloc de "debit" i "credit".

Si el vostre fitxer conté altres columnes, anomeneu-es “null” en aquest mapeig. 15 | BankImportDateFormatHelp = Format de les dates usat al seu fitxer CSV ("d" és el dia en dos caràcters, "m" mes en dos caràcters, "Y" any en quatre caràcters, "y" any en dos caràcters, etc... són formats per dates habituals de PHP).

Per exemple, la data 07/25/2013 es correspon amb el format de data "m/d/Y". 16 | 17 | bankImportUseHistory = Activar el registre d'importacions amb el contingut del fitxer (Advertiment: una línia de capçalera ha de ser present al vostre fitxer) 18 | bankImportAllowInvoiceFromSeveralThird = Autoritzar la liquidació/conciliació de factures pertanyents a diferents tercers 19 | bankImportAllowDraftInvoice = Autorizar la conciliación de facturas en estado de borrador (validación de la factura y creación del pago) 20 | bankImportUncheckAllLines = Desmarcar totes les línies en previsualitzar els moviments del fitxer (les línies no marcades no són importades) 21 | bankImportAutoCreateDiscount = Convertir automàticament les quotes (pagaments parcials) en una reducció futura si es paga del tot 22 | bankImportMatchBanklinesByAmountAndLabel = Buscar coincidències amb línies ja importades per suma **i** per descripció 23 | bankImportAllowFreelines = Autoritzar la creació d'entrades bancàries orfes (no vinculades a un pagament existent a Dolibarr) 24 | UseMacCompatibility = Activar la compatibilitat amb Mac 25 | 26 | # MENU 27 | LeftMenuBankImport = Importar mov. bancaris 28 | 29 | # PAGE 30 | TitleBankImport = Importació de moviments bancaris 31 | BankImportFile = Fitxer CSV a importar 32 | BankCompareTransactions = Previsualitzar i comparar els moviments 33 | BankImport = Importar els **moviments marcats** i gravar les conciliacions indicades 34 | FileTransactions = Moviments bancaris del fitxer CSV 35 | DolibarrTransactions = Moviments bancaris ja a Dolibarr 36 | RelatedItem = Element relacionat 37 | PlannedAction = Acció prevista 38 | DoAction = Validar 39 | StatementCreatedAndDataImported = Extracte %s importat amb: %s moviments conciliats, incloent %s creats 40 | FileHasHeader = El fitxer té una línia de capçalera 41 | bankImport_selectCompanyPls = Seleccioneu un tercer 42 | bankImport_selectPaymentTypePls = Seleccioneu un pagament/factura 43 | bankImportNoReccordFound = No s'ha trobat informació 44 | 45 | bankImportFieldBankAccountRequired = El compte bancari és obligatori 46 | bankImportFieldNumReleveRequired = El número d'extracte és obligatori 47 | bankImportFieldBankImportFileRequired = El fitxer és obligatori 48 | bankImportFieldCompanyRequired = El tercer és obligatori 49 | bankImportFieldPaymentRequired = El tipus de pagament és obligatori 50 | bankImportCretaFreeLine = Moviment orfe 51 | 52 | # DATA 53 | BankTransactionWillBeCreatedAndReconciled = El moviment serà importat i conciliat 54 | WillBeReconciledWithStatement = El moviment serà conciliat a l'extracte %s 55 | AlreadyReconciledWithStatement = El moviment ja va ser conciliat a l'extracte %s 56 | LineDoesNotMatchWithMapping = Línia de fitxer no compleix amb el mapeig de columnes 57 | 58 | BankImport_FatalError_PaymentType_NotPossible = Error: el tipus de pagament [%s] no és possible 59 | 60 | SupplierInvoices = Factura de proveïdor 61 | 62 | bankimport_no_customer_selected_click_to_select_one = No hi ha tercers associats, premeu aquí per triar un 63 | bankimport_customer_selected_click_to_select_another_one = %s (premeu aquí per triar un altre tercer) 64 | -------------------------------------------------------------------------------- /langs/es_ES/bankimport.lang: -------------------------------------------------------------------------------- 1 | Module104020Name = Importación de movimientos bancarios 2 | Module104020Desc = Permite importar movimientos bancarios mediante archivos CSV para conciliación automática con los pagos de facturas de cliente y proveedor 3 | 4 | ATMAbout = Este módulo ha sido desarrollado por ATM Consulting
Puede encontrar documentación en este portal wiki wiki

Para preguntas o valoraciones, contáctenos en support@atm-consulting.fr

Para preguntas comerciales, contáctenos en contact@atm-consulting.fr or en +33 9 77 19 50 70

Conozca nuestros otros módulos en Dolistore. 5 | 6 | BankImportSetup = Configuración del módulo de importación de movimientos bancarios 7 | BankImportAbout = Acerca del módulo de importación de movimientos bancarios 8 | 9 | # ADMIN 10 | BankImportSeparator = Separador de datos en el archivo CSV 11 | BankImportMapping = Mapeo de columnas del archivo CSV 12 | BankImportDateFormat = Formato de fecha del archivo CSV 13 | BankImportSeparatorHelp = Carácter usado como separador de columnas en el archivo CSV. (Habitualmente "," o ";". Un sólo carácter) 14 | BankImportMappingHelp = Correspondencia de cada columna en su archivo CSV con un "concepto bancario clave en Dolibarr" (usando las siguientes palabras clave).

Los códigos "date", "label", "debit" and "credit" deben existir en este mapeo de datos.

Si su archivo contiene una única columna para el importe, utilice “amount” y posiblemente "direction=Debit token" (eg. "direction=DEBIT" or "direction=-") en lugar de "debit" y "credit".

Si su archivo contiene otras columnas, nombrelas “null” en este mapeo. 15 | BankImportDateFormatHelp = Formato de fecha usado en su archivo CSV ("d" es el día en dos caracteres, "m" mes en dos caracteres, "Y" año en cuatro carácteres, "y" año en dos carácteres, etc... son formatos de fecha habituales de PHP).

Por ejemplo, la fecha 07/25/2013 se corresponde con el formato de fecha "m/d/Y". 16 | 17 | bankImportUseHistory = Activar el registro de importaciones con el contenido del archivo (Advertencia: una línea de encabezado debe estar presente en su archivo) 18 | bankImportAllowInvoiceFromSeveralThird = Autorizar la liquidación/conciliación de facturas pertenecientes a diferentes terceros 19 | bankImportAllowDraftInvoice = Autorizar la conciliación de facturas en estado de borrador (validación de la factura y creación del pago) 20 | bankImportUncheckAllLines = Desmarcar todas las líneas al previsualizar los movimientos del archivo (las líneas no marcadas no son importadas) 21 | bankImportAutoCreateDiscount = Convertir automáticamente las cuotas (pagos parciales) en una reducción futura si se paga por completo 22 | bankImportMatchBanklinesByAmountAndLabel = Buscar coincidencias con líneas ya importadas por monto **y** por descripción 23 | bankImportAllowFreelines = Autorizar la creación de entradas bancarias huérfanos (no vinculadas a un pago existente en Dolibarr) 24 | UseMacCompatibility = Activar la compatibilidad con Mac 25 | 26 | # MENU 27 | LeftMenuBankImport = Importar mov. bancarios 28 | 29 | # PAGE 30 | TitleBankImport = Importación de movimientos bancarios 31 | BankImportFile = Archivo CSV a importar 32 | BankCompareTransactions = Previsualizar y comparar los movimientos 33 | BankImport = Importar los **movimientos marcados** y grabar las conciliaciones indicadas 34 | FileTransactions = Movimientos bancarios del fichero CSV 35 | DolibarrTransactions = Movimientos bancarios ya en Dolibarr 36 | RelatedItem = Elemento relacionado 37 | PlannedAction = Acción prevista 38 | DoAction = Validar 39 | StatementCreatedAndDataImported = Extracto %s importado con: %s movimientos conciliados, incluyendo %s creados 40 | FileHasHeader = El archivo tiene una línea de cabecera 41 | bankImport_selectCompanyPls = Seleccine un tercero 42 | bankImport_selectPaymentTypePls = Seleccione un pago/factura 43 | bankImportNoReccordFound = No se ha encontrado información 44 | 45 | bankImportFieldBankAccountRequired = La cuenta bancaria es obligatoria 46 | bankImportFieldNumReleveRequired = El número de extracto es obligatorio 47 | bankImportFieldBankImportFileRequired = El archivo es obligatorio 48 | bankImportFieldCompanyRequired = El tercero es obligatorio 49 | bankImportFieldPaymentRequired = El tipo de pago es obligatorio 50 | bankImportCretaFreeLine = Movimiento huérfano 51 | 52 | # DATA 53 | BankTransactionWillBeCreatedAndReconciled = El movimiento va a ser importado y conciliado 54 | WillBeReconciledWithStatement = El movimiento va a ser conciliado en el extracto %s 55 | AlreadyReconciledWithStatement = El movimiento ya fue conciliado en el extracto %s 56 | LineDoesNotMatchWithMapping = Línea de archivo no cumple con el mapeo de columnas 57 | 58 | BankImport_FatalError_PaymentType_NotPossible = Error: el tipo de pago [%s] no es posible 59 | 60 | SupplierInvoices = Factura de proveedor 61 | 62 | bankimport_no_customer_selected_click_to_select_one = No hay terceros asociados, pulse aquí para elegir uno 63 | bankimport_customer_selected_click_to_select_another_one = %s (pulse aquí para elegir otro tercero) 64 | Action = Acción prevista 65 | BankImportAboutPage = Acerca del módulo de importación de bancos 66 | ImportBankFile = Importación de ficheros bancarios 67 | -------------------------------------------------------------------------------- /class/techatm.class.php: -------------------------------------------------------------------------------- 1 | db = $db; 66 | } 67 | 68 | /** 69 | * @param DolibarrModules $moduleDescriptor 70 | */ 71 | function getAboutPage($moduleDescriptor, $useCache = true){ 72 | global $langs; 73 | 74 | $url = self::ATM_TECH_URL.'/modules/modules-page-about.php'; 75 | $url.= '?module='.$moduleDescriptor->name; 76 | $url.= '&id='.$moduleDescriptor->numero; 77 | $url.= '&version='.$moduleDescriptor->version; 78 | $url.= '&langs='.$langs->defaultlang; 79 | $url.= '&callv='.self::CALL_VERSION; 80 | 81 | $cachePath = DOL_DATA_ROOT . "/modules-atm/temp/about_page"; 82 | $cacheFileName = dol_sanitizeFileName($moduleDescriptor->name.'_'.$langs->defaultlang).'.html'; 83 | $cacheFilePath = $cachePath.'/'.$cacheFileName; 84 | 85 | if($useCache && is_readable($cacheFilePath)){ 86 | $lastChange = filemtime($cacheFilePath); 87 | if($lastChange > time() - 86400){ 88 | $content = @file_get_contents($cacheFilePath); 89 | if($content !== false){ 90 | return $content; 91 | } 92 | } 93 | } 94 | 95 | $content = $this->getContents($url); 96 | 97 | if(!$content){ 98 | $content = ''; 99 | // About page goes here 100 | $content.= '
'; 101 | $content.= '
'.$langs->trans('ATMAbout').'
'; 102 | $content.= '
'; 103 | $content.= ''; 104 | $content.= '
'; 105 | } 106 | 107 | if($useCache){ 108 | if(!is_dir($cachePath)){ 109 | $res = dol_mkdir($cachePath, DOL_DATA_ROOT); 110 | }else{ 111 | $res = true; 112 | } 113 | 114 | if($res){ 115 | $comment = ''."\r\n"; 116 | 117 | file_put_contents( 118 | $cacheFilePath, 119 | $comment.$content 120 | ); 121 | } 122 | } 123 | 124 | return $content; 125 | } 126 | 127 | /** 128 | * @param string $moduleTechMane 129 | */ 130 | public static function getModuleDocUrl($moduleTechMane){ 131 | $url = self::ATM_TECH_URL.'/modules/doc-redirect.php'; 132 | $url.= '?module='.$moduleTechMane; 133 | return $url; 134 | } 135 | 136 | /** 137 | * @param DolibarrModules $moduleDescriptor 138 | */ 139 | public static function getLastModuleVersionUrl($moduleDescriptor){ 140 | $url = self::ATM_TECH_URL.'/modules/modules-last-version.php'; 141 | $url.= '?module='.$moduleDescriptor->name; 142 | $url.= '&number='.$moduleDescriptor->numero; 143 | $url.= '&version='.$moduleDescriptor->version; 144 | $url.= '&dolversion='.DOL_VERSION; 145 | $url.= '&callv='.self::CALL_VERSION; 146 | return $url; 147 | } 148 | 149 | 150 | /** 151 | * @param $url 152 | * @return false|object 153 | */ 154 | public function getJsonData($url){ 155 | $this->data = false; 156 | $res = @file_get_contents($url); 157 | $this->http_response_header = $http_response_header; 158 | $this->TResponseHeader = self::parseHeaders($http_response_header); 159 | if($res !== false){ 160 | $pos = strpos($res, '{'); 161 | if($pos > 0){ 162 | // cela signifie qu'il y a une erreur ou que la sortie n'est pas propre 163 | $res = substr($res, $pos); 164 | } 165 | 166 | $this->data = json_decode($res); 167 | } 168 | 169 | return $this->data; 170 | } 171 | 172 | /** 173 | * @param $url 174 | * @return false|string 175 | */ 176 | public function getContents($url){ 177 | $this->data = false; 178 | $res = @file_get_contents($url); 179 | $this->http_response_header = $http_response_header; 180 | $this->TResponseHeader = self::parseHeaders($http_response_header); 181 | if($res !== false){ 182 | $this->data = $res; 183 | } 184 | return $this->data; 185 | } 186 | 187 | public static function http_response_code_msg($code = NULL) 188 | { 189 | if ($code !== NULL) { 190 | 191 | switch ($code) { 192 | case 100: 193 | $text = 'Continue'; 194 | break; 195 | case 101: 196 | $text = 'Switching Protocols'; 197 | break; 198 | case 200: 199 | $text = 'OK'; 200 | break; 201 | case 201: 202 | $text = 'Created'; 203 | break; 204 | case 202: 205 | $text = 'Accepted'; 206 | break; 207 | case 203: 208 | $text = 'Non-Authoritative Information'; 209 | break; 210 | case 204: 211 | $text = 'No Content'; 212 | break; 213 | case 205: 214 | $text = 'Reset Content'; 215 | break; 216 | case 206: 217 | $text = 'Partial Content'; 218 | break; 219 | case 300: 220 | $text = 'Multiple Choices'; 221 | break; 222 | case 301: 223 | $text = 'Moved Permanently'; 224 | break; 225 | case 302: 226 | $text = 'Moved Temporarily'; 227 | break; 228 | case 303: 229 | $text = 'See Other'; 230 | break; 231 | case 304: 232 | $text = 'Not Modified'; 233 | break; 234 | case 305: 235 | $text = 'Use Proxy'; 236 | break; 237 | case 400: 238 | $text = 'Bad Request'; 239 | break; 240 | case 401: 241 | $text = 'Unauthorized'; 242 | break; 243 | case 402: 244 | $text = 'Payment Required'; 245 | break; 246 | case 403: 247 | $text = 'Forbidden'; 248 | break; 249 | case 404: 250 | $text = 'Not Found'; 251 | break; 252 | case 405: 253 | $text = 'Method Not Allowed'; 254 | break; 255 | case 406: 256 | $text = 'Not Acceptable'; 257 | break; 258 | case 407: 259 | $text = 'Proxy Authentication Required'; 260 | break; 261 | case 408: 262 | $text = 'Request Time-out'; 263 | break; 264 | case 409: 265 | $text = 'Conflict'; 266 | break; 267 | case 410: 268 | $text = 'Gone'; 269 | break; 270 | case 411: 271 | $text = 'Length Required'; 272 | break; 273 | case 412: 274 | $text = 'Precondition Failed'; 275 | break; 276 | case 413: 277 | $text = 'Request Entity Too Large'; 278 | break; 279 | case 414: 280 | $text = 'Request-URI Too Large'; 281 | break; 282 | case 415: 283 | $text = 'Unsupported Media Type'; 284 | break; 285 | case 500: 286 | $text = 'Internal Server Error'; 287 | break; 288 | case 501: 289 | $text = 'Not Implemented'; 290 | break; 291 | case 502: 292 | $text = 'Bad Gateway'; 293 | break; 294 | case 503: 295 | $text = 'Service Unavailable'; 296 | break; 297 | case 504: 298 | $text = 'Gateway Time-out'; 299 | break; 300 | case 505: 301 | $text = 'HTTP Version not supported'; 302 | break; 303 | default: 304 | $text = 'Unknown http status code "' . htmlentities($code) . '"'; 305 | break; 306 | } 307 | 308 | return $text; 309 | 310 | } else { 311 | return $text = 'Unknown http status code NULL'; 312 | } 313 | } 314 | 315 | public static function parseHeaders( $headers ) 316 | { 317 | $head = array(); 318 | if(!is_array($headers)){ 319 | return $head; 320 | } 321 | 322 | foreach( $headers as $k=>$v ) 323 | { 324 | $t = explode( ':', $v, 2 ); 325 | if( isset( $t[1] ) ) 326 | $head[ trim($t[0]) ] = trim( $t[1] ); 327 | else 328 | { 329 | $head[] = $v; 330 | if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) ) 331 | $head['reponse_code'] = intval($out[1]); 332 | } 333 | } 334 | return $head; 335 | } 336 | 337 | } 338 | -------------------------------------------------------------------------------- /admin/bankimport_setup.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file admin/bankimport.php 21 | * \ingroup bankimport 22 | * \brief This file is an example module setup page 23 | * Put some comments here 24 | */ 25 | // Dolibarr environment 26 | $res = 0; 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 29 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 30 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 31 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 34 | // Try main.inc.php using relative path 35 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 36 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 37 | if (!$res) die("Include of main fails"); 38 | 39 | // Libraries 40 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 41 | require_once '../lib/bankimport.lib.php'; 42 | 43 | global $bc, $conf, $db, $langs, $user; 44 | 45 | // Translations 46 | $langs->load('admin'); 47 | $langs->load("bankimport@bankimport"); 48 | 49 | // Access control 50 | if (! $user->admin) { 51 | accessforbidden(); 52 | } 53 | 54 | // Parameters 55 | $action = GETPOST('action', 'alpha'); 56 | 57 | /* 58 | * Actions 59 | */ 60 | if (preg_match('/set_(.*)/',$action,$reg)) 61 | { 62 | $code=$reg[1]; 63 | if (dolibarr_set_const($db, $code, GETPOST($code,"alphanohtml"), 'chaine', 0, '', $conf->entity) > 0) 64 | { 65 | header("Location: ".$_SERVER["PHP_SELF"]); 66 | exit; 67 | } 68 | else 69 | { 70 | dol_print_error($db); 71 | } 72 | } 73 | 74 | if (preg_match('/del_(.*)/',$action,$reg)) 75 | { 76 | $code=$reg[1]; 77 | if (dolibarr_del_const($db, $code, 0) > 0) 78 | { 79 | Header("Location: ".$_SERVER["PHP_SELF"]); 80 | exit; 81 | } 82 | else 83 | { 84 | dol_print_error($db); 85 | } 86 | } 87 | 88 | /* 89 | * View 90 | */ 91 | $page_name = "BankImportSetup"; 92 | llxHeader('', $langs->trans($page_name)); 93 | 94 | // Subheader 95 | $linkback = '' 96 | . $langs->trans("BackToModuleList") . ''; 97 | print load_fiche_titre($langs->trans($page_name), $linkback, 'tools'); 98 | 99 | // Configuration header 100 | $head = bankimportAdminPrepareHead(); 101 | print dol_get_fiche_head( 102 | $head, 103 | 'settings', 104 | $langs->trans("Module104020Name"), 105 | -1, 106 | "bankimport@bankimport" 107 | ); 108 | 109 | // Setup page goes here 110 | $form = new Form($db); 111 | $var = true; 112 | print ''; 113 | print ''; 114 | print ''; 115 | print ''; 116 | print ''; 117 | 118 | $newToken = function_exists('newToken')?newToken():$_SESSION['newtoken']; 119 | 120 | // Separator 121 | $var = !$var; 122 | print ''; 123 | print ''; 129 | print ''; 130 | print ''; 138 | 139 | // Mapping 140 | $var = !$var; 141 | print ''; 142 | print ''; 148 | print ''; 149 | print ''; 157 | 158 | // Date format 159 | $var = !$var; 160 | print ''; 161 | print ''; 167 | print ''; 168 | print ''; 176 | 177 | $var=!$var; 178 | print ''; 179 | print ''; 180 | print ''; 181 | print ''; 184 | 185 | $var=!$var; 186 | print ''; 187 | print ''; 188 | print ''; 189 | print ''; 192 | 193 | $var=!$var; 194 | print ''; 195 | print ''; 196 | print ''; 197 | print ''; 200 | 201 | $var=!$var; 202 | print ''; 203 | print ''; 204 | print ''; 205 | print ''; 208 | 209 | $var=!$var; 210 | print ''; 211 | print ''; 212 | print ''; 213 | print ''; 216 | 217 | $var=!$var; 218 | print ''; 219 | print ''; 220 | print ''; 221 | print ''; 224 | 225 | $var=!$var; 226 | print ''; 227 | print ''; 228 | print ''; 229 | print ''; 232 | 233 | $var=!$var; 234 | print ''; 235 | print ''; 236 | print ''; 237 | print ''; 240 | 241 | $var=!$var; 242 | print ''; 243 | print ''; 244 | print ''; 245 | print ''; 248 | 249 | print '
' . $langs->trans("Parameters") . ' ' . $langs->trans("Value") . '
'; 124 | print $form->textwithpicto( 125 | '', 126 | $langs->trans("BankImportSeparatorHelp") 127 | ); 128 | print ' '; 131 | print '
'; 132 | print ''; 133 | print ''; 134 | print ''; 135 | print ' '; 136 | print '
'; 137 | print '
'; 143 | print $form->textwithpicto( 144 | '', 145 | $langs->trans("BankImportMappingHelp") 146 | ); 147 | print ' '; 150 | print '
'; 151 | print ''; 152 | print ''; 153 | print ''; 154 | print ' '; 155 | print '
'; 156 | print '
'; 162 | print $form->textwithpicto( 163 | '', 164 | $langs->trans("BankImportDateFormatHelp") 165 | ); 166 | print ' '; 169 | print '
'; 170 | print ''; 171 | print ''; 172 | print ''; 173 | print ' '; 174 | print '
'; 175 | print '
'.$langs->trans("FileHasHeader").' '; 182 | print ajax_constantonoff('BANKIMPORT_HEADER'); 183 | print '
'.$langs->trans("UseMacCompatibility").' '; 190 | print ajax_constantonoff('BANKIMPORT_MAC_COMPATIBILITY'); 191 | print '
'.$langs->trans("bankImportUseHistory").' '; 198 | print ajax_constantonoff('BANKIMPORT_HISTORY_IMPORT'); 199 | print '
'.$langs->trans("bankImportAllowInvoiceFromSeveralThird").' '; 206 | print ajax_constantonoff('BANKIMPORT_ALLOW_INVOICE_FROM_SEVERAL_THIRD'); 207 | print '
'.$langs->trans("bankImportAllowDraftInvoice").' '; 214 | print ajax_constantonoff('BANKIMPORT_ALLOW_DRAFT_INVOICE'); 215 | print '
'.$langs->trans("bankImportUncheckAllLines").' '; 222 | print ajax_constantonoff('BANKIMPORT_UNCHECK_ALL_LINES'); 223 | print '
'.$langs->trans("bankImportAutoCreateDiscount").' '; 230 | print ajax_constantonoff('BANKIMPORT_AUTO_CREATE_DISCOUNT'); 231 | print '
'.$langs->trans("bankImportMatchBanklinesByAmountAndLabel").' '; 238 | print ajax_constantonoff('BANKIMPORT_MATCH_BANKLINES_BY_AMOUNT_AND_LABEL'); 239 | print '
'.$langs->trans("bankImportAllowFreelines").' '; 246 | print ajax_constantonoff('BANKIMPORT_ALLOW_FREELINES'); 247 | print '
'; 250 | 251 | print dol_get_fiche_end(-1); 252 | 253 | llxFooter(); 254 | 255 | $db->close(); 256 | -------------------------------------------------------------------------------- /tpl/bankimport.check.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
trans("BankAccount") ?>account->getNomUrl(1) ?>trans("DateStart") ?>dateStart, 'day') ?>trans("AccountStatement") ?>numReleve ?>
trans("BankImportFile") ?>file) ?>trans("DateEnd") ?>dateEnd, 'day') ?>trans("FileHasHeader") ?>hasHeader == 1 ? $langs->trans('Yes') : $langs->trans('No') ?>
19 |
20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | $line) { ?> 56 | > 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | $bankline) { ?> 65 | 0) echo '' ?> 66 | 67 | 68 | 69 | 70 | 71 | 72 | 75 | ' ?> 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 |
trans("FileTransactions") ?>trans("DolibarrTransactions") ?>
trans("Line") ?>trans("Date") ?>trans("Description") ?>trans("Amount") ?>trans("Transaction") ?>trans("Date") ?>trans("Description") ?>trans("RelatedItem") ?>trans("Amount") ?> id="checkall" name="checkall" value="1" onchange="checkAll()" />
73 | 74 |   89 |  * 107 | 108 | query("SELECT rowid, nom FROM ".MAIN_DB_PREFIX."societe 114 | WHERE code_compta='".$db->escape($line['code_client'])."' OR code_compta_fournisseur='".$db->escape($line['code_client'])."' 115 | LIMIT 1"); 116 | $fk_soc = 0; 117 | $name = $langs->trans('bankimport_no_customer_selected_click_to_select_one'); 118 | if($obj_soc = $db->fetch_object($res)) 119 | { 120 | $fk_soc = $obj_soc->rowid; 121 | $name = $langs->trans('bankimport_customer_selected_click_to_select_another_one', $obj_soc->nom); 122 | } 123 | 124 | $select_company = $form->select_company($fk_soc, $comboName,'',1,0,1); 125 | 126 | echo '
'; 127 | echo $line['code_client'].' '.$name.''; 128 | echo ' *
'; 129 | echo $form->select_types_paiements('', 'TLine[fk_payment]['.$i.']'); 130 | echo ' *'; 131 | 132 | ?> 133 | 134 |
135 |
136 |
137 | 138 |
trans('BankTransactionWillBeCreatedAndReconciled', $import->numReleve) ?> name="TLine[new][]" value="" />
248 |
249 | 264 |
265 | "> 266 |
267 |
268 | 269 | 270 | 309 | -------------------------------------------------------------------------------- /core/modules/modBankImport.class.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2012 Laurent Destailleur 4 | * Copyright (C) 2005-2012 Regis Houssin 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /** 21 | * \defgroup bankimport Module BankImport 22 | * \brief Example of a module descriptor. 23 | * Such a file must be copied into htdocs/bankimport/core/modules directory. 24 | * \file htdocs/bankimport/core/modules/modBankImport.class.php 25 | * \ingroup bankimport 26 | * \brief Description and activation file for module BankImport 27 | */ 28 | include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; 29 | 30 | 31 | /** 32 | * Description and activation class for module BankImport 33 | */ 34 | class modBankImport extends DolibarrModules 35 | { 36 | /** 37 | * Constructor. Define names, constants, directories, boxes, permissions 38 | * 39 | * @param DoliDB $db Database handler 40 | */ 41 | function __construct($db) 42 | { 43 | global $langs,$conf; 44 | 45 | $this->db = $db; 46 | 47 | // Id for module (must be unique). 48 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). 49 | $this->numero = 104020; // 104000 to 104999 for ATM CONSULTING 50 | $this->editor_name = 'ATM Consulting'; 51 | $this->editor_url = 'https://www.atm-consulting.fr'; 52 | // Key text used to identify module (for permissions, menus, etc...) 53 | $this->rights_class = 'bankimport'; 54 | 55 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' 56 | // It is used to group modules in module setup page 57 | $this->family = 'financial'; 58 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) 59 | $this->name = preg_replace('/^mod/i','',get_class($this)); 60 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) 61 | $this->description = "Allow to import csv files to reconcile bank accounts"; 62 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version 63 | 64 | $this->version = '2.8.3'; 65 | 66 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) 67 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); 68 | // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) 69 | $this->special = 2; 70 | // Name of image file used for this module. 71 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' 72 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' 73 | $this->picto='module.svg@bankimport'; 74 | 75 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) 76 | // for default path (eg: /bankimport/core/xxxxx) (0=disable, 1=enable) 77 | // for specific path of parts (eg: /bankimport/core/modules/barcode) 78 | // for specific css file (eg: /bankimport/css/bankimport.css.php) 79 | //$this->module_parts = array( 80 | // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) 81 | // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) 82 | // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) 83 | // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) 84 | // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) 85 | // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 86 | // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 87 | // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 88 | // 'css' => array('/bankimport/css/bankimport.css.php'), // Set this to relative path of css file if module has its own css file 89 | // 'js' => array('/bankimport/js/bankimport.js'), // Set this to relative path of js file if module must load a js on all pages 90 | // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module 91 | // 'dir' => array('output' => 'othermodulename'), // To force the default directories names 92 | // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@bankimport')) // Set here all workflow context managed by module 93 | // ); 94 | $this->module_parts = []; 95 | 96 | // Data directories to create when module is enabled. 97 | // Example: this->dirs = array("/bankimport/temp"); 98 | $this->dirs = []; 99 | 100 | // Config pages. Put here list of php page, stored into bankimport/admin directory, to use to setup module. 101 | $this->config_page_url = ["bankimport_setup.php@bankimport"]; 102 | 103 | // Dependencies 104 | $this->hidden = false; // A condition to hide module 105 | $this->depends = []; // List of modules id that must be enabled if this module is enabled 106 | $this->requiredby = []; // List of modules id to disable if this one is disabled 107 | $this->conflictwith = []; // List of modules id this module is in conflict with 108 | $this->phpmin = [7,0]; // Minimum version of PHP required by module 109 | $this->need_dolibarr_version = [16,0]; // Minimum version of Dolibarr required by module 110 | $this->langfiles = ["bankimport@bankimport"]; 111 | 112 | // Url to the file with your last numberversion of this module 113 | require_once __DIR__ . '/../../class/techatm.class.php'; 114 | $this->url_last_version = \bankimport\TechATM::getLastModuleVersionUrl($this); 115 | 116 | // Constants 117 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) 118 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), 119 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) 120 | // ); 121 | $this->const = [ 122 | 0 => ['BANKIMPORT_MAPPING', 'chaine', 'date;label;debit;credit', 'CSV file mapping for bank import', 1, 'current', 0], 123 | 1 => ['BANKIMPORT_SEPARATOR', 'chaine', ';', 'Data separator for bank import', 1, 'current', 0], 124 | 2 => ['BANKIMPORT_DATE_FORMAT', 'chaine', 'd/m/Y', 'Date format in CSV file', 1, 'current', 0], 125 | 3 => ['BANKIMPORT_HEADER', 'bool', true, 'File header line presence', 1, 'current', 0] 126 | ]; 127 | 128 | // Array to add new pages in new tabs 129 | // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@bankimport:$user->rights->bankimport->read:/bankimport/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 130 | // 'objecttype:+tabname2:Title2:mylangfile@bankimport:$user->rights->othermodule->read:/bankimport/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 131 | // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname 132 | // where objecttype can be 133 | // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) 134 | // 'contact' to add a tab in contact view 135 | // 'contract' to add a tab in contract view 136 | // 'group' to add a tab in group view 137 | // 'intervention' to add a tab in intervention view 138 | // 'invoice' to add a tab in customer invoice view 139 | // 'invoice_supplier' to add a tab in supplier invoice view 140 | // 'member' to add a tab in fundation member view 141 | // 'opensurveypoll' to add a tab in opensurvey poll view 142 | // 'order' to add a tab in customer order view 143 | // 'order_supplier' to add a tab in supplier order view 144 | // 'payment' to add a tab in payment view 145 | // 'payment_supplier' to add a tab in supplier payment view 146 | // 'product' to add a tab in product view 147 | // 'propal' to add a tab in propal view 148 | // 'project' to add a tab in project view 149 | // 'stock' to add a tab in stock view 150 | // 'thirdparty' to add a tab in third party view 151 | // 'user' to add a tab in user view 152 | $this->tabs = [ 153 | 'bank:+bankimport_statement:'.$langs->trans('AccountStatements').':bankimport@bankimport:isModEnabled(\'bankimport\') && getDolGlobalString("BANKIMPORT_HISTORY_IMPORT"):/bankimport/releve.php?account=__ID__' 154 | ,'bank:-statement:NU:isModEnabled(\'bankimport\') && getDolGlobalString("BANKIMPORT_HISTORY_IMPORT")' 155 | ]; 156 | 157 | // Dictionaries 158 | if (!isModEnabled('bankimport')) 159 | { 160 | $conf->bankimport=new stdClass(); 161 | $conf->bankimport->enabled=0; 162 | } 163 | $this->dictionaries=[]; 164 | /* Example: 165 | if (! isset($conf->bankimport->enabled)) $conf->bankimport->enabled=0; // This is to avoid warnings 166 | $this->dictionaries=array( 167 | 'langs'=>'mylangfile@bankimport', 168 | 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor 169 | 'tablib'=>array("Table1","Table2","Table3"), // Label of tables 170 | 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields 171 | 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order 172 | 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) 173 | 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) 174 | 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) 175 | 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') 176 | 'tabcond'=>array($conf->bankimport->enabled,$conf->bankimport->enabled,$conf->bankimport->enabled) // Condition to show each dictionary 177 | ); 178 | */ 179 | 180 | // Boxes 181 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. 182 | $this->boxes = []; // List of boxes 183 | // Example: 184 | //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); 185 | 186 | // Permissions 187 | $this->rights = []; // Permission array used by this module 188 | $r=0; 189 | 190 | // Add here list of permission defined by an id, a label, a boolean and two constant strings. 191 | // Example: 192 | // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) 193 | // $this->rights[$r][1] = 'Permision label'; // Permission label 194 | // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) 195 | // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 196 | // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 197 | // $r++; 198 | $this->rights[$r][0] = 104021; // Permission id (must not be already used) 199 | $this->rights[$r][1] = 'Import bancaire'; // Permission label 200 | $this->rights[$r][3] = 0; // Permission by default for new user (0/1) 201 | $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 202 | $r++; 203 | 204 | 205 | // Main menu entries 206 | $this->menu = []; // List of menus to add 207 | $r=0; 208 | 209 | // Add here entries to declare new menus 210 | // 211 | // Example to declare a new Top Menu entry and its Left menu entry: 212 | // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu 213 | // 'type'=>'top', // This is a Top menu entry 214 | // 'titre'=>'BankImport top menu', 215 | // 'mainmenu'=>'bankimport', 216 | // 'leftmenu'=>'bankimport', 217 | // 'url'=>'/bankimport/pagetop.php', 218 | // 'langs'=>'mylangfile@bankimport', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 219 | // 'position'=>100, 220 | // 'enabled'=>'$conf->bankimport->enabled', // Define condition to show or hide menu entry. Use '$conf->bankimport->enabled' if entry must be visible if module is enabled. 221 | // 'perms'=>'1', // Use 'perms'=>'$user->rights->bankimport->level1->level2' if you want your menu with a permission rules 222 | // 'target'=>'', 223 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 224 | // $r++; 225 | // 226 | // Example to declare a Left Menu entry into an existing Top menu entry: 227 | // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 228 | // 'type'=>'left', // This is a Left menu entry 229 | // 'titre'=>'BankImport left menu', 230 | // 'mainmenu'=>'xxx', 231 | // 'leftmenu'=>'bankimport', 232 | // 'url'=>'/bankimport/pagelevel2.php', 233 | // 'langs'=>'mylangfile@bankimport', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 234 | // 'position'=>100, 235 | // 'enabled'=>'$conf->bankimport->enabled', // Define condition to show or hide menu entry. Use '$conf->bankimport->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 236 | // 'perms'=>'1', // Use 'perms'=>'$user->rights->bankimport->level1->level2' if you want your menu with a permission rules 237 | // 'target'=>'', 238 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 239 | // $r++; 240 | $this->menu[$r]= ['fk_menu'=>'fk_mainmenu=bank', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 241 | 'type'=>'left', // This is a Left menu entry 242 | 'titre'=>'LeftMenuBankImport', 243 | 'mainmenu'=>'bank', 244 | 'leftmenu'=>'bankimport', 245 | 'url'=>'/bankimport/import.php', 246 | 'langs'=>'bankimport@bankimport', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 247 | 'position'=>100, 248 | 'enabled'=>'isModEnabled(\'bankimport\')', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 249 | 'perms'=>'$user->rights->bankimport->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 250 | 'target'=>'', 251 | 'user'=>0]; // 0=Menu for internal users, 1=external users, 2=both 252 | $r++; 253 | 254 | 255 | // Exports 256 | $r=1; 257 | 258 | // Example: 259 | // $this->export_code[$r]=$this->rights_class.'_'.$r; 260 | // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) 261 | // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. 262 | // $this->export_permission[$r]=array(array("facture","facture","export")); 263 | // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); 264 | // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); 265 | // $this->export_sql_start[$r]='SELECT DISTINCT '; 266 | // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; 267 | // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; 268 | // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; 269 | // $this->export_sql_order[$r] .=' ORDER BY s.nom'; 270 | // $r++; 271 | } 272 | 273 | /** 274 | * Function called when module is enabled. 275 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. 276 | * It also creates data directories 277 | * 278 | * @param string $options Options when enabling module ('', 'noboxes') 279 | * @return int 1 if OK, 0 if KO 280 | */ 281 | function init($options='') 282 | { 283 | $sql = []; 284 | 285 | define('INC_FROM_DOLIBARR',true); 286 | 287 | dol_include_once('/bankimport/config.php'); 288 | dol_include_once('/bankimport/script/create-maj-base.php'); 289 | 290 | $result=$this->_load_tables('/bankimport/sql/'); 291 | 292 | return $this->_init($sql, $options); 293 | } 294 | 295 | /** 296 | * Function called when module is disabled. 297 | * Remove from database constants, boxes and permissions from Dolibarr database. 298 | * Data directories are not deleted 299 | * 300 | * @param string $options Options when enabling module ('', 'noboxes') 301 | * @return int 1 if OK, 0 if KO 302 | */ 303 | function remove($options='') 304 | { 305 | $sql = []; 306 | 307 | return $this->_remove($sql, $options); 308 | } 309 | 310 | } 311 | -------------------------------------------------------------------------------- /class/bankimport.class.php: -------------------------------------------------------------------------------- 1 | db = &$db; 38 | $this->dateStart = strtotime('first day of last month'); 39 | $this->dateEnd = strtotime('last day of last month'); 40 | } 41 | 42 | /** 43 | * Set vars we will work with 44 | */ 45 | function analyse($accountId, $filename, $dateStart, $dateEnd, $numReleve, $hasHeader) { 46 | global $conf, $langs; 47 | 48 | // Bank account selected 49 | if($accountId <= 0) { 50 | setEventMessage($langs->trans('ErrorAccountIdNotSelected'), 'errors'); 51 | return false; 52 | } else { 53 | $this->account = new Account($this->db); 54 | $this->account->fetch($accountId); 55 | } 56 | 57 | // Start and end date regarding bank statement 58 | $this->dateStart = $dateStart; 59 | $this->dateEnd = $dateEnd; 60 | 61 | // Statement number 62 | $this->numReleve = $numReleve; 63 | $this->hasHeader = $hasHeader; 64 | 65 | // Bank statement file (csv or filename if csv already uploaded) 66 | if(is_file($filename)) { 67 | $this->file = $filename; 68 | } else if(!empty($_FILES[$filename])) { 69 | 70 | if($_FILES[$filename]['error'] != 0) { 71 | setEventMessage($langs->trans('ErrorFile' . $_FILES[$filename]['error']), 'errors'); 72 | return false; 73 | }/* else if($_FILES[$filename]['type'] != 'text/csv' && $_FILES[$filename]['type'] != 'text/plain' && && $_FILES[$filename]['type'] != 'application/octet-stream') { 74 | setEventMessage($langs->trans('ErrorFileIsNotCSV') . ' ' . $_FILES[$filename]['type'], 'errors'); 75 | return false; 76 | }*/ 77 | else { 78 | 79 | dol_include_once('/core/lib/files.lib.php'); 80 | dol_include_once('/core/lib/images.lib.php'); 81 | $upload_dir = $conf->bankimport->dir_output . '/' . dol_sanitizeFileName($this->account->ref); 82 | 83 | dol_add_file_process($upload_dir,1,1,$filename); 84 | $this->file = $upload_dir . '/' . $_FILES[$filename]['name']; 85 | $info = pathinfo($this->file); 86 | $this->file = $info['dirname'].'/'.dol_sanitizeFileName($info['filename'].'.'.strtolower($info['extension'])); 87 | 88 | if(!is_file($this->file)) { 89 | return false; 90 | } 91 | } 92 | } 93 | 94 | return true; 95 | } 96 | 97 | function load_transactions($delimiter='', $dateFormat='', $mapping_string='', $enclosure='"') { 98 | global $hookmanager; 99 | 100 | //gestion possible par un hook 101 | if (is_object($hookmanager)) { 102 | $parameters = array("moduleName" => "bankimport"); 103 | $action = "load_transactions"; 104 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks 105 | if ($reshook > 0) { 106 | print $hookmanager->resPrint; 107 | return; 108 | } else { 109 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 110 | } 111 | 112 | } 113 | 114 | $this->load_bank_transactions(); 115 | $this->load_check_receipt(); 116 | $this->load_file_transactions($delimiter, $dateFormat, $mapping_string, $enclosure); 117 | } 118 | 119 | // Load bank lines 120 | function load_bank_transactions() { 121 | $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "bank WHERE fk_account = " . $this->account->id . " "; 122 | $sql.= "AND dateo BETWEEN '" . date('Y-m-d', $this->dateStart) . "' AND '" . date('Y-m-d', $this->dateEnd) . "' "; 123 | $sql.= "ORDER BY datev DESC"; 124 | 125 | $resql = $this->db->query($sql); 126 | $TBankLineId = array(); 127 | while($obj = $this->db->fetch_object($resql)) { 128 | $TBankLineId[] = $obj->rowid; 129 | } 130 | 131 | foreach($TBankLineId as $bankid) { 132 | $bankLine = new AccountLine($this->db); 133 | $bankLine->fetch($bankid); 134 | $this->TBank[$bankid] = $bankLine; 135 | } 136 | } 137 | 138 | // Load check receipt regarding bank lines 139 | function load_check_receipt() { 140 | foreach($this->TBank as $bankLine) { 141 | if($bankLine->fk_bordereau > 0 && empty($this->TCheckReceipt[$bankLine->fk_bordereau])) { 142 | $bord = new RemiseCheque($this->db); 143 | $bord->fetch($bankLine->fk_bordereau); 144 | 145 | $this->TCheckReceipt[$bankLine->fk_bordereau] = $bord; 146 | } 147 | } 148 | } 149 | 150 | // Load file lines 151 | function load_file_transactions($delimiter='', $dateFormat='', $mapping_string='', $enclosure='"') { 152 | global $conf, $langs, $hookmanager; 153 | 154 | //gestion possible par un hook 155 | if (is_object($hookmanager)) { 156 | $parameters = array("moduleName" => "bankimport"); 157 | $action = "load_file_transactions"; 158 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks 159 | if ($reshook > 0) { 160 | print $hookmanager->resPrint; 161 | return; 162 | } else { 163 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 164 | } 165 | } 166 | if(empty($delimiter)) $delimiter = getDolGlobalString('BANKIMPORT_SEPARATOR'); 167 | if(empty($dateFormat)) $dateFormat = strtr(getDolGlobalString('BANKIMPORT_DATE_FORMAT'), array('%'=>'')); 168 | 169 | if(empty($mapping_string)) $mapping_string = getDolGlobalString('BANKIMPORT_MAPPING'); 170 | $mapping_string = preg_replace_callback('|=([^' . $delimiter . ']*)|', 'BankImport::extractNegDir', $mapping_string); 171 | 172 | if($delimiter == '\t')$delimiter="\t"; 173 | 174 | if(strpos($mapping_string,$delimiter) === false) $mapping = explode(";", $mapping_string); // pour le \t 175 | else $mapping = explode($delimiter, $mapping_string); // pour le \t 176 | 177 | $f1 = fopen($this->file, 'r'); 178 | if($this->hasHeader) $this->lineHeader = fgets($f1, 4096); 179 | 180 | while(!feof($f1)) { 181 | 182 | if(getDolGlobalString('BANKIMPORT_MAC_COMPATIBILITY')) { 183 | $ligne = fgets($f1, 4096); 184 | if (empty($ligne)) continue; 185 | // print '
'.$ligne.'
'; 186 | $dataline = str_getcsv(trim($ligne), $delimiter, $enclosure); 187 | 188 | } 189 | else { 190 | $dataline = fgetcsv($f1, 4096, $delimiter, $enclosure); 191 | if (empty($dataline)) continue; 192 | } 193 | // var_dump($dataline, $delimiter, $enclosure); 194 | 195 | $mapping_en_colonne = (strpos($mapping_string, ':') !== false) ? true : false; 196 | 197 | if((count($dataline) == count($mapping)) || $mapping_en_colonne) { 198 | $this->TOriginLine[] = $dataline; 199 | 200 | if($mapping_en_colonne) $data = $this->construct_data_tab_column_file($mapping, $dataline[0]); 201 | else $data = array_combine($mapping, $dataline); 202 | 203 | // Gestion du montant débit / crédit 204 | if (empty($data['debit']) && empty($data['credit'])) { 205 | $amount = (float)price2num($data['amount']); 206 | 207 | // Direction support 208 | if (!empty($data['direction'])) { 209 | if ($data['direction'] == $this->neg_dir) { 210 | $amount *= -1; 211 | } 212 | } 213 | 214 | if ($amount >= 0) { 215 | $data['credit'] = $amount; 216 | } elseif ($amount < 0) { 217 | $data['debit'] = $amount; 218 | } 219 | } else { 220 | $data['debit'] = (float)price2num($data['debit']); 221 | 222 | if ($data['debit'] > 0) { 223 | $data['debit'] *= -1; 224 | } 225 | $data['credit'] = (float)price2num($data['credit']); 226 | } 227 | 228 | $data['amount'] = (!empty($data['debit']) ? $data['debit'] : $data['credit']); 229 | 230 | //$time = date_parse_from_format($dateFormat, $data['date']); 231 | //$data['datev'] = mktime(0, 0, 0, $time['month'], $time['day'], $time['year']+2000); 232 | 233 | // TODO : Apparemment createFromFormat ne fonctionne pas si PHP < 5.3 .... 234 | $datetime = DateTime::createFromFormat($dateFormat, $data['date']); 235 | 236 | $data['datev'] = ($datetime === false) ? 0 : $datetime->getTimestamp(); 237 | 238 | $data['error'] = ''; 239 | } else { 240 | $data = array(); 241 | $data['error'] = $langs->trans('LineDoesNotMatchWithMapping'); 242 | } 243 | 244 | $this->TFile[] = $data; 245 | } 246 | 247 | fclose($f1); 248 | } 249 | 250 | function construct_data_tab_column_file(&$mapping, $data) { 251 | 252 | $TDataFinal = array(); 253 | $pos = 0; 254 | foreach($mapping as $m) { 255 | 256 | $TTemp = explode(':', $m); 257 | 258 | $label_colonne = $TTemp[0]; 259 | $nb_car = $TTemp[1]; 260 | $res = substr($data, $pos, $nb_car); 261 | $res = trim($res); 262 | $TDataFinal[$label_colonne] = $res; 263 | $pos += $nb_car; 264 | } 265 | 266 | return $TDataFinal; 267 | 268 | } 269 | 270 | function compare_transactions() { 271 | 272 | // For each file transaction, we search in Dolibarr bank transaction if there is a match by amount 273 | foreach($this->TFile as &$fileLine) { 274 | $amount = price2num($fileLine['amount']); // Transform to numeric string 275 | if(is_numeric($amount)) { 276 | $transac = $this->search_dolibarr_transaction_by_amount($amount, $fileLine['label']); 277 | if($transac === false) $transac = $this->search_dolibarr_transaction_by_receipt($amount); 278 | $fileLine['bankline'] = $transac; 279 | } 280 | } 281 | } 282 | 283 | private function search_dolibarr_transaction_by_amount($amount, $label) { 284 | global $conf, $langs; 285 | $langs->load("banks"); 286 | 287 | $amount = floatval($amount); // Transform to float 288 | foreach($this->TBank as $i => $bankLine) { 289 | $test = ($amount == $bankLine->amount); 290 | if(getDolGlobalString('BANKIMPORT_MATCH_BANKLINES_BY_AMOUNT_AND_LABEL')) $test = ($amount == $bankLine->amount && $label == $bankLine->label); 291 | if(!empty($test)) { 292 | unset($this->TBank[$i]); 293 | 294 | return array($this->get_bankline_data($bankLine)); 295 | } 296 | } 297 | 298 | return false; 299 | } 300 | 301 | /** 302 | * @param $amount 303 | * @return array|false 304 | */ 305 | private function search_dolibarr_transaction_by_receipt($amount) { 306 | global $langs; 307 | $langs->load("banks"); 308 | 309 | $amount = floatval($amount); // Transform to float 310 | foreach($this->TCheckReceipt as $bordereau) { 311 | if($amount == $bordereau->amount) { 312 | $TBankLine = array(); 313 | foreach($this->TBank as $i => $bankLine) { 314 | if($bankLine->fk_bordereau == $bordereau->id) { 315 | unset($this->TBank[$i]); 316 | 317 | $TBankLine[] = $this->get_bankline_data($bankLine); 318 | } 319 | } 320 | 321 | return $TBankLine; 322 | } 323 | } 324 | 325 | return false; 326 | } 327 | 328 | private function get_bankline_data($bankLine) { 329 | global $langs, $db; 330 | 331 | if(!empty($bankLine->num_releve)) { 332 | $link = '' 337 | . $bankLine->num_releve 338 | . ''; 339 | $result = $langs->transnoentitiesnoconv('AlreadyReconciledWithStatement', $link); 340 | $autoaction = false; 341 | } else { 342 | $result = $langs->transnoentitiesnoconv('WillBeReconciledWithStatement', $this->numReleve); 343 | $autoaction = true; 344 | } 345 | 346 | $societestatic = new Societe($db); 347 | $userstatic = new User($db); 348 | $chargestatic = new ChargeSociales($db); 349 | $memberstatic = new Adherent($db); 350 | 351 | $links = $this->account->get_url($bankLine->id); 352 | $relatedItem = ''; 353 | foreach($links as $key=>$val) { 354 | if ($links[$key]['type'] == 'company') { 355 | $societestatic->id = $links[$key]['url_id']; 356 | $societestatic->name = $links[$key]['label']; 357 | $relatedItem = $societestatic->getNomUrl(1,'',16); 358 | } else if ($links[$key]['type'] == 'user') { 359 | $userstatic->id = $links[$key]['url_id']; 360 | $userstatic->lastname = $links[$key]['label']; 361 | $relatedItem = $userstatic->getNomUrl(1,''); 362 | } else if ($links[$key]['type'] == 'sc') { 363 | // sc=old value 364 | $chargestatic->id = $links[$key]['url_id']; 365 | if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) { 366 | if ($reg[1] == 'socialcontribution') $reg[1] = 'SocialContribution'; 367 | $chargestatic->lib = $langs->trans($reg[1]); 368 | } else { 369 | $chargestatic->lib = $links[$key]['label']; 370 | } 371 | $chargestatic->ref = $chargestatic->lib; 372 | $relatedItem = $chargestatic->getNomUrl(1,16); 373 | } else if ($links[$key]['type'] == 'member') { 374 | $memberstatic->id = $links[$key]['url_id']; 375 | $memberstatic->ref = $links[$key]['label']; 376 | $relatedItem = $memberstatic->getNomUrl(1,16,'card'); 377 | } 378 | } 379 | 380 | return array( 381 | 'id' => $bankLine->id 382 | ,'url' => $bankLine->getNomUrl(1) 383 | ,'date' => dol_print_date($bankLine->datev,"day") 384 | ,'label' => (preg_match('/^\((.*)\)$/i',$bankLine->label,$reg) ? $langs->trans($reg[1]) : dol_trunc($bankLine->label,60)) 385 | ,'amount' => price($bankLine->amount) 386 | ,'result' => $result 387 | ,'autoaction' => $autoaction 388 | ,'relateditem' => $relatedItem 389 | ,'time' => $bankLine->datev 390 | ); 391 | } 392 | 393 | /** 394 | * Actions made after file check by user 395 | */ 396 | public function import_data($TLine) 397 | { 398 | global $conf, $db; 399 | 400 | $TLineBackup = $TLine; // car le programme est concue pour scier la branche sur laquelle il est assis 401 | 402 | $PDOdb = new TPDOdb; 403 | if (!empty($TLine['piece'])) 404 | { 405 | dol_include_once('/compta/paiement/class/paiement.class.php'); 406 | dol_include_once('/fourn/class/paiementfourn.class.php'); 407 | dol_include_once('/fourn/class/fournisseur.facture.class.php'); 408 | dol_include_once('/compta/sociales/class/paymentsocialcontribution.class.php'); 409 | 410 | /* 411 | * Reglemenent créé manuellement 412 | */ 413 | 414 | $db = &$this->db; 415 | foreach($TLine['piece'] as $iFileLine=>$TObject) 416 | { 417 | if(!empty($TLine['fk_soc'][$iFileLine])) { 418 | $l_societe = new Societe($db); 419 | $l_societe->fetch($TLine['fk_soc'][$iFileLine]); 420 | } 421 | 422 | $fk_payment = $TLine['fk_payment'][$iFileLine]; 423 | $date_paye = $this->TFile[$iFileLine]['datev']; 424 | 425 | foreach($TObject as $typeObject=>$TAmounts) 426 | { 427 | if(!empty($TAmounts)) 428 | { 429 | switch ($typeObject) 430 | { 431 | case 'facture': 432 | $fk_bank = $this->doPaymentForFacture($TLine, $TAmounts, $l_societe, $iFileLine, $fk_payment, $date_paye); 433 | break; 434 | case 'fournfacture': 435 | $fk_bank = $this->doPaymentForFactureFourn($TLine, $TAmounts, $l_societe, $iFileLine, $fk_payment, $date_paye); 436 | break; 437 | case 'charge': 438 | $fk_bank = $this->doPaymentForCharge(); 439 | break; 440 | } 441 | 442 | } 443 | } 444 | 445 | } 446 | 447 | unset($TLine['piece']); 448 | } 449 | 450 | unset($TLine['fk_payment'], $TLine['fk_soc'], $TLine['type']); 451 | 452 | if (isset($TLine['new'])) 453 | { 454 | if(!empty($TLine['new'])) { 455 | foreach($TLine['new'] as $iFileLine) { 456 | $oper = 'PRE'; 457 | $sql = 'SELECT c.code FROM '. MAIN_DB_PREFIX . 'c_paiement c WHERE id='.intval($TLineBackup['fk_payment'][$iFileLine]).' LIMIT 1;'; 458 | $res = $db->query($sql); 459 | if ($res){ 460 | $obj = $db->fetch_object($res); 461 | $oper = $obj->code; 462 | } 463 | 464 | $bankLineId = $this->create_bank_transaction($this->TFile[$iFileLine], $oper); 465 | if($bankLineId > 0) { 466 | $bankLine = new AccountLine($this->db); 467 | $bankLine->fetch($bankLineId); 468 | $this->reconcile_bank_transaction($bankLine, $this->TFile[$iFileLine]); 469 | } 470 | } 471 | } 472 | unset($TLine['new']); 473 | } 474 | 475 | foreach($TLine as $bankLineId => $iFileLine) 476 | { 477 | $this->reconcile_bank_transaction($this->TBank[$bankLineId], $this->TFile[$iFileLine]); 478 | if (getDolGlobalString('BANKIMPORT_HISTORY_IMPORT') && $bankLineId > 0) 479 | { 480 | $this->insertHistoryLine($PDOdb, $iFileLine, $bankLineId); 481 | } 482 | } 483 | } 484 | 485 | private function validateInvoices(&$TAmounts, $type) { 486 | 487 | global $db, $user; 488 | 489 | dol_include_once('/compta/facture/class/facture.class.php'); 490 | dol_include_once('/fourn/class/fournisseur.facture.class.php'); 491 | 492 | $TTypeElement = array('payment'=>'Facture', 'payment_supplier'=>'FactureFournisseur'); 493 | 494 | if(!empty($TAmounts) && in_array($type, array_keys($TTypeElement))) { 495 | foreach($TAmounts as $facid=>$amount) { 496 | $f = new $TTypeElement[$type]($db); 497 | if($f->fetch($facid) > 0 && $f->statut == 0 && $amount > 0) $f->validate($user); 498 | } 499 | } 500 | 501 | } 502 | 503 | private function doPaymentForFacture(&$TLine, &$TAmounts, &$l_societe, $iFileLine, $fk_payment, $date_paye) 504 | { 505 | return $this->doPayment($TLine, $TAmounts, $l_societe, $iFileLine, $fk_payment, $date_paye, 'payment'); 506 | } 507 | 508 | private function doPaymentForFactureFourn(&$TLine, &$TAmounts, &$l_societe, $iFileLine, $fk_payment, $date_paye) 509 | { 510 | return $this->doPayment($TLine, $TAmounts, $l_societe, $iFileLine, $fk_payment, $date_paye, 'payment_supplier'); 511 | } 512 | 513 | private function doPaymentForCharge(&$TLine, &$TAmounts, &$l_societe, $iFileLine, $fk_payment, $date_paye) 514 | { 515 | return $this->doPayment($TLine, $TAmounts, $l_societe, $iFileLine, $fk_payment, $date_paye, 'payment_sc'); 516 | } 517 | 518 | private function doPayment(&$TLine, &$TAmounts, &$l_societe, $iFileLine, $fk_payment, $date_paye, $type='payment') 519 | { 520 | global $conf, $langs,$user; 521 | 522 | $note = $langs->trans('TitleBankImport') .' - '.$this->numReleve; 523 | 524 | if ($type == 'payment') $paiement = new Paiement($this->db); 525 | elseif ($type == 'payment_supplier') $paiement = new PaiementFourn($this->db); 526 | elseif ($type == 'payment_supplier') $paiement = new PaymentSocialContribution($this->db); 527 | else exit($langs->trans('BankImport_FatalError_PaymentType_NotPossible', $type)); 528 | 529 | if(getDolGlobalString('BANKIMPORT_ALLOW_DRAFT_INVOICE')) $this->validateInvoices($TAmounts, $type); 530 | 531 | $paiement->datepaye = $date_paye; 532 | $paiement->amounts = $TAmounts; // Array with all payments dispatching 533 | $paiement->paiementid = $fk_payment; 534 | if (floatval(DOL_VERSION) >= 13.0) $paiement->num_payment = ''; 535 | else $paiement->num_paiement = ''; 536 | $paiement->note = $note; 537 | 538 | $paiement_id = $paiement->create($user, 1); 539 | 540 | if ($paiement_id > 0) 541 | { 542 | $bankLineId = $paiement->addPaymentToBank($user, $type, !empty($this->TFile[$iFileLine]['label']) ? $this->TFile[$iFileLine]['label'] : $note, $this->account->id, $l_societe->name, ''); 543 | $TLine[$bankLineId] = $iFileLine; 544 | 545 | $bankLine = new AccountLine($this->db); 546 | $bankLine->fetch($bankLineId); 547 | $this->TBank[$bankLineId] = $bankLine; 548 | 549 | // On supprime le new saisi 550 | foreach($TLine['new'] as $k=>$iFileLineNew) 551 | { 552 | if($iFileLineNew == $iFileLine) unset($TLine['new'][$k]); 553 | } 554 | 555 | // Uniquement pour les factures client (les acomptes fournisseur n'existent pas) 556 | if(getDolGlobalInt('BANKIMPORT_AUTO_CREATE_DISCOUNT') && $type === 'payment') $this->createDiscount($TAmounts); 557 | 558 | return $bankLineId; 559 | } 560 | 561 | return 0; // Payment fail, can't return bankLineId 562 | } 563 | 564 | private function createDiscount(&$TAmounts) { 565 | 566 | global $db, $user; 567 | 568 | dol_include_once('/core/class/discount.class.php'); 569 | 570 | foreach($TAmounts as $id_fac => $amount) { 571 | 572 | $object = new Facture($db); 573 | $object->fetch($id_fac); 574 | if($object->type != 3) continue; // Uniquement les acomptes 575 | 576 | $object->fetch_thirdparty(); 577 | 578 | // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) 579 | $discountcheck=new DiscountAbsolute($db); 580 | $result=$discountcheck->fetch(0,$object->id); 581 | 582 | $canconvert=0; 583 | if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc) 584 | if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) 585 | if ($canconvert) 586 | { 587 | $db->begin(); 588 | 589 | // Boucle sur chaque taux de tva 590 | $i = 0; 591 | foreach ($object->lines as $line) { 592 | $amount_ht [$line->tva_tx] += $line->total_ht; 593 | $amount_tva [$line->tva_tx] += $line->total_tva; 594 | $amount_ttc [$line->tva_tx] += $line->total_ttc; 595 | $i ++; 596 | } 597 | 598 | // Insert one discount by VAT rate category 599 | $discount = new DiscountAbsolute($db); 600 | if ($object->type == Facture::TYPE_CREDIT_NOTE) 601 | $discount->description = '(CREDIT_NOTE)'; 602 | elseif ($object->type == Facture::TYPE_DEPOSIT) 603 | $discount->description = '(DEPOSIT)'; 604 | else { 605 | setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors'); 606 | } 607 | $discount->tva_tx = abs($object->total_ttc); 608 | $discount->fk_soc = $object->socid; 609 | $discount->fk_facture_source = $object->id; 610 | 611 | $error = 0; 612 | foreach ($amount_ht as $tva_tx => $xxx) { 613 | $discount->amount_ht = abs($amount_ht [$tva_tx]); 614 | $discount->amount_tva = abs($amount_tva [$tva_tx]); 615 | $discount->amount_ttc = abs($amount_ttc [$tva_tx]); 616 | $discount->tva_tx = abs($tva_tx); 617 | 618 | $result = $discount->create($user); 619 | if ($result < 0) 620 | { 621 | $error++; 622 | break; 623 | } 624 | } 625 | 626 | if (empty($error)) 627 | { 628 | // Classe facture 629 | $result = $object->set_paid($user); 630 | if ($result >= 0) 631 | { 632 | //$mesgs[]='OK'.$discount->id; 633 | $db->commit(); 634 | } 635 | else 636 | { 637 | setEventMessage($object->error,'errors'); 638 | $db->rollback(); 639 | } 640 | } 641 | else 642 | { 643 | setEventMessage($discount->error,'errors'); 644 | $db->rollback(); 645 | } 646 | } 647 | 648 | } 649 | 650 | } 651 | 652 | private function insertHistoryLine(&$PDOdb, $iFileLine, $fk_bank) 653 | { 654 | if (!empty($this->hasHeader) && !empty($this->TOriginLine[$iFileLine])) 655 | { 656 | $header = $this->parseHeader($this->lineHeader); 657 | $line = $this->parseLine($this->TOriginLine[$iFileLine]); 658 | 659 | $historyLine = new TBankImportHistory; 660 | 661 | $historyLine->num_releve = $this->numReleve; 662 | $historyLine->fk_bank = $fk_bank; 663 | $historyLine->line_imported_title = $header; 664 | $historyLine->line_imported_value = $line; 665 | 666 | $historyLine->save($PDOdb); 667 | } 668 | } 669 | 670 | public function parseHeader($headerToParse) 671 | { 672 | global $conf; 673 | 674 | $header = explode(getDolGlobalString('BANKIMPORT_SEPARATOR'), $headerToParse); 675 | $header = array_map(array('BankImport', 'cleanString'), $header); 676 | 677 | return $header; 678 | } 679 | 680 | public static function cleanString($strToClean) 681 | { 682 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; 683 | $strToClean = trim($strToClean); 684 | $strToClean = preg_replace('/\s{2,}/', '', $strToClean); 685 | $strToClean = dol_strtolower(dol_string_unaccent($strToClean)); 686 | 687 | return ucfirst($strToClean); 688 | } 689 | 690 | public function parseLine($lineArrayToParse) 691 | { 692 | $line = array_map(array('BankImport', 'cleanStringForLine'), $lineArrayToParse); 693 | 694 | return $line; 695 | } 696 | 697 | public static function cleanStringForLine($strToClean) 698 | { 699 | $strToClean = trim($strToClean); 700 | $strToClean = preg_replace('/\s{2,}/', '', $strToClean); 701 | 702 | return $strToClean; 703 | } 704 | 705 | /** 706 | * @param array $fileLine 707 | * @param string $oper 'VIR','PRE','LIQ','VAD','CB','CHQ'... 708 | * @return int 709 | */ 710 | private function create_bank_transaction($fileLine, $oper = 'PRE') { 711 | global $user; 712 | 713 | $bankLineId = $this->account->addline($fileLine['datev'], $oper, $fileLine['label'], $fileLine['amount'], '', '', $user); 714 | $this->nbCreated++; 715 | 716 | return $bankLineId; 717 | } 718 | 719 | private function reconcile_bank_transaction($bankLine, $fileLine) { 720 | global $user,$conf; 721 | 722 | // Set conciliation 723 | $bankLine->num_releve = $this->numReleve; 724 | $bankLine->update_conciliation($user, 0); 725 | 726 | // Update value date 727 | if (is_int($bankLine->datev)){ 728 | $dateDiff = ($fileLine['datev'] - $bankLine->datev) / 24 / 3600; 729 | } else { 730 | $dateDiff = ($fileLine['datev'] - strtotime($bankLine->datev)) / 24 / 3600; 731 | } 732 | $bankLine->datev_change($bankLine->id, $dateDiff); 733 | 734 | $this->nbReconciled++; 735 | } 736 | 737 | /** 738 | * Extract negative direction token from direction key 739 | * 740 | * @param array $matches Regex matches 741 | * @return string Last separator (Effectively removing the extracted negative direction) 742 | */ 743 | private function extractNegDir(array $matches) { 744 | $this->neg_dir = $matches[1]; 745 | return substr($matches[0], -1); 746 | } 747 | } 748 | 749 | 750 | class TBankImportHistory extends TObjetStd 751 | { 752 | function __construct() 753 | { 754 | $this->set_table( MAIN_DB_PREFIX.'bankimport_history' ); 755 | 756 | $this->add_champs('num_releve',array('type'=>'varchar','length'=>50,'index'=>true)); 757 | $this->add_champs('fk_bank',array('type'=>'integer','index'=>true)); 758 | $this->add_champs('line_imported_title,line_imported_value', array('type'=>'array')); 759 | 760 | $this->_init_vars(); 761 | 762 | $this->start(); 763 | } 764 | 765 | } 766 | -------------------------------------------------------------------------------- /releve.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2013 Laurent Destailleur 4 | * Copyright (C) 2005-2013 Regis Houssin 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /** 21 | * \file htdocs/compta/bank/releve.php 22 | * \ingroup banque 23 | * \brief Page to show a bank receipt report 24 | */ 25 | 26 | require('config.php'); 27 | dol_include_once('/bankimport/class/bankimport.class.php'); 28 | dol_include_once('/compta/facture/class/facture.class.php'); 29 | dol_include_once('/fourn/class/fournisseur.facture.class.php'); 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; 31 | require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; 32 | require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; 33 | require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; 34 | require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; 35 | require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; 36 | require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; 37 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; 38 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; 39 | 40 | $langs->load("banks"); 41 | $langs->load("categories"); 42 | $langs->load("companies"); 43 | $langs->load("bills"); 44 | 45 | $action=GETPOST('action', 'alpha'); 46 | $id=GETPOST('account','int'); 47 | $ref=GETPOST('ref','alpha'); 48 | $dvid=GETPOST('dvid','int'); 49 | $num=GETPOST('num','alpha'); 50 | 51 | // Security check 52 | $fieldid = (! empty($ref)?$ref:$id); 53 | $fieldname = isset($ref)?'ref':'rowid'; 54 | $newToken = function_exists('newToken')?newToken():$_SESSION['newtoken']; 55 | $socidVersion = "socid"; 56 | if (DOL_VERSION < 13){ 57 | $socidVersion = "societe_id"; 58 | } 59 | if ($user->{$socidVersion}) $socid=$user->{$socidVersion}; 60 | 61 | $result=restrictedArea($user,'banque',$fieldid,'bank_account','','',$fieldname); 62 | 63 | if ($user->hasRight('banque', 'consolidate') && $action == 'dvnext' && ! empty($dvid)) 64 | { 65 | $al = new AccountLine($db); 66 | $al->datev_next($dvid); 67 | } 68 | 69 | if ($user->hasRight('banque', 'consolidate') && $action == 'dvprev' && ! empty($dvid)) 70 | { 71 | $al = new AccountLine($db); 72 | $al->datev_previous($dvid); 73 | } 74 | 75 | 76 | $sortfield = GETPOST('sortfield', 'alpha'); 77 | $sortorder = GETPOST('sortorder', 'alpha'); 78 | $page = GETPOST('page', 'int'); 79 | if ($page == -1 || empty($page)) { $page = 0; } 80 | if (! $sortorder) $sortorder="ASC"; 81 | if (! $sortfield) $sortfield="s.nom"; 82 | 83 | $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; 84 | $offset = ((int) $limit * $page); 85 | $pageprev = $page - 1; 86 | $pagenext = $page + 1; 87 | 88 | 89 | /* 90 | * View 91 | */ 92 | 93 | llxHeader(); 94 | 95 | $form = new Form($db); 96 | $societestatic=new Societe($db); 97 | $chargestatic=new ChargeSociales($db); 98 | $memberstatic=new Adherent($db); 99 | $paymentstatic=new Paiement($db); 100 | $paymentsupplierstatic=new PaiementFourn($db); 101 | $paymentvatstatic=new TVA($db); 102 | $bankstatic=new Account($db); 103 | $banklinestatic=new AccountLine($db); 104 | 105 | 106 | // Load account 107 | $acct = new Account($db); 108 | if ($id > 0 || ! empty($ref)) 109 | { 110 | $acct->fetch($id, $ref); 111 | } 112 | 113 | if (empty($num)) 114 | { 115 | /* 116 | * Vue liste tous releves confondus 117 | */ 118 | $sql = "SELECT DISTINCT(b.num_releve) as numr"; 119 | $sql.= " FROM ".$db->prefix()."bank as b"; 120 | $sql.= " WHERE b.fk_account = ".$acct->id; 121 | $sql.= " ORDER BY numr DESC"; 122 | 123 | $sql.= $db->plimit($conf->liste_limit+1,$offset); 124 | 125 | $result = $db->query($sql); 126 | if ($result) 127 | { 128 | $var=True; 129 | $numrows = $db->num_rows($result); 130 | $i = 0; 131 | 132 | // Onglets 133 | $head=bank_prepare_head($acct); 134 | dol_fiche_head($head,'bankimport_statement',$langs->trans("FinancialAccount"),0,'account'); 135 | 136 | print ''; 137 | 138 | $linkback = ''.$langs->trans("BackToList").''; 139 | 140 | // Ref 141 | print ''; 142 | print ''; 145 | 146 | // Label 147 | print ''; 148 | print ''; 149 | 150 | print '
'.$langs->trans("Ref").''; 143 | print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref'); 144 | print '
'.$langs->trans("Label").''.$acct->label.'
'; 151 | 152 | print '
'; 153 | 154 | 155 | print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$acct->id, $sortfield, $sortorder,'',$numrows); 156 | 157 | print ''; 158 | print ''; 159 | print ''; 160 | 161 | //while ($i < min($numrows,$conf->liste_limit)) // retrait de la limite tant qu'il n'y a pas de pagination 162 | while ($i < min($numrows,$conf->liste_limit)) 163 | { 164 | $objp = $db->fetch_object($result); 165 | $var=!$var; 166 | if (! isset($objp->numr)) 167 | { 168 | // 169 | } 170 | else 171 | { 172 | print ''."\n"; 173 | } 174 | $i++; 175 | } 176 | print "
'.$langs->trans("AccountStatement").'
'.$objp->numr.'
\n"; 177 | 178 | print "\n\n"; 179 | } 180 | else 181 | { 182 | dol_print_error($db); 183 | } 184 | } 185 | else 186 | { 187 | /** 188 | * Affiche liste ecritures d'un releve 189 | */ 190 | $ve=$_GET["ve"]; 191 | 192 | $found=false; 193 | if ($_GET["rel"] == 'prev') 194 | { 195 | // Recherche valeur pour num = numero releve precedent 196 | $sql = "SELECT DISTINCT(b.num_releve) as num"; 197 | $sql.= " FROM ".$db->prefix()."bank as b"; 198 | $sql.= " WHERE b.num_releve < '".$db->escape($num)."'"; 199 | $sql.= " AND b.fk_account = ".$acct->id; 200 | $sql.= " ORDER BY b.num_releve DESC"; 201 | 202 | dol_syslog("htdocs/compta/bank/releve.php sql=".$sql); 203 | $resql = $db->query($sql); 204 | if ($resql) 205 | { 206 | $numrows = $db->num_rows($resql); 207 | if ($numrows > 0) 208 | { 209 | $obj = $db->fetch_object($resql); 210 | $num = $obj->num; 211 | $found=true; 212 | } 213 | } 214 | } 215 | elseif ($_GET["rel"] == 'next') 216 | { 217 | // Recherche valeur pour num = numero releve precedent 218 | $sql = "SELECT DISTINCT(b.num_releve) as num"; 219 | $sql.= " FROM ".$db->prefix()."bank as b"; 220 | $sql.= " WHERE b.num_releve > '".$db->escape($num)."'"; 221 | $sql.= " AND b.fk_account = ".$acct->id; 222 | $sql.= " ORDER BY b.num_releve ASC"; 223 | 224 | dol_syslog("htdocs/compta/bank/releve.php sql=".$sql); 225 | $resql = $db->query($sql); 226 | if ($resql) 227 | { 228 | $numrows = $db->num_rows($resql); 229 | if ($numrows > 0) 230 | { 231 | $obj = $db->fetch_object($resql); 232 | $num = $obj->num; 233 | $found=true; 234 | } 235 | } 236 | } 237 | else { 238 | // On veut le releve num 239 | $found=true; 240 | } 241 | 242 | $mesprevnext ="id\">".img_previous()."  "; 243 | $mesprevnext.= $langs->trans("AccountStatement")." $num"; 244 | $mesprevnext.="   id\">".img_next().""; 245 | print_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$acct->getNomUrl(0),$mesprevnext); 246 | print '
'; 247 | 248 | print "
"; 249 | print ''; 250 | print ""; 251 | 252 | 253 | 254 | $PDOdb = new TPDOdb; 255 | 256 | /* 257 | 258 | print ''.$langs->trans("DateOperationShort").''; 259 | print ''.$langs->trans("DateValueShort").''; 260 | print ''.$langs->trans("Type").''; 261 | print ''.$langs->trans("Description").''; 262 | print ''.$langs->trans("Debit").''; 263 | print ''.$langs->trans("Credit").''; 264 | print ''.$langs->trans("Balance").''; 265 | print ' '; 266 | print "\n"; 267 | */ 268 | // Calcul du solde de depart du releve 269 | $sql = "SELECT sum(b.amount) as amount"; 270 | $sql.= " FROM ".$db->prefix()."bank as b"; 271 | $sql.= " WHERE b.num_releve < '".$db->escape($num)."'"; 272 | $sql.= " AND b.fk_account = ".$acct->id; 273 | 274 | $resql=$db->query($sql); 275 | if ($resql) 276 | { 277 | $obj=$db->fetch_object($resql); 278 | $total = $obj->amount; 279 | $db->free($resql); 280 | } 281 | 282 | 283 | $TEcriture = array(); 284 | 285 | // Recherche les ecritures pour le releve 286 | $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; 287 | $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; 288 | $sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel, bih.rowid AS historyId, bih.line_imported_title, bih.line_imported_value"; 289 | $sql.= " FROM ".$db->prefix()."bank_account as ba"; 290 | $sql.= ", ".$db->prefix()."bank as b"; 291 | $sql.= " LEFT JOIN ".$db->prefix()."bankimport_history bih ON (b.rowid = bih.fk_bank)"; 292 | $sql.= " WHERE b.num_releve='".$db->escape($num)."'"; 293 | if (!isset($num)) $sql.= " OR b.num_releve is null"; 294 | $sql.= " AND b.fk_account = ".$acct->id; 295 | $sql.= " AND b.fk_account = ba.rowid"; 296 | $sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day 297 | 298 | $result = $db->query($sql); 299 | if ($result) 300 | { 301 | while ($objp = $db->fetch_object($result)) 302 | { 303 | $TEcriture[$objp->line_imported_title][] = $objp; 304 | } 305 | } 306 | $db->free($result); 307 | 308 | if (!empty($TEcriture)) 309 | { 310 | $var=true; 311 | 312 | $solde_initial = $total; 313 | foreach ($TEcriture as $title_serialize => $TObjp) 314 | { 315 | printTableHeader($title_serialize, $solde_initial, $acct->id); 316 | $totald = $totalc = 0; 317 | 318 | foreach ($TObjp as $objp) 319 | { 320 | $var=!$var; 321 | $total = $total + $objp->amount; 322 | 323 | print ""; 324 | 325 | // History 326 | $bankImportHistory = new TBankImportHistory; 327 | $bankImportHistory->load($PDOdb, $objp->historyId); 328 | if ($bankImportHistory->getId() > 0) 329 | { 330 | foreach ($bankImportHistory->line_imported_value as $val) 331 | { 332 | print ''.$val.''; 333 | } 334 | } 335 | 336 | printStandardValues($db, $user, $langs, $acct, $objp, $num, $totald, $totalc, $paymentsupplierstatic, $paymentstatic, $paymentvatstatic, $bankstatic, $banklinestatic); 337 | 338 | print ''; 339 | } 340 | 341 | $solde_initial = $total; 342 | printTableFooter($title_serialize, $totald, $totalc, $total); 343 | } 344 | } 345 | else 346 | { 347 | print '
'.$langs->trans('bankImportNoReccordFound').'
'; 348 | } 349 | 350 | 351 | /*dol_syslog("sql=".$sql); 352 | $result = $db->query($sql); 353 | if ($result) 354 | { 355 | $var=True; 356 | $numrows = $db->num_rows($result); 357 | $i = 0; 358 | 359 | // Ligne Solde debut releve 360 | print "id."\"> "; 361 | print "".$langs->trans("InitialBankBalance")." :".price($total)." \n"; 362 | 363 | while ($i < $numrows) 364 | { 365 | $objp = $db->fetch_object($result); 366 | $total = $total + $objp->amount; 367 | 368 | 369 | $var=!$var; 370 | print ""; 371 | 372 | // Date operation 373 | print ''.dol_print_date($db->jdate($objp->do),"day").''; 374 | 375 | // Date de valeur 376 | print ''; 377 | print ''; 378 | print img_previous().' '; 379 | print dol_print_date($db->jdate($objp->dv),"day") .' '; 380 | print ''; 381 | print img_next().''; 382 | print "\n"; 383 | 384 | // Type and num 385 | if ($objp->fk_type == 'SOLD') { 386 | $type_label=' '; 387 | } else { 388 | $type_label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; 389 | } 390 | print ''.$type_label.' '.($objp->num_chq?$objp->num_chq:'').''; 391 | 392 | // Description 393 | print ''; 394 | $reg=array(); 395 | preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction 396 | if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); 397 | else print $objp->label; 398 | print ''; 399 | 400 | /* 401 | * Ajout les liens (societe, company...) 402 | 403 | $newline=1; 404 | $links = $acct->get_url($objp->rowid); 405 | foreach($links as $key=>$val) 406 | { 407 | if (! $newline) print ' - '; 408 | else print '
'; 409 | if ($links[$key]['type']=='payment') 410 | { 411 | $paymentstatic->id=$links[$key]['url_id']; 412 | $paymentstatic->ref=$langs->trans("Payment"); 413 | print ' '.$paymentstatic->getNomUrl(1); 414 | $newline=0; 415 | } 416 | elseif ($links[$key]['type']=='payment_supplier') 417 | { 418 | $paymentsupplierstatic->id=$links[$key]['url_id']; 419 | $paymentsupplierstatic->ref=$langs->trans("Payment");; 420 | print ' '.$paymentsupplierstatic->getNomUrl(1); 421 | $newline=0; 422 | } 423 | elseif ($links[$key]['type']=='payment_sc') 424 | { 425 | print ''; 426 | print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; 427 | print $langs->trans("SocialContributionPayment"); 428 | print ''; 429 | $newline=0; 430 | } 431 | elseif ($links[$key]['type']=='payment_vat') 432 | { 433 | $paymentvatstatic->id=$links[$key]['url_id']; 434 | $paymentvatstatic->ref=$langs->trans("Payment"); 435 | print ' '.$paymentvatstatic->getNomUrl(1); 436 | } 437 | elseif ($links[$key]['type']=='banktransfert') { 438 | // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. 439 | if ($objp->amount > 0) 440 | { 441 | $banklinestatic->fetch($links[$key]['url_id']); 442 | $bankstatic->id=$banklinestatic->fk_account; 443 | $bankstatic->label=$banklinestatic->bank_account_label; 444 | print ' ('.$langs->trans("from").' '; 445 | print $bankstatic->getNomUrl(1,'transactions'); 446 | print ' '.$langs->trans("toward").' '; 447 | $bankstatic->id=$objp->bankid; 448 | $bankstatic->label=$objp->bankref; 449 | print $bankstatic->getNomUrl(1,''); 450 | print ')'; 451 | } 452 | else 453 | { 454 | $bankstatic->id=$objp->bankid; 455 | $bankstatic->label=$objp->bankref; 456 | print ' ('.$langs->trans("from").' '; 457 | print $bankstatic->getNomUrl(1,''); 458 | print ' '.$langs->trans("toward").' '; 459 | $banklinestatic->fetch($links[$key]['url_id']); 460 | $bankstatic->id=$banklinestatic->fk_account; 461 | $bankstatic->label=$banklinestatic->bank_account_label; 462 | print $bankstatic->getNomUrl(1,'transactions'); 463 | print ')'; 464 | } 465 | } 466 | elseif ($links[$key]['type']=='company') { 467 | print ''; 468 | print img_object($langs->trans('ShowCustomer'),'company').' '; 469 | print dol_trunc($links[$key]['label'],24); 470 | print ''; 471 | $newline=0; 472 | } 473 | elseif ($links[$key]['type']=='member') { 474 | print ''; 475 | print img_object($langs->trans('ShowMember'),'user').' '; 476 | print $links[$key]['label']; 477 | print ''; 478 | $newline=0; 479 | } 480 | elseif ($links[$key]['type']=='sc') { 481 | print ''; 482 | print img_object($langs->trans('ShowBill'),'bill').' '; 483 | print $langs->trans("SocialContribution"); 484 | print ''; 485 | $newline=0; 486 | } 487 | else { 488 | print ''; 489 | print $links[$key]['label']; 490 | print ''; 491 | $newline=0; 492 | } 493 | } 494 | 495 | // Categories 496 | if ($ve) 497 | { 498 | $sql = "SELECT label"; 499 | $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as ct"; 500 | $sql.= ", ".MAIN_DB_PREFIX."bank_class as cl"; 501 | $sql.= " WHERE ct.rowid = cl.fk_categ"; 502 | $sql.= " AND ct.entity = ".$conf->entity; 503 | $sql.= " AND cl.lineid = ".$objp->rowid; 504 | 505 | $resc = $db->query($sql); 506 | if ($resc) 507 | { 508 | $numc = $db->num_rows($resc); 509 | $ii = 0; 510 | if ($numc && ! $newline) print '
'; 511 | while ($ii < $numc) 512 | { 513 | $objc = $db->fetch_object($resc); 514 | print "
$objc->label"; 515 | $ii++; 516 | } 517 | } 518 | else 519 | { 520 | dol_print_error($db); 521 | } 522 | } 523 | 524 | print ""; 525 | 526 | if ($objp->amount < 0) 527 | { 528 | $totald = $totald + abs($objp->amount); 529 | print ''.price($objp->amount * -1)." \n"; 530 | } 531 | else 532 | { 533 | $totalc = $totalc + abs($objp->amount); 534 | print " ".price($objp->amount)."\n"; 535 | } 536 | 537 | print "".price($total)."\n"; 538 | 539 | if ($user->rights->banque->modifier || $user->rights->banque->consolidate) 540 | { 541 | print "rowid&account=".$acct->id."\">"; 542 | print img_edit(); 543 | print ""; 544 | } 545 | else 546 | { 547 | print " "; 548 | } 549 | print ""; 550 | 551 | $i++; 552 | } 553 | $db->free($result); 554 | } 555 | */ 556 | /* 557 | // Line Total 558 | print "\n".''.$langs->trans("Total")." :".price($totald)."".price($totalc)."  "; 559 | 560 | // Line Balance 561 | print "\n ".$langs->trans("EndBankBalance")." :".price($total)." \n"; 562 | print "
\n";*/ 563 | 564 | } 565 | 566 | $db->close(); 567 | 568 | llxFooter(); 569 | 570 | function printTableHeader($title_serialize, $total, $acct_id) 571 | { 572 | global $langs; 573 | 574 | print ''; 575 | print ''; 576 | 577 | if (!empty($title_serialize)) 578 | { 579 | $TTitle = unserialize($title_serialize); 580 | foreach ($TTitle as $title) print ''; 581 | } 582 | 583 | print ''; 584 | print ''; 585 | print ''; 586 | print ''; 587 | print ''; 588 | print ''; 589 | print ''; 590 | print ''; 591 | print "\n"; 592 | 593 | // Ligne Solde debut releve 594 | print ' '; 595 | if (!empty($TTitle)) print ''; 596 | print ' 597 | 598 | '; 599 | } 600 | 601 | function printTableFooter($title_serialize, $totald, $totalc, $total) 602 | { 603 | global $langs; 604 | 605 | print ' '; 606 | 607 | if (!empty($title_serialize)) 608 | { 609 | $TTitle = unserialize($title_serialize); 610 | if (count($TTitle) > 0) print ''; 611 | } 612 | 613 | // Line Total 614 | print ' 615 | 616 | 617 | 618 | '; 619 | print ''; 620 | 621 | // Line Balance 622 | print ' '; 623 | if (!empty($TTitle)) print ''; 624 | print ' 625 | 626 | 627 | '; 628 | print ''; 629 | 630 | print '
'.$title.''.$langs->trans("DateOperationShort").''.$langs->trans("DateValueShort").''.$langs->trans("Type").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").' 
 '.$langs->trans("InitialBankBalance").' :'.price($total).' 
'.$langs->trans("Total").' :'.price($totald).''.price($totalc).'  
 '.$langs->trans("EndBankBalance").' :'.price($total).' 
'; 631 | } 632 | 633 | function printStandardValues(&$db, &$user, &$langs, &$acct, &$objp, &$num, &$totald, &$totalc, &$paymentsupplierstatic, &$paymentstatic, &$paymentvatstatic, &$bankstatic, &$banklinestatic) 634 | { 635 | // Date operation 636 | print ''.dol_print_date($db->jdate($objp->do),"day").''; 637 | 638 | // Date de valeur 639 | print ''; 640 | print ''; 641 | print img_previous().' '; 642 | print dol_print_date($db->jdate($objp->dv),"day") .' '; 643 | print ''; 644 | print img_next().''; 645 | print "\n"; 646 | 647 | // Type and num 648 | if ($objp->fk_type == 'SOLD') { 649 | $type_label=' '; 650 | } else { 651 | $type_label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; 652 | } 653 | print ''.$type_label.' '.($objp->num_chq?$objp->num_chq:'').''; 654 | 655 | // Description 656 | $bankLineUrl = DOL_URL_ROOT.'/compta/bank/line.php'; 657 | if(version_compare(DOL_VERSION , '13.0.0', '<')){ 658 | $bankLineUrl = DOL_URL_ROOT.'/compta/bank/ligne.php'; 659 | } 660 | 661 | print ''; 662 | $reg=array(); 663 | preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction 664 | if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); 665 | else print $objp->label; 666 | print ''; 667 | 668 | /* 669 | * Ajout les liens (societe, company...) 670 | */ 671 | 672 | $newline=1; 673 | $links = $acct->get_url($objp->rowid); 674 | if(!empty($links)){ 675 | foreach($links as $key=>$val) 676 | { 677 | if (! $newline) print ' - '; 678 | else print '
'; 679 | if ($links[$key]['type']=='payment') 680 | { 681 | $paymentstatic->id=$links[$key]['url_id']; 682 | $paymentstatic->ref=$langs->trans("Payment"); 683 | 684 | print '
'.$paymentstatic->getNomUrl(1); 685 | 686 | $sql = "SELECT pf.fk_facture 687 | FROM ".$db->prefix()."paiement_facture as pf 688 | LEFT JOIN ".$db->prefix()."paiement as p ON (p.rowid = pf.fk_paiement) 689 | WHERE p.rowid = ".$paymentstatic->id; 690 | $resql = $db->query($sql); 691 | $res = $db->fetch_object($resql); 692 | if ($res) 693 | { 694 | $facture = new Facture($db); 695 | $facture->fetch($res->fk_facture); 696 | //if ($facture->id > 0) print '
'.$facture->getNomUrl(1); La facture sera maintenant affichée par la fonction getListFacture() en dessous 697 | } 698 | 699 | $newline=0; 700 | } 701 | elseif ($links[$key]['type']=='payment_supplier') 702 | { 703 | $paymentsupplierstatic->id=$links[$key]['url_id']; 704 | $paymentsupplierstatic->ref=$langs->trans("Payment"); 705 | 706 | print '
'.$paymentsupplierstatic->getNomUrl(1); 707 | 708 | $sql = "SELECT pf.fk_facturefourn 709 | FROM ".$db->prefix()."paiementfourn_facturefourn as pf 710 | LEFT JOIN " . $db->prefix() . "paiementfourn as p ON (p.rowid = pf.fk_paiementfourn) 711 | WHERE p.rowid = ".$paymentsupplierstatic->id; 712 | $resql = $db->query($sql); 713 | $res = $db->fetch_object($resql); 714 | if ($res) 715 | { 716 | $facture = new FactureFournisseur($db); 717 | $facture->fetch($res->fk_facturefourn); 718 | //if ($facture->id > 0) print '
'.$facture->getNomUrl(1); La facture sera maintenant affichée par la fonction getListFacture() en dessous 719 | } 720 | 721 | $newline=0; 722 | } 723 | elseif ($links[$key]['type']=='payment_sc') 724 | { 725 | print ''; 726 | print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; 727 | print $langs->trans("SocialContributionPayment"); 728 | print ''; 729 | $newline=0; 730 | } 731 | elseif ($links[$key]['type']=='payment_vat') 732 | { 733 | $paymentvatstatic->id=$links[$key]['url_id']; 734 | $paymentvatstatic->ref=$langs->trans("Payment"); 735 | print ' '.$paymentvatstatic->getNomUrl(1); 736 | } 737 | elseif ($links[$key]['type']=='banktransfert') { 738 | // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. 739 | if ($objp->amount > 0) 740 | { 741 | $banklinestatic->fetch($links[$key]['url_id']); 742 | $bankstatic->id=$banklinestatic->fk_account; 743 | $bankstatic->label=$banklinestatic->bank_account_label; 744 | print ' ('.$langs->trans("from").' '; 745 | print $bankstatic->getNomUrl(1,'transactions'); 746 | print ' '.$langs->trans("toward").' '; 747 | $bankstatic->id=$objp->bankid; 748 | $bankstatic->label=$objp->bankref; 749 | print $bankstatic->getNomUrl(1,''); 750 | print ')'; 751 | } 752 | else 753 | { 754 | $bankstatic->id=$objp->bankid; 755 | $bankstatic->label=$objp->bankref; 756 | print ' ('.$langs->trans("from").' '; 757 | print $bankstatic->getNomUrl(1,''); 758 | print ' '.$langs->trans("toward").' '; 759 | $banklinestatic->fetch($links[$key]['url_id']); 760 | $bankstatic->id=$banklinestatic->fk_account; 761 | $bankstatic->label=$banklinestatic->bank_account_label; 762 | print $bankstatic->getNomUrl(1,'transactions'); 763 | print ')'; 764 | } 765 | } 766 | elseif ($links[$key]['type']=='company') { 767 | print ''; 768 | print img_object($langs->trans('ShowCustomer'),'company').' '; 769 | print dol_trunc($links[$key]['label'],24); 770 | print ''; 771 | $newline=0; 772 | } 773 | elseif ($links[$key]['type']=='member') { 774 | print ''; 775 | print img_object($langs->trans('ShowMember'),'user').' '; 776 | print $links[$key]['label']; 777 | print ''; 778 | $newline=0; 779 | } 780 | elseif ($links[$key]['type']=='sc') { 781 | print ''; 782 | print img_object($langs->trans('ShowBill'),'bill').' '; 783 | print $langs->trans("SocialContribution"); 784 | print ''; 785 | $newline=0; 786 | } 787 | else { 788 | print ''; 789 | print $links[$key]['label']; 790 | print ''; 791 | $newline=0; 792 | } 793 | } 794 | 795 | 796 | if($links[key($links)]['type']=='payment_supplier') $param = 'fourn'; 797 | print '
'.getListFacture($links[key($links)]['url_id'], $param); 798 | 799 | } 800 | // Avec la nouvelle version de bankimport, on peut régler des factures de différents tiers avec un même paiement, donc on les affiche toutes 801 | 802 | 803 | // Categories 804 | if ($ve) 805 | { 806 | $sql = "SELECT label"; 807 | $sql.= " FROM ". $db->prefix() ."bank_categ as ct"; 808 | if(version_compare(DOL_VERSION , '21.0.0', '<')) { 809 | $sql .= ", " . $db->prefix() . "bank_class as cl"; 810 | }else { 811 | $sql .= ", " . $db->prefix() . "category_bankline as cl"; 812 | } 813 | $sql.= " WHERE ct.rowid = cl.fk_categ"; 814 | $sql.= " AND ct.entity = ".$conf->entity; 815 | $sql.= " AND cl.lineid = ".$objp->rowid; 816 | 817 | $resc = $db->query($sql); 818 | if ($resc) 819 | { 820 | $numc = $db->num_rows($resc); 821 | $ii = 0; 822 | if ($numc && ! $newline) print '
'; 823 | while ($ii < $numc) 824 | { 825 | $objc = $db->fetch_object($resc); 826 | print "
$objc->label"; 827 | $ii++; 828 | } 829 | } 830 | else 831 | { 832 | dol_print_error($db); 833 | } 834 | } 835 | 836 | print ""; 837 | 838 | if ($objp->amount < 0) 839 | { 840 | $totald = $totald + abs($objp->amount); 841 | print ''.price($objp->amount * -1)." \n"; 842 | } 843 | else 844 | { 845 | $totalc = $totalc + abs($objp->amount); 846 | print " ".price($objp->amount)."\n"; 847 | } 848 | 849 | print "".price($total)."\n"; 850 | 851 | if ($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) 852 | { 853 | // Description 854 | $bankLineUrl = DOL_URL_ROOT.'/compta/bank/line.php'; 855 | if(version_compare(DOL_VERSION , '11.0.0', '<')){ 856 | $bankLineUrl = DOL_URL_ROOT.'/compta/bank/ligne.php'; 857 | } 858 | 859 | print ''; 860 | print img_edit(); 861 | print ""; 862 | } 863 | else 864 | { 865 | print " "; 866 | } 867 | } 868 | 869 | /** 870 | * @param $id_regelement : numéro du paiement 871 | * @param $fourn : contient chaine vide ou "fourn", parce que s'il s'agit d'un paiement fournisseur, 872 | * la table s'appelle llx_paiementfourn_facturefourn 873 | */ 874 | function getListFacture($id_reglement, $fourn='') { 875 | 876 | global $db; 877 | 878 | $sql = 'SELECT pf.fk_facture'.$fourn; 879 | // empty($fourn) = Spécificité pour les factures clients 880 | if(empty($fourn)) $sql.= ', rem.fk_facture as fac_finale'; 881 | $sql.= ' FROM ' . $db->prefix() . 'paiement'.$fourn.'_facture'.$fourn.' as pf'; 882 | if(empty($fourn)) $sql.= ' LEFT JOIN ' . $db->prefix() . 'societe_remise_except as rem ON (pf.fk_facture = rem.fk_facture_source)'; 883 | $sql.= ' WHERE fk_paiement'.$fourn.' = '.$id_reglement; 884 | //echo $sql;exit; 885 | $resql = $db->query($sql); 886 | 887 | $Tfact = array(); 888 | 889 | $classname = 'Facture'; 890 | if (!empty($fourn)) $classname = 'FactureFournisseur'; 891 | 892 | while($res = $db->fetch_object($resql)) { 893 | 894 | $f = new $classname($db); 895 | if($f->fetch($res->{'fk_facture'.$fourn}) > 0) { 896 | 897 | // On affiche la facture finale s'il s'agit d'un acompte 898 | $suite = ''; 899 | if(empty($fourn) && !empty($res->fac_finale)) { 900 | $fac_finale = new Facture($db); 901 | $fac_finale->fetch($res->fac_finale); 902 | $suite = ' / '.$fac_finale->getNomUrl(1); 903 | } 904 | 905 | $Tfact[] = $f->getNomURL(1).$suite; 906 | } 907 | } 908 | 909 | return implode('
', $Tfact); 910 | 911 | } 912 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | --------------------------------------------------------------------------------