├── .gitignore ├── config.php ├── img ├── lcr.png ├── ATM_logo.jpg ├── object_lcr.png └── Dolibarr_Preferred_Partner_logo.png ├── script └── create-maj-base.php ├── ChangeLog.md ├── README ├── config.default.php ├── langs ├── en_US │ └── lcr.lang └── fr_FR │ └── lcr.lang ├── class └── actions_lcr.class.php ├── admin ├── lcr_about.php └── lcr_setup.php ├── core ├── boxes │ └── lcr_box.php ├── modules │ ├── lcr │ │ ├── modules_lcr.php │ │ └── doc │ │ │ └── pdf_generic_lcr.modules.php │ └── modlcr.class.php └── triggers │ └── interface_99_modlcr_lcrtrigger.class.php ├── lib └── lcr.lib.php └── lcr.php /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings/* 3 | .buildpath 4 | /nbproject -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | init_db_by_vars($PDOdb); 23 | */ 24 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | ## [Unreleased] 5 | - NEW : Compat V21 6 | + Fixed LCR fusion generation - **04/07/2025** - 3.3 7 | 8 | ## Version 3.1 9 | - FIX : Correction phpmin en 7 - *05/09/2024* - 3.2 10 | - FIX : Correction du phpmin - *05/09/2024* - 3.1.1 11 | - NEW : Comapt V19 - *24/08/2024* - 3.1.0 12 | 13 | ## Version 3.0 14 | - FIX : Ajout Changelog - *16/02/2024* - 3.0.2 15 | 16 | ## Version 2.0 17 | ## Version 1.0 18 | 19 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 ATM Consulting 3 | * 4 | * This program and files/directory inner it is free software: you can 5 | * redistribute it and/or modify it under the terms of the 6 | * 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 | -------------------------------------------------------------------------------- /config.default.php: -------------------------------------------------------------------------------- 1 | trans('AbricotNotFound'). ' : Abricot'; 27 | exit; 28 | } 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /langs/en_US/lcr.lang: -------------------------------------------------------------------------------- 1 | Module104940Name = lcr 2 | Module104940Desc = lcr Descripion 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 | lcrSetup = lcr module setup 7 | lcrAbout = About lcr 8 | 9 | LCR_ERROROPENFILE = Iunable to open file 10 | LCR_ERRORCREATFILE = unable to create file %s 11 | LCR_GENERATEFILE = Generate LCR Files 12 | LCR_FUSIONLCR = Fusion LCR 13 | LCR_SELECTINVOICE = Could you choose one invoice 14 | -------------------------------------------------------------------------------- /class/actions_lcr.class.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 class/actions_lcr.class.php 21 | * \ingroup lcr 22 | * \brief This file is an example hook overload class file 23 | * Put some comments here 24 | */ 25 | 26 | /** 27 | * Class Actionslcr 28 | */ 29 | class Actionslcr 30 | { 31 | /** 32 | * @var array Hook results. Propagated to $hookmanager->resArray for later reuse 33 | */ 34 | public $results = array(); 35 | 36 | /** 37 | * @var string String displayed by executeHook() immediately after return 38 | */ 39 | public $resprints; 40 | 41 | /** 42 | * @var array Errors 43 | */ 44 | public $errors = array(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /langs/fr_FR/lcr.lang: -------------------------------------------------------------------------------- 1 | Module104940Name = LCR 2 | Module104940Desc = Module de gestion des traites (LCR). Il permet la génération de pdf avec une ou plusieurs LCR par page. Il permet aussi la génération d'un fichier CSV 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 | lcrSetup = Configuration du module lcr 7 | lcrAbout = A propos du module lcr 8 | lcrMenuTitle = Gestion des LCR 9 | lcrTitle = Factures clients mode règlement "LCR" 10 | 11 | lcr_generateOneLcrPerPageWithAddress=Générer 1 seul LCR par page avec entête de facture (sinon impression de 3 LCR par page) 12 | lcr_useRestToPay=Reprendre uniquement le reste à payer 13 | lcr_paiementMode=Mode de règlement sur lequel la liste de factures est filtrée 14 | LCR_ERROROPENFILE = Impossible d'ouvrir le fichier 15 | LCR_ERRORCREATFILE = Impossible de créer le fichier %s 16 | LCR_GENERATEFILE = Fichier LCR générés 17 | LCR_FUSIONLCR = Fusion LCR 18 | LCR_SELECTINVOICE = Veuillez sélectioner au moins une facture. 19 | -------------------------------------------------------------------------------- /admin/lcr_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 lcr 22 | * \brief This file is an example about page 23 | * Put some comments here 24 | */ 25 | // Dolibarr environment 26 | $res = @include("../../main.inc.php"); // From htdocs directory 27 | if (! $res) { 28 | $res = @include("../../../main.inc.php"); // From "custom" directory 29 | } 30 | 31 | // Libraries 32 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 33 | require_once '../lib/lcr.lib.php'; 34 | 35 | // Translations 36 | $langs->load("lcr@lcr"); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | /* 44 | * View 45 | */ 46 | $page_name = "lcrAbout"; 47 | llxHeader('', $langs->trans($page_name)); 48 | 49 | // Subheader 50 | $linkback = '' 51 | . $langs->trans("BackToModuleList") . ''; 52 | print_fiche_titre($langs->trans($page_name), $linkback); 53 | 54 | // Configuration header 55 | $head = lcrAdminPrepareHead(); 56 | dol_fiche_head( 57 | $head, 58 | 'about', 59 | $langs->trans("Module104940Name"), 60 | 0, 61 | 'lcr@lcr' 62 | ); 63 | 64 | // About page goes here 65 | print '
'; 66 | print '
'.$langs->trans('ATMAbout').'
'; 67 | 68 | dol_fiche_end(); 69 | 70 | print '
'; 71 | print ''; 72 | print '
'; 73 | 74 | llxFooter(); 75 | 76 | $db->close(); -------------------------------------------------------------------------------- /core/boxes/lcr_box.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 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 core/boxes/mybox.php 21 | * \ingroup lcr 22 | * \brief This file is a sample box definition file 23 | * Put some comments here 24 | */ 25 | include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; 26 | 27 | /** 28 | * Class to manage the box 29 | */ 30 | class lcrbox extends ModeleBoxes 31 | { 32 | 33 | public $boxcode = "mybox"; 34 | public $boximg = "lcr@lcr"; 35 | public $boxlabel; 36 | public $depends = array("lcr"); 37 | public $db; 38 | public $param; 39 | public $info_box_head = array(); 40 | public $info_box_contents = array(); 41 | 42 | /** 43 | * Constructor 44 | */ 45 | public function __construct() 46 | { 47 | global $langs; 48 | $langs->load("boxes"); 49 | 50 | $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); 51 | } 52 | 53 | /** 54 | * Load data into info_box_contents array to show array later. 55 | * 56 | * @param int $max Maximum number of records to load 57 | * @return void 58 | */ 59 | public function loadBox($max = 5) 60 | { 61 | global $conf, $user, $langs, $db; 62 | 63 | $this->max = $max; 64 | 65 | //include_once DOL_DOCUMENT_ROOT . "/lcr/class/lcr.class.php"; 66 | 67 | $text = $langs->trans("MyBoxDescription", $max); 68 | $this->info_box_head = array( 69 | 'text' => $text, 70 | 'limit' => dol_strlen($text) 71 | ); 72 | 73 | $this->info_box_contents[0][0] = array('td' => 'align="left"', 74 | 'text' => $langs->trans("MyBoxContent")); 75 | } 76 | 77 | /** 78 | * Method to show box 79 | * 80 | * @param array $head Array with properties of box title 81 | * @param array $contents Array with properties of box lines 82 | * @return void 83 | */ 84 | public function showBox($head = null, $contents = null) 85 | { 86 | parent::showBox($this->info_box_head, $this->info_box_contents); 87 | } 88 | } -------------------------------------------------------------------------------- /lib/lcr.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/lcr.lib.php 21 | * \ingroup lcr 22 | * \brief This file is an example module library 23 | * Put some comments here 24 | */ 25 | 26 | function lcrPrepareHead() 27 | { 28 | global $langs, $conf; 29 | 30 | $langs->load("lcr@lcr"); 31 | 32 | $h = 0; 33 | $head = array(); 34 | 35 | $head[$h][0] = dol_buildpath("/lcr/lcr.php", 1); 36 | $head[$h][1] = $langs->trans("LCR"); 37 | $head[$h][2] = 'lcr'; 38 | $h++; 39 | 40 | // Show more tabs from modules 41 | // Entries must be declared in modules descriptor with line 42 | //$this->tabs = array( 43 | // 'entity:+tabname:Title:@lcr:/lcr/mypage.php?id=__ID__' 44 | //); // to add new tab 45 | //$this->tabs = array( 46 | // 'entity:-tabname:Title:@lcr:/lcr/mypage.php?id=__ID__' 47 | //); // to remove a tab 48 | complete_head_from_modules($conf, $langs, null, $head, $h, 'lcr'); 49 | 50 | return $head; 51 | } 52 | 53 | function lcrAdminPrepareHead() 54 | { 55 | global $langs, $conf; 56 | 57 | $langs->load("lcr@lcr"); 58 | 59 | $h = 0; 60 | $head = array(); 61 | 62 | $head[$h][0] = dol_buildpath("/lcr/admin/lcr_setup.php", 1); 63 | $head[$h][1] = $langs->trans("Parameters"); 64 | $head[$h][2] = 'settings'; 65 | $h++; 66 | $head[$h][0] = dol_buildpath("/lcr/admin/lcr_about.php", 1); 67 | $head[$h][1] = $langs->trans("About"); 68 | $head[$h][2] = 'about'; 69 | $h++; 70 | 71 | // Show more tabs from modules 72 | // Entries must be declared in modules descriptor with line 73 | //$this->tabs = array( 74 | // 'entity:+tabname:Title:@lcr:/lcr/mypage.php?id=__ID__' 75 | //); // to add new tab 76 | //$this->tabs = array( 77 | // 'entity:-tabname:Title:@lcr:/lcr/mypage.php?id=__ID__' 78 | //); // to remove a tab 79 | complete_head_from_modules($conf, $langs, null, $head, $h, 'lcr'); 80 | 81 | return $head; 82 | } 83 | 84 | function generateCSV() { 85 | 86 | global $db, $conf; 87 | 88 | $TFactRef = $_REQUEST['toGenerate']; 89 | 90 | // Création et attribution droits fichier 91 | $dir = $conf->lcr->dir_output; 92 | if (!is_dir($dir)) { 93 | mkdir($dir); 94 | } 95 | $filename = 'lcr_'.date('YmdHis').'.csv'; 96 | $f = fopen($dir.'/'.$filename, 'w+'); 97 | chmod($dir.'/'.$filename, 0777); 98 | 99 | $TTitle = array( 100 | 'Code client' 101 | ,'Raison sociale' 102 | ,'Adresse 1' 103 | ,'Adresse 2' 104 | ,'Code postal' 105 | ,'Ville' 106 | ,'Téléphone' 107 | ,'Référence' 108 | ,'SIREN' 109 | ,'RIB' 110 | ,'Agence' 111 | ,'Montant' 112 | ,'Monnaie' 113 | ,'Accepté' 114 | ,'Référence' 115 | ,'Date de création' 116 | ,'Date d\'échéance' 117 | ); 118 | 119 | fputcsv($f, $TTitle, ';'); 120 | 121 | $fact = new Facture($db); 122 | $s = new Societe($db); 123 | 124 | foreach($TFactRef as $ref_fact) { 125 | 126 | if($fact->fetch('', $ref_fact) > 0 && $s->fetch($fact->socid) > 0) { 127 | 128 | $rib = $s->get_all_rib(); 129 | $iban=''; 130 | if(!empty($rib)) { 131 | $iban = $rib[0]->iban; 132 | foreach($rib as $i_rib=>&$obj_rib) { 133 | if(!empty($obj_rib->default_rib)) { 134 | $iban = $obj_rib->iban; 135 | break; 136 | } 137 | } 138 | } 139 | 140 | $total_facture = $fact->total_ttc; 141 | $total_facture -= $fact->getSumCreditNotesUsed(); 142 | $total_facture -= $fact->getSumDepositsUsed(); 143 | 144 | fputcsv( 145 | $f 146 | ,array( 147 | $s->code_client 148 | ,$s->name 149 | ,$s->address 150 | ,'' // Adresse 2 151 | ,$s->zip 152 | ,$s->town 153 | ,$s->phone 154 | ,$ref_fact 155 | ,$s->idprof1 156 | ,$iban 157 | ,'' // Agence 158 | ,price($total_facture-$fact->getSommePaiement()) 159 | ,'E' 160 | ,1 161 | ,$ref_fact 162 | ,date('d/m/Y', $fact->date) 163 | ,date('d/m/Y', $fact->date_lim_reglement) 164 | ) 165 | , ';' 166 | ); 167 | } 168 | 169 | } 170 | 171 | fclose($f); 172 | 173 | } 174 | -------------------------------------------------------------------------------- /admin/lcr_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/lcr.php 21 | * \ingroup lcr 22 | * \brief This file is an example module setup page 23 | * Put some comments here 24 | */ 25 | // Dolibarr environment 26 | $res = @include("../../main.inc.php"); // From htdocs directory 27 | if (! $res) { 28 | $res = @include("../../../main.inc.php"); // From "custom" directory 29 | } 30 | 31 | // Libraries 32 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 33 | require_once '../lib/lcr.lib.php'; 34 | 35 | // Translations 36 | $langs->load("lcr@lcr"); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | // Parameters 44 | $action = GETPOST('action', 'alpha'); 45 | 46 | /* 47 | * Actions 48 | */ 49 | if (preg_match('/set_(.*)/',$action,$reg)) 50 | { 51 | $code=$reg[1]; 52 | if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) 53 | { 54 | header("Location: ".$_SERVER["PHP_SELF"]); 55 | exit; 56 | } 57 | else 58 | { 59 | dol_print_error($db); 60 | } 61 | } 62 | 63 | if (preg_match('/del_(.*)/',$action,$reg)) 64 | { 65 | $code=$reg[1]; 66 | if (dolibarr_del_const($db, $code, 0) > 0) 67 | { 68 | Header("Location: ".$_SERVER["PHP_SELF"]); 69 | exit; 70 | } 71 | else 72 | { 73 | dol_print_error($db); 74 | } 75 | } 76 | 77 | /* 78 | * View 79 | */ 80 | $page_name = "lcrSetup"; 81 | llxHeader('', $langs->trans($page_name)); 82 | 83 | // Subheader 84 | $linkback = '' 85 | . $langs->trans("BackToModuleList") . ''; 86 | print_fiche_titre($langs->trans($page_name), $linkback); 87 | 88 | // Configuration header 89 | $head = lcrAdminPrepareHead(); 90 | dol_fiche_head( 91 | $head, 92 | 'settings', 93 | $langs->trans("Module104940Name"), 94 | 0, 95 | "lcr@lcr" 96 | ); 97 | 98 | // Setup page goes here 99 | $form=new Form($db); 100 | $var=false; 101 | print ''; 102 | print ''; 103 | print ''."\n"; 104 | print ''; 105 | print ''."\n"; 106 | 107 | 108 | // Example with a yes / no select 109 | $var=!$var; 110 | print ''; 111 | print ''; 112 | print ''; 113 | print ''; 121 | 122 | $var=!$var; 123 | print ''; 124 | print ''; 125 | print ''; 126 | print ''; 134 | 135 | $var=!$var; 136 | print ''; 137 | print ''; 138 | print ''; 139 | print ''; 147 | 148 | print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans("lcr_generateOneLcrPerPageWithAddress").' '; 114 | print '
'; 115 | print ''; 116 | print ''; 117 | print $form->selectyesno("LCR_GENERATE_ONE_PER_PAGE_WiTH_ADDRESS",getDolGlobalString('LCR_GENERATE_ONE_PER_PAGE_WiTH_ADDRESS'),1); 118 | print ''; 119 | print '
'; 120 | print '
'.$langs->trans("lcr_useRestToPay").' '; 127 | print '
'; 128 | print ''; 129 | print ''; 130 | print $form->selectyesno("LCR_USE_REST_TO_PAY",getDolGlobalInt('LCR_USE_REST_TO_PAY'),1); 131 | print ''; 132 | print '
'; 133 | print '
'.$langs->trans("lcr_paiementMode").' '; 140 | print '
'; 141 | print ''; 142 | print ''; 143 | print $form->select_types_paiements(getDolGlobalString('LCR_PAIEMENT_MODE'), 'LCR_PAIEMENT_MODE', '', 0, 0, 1); 144 | print ''; 145 | print '
'; 146 | print '
'; 149 | 150 | llxFooter(); 151 | 152 | $db->close(); 153 | -------------------------------------------------------------------------------- /core/modules/lcr/modules_lcr.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2011 Laurent Destailleur 4 | * Copyright (C) 2004 Eric Seigne 5 | * Copyright (C) 2005-2012 Regis Houssin 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * or see http://www.gnu.org/ 20 | */ 21 | 22 | /** 23 | * \file htdocs/core/modules/facture/modules_facture.php 24 | * \ingroup facture 25 | * \brief Fichier contenant la classe mere de generation des factures en PDF 26 | * et la classe mere de numerotation des factures 27 | */ 28 | 29 | require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; 30 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; 31 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent 32 | 33 | 34 | /** 35 | * Parent class of invoice document generators 36 | */ 37 | abstract class ModeleLcr extends CommonDocGenerator 38 | { 39 | var $error=''; 40 | 41 | /** 42 | * Return list of active generation modules 43 | * 44 | * @param DoliDB $db Database handler 45 | * @param string $maxfilenamelength Max length of value to show 46 | * @return array List of templates 47 | */ 48 | static function liste_modeles($db,$maxfilenamelength=0) 49 | { 50 | global $conf; 51 | 52 | $type='invoice'; 53 | $liste=array(); 54 | 55 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 56 | $liste=getListOfModels($db,$type,$maxfilenamelength); 57 | 58 | return $liste; 59 | } 60 | } 61 | 62 | if((float)DOL_VERSION >= 8.0) {abstract class ModelePDFLcr extends ModeleLcr {}} 63 | 64 | /** 65 | * Classe mere des modeles de numerotation des references de facture 66 | */ 67 | abstract class ModeleNumRefLCR 68 | { 69 | var $error=''; 70 | 71 | /** 72 | * Return if a module can be used or not 73 | * 74 | * @return boolean true if module can be used 75 | */ 76 | function isEnabled() 77 | { 78 | return true; 79 | } 80 | 81 | /** 82 | * Renvoi la description par defaut du modele de numerotation 83 | * 84 | * @return string Texte descripif 85 | */ 86 | function info() 87 | { 88 | global $langs; 89 | $langs->load("bills"); 90 | return $langs->trans("NoDescription"); 91 | } 92 | 93 | /** 94 | * Renvoi un exemple de numerotation 95 | * 96 | * @return string Example 97 | */ 98 | function getExample() 99 | { 100 | global $langs; 101 | $langs->load("bills"); 102 | return $langs->trans("NoExample"); 103 | } 104 | 105 | /** 106 | * Test si les numeros deja en vigueur dans la base ne provoquent pas 107 | * de conflits qui empecheraient cette numerotation de fonctionner. 108 | * 109 | * @return boolean false si conflit, true si ok 110 | */ 111 | function canBeActivated() 112 | { 113 | return true; 114 | } 115 | 116 | /** 117 | * Renvoi prochaine valeur attribuee 118 | * 119 | * @param Societe $objsoc Objet societe 120 | * @param Facture $facture Objet facture 121 | * @return string Value 122 | */ 123 | function getNextValue($objsoc,$facture) 124 | { 125 | global $langs; 126 | return $langs->trans("NotAvailable"); 127 | } 128 | 129 | /** 130 | * Renvoi version du modele de numerotation 131 | * 132 | * @return string Valeur 133 | */ 134 | function getVersion() 135 | { 136 | global $langs; 137 | $langs->load("admin"); 138 | 139 | if ($this->version == 'development') return $langs->trans("VersionDevelopment"); 140 | if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); 141 | if ($this->version == 'dolibarr') return DOL_VERSION; 142 | return $langs->trans("NotAvailable"); 143 | } 144 | } 145 | 146 | 147 | /** 148 | * Create a document onto disk according to template module. 149 | * 150 | * @param DoliDB $db Database handler 151 | * @param Object $object Object invoice 152 | * @param string $modele Force template to use ('' to not force) 153 | * @param Translate $outputlangs objet lang a utiliser pour traduction 154 | * @param int $hidedetails Hide details of lines 155 | * @param int $hidedesc Hide description 156 | * @param int $hideref Hide ref 157 | * @return int <0 if KO, >0 if OK 158 | */ 159 | function lcr_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, &$TtoGenerate) 160 | { 161 | global $conf,$user,$langs; 162 | 163 | $langs->load("bills"); 164 | 165 | $error=0; 166 | 167 | // Increase limit for PDF build 168 | $err=error_reporting(); 169 | error_reporting(0); 170 | @set_time_limit(120); 171 | error_reporting($err); 172 | 173 | $srctemplatepath=''; 174 | 175 | // Positionne le modele sur le nom du modele a utiliser 176 | if (! dol_strlen($modele)) 177 | { 178 | if (getDolGlobalString('FACTURE_ADDON_PDF')) 179 | { 180 | $modele = getDolGlobalString('FACTURE_ADDON_PDF'); 181 | } 182 | else 183 | { 184 | $modele = 'crabe'; 185 | } 186 | } 187 | 188 | // If selected modele is a filename template (then $modele="modelname:filename") 189 | $tmp=explode(':',$modele,2); 190 | if (! empty($tmp[1])) 191 | { 192 | $modele=$tmp[0]; 193 | $srctemplatepath=$tmp[1]; 194 | } 195 | 196 | // Search template files 197 | $file=''; $classname=''; $filefound=0; 198 | $dirmodels=array('/'); 199 | if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); 200 | foreach($dirmodels as $reldir) 201 | { 202 | foreach(array('doc','pdf') as $prefix) 203 | { 204 | $file = $prefix."_".$modele.".modules.php"; 205 | 206 | // On verifie l'emplacement du modele 207 | //echo $reldir."core/modules/facture/doc/".$file.'
'; 208 | $file=dol_buildpath($reldir."core/modules/lcr/doc/".$file,0); 209 | if (file_exists($file)) 210 | { 211 | $filefound=1; 212 | $classname=$prefix.'_'.$modele; 213 | break; 214 | } 215 | } 216 | if ($filefound) break; 217 | } 218 | 219 | // Charge le modele 220 | if ($filefound) 221 | { 222 | require_once $file; 223 | 224 | $obj = new $classname($db); 225 | 226 | // Appel des triggers 227 | include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; 228 | $interface=new Interfaces($db); 229 | $result=$interface->run_triggers('BEFORE_BILL_LCR_BUILDDOC',$object,$user,$langs,$conf); 230 | if ($result < 0) { $error++; $errors=$interface->errors; } 231 | // Fin appel triggers 232 | 233 | // We save charset_output to restore it because write_file can change it if needed for 234 | // output format that does not support UTF8. 235 | $sav_charset_output=$outputlangs->charset_output; 236 | if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $TtoGenerate) > 0) 237 | { 238 | $outputlangs->charset_output=$sav_charset_output; 239 | 240 | // We delete old preview 241 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 242 | //dol_delete_preview($object); 243 | 244 | // Success in building document. We build meta file. 245 | dol_meta_create($object); 246 | 247 | // Appel des triggers 248 | include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; 249 | $interface=new Interfaces($db); 250 | $result=$interface->run_triggers('BILL_LCR_BUILDDOC',$object,$user,$langs,$conf); 251 | if ($result < 0) { $error++; $errors=$interface->errors; } 252 | // Fin appel triggers 253 | 254 | return 1; 255 | } 256 | else 257 | { 258 | $outputlangs->charset_output=$sav_charset_output; 259 | dol_print_error($db,"lcr_pdf_create Error: ".$obj->error); 260 | return -1; 261 | } 262 | 263 | } 264 | else 265 | { 266 | dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); 267 | return -1; 268 | } 269 | } 270 | 271 | -------------------------------------------------------------------------------- /core/modules/modlcr.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 lcr Module lcr 22 | * \brief Example of a module descriptor. 23 | * Such a file must be copied into htdocs/lcr/core/modules directory. 24 | * \file htdocs/lcr/core/modules/modlcr.class.php 25 | * \ingroup lcr 26 | * \brief Description and activation file for module lcr 27 | */ 28 | include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; 29 | 30 | 31 | /** 32 | * Description and activation class for module lcr 33 | */ 34 | class modlcr 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, $langs; 44 | 45 | $langs->load('lcr@lcr'); 46 | 47 | $this->db = $db; 48 | 49 | // Id for module (must be unique). 50 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). 51 | $this->numero = 104940; // 104000 to 104999 for ATM CONSULTING 52 | // Key text used to identify module (for permissions, menus, etc...) 53 | $this->rights_class = 'lcr'; 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 = "ATM Consulting"; 58 | $this->editor_name = 'ATM Consulting'; 59 | $this->editor_url = 'http://www.atm-consulting.fr/'; 60 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) 61 | $this->name = preg_replace('/^mod/i','',get_class($this)); 62 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) 63 | $this->description = "Module de gestion des traites (LCR). Il permet la génération de pdf avec une ou plusieurs LCR par page. Il permet aussi la génération d'un fichier CSV"; 64 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version 65 | $this->version = '3.1.2'; 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 = 0; 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='lcr@lcr'; 74 | 75 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) 76 | // for default path (eg: /lcr/core/xxxxx) (0=disable, 1=enable) 77 | // for specific path of parts (eg: /lcr/core/modules/barcode) 78 | // for specific css file (eg: /lcr/css/lcr.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('/lcr/css/lcr.css.php'), // Set this to relative path of css file if module has its own css file 89 | // 'js' => array('/lcr/js/lcr.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@lcr')) // Set here all workflow context managed by module 93 | // ); 94 | $this->module_parts = array('models'=>1, 'dir'=>array('output', 'lcr')); 95 | 96 | // Data directories to create when module is enabled. 97 | // Example: this->dirs = array("/lcr/temp"); 98 | $this->dirs = array(); 99 | 100 | // Config pages. Put here list of php page, stored into lcr/admin directory, to use to setup module. 101 | $this->config_page_url = array("lcr_setup.php@lcr"); 102 | 103 | // Dependencies 104 | $this->hidden = false; // A condition to hide module 105 | $this->depends = array(); // List of modules id that must be enabled if this module is enabled 106 | $this->requiredby = array(); // List of modules id to disable if this one is disabled 107 | $this->conflictwith = array(); // List of modules id this module is in conflict with 108 | $this->phpmin = array(7,0); // Minimum version of PHP required by module 109 | $this->need_dolibarr_version = array(14,0); // Minimum version of Dolibarr required by module 110 | $this->langfiles = array("lcr@lcr"); 111 | 112 | // Constants 113 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) 114 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), 115 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) 116 | // ); 117 | $this->const = array(); 118 | 119 | // Array to add new pages in new tabs 120 | // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@lcr:$user->rights->lcr->read:/lcr/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 121 | // 'objecttype:+tabname2:Title2:mylangfile@lcr:$user->rights->othermodule->read:/lcr/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 122 | // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname 123 | // where objecttype can be 124 | // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) 125 | // 'contact' to add a tab in contact view 126 | // 'contract' to add a tab in contract view 127 | // 'group' to add a tab in group view 128 | // 'intervention' to add a tab in intervention view 129 | // 'invoice' to add a tab in customer invoice view 130 | // 'invoice_supplier' to add a tab in supplier invoice view 131 | // 'member' to add a tab in fundation member view 132 | // 'opensurveypoll' to add a tab in opensurvey poll view 133 | // 'order' to add a tab in customer order view 134 | // 'order_supplier' to add a tab in supplier order view 135 | // 'payment' to add a tab in payment view 136 | // 'payment_supplier' to add a tab in supplier payment view 137 | // 'product' to add a tab in product view 138 | // 'propal' to add a tab in propal view 139 | // 'project' to add a tab in project view 140 | // 'stock' to add a tab in stock view 141 | // 'thirdparty' to add a tab in third party view 142 | // 'user' to add a tab in user view 143 | $this->tabs = array(); 144 | 145 | // Dictionaries 146 | if (! isset($conf->lcr->enabled)) 147 | { 148 | $conf->lcr=new stdClass(); 149 | $conf->lcr->enabled=0; 150 | } 151 | $this->dictionaries=array(); 152 | /* Example: 153 | if (! isset($conf->lcr->enabled)) $conf->lcr->enabled=0; // This is to avoid warnings 154 | $this->dictionaries=array( 155 | 'langs'=>'mylangfile@lcr', 156 | 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor 157 | 'tablib'=>array("Table1","Table2","Table3"), // Label of tables 158 | '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 159 | 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order 160 | 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) 161 | 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) 162 | 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) 163 | 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') 164 | 'tabcond'=>array($conf->lcr->enabled,$conf->lcr->enabled,$conf->lcr->enabled) // Condition to show each dictionary 165 | ); 166 | */ 167 | 168 | // Boxes 169 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. 170 | $this->boxes = array(); // List of boxes 171 | // Example: 172 | //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); 173 | 174 | // Permissions 175 | $this->rights = array(); // Permission array used by this module 176 | $r=0; 177 | 178 | // Add here list of permission defined by an id, a label, a boolean and two constant strings. 179 | // Example: 180 | // $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) 181 | // $this->rights[$r][1] = 'Permision label'; // Permission label 182 | // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) 183 | // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 184 | // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 185 | // $r++; 186 | $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) 187 | $this->rights[$r][1] = 'Télécharger les fichiers PDF et CSV des LCR'; // Permission label 188 | $this->rights[$r][3] = 1; // Permission by default for new user (0/1) 189 | $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 190 | $r++; 191 | 192 | 193 | // Main menu entries 194 | $this->menu = array(); // List of menus to add 195 | $r=0; 196 | 197 | // Add here entries to declare new menus 198 | // 199 | // Example to declare a new Top Menu entry and its Left menu entry: 200 | $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu='.((float)DOL_VERSION >= 7.0 ? 'billing' : 'accountancy').',fk_leftmenu=customers_bills', // Put 0 if this is a top menu 201 | 'type'=>'left', // This is a Top menu entry 202 | 'titre'=>$langs->trans('lcrMenuTitle'), 203 | 'mainmenu'=>(float)DOL_VERSION >= 7.0 ? 'billing' : 'accountancy', 204 | 'leftmenu'=>'customers_bills', 205 | 'url'=>'/lcr/lcr.php', 206 | 'langs'=>'mylangfile@lcr', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 207 | 'position'=>100, 208 | 'enabled'=>'$conf->lcr->enabled', // Define condition to show or hide menu entry. Use '$conf->concatlcr->enabled' if entry must be visible if module is enabled. 209 | 'perms'=>'1', // Use 'perms'=>'$user->rights->concatlcr->level1->level2' if you want your menu with a permission rules 210 | 'target'=>'', 211 | 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 212 | // $r++; 213 | // 214 | // Example to declare a Left Menu entry into an existing Top menu entry: 215 | // $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 216 | // 'type'=>'left', // This is a Left menu entry 217 | // 'titre'=>'lcr left menu', 218 | // 'mainmenu'=>'xxx', 219 | // 'leftmenu'=>'lcr', 220 | // 'url'=>'/lcr/pagelevel2.php', 221 | // 'langs'=>'mylangfile@lcr', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 222 | // 'position'=>100, 223 | // 'enabled'=>'$conf->lcr->enabled', // Define condition to show or hide menu entry. Use '$conf->lcr->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 224 | // 'perms'=>'1', // Use 'perms'=>'$user->rights->lcr->level1->level2' if you want your menu with a permission rules 225 | // 'target'=>'', 226 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 227 | // $r++; 228 | 229 | 230 | // Exports 231 | $r=1; 232 | 233 | // Example: 234 | // $this->export_code[$r]=$this->rights_class.'_'.$r; 235 | // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) 236 | // $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. 237 | // $this->export_permission[$r]=array(array("facture","facture","export")); 238 | // $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'); 239 | // $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'); 240 | // $this->export_sql_start[$r]='SELECT DISTINCT '; 241 | // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; 242 | // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; 243 | // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; 244 | // $this->export_sql_order[$r] .=' ORDER BY s.nom'; 245 | // $r++; 246 | } 247 | 248 | /** 249 | * Function called when module is enabled. 250 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. 251 | * It also creates data directories 252 | * 253 | * @param string $options Options when enabling module ('', 'noboxes') 254 | * @return int 1 if OK, 0 if KO 255 | */ 256 | function init($options='') 257 | { 258 | $sql = array(); 259 | 260 | define('INC_FROM_DOLIBARR',true); 261 | 262 | dol_include_once('/lcr/config.php'); 263 | dol_include_once('/lcr/script/create-maj-base.php'); 264 | 265 | $result=$this->_load_tables('/lcr/sql/'); 266 | 267 | return $this->_init($sql, $options); 268 | } 269 | 270 | /** 271 | * Function called when module is disabled. 272 | * Remove from database constants, boxes and permissions from Dolibarr database. 273 | * Data directories are not deleted 274 | * 275 | * @param string $options Options when enabling module ('', 'noboxes') 276 | * @return int 1 if OK, 0 if KO 277 | */ 278 | function remove($options='') 279 | { 280 | $sql = array(); 281 | 282 | return $this->_remove($sql, $options); 283 | } 284 | 285 | } 286 | -------------------------------------------------------------------------------- /core/triggers/interface_99_modlcr_lcrtrigger.class.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 core/triggers/interface_99_modMyodule_lcrtrigger.class.php 21 | * \ingroup lcr 22 | * \brief Sample trigger 23 | * \remarks You can create other triggers by copying this one 24 | * - File name should be either: 25 | * interface_99_modMymodule_Mytrigger.class.php 26 | * interface_99_all_Mytrigger.class.php 27 | * - The file must stay in core/triggers 28 | * - The class name must be InterfaceMytrigger 29 | * - The constructor method must be named InterfaceMytrigger 30 | * - The name property name must be Mytrigger 31 | */ 32 | 33 | /** 34 | * Trigger class 35 | */ 36 | class Interfacelcrtrigger 37 | { 38 | 39 | private $db; 40 | 41 | /** 42 | * Constructor 43 | * 44 | * @param DoliDB $db Database handler 45 | */ 46 | public function __construct($db) 47 | { 48 | $this->db = $db; 49 | 50 | $this->name = preg_replace('/^Interface/i', '', get_class($this)); 51 | $this->family = "demo"; 52 | $this->description = "Triggers of this module are empty functions." 53 | . "They have no effect." 54 | . "They are provided for tutorial purpose only."; 55 | // 'development', 'experimental', 'dolibarr' or version 56 | $this->version = 'development'; 57 | $this->picto = 'lcr@lcr'; 58 | } 59 | 60 | /** 61 | * Trigger name 62 | * 63 | * @return string Name of trigger file 64 | */ 65 | public function getName() 66 | { 67 | return $this->name; 68 | } 69 | 70 | /** 71 | * Trigger description 72 | * 73 | * @return string Description of trigger file 74 | */ 75 | public function getDesc() 76 | { 77 | return $this->description; 78 | } 79 | 80 | /** 81 | * Trigger version 82 | * 83 | * @return string Version of trigger file 84 | */ 85 | public function getVersion() 86 | { 87 | global $langs; 88 | $langs->load("admin"); 89 | 90 | if ($this->version == 'development') { 91 | return $langs->trans("Development"); 92 | } elseif ($this->version == 'experimental') 93 | 94 | return $langs->trans("Experimental"); 95 | elseif ($this->version == 'dolibarr') return DOL_VERSION; 96 | elseif ($this->version) return $this->version; 97 | else { 98 | return $langs->trans("Unknown"); 99 | } 100 | } 101 | 102 | /** 103 | * Function called when a Dolibarrr business event is done. 104 | * All functions "run_trigger" are triggered if file 105 | * is inside directory core/triggers 106 | * 107 | * @param string $action Event action code 108 | * @param Object $object Object 109 | * @param User $user Object user 110 | * @param Translate $langs Object langs 111 | * @param conf $conf Object conf 112 | * @return int <0 if KO, 0 if no triggered ran, >0 if OK 113 | */ 114 | public function run_trigger($action, $object, $user, $langs, $conf) 115 | { 116 | // Put here code you want to execute when a Dolibarr business events occurs. 117 | // Data and type of action are stored into $object and $action 118 | // Users 119 | if ($action == 'USER_LOGIN') { 120 | dol_syslog( 121 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 122 | ); 123 | } elseif ($action == 'USER_UPDATE_SESSION') { 124 | // Warning: To increase performances, this action is triggered only if 125 | // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. 126 | dol_syslog( 127 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 128 | ); 129 | } elseif ($action == 'USER_CREATE') { 130 | dol_syslog( 131 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 132 | ); 133 | } elseif ($action == 'USER_CREATE_FROM_CONTACT') { 134 | dol_syslog( 135 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 136 | ); 137 | } elseif ($action == 'USER_MODIFY') { 138 | dol_syslog( 139 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 140 | ); 141 | } elseif ($action == 'USER_NEW_PASSWORD') { 142 | dol_syslog( 143 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 144 | ); 145 | } elseif ($action == 'USER_ENABLEDISABLE') { 146 | dol_syslog( 147 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 148 | ); 149 | } elseif ($action == 'USER_DELETE') { 150 | dol_syslog( 151 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 152 | ); 153 | } elseif ($action == 'USER_LOGOUT') { 154 | dol_syslog( 155 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 156 | ); 157 | } elseif ($action == 'USER_SETINGROUP') { 158 | dol_syslog( 159 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 160 | ); 161 | } elseif ($action == 'USER_REMOVEFROMGROUP') { 162 | dol_syslog( 163 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 164 | ); 165 | } 166 | 167 | // Groups 168 | elseif ($action == 'GROUP_CREATE') { 169 | dol_syslog( 170 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 171 | ); 172 | } elseif ($action == 'GROUP_MODIFY') { 173 | dol_syslog( 174 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 175 | ); 176 | } elseif ($action == 'GROUP_DELETE') { 177 | dol_syslog( 178 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 179 | ); 180 | } 181 | 182 | // Companies 183 | elseif ($action == 'COMPANY_CREATE') { 184 | dol_syslog( 185 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 186 | ); 187 | } elseif ($action == 'COMPANY_MODIFY') { 188 | dol_syslog( 189 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 190 | ); 191 | } elseif ($action == 'COMPANY_DELETE') { 192 | dol_syslog( 193 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 194 | ); 195 | } 196 | 197 | // Contacts 198 | elseif ($action == 'CONTACT_CREATE') { 199 | dol_syslog( 200 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 201 | ); 202 | } elseif ($action == 'CONTACT_MODIFY') { 203 | dol_syslog( 204 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 205 | ); 206 | } elseif ($action == 'CONTACT_DELETE') { 207 | dol_syslog( 208 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 209 | ); 210 | } 211 | 212 | // Products 213 | elseif ($action == 'PRODUCT_CREATE') { 214 | dol_syslog( 215 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 216 | ); 217 | } elseif ($action == 'PRODUCT_MODIFY') { 218 | dol_syslog( 219 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 220 | ); 221 | } elseif ($action == 'PRODUCT_DELETE') { 222 | dol_syslog( 223 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 224 | ); 225 | } 226 | 227 | // Customer orders 228 | elseif ($action == 'ORDER_CREATE') { 229 | dol_syslog( 230 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 231 | ); 232 | } elseif ($action == 'ORDER_CLONE') { 233 | dol_syslog( 234 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 235 | ); 236 | } elseif ($action == 'ORDER_VALIDATE') { 237 | dol_syslog( 238 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 239 | ); 240 | } elseif ($action == 'ORDER_DELETE') { 241 | dol_syslog( 242 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 243 | ); 244 | } elseif ($action == 'ORDER_BUILDDOC') { 245 | dol_syslog( 246 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 247 | ); 248 | } elseif ($action == 'ORDER_SENTBYMAIL') { 249 | dol_syslog( 250 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 251 | ); 252 | } elseif ($action == 'LINEORDER_INSERT') { 253 | dol_syslog( 254 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 255 | ); 256 | } elseif ($action == 'LINEORDER_DELETE') { 257 | dol_syslog( 258 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 259 | ); 260 | } 261 | 262 | // Supplier orders 263 | elseif ($action == 'ORDER_SUPPLIER_CREATE') { 264 | dol_syslog( 265 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 266 | ); 267 | } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { 268 | dol_syslog( 269 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 270 | ); 271 | } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { 272 | dol_syslog( 273 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 274 | ); 275 | } elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') { 276 | dol_syslog( 277 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 278 | ); 279 | } 280 | 281 | // Proposals 282 | elseif ($action == 'PROPAL_CREATE') { 283 | dol_syslog( 284 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 285 | ); 286 | } elseif ($action == 'PROPAL_CLONE') { 287 | dol_syslog( 288 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 289 | ); 290 | } elseif ($action == 'PROPAL_MODIFY') { 291 | dol_syslog( 292 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 293 | ); 294 | } elseif ($action == 'PROPAL_VALIDATE') { 295 | dol_syslog( 296 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 297 | ); 298 | } elseif ($action == 'PROPAL_BUILDDOC') { 299 | dol_syslog( 300 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 301 | ); 302 | } elseif ($action == 'PROPAL_SENTBYMAIL') { 303 | dol_syslog( 304 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 305 | ); 306 | } elseif ($action == 'PROPAL_CLOSE_SIGNED') { 307 | dol_syslog( 308 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 309 | ); 310 | } elseif ($action == 'PROPAL_CLOSE_REFUSED') { 311 | dol_syslog( 312 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 313 | ); 314 | } elseif ($action == 'PROPAL_DELETE') { 315 | dol_syslog( 316 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 317 | ); 318 | } elseif ($action == 'LINEPROPAL_INSERT') { 319 | dol_syslog( 320 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 321 | ); 322 | } elseif ($action == 'LINEPROPAL_MODIFY') { 323 | dol_syslog( 324 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 325 | ); 326 | } elseif ($action == 'LINEPROPAL_DELETE') { 327 | dol_syslog( 328 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 329 | ); 330 | } 331 | 332 | // Contracts 333 | elseif ($action == 'CONTRACT_CREATE') { 334 | dol_syslog( 335 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 336 | ); 337 | } elseif ($action == 'CONTRACT_MODIFY') { 338 | dol_syslog( 339 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 340 | ); 341 | } elseif ($action == 'CONTRACT_ACTIVATE') { 342 | dol_syslog( 343 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 344 | ); 345 | } elseif ($action == 'CONTRACT_CANCEL') { 346 | dol_syslog( 347 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 348 | ); 349 | } elseif ($action == 'CONTRACT_CLOSE') { 350 | dol_syslog( 351 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 352 | ); 353 | } elseif ($action == 'CONTRACT_DELETE') { 354 | dol_syslog( 355 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 356 | ); 357 | } 358 | 359 | // Bills 360 | elseif ($action == 'BILL_CREATE') { 361 | dol_syslog( 362 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 363 | ); 364 | } elseif ($action == 'BILL_CLONE') { 365 | dol_syslog( 366 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 367 | ); 368 | } elseif ($action == 'BILL_MODIFY') { 369 | dol_syslog( 370 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 371 | ); 372 | } elseif ($action == 'BILL_VALIDATE') { 373 | dol_syslog( 374 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 375 | ); 376 | } elseif ($action == 'BILL_BUILDDOC') { 377 | dol_syslog( 378 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 379 | ); 380 | } elseif ($action == 'BILL_SENTBYMAIL') { 381 | dol_syslog( 382 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 383 | ); 384 | } elseif ($action == 'BILL_CANCEL') { 385 | dol_syslog( 386 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 387 | ); 388 | } elseif ($action == 'BILL_DELETE') { 389 | dol_syslog( 390 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 391 | ); 392 | } elseif ($action == 'LINEBILL_INSERT') { 393 | dol_syslog( 394 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 395 | ); 396 | } elseif ($action == 'LINEBILL_DELETE') { 397 | dol_syslog( 398 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 399 | ); 400 | } 401 | 402 | // Payments 403 | elseif ($action == 'PAYMENT_CUSTOMER_CREATE') { 404 | dol_syslog( 405 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 406 | ); 407 | } elseif ($action == 'PAYMENT_SUPPLIER_CREATE') { 408 | dol_syslog( 409 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 410 | ); 411 | } elseif ($action == 'PAYMENT_ADD_TO_BANK') { 412 | dol_syslog( 413 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 414 | ); 415 | } elseif ($action == 'PAYMENT_DELETE') { 416 | dol_syslog( 417 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 418 | ); 419 | } 420 | 421 | // Interventions 422 | elseif ($action == 'FICHEINTER_CREATE') { 423 | dol_syslog( 424 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 425 | ); 426 | } elseif ($action == 'FICHEINTER_MODIFY') { 427 | dol_syslog( 428 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 429 | ); 430 | } elseif ($action == 'FICHEINTER_VALIDATE') { 431 | dol_syslog( 432 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 433 | ); 434 | } elseif ($action == 'FICHEINTER_DELETE') { 435 | dol_syslog( 436 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 437 | ); 438 | } 439 | 440 | // Members 441 | elseif ($action == 'MEMBER_CREATE') { 442 | dol_syslog( 443 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 444 | ); 445 | } elseif ($action == 'MEMBER_VALIDATE') { 446 | dol_syslog( 447 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 448 | ); 449 | } elseif ($action == 'MEMBER_SUBSCRIPTION') { 450 | dol_syslog( 451 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 452 | ); 453 | } elseif ($action == 'MEMBER_MODIFY') { 454 | dol_syslog( 455 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 456 | ); 457 | } elseif ($action == 'MEMBER_NEW_PASSWORD') { 458 | dol_syslog( 459 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 460 | ); 461 | } elseif ($action == 'MEMBER_RESILIATE') { 462 | dol_syslog( 463 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 464 | ); 465 | } elseif ($action == 'MEMBER_DELETE') { 466 | dol_syslog( 467 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 468 | ); 469 | } 470 | 471 | // Categories 472 | elseif ($action == 'CATEGORY_CREATE') { 473 | dol_syslog( 474 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 475 | ); 476 | } elseif ($action == 'CATEGORY_MODIFY') { 477 | dol_syslog( 478 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 479 | ); 480 | } elseif ($action == 'CATEGORY_DELETE') { 481 | dol_syslog( 482 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 483 | ); 484 | } 485 | 486 | // Projects 487 | elseif ($action == 'PROJECT_CREATE') { 488 | dol_syslog( 489 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 490 | ); 491 | } elseif ($action == 'PROJECT_MODIFY') { 492 | dol_syslog( 493 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 494 | ); 495 | } elseif ($action == 'PROJECT_DELETE') { 496 | dol_syslog( 497 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 498 | ); 499 | } 500 | 501 | // Project tasks 502 | elseif ($action == 'TASK_CREATE') { 503 | dol_syslog( 504 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 505 | ); 506 | } elseif ($action == 'TASK_MODIFY') { 507 | dol_syslog( 508 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 509 | ); 510 | } elseif ($action == 'TASK_DELETE') { 511 | dol_syslog( 512 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 513 | ); 514 | } 515 | 516 | // Task time spent 517 | elseif ($action == 'TASK_TIMESPENT_CREATE') { 518 | dol_syslog( 519 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 520 | ); 521 | } elseif ($action == 'TASK_TIMESPENT_MODIFY') { 522 | dol_syslog( 523 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 524 | ); 525 | } elseif ($action == 'TASK_TIMESPENT_DELETE') { 526 | dol_syslog( 527 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 528 | ); 529 | } 530 | 531 | // Shipping 532 | elseif ($action == 'SHIPPING_CREATE') { 533 | dol_syslog( 534 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 535 | ); 536 | } elseif ($action == 'SHIPPING_MODIFY') { 537 | dol_syslog( 538 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 539 | ); 540 | } elseif ($action == 'SHIPPING_VALIDATE') { 541 | dol_syslog( 542 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 543 | ); 544 | } elseif ($action == 'SHIPPING_SENTBYMAIL') { 545 | dol_syslog( 546 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 547 | ); 548 | } elseif ($action == 'SHIPPING_DELETE') { 549 | dol_syslog( 550 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 551 | ); 552 | } elseif ($action == 'SHIPPING_BUILDDOC') { 553 | dol_syslog( 554 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 555 | ); 556 | } 557 | 558 | // File 559 | elseif ($action == 'FILE_UPLOAD') { 560 | dol_syslog( 561 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 562 | ); 563 | } elseif ($action == 'FILE_DELETE') { 564 | dol_syslog( 565 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 566 | ); 567 | } 568 | 569 | return 0; 570 | } 571 | } -------------------------------------------------------------------------------- /lcr.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004 Eric Seigne 4 | * Copyright (C) 2004-2014 Laurent Destailleur 5 | * Copyright (C) 2005-2012 Regis Houssin 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * Note: Page can be call with param mode=sendremind to bring feature to send 21 | * remind by emails. 22 | */ 23 | 24 | /** 25 | * \file htdocs/compta/facture/impayees.php 26 | * \ingroup facture 27 | * \brief Page to list and build liste of unpaid invoices 28 | */ 29 | 30 | require '../../main.inc.php'; 31 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 32 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; 33 | require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 35 | require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; 36 | dol_include_once('/lcr/lib/lcr.lib.php'); 37 | 38 | $langs->load("mails"); 39 | $langs->load("bills"); 40 | 41 | $id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); 42 | $action = GETPOST('action','alpha'); 43 | $option = GETPOST('option'); 44 | $mode=GETPOST('mode'); 45 | $builddoc_generatebutton=GETPOST('builddoc_generatebutton'); 46 | 47 | // Security check 48 | if (isset($user->societe_id)) $socid=$user->societe_id; 49 | $result = restrictedArea($user,'facture',$id,''); 50 | 51 | $diroutputpdf=$conf->lcr->dir_output; 52 | if ($user->hasRight('societe','client','read') || isset($socid)) $diroutputpdf.='/private/'.$user->id; // If user has no permission to see all, output dir is specific to user 53 | 54 | $resultmasssend=''; 55 | 56 | 57 | /* 58 | * Action 59 | */ 60 | 61 | // Send remind email 62 | if ($action == 'presend' && GETPOST('cancel')) 63 | { 64 | $action=''; 65 | if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind 66 | } 67 | 68 | if ($action == 'presend' && GETPOST('sendmail')) 69 | { 70 | if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind 71 | 72 | if (!isset($user->email)) 73 | { 74 | $error++; 75 | setEventMessage("NoSenderEmailDefined"); 76 | } 77 | 78 | $countToSend = count($_POST['toSend']); 79 | if (empty($countToSend)) 80 | { 81 | $error++; 82 | setEventMessage("InvoiceNotChecked","warnings"); 83 | } 84 | 85 | if (! $error) 86 | { 87 | $nbsent = 0; 88 | $nbignored = 0; 89 | 90 | for ($i = 0; $i < $countToSend; $i++) 91 | { 92 | $object = new Facture($db); 93 | $result = $object->fetch($_POST['toSend'][$i]); 94 | 95 | if ($result > 0) // Invoice was found 96 | { 97 | if ($object->statut != 1) 98 | { 99 | continue; // Payment done or started or canceled 100 | } 101 | 102 | // Read document 103 | // TODO Use future field $object->fullpathdoc to know where is stored default file 104 | // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. 105 | $filename=dol_sanitizeFileName($object->ref).'.pdf'; 106 | $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); 107 | $file = $filedir . '/' . $filename; 108 | $mime = 'application/pdf'; 109 | 110 | if (dol_is_file($file)) 111 | { 112 | $object->fetch_thirdparty(); 113 | $sendto = $object->thirdparty->email; 114 | 115 | if (empty($sendto)) $nbignored++; 116 | 117 | if (dol_strlen($sendto)) 118 | { 119 | $langs->load("commercial"); 120 | $from = $user->getFullName($langs) . ' <' . $user->email .'>'; 121 | $replyto = $from; 122 | $subject = GETPOST('subject'); 123 | $message = GETPOST('message'); 124 | $sendtocc = GETPOST('sentocc'); 125 | 126 | $substitutionarray=array( 127 | '__ID__' => $object->id, 128 | '__EMAIL__' => $object->thirdparty->email, 129 | '__CHECK_READ__' => '', 130 | //'__LASTNAME__' => $obj2->lastname, 131 | //'__FIRSTNAME__' => $obj2->firstname, 132 | '__REF__' => $object->ref, 133 | '__REFCLIENT__' => $object->thirdparty->name 134 | ); 135 | 136 | $message=make_substitutions($message, $substitutionarray); 137 | 138 | $actiontypecode='AC_FAC'; 139 | $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; 140 | if ($message) 141 | { 142 | $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; 143 | $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; 144 | $actionmsg.=$message; 145 | } 146 | 147 | // Create form object 148 | $attachedfiles=array('paths'=>array($file), 'names'=>array($filename), 'mimes'=>array($mime)); 149 | $filepath = $attachedfiles['paths']; 150 | $filename = $attachedfiles['names']; 151 | $mimetype = $attachedfiles['mimes']; 152 | 153 | // Send mail 154 | require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); 155 | $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); 156 | if ($mailfile->error) 157 | { 158 | $resultmasssend.='
'.$mailfile->error.'
'; 159 | } 160 | else 161 | { 162 | //$result=$mailfile->sendfile(); 163 | if ($result) 164 | { 165 | $resultmasssend.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " 166 | 167 | $error=0; 168 | 169 | // Initialisation donnees 170 | $object->sendtoid = 0; 171 | $object->actiontypecode = $actiontypecode; 172 | $object->actionmsg = $actionmsg; // Long text 173 | $object->actionmsg2 = $actionmsg2; // Short text 174 | $object->fk_element = $object->id; 175 | $object->elementtype = $object->element; 176 | 177 | // Appel des triggers 178 | include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); 179 | $interface=new Interfaces($db); 180 | $result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf); 181 | if ($result < 0) { $error++; $this->errors=$interface->errors; } 182 | // Fin appel triggers 183 | 184 | if (! $error) 185 | { 186 | $resultmasssend.=$langs->trans("MailSent").': '.$sendto."
\n"; 187 | } 188 | else 189 | { 190 | dol_print_error($db); 191 | } 192 | $nbsent++; 193 | 194 | } 195 | else 196 | { 197 | $langs->load("other"); 198 | if ($mailfile->error) 199 | { 200 | $resultmasssend.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); 201 | $resultmasssend.='
'.$mailfile->error.'
'; 202 | } 203 | else 204 | { 205 | $resultmasssend.='
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; 206 | } 207 | } 208 | } 209 | } 210 | } 211 | else 212 | { 213 | $nbignored++; 214 | $langs->load("other"); 215 | $resultmasssend.='
'.$langs->trans('ErrorCantReadFile',$file).'
'; 216 | dol_syslog('Failed to read file: '.$file); 217 | break ; 218 | } 219 | } 220 | } 221 | 222 | if ($nbsent) 223 | { 224 | $action=''; // Do not show form post if there was at least one successfull sent 225 | setEventMessage($nbsent. '/'.$countToSend.' '.$langs->trans("RemindSent")); 226 | } 227 | else 228 | { 229 | setEventMessage($langs->trans("NoRemindSent"), 'warnings'); 230 | } 231 | } 232 | } 233 | 234 | 235 | if ($action == "builddoc" && $user->hasRight('facture','lire') && ! GETPOST('button_search') && !empty($builddoc_generatebutton)) 236 | { 237 | if (is_array($_POST['toGenerate'])) 238 | { 239 | $arrayofinclusion=array(); 240 | foreach($_POST['toGenerate'] as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/'); 241 | $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC); 242 | 243 | // liste les fichiers 244 | $files = array(); 245 | $factures_bak = $factures ; 246 | foreach($_POST['toGenerate'] as $basename) 247 | { 248 | foreach($factures as $facture) 249 | { 250 | if(strstr($facture["name"],$basename)) 251 | { 252 | $files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"]; 253 | } 254 | } 255 | } 256 | 257 | // Define output language (Here it is not used because we do only merging existing PDF) 258 | $outputlangs = $langs; 259 | $newlang=''; 260 | if (getDolGlobalString('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); 261 | if (getDolGlobalString('MAIN_MULTILANGS') && empty($newlang)) $newlang=! empty($object->thirdparty->default_lang) ? $object->thirdparty->default_lang : $object->client->default_lang; 262 | if (! empty($newlang)) 263 | { 264 | $outputlangs = new Translate("",$conf); 265 | $outputlangs->setDefaultLang($newlang); 266 | } 267 | 268 | // Create empty PDF 269 | $pdf=pdf_getInstance(); 270 | if (class_exists('TCPDF')) 271 | { 272 | $pdf->setPrintHeader(false); 273 | $pdf->setPrintFooter(false); 274 | } 275 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); 276 | 277 | if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) $pdf->SetCompression(false); 278 | 279 | dol_include_once('/lcr/core/modules/lcr/modules_lcr.php'); 280 | 281 | //$doc = new generic_pdf_lcr($db); 282 | $TtoGenerate = $_REQUEST['toGenerate']; 283 | $object = new Facture($db); 284 | $result = lcr_pdf_create($db, $object, 'generic_lcr', $outputlangs, '', '', '', $TtoGenerate); 285 | 286 | // Add all others 287 | /*foreach($files as $file) 288 | { 289 | // Charge un document PDF depuis un fichier. 290 | $pagecount = $pdf->setSourceFile($file); 291 | for ($i = 1; $i <= $pagecount; $i++) 292 | { 293 | $tplidx = $pdf->importPage($i); 294 | $s = $pdf->getTemplatesize($tplidx); 295 | $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); 296 | $pdf->useTemplate($tplidx); 297 | } 298 | }*/ 299 | 300 | // Create output dir if not exists 301 | dol_mkdir($diroutputpdf); 302 | 303 | // Save merged file 304 | $filename=strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); 305 | if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); 306 | $pagecount = 0; 307 | if ($pagecount) 308 | { 309 | $now=dol_now(); 310 | $file=$diroutputpdf.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; 311 | $pdf->Output($file,'F'); 312 | if (getDolGlobalString('MAIN_UMASK')) 313 | @chmod($file, octdec(getDolGlobalString('MAIN_UMASK'))); 314 | } 315 | } 316 | 317 | } elseif (isset($_POST['toGenerate']) && is_array($_POST['toGenerate']) && isset($_REQUEST['generateCSV'])) { 318 | 319 | generateCSV(); 320 | 321 | } 322 | 323 | // Remove file 324 | if ($action == 'remove_file') 325 | { 326 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 327 | 328 | $langs->load("other"); 329 | $upload_dir = $diroutputpdf; 330 | $file = $upload_dir . '/' . GETPOST('file'); 331 | $ret=dol_delete_file($file,0,0,0,''); 332 | if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); 333 | else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); 334 | $action=''; 335 | } 336 | 337 | 338 | 339 | /* 340 | * View 341 | */ 342 | 343 | $form = new Form($db); 344 | $formfile = new FormFile($db); 345 | 346 | $langs->load('lcr@lcr'); 347 | 348 | $title=$langs->trans("lcrTitle"); 349 | if ($option=='late') $title=$langs->trans("lcrTitle"); 350 | 351 | llxHeader('',$title); 352 | 353 | $dolibarr_version = (float) DOL_VERSION; 354 | ?> 355 | 378 | liste_limit * $page; 394 | $pageprev = $page - 1; 395 | $pagenext = $page + 1; 396 | if (! $sortfield) $sortfield="f.date_lim_reglement"; 397 | if (! $sortorder) $sortorder="ASC"; 398 | 399 | $limit = $conf->liste_limit; 400 | $ref_field = (floatval(DOL_VERSION) < 10.0 ? 'facnumber' : 'ref'); 401 | $total_field = (floatval(DOL_VERSION) < 10.0 ? 'total' : 'total_ht'); 402 | $tva_field = (floatval(DOL_VERSION) < 10.0 ? 'tva' : 'total_tva'); 403 | 404 | $sql = "SELECT s.nom, s.rowid as socid, s.email"; 405 | $sql.= ", f.rowid as facid, f.".$ref_field.", f.ref_client, f.increment, f.".$total_field." as total_ht, f.".$tva_field." as total_tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp"; 406 | $sql.= ", f.datef as df, f.date_lim_reglement as datelimite"; 407 | $sql.= ", f.paye as paye, f.fk_statut, f.type"; 408 | $sql.= ", sum(pf.amount) as am"; 409 | if ($user->hasRight('societe','client','read') && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; 410 | $sql.= " FROM ".$db->prefix()."societe as s"; 411 | if (! $user->hasRight('societe','client','voir') && ! $socid) $sql .= ", ".$db->prefix()."societe_commerciaux as sc"; 412 | $sql.= ",".$db->prefix()."facture as f"; 413 | $sql.= " LEFT JOIN ".$db->prefix()."paiement_facture as pf ON f.rowid=pf.fk_facture "; 414 | $sql.= " WHERE f.fk_soc = s.rowid"; 415 | $sql.= " AND f.entity = ".$conf->entity; 416 | $sql.= " AND f.type IN (0,1,3) AND f.fk_statut = 1"; 417 | if(getDolGlobalString('LCR_PAIEMENT_MODE')) 418 | $sql.= " AND fk_mode_reglement = ".getDolGlobalString('LCR_PAIEMENT_MODE'); 419 | else 420 | $sql.= " AND fk_mode_reglement = 52"; 421 | $sql.= " AND f.paye = 0"; 422 | //if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; 423 | if (! $user->hasRight('societe','client','voir') && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; 424 | if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; 425 | if (GETPOST('filtre')) 426 | { 427 | $filtrearr = explode(",", GETPOST('filtre')); 428 | foreach ($filtrearr as $fil) 429 | { 430 | $filt = explode(":", $fil); 431 | $sql .= " AND " . $filt[0] . " = " . $filt[1]; 432 | } 433 | } 434 | if ($search_ref) $sql .= " AND f.".$ref_field." LIKE '%".$db->escape($search_ref)."%'"; 435 | if ($search_refcustomer) $sql .= " AND f.ref_client LIKE '%".$db->escape($search_refcustomer)."%'"; 436 | if ($search_societe) $sql .= " AND s.nom LIKE '%".$db->escape($search_societe)."%'"; 437 | if ($search_montant_ht) $sql .= " AND f.".$total_field." = '".$db->escape($search_montant_ht)."'"; 438 | if ($search_montant_ttc) $sql .= " AND f.total_ttc = '".$db->escape($search_montant_ttc)."'"; 439 | if (GETPOST('sf_ref')) $sql .= " AND f.".$ref_field." LIKE '%".$db->escape(GETPOST('sf_ref'))."%'"; 440 | $sql.= " GROUP BY s.nom, s.rowid, s.email, f.rowid, f.".$ref_field.", f.increment, f.".$total_field.", f.".$tva_field.", f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp, f.datef, f.date_lim_reglement, f.paye, f.fk_statut, f.type "; 441 | if (! $user->hasRight('societe','client','voir') && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; 442 | $sql.= " ORDER BY "; 443 | $listfield=explode(',',$sortfield); 444 | foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.","; 445 | $sql.= " f.".$ref_field." DESC"; 446 | 447 | //$sql .= $db->plimit($limit+1,$offset); 448 | 449 | $resql = $db->query($sql); 450 | if ($resql) 451 | { 452 | $num = $db->num_rows($resql); 453 | 454 | if (! empty($socid)) 455 | { 456 | $soc = new Societe($db); 457 | $soc->fetch($socid); 458 | } 459 | 460 | $param=""; 461 | $param.=(! empty($socid)?"&socid=".$socid:""); 462 | $param.=(! empty($option)?"&option=".$option:""); 463 | if ($search_ref) $param.='&search_ref='.urlencode($search_ref); 464 | if ($search_refcustomer) $param.='&search_ref='.urlencode($search_refcustomer); 465 | if ($search_societe) $param.='&search_societe='.urlencode($search_societe); 466 | if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); 467 | if ($search_montant_ttc) $param.='&search_montant_ttc='.urlencode($search_montant_ttc); 468 | if ($late) $param.='&late='.urlencode($late); 469 | 470 | $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; 471 | $urlsource.=str_replace('&','&',$param); 472 | 473 | $titre=(! empty($socid)?$langs->trans("BillsCustomersUnpaidForCompany",$soc->nom):$langs->trans("lcrTitle")); 474 | if ($option == 'late') $titre.=' ('.$langs->trans("Late").')'; 475 | else $titre.=' ('.$langs->trans("All").')'; 476 | 477 | $link=''; 478 | if (empty($option)) $link=''.$langs->trans("ShowUnpaidLateOnly").''; 479 | elseif ($option == 'late') $link=''.$langs->trans("ShowUnpaidAll").''; 480 | print_fiche_titre($titre,$link); 481 | //print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',0); // We don't want pagination on this page 482 | 483 | dol_htmloutput_mesg($mesg); 484 | 485 | print '
'; 486 | 487 | if (! empty($mode) && $action == 'presend') 488 | { 489 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; 490 | $formmail = new FormMail($db); 491 | 492 | print '
'; 493 | print_fiche_titre($langs->trans("SendRemind"),'','').'
'; 494 | 495 | $topicmail="MailTopicSendRemindUnpaidInvoices"; 496 | $modelmail="facture_relance"; 497 | 498 | // Cree l'objet formulaire mail 499 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; 500 | $formmail = new FormMail($db); 501 | $formmail->withform=-1; 502 | $formmail->fromtype = 'user'; 503 | $formmail->fromid = $user->id; 504 | $formmail->fromname = $user->getFullName($langs); 505 | $formmail->frommail = $user->email; 506 | $formmail->withfrom=1; 507 | $liste=array(); 508 | $formmail->withto=$langs->trans("AllRecipientSelectedForRemind"); 509 | $formmail->withtofree=0; 510 | $formmail->withtoreadonly=1; 511 | $formmail->withtocc=1; 512 | $formmail->withtoccc=getDolGlobalString('MAIN_EMAIL_USECCC'); 513 | $formmail->withtopic=$langs->transnoentities($topicmail, '__FACREF__', '__REFCLIENT__'); 514 | $formmail->withfile=$langs->trans("EachInvoiceWillBeAttachedToEmail"); 515 | $formmail->withbody=1; 516 | $formmail->withdeliveryreceipt=1; 517 | $formmail->withcancel=1; 518 | // Tableau des substitutions 519 | //$formmail->substit['__FACREF__']=''; 520 | $formmail->substit['__SIGNATURE__']=$user->signature; 521 | //$formmail->substit['__REFCLIENT__']=''; 522 | $formmail->substit['__PERSONALIZED__']=''; 523 | $formmail->substit['__CONTACTCIVNAME__']=''; 524 | 525 | // Tableau des parametres complementaires du post 526 | $formmail->param['action']=$action; 527 | $formmail->param['models']=$modelmail; 528 | $formmail->param['facid']=$object->id; 529 | $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; 530 | 531 | print $formmail->get_form(); 532 | print '
'."\n"; 533 | } 534 | 535 | print ''; 536 | print ''; 537 | if ($late) print ''; 538 | 539 | if ($resultmasssend) 540 | { 541 | print '
'.$langs->trans("ResultOfMassSending").':
'."\n"; 542 | print $langs->trans("Selected").': '.$countToSend."\n
"; 543 | print $langs->trans("Ignored").': '.$nbignored."\n
"; 544 | print $langs->trans("Sent").': '.$nbsent."\n
"; 545 | //print $resultmasssend; 546 | print '
'; 547 | } 548 | 549 | $i = 0; 550 | print ''; 551 | print ''; 552 | print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.$ref_field","",$param,"",$sortfield,$sortorder); 553 | print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder); 554 | print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","",$param,'align="center"',$sortfield,$sortorder); 555 | print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); 556 | print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); 557 | print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.$total_field","",$param,'align="right"',$sortfield,$sortorder); 558 | print_liste_field_titre($langs->trans("Taxes"),$_SERVER["PHP_SELF"],"f.$tva_field","",$param,'align="right"',$sortfield,$sortorder); 559 | print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); 560 | print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); 561 | print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); 562 | print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); 563 | if (empty($mode)) 564 | { 565 | print_liste_field_titre($langs->trans("Concat LCR"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); 566 | } 567 | else 568 | { 569 | print_liste_field_titre($langs->trans("Remind"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); 570 | } 571 | print "\n"; 572 | 573 | // Lignes des champs de filtre 574 | print ''; 575 | // Ref 576 | print ''; 578 | print ''; 581 | print ''; 582 | print ''; 583 | print ''; 584 | print ''; 585 | print ''; 586 | print ''; 587 | print ''; 588 | print ''; 589 | print ''; 592 | if (empty($mode)) 593 | { 594 | print ''; 597 | } 598 | else 599 | { 600 | print ''; 603 | } 604 | print "\n"; 605 | 606 | if ($num > 0) 607 | { 608 | $var=True; 609 | $total_ht=0; 610 | $total_tva=0; 611 | $total_ttc=0; 612 | $total_paid=0; 613 | 614 | $facturestatic=new Facture($db); 615 | 616 | while ($i < $num) 617 | { 618 | $objp = $db->fetch_object($resql); 619 | $date_limit=$db->jdate($objp->datelimite); 620 | 621 | $var=!$var; 622 | 623 | print ""; 624 | $classname = "impayee"; 625 | 626 | print '\n"; 654 | 655 | // Customer ref 656 | print ''; 659 | 660 | print ''."\n"; 661 | print ''."\n"; 662 | 663 | print ''; 664 | 665 | print ''; 666 | print ''; 672 | print ''; 673 | print ''; 678 | 679 | // Remain to receive 680 | print ''; 681 | 682 | // Status of invoice 683 | print ''; 686 | 687 | if (empty($mode)) 688 | { 689 | // Checkbox to merge 690 | print '' ; 693 | } 694 | else 695 | { 696 | // Checkbox to send remind 697 | print '' ; 701 | } 702 | 703 | print "\n"; 704 | $total_ht+=$objp->total_ht; 705 | $total_tva+=($objp->total_tva + $tx1 + $tx2 + $revenuestamp); 706 | $total_ttc+=$objp->total_ttc; 707 | $total_paid+=$objp->am + $cn + $dep; 708 | 709 | $i++; 710 | } 711 | 712 | print ''; 713 | print ''; 714 | print ''; 715 | print ''; 716 | print ''; 717 | print ''; 718 | print ''; 719 | print ''; 720 | print ''; 721 | print "\n"; 722 | } 723 | 724 | print "
'; 577 | print ''; 579 | print ''; 580 | print '     '; 590 | print ''; 591 | print ''; 595 | if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; 596 | print ''; 601 | if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; 602 | print '
'; 627 | 628 | $facturestatic->id=$objp->facid; 629 | $facturestatic->ref=$objp->$ref_field; 630 | $facturestatic->type=$objp->type; 631 | 632 | print ''; 633 | 634 | // Ref 635 | print ''; 638 | 639 | // Warning picto 640 | print ''; 643 | 644 | // PDF Picto 645 | print ''; 650 | 651 | print '
'; 636 | print $facturestatic->getNomUrl(1); 637 | print ''; 641 | if ($date_limit < ($now - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late")); 642 | print ''; 646 | $filename=dol_sanitizeFileName($objp->$ref_field); 647 | $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->$ref_field); 648 | print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); 649 | print '
'; 652 | 653 | print "
'; 657 | print $objp->ref_client; 658 | print ''.dol_print_date($db->jdate($objp->df),'day').''.dol_print_date($db->jdate($objp->datelimite),'day').''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,28).''.price($objp->total_ht).''.price($objp->total_tva); 667 | $tx1=price2num($objp->localtax1); 668 | $tx2=price2num($objp->localtax2); 669 | $revenuestamp=price2num($objp->revenuestamp); 670 | if (! empty($tx1) || ! empty($tx2) || ! empty($revenuestamp)) print '+'.price($tx1 + $tx2 + $revenuestamp); 671 | print ''.price($objp->total_ttc).''; 674 | $cn=$facturestatic->getSumCreditNotesUsed(); 675 | $dep=$facturestatic->getSumDepositsUsed(); 676 | print price($objp->am + $cn + $dep); 677 | print ''.price($objp->total_ttc-$objp->am-$cn-$dep).''; 684 | print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am); 685 | print ''; 691 | print ''; 692 | print ''; 698 | if ($objp->email) print ''; 699 | else print img_picto($langs->trans("NoEMail"), 'warning.png'); 700 | print '
'.$langs->trans("Total").''.price($total_ht).''.price($total_tva).''.price($total_ttc).''.price($total_paid).''.price($total_ttc - $total_paid).'  
"; 725 | 726 | 727 | if (empty($mode)) 728 | { 729 | /* 730 | * Show list of available documents 731 | */ 732 | $filedir=$diroutputpdf; 733 | $genallowed=$user->hasRight('facture', 'lire'); 734 | $delallowed=$user->hasRight('facture', 'lire'); 735 | 736 | print '
'; 737 | print ''; 738 | // We disable multilang because we concat already existing pdf. 739 | //echo $filedir;exit; 740 | $formfile->show_documents('lcr','',$filedir,$urlsource,$genallowed,$delallowed,'',1,1,0,48,1,$param,$langs->trans("Fichier LCR générés"),$langs->trans("Fusion LCR")); 741 | 742 | ?> 743 | 744 | 749 | 750 | '; 758 | print ''.$langs->trans("SendRemind").''; 759 | print ''; 760 | print '
'; 761 | } 762 | } 763 | 764 | print '
'; 765 | 766 | $db->free($resql); 767 | } 768 | else dol_print_error($db,''); 769 | 770 | 771 | llxFooter(); 772 | $db->close(); 773 | -------------------------------------------------------------------------------- /core/modules/lcr/doc/pdf_generic_lcr.modules.php: -------------------------------------------------------------------------------- 1 | load("main"); 32 | $langs->load("bills"); 33 | 34 | $this->db = $db; 35 | $this->name = "Facture Epoxy 3000"; 36 | $this->description = $langs->trans('PDFCrabeDescription'); 37 | 38 | // Dimension page pour format A4 39 | $this->type = 'pdf'; 40 | $formatarray=pdf_getFormat(); 41 | $this->page_largeur = $formatarray['width']; 42 | $this->page_hauteur = $formatarray['height']; 43 | $this->format = array($this->page_largeur,$this->page_hauteur); 44 | $this->marge_gauche=getDolGlobalString('MAIN_PDF_MARGIN_LEFT')?getDolGlobalString('MAIN_PDF_MARGIN_LEFT'):10; 45 | $this->marge_droite=getDolGlobalString('MAIN_PDF_MARGIN_RIGHT')?getDolGlobalString('MAIN_PDF_MARGIN_RIGHT'):10; 46 | $this->marge_haute =getDolGlobalString('MAIN_PDF_MARGIN_TOP')?getDolGlobalString('MAIN_PDF_MARGIN_TOP'):10; 47 | $this->marge_basse =getDolGlobalString('MAIN_PDF_MARGIN_BOTTOM')?getDolGlobalString('MAIN_PDF_MARGIN_BOTTOM'):10; 48 | 49 | $this->option_logo = 1; // Affiche logo 50 | $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION 51 | $this->option_modereg = 1; // Affiche mode reglement 52 | $this->option_condreg = 1; // Affiche conditions reglement 53 | $this->option_codeproduitservice = 1; // Affiche code produit-service 54 | $this->option_multilang = 1; // Dispo en plusieurs langues 55 | $this->option_escompte = 1; // Affiche si il y a eu escompte 56 | $this->option_credit_note = 1; // Support credit notes 57 | $this->option_freetext = 1; // Support add of a personalised text 58 | $this->option_draft_watermark = 1; // Support add of a watermark on drafts 59 | 60 | $this->franchise=!$mysoc->tva_assuj; 61 | 62 | // Get source company 63 | $this->emetteur=$mysoc; 64 | if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined 65 | 66 | // Define position of columns 67 | $this->posxdesc=$this->marge_gauche+1; 68 | $this->posxtva=112; 69 | $this->posxup=126; 70 | $this->posxqty=145; 71 | $this->posxdiscount=162; 72 | $this->postotalht=174; 73 | if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) $this->posxtva=$this->posxup; 74 | $this->posxpicture=$this->posxtva - (getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')?20:getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')); // width of images 75 | if ($this->page_largeur < 210) // To work with US executive format 76 | { 77 | $this->posxpicture-=20; 78 | $this->posxtva-=20; 79 | $this->posxup-=20; 80 | $this->posxqty-=20; 81 | $this->posxdiscount-=20; 82 | $this->postotalht-=20; 83 | } 84 | 85 | $this->tva=array(); 86 | $this->localtax1=array(); 87 | $this->localtax2=array(); 88 | $this->atleastoneratenotnull=0; 89 | $this->atleastonediscount=0; 90 | } 91 | 92 | 93 | 94 | function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0, &$TtoGenerate) 95 | { 96 | global $user,$langs,$conf,$mysoc,$db,$hookmanager; 97 | 98 | if (! is_object($outputlangs)) $outputlangs=$langs; 99 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO 100 | if (getDolGlobalInt('MAIN_USE_FPDF')) $outputlangs->charset_output='ISO-8859-1'; 101 | 102 | $outputlangs->load("main"); 103 | $outputlangs->load("dict"); 104 | $outputlangs->load("companies"); 105 | $outputlangs->load("bills"); 106 | $outputlangs->load("products"); 107 | 108 | if ($conf->facture->dir_output) 109 | { 110 | $dir = $conf->lcr->dir_output . "/"; 111 | $file = $dir . "" . 'lcr_'.date('YmdHis') . ".pdf"; 112 | 113 | if (! file_exists($dir)) 114 | { 115 | if (dol_mkdir($dir) < 0) 116 | { 117 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); 118 | return 0; 119 | } 120 | } 121 | 122 | if (file_exists($dir)) 123 | { 124 | $pdf=pdf_getInstance($this->format); 125 | $pdf->SetAutoPageBreak(1,0); 126 | 127 | $this->_showLCR($pdf, $object, $outputlangs, $TtoGenerate); 128 | 129 | $pdf->Close(); 130 | 131 | $pdf->Output($file,'F'); 132 | 133 | // Add pdfgeneration hook 134 | if (! is_object($hookmanager)) 135 | { 136 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; 137 | $hookmanager=new HookManager($this->db); 138 | } 139 | 140 | // Ne pas passer dans le hook des factures (pour concatpdf) 141 | $object->element = 'lcr_facture'; 142 | $hookmanager->initHooks(array('pdfgeneration')); 143 | $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); 144 | global $action; 145 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks 146 | 147 | if (getDolGlobalString('MAIN_UMASK')) 148 | @chmod($file, octdec(getDolGlobalString('MAIN_UMASK'))); 149 | 150 | return 1; // Pas d'erreur 151 | } 152 | else 153 | { 154 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); 155 | return 0; 156 | } 157 | } 158 | else 159 | { 160 | $this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR"); 161 | return 0; 162 | } 163 | $this->error=$langs->trans("ErrorUnknown"); 164 | return 0; // Erreur par defaut 165 | } 166 | 167 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) 168 | { 169 | global $conf,$langs, $w; 170 | 171 | $outputlangs->load("main"); 172 | $outputlangs->load("bills"); 173 | $outputlangs->load("propal"); 174 | $outputlangs->load("companies"); 175 | 176 | $default_font_size = pdf_getPDFFontSize($outputlangs); 177 | 178 | pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); 179 | 180 | $pdf->SetTextColor(0,0,60); 181 | $pdf->SetFont('','B', $default_font_size + 3); 182 | 183 | $posy=$this->marge_haute; 184 | $posx=$this->page_largeur-$this->marge_droite-100; 185 | 186 | $pdf->SetXY($this->marge_gauche,$posy); 187 | // Logo 188 | if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) 189 | { 190 | $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; 191 | if ($this->emetteur->logo) 192 | { 193 | if (is_readable($logo)) 194 | { 195 | $height=pdf_getHeightForLogo($logo); 196 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) 197 | } 198 | else 199 | { 200 | $pdf->SetTextColor(200,0,0); 201 | $pdf->SetFont('','B',$default_font_size - 2); 202 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); 203 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); 204 | } 205 | } 206 | else 207 | { 208 | $text=$this->emetteur->name; 209 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); 210 | } 211 | } 212 | 213 | $pdf->SetFont('','B', $default_font_size + 3); 214 | $pdf->SetXY($posx,$posy); 215 | $pdf->SetTextColor(0,0,60); 216 | $title=$outputlangs->transnoentities("Invoice"); 217 | if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); 218 | if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); 219 | if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); 220 | if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat"); 221 | $pdf->MultiCell(100, 3, $title, '', 'R'); 222 | 223 | $pdf->SetFont('','B',$default_font_size); 224 | 225 | $posy+=5; 226 | $pdf->SetXY($posx,$posy); 227 | $pdf->SetTextColor(0,0,60); 228 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); 229 | 230 | $posy+=1; 231 | $pdf->SetFont('','', $default_font_size - 2); 232 | 233 | if ($object->ref_client) 234 | { 235 | $posy+=4; 236 | $pdf->SetXY($posx,$posy); 237 | $pdf->SetTextColor(0,0,60); 238 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); 239 | } 240 | 241 | $objectidnext=$object->getIdReplacingInvoice('validated'); 242 | if ($object->type == 0 && $objectidnext) 243 | { 244 | $objectreplacing=new Facture($this->db); 245 | $objectreplacing->fetch($objectidnext); 246 | 247 | $posy+=3; 248 | $pdf->SetXY($posx,$posy); 249 | $pdf->SetTextColor(0,0,60); 250 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R'); 251 | } 252 | if ($object->type == 1) 253 | { 254 | $objectreplaced=new Facture($this->db); 255 | $objectreplaced->fetch($object->fk_facture_source); 256 | 257 | $posy+=4; 258 | $pdf->SetXY($posx,$posy); 259 | $pdf->SetTextColor(0,0,60); 260 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); 261 | } 262 | if ($object->type == 2) 263 | { 264 | $objectreplaced=new Facture($this->db); 265 | $objectreplaced->fetch($object->fk_facture_source); 266 | 267 | $posy+=3; 268 | $pdf->SetXY($posx,$posy); 269 | $pdf->SetTextColor(0,0,60); 270 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); 271 | } 272 | 273 | $posy+=4; 274 | $pdf->SetXY($posx,$posy); 275 | $pdf->SetTextColor(0,0,60); 276 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date,"day",false,$outputlangs), '', 'R'); 277 | 278 | if ($object->type != 2) 279 | { 280 | $posy+=3; 281 | $pdf->SetXY($posx,$posy); 282 | $pdf->SetTextColor(0,0,60); 283 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R'); 284 | } 285 | 286 | if ($object->client->code_client) 287 | { 288 | $posy+=3; 289 | $pdf->SetXY($posx,$posy); 290 | $pdf->SetTextColor(0,0,60); 291 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); 292 | } 293 | 294 | $posy+=1; 295 | $top_shift = 0; 296 | 297 | if ($showaddress) 298 | { 299 | // Sender properties 300 | $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); 301 | 302 | // Show sender 303 | $posy=getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; 304 | $posy+=$top_shift; 305 | $posx=$this->marge_gauche; 306 | if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) $posx=$this->page_largeur-$this->marge_droite-80; 307 | 308 | $hautcadre=getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40; 309 | $widthrecbox=getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82; 310 | 311 | 312 | // Show sender frame 313 | $pdf->SetTextColor(0,0,0); 314 | $pdf->SetFont('','', $default_font_size - 2); 315 | $pdf->SetXY($posx,$posy-5); 316 | $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); 317 | $pdf->SetXY($posx,$posy); 318 | $pdf->SetFillColor(230,230,230); 319 | $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); 320 | $pdf->SetTextColor(0,0,60); 321 | 322 | // Show sender name 323 | $pdf->SetXY($posx+2,$posy+3); 324 | $pdf->SetFont('','B', $default_font_size); 325 | $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); 326 | $posy=$pdf->getY(); 327 | 328 | // Show sender information 329 | $pdf->SetXY($posx+2,$posy); 330 | $pdf->SetFont('','', $default_font_size - 1); 331 | $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); 332 | 333 | // Recipient name 334 | if (!empty($usecontact)) { 335 | // On peut utiliser le nom de la societe du contact 336 | if (getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT', 0)) { 337 | $socname = $object->contact->socname; 338 | } else { 339 | $socname = $object->client->nom; 340 | } 341 | $carac_client_name = $outputlangs->convToOutputCharset($socname); 342 | } else { 343 | $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom); 344 | } 345 | 346 | $carac_client = pdf_build_address($outputlangs, $this->emetteur, (!empty($object->thirdparty) ? $object->thirdparty : $object->client), ($usecontact ? $object->contact : ''), $usecontact, 'target'); 347 | 348 | // If BILLING contact defined on invoice, we use it 349 | $usecontact=false; 350 | $arrayidcontact=$object->getIdContact('external','BILLING'); 351 | if (count($arrayidcontact) > 0) 352 | { 353 | $usecontact=true; 354 | $result=$object->fetch_contact($arrayidcontact[0]); 355 | } 356 | 357 | //Recipient name 358 | // On peut utiliser le nom de la societe du contact 359 | if ($usecontact && getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')) { 360 | $thirdparty = $object->contact; 361 | } else { 362 | $thirdparty = $object->thirdparty; 363 | } 364 | 365 | $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); 366 | 367 | $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object); 368 | 369 | // Show recipient 370 | $widthrecbox=getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100; 371 | if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format 372 | $posy=getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; 373 | $posy+=$top_shift; 374 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; 375 | if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) $posx=$this->marge_gauche; 376 | 377 | // Show recipient frame 378 | $pdf->SetTextColor(0,0,0); 379 | $pdf->SetFont('','', $default_font_size - 2); 380 | $pdf->SetXY($posx+2,$posy-5); 381 | $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); 382 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); 383 | 384 | // Show recipient name 385 | $pdf->SetXY($posx+2,$posy+3); 386 | $pdf->SetFont('','B', $default_font_size); 387 | $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); 388 | 389 | $posy = $pdf->getY(); 390 | 391 | // Show recipient information 392 | $pdf->SetFont('','', $default_font_size - 1); 393 | $pdf->SetXY($posx+2,$posy); 394 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); 395 | } 396 | 397 | $pdf->SetTextColor(0,0,0); 398 | } 399 | 400 | function _showLCR($pdf, $object, $outputlangs, &$TtoGenerate) 401 | { 402 | global $db, $conf; 403 | 404 | //Gestion LCR 405 | 406 | $pdf->AddPage(); 407 | $posy =50; 408 | $pdf->SetDrawColor(0,0,0); 409 | 410 | $default_font_size = pdf_getPDFFontSize($outputlangs); 411 | $nb_facture = count($TtoGenerate); 412 | 413 | foreach($TtoGenerate as $ii => $ref_piece) { 414 | 415 | $f = new Facture($db); 416 | $f->fetch('', $ref_piece); 417 | $f->fetch_thirdparty(); 418 | $object = &$f; 419 | 420 | // Compatibilité Dolibarr >= 4.0 421 | if(empty($object->client) && ! empty($object->thirdparty)) 422 | { 423 | $object->client = $object->thirdparty; 424 | } 425 | 426 | if (getDolGlobalString('LCR_USE_REST_TO_PAY')) 427 | { 428 | $deja_regle = $object->getSommePaiement(); 429 | $creditnoteamount=$object->getSumCreditNotesUsed(); 430 | $depositsamount=$object->getSumDepositsUsed(); 431 | $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); 432 | } 433 | else 434 | { 435 | $resteapayer = price2num($object->total_ttc); 436 | } 437 | 438 | 439 | // ENTETE 440 | if (getDolGlobalString('LCR_GENERATE_ONE_PER_PAGE_WiTH_ADDRESS')) 441 | { 442 | $this->_pagehead($pdf, $object, 1, $outputlangs); 443 | $curx=$this->marge_gauche; 444 | 445 | $heightforinfotot = 78; // Height reserved to output the info and total part 446 | $heightforfreetext= (getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT')?getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT'):5); // Height reserved to output the free text on last page 447 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) 448 | 449 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 10; 450 | $cury=$bottomlasttab; 451 | 452 | $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(200,200,200))); 453 | $pdf->Line($curx, $cury-11, $this->page_largeur-$this->marge_droite, $cury-11); 454 | $pdf->SetLineStyle(array('dash'=>0, 'color'=>array(0,0,0))); 455 | } 456 | else 457 | { 458 | $curx=$this->marge_gauche; 459 | $cury=$posy-30; 460 | } 461 | 462 | 463 | $pdf->SetFont('','', $default_font_size - 1); 464 | $pdf->writeHTMLCell(53, 20, 10, $cury-8, $outputlangs->convToOutputCharset('MERCI DE NOUS RETOURNER LA PRESENTE TRAITE SOUS 8 JOURS.'), 0, 1, false, true, 'J',true); 465 | 466 | $pdf->SetFont('','', $default_font_size - 3); 467 | $pdf->writeHTMLCell(45, 20, 68, $cury-8, $outputlangs->convToOutputCharset('Contre cette LETTRE DE CHANGE STIPULEE SANS FRAIS').'
'.$outputlangs->convToOutputCharset('Veuillez payer la somme indiquée ci-dessous à l\'ordre de'), 0, 1, false, true, 'J',true); 468 | 469 | $pdf->SetFont('','', $default_font_size - 2); 470 | $adresse = $outputlangs->convToOutputCharset(getDolGlobalString('MAIN_INFO_SOCIETE_NOM')) . '
' . nl2br(getDolGlobalString('MAIN_INFO_SOCIETE_ADDRESS')) . '
' . $outputlangs->convToOutputCharset(getDolGlobalString('MAIN_INFO_SOCIETE_ZIP').' '.getDolGlobalString('MAIN_INFO_SOCIETE_TOWN')); 471 | $pdf->writeHTMLCell(50, 20, 120, $cury-8, $adresse, 0, 1, false, true, 'J',true); 472 | 473 | //Affichage code monnaie 474 | $pdf->SetXY(180, $cury+1); 475 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',7); 476 | $pdf->Cell(18, 0, "Code Monnaie",0,1,'C'); 477 | $pdf->SetXY(180, $cury+5); 478 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',14); 479 | $pdf->Cell(18, 0, $outputlangs->trans($conf->currency),0,0,'C'); 480 | 481 | //Affichage lieu / date 482 | //$town = !empty($this->emetteur->town) ? $this->emetteur->town : $this->emetteur->ville; 483 | $town = getDolGlobalString('MAIN_INFO_SOCIETE_TOWN'); 484 | 485 | $cury+=5; 486 | $pdf->SetXY(30, $cury); 487 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 488 | $pdf->Cell(15, 0, "A ".$outputlangs->convToOutputCharset($town).", le",0,1,'R'); 489 | 490 | // jolie fleche ... 491 | $curx=43; 492 | $cury+=2; 493 | $largeur_cadre=5; 494 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre+5, $cury); 495 | $pdf->Line($curx+$largeur_cadre+5, $cury, $curx+$largeur_cadre+5, $cury+2); 496 | $pdf->Line($curx+$largeur_cadre+4, $cury+2, $curx+$largeur_cadre+6, $cury+2); 497 | $pdf->Line($curx+$largeur_cadre+4, $cury+2, $curx+$largeur_cadre+5, $cury+3); 498 | $pdf->Line($curx+$largeur_cadre+6, $cury+2, $curx+$largeur_cadre+5, $cury+3); 499 | // fin jolie fleche 500 | 501 | //Affichage toute la ligne qui commence par "montant pour controle" ... 502 | $curx=$this->marge_gauche; 503 | $cury+=5; 504 | $hauteur_cadre=8; 505 | $largeur_cadre=27; 506 | $pdf->SetXY($curx, $cury); 507 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',7); 508 | $pdf->Cell($largeur_cadre, 0, "Montant pour contrôle",0,0,'C'); 509 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 510 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeur_cadre, $cury+$hauteur_cadre); 511 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre, $cury+$hauteur_cadre); 512 | $pdf->SetXY($curx, $cury+4); 513 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 514 | $pdf->Cell($largeur_cadre, 0, price($resteapayer),0,0,'C'); 515 | 516 | $curx=$curx+$largeur_cadre+5; 517 | $hauteur_cadre=8; 518 | $largeur_cadre=25; 519 | $pdf->SetXY($curx, $cury); 520 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',7); 521 | $pdf->Cell($largeur_cadre, 0, "Date de création",0,0,'C'); 522 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 523 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeur_cadre, $cury+$hauteur_cadre); 524 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre, $cury+$hauteur_cadre); 525 | $pdf->SetXY($curx, $cury+4); 526 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 527 | $pdf->Cell($largeur_cadre, 0, dol_print_date($object->date,"day",false,''),0,0,'C'); 528 | 529 | $curx=$curx+$largeur_cadre+5; 530 | $hauteur_cadre=8; 531 | $largeur_cadre=25; 532 | $pdf->SetXY($curx, $cury); 533 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',7); 534 | $pdf->Cell($largeur_cadre, 0, "Echéance",0,0,'C'); 535 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 536 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeur_cadre, $cury+$hauteur_cadre); 537 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre, $cury+$hauteur_cadre); 538 | $pdf->SetXY($curx, $cury+4); 539 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 540 | $pdf->Cell($largeur_cadre, 0, dol_print_date($object->date_lim_reglement,"day"),0,0,'C'); 541 | 542 | $curx=$curx+$largeur_cadre+5; 543 | $hauteur_cadre=8; 544 | $largeur_cadre=75; 545 | $pdf->SetXY($curx, $cury-1); 546 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',7); 547 | $pdf->Cell($largeur_cadre, 0, "LCR Seulement",0,0,'C'); 548 | 549 | $largeurportioncadre=30; 550 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 551 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeurportioncadre, $cury+$hauteur_cadre); 552 | $curx+=$largeurportioncadre; 553 | $pdf->Line($curx, $cury+2, $curx, $cury+$hauteur_cadre); 554 | 555 | $curx+=10; 556 | $largeurportioncadre=6; 557 | $pdf->Line($curx, $cury+2, $curx, $cury+$hauteur_cadre); 558 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeurportioncadre, $cury+$hauteur_cadre); 559 | $curx+=$largeurportioncadre; 560 | $pdf->Line($curx, $cury+2, $curx, $cury+$hauteur_cadre); 561 | 562 | $curx+=3; 563 | $largeurportioncadre=6; 564 | $pdf->Line($curx, $cury+2, $curx, $cury+$hauteur_cadre); 565 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeurportioncadre, $cury+$hauteur_cadre); 566 | $curx+=$largeurportioncadre; 567 | $pdf->Line($curx, $cury+2, $curx, $cury+$hauteur_cadre); 568 | 569 | $curx+=3; 570 | $largeurportioncadre=12; 571 | $pdf->Line($curx, $cury+2, $curx, $cury+$hauteur_cadre); 572 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeurportioncadre, $cury+$hauteur_cadre); 573 | $curx+=$largeurportioncadre; 574 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 575 | 576 | $curx+=3; 577 | $hauteur_cadre=8; 578 | $largeur_cadre=30; 579 | $pdf->SetXY($curx, $cury); 580 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',7); 581 | $pdf->Cell($largeur_cadre, 0, "Montant",0,0,'C'); 582 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 583 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeur_cadre, $cury+$hauteur_cadre); 584 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre, $cury+$hauteur_cadre); 585 | $pdf->SetXY($curx, $cury+4); 586 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 587 | $pdf->Cell($largeur_cadre, 0, price($resteapayer),0,0,'C'); 588 | 589 | $cury=$cury+$hauteur_cadre+3; 590 | $curx=20; 591 | $hauteur_cadre=6; 592 | $largeur_cadre=70; 593 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 594 | $pdf->Line($curx, $cury, $curx+$largeur_cadre/5, $cury); 595 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeur_cadre/5, $cury+$hauteur_cadre); 596 | 597 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre, $cury+$hauteur_cadre); 598 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre*4/5, $cury); 599 | $pdf->Line($curx+$largeur_cadre, $cury+$hauteur_cadre, $curx+$largeur_cadre*4/5, $cury+$hauteur_cadre); 600 | $pdf->SetXY($curx, $cury+1.5); 601 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 602 | $pdf->Cell($largeur_cadre, 1, $outputlangs->convToOutputCharset($object->ref),0,0,'C'); 603 | 604 | $curx=$curx+$largeur_cadre+15; 605 | $largeur_cadre=50; 606 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 607 | $pdf->Line($curx, $cury, $curx+$largeur_cadre/5, $cury); 608 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeur_cadre/5, $cury+$hauteur_cadre); 609 | 610 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre, $cury+$hauteur_cadre); 611 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre*4/5, $cury); 612 | $pdf->Line($curx+$largeur_cadre, $cury+$hauteur_cadre, $curx+$largeur_cadre*4/5, $cury+$hauteur_cadre); 613 | $pdf->SetXY($curx, $cury+2); 614 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 615 | // MB leave blank 616 | //$pdf->Cell($largeur_cadre, 0, "Réf ",0,0,C); 617 | 618 | $curx=$curx+$largeur_cadre+10; 619 | $largeur_cadre=30; 620 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 621 | $pdf->Line($curx, $cury, $curx+$largeur_cadre/5, $cury); 622 | $pdf->Line($curx, $cury+$hauteur_cadre, $curx+$largeur_cadre/5, $cury+$hauteur_cadre); 623 | 624 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre, $cury+$hauteur_cadre); 625 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre*4/5, $cury); 626 | $pdf->Line($curx+$largeur_cadre, $cury+$hauteur_cadre, $curx+$largeur_cadre*4/5, $cury+$hauteur_cadre); 627 | $pdf->SetXY($curx, $cury+2); 628 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 629 | // MB leave blank 630 | //$pdf->Cell($largeur_cadre, 0, "R�f ",0,0,C); 631 | 632 | // RIB client 633 | $cury=$cury+$hauteur_cadre+3; 634 | $largeur_cadre=70; 635 | $hauteur_cadre=6; 636 | $sql = "SELECT rib.fk_soc, rib.domiciliation, rib.code_banque, rib.code_guichet, rib.number, rib.cle_rib"; 637 | $sql.= " FROM ".$db->prefix() ."societe_rib as rib"; 638 | $sql.= " WHERE rib.fk_soc = ".$object->client->id; 639 | $sql.= ' ORDER BY default_rib DESC LIMIT 1'; // On veux en priorité le RIB par défaut si jamais on tombe sur le cas de +sieurs RIB mais pas de default alors on en prend qu'un 640 | 641 | $resql=$this->db->query($sql); 642 | if ($resql) 643 | { 644 | $num = $this->db->num_rows($resql); 645 | $i=0; 646 | while ($i <= $num) 647 | { 648 | $cpt = $this->db->fetch_object($resql); 649 | 650 | $curx=$this->marge_gauche; 651 | $pdf->Line($curx, $cury, $curx+$largeur_cadre, $cury); 652 | $pdf->Line($curx, $cury, $curx, $cury+$hauteur_cadre); 653 | $pdf->Line($curx+22, $cury, $curx+22, $cury+$hauteur_cadre-2); 654 | $pdf->Line($curx+35, $cury, $curx+35, $cury+$hauteur_cadre-2); 655 | $pdf->Line($curx+60, $cury, $curx+60, $cury+$hauteur_cadre-2); 656 | $pdf->Line($curx+70, $cury, $curx+70, $cury+$hauteur_cadre); 657 | $pdf->SetXY($curx+5, $cury+$hauteur_cadre-4); 658 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 659 | if (isset($cpt->code_banque) && isset($cpt->code_guichet) && isset($cpt->number) && isset($cpt->cle_rib)) 660 | $pdf->Cell($largeur_cadre, 1, $cpt->code_banque." ".$cpt->code_guichet." ".$cpt->number." ".$cpt->cle_rib,0,0,'L'); 661 | $pdf->SetXY($curx, $cury+$hauteur_cadre-1); 662 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',6); 663 | $pdf->Cell($largeur_cadre, 1, "Code établissement Code guichet N° de compte Cl RIB",0,0,'L'); 664 | $curx=136; 665 | $largeur_cadre=68; 666 | $pdf->SetXY($curx, $cury-1); 667 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',6); 668 | $pdf->Cell($largeur_cadre, 1, "Domiciliation bancaire",0,0,'C'); 669 | $pdf->SetXY($curx, $cury+2); 670 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 671 | if (isset($cpt->domiciliation)) 672 | $pdf->Cell($largeur_cadre, 5,$outputlangs->convToOutputCharset($cpt->domiciliation) ,1,0,'C'); 673 | $i++; 674 | } 675 | } 676 | // 677 | $cury=$cury+$hauteur_cadre+3; 678 | $curx=$this->marge_gauche; 679 | $largeur_cadre=20; 680 | $pdf->SetXY($curx, $cury); 681 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',6); 682 | $pdf->Cell($largeur_cadre, 1, "Acceptation ou aval",0,0,'L'); 683 | // jolie fl�che ... 684 | $cury += 2; 685 | $pdf->Line($curx+$largeur_cadre, $cury, $curx+$largeur_cadre+5, $cury); 686 | $pdf->Line($curx+$largeur_cadre+5, $cury, $curx+$largeur_cadre+5, $cury+2); 687 | $pdf->Line($curx+$largeur_cadre+4, $cury+2, $curx+$largeur_cadre+6, $cury+2); 688 | $pdf->Line($curx+$largeur_cadre+4, $cury+2, $curx+$largeur_cadre+5, $cury+3); 689 | $pdf->Line($curx+$largeur_cadre+6, $cury+2, $curx+$largeur_cadre+5, $cury+3); 690 | // fin jolie fl�che 691 | 692 | $curx+=50; 693 | $largeur_cadre=20; 694 | $hauteur_cadre=6; 695 | 696 | // Signature du tireur 697 | $pdf->SetXY($curx+$largeur_cadre*5, $cury); 698 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',6); 699 | $pdf->MultiCell($largeur_cadre*2, 4, "Signature du tireur",0,'C'); 700 | 701 | $pdf->Line(0,$cury+40,$this->page_largeur, $cury+40); 702 | $pdf->SetXY($curx+100, $cury+36); 703 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',6); 704 | $pdf->MultiCell(50, 4, "Ne rien inscrire au dessous de cette ligne",0,'R'); 705 | 706 | // Coordonnées du tiré 707 | $pdf->SetXY($curx, $cury); 708 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',6); 709 | $pdf->MultiCell($largeur_cadre, $hauteur_cadre, "Nom\n et Adresse\n du tiré",0,'R'); 710 | $pdf->SetXY($curx+$largeur_cadre+2, $cury-0.5); 711 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 712 | $arrayidcontact = $object->getIdContact('external','BILLING'); 713 | $carac_client=$outputlangs->convToOutputCharset($object->client->nom); 714 | $carac_client.="\n".$outputlangs->convToOutputCharset(!empty($object->client->address) ? $object->client->address : $object->client->adresse); 715 | $carac_client.="\n".$outputlangs->convToOutputCharset(!empty($object->client->zip) ? $object->client->zip : $object->client->cp) . " " . $outputlangs->convToOutputCharset(!empty($object->client->town) ? $object->client->town : $object->client->ville)."\n"; 716 | $pdf->MultiCell($largeur_cadre*2.5, $hauteur_cadre, $carac_client,1,'C'); 717 | 718 | // N° Siren 719 | $cury = $pdf->GetY() + 4; // Le précédent MultiCell change le Y courant. On rajoute 4 pour le démarrer systématiquement le cadre SIREN en dessous 720 | $pdf->SetXY($curx, $cury); 721 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'',6); 722 | $pdf->MultiCell($largeur_cadre, 4, "N° SIREN du tiré",0,'R'); 723 | $pdf->SetXY($curx+$largeur_cadre+2, $cury-0.5); 724 | $pdf->SetFont(pdf_getPDFFont($outputlangs),'B',8); 725 | $pdf->MultiCell($largeur_cadre*2.5, 4, $outputlangs->convToOutputCharset(empty($object->client->siren) ? $object->client->idprof1 : $object->client->siren),1,'C'); 726 | 727 | if (getDolGlobalString('LCR_GENERATE_ONE_PER_PAGE_WiTH_ADDRESS')) 728 | { 729 | // New page 730 | if ($ii < $nb_facture-1) $pdf->AddPage(); 731 | 732 | } 733 | else 734 | { 735 | $posy+=96; 736 | $ii++; 737 | $res_modulo = $ii%3; 738 | if($res_modulo == 0) { 739 | $pdf->AddPage(); 740 | $posy=50; 741 | } 742 | } 743 | 744 | 745 | } 746 | 747 | //fin mb 748 | } 749 | 750 | } 751 | --------------------------------------------------------------------------------