├── .gitignore ├── config.php ├── img ├── ATM_logo.jpg ├── importdevis.png ├── object_importdevis.png └── Dolibarr_Preferred_Partner_logo.png ├── .gitmodules ├── script └── create-maj-base.php ├── README ├── config.default.php ├── langs ├── en_US │ └── importdevis.lang └── fr_FR │ └── importdevis.lang ├── admin ├── importdevis_about.php └── importdevis_setup.php ├── core ├── boxes │ └── importdevis_box.php ├── modules │ └── modimportdevis.class.php └── triggers │ └── interface_99_modimportdevis_importdevistrigger.class.php ├── class └── actions_importdevis.class.php ├── lib └── importdevis.lib.php └── importdevis.php /.gitignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | .project 3 | 4 | *.log 5 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | init_db_by_vars($PDOdb); 23 | */ 24 | -------------------------------------------------------------------------------- /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/importdevis.lang: -------------------------------------------------------------------------------- 1 | Module104740Name = importdevis 2 | Module104740Desc = importdevis 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 | importdevisSetup = importdevis module setup 7 | importdevisAbout = About importdevis 8 | 9 | import=Import 10 | FileToImport=Fichier à importer (format csv) 11 | SendFile=Importer fichier 12 | importDGPFErrorExtension=Erreur de fichier d'import, le type du fichier ou l'extension n'est pas un csv 13 | IMPORTPROPAL_FORMAT=Appel du lineMapper 14 | IMPORTPROPAL_FORMAT_INFO=Définir IMPORTPROPAL_OTHERFORMAT dans divers avec le/les différentes formats séparé par une virgule -------------------------------------------------------------------------------- /langs/fr_FR/importdevis.lang: -------------------------------------------------------------------------------- 1 | Module104740Name = importdevis 2 | Module104740Desc = importdevis Descripion 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 | importdevisSetup = Configuration du module importdevis 7 | importdevisAbout = A propos du module importdevis 8 | 9 | import=Import 10 | FileToImport=Fichier à importer (format csv) 11 | NbLineToAvoid=Nombre de lignes à ignorer 12 | DeleteLinesBeforeImport=Supprimer lignes du document avant import 13 | SendFile=Importer fichier 14 | importDGPFErrorExtension=Erreur de fichier d'import, le type du fichier ou l'extension n'est pas un csv 15 | IMPORTPROPAL_FORMAT=Appel du lineMapper 16 | IMPORTPROPAL_FORMAT_INFO=Définir IMPORTPROPAL_OTHERFORMAT dans divers avec le/les différentes formats séparé par une virgule 17 | importdevispropalDraftWarning=Attention : la proposition commerciale doit être en brouillon 18 | importdevisorderDraftWarning= Attention : la commande doit être en brouillon 19 | IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE=Utiliser le sytème de mise à jour des lignes de nomenclature 20 | CREATE_PRODUCT_FROM_IMPORT=Créer les produits à l'import 21 | SEE_ORDER_TAB = Afficher l'onglet import sur fiche commande 22 | IMPORTPROPAL_FORCE_TVA=Taux de TVA des lignes insérées 23 | IMPORTDEVIS_UPDATE_PRODUCT=Mettre à jour le produit lors de l'import 24 | 25 | title=Titre 26 | product=Produit 27 | nomenclatureComponent=Nomenclature 28 | 29 | Level1=Niveau 1 30 | Level2=Niveau 2 31 | Level3=Niveau 3 32 | Level4=Niveau 4 33 | Level5=Niveau 5 34 | Level6=Niveau 6 35 | Level7=Niveau 7 36 | Level8=Niveau 8 37 | Level9=Niveau 9 38 | Level10=Niveau 10 39 | -------------------------------------------------------------------------------- /admin/importdevis_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 importdevis 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/importdevis.lib.php'; 34 | 35 | // Translations 36 | $langs->load("importdevis@importdevis"); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | /* 44 | * View 45 | */ 46 | $page_name = "importdevisAbout"; 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 = importdevisAdminPrepareHead(); 56 | dol_fiche_head( 57 | $head, 58 | 'about', 59 | $langs->trans("Module104740Name"), 60 | 0, 61 | 'importdevis@importdevis' 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/importdevis_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 importdevis 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 importdevisbox extends ModeleBoxes 31 | { 32 | 33 | public $boxcode = "mybox"; 34 | public $boximg = "importdevis@importdevis"; 35 | public $boxlabel; 36 | public $depends = array("importdevis"); 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 . "/importdevis/class/importdevis.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 | } -------------------------------------------------------------------------------- /class/actions_importdevis.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_importdevis.class.php 21 | * \ingroup importdevis 22 | * \brief This file is an example hook overload class file 23 | * Put some comments here 24 | */ 25 | 26 | /** 27 | * Class Actionsimportdevis 28 | */ 29 | class Actionsimportdevis 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 | * Constructor 48 | */ 49 | public function __construct() 50 | { 51 | } 52 | 53 | /** 54 | * Overloading the doActions function : replacing the parent's function with the one below 55 | * 56 | * @param array() $parameters Hook metadatas (context, etc...) 57 | * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 58 | * @param string &$action Current action (if set). Generally create or edit or null 59 | * @param HookManager $hookmanager Hook manager propagated to allow calling another hook 60 | * @return int < 0 on error, 0 on success, 1 to replace standard code 61 | */ 62 | function doActions($parameters, &$object, &$action, $hookmanager) 63 | { 64 | $error = 0; // Error counter 65 | $myvalue = 'test'; // A result value 66 | 67 | print_r($parameters); 68 | echo "action: " . $action; 69 | print_r($object); 70 | 71 | if (in_array('somecontext', explode(':', $parameters['context']))) 72 | { 73 | // do something only for the context 'somecontext' 74 | } 75 | 76 | if (! $error) 77 | { 78 | $this->results = array('myreturn' => $myvalue); 79 | $this->resprints = 'A text to show'; 80 | return 0; // or return 1 to replace standard code 81 | } 82 | else 83 | { 84 | $this->errors[] = 'Error message'; 85 | return -1; 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /admin/importdevis_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/importdevis.php 21 | * \ingroup importdevis 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 | require '../config.php'; 32 | // Libraries 33 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 34 | require_once '../lib/importdevis.lib.php'; 35 | 36 | // Translations 37 | $langs->load("importdevis@importdevis"); 38 | 39 | // Access control 40 | if (! $user->admin) { 41 | accessforbidden(); 42 | } 43 | 44 | // Parameters 45 | $action = GETPOST('action', 'alpha'); 46 | 47 | /* 48 | * Actions 49 | */ 50 | if (preg_match('/set_(.*)/',$action,$reg)) 51 | { 52 | $code=$reg[1]; 53 | if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) 54 | { 55 | header("Location: ".$_SERVER["PHP_SELF"]); 56 | exit; 57 | } 58 | else 59 | { 60 | dol_print_error($db); 61 | } 62 | } 63 | 64 | if (preg_match('/del_(.*)/',$action,$reg)) 65 | { 66 | $code=$reg[1]; 67 | if (dolibarr_del_const($db, $code, 0) > 0) 68 | { 69 | Header("Location: ".$_SERVER["PHP_SELF"]); 70 | exit; 71 | } 72 | else 73 | { 74 | dol_print_error($db); 75 | } 76 | } 77 | 78 | /* 79 | * View 80 | */ 81 | $page_name = "importdevisSetup"; 82 | llxHeader('', $langs->trans($page_name)); 83 | 84 | // Subheader 85 | $linkback = '' 86 | . $langs->trans("BackToModuleList") . ''; 87 | print_fiche_titre($langs->trans($page_name), $linkback); 88 | 89 | // Configuration header 90 | $head = importdevisAdminPrepareHead(); 91 | dol_fiche_head( 92 | $head, 93 | 'settings', 94 | $langs->trans("Module104740Name"), 95 | 0, 96 | "importdevis@importdevis" 97 | ); 98 | 99 | // Setup page goes here 100 | $form=new Form($db); 101 | $formabricot=new TFormCore; 102 | 103 | $var=false; 104 | print ''; 105 | print ''; 106 | print ''."\n"; 107 | print ''; 108 | print ''."\n"; 109 | 110 | $TFormat = array('SMARTBOM' => 'SMARTBOM'); 111 | $TOtherFormat = explode(',', $conf->global->IMPORTPROPAL_OTHERFORMAT); 112 | if (count($TOtherFormat) > 0) 113 | { 114 | foreach ($TOtherFormat as $format) 115 | { 116 | if (empty($format)) continue; 117 | 118 | $TFormat[$format] = $format; 119 | } 120 | } 121 | 122 | // Example with a yes / no select 123 | $var=!$var; 124 | print ''; 125 | print ''; 126 | print ''; 127 | print ''; 135 | 136 | $var=!$var; 137 | print ''; 138 | print ''; 139 | print ''; 140 | print ''; 143 | 144 | $var=!$var; 145 | print ''; 146 | print ''; 147 | print ''; 148 | print ''; 151 | 152 | $var=!$var; 153 | print ''; 154 | print ''; 155 | print ''; 156 | print ''; 164 | 165 | $var=!$var; 166 | print ''; 167 | print ''; 168 | print ''; 169 | print ''; 172 | 173 | print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans("IMPORTPROPAL_FORMAT").' '; 128 | print '
'; 129 | print ''; 130 | print ''; 131 | print $form->textwithpicto($formabricot->combo('', 'IMPORTPROPAL_FORMAT', $TFormat, $conf->global->IMPORTPROPAL_FORMAT), $langs->transnoentitiesnoconv('IMPORTPROPAL_FORMAT_INFO'), -1); 132 | print ''; 133 | print '
'; 134 | print '
'.$langs->trans("IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE").' '; 141 | print ajax_constantonoff('IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE'); 142 | print '
'.$langs->trans("CREATE_PRODUCT_FROM_IMPORT").' '; 149 | print ajax_constantonoff('CREATE_PRODUCT_FROM_IMPORT'); 150 | print '
'.$langs->trans("IMPORTPROPAL_FORCE_TVA").' '; 157 | print '
'; 158 | print ''; 159 | print ''; 160 | print ' % '; 161 | print ''; 162 | print '
'; 163 | print '
'.$langs->trans("IMPORTDEVIS_UPDATE_PRODUCT").' '; 170 | print ajax_constantonoff('IMPORTDEVIS_UPDATE_PRODUCT'); 171 | print '
'; 174 | 175 | llxFooter(); 176 | 177 | $db->close(); -------------------------------------------------------------------------------- /lib/importdevis.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/importdevis.lib.php 21 | * \ingroup importdevis 22 | * \brief This file is an example module library 23 | * Put some comments here 24 | */ 25 | 26 | function importdevisAdminPrepareHead() 27 | { 28 | global $langs, $conf; 29 | 30 | $langs->load("importdevis@importdevis"); 31 | 32 | $h = 0; 33 | $head = array(); 34 | 35 | $head[$h][0] = dol_buildpath("/importdevis/admin/importdevis_setup.php", 1); 36 | $head[$h][1] = $langs->trans("Parameters"); 37 | $head[$h][2] = 'settings'; 38 | $h++; 39 | $head[$h][0] = dol_buildpath("/importdevis/admin/importdevis_about.php", 1); 40 | $head[$h][1] = $langs->trans("About"); 41 | $head[$h][2] = 'about'; 42 | $h++; 43 | 44 | // Show more tabs from modules 45 | // Entries must be declared in modules descriptor with line 46 | //$this->tabs = array( 47 | // 'entity:+tabname:Title:@importdevis:/importdevis/mypage.php?id=__ID__' 48 | //); // to add new tab 49 | //$this->tabs = array( 50 | // 'entity:-tabname:Title:@importdevis:/importdevis/mypage.php?id=__ID__' 51 | //); // to remove a tab 52 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'importdevis'); 53 | 54 | return $head; 55 | } 56 | function _importFileParseCSV(&$file, $nb_line_to_avoid) { 57 | global $conf; 58 | 59 | $handle = fopen($file['tmp_name'], 'r'); 60 | $method = 'lineMapper_'.$conf->global->IMPORTPROPAL_FORMAT; 61 | $method_after = 'dataParserAfter_'.$conf->global->IMPORTPROPAL_FORMAT; 62 | 63 | $k = 0; 64 | $TData = array(); 65 | while (!feof($handle)) 66 | { 67 | $input = trim(fgets($handle,4096)); // obligé sinon prend des lignes vides 68 | if(empty($input)) continue; 69 | 70 | $line = str_getcsv($input,';','"'); 71 | 72 | if($k<$nb_line_to_avoid) { 73 | null; 74 | } 75 | else{ 76 | if (!empty($line) ) { 77 | 78 | if(function_exists($method)) { 79 | $line = call_user_func($method, $line); 80 | } 81 | 82 | $TData[] = $line; 83 | } 84 | 85 | } 86 | 87 | 88 | $k++; 89 | } 90 | 91 | if(function_exists($method_after)) { 92 | $TData = call_user_func($method_after, $TData); 93 | } 94 | 95 | 96 | fclose($handle); 97 | 98 | return $TData; 99 | } 100 | function lineMapper_DGPF($line) { 101 | 102 | $line[0] = trim($line[0]); 103 | $line[1] = trim($line[1]); 104 | $line[2] = trim($line[2]); 105 | $line[3] = trim($line[3]); 106 | 107 | if (empty($line[0]) && empty($line[1])) return ''; 108 | 109 | $niveau = trim($line[0]); 110 | $niveau = empty($niveau) ? null : explode('.', $niveau); 111 | $level = count($niveau); 112 | 113 | 114 | /** 115 | * $line 116 | * [0] = numéro titre ou ligne 117 | * [1] = titre/label 118 | * [2] = unité 119 | * [3] = qty 120 | * 121 | * Processus pour détection des lignes : 122 | * - Si unité => ligne d’ouvrage, reliée à la 1ère ligne de titre du dessus 123 | * - Si désignation uniquement => description de l’ouvrage 124 | * - Si quantité vide => Mettre 999999 (voir affichage en rouge) 125 | * - Si indice et pas de quantité ni d’unité => ligne de chapitre 126 | * * Regarder l’indice pour connaître le niveau du chapitre 127 | * * Exemple : si indice A.6.d.12 => Niveau 4 128 | * * Exemple : si indice C-3-3 => Niveau 3 129 | */ 130 | $is_title = true; 131 | 132 | if (!empty($line[2]) && $line[2] != '.') $is_title = false; 133 | elseif (empty($line[0]) && empty($line[2]) && empty($line[3])) return ''; // vu comment le système fonctionne actuellement les descriptions ne peuvent pas être ajoutés 134 | 135 | if (!$is_title && empty($line[3])) $line[3] = 999999; 136 | 137 | $fk_unit = _getFkUnitByCode($line[2]); 138 | 139 | $Tab=array( 140 | 'label'=>$line[0].' - '.$line[1] 141 | ,'qty'=>empty($line[3]) ? 1 : (float)$line[3] 142 | ,'type'=>$is_title ? 'title' : 'line' 143 | ,'product_ref'=>'' 144 | ,'title1'=>$line[1] 145 | ,'title2'=>'' 146 | ,'title3'=>'' 147 | ,'level'=>$level 148 | ,'price'=>0 149 | ,'fk_unit'=>$fk_unit 150 | ); 151 | 152 | return $Tab; 153 | 154 | } 155 | 156 | function _getFkUnitByCode($code) 157 | { 158 | global $db,$conf; 159 | 160 | if (empty($conf->global->PRODUCT_USE_UNITS)) return null; 161 | 162 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'c_units WHERE code = "'.$db->escape($code).'"'; 163 | $resql = $db->query($sql); 164 | 165 | if ($resql && $db->num_rows($resql) > 0) 166 | { 167 | $obj = $db->fetch_object($resql); 168 | return $obj->rowid; 169 | } 170 | 171 | return null; 172 | } 173 | 174 | function lineMapper_SMARTBOM($line) { 175 | //var_dump($line); 176 | 177 | //if(empty($line[3]) && empty($line[4])) return false; 178 | 179 | $label=$line[3].'_'.$line[4]; 180 | if (!empty($line[12]) && $line[12]!="Matériau "){ 181 | $label.='_'.$line[12]; 182 | } 183 | if (!empty($line[8])){ 184 | $label.='_'.$line[8]; 185 | } 186 | if (!empty($line[9])){ 187 | $label.='_'.$line[9]; 188 | } 189 | if (!empty($line[10])){ 190 | $label.='_'.$line[10]; 191 | } 192 | if (!empty($line[11])){ 193 | $label.='_'.$line[11]; 194 | } 195 | 196 | $Tab=array( 197 | 'label'=> $label 198 | ,'qty'=> $line[13] 199 | ,'type'=>'line' 200 | ,'product_ref'=>dol_string_nospecial($label) 201 | ,'title0'=>$line[1] 202 | ,'title1'=>$line[2] 203 | ,'title2'=>$line[3] 204 | ,'title3'=>$line[4] 205 | ,'level'=>0 206 | ,'price'=>$line[16] 207 | ,'length'=>$line[8] 208 | ,'width' => $line[10] 209 | ,'height' => $line[9] 210 | ,'weight' => $line[11] 211 | ,'buy_price' => $line[17] 212 | ,'ref'=> $line[4] 213 | ); 214 | 215 | return $Tab; 216 | 217 | } 218 | 219 | function _dPA_SMARTBOM_add_title(&$Tab, $label, $level=1) { 220 | global $conf; 221 | //var_dump($Tab); 222 | $label = trim($label); 223 | 224 | if(empty($conf->subtotal->enabled)) return false; 225 | if(empty($label)) return false; 226 | 227 | $nb = count($Tab); 228 | 229 | $found = false; 230 | for($k = $nb-1;$k>=0;$k--) { 231 | 232 | if($Tab[$k]['type'] == 'title' && $Tab[$k]['label'] === $label && $Tab[$k]['level'] == $level) { 233 | $found = true; 234 | break; 235 | } 236 | else if($Tab[$k]['type'] == 'title' && $Tab[$k]['level'] == $level) { 237 | break; 238 | } 239 | 240 | } 241 | 242 | if(!$found) { 243 | 244 | /*$Tab[]=array( 245 | 'label'=>'Sous-total' 246 | ,'type'=>'subtotal' 247 | ,'qty'=>0 248 | ,'level'=>$level 249 | 250 | )*/ 251 | 252 | $Tab[] = array( 253 | 'label'=>$label 254 | ,'qty'=>0 255 | ,'level'=>$level 256 | ,'type'=>'title' 257 | 258 | ); 259 | 260 | } 261 | 262 | 263 | 264 | if($found === false) return false; 265 | else return $k; 266 | } 267 | 268 | function dataParserAfter_SMARTBOM($TData) { 269 | 270 | $Tab = array(); 271 | 272 | foreach($TData as &$row) { 273 | 274 | _dPA_SMARTBOM_add_title($Tab, $row['title0']); 275 | _dPA_SMARTBOM_add_title($Tab, $row['title1'],2); 276 | _dPA_SMARTBOM_add_title($Tab, $row['title2'],3); 277 | //_dPA_SMARTBOM_add_title($Tab, $row['title3'],4); 278 | 279 | 280 | $Tab[] = $row; 281 | } 282 | 283 | return $Tab; 284 | } 285 | 286 | function _importFileParseXLS2(&$file, $nb_line_to_avoid) { 287 | global $conf; 288 | 289 | set_time_limit(0); 290 | $TData=array(); 291 | $method = 'lineMapper_'.$conf->global->IMPORTPROPAL_FORMAT; 292 | $method_after = 'dataParserAfter_'.$conf->global->IMPORTPROPAL_FORMAT; 293 | 294 | $filename = sys_get_temp_dir().'/'. $file['name']; 295 | copy($file['tmp_name'], $filename); 296 | require(__DIR__.'/PHPExcel/Classes/PHPExcel.php'); 297 | 298 | $objReader = PHPExcel_IOFactory::createReader('Excel2007'); 299 | /** Advise the Reader of which WorkSheets we want to load **/ 300 | $objReader->setReadDataOnly(true); 301 | $objReader->setLoadSheetsOnly('Exemple'); 302 | 303 | 304 | $objPHPExcel = $objReader->load($filename); 305 | $objWorksheet = $objPHPExcel->setActiveSheetIndex(0); 306 | $k=0; 307 | foreach ($objWorksheet->getRowIterator() as $row) { 308 | $cellIterator = $row->getCellIterator(); 309 | $cellIterator->setIterateOnlyExistingCells(false); // This loops all cells, 310 | // even if it is not set. 311 | $k++; 312 | // By default, only cells 313 | if($k<=$nb_line_to_avoid) continue; // that are set will be 314 | 315 | $line = array(); 316 | foreach ($cellIterator as $cell) { 317 | $line[] =$cell->getValue(); 318 | } 319 | 320 | if(function_exists($method)) { 321 | $line = call_user_func($method, $line); 322 | } 323 | 324 | if (!empty($line) ) { 325 | $TData[] = $line; 326 | } 327 | 328 | 329 | } if(function_exists($method)) { 330 | $line = call_user_func($method, $line); 331 | } 332 | 333 | if (!empty($line) ) { 334 | $TData[] = $line; 335 | } 336 | 337 | 338 | if(function_exists($method_after)) { 339 | $TData = call_user_func($method_after, $TData); 340 | } 341 | 342 | return $TData; 343 | 344 | } 345 | 346 | function _importFileParseXLS(&$file, $nb_line_to_avoid) { 347 | global $conf; 348 | 349 | dol_include_once('/importdevis/lib/spreadsheet-reader/php-excel-reader/excel_reader2.php'); 350 | dol_include_once('/importdevis/lib/spreadsheet-reader/SpreadsheetReader.php'); 351 | 352 | $method = 'lineMapper_'.$conf->global->IMPORTPROPAL_FORMAT; 353 | $method_after = 'dataParserAfter_'.$conf->global->IMPORTPROPAL_FORMAT; 354 | 355 | $filename = sys_get_temp_dir().'/'. $file['name']; 356 | copy($file['tmp_name'], $filename); 357 | 358 | $Reader = new SpreadsheetReader($filename); 359 | 360 | 361 | $Reader->ChangeSheet(0); 362 | //var_dump($Reader); 363 | $TData = array(); 364 | foreach ($Reader as $k => $line) { 365 | 366 | if($k<$nb_line_to_avoid) continue; 367 | 368 | if(function_exists($method)) { 369 | $line = call_user_func($method, array($line)); 370 | } 371 | 372 | if (!empty($line) ) { 373 | $TData[] = $line; 374 | } 375 | 376 | } 377 | 378 | if(function_exists($method_after)) { 379 | $TData = call_user_func($method_after, $TData); 380 | } 381 | 382 | 383 | return $TData; 384 | } 385 | 386 | function _generateArrayFromXML($file, $nb_line_to_avoid) 387 | { 388 | $TData = array(); 389 | $filename = sys_get_temp_dir().'/'. $file['name']; 390 | copy($file['tmp_name'], $filename); 391 | $TmpData = array(); 392 | // On récupère le fichier XML et on le convertie en tableau grace au json encode 393 | $array=json_decode(json_encode(simplexml_load_file($filename)),true); 394 | $indexNewTable = 1; 395 | foreach($array as $key => $item) 396 | { 397 | /*************************** 398 | * @Def 399 | * Colonne1 .. Colonne15 400 | **************************/ 401 | $subkey=preg_replace('/Colonne/', '', $key); // Catch only the number's column 402 | $i=0; 403 | foreach($item as $element => $text) 404 | { 405 | /*************************** 406 | * @Def 407 | * Name 408 | * element1 .. element40 409 | **************************/ 410 | $jump=false; 411 | $subelement=preg_replace('/element/', '', $element); // Catch only the number's row 412 | if(is_array($text))$text=null; // Eject array element because = empty value 413 | if(strtolower($subelement) === 'nom' || $i < $nb_line_to_avoid)$jump=true; 414 | if(!$jump) 415 | { 416 | $TmpData[$subelement][$indexNewTable] = $text; 417 | } 418 | $i++; 419 | } 420 | $indexNewTable++; 421 | } 422 | /* ************************************************************ 423 | * 424 | * Doit retourner un tableau avec cette structure (16 champs) 425 | * 426 | * ************************************************************ 427 | 428 | array (size=39) 429 | 1 => 430 | array (size=16) 431 | 1 => string '1' (length=1) 432 | 2 => string 'PRAGUE' (length=6) 433 | 3 => string 'V1' (length=2) 434 | 4 => string 'DOOR' (length=4) 435 | 5 => null 436 | 6 => null 437 | 7 => null 438 | 8 => string 'EDEN' (length=4) 439 | 9 => string '1297' (length=4) 440 | 10 => string '1008' (length=4) 441 | 11 => string '"D1@Boss.-Extru.1@@Défaut@Pièce28"' (length=36) 442 | 12 => string ' 6.1571 kg' (length=10) 443 | 13 => null 444 | 14 => string '1' (length=1) 445 | 15 => string '3194_PRAGUE_V1_DOOR_.SLDPRT' (length=27) 446 | 16 => string 'OUI' (length=3) 447 | 448 | 449 | */ 450 | return $TmpData; 451 | } 452 | 453 | function _importFileParseXML($file, $nb_line_to_avoid) 454 | { 455 | global $conf; 456 | 457 | $method = 'lineMapper_XML_'.$conf->global->IMPORTPROPAL_FORMAT; 458 | $method_after = 'dataParserAfter_'.$conf->global->IMPORTPROPAL_FORMAT; 459 | 460 | $array = _generateArrayFromXML($file, $nb_line_to_avoid); 461 | $TData = array(); 462 | foreach ($array as $item) 463 | { 464 | if(function_exists($method)) { 465 | $line = call_user_func($method, $item); 466 | } 467 | 468 | if (!empty($line) ) { 469 | $TData[] = $line; 470 | } 471 | } 472 | 473 | if(function_exists($method_after)) { 474 | $TData = call_user_func($method_after, $TData); 475 | } 476 | return $TData; 477 | } 478 | 479 | function lineMapper_XML_SMARTBOM($line) { 480 | //var_dump($line); 481 | if(empty($line[2]) && empty($line[3]) && empty($line[4])) return false; 482 | 483 | $label=$line[2].'_'.$line[3].'_'.$line[4]; 484 | if (!empty($line[5])){ 485 | $label.='_'.$line[5]; 486 | } 487 | if (!empty($line[13]) && $line[13]!="Matériau "){ 488 | $label.='_'.$line[13]; 489 | } 490 | if (!empty($line[9])){ 491 | $label.='_'.$line[9]; 492 | } 493 | if (!empty($line[10])){ 494 | $label.='_'.$line[10]; 495 | } 496 | //var_dump($line[15]);exit; 497 | 498 | $Tab=array( 499 | 'label' => $label 500 | ,'qty' => (float)$line[14] 501 | ,'type' => 'line' 502 | ,'product_ref'=> $line[1] 503 | ,'title1' => $line[2] 504 | ,'title2' => $line[3] 505 | ,'title3' => $line[4] 506 | ,'level' => 0 507 | ,'price' => $line[17] 508 | ,'width' => $line[9] 509 | ,'height' => $line[10] 510 | ,'weight' => $line[12] 511 | ,'buy_price' => $line[18] 512 | ); 513 | 514 | return $Tab; 515 | 516 | } 517 | 518 | function importFile(&$db, &$conf, &$langs) 519 | { 520 | $file = $_FILES['fileDGPF']; 521 | $info = pathinfo($file['name']); 522 | $TData = array(); 523 | 524 | if(strtolower($info['extension']) == 'csv') { 525 | $TData = _importFileParseCSV($file, GETPOST('nb_line_to_avoid')); 526 | } 527 | else if(strtolower($info['extension'] == 'xls')) { 528 | $TData = _importFileParseXLS2($file, GETPOST('nb_line_to_avoid')); 529 | } 530 | else if(strtolower($info['extension'] == 'xml')) { 531 | $TData = _importFileParseXML($file, GETPOST('nb_line_to_avoid')); 532 | } 533 | return $TData; 534 | } 535 | 536 | /** 537 | * Si $level == 0 alors on ajoute tous les sous-totaux restants 538 | */ 539 | function _addSousTotaux(&$langs, &$object, &$TLastLevelTitleAdded, $level=0) 540 | { 541 | $lastIndex = count($TLastLevelTitleAdded)-1; 542 | if ($lastIndex < 0) $lastIndex = 0; 543 | 544 | if ($level <= $TLastLevelTitleAdded[$lastIndex]) 545 | { 546 | for ($i = $lastIndex; $i >= 0; $i--) 547 | { 548 | if (is_null($TLastLevelTitleAdded[$i])) continue; 549 | if ($level > $TLastLevelTitleAdded[$i]) break; 550 | // Add sous-total 551 | TSubtotal::addSubTotalLine($object,$langs->trans('SubTotal'), 100-$TLastLevelTitleAdded[$i]); 552 | $TLastLevelTitleAdded[$i] = null; // Nettoyage du tableau 553 | } 554 | } 555 | } 556 | 557 | function getTypeLine() 558 | { 559 | global $conf,$langs; 560 | 561 | $Tab = array(); 562 | 563 | if (!empty($conf->subtotal->enabled)) $Tab['title'] = $langs->trans('title'); 564 | $Tab['line'] = $langs->trans('product'); 565 | if (!empty($conf->nomenclature->enabled)) $Tab['nomenclature'] = $langs->trans('nomenclatureComponent'); 566 | if (!empty($conf->workstation->enabled)) $Tab['workstation'] = $langs->trans('WorkStation'); 567 | return $Tab; 568 | } 569 | 570 | 571 | function getLevelTitle() 572 | { 573 | global $conf,$langs; 574 | 575 | $Tab = array(); 576 | 577 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) 578 | { 579 | for ($i=1; $i <= 10; $i++) 580 | { 581 | $Tab[$i] = $langs->trans('Level'.$i); 582 | } 583 | } 584 | else 585 | { 586 | $Tab[1] = $langs->trans('Level1'); 587 | if ($conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL) $Tab[2] = $langs->trans('Level2'); 588 | } 589 | 590 | return $Tab; 591 | } 592 | 593 | 594 | function lineMapper_IMMECA($line) 595 | { 596 | if (empty($line[2])) return false; // Si label vide 597 | 598 | $Tab=array( 599 | 'label'=>$line[2] 600 | ,'qty'=>$line[3] 601 | ,'type'=>'line' 602 | ,'product_ref'=>dol_string_nospecial($line[1]) 603 | ,'level'=>0 604 | ,'price'=>$line[4] 605 | ); 606 | 607 | return $Tab; 608 | } 609 | -------------------------------------------------------------------------------- /core/modules/modimportdevis.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 importdevis Module importdevis 22 | * \brief Example of a module descriptor. 23 | * Such a file must be copied into htdocs/importdevis/core/modules directory. 24 | * \file htdocs/importdevis/core/modules/modimportdevis.class.php 25 | * \ingroup importdevis 26 | * \brief Description and activation file for module importdevis 27 | */ 28 | include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; 29 | 30 | 31 | /** 32 | * Description and activation class for module importdevis 33 | */ 34 | class modimportdevis 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, $user; 44 | 45 | $this->db = $db; 46 | 47 | // Id for module (must be unique). 48 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). 49 | $this->numero = 104740; // 104000 to 104999 for ATM CONSULTING 50 | // Key text used to identify module (for permissions, menus, etc...) 51 | $this->rights_class = 'importdevis'; 52 | 53 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' 54 | // It is used to group modules in module setup page 55 | $this->family = "ATM"; 56 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) 57 | $this->name = preg_replace('/^mod/i','',get_class($this)); 58 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) 59 | $this->description = "Description of module importdevis"; 60 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version 61 | $this->version = '1.0'; 62 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) 63 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); 64 | // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) 65 | $this->special = 0; 66 | // Name of image file used for this module. 67 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' 68 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' 69 | $this->picto='importdevis@importdevis'; 70 | 71 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) 72 | // for default path (eg: /importdevis/core/xxxxx) (0=disable, 1=enable) 73 | // for specific path of parts (eg: /importdevis/core/modules/barcode) 74 | // for specific css file (eg: /importdevis/css/importdevis.css.php) 75 | //$this->module_parts = array( 76 | // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) 77 | // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) 78 | // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) 79 | // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) 80 | // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) 81 | // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 82 | // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 83 | // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 84 | // 'css' => array('/importdevis/css/importdevis.css.php'), // Set this to relative path of css file if module has its own css file 85 | // 'js' => array('/importdevis/js/importdevis.js'), // Set this to relative path of js file if module must load a js on all pages 86 | // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module 87 | // 'dir' => array('output' => 'othermodulename'), // To force the default directories names 88 | // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@importdevis')) // Set here all workflow context managed by module 89 | // ); 90 | $this->module_parts = array(); 91 | 92 | // Data directories to create when module is enabled. 93 | // Example: this->dirs = array("/importdevis/temp"); 94 | $this->dirs = array(); 95 | 96 | // Config pages. Put here list of php page, stored into importdevis/admin directory, to use to setup module. 97 | $this->config_page_url = array("importdevis_setup.php@importdevis"); 98 | 99 | // Dependencies 100 | $this->hidden = false; // A condition to hide module 101 | $this->depends = array(); // List of modules id that must be enabled if this module is enabled 102 | $this->requiredby = array(); // List of modules id to disable if this one is disabled 103 | $this->conflictwith = array(); // List of modules id this module is in conflict with 104 | $this->phpmin = array(5,0); // Minimum version of PHP required by module 105 | $this->need_dolibarr_version = array(3,7); // Minimum version of Dolibarr required by module 106 | $this->langfiles = array("importdevis@importdevis"); 107 | 108 | // Constants 109 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) 110 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), 111 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) 112 | // ); 113 | $this->const = array(); 114 | 115 | // Array to add new pages in new tabs 116 | // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@importdevis:$user->rights->importdevis->read:/importdevis/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 117 | // 'objecttype:+tabname2:Title2:mylangfile@importdevis:$user->rights->othermodule->read:/importdevis/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 118 | // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname 119 | // where objecttype can be 120 | // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) 121 | // 'contact' to add a tab in contact view 122 | // 'contract' to add a tab in contract view 123 | // 'group' to add a tab in group view 124 | // 'intervention' to add a tab in intervention view 125 | // 'invoice' to add a tab in customer invoice view 126 | // 'invoice_supplier' to add a tab in supplier invoice view 127 | // 'member' to add a tab in fundation member view 128 | // 'opensurveypoll' to add a tab in opensurvey poll view 129 | // 'order' to add a tab in customer order view 130 | // 'order_supplier' to add a tab in supplier order view 131 | // 'payment' to add a tab in payment view 132 | // 'payment_supplier' to add a tab in supplier payment view 133 | // 'product' to add a tab in product view 134 | // 'propal' to add a tab in propal view 135 | // 'project' to add a tab in project view 136 | // 'stock' to add a tab in stock view 137 | // 'thirdparty' to add a tab in third party view 138 | // 'user' to add a tab in user view 139 | 140 | $this->tabs = array( 141 | 'propal:+importdevis:Import:importdevis@importdevis:$user->rights->importdevis->myactions->propaltab:/importdevis/importdevis.php?origin=propal&id=__ID__', 142 | 'order:+importdevis:Import:importdevis@importdevis:$user->rights->importdevis->myactions->ordertab:/importdevis/importdevis.php?origin=order&id=__ID__' 143 | ); 144 | 145 | // Dictionaries 146 | if (! isset($conf->importdevis->enabled)) 147 | { 148 | $conf->importdevis=new stdClass(); 149 | $conf->importdevis->enabled=0; 150 | } 151 | $this->dictionaries=array(); 152 | /* Example: 153 | if (! isset($conf->importdevis->enabled)) $conf->importdevis->enabled=0; // This is to avoid warnings 154 | $this->dictionaries=array( 155 | 'langs'=>'mylangfile@importdevis', 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->importdevis->enabled,$conf->importdevis->enabled,$conf->importdevis->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] = 'Autorise l\'accès à l\'onglet DGPF sur une propal'; // Permission label 182 | $this->rights[$r][3] = 0; // Permission by default for new user (0/1) 183 | $this->rights[$r][4] = 'myactions'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 184 | $this->rights[$r][5] = 'propaltab'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 185 | $r++; 186 | 187 | $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) 188 | $this->rights[$r][1] = $langs->trans('SEE_ORDER_TAB'); // Permission label 189 | $this->rights[$r][3] = 0; // Permission by default for new user (0/1) 190 | $this->rights[$r][4] = 'myactions'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 191 | $this->rights[$r][5] = 'ordertab'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 192 | $r++; 193 | 194 | 195 | // Main menu entries 196 | $this->menu = array(); // List of menus to add 197 | $r=0; 198 | 199 | // Add here entries to declare new menus 200 | // 201 | // Example to declare a new Top Menu entry and its Left menu entry: 202 | // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu 203 | // 'type'=>'top', // This is a Top menu entry 204 | // 'titre'=>'importdevis top menu', 205 | // 'mainmenu'=>'importdevis', 206 | // 'leftmenu'=>'importdevis', 207 | // 'url'=>'/importdevis/pagetop.php', 208 | // 'langs'=>'mylangfile@importdevis', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 209 | // 'position'=>100, 210 | // 'enabled'=>'$conf->importdevis->enabled', // Define condition to show or hide menu entry. Use '$conf->importdevis->enabled' if entry must be visible if module is enabled. 211 | // 'perms'=>'1', // Use 'perms'=>'$user->rights->importdevis->level1->level2' if you want your menu with a permission rules 212 | // 'target'=>'', 213 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 214 | // $r++; 215 | // 216 | // Example to declare a Left Menu entry into an existing Top menu entry: 217 | // $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 218 | // 'type'=>'left', // This is a Left menu entry 219 | // 'titre'=>'importdevis left menu', 220 | // 'mainmenu'=>'xxx', 221 | // 'leftmenu'=>'importdevis', 222 | // 'url'=>'/importdevis/pagelevel2.php', 223 | // 'langs'=>'mylangfile@importdevis', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 224 | // 'position'=>100, 225 | // 'enabled'=>'$conf->importdevis->enabled', // Define condition to show or hide menu entry. Use '$conf->importdevis->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 226 | // 'perms'=>'1', // Use 'perms'=>'$user->rights->importdevis->level1->level2' if you want your menu with a permission rules 227 | // 'target'=>'', 228 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 229 | // $r++; 230 | 231 | 232 | // Exports 233 | $r=1; 234 | 235 | // Example: 236 | // $this->export_code[$r]=$this->rights_class.'_'.$r; 237 | // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) 238 | // $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. 239 | // $this->export_permission[$r]=array(array("facture","facture","export")); 240 | // $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'); 241 | // $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'); 242 | // $this->export_sql_start[$r]='SELECT DISTINCT '; 243 | // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; 244 | // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; 245 | // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; 246 | // $this->export_sql_order[$r] .=' ORDER BY s.nom'; 247 | // $r++; 248 | } 249 | 250 | /** 251 | * Function called when module is enabled. 252 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. 253 | * It also creates data directories 254 | * 255 | * @param string $options Options when enabling module ('', 'noboxes') 256 | * @return int 1 if OK, 0 if KO 257 | */ 258 | function init($options='') 259 | { 260 | $sql = array(); 261 | 262 | define('INC_FROM_DOLIBARR',true); 263 | 264 | dol_include_once('/importdevis/config.php'); 265 | dol_include_once('/importdevis/script/create-maj-base.php'); 266 | 267 | $result=$this->_load_tables('/importdevis/sql/'); 268 | 269 | return $this->_init($sql, $options); 270 | } 271 | 272 | /** 273 | * Function called when module is disabled. 274 | * Remove from database constants, boxes and permissions from Dolibarr database. 275 | * Data directories are not deleted 276 | * 277 | * @param string $options Options when enabling module ('', 'noboxes') 278 | * @return int 1 if OK, 0 if KO 279 | */ 280 | function remove($options='') 281 | { 282 | $sql = array(); 283 | 284 | return $this->_remove($sql, $options); 285 | } 286 | 287 | } 288 | -------------------------------------------------------------------------------- /importdevis.php: -------------------------------------------------------------------------------- 1 | subtotal->enabled)) dol_include_once('/subtotal/class/subtotal.class.php'); 11 | if (!empty($conf->nomenclature->enabled)) dol_include_once('/nomenclature/class/nomenclature.class.php'); 12 | set_time_limit(0); 13 | $PDOdb = new TPDOdb; 14 | //var_dump($_REQUEST);exit; 15 | 16 | $doliversion = (float) DOL_VERSION; 17 | $langs->Load('importdevis@importdevis'); 18 | 19 | $id = GETPOST('id', 'int'); 20 | $delete_lines_before_import = GETPOST('delete_lines_before_import'); 21 | $origin = GETPOST('origin'); 22 | $action = GETPOST('action', 'alpha'); 23 | $error = false; 24 | 25 | $object= ''; 26 | if ($origin=='propal'){ 27 | $result = restrictedArea($user, 'propal', $id); 28 | //var_dump($result);exit; 29 | $object = new Propal($db); 30 | }else{ 31 | $result = restrictedArea($user,'commande', $id); 32 | //var_dump($result, $origin);exit; 33 | $object = new Commande($db); 34 | 35 | } 36 | if ($id > 0) { 37 | $ret = $object->fetch($id); 38 | if ($ret > 0) 39 | $ret = $object->fetch_thirdparty(); 40 | if ($ret < 0) 41 | dol_print_error('', $object->error); 42 | if ($object->statut != Propal::STATUS_DRAFT || $object->statut != Commande::STATUS_DRAFT) 43 | { 44 | //var_dump('toto');exit; 45 | $error = true; 46 | setEventMessages($langs->trans('importdevis'.$origin.'DraftWarning'), null, 'warnings'); 47 | } 48 | 49 | } 50 | 51 | 52 | if ($action == 'send_file') 53 | { 54 | $TData = importFile($db, $conf, $langs); 55 | fiche_preview($object, $TData); 56 | 57 | exit; 58 | } 59 | else if($action == 'import_data') { 60 | 61 | if(!empty($delete_lines_before_import) && !empty($object->lines)) { 62 | foreach($object->lines as $l) { 63 | $l->delete(); 64 | } 65 | } 66 | 67 | $default_tva = 0; 68 | if (!empty($conf->global->IMPORTPROPAL_FORCE_TVA)) $default_tva = $conf->global->IMPORTPROPAL_FORCE_TVA; 69 | $TLastLevelTitleAdded = array(); // Tableau pour empiler et dépiller les niveaux de titre pour ensuite ajouter les sous-totaux 70 | $TData = $_REQUEST['TData']; 71 | $last_line_id = null; 72 | $last_line_product = null; 73 | 74 | foreach($TData as $k=>$row) 75 | { 76 | 77 | if (empty($row['to_import'])) continue; 78 | elseif(!empty($conf->subtotal->enabled) && $row['type'] == 'title') 79 | { 80 | _addSousTotaux($langs, $object, $TLastLevelTitleAdded, $row['level']); 81 | 82 | // Add title ou sub-title 83 | TSubtotal::addSubTotalLine($object,$row['label'], 0+$row['level']); 84 | $TLastLevelTitleAdded[] = $row['level']; 85 | } 86 | else if (!empty($conf->nomenclature->enabled) && ($row['type'] == 'nomenclature' || $row['type'] == 'workstation')) 87 | { 88 | 89 | //var_dump($last_line_product,$last_line_id);exit; 90 | if ($last_line_id > 0) 91 | { 92 | 93 | $nomenclature = new TNomenclature; 94 | $workstation = new TWorkstation; 95 | 96 | if($last_line_product>0 && !empty($conf->global->CREATE_PRODUCT_FROM_IMPORT)) { 97 | $nomenclature->loadByObjectId($PDOdb, $last_line_product, 'product'); 98 | $nomenclature->fk_object = $last_line_product; 99 | $nomenclature->fk_nomenclature_parent = 0; 100 | $nomenclature->is_default = 0; 101 | $nomenclature->object_type ='product'; 102 | $nomenclature->save($PDOdb); 103 | 104 | } 105 | else { 106 | $nomenclature->loadByObjectId($PDOdb, $last_line_id, $object->element); 107 | $nomenclature->fk_object = $last_line_id; 108 | $nomenclature->fk_nomenclature_parent = 0; 109 | $nomenclature->is_default = 0; 110 | $nomenclature->object_type = $object->element; 111 | $nomenclature->save($PDOdb); 112 | 113 | } 114 | 115 | if(!empty($row['fk_product'])) { 116 | $k = $nomenclature->addChild($PDOdb, 'TNomenclatureDet'); 117 | $nomenclature->TNomenclatureDet[$k]->fk_product = $row['fk_product']; 118 | $nomenclature->TNomenclatureDet[$k]->title = $row['label']; 119 | $nomenclature->TNomenclatureDet[$k]->fk_nomenclature = $nomenclature->getId(); 120 | $nomenclature->TNomenclatureDet[$k]->qty = $row['qty']; 121 | $nomenclature->TNomenclatureDet[$k]->price = $row['price']; 122 | $nomenclature->TNomenclatureDet[$k]->is_imported = $last_line_id; 123 | } 124 | 125 | if (!empty($row['fk_workstation']) && !empty($conf->workstation->enabled)){ 126 | //var_dump('tata');exit; 127 | $workstation->loadBy($PDOdb, $row['ref'], 'code'); 128 | 129 | $k = $nomenclature->addChild($PDOdb, 'TNomenclatureWorkstation'); 130 | $det = &$nomenclature->TNomenclatureWorkstation[$k]; 131 | $det->fk_workstation = $row['fk_workstation']; 132 | $det->qty = $row['qty']; 133 | } 134 | 135 | $nomenclature->save($PDOdb); 136 | 137 | } 138 | } 139 | else if ($row['type']='line'){ 140 | $product=new Product($db); 141 | $fk_product = $row['fk_product']; 142 | $ref = $row['product_ref']; 143 | 144 | $res = $product->fetch($fk_product, $ref); 145 | //var_dump($product);exit; 146 | 147 | $product->ref = $ref; 148 | $product->label = $row['label']; 149 | $product->price = $row['price']; 150 | $product->weight = $row['weight']; 151 | $product->length = $row['length']; 152 | $product->buyprice = $row['buy_price']; 153 | $product->status = 1; 154 | $product->status_buy = 1; 155 | 156 | if(!empty($row['buy_price'])){ 157 | $product->buyprice = $row['buy_price']; 158 | 159 | } 160 | //echo (int)$product->id; 161 | if (empty($product->id)){ 162 | if (!empty($conf->global->CREATE_PRODUCT_FROM_IMPORT)){ 163 | $product->create($user); 164 | } 165 | }else{ 166 | if (!empty($conf->global->IMPORTDEVIS_UPDATE_PRODUCT)) $product->update($product->id, $user); 167 | } 168 | 169 | //var_dump($product->id); 170 | $last_line_product = $product->id; 171 | 172 | if ($product->id > 0 && !empty($conf->global->CREATE_PRODUCT_FROM_IMPORT)) // TODO on pourrais faire de l'update line ici 173 | { 174 | $nomenclature = new TNomenclature; 175 | $nomenclature->loadByObjectId($PDOdb, $product->id, 'product'); 176 | $nomenclature->deleteChildrenNotImported($PDOdb); 177 | 178 | } 179 | 180 | 181 | if ($row['fk_propaldet'] > 0) // TODO on pourrais faire de l'update line ici 182 | { 183 | $last_line_id = $row['fk_propaldet']; 184 | $nomenclature = new TNomenclature; 185 | $nomenclature->loadByObjectId($PDOdb, $last_line_id, $object->element); 186 | $nomenclature->deleteChildrenNotImported($PDOdb); 187 | 188 | } 189 | 190 | else // Add line 191 | { 192 | 193 | // var_dump($product->id); 194 | if ($doliversion >= 3.8) 195 | { 196 | if ($row['fk_unit'] == 'none') $row['fk_unit'] = null; 197 | 198 | if($object->element=='facture') $last_line_id = $object->addline($row['label'], $row['price'],$row['qty'],$default_tva,0,0,$product->id,0,'','',0,0,'','HT',0,Facture::TYPE_STANDARD,-1,0,'',0,0,null,0,'',0,100,'',$row['fk_unit']); 199 | else if($object->element=='propal')$last_line_id = $object->addline($row['label'], $row['price'],$row['qty'],$default_tva,0,0,$product->id,0,'HT',0,0,0,-1,0,0,0,0,'','','',0,$row['fk_unit']); 200 | else if($object->element=='commande') $last_line_id = $object->addline($row['label'], $row['price'],$row['qty'],$default_tva,0,0,$product->id,0,0,0,'HT',0,'','',0,-1,0,0,null,0,'',0,$row['fk_unit']); 201 | } 202 | else 203 | { 204 | if($object->element=='facture') $last_line_id = $object->addline($row['label'], $row['price'],$row['qty'],$default_tva,0,0,$product->id,0,'','',0,0,'','HT'); 205 | else if($object->element=='propal')$last_line_id = $object->addline($row['label'], $row['price'],$row['qty'],$default_tva,0,0,$product->id); 206 | else if($object->element=='commande') $last_line_id = $object->addline($row['label'], $row['price'],$row['qty'],$default_tva,0,0,$product->id); 207 | 208 | } 209 | 210 | if($res<0) { 211 | var_dump($row,$last_line_id, $object->db); 212 | exit; 213 | } 214 | } 215 | } 216 | } 217 | //exit; 218 | if (!empty($conf->subtotal->enabled)) 219 | { 220 | // Check pour ajouter les derniers sous-totaux 221 | _addSousTotaux($langs, $object, $TLastLevelTitleAdded, 0); 222 | } 223 | 224 | setEventMessage("Lignes importées"); 225 | 226 | if($object->element=='propal') header('location:'.dol_buildpath('/comm/propal.php?id='.$object->id,1)); 227 | if($object->element=='commande') header('location:'.dol_buildpath('/commande/card.php?id='.$object->id, 1)); 228 | 229 | exit; 230 | } 231 | else { 232 | fiche_import($object, $error); 233 | } 234 | 235 | function fiche_preview(&$object, &$TData) { 236 | 237 | global $langs, $user, $db, $conf; 238 | 239 | //var_dump($_REQUEST);exit; 240 | $origin=GETPOST('origin'); 241 | $head=null; 242 | 243 | if ($object->element=='propal'){ 244 | $head = propal_prepare_head($object); 245 | }else{ 246 | $head = commande_prepare_head($object); 247 | } 248 | 249 | if (empty($user->rights->importdevis->myactions)) 250 | { 251 | accessforbidden(); 252 | exit; 253 | } 254 | 255 | $form=new Form($db); 256 | 257 | llxHeader(); 258 | $title = $langs->trans('Import'); 259 | if ($origin=='propal'){ 260 | dol_fiche_head($head, 'importdevis', $title, 0, 'propal'); 261 | }else{ 262 | dol_fiche_head($head, 'importdevis', $title, 0, 'commande'); 263 | } 264 | ?> 265 | 282 | 283 | 372 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | MO-1 384 | 385 | 386 | 387 | 550 | 551 |
trans('Ref'); ?>
ref; ?>
trans('Company'); ?>thirdparty->getNomUrl(1); ?>
388 | 389 | hidden('action', 'import_data'); 393 | echo $formCore->hidden('id', $object->id); 394 | echo $formCore->hidden('origin', $origin); 395 | echo $formCore->hidden('token', $_SESSION['newtoken']); 396 | echo $formCore->hidden('data', base64_encode(serialize($TData))); 397 | 398 | ?> 399 | 400 | 401 | 402 | 403 | subtotal->enabled) { ?> 404 | 405 | 406 | 407 | global->PRODUCT_USE_UNITS)) { ?> 408 | 409 | 410 | global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) { ?> 411 | 412 | 413 | 414 | global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) 417 | { 418 | $TPropalDet = array(); 419 | 420 | foreach ($object->lines as $line) 421 | { 422 | $label = !empty($line->label) ? $line->label : $line->desc; 423 | $label.= ' (qté : '.$line->qty.', total HT : '.$line->total_ht.')'; 424 | $TPropalDet[$line->id] = $label; 425 | } 426 | } 427 | $class = ''; 428 | //var_dump($TData); 429 | 430 | $TWorkstation = TWorkstation::getWorstations($PDOdb); 431 | 432 | foreach($TData as $k=>&$row) { 433 | //var_dump($row);MO-1 434 | $workstation = new TWorkstation; 435 | //var_dump($workstation->loadBy($PDOdb, $row['workstation'], 'code')); 436 | //var_dump($workstation);exit; 437 | 438 | if (!empty($row['ref'])) 439 | { 440 | $res = $workstation->loadBy($PDOdb, $row['ref'], 'code'); 441 | 442 | if ($res >0){ 443 | $row['type']='workstation'; 444 | $id_workstation = $workstation->getId(); 445 | //var_dump($workstation); 446 | 447 | } 448 | } 449 | 450 | 451 | $type=$row['type']; 452 | 453 | if($type == 'title') { 454 | $class = ''; 455 | print ''; 456 | print ''; 457 | print ''; 458 | print ''; 459 | print ''; 462 | print ''; 463 | print ''; 464 | if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''; 465 | print ''; 466 | print ''; 467 | } 468 | elseif($type == 'workstation'){ 469 | //var_dump($type); 470 | $class = ''; 471 | print ''; 472 | print ''; 473 | print ''; 474 | print ''; 475 | print ''; 479 | print ''; 480 | print ''; 481 | if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''; 482 | print ''; 483 | print ''; 484 | } 485 | else { 486 | $class = ($class == 'impair') ? 'pair' : 'impair'; 487 | print ''; 488 | print ''; 489 | print ''; 490 | if ($conf->subtotal->enabled) print ''; 491 | print ''; 511 | 512 | 513 | print ''; 524 | 525 | 526 | print ''; 527 | if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''; 528 | print ''; 529 | print ''; 530 | } 531 | 532 | if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) 533 | { 534 | print ''; 535 | } 536 | 537 | print ''; 538 | } 539 | //exit; 540 | ?> 541 |
Imp.TypeNiveauProduitLabelQtéUnitéPrix AchatPrixLigne d'origine
'.$formCore->checkbox1('', 'TData['.$k.'][to_import]', 1,true, '', 'check_imp').''.$form->selectarray('TData['.$k.'][type]', getTypeLine(), $row['type']).''.$form->selectarray('TData['.$k.'][level]', getLevelTitle(), $row['level']).''; 460 | //$form->select_produits(0, 'TData['.$k.'][fk_product]'); 461 | print ''.$formCore->texte('', 'TData['.$k.'][label]', $row['label'], 50,255) .''.$formCore->texte('', 'TData['.$k.'][qty]', $row['qty'], 3,20) .''.$formCore->texte('', 'TData['.$k.'][price]', $row['price'], 10,20) .''.$formCore->texte('', 'TData['.$k.'][price]', $row['price'], 10,20) .'
'.$formCore->checkbox1('', 'TData['.$k.'][to_import]', 1,true, '', 'check_imp').''.$form->selectarray('TData['.$k.'][type]', getTypeLine(), $row['type']).''; 476 | 477 | echo $formCore->combo('', 'TData['.$k.'][fk_workstation]', $TWorkstation,$id_workstation); 478 | print ''.$row['workstation'] .''.$formCore->texte('', 'TData['.$k.'][qty]', $row['qty'], 3,20) .'
'.$formCore->checkbox1('', 'TData['.$k.'][to_import]', 1,true, '', 'check_imp').''.$form->selectarray('TData['.$k.'][type]', getTypeLine(), $row['type']).''.$form->selectarray('TData['.$k.'][level]', getLevelTitle(), $row['level']).''; 492 | 493 | if(!empty($row['product_ref'])) { 494 | $p=new Product($db); 495 | $p->fetch(null, $row['product_ref']); 496 | 497 | $fk_product = $p->id; 498 | } 499 | else{ 500 | $fk_product = 0; 501 | 502 | } 503 | 504 | print ''.( $fk_product > 0 ? $p->getNomUrl(1) : 'N/A' ).' '.img_edit('Changer le produit de destination').''; 505 | //$form->select_produits($fk_product, 'TData['.$k.'][fk_product]'); 506 | 507 | echo $formCore->hidden('TData['.$k.'][fk_product]', $fk_product,' rel="fk_product" '); 508 | echo $formCore->hidden('TData['.$k.'][product_ref]', $row['product_ref'],' rel="product_ref" '); 509 | 510 | print ''.$formCore->texte('', 'TData['.$k.'][label]', $row['label'], 80,255); 514 | print ''; 515 | print ''; 516 | print ''; 517 | print ''; 518 | print ''; 519 | print ''; 520 | print ''; 521 | print '
Longueur : '.$formCore->texte('', 'TData['.$k.'][length]', $row['length'], 15,255).'Largeur : '.$formCore->texte('', 'TData['.$k.'][width]', $row['width'], 15,255).'Hauteur : '.$formCore->texte('', 'TData['.$k.'][height]', $row['height'], 15,255).'Poids : '.$formCore->texte('', 'TData['.$k.'][weight]', $row['weight'], 15,255).'
'; 522 | 523 | print '
'.$formCore->texte('', 'TData['.$k.'][qty]', $row['qty'], 3,20) .''.$form->selectUnits($row['fk_unit'],'TData['.$k.'][fk_unit]',1).''.$formCore->texte('','TData['.$k.'][buy_price]', $row['buy_price'], 10, 20).''.$formCore->texte('', 'TData['.$k.'][price]', $row['price'], 10,20) .''.$form->selectarray('TData['.$k.'][fk_propaldet]', $TPropalDet, '', 1).'
542 |
543 | trans('DeleteLinesBeforeImport'); ?> 544 | 545 |
546 | end(); 548 | ?> 549 |
552 | rights->importdevis->myactions)) 572 | { 573 | accessforbidden(); 574 | } 575 | else 576 | { 577 | llxHeader(); 578 | $title = $langs->trans('Import'); 579 | if ($origin=='propal'){ 580 | dol_fiche_head($head, 'importdevis', $title, 0, 'propal'); 581 | }else { 582 | dol_fiche_head($head, 'importdevis', $title, 0, 'commande'); 583 | } 584 | ?> 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 611 | 612 | 613 |
trans('Ref'); ?>
ref; ?>
trans('Company'); ?>thirdparty->getNomUrl(1); ?>
trans('FileToImport'); ?> 599 |
600 | 601 | 602 | 603 | 604 | 605 | 606 | trans('NbLineToAvoid'); ?> 607 | 608 | 609 |
610 |
614 | 615 | 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_importdevistrigger.class.php 21 | * \ingroup importdevis 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 Interfaceimportdevistrigger 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 = 'importdevis@importdevis'; 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 | } --------------------------------------------------------------------------------