├── .gitignore ├── img ├── ATM_logo.jpg ├── dolifleet.png ├── object_dolifleet.png ├── Dolibarr_Preferred_Partner_logo.png └── icon.svg ├── sql └── llx_dolifleet_vehicule_rental_matrix.key.sql ├── README ├── config.php ├── langs ├── en_US │ └── dolifleet.lang └── fr_FR │ └── dolifleet.lang ├── class ├── dictionaryContractType.class.php ├── dictionaryVehiculeMark.class.php ├── dictionaryVehiculeType.class.php ├── dictionaryVehiculeActivityType.class.php ├── vehiculeRental.class.php ├── vehiculeLink.class.php ├── vehiculeRentalMatrix.class.php ├── vehiculeActivity.class.php ├── dictionary.class.php ├── actions_dolifleet.class.php ├── vehiculeOperation.class.php └── dolifleet.class.php ├── config.default.php ├── admin ├── vehicule_extrafields.php ├── dolifleet_about.php ├── multicompany_sharing.php ├── rental_matrix.php └── dolifleet_setup.php ├── tpl └── linkedobjectblock.tpl.php ├── core ├── boxes │ └── dolifleet_box.php └── modules │ └── dolifleet │ └── modules_rentalproposal.php ├── script └── create-maj-base.php ├── rental_proposal_list.php ├── vehicule_list.php ├── matrix_tab.php ├── vehicule_card.php ├── rental_proposal_card.php └── lib └── dolifleet.lib.php /.gitignore: -------------------------------------------------------------------------------- 1 | .buildpath 2 | .project 3 | .settings/ 4 | *.log 5 | /nbproject/private/ -------------------------------------------------------------------------------- /img/ATM_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_dolifleet/master/img/ATM_logo.jpg -------------------------------------------------------------------------------- /img/dolifleet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_dolifleet/master/img/dolifleet.png -------------------------------------------------------------------------------- /img/object_dolifleet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_dolifleet/master/img/object_dolifleet.png -------------------------------------------------------------------------------- /img/Dolibarr_Preferred_Partner_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_dolifleet/master/img/Dolibarr_Preferred_Partner_logo.png -------------------------------------------------------------------------------- /sql/llx_dolifleet_vehicule_rental_matrix.key.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE llx_dolifleet_vehicule_rental_matrix ADD UNIQUE matrix_unicity (fk_soc, fk_c_type_vh, fk_c_mark_vh, delay); 2 | -------------------------------------------------------------------------------- /img/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020 ATM Consulting 2 | * 3 | * This program and files/directory inner it is free software: you can 4 | * redistribute it and/or modify it under the terms of the 5 | * GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | require __DIR__.'/config.default.php'; 19 | 20 | -------------------------------------------------------------------------------- /langs/en_US/dolifleet.lang: -------------------------------------------------------------------------------- 1 | Module104087Name = doliFleet 2 | Module104087Desc = doliFleet Description 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 | doliFleetSetup = doliFleet module setup 7 | doliFleetAbout = About doliFleet 8 | -------------------------------------------------------------------------------- /class/dictionaryContractType.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | dol_include_once('/dolifleet/class/dictionary.class.php'); 28 | 29 | class dictionaryContractType extends dictionary 30 | { 31 | /** @var string $table_element Table name in SQL */ 32 | public $table_element = 'c_dolifleet_contract_type'; 33 | 34 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 35 | public $element = 'dolifleetContractType'; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /class/dictionaryVehiculeMark.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | dol_include_once('/dolifleet/class/dictionary.class.php'); 28 | 29 | class dictionaryVehiculeMark extends dictionary 30 | { 31 | /** @var string $table_element Table name in SQL */ 32 | public $table_element = 'c_dolifleet_vehicule_mark'; 33 | 34 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 35 | public $element = 'dolifleetVehiculeMark'; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /class/dictionaryVehiculeType.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | dol_include_once('/dolifleet/class/dictionary.class.php'); 28 | 29 | class dictionaryVehiculeType extends dictionary 30 | { 31 | /** @var string $table_element Table name in SQL */ 32 | public $table_element = 'c_dolifleet_vehicule_type'; 33 | 34 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 35 | public $element = 'dolifleetVehiculeType'; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /config.default.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if(is_file('../main.inc.php'))$dir = '../'; 19 | else if(is_file('../../../main.inc.php'))$dir = '../../../'; 20 | else $dir = '../../'; 21 | 22 | 23 | if(!defined('INC_FROM_DOLIBARR') && defined('INC_FROM_CRON_SCRIPT')) { 24 | include($dir."master.inc.php"); 25 | } 26 | elseif(!defined('INC_FROM_DOLIBARR')) { 27 | include($dir."main.inc.php"); 28 | } else { 29 | global $dolibarr_main_db_host, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass; 30 | } 31 | 32 | if(!defined('DB_HOST')) { 33 | define('DB_HOST',$dolibarr_main_db_host); 34 | define('DB_NAME',$dolibarr_main_db_name); 35 | define('DB_USER',$dolibarr_main_db_user); 36 | define('DB_PASS',$dolibarr_main_db_pass); 37 | define('DB_DRIVER',$dolibarr_main_db_type); 38 | } 39 | 40 | if(!dol_include_once('/abricot/inc.core.php')) { 41 | print $langs->trans('AbricotNotFound'). ' : Abricot'; 42 | exit; 43 | } 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /class/dictionaryVehiculeActivityType.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | dol_include_once('/dolifleet/class/dictionary.class.php'); 28 | 29 | class dictionaryVehiculeActivityType extends dictionary 30 | { 31 | /** @var string $table_element Table name in SQL */ 32 | public $table_element = 'c_dolifleet_vehicule_activity_type'; 33 | 34 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 35 | public $element = 'dolifleetVehiculeActivityType'; 36 | 37 | public function getValueFromId($id, $field = 'label') 38 | { 39 | global $langs; 40 | 41 | if (empty($id)) return $langs->trans('NodoliFleetActivity'); 42 | 43 | return parent::getValueFromId($id, $field); // TODO: Change the autogenerated stub 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /admin/vehicule_extrafields.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * \file admin/dolifleet_extrafields.php 20 | * \ingroup dolifleet 21 | * \brief Page to setup extra fields of dolifleet 22 | */ 23 | 24 | $res = @include '../../main.inc.php'; // From htdocs directory 25 | if (! $res) { 26 | $res = @include '../../../main.inc.php'; // From "custom" directory 27 | } 28 | 29 | 30 | /* 31 | * Config of extrafield page for doliFleet 32 | */ 33 | require_once '../lib/dolifleet.lib.php'; 34 | require_once '../class/vehicule.class.php'; 35 | $langs->loadLangs(array('dolifleet@dolifleet', 'admin', 'other')); 36 | 37 | $dolifleet = new doliFleetVehicule($db); 38 | $elementtype=$dolifleet->table_element; //Must be the $table_element of the class that manage extrafield 39 | 40 | // Page title and texts elements 41 | $textobject=$langs->transnoentitiesnoconv('doliFleet'); 42 | $help_url='EN:Help doliFleet|FR:Aide doliFleet'; 43 | $pageTitle = $langs->trans('ExtraFields'); 44 | 45 | // Configuration header 46 | $head = dolifleetAdminPrepareHead(); 47 | 48 | 49 | 50 | /* 51 | * Include of extrafield page 52 | */ 53 | 54 | require_once dol_buildpath('abricot/tpl/extrafields_setup.tpl.php'); // use this kind of call for variables scope 55 | -------------------------------------------------------------------------------- /tpl/linkedobjectblock.tpl.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | // Protection to avoid direct call of template 19 | if (empty($conf) || ! is_object($conf)) { 20 | print "Error, template page can't be called as URL"; 21 | exit; 22 | } 23 | 24 | ?> 25 | 26 | 27 | 28 | load("dolifleet@dolifleet"); 36 | echo '
'; 37 | print load_fiche_titre($langs->trans("doliFleetRelated")); 38 | ?> 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | $objectlink) 51 | { 52 | $var=!$var; 53 | ?> 54 | > 55 | 56 | 57 | 58 | 59 | 60 | 61 | 64 | 65 |
trans("Ref"); ?>trans("Label"); ?>trans("DateMaj"); ?>trans("Status"); ?>
getNomUrl(1); ?>label; ?>date_maj, 'day'); ?>getLibStatut(0); ?>">transnoentitiesnoconv("RemoveLink")); ?>
66 | 67 | -------------------------------------------------------------------------------- /admin/dolifleet_about.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * \file admin/about.php 20 | * \ingroup dolifleet 21 | * \brief This file is an example about page 22 | * Put some comments here 23 | */ 24 | // Dolibarr environment 25 | $res = @include '../../main.inc.php'; // From htdocs directory 26 | if (! $res) { 27 | $res = @include '../../../main.inc.php'; // From "custom" directory 28 | } 29 | 30 | // Libraries 31 | require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; 32 | require_once '../lib/dolifleet.lib.php'; 33 | 34 | // Translations 35 | $langs->load('dolifleet@dolifleet'); 36 | 37 | // Access control 38 | if (! $user->admin) { 39 | accessforbidden(); 40 | } 41 | 42 | /* 43 | * View 44 | */ 45 | $page_name = 'doliFleetAbout'; 46 | llxHeader('', $langs->trans($page_name)); 47 | 48 | // Subheader 49 | $linkback = '' 50 | . $langs->trans('BackToModuleList') . ''; 51 | print load_fiche_titre($langs->trans($page_name), $linkback); 52 | 53 | // Configuration header 54 | $head = dolifleetAdminPrepareHead(); 55 | dol_fiche_head( 56 | $head, 57 | 'about', 58 | $langs->trans('Module104087Name'), 59 | 0, 60 | 'dolifleet@dolifleet' 61 | ); 62 | 63 | // About page goes here 64 | print '
'; 65 | print '
'.$langs->trans('ATMAbout').'
'; 66 | 67 | dol_fiche_end(); 68 | 69 | print '
'; 70 | print ''; 71 | print '
'; 72 | 73 | llxFooter(); 74 | $db->close(); 75 | -------------------------------------------------------------------------------- /core/boxes/dolifleet_box.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * \file core/boxes/mybox.php 20 | * \ingroup dolifleet 21 | * \brief This file is a sample box definition file 22 | * Put some comments here 23 | */ 24 | include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; 25 | 26 | /** 27 | * Class to manage the box 28 | */ 29 | class dolifleetbox extends ModeleBoxes 30 | { 31 | 32 | public $boxcode = "mybox"; 33 | public $boximg = "dolifleet@dolifleet"; 34 | public $boxlabel; 35 | public $depends = array("dolifleet"); 36 | public $db; 37 | public $param; 38 | public $info_box_head = array(); 39 | public $info_box_contents = array(); 40 | 41 | /** 42 | * Constructor 43 | */ 44 | public function __construct() 45 | { 46 | global $langs; 47 | $langs->load("boxes"); 48 | 49 | $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); 50 | } 51 | 52 | /** 53 | * Load data into info_box_contents array to show array later. 54 | * 55 | * @param int $max Maximum number of records to load 56 | * @return void 57 | */ 58 | public function loadBox($max = 5) 59 | { 60 | global $conf, $user, $langs, $db; 61 | 62 | $this->max = $max; 63 | 64 | // dol_include_once('/dolifleet/class/dolifleet.class.php'); 65 | 66 | $text = $langs->trans("MyBoxDescription", $max); 67 | $this->info_box_head = array( 68 | 'text' => $text, 69 | 'limit' => dol_strlen($text) 70 | ); 71 | 72 | $this->info_box_contents[0][0] = array('td' => 'align="left"', 73 | 'text' => $langs->trans("MyBoxContent")); 74 | } 75 | 76 | /** 77 | * Method to show box 78 | * 79 | * @param array $head Array with properties of box title 80 | * @param array $contents Array with properties of box lines 81 | * @return void 82 | */ 83 | public function showBox($head = null, $contents = null) 84 | { 85 | parent::showBox($this->info_box_head, $this->info_box_contents); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /script/create-maj-base.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * Script créant et vérifiant que les champs requis s'ajoutent bien 20 | */ 21 | 22 | if(!defined('INC_FROM_DOLIBARR')) { 23 | define('INC_FROM_CRON_SCRIPT', true); 24 | 25 | require '../config.php'; 26 | } else { 27 | global $db; 28 | } 29 | 30 | 31 | /* uncomment 32 | dol_include_once('/dolifleet/class/dolifleet.class.php'); 33 | 34 | $o=new doliFleet($db); 35 | $o->init_db_by_vars(); 36 | */ 37 | 38 | /* Dictionnaries */ 39 | 40 | dol_include_once('/dolifleet/class/dictionaryContractType.class.php'); 41 | $o=new dictionaryContractType($db); 42 | $o->init_db_by_vars(); 43 | 44 | dol_include_once('/dolifleet/class/dictionaryVehiculeType.class.php'); 45 | $o=new dictionaryVehiculeType($db); 46 | $o->init_db_by_vars(); 47 | 48 | dol_include_once('/dolifleet/class/dictionaryVehiculeMark.class.php'); 49 | $o=new dictionaryVehiculeMark($db); 50 | $o->init_db_by_vars(); 51 | 52 | dol_include_once('/dolifleet/class/dictionaryVehiculeActivityType.class.php'); 53 | $o=new dictionaryVehiculeActivityType($db); 54 | $o->init_db_by_vars(); 55 | 56 | /* Objects */ 57 | 58 | dol_include_once('/dolifleet/class/vehicule.class.php'); 59 | $o=new doliFleetVehicule($db); 60 | $o->init_db_by_vars(); 61 | 62 | dol_include_once('/dolifleet/class/vehiculeActivity.class.php'); 63 | $o=new doliFleetVehiculeActivity($db); 64 | $o->init_db_by_vars(); 65 | 66 | dol_include_once('/dolifleet/class/vehiculeLink.class.php'); 67 | $o=new doliFleetVehiculeLink($db); 68 | $o->init_db_by_vars(); 69 | 70 | dol_include_once('/dolifleet/class/vehiculeRental.class.php'); 71 | $o=new dolifleetVehiculeRental($db); 72 | $o->init_db_by_vars(); 73 | 74 | dol_include_once('/dolifleet/class/vehiculeRentalMatrix.class.php'); 75 | $o=new doliFleetVehiculeRentalMatrix($db); 76 | $o->init_db_by_vars(); 77 | 78 | dol_include_once('/dolifleet/class/vehiculeOperation.class.php'); 79 | $o=new dolifleetVehiculeOperation($db); 80 | $o->init_db_by_vars(); 81 | 82 | dol_include_once('/dolifleet/class/rentalProposal.class.php'); 83 | $o=new dolifleetRentalProposal($db); 84 | $o->init_db_by_vars(); 85 | 86 | $o=new dolifleetRentalProposalDet($db); 87 | $o->init_db_by_vars(); 88 | -------------------------------------------------------------------------------- /class/vehiculeRental.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | class dolifleetVehiculeRental extends SeedObject 28 | { 29 | /** @var string $table_element Table name in SQL */ 30 | public $table_element = 'dolifleet_vehicule_rental'; 31 | 32 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 33 | public $element = 'dolifleet_vehicule_rental'; 34 | 35 | public $fk_vehicule; 36 | 37 | public $date_start; 38 | 39 | public $date_end; 40 | 41 | public $total_ht; 42 | 43 | public $fk_soc; 44 | 45 | public $fk_proposaldet; 46 | 47 | public $fields = array( 48 | 'fk_vehicule' => array( 49 | 'type' => 'integer:doliFleetVehicule:dolifleet/class/vehicule.class.php', 50 | 'label' => 'doliFleetVehicule', 51 | 'visible' => 1, 52 | 'enabled' => 1, 53 | 'position' => 10, 54 | 'index' => 1, 55 | ), 56 | 57 | 'date_start' => array( 58 | 'type' => 'date', 59 | 'label' => 'date_start', 60 | 'enabled' => 1, 61 | 'visible' => 1, 62 | 'position' => 70, 63 | 'searchall' => 1, 64 | ), 65 | 66 | 'date_end' => array( 67 | 'type' => 'date', 68 | 'label' => 'date_end', 69 | 'enabled' => 1, 70 | 'visible' => 1, 71 | 'position' => 70, 72 | 'searchall' => 1, 73 | ), 74 | 75 | 'total_ht' => array( 76 | 'type' => 'price', 77 | 'label' => 'totalHT', 78 | 'enabled' => 1, 79 | 'visible' => 1, 80 | 'position' => 80 81 | ), 82 | 83 | 'fk_soc' => array( 84 | 'type' => 'integer:Societe:societe/class/societe.class.php', 85 | 'enabled' => 1, 86 | 'visible' => 0, 87 | 'position' => 90, 88 | 'index' => 1, 89 | ), 90 | 91 | 'fk_proposaldet' => array( 92 | 'type' => 'integer', 93 | 'enabled' => 1, 94 | 'visible' => 0, 95 | 'position' => 100, 96 | 'index' => 1, 97 | ), 98 | ); 99 | 100 | public function __construct($db) 101 | { 102 | parent::__construct($db); 103 | 104 | $this->init(); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /class/vehiculeLink.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | class doliFleetVehiculeLink extends SeedObject 28 | { 29 | /** @var string $table_element Table name in SQL */ 30 | public $table_element = 'dolifleet_vehicule_link'; 31 | 32 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 33 | public $element = 'dolifleet_vehicule_link'; 34 | 35 | public $date_start; 36 | 37 | public $date_end; 38 | 39 | public $fk_source; 40 | 41 | public $fk_soc_vehicule_source; 42 | 43 | public $fk_target; 44 | 45 | public $fk_soc_vehicule_target; 46 | 47 | public $fields = array( 48 | 'date_start' => array( 49 | 'type' => 'date', 50 | 'label' => 'date_start', 51 | 'enabled' => 1, 52 | 'visible' => 1, 53 | 'position' => 70, 54 | 'searchall' => 1, 55 | ), 56 | 57 | 'date_end' => array( 58 | 'type' => 'date', 59 | 'label' => 'date_end', 60 | 'enabled' => 1, 61 | 'visible' => 1, 62 | 'position' => 70, 63 | 'searchall' => 1, 64 | ), 65 | 66 | 'fk_source' => array( 67 | 'type' => 'integer:doliFleetVehicule:dolifleet/class/vehicule.class.php', 68 | 'label' => 'doliFleetVehicule', 69 | 'visible' => 1, 70 | 'enabled' => 1, 71 | 'position' => 10, 72 | 'index' => 1, 73 | ), 74 | 75 | 'fk_soc_vehicule_source' => array( 76 | 'type' => 'integer:Societe:societe/class/societe.class.php', 77 | 'label' => 'ThirdParty', 78 | 'visible' => 1, 79 | 'notnull' =>1, 80 | 'default' => 0, 81 | 'enabled' => 1, 82 | 'position' => 80, 83 | 'index' => 1, 84 | 'help' => 'LinkToThirparty' 85 | ), 86 | 87 | 'fk_target' => array( 88 | 'type' => 'integer:doliFleetVehicule:dolifleet/class/vehicule.class.php', 89 | 'label' => 'doliFleetVehicule', 90 | 'visible' => 1, 91 | 'enabled' => 1, 92 | 'position' => 10, 93 | 'index' => 1, 94 | ), 95 | 96 | 'fk_soc_vehicule_target' => array( 97 | 'type' => 'integer:Societe:societe/class/societe.class.php', 98 | 'label' => 'ThirdParty', 99 | 'visible' => 1, 100 | 'notnull' =>1, 101 | 'default' => 0, 102 | 'enabled' => 1, 103 | 'position' => 80, 104 | 'index' => 1, 105 | 'help' => 'LinkToThirparty' 106 | ), 107 | ); 108 | 109 | /** 110 | * doliFleetVehiculeActivity constructor. 111 | * @param DoliDB $db Database connector 112 | */ 113 | public function __construct($db) 114 | { 115 | global $conf; 116 | 117 | parent::__construct($db); 118 | 119 | $this->init(); 120 | 121 | $this->entity = $conf->entity; 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /class/vehiculeRentalMatrix.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | class doliFleetVehiculeRentalMatrix extends SeedObject 28 | { 29 | /** @var string $table_element Table name in SQL */ 30 | public $table_element = 'dolifleet_vehicule_rental_matrix'; 31 | 32 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 33 | public $element = 'dolifleet_vehicule_rental_matrix'; 34 | 35 | public $fk_soc; 36 | 37 | public $fk_c_type_vh; 38 | 39 | public $fk_c_mark_vh; 40 | 41 | public $delay; 42 | 43 | public $amount_ht; 44 | 45 | public $fields = array( 46 | 'fk_soc' => array( 47 | 'type' => 'integer', 48 | 'enabled' => 1, 49 | 'visible' => 0, 50 | 'notnull' =>1, 51 | 'default' => 0, 52 | 'position' => 10, 53 | 'index' => 1, 54 | ), 55 | 56 | 'fk_c_type_vh' => array( 57 | 'type' => 'sellist:c_dolifleet_vehicule_type:label:rowid::active=1', 58 | 'label' => 'vehiculeType', 59 | 'visible' => 1, 60 | 'enabled' => 1, 61 | 'position' => 20, 62 | 'index' => 1, 63 | ), 64 | 65 | 'fk_c_mark_vh' => array( 66 | 'type' => 'sellist:c_dolifleet_vehicule_mark:label:rowid::active=1', 67 | 'label' => 'vehiculeMark', 68 | 'visible' => 1, 69 | 'enabled' => 1, 70 | 'position' => 30, 71 | 'index' => 1, 72 | ), 73 | 74 | 'delay' => array( 75 | 'type' => 'integer', 76 | 'label' => 'vehiculeDelayExploit', 77 | 'visible' => 1, 78 | 'enabled' => 1, 79 | 'position' => 40, 80 | 'index' => 1, 81 | ), 82 | 83 | 'amount_ht' => array( 84 | 'type' => 'double', 85 | 'label' => 'totalHT', 86 | 'enabled' => 1, 87 | 'visible' => 1, 88 | 'position' => 50 89 | ), 90 | 91 | ); 92 | 93 | public function __construct($db) 94 | { 95 | parent::__construct($db); 96 | 97 | $this->init(); 98 | } 99 | 100 | public function create(User &$user, $notrigger = false) 101 | { 102 | global $langs; 103 | 104 | // check parameters 105 | if (empty($this->fk_c_type_vh) || $this->fk_c_type_vh == -1) $this->errors[] = $langs->trans('ErrInvalidType'); 106 | if (empty($this->fk_c_mark_vh) || $this->fk_c_mark_vh == -1) $this->errors[] = $langs->trans('ErrInvalidMark'); 107 | if (empty($this->delay)) $this->errors[] = $langs->trans('ErrNoDelayForLine'); 108 | if (empty($this->amount_ht)) $this->errors[] = $langs->trans('ErrInvalidAmount'); 109 | 110 | if (empty($this->id)) 111 | { 112 | $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$this->table_element; 113 | $sql.= " WHERE fk_soc = " . $this->fk_soc; 114 | $sql.= " AND fk_c_type_vh = ".$this->fk_c_type_vh; 115 | $sql.= " AND fk_c_mark_vh = ".$this->fk_c_mark_vh; 116 | $sql.= " AND delay = ".$this->delay; 117 | $resql = $this->db->query($sql); 118 | if ($resql) 119 | { 120 | $obj = $this->db->fetch_object($resql); 121 | if ($obj->nb > 0) $this->errors[] = $langs->trans('ErrDuplicateMatrix'); 122 | } 123 | } 124 | 125 | 126 | if (!empty($this->errors)) return -1; 127 | 128 | return parent::create($user, $notrigger); // TODO: Change the autogenerated stub 129 | } 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /class/vehiculeActivity.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | class doliFleetVehiculeActivity extends SeedObject 28 | { 29 | /** @var string $table_element Table name in SQL */ 30 | public $table_element = 'dolifleet_vehicule_activity'; 31 | 32 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 33 | public $element = 'dolifleet_vehicule_activity'; 34 | 35 | /** @var int $fk_vehicule Object link to vehicule */ 36 | public $fk_vehicule; 37 | 38 | /** @var int $fk_type Object type */ 39 | public $fk_type; 40 | 41 | public $fk_soc; 42 | 43 | public $date_start; 44 | 45 | public $date_end; 46 | 47 | public $fields = array( 48 | 'fk_vehicule' => array( 49 | 'type' => 'integer:doliFleetVehicule:dolifleet/class/vehicule.class.php', 50 | 'label' => 'doliFleetVehicule', 51 | 'visible' => 1, 52 | 'enabled' => 1, 53 | 'notnull' => 1, 54 | 'position' => 10, 55 | 'index' => 1, 56 | ), 57 | 58 | 'fk_type' => array( 59 | 'type' => 'sellist:c_dolifleet_vehicule_activity_type:label:rowid::active=1', 60 | 'label' => 'vehiculeMark', 61 | 'visible' => 1, 62 | 'enabled' => 1, 63 | 'notnull' => 1, 64 | 'position' => 50, 65 | 'index' => 1, 66 | ), 67 | 68 | 'date_start' => array( 69 | 'type' => 'date', 70 | 'label' => 'date_start', 71 | 'enabled' => 1, 72 | 'visible' => 1, 73 | 'position' => 70, 74 | 'searchall' => 1, 75 | ), 76 | 77 | 'date_end' => array( 78 | 'type' => 'date', 79 | 'label' => 'date_end', 80 | 'enabled' => 1, 81 | 'visible' => 1, 82 | 'position' => 70, 83 | 'searchall' => 1, 84 | ), 85 | 86 | 'fk_soc' => array( 87 | 'type' => 'integer:Societe:societe/class/societe.class.php', 88 | 'label' => 'ThirdParty', 89 | 'visible' => 1, 90 | 'enabled' => 1, 91 | 'position' => 80, 92 | 'index' => 1, 93 | 'help' => 'LinkToThirparty' 94 | ), 95 | ); 96 | 97 | /** 98 | * doliFleetVehiculeActivity constructor. 99 | * @param DoliDB $db Database connector 100 | */ 101 | public function __construct($db) 102 | { 103 | global $conf; 104 | 105 | parent::__construct($db); 106 | 107 | $this->init(); 108 | 109 | $this->entity = $conf->entity; 110 | } 111 | 112 | public function getType() 113 | { 114 | dol_include_once('/dolifleet/class/dictionaryVehiculeActivityType.class.php'); 115 | $dict = new dictionaryVehiculeActivityType($this->db); 116 | 117 | if (!empty($this->fk_type)) 118 | { 119 | return $dict->getValueFromId($this->fk_type); 120 | } 121 | 122 | return ''; 123 | } 124 | 125 | public function verifyDates() 126 | { 127 | global $langs; 128 | 129 | $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$this->table_element; 130 | $sql.= " WHERE fk_vehicule = ". $this->fk_vehicule; 131 | if (!empty($this->date_start)) $sql.= " AND date_end > '" . $this->db->idate($this->date_start) ."'"; 132 | if (!empty($this->date_end)) $sql.= " AND date_start < '" . $this->db->idate($this->date_end) . "'"; 133 | 134 | $resql = $this->db->query($sql); 135 | if ($resql) 136 | { 137 | $obj = $this->db->fetch_object($resql); 138 | 139 | if (empty($obj->nb)) return true; 140 | else $this->error = $langs->trans('ErrAlreadyInActivity'); 141 | } 142 | else $this->error = $this->db->lasterror(); 143 | 144 | return false; 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /core/modules/dolifleet/modules_rentalproposal.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2011 Laurent Destailleur 4 | * Copyright (C) 2004 Eric Seigne 5 | * Copyright (C) 2005-2012 Regis Houssin 6 | * Copyright (C) 2006 Andre Cianfarani 7 | * Copyright (C) 2012 Juanjo Menent 8 | * Copyright (C) 2014 Marcos García 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | * or see https://www.gnu.org/ 23 | */ 24 | 25 | /** 26 | * \file modules/dolifleet/modules_rentalproposal.php 27 | * \ingroup dolifleet 28 | * \brief File that contains parent class for orders models 29 | * and parent class for orders numbering models 30 | */ 31 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; 33 | 34 | /** 35 | * Parent class for rentalproposal models 36 | */ 37 | abstract class ModelePDFRentalproposal extends CommonDocGenerator 38 | { 39 | 40 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps 41 | /** 42 | * Return list of active generation modules 43 | * 44 | * @param DoliDB $db Database handler 45 | * @param integer $maxfilenamelength Max length of value to show 46 | * @return array List of templates 47 | */ 48 | public static function liste_modeles($db, $maxfilenamelength = 0) 49 | { 50 | // phpcs:enable 51 | global $conf; 52 | 53 | $type = 'rentalproposal'; 54 | $list = array(); 55 | 56 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 57 | $list = getListOfModels($db, $type, $maxfilenamelength); 58 | 59 | return $list; 60 | } 61 | } 62 | 63 | 64 | 65 | /** 66 | * Parent class to manage numbering Processrules 67 | */ 68 | abstract class ModeleNumRefRentalproposal 69 | { 70 | /** 71 | * @var string Error code (or message) 72 | */ 73 | public $error=''; 74 | 75 | /** 76 | * Return if a module can be used or not 77 | * 78 | * @return boolean true if module can be used 79 | */ 80 | public function isEnabled() 81 | { 82 | return true; 83 | } 84 | 85 | /** 86 | * Renvoie la description par defaut du modele de numerotation 87 | * 88 | * @return string Texte descripif 89 | */ 90 | public function info() 91 | { 92 | global $langs; 93 | $langs->load("processrules@processrules"); 94 | return $langs->trans("NoDescription"); 95 | } 96 | 97 | /** 98 | * Renvoie un exemple de numerotation 99 | * 100 | * @return string Example 101 | */ 102 | public function getExample() 103 | { 104 | global $langs; 105 | $langs->load("processrules@processrules"); 106 | return $langs->trans("NoExample"); 107 | } 108 | 109 | /** 110 | * Checks if the numbers already in force in the data base do not 111 | * cause conflicts that would prevent this numbering from working. 112 | * 113 | * @return boolean false if conflict, true if ok 114 | */ 115 | public function canBeActivated() 116 | { 117 | return true; 118 | } 119 | 120 | /** 121 | * Returns next assigned value 122 | * 123 | * @param Societe $objsoc Object thirdparty 124 | * @param Object $object Object we need next value for 125 | * @return string Valeur 126 | */ 127 | public function getNextValue($objsoc, $object) 128 | { 129 | global $langs; 130 | return $langs->trans("NotAvailable"); 131 | } 132 | 133 | /** 134 | * Returns version of numbering module 135 | * 136 | * @return string Valeur 137 | */ 138 | public function getVersion() 139 | { 140 | global $langs; 141 | $langs->load("admin"); 142 | 143 | if ($this->version == 'development') return $langs->trans("VersionDevelopment"); 144 | if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); 145 | if ($this->version == 'dolibarr') return DOL_VERSION; 146 | if ($this->version) return $this->version; 147 | return $langs->trans("NotAvailable"); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /class/dictionary.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | abstract class dictionary extends SeedObject 28 | { 29 | 30 | /** @var string $code Object reference */ 31 | public $code; 32 | 33 | /** @var int $entity Object entity */ 34 | public $entity; 35 | 36 | /** @var int $active Object active */ 37 | public $active; 38 | 39 | /** @var int $label Object name */ 40 | public $label; 41 | 42 | /** 43 | * 'type' is the field format. 44 | * 'label' the translation key. 45 | * 'enabled' is a condition when the field must be managed. 46 | * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) 47 | * 'noteditable' says if field is not editable (1 or 0) 48 | * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). 49 | * 'default' is a default value for creation (can still be replaced by the global setup of default values) 50 | * 'index' if we want an index in database. 51 | * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). 52 | * 'position' is the sort order of field. 53 | * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. 54 | * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). 55 | * 'css' is the CSS style to use on field. For example: 'maxwidth200' 56 | * 'help' is a string visible as a tooltip on field 57 | * 'comment' is not used. You can store here any text of your choice. It is not used by application. 58 | * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record 59 | * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") 60 | */ 61 | 62 | public $fields = array( 63 | 64 | 'code' => array( 65 | 'type' => 'varchar(20)', 66 | 'length' => 20, 67 | 'label' => 'Code', 68 | 'enabled' => 1, 69 | 'visible' => 1, 70 | 'notnull' => 1, 71 | 'index' => 1, 72 | ), 73 | 74 | 'entity' => array( 75 | 'type' => 'integer', 76 | 'label' => 'Entity', 77 | 'enabled' => 1, 78 | 'visible' => 0, 79 | 'default' => 1, 80 | 'notnull' => 1, 81 | 'index' => 1, 82 | 'position' => 20 83 | ), 84 | 85 | 'active' => array( 86 | 'type' => 'integer', 87 | 'label' => 'Active', 88 | 'enabled' => 1, 89 | 'visible' => 0, 90 | 'notnull' => 1, 91 | 'default' => 0, 92 | 'index' => 1, 93 | 'position' => 30, 94 | 'arrayofkeyval' => array( 95 | 0 => 'Disabled', 96 | 1 => 'Active' 97 | ) 98 | ), 99 | 100 | 'label' => array( 101 | 'type' => 'varchar(255)', 102 | 'label' => 'Label', 103 | 'enabled' => 1, 104 | 'visible' => 1, 105 | 'position' => 40, 106 | 'searchall' => 1, 107 | 'css' => 'minwidth200', 108 | 'showoncombobox' => 1 109 | ), 110 | 111 | ); 112 | 113 | /** 114 | * Dictionnary constructor. 115 | * @param DoliDB $db Database connector 116 | */ 117 | public function __construct($db) 118 | { 119 | global $conf; 120 | 121 | parent::__construct($db); 122 | 123 | $this->init(); 124 | 125 | $this->entity = $conf->entity; 126 | } 127 | 128 | /** 129 | * @param User $user User object 130 | * @return int 131 | */ 132 | public function save($user) 133 | { 134 | return $this->create($user); 135 | } 136 | 137 | public function getAllActiveArray($field = '') 138 | { 139 | $Tab = array(); 140 | 141 | $sql = 'SELECT rowid'; 142 | if (!empty($field)) $sql.= ', '.$field; 143 | $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; 144 | $sql.= ' WHERE active=1'; 145 | $sql.= ' AND entity IN ('.getEntity('dolifleet').')'; 146 | 147 | $resql = $this->db->query($sql); 148 | if ($resql) 149 | { 150 | while ($obj = $this->db->fetch_object($resql)) 151 | { 152 | $Tab[$obj->rowid] = empty($field) ? $obj->rowid : $obj->{$field}; 153 | } 154 | return $Tab; 155 | } 156 | else 157 | { 158 | return -1; 159 | } 160 | } 161 | 162 | public function getValueFromId($id, $field = 'label') 163 | { 164 | global $langs; 165 | 166 | $dict = new static($this->db); 167 | $ret = $dict->fetch($id); 168 | if ($ret > 0 && isset($dict->{$field})) 169 | { 170 | return $dict->{$field}; 171 | } 172 | 173 | return ''; 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /rental_proposal_list.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | require 'config.php'; 19 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; 20 | dol_include_once('dolifleet/class/rentalProposal.class.php'); 21 | 22 | if(empty($user->rights->dolifleet->rentalproposal->read)) accessforbidden(); 23 | 24 | $langs->load('abricot@abricot'); 25 | $langs->load('dolifleet@dolifleet'); 26 | 27 | 28 | $massaction = GETPOST('massaction', 'alpha'); 29 | $confirmmassaction = GETPOST('confirmmassaction', 'alpha'); 30 | $toselect = GETPOST('toselect', 'array'); 31 | 32 | $object = new dolifleetRentalProposal($db); 33 | 34 | $hookmanager->initHooks(array('dolifleetrentalproposallist')); 35 | 36 | if ($object->isextrafieldmanaged) 37 | { 38 | $extrafields = new ExtraFields($db); 39 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); 40 | } 41 | 42 | /* 43 | * Actions 44 | */ 45 | 46 | $parameters=array(); 47 | $reshook=$hookmanager->executeHooks('doActions', $parameters, $object); // Note that $action and $object may have been modified by some hooks 48 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 49 | 50 | if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') 51 | { 52 | $massaction = ''; 53 | } 54 | 55 | if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) 56 | { 57 | unset($_GET['Listview_dolifleetrentalproposal_search_fk_soc']); 58 | } 59 | 60 | if (empty($reshook)) 61 | { 62 | // do action from GETPOST ... 63 | } 64 | 65 | 66 | /* 67 | * View 68 | */ 69 | 70 | llxHeader('', $langs->trans('dolifleetRentalProposalList'), '', ''); 71 | 72 | //$type = GETPOST('type'); 73 | //if (empty($user->rights->dolifleetrentalproposal->all->read)) $type = 'mine'; 74 | 75 | // TODO ajouter les champs de son objet que l'on souhaite afficher 76 | $keys = array_keys($object->fields); 77 | $fieldList = 't.'.implode(', t.', $keys); 78 | if (!empty($object->isextrafieldmanaged)) 79 | { 80 | $keys = array_keys($extralabels); 81 | if(!empty($keys)) { 82 | $fieldList .= ', et.' . implode(', et.', $keys); 83 | } 84 | } 85 | 86 | $sql = 'SELECT '.$fieldList; 87 | 88 | // Add fields from hooks 89 | $parameters=array('sql' => $sql); 90 | $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook 91 | $sql.=$hookmanager->resPrint; 92 | 93 | $sql.= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' t '; 94 | 95 | if (!empty($object->isextrafieldmanaged)) 96 | { 97 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.$object->table_element.'_extrafields et ON (et.fk_object = t.rowid)'; 98 | } 99 | 100 | $sql.= ' WHERE 1=1'; 101 | //$sql.= ' AND t.entity IN ('.getEntity('dolifleetRentalProposal', 1).')'; 102 | //if ($type == 'mine') $sql.= ' AND t.fk_user = '.$user->id; 103 | 104 | // Add where from hooks 105 | $parameters=array('sql' => $sql); 106 | $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook 107 | $sql.=$hookmanager->resPrint; 108 | 109 | $formcore = new TFormCore($_SERVER['PHP_SELF'], 'form_list_dolifleetrentalproposal', 'GET'); 110 | 111 | $nbLine = GETPOST('limit'); 112 | if (empty($nbLine)) $nbLine = !empty($user->conf->MAIN_SIZE_LISTE_LIMIT) ? $user->conf->MAIN_SIZE_LISTE_LIMIT : $conf->global->MAIN_SIZE_LISTE_LIMIT; 113 | 114 | // List configuration 115 | $listViewConfig = array( 116 | 'view_type' => 'list' // default = [list], [raw], [chart] 117 | ,'allow-fields-select' => true 118 | ,'limit'=>array( 119 | 'nbLine' => $nbLine 120 | ) 121 | ,'list' => array( 122 | 'title' => $langs->trans('dolifleetRentalProposalList') 123 | ,'image' => 'title_generic.png' 124 | ,'picto_precedent' => '<' 125 | ,'picto_suivant' => '>' 126 | ,'noheader' => 0 127 | ,'messageNothing' => $langs->trans('NodoliFleet') 128 | ,'picto_search' => img_picto('', 'search.png', '', 0) 129 | ,'param_url' => '&limit='.$nbLine 130 | // ,'massactions'=>array( 131 | // 'yourmassactioncode' => $langs->trans('YourMassActionLabel') 132 | // ) 133 | ) 134 | ,'subQuery' => array() 135 | ,'link' => array() 136 | ,'type' => array( 137 | 'date_creation' => 'date' // [datetime], [hour], [money], [number], [integer] 138 | ,'tms' => 'date' 139 | ) 140 | ,'search' => array( 141 | 'date_creation' => array('search_type' => 'calendars', 'allow_is_null' => true) 142 | ,'ref' => array('search_type' => true, 'table' => 't', 'field' => 'ref') 143 | // ,'tms' => array('search_type' => 'calendars', 'allow_is_null' => false) 144 | // ,'label' => array('search_type' => true, 'table' => array('t', 't'), 'field' => array('label')) // input text de recherche sur plusieurs champs 145 | ,'status' => array('search_type' => dolifleetRentalProposal::$TStatus, 'to_translate' => true) // select html, la clé = le status de l'objet, 'to_translate' à true si nécessaire 146 | ,'month' => array('search_type' => monthArray($langs)) 147 | ,'year' => array('search_type' => true, 'table' => 't', 'field', 'year') 148 | ,'fk_soc' => array('search_type' => 'override', 'override' => $object->showInputField($object->fields['fk_soc'], 'fk_soc', GETPOST('Listview_dolifleetrentalproposal_search_fk_soc'),'','','Listview_dolifleetrentalproposal_search_')) 149 | ) 150 | ,'translate' => array() 151 | ,'hide' => array( 152 | 'rowid' // important : rowid doit exister dans la query sql pour les checkbox de massaction 153 | ) 154 | ,'title'=>array( 155 | 'ref' => $langs->trans('Ref.') 156 | // ,'label' => $langs->trans('Label') 157 | // ,'date_creation' => $langs->trans('DateCre') 158 | // ,'tms' => $langs->trans('DateMaj') 159 | // ,'id'=>$langs->trans('Id') 160 | ,'month' => $langs->trans('Month') 161 | ,'year' => $langs->trans('Year') 162 | ,'fk_soc'=> $langs->trans('ThirdParty') 163 | ,'status'=> $langs->trans('Status') 164 | ) 165 | ,'eval'=>array( 166 | 'ref' => '_getObjectNomUrl(\'@rowid@\')' 167 | ,'fk_soc' => '_getObjectNomUrl(\'@val@\', "Societe")' 168 | ,'month' => '_displayMonth(@val@)' 169 | ,'status' => "_printStatus(@val@)" 170 | // ,'fk_user' => '_getUserNomUrl(@val@)' // Si on a un fk_user dans notre requête 171 | ) 172 | ); 173 | 174 | $r = new Listview($db, 'dolifleetrentalproposal'); 175 | 176 | // Change view from hooks 177 | $parameters=array( 'listViewConfig' => $listViewConfig); 178 | $reshook=$hookmanager->executeHooks('listViewConfig',$parameters,$r); // Note that $action and $object may have been modified by hook 179 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 180 | if ($reshook>0) 181 | { 182 | $listViewConfig = $hookmanager->resArray; 183 | } 184 | 185 | echo $r->render($sql, $listViewConfig); 186 | 187 | $parameters=array('sql'=>$sql); 188 | $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook 189 | print $hookmanager->resPrint; 190 | 191 | $formcore->end_form(); 192 | 193 | llxFooter(''); 194 | $db->close(); 195 | 196 | /** 197 | * TODO remove if unused 198 | */ 199 | function _getObjectNomUrl($id, $classname = 'dolifleetRentalProposal') 200 | { 201 | 202 | global $db; 203 | 204 | if ($classname == 'Societe') require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; 205 | 206 | $o = new $classname($db); 207 | if ($classname == 'dolifleetRentalProposal') $res = $o->fetch($id, false, ''); 208 | else $res = $o->fetch($id); 209 | if ($res > 0) 210 | { 211 | return $o->getNomUrl(1); 212 | } 213 | 214 | return ''; 215 | } 216 | 217 | function _printStatus($fk_status) 218 | { 219 | global $langs; 220 | 221 | return $langs->trans(dolifleetRentalProposal::$TStatus[$fk_status]); 222 | } 223 | 224 | function _displayMonth($monthNumber) 225 | { 226 | global $langs, $TMonth; 227 | 228 | if (empty($TMonth)) $TMonth = monthArray($langs); 229 | 230 | return $TMonth[$monthNumber]; 231 | 232 | } 233 | 234 | /** 235 | * TODO remove if unused 236 | */ 237 | function _getUserNomUrl($fk_user) 238 | { 239 | global $db; 240 | 241 | $u = new User($db); 242 | if ($u->fetch($fk_user) > 0) 243 | { 244 | return $u->getNomUrl(1); 245 | } 246 | 247 | return ''; 248 | } 249 | -------------------------------------------------------------------------------- /admin/multicompany_sharing.php: -------------------------------------------------------------------------------- 1 | load("admin"); 20 | $langs->load("dolifleet@dolifleet"); 21 | 22 | // Merci à dolibarr et multicompany de simplifier les choses... 23 | $moduleKey = 'dolifleet'; 24 | $element = 'dolifleet'; 25 | $elementConvertion = 'dolifleetvehicule'; // voir selectForForms dans html.form.class.php 26 | $elementConvertionAnotherOne = 'dolifleet_vehicule'; // voir selectForFormsList dans html.form.class.php 27 | 28 | 29 | $moduleSharingEnabled = 'MULTICOMPANY_'.strtoupper($moduleKey).'_SHARING_ENABLED'; 30 | $moduleSharingEnabledValue = $conf->global->{$moduleSharingEnabled}; 31 | 32 | dolibarr_set_const($db, 'MULTICOMPANY_'.strtoupper($elementConvertion).'_SHARING_ENABLED' , $moduleSharingEnabledValue, 'chaine', 0, '', 0); // la conf MULTICOMPANY_EXTERNAL_MODULES_SHARING regle le PB je les garde au cas ou 33 | dolibarr_set_const($db, 'MULTICOMPANY_'.strtoupper($elementConvertionAnotherOne).'_SHARING_ENABLED' , $moduleSharingEnabledValue, 'chaine', 0, '', 0); // la conf MULTICOMPANY_EXTERNAL_MODULES_SHARING regle le PB je les garde au cas ou 34 | 35 | $externalmodules = array(); 36 | if (! empty($conf->global->MULTICOMPANY_EXTERNAL_MODULES_SHARING)) { 37 | $externalmodules = json_decode($conf->global->MULTICOMPANY_EXTERNAL_MODULES_SHARING, true); 38 | } 39 | 40 | if(!empty($moduleSharingEnabledValue)){ 41 | $externalmodules[$moduleKey]['sharingmodulename'][$elementConvertion] = 'dolifleet'; 42 | $externalmodules[$moduleKey]['sharingmodulename'][$elementConvertionAnotherOne] = 'dolifleet'; 43 | dolibarr_set_const($db, 'MULTICOMPANY_EXTERNAL_MODULES_SHARING' , json_encode($externalmodules), 'chaine', 0, '', 0); 44 | } 45 | 46 | $action = GETPOST("action"); 47 | if ($action == 'save_multicompany_shared_conf') 48 | { 49 | $multicompanypriceshare = GETPOST('multicompany-dolifleet', 'array'); 50 | $dao = new DaoMulticompany($db); 51 | $dao->getEntities(); 52 | 53 | foreach ($dao->entities as $entity) 54 | { 55 | $entity->options['sharings'][$element] = $entity->options['sharings'][$elementConvertion] = $entity->options['sharings'][$elementConvertionAnotherOne] = array(); 56 | $entity->update($entity->id, $user); 57 | } 58 | 59 | if (!empty($multicompanypriceshare)) 60 | { 61 | 62 | foreach ($multicompanypriceshare as $entityId => $shared) 63 | { 64 | 65 | //'MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED 66 | if (is_array($shared)) 67 | { 68 | $shared = array_map('intval', $shared); 69 | 70 | if ($dao->fetch($entityId) > 0) 71 | { 72 | $dao->options['sharings'][$element] = $dao->options['sharings'][$elementConvertion] = $dao->options['sharings'][$elementConvertionAnotherOne] = $shared; 73 | $dao->options['sharings'][$elementConvertion] = $dao->options['sharings'][$element]; 74 | $dao->options['sharings'][$elementConvertionAnotherOne] = $dao->options['sharings'][$element]; 75 | 76 | if ($dao->update($entityId, $user) < 1) 77 | { 78 | setEventMessage('Error'); 79 | } 80 | } 81 | } 82 | } 83 | } 84 | } 85 | 86 | 87 | $extrajs = $extracss = array(); 88 | if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) 89 | { 90 | $extrajs = array( 91 | '/multicompany/inc/multiselect/js/ui.multiselect.js', 92 | ); 93 | $extracss = array( 94 | '/multicompany/inc/multiselect/css/ui.multiselect.css', 95 | ); 96 | } 97 | 98 | llxHeader('', $langs->trans('multicompanySharing'), '', '', '', '', $extrajs, $extracss); 99 | 100 | 101 | 102 | $linkback = ''.$langs->trans("BackToModuleList").''; 103 | print_fiche_titre($langs->trans("multicompanySharing"), $linkback, 'setup'); 104 | 105 | // Configuration header 106 | $head = dolifleetAdminPrepareHead(); 107 | dol_fiche_head($head, 'multicompanySharing', $langs->trans("Module104087Name"), 0, "dolifleet@dolifleet"); 108 | 109 | 110 | 111 | if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED)) 112 | { 113 | 114 | print '

'; 115 | 116 | //var_dump($mc); 117 | print '
'; 118 | print ''; 119 | print ''; 120 | 121 | print ''; 122 | print ''; 123 | print ''."\n"; 124 | print ''; 125 | print ''; 126 | 127 | $moduleSharingEnabled = 'MULTICOMPANY_'.strtoupper($element).'_SHARING_ENABLED'; 128 | 129 | 130 | print ''; 131 | print ''; 134 | print ''; 137 | print ''; 138 | 139 | 140 | print ''; 141 | print ''."\n"; 142 | print ''; 143 | print ''; 144 | 145 | $m = new ActionsMulticompany($db); 146 | 147 | $dao = new DaoMulticompany($db); 148 | $dao->getEntities(); 149 | 150 | if (is_array($dao->entities)) 151 | { 152 | 153 | foreach ($dao->entities as $entitie) 154 | { 155 | 156 | if (intval($conf->entity) === 1 || intval($conf->entity) === intval($entitie->id)) 157 | { 158 | 159 | print ''; 160 | print ''; 164 | print ''; 167 | print ''; 168 | } 169 | } 170 | 171 | 172 | print ''; 173 | print ''; 176 | print ''; 177 | } 178 | print '
'.$langs->trans("Multicompany").'
'; 132 | print $langs->trans("ActivateVehiculeSharing"); 133 | print ''; 135 | print ajax_constantonoff($moduleSharingEnabled, array(), 0); 136 | print '
'.$langs->trans("MulticompanyConfiguration").''.$langs->trans("ShareWith").'
'; 161 | print $entitie->name.' ('.$entitie->label.') '; 162 | // 163 | print ''; 165 | print _multiselect_entities('multicompany-dolifleet['.$entitie->id.']', $entitie, '', $element); 166 | print '
'; 174 | print ''; 175 | print '
'; 179 | 180 | print '
'; 181 | 182 | $langs->loadLangs(array('languages', 'multicompany@multicompany')); 183 | 184 | print ''; 199 | } 200 | 201 | 202 | llxFooter(); 203 | 204 | /** 205 | * Return multiselect list of entities. 206 | * 207 | * @param string $htmlname Name of select 208 | * @param DaoMulticompany $current Current entity to manage 209 | * @param string $option Option 210 | * @return string 211 | */ 212 | function _multiselect_entities($htmlname, $current, $option = '', $sharingElement = '') 213 | { 214 | global $conf, $langs, $db; 215 | 216 | $dao = new DaoMulticompany($db); 217 | $dao->getEntities(); 218 | 219 | $sharingElement = !empty($sharingElement) ? $sharingElement : $htmlname; 220 | 221 | $return = ''; 245 | 246 | return $return; 247 | } 248 | -------------------------------------------------------------------------------- /class/actions_dolifleet.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * \file class/actions_dolifleet.class.php 20 | * \ingroup dolifleet 21 | * \brief This file is an example hook overload class file 22 | * Put some comments here 23 | */ 24 | 25 | /** 26 | * Class ActionsdoliFleet 27 | */ 28 | class ActionsdoliFleet 29 | { 30 | /** 31 | * @var DoliDb Database handler (result of a new DoliDB) 32 | */ 33 | public $db; 34 | 35 | /** 36 | * @var array Hook results. Propagated to $hookmanager->resArray for later reuse 37 | */ 38 | public $results = array(); 39 | 40 | /** 41 | * @var string String displayed by executeHook() immediately after return 42 | */ 43 | public $resprints; 44 | 45 | /** 46 | * @var array Errors 47 | */ 48 | public $errors = array(); 49 | 50 | /** 51 | * Constructor 52 | * @param DoliDB $db Database connector 53 | */ 54 | public function __construct($db) 55 | { 56 | $this->db = $db; 57 | } 58 | 59 | /** 60 | * Overloading the doActions function : replacing the parent's function with the one below 61 | * 62 | * @param array() $parameters Hook metadatas (context, etc...) 63 | * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 64 | * @param string $action Current action (if set). Generally create or edit or null 65 | * @param HookManager $hookmanager Hook manager propagated to allow calling another hook 66 | * @return int < 0 on error, 0 on success, 1 to replace standard code 67 | */ 68 | public function doActions($parameters, &$object, &$action, $hookmanager) 69 | { 70 | global $conf, $langs, $user, $db; 71 | $contextArray = explode(':', $parameters['context']); 72 | 73 | if (in_array('operationordercard', $contextArray) && $action == 'clone') { 74 | $action = 'cloneOR'; 75 | } 76 | 77 | if (in_array('operationordercard', $contextArray) && $action == 'confirm_cloneOR' && !empty($user->rights->operationorder->write)) { 78 | $newid = $object->cloneObject($user); 79 | $new_fk_vehicule = GETPOST('select_fk_vehicule'); 80 | $sql = 'SELECT fk_soc, km FROM '.MAIN_DB_PREFIX.'dolifleet_vehicule WHERE rowid ='.$new_fk_vehicule; 81 | $resql = $db->query($sql); 82 | if($resql){ 83 | $obj = $db->fetch_object($resql); 84 | $object->array_options['options_fk_dolifleet_vehicule'] = $new_fk_vehicule; 85 | $object->fk_soc = $obj->fk_soc; 86 | $object->array_options['options_km_on_creation'] = $obj->km; 87 | $object->update($user); 88 | if ($newid > 0) { 89 | setEventMessage('OperationOrderCloned'); 90 | header('Location: ' . dol_buildpath('/operationorder/operationorder_card.php', 1) . '?id=' . $object->id); 91 | exit; 92 | } else { 93 | setEventMessage('OperationOrderCloneError', 'errors'); 94 | } 95 | } else { 96 | dol_print_error($db); 97 | } 98 | } 99 | } 100 | 101 | public function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager){ 102 | 103 | global $conf, $langs, $user, $db; 104 | $contextArray = explode(':', $parameters['context']); 105 | 106 | if (in_array('operationordercard', $contextArray) && $action == 'cloneOR') { 107 | $form = new Form($db); 108 | $fk_status = GETPOST('fk_status' , 'int'); 109 | $formquestion = array ( 'text' => $langs->trans("ConfirmClone"), 110 | array('type' => 'other', 'name' => 'select_fk_vehicule', 'label' => $langs->trans("SelectVehicule"), 'value' => $form->selectForForms('doliFleetVehicule:dolifleet/class/vehicule.class.php', "select_fk_vehicule", $object->array_options['options_fk_dolifleet_vehicule']))); 111 | $body = $langs->trans('ConfirmCloneOperationOrderBody', $object->ref); 112 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id.'&fk_status='.$fk_status, $langs->trans('ConfirmCloneOperationOrderTitle'), $body, 'confirm_cloneOR', $formquestion, 0, 1); 113 | print $formconfirm; 114 | } 115 | 116 | 117 | /*$error = 0; // Error counter 118 | $myvalue = 'test'; // A result value 119 | 120 | print_r($parameters); 121 | echo "action: " . $action; 122 | print_r($object); 123 | 124 | if (in_array('somecontext', explode(':', $parameters['context']))) { 125 | // do something only for the context 'somecontext' 126 | } 127 | 128 | if (!$error) { 129 | $this->results = array('myreturn' => $myvalue); 130 | $this->resprints = 'A text to show'; 131 | return 0; // or return 1 to replace standard code 132 | } else { 133 | $this->errors[] = 'Error message'; 134 | return -1; 135 | }*/ 136 | } 137 | 138 | public function completeTabsHead($parameters, &$object, &$action, $hookmanager) 139 | { 140 | global $langs; 141 | 142 | if (!empty($parameters['object']) && is_object($parameters['object']) && get_class($parameters['object']) == "Societe" && $parameters['mode'] == 'add') 143 | { 144 | $this->results = $parameters['head']; 145 | $this->results[] = array( 146 | dol_buildpath('dolifleet/matrix_tab.php?socid='.$parameters['object']->id, 1), 147 | $langs->trans('rentalMatrix'), 148 | 'matrix' 149 | ); 150 | 151 | return 1; 152 | } 153 | } 154 | 155 | /** 156 | * addSearchEntry Method Hook Call 157 | * 158 | * @param array $parameters parameters 159 | * @param Object &$object Object to use hooks on 160 | * @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) 161 | * @param object $hookmanager class instance 162 | * @return void 163 | */ 164 | public function addSearchEntry($parameters, &$object, &$action, $hookmanager) 165 | { 166 | global $conf, $langs, $user, $db; 167 | $langs->load('dolifleet@dolifleet'); 168 | 169 | dol_include_once('/dolifleet/core/modules/moddoliFleet.class.php'); 170 | $modDolifleet = new moddoliFleet($db); 171 | 172 | $arrayresult = array(); 173 | if (empty($conf->global->DOLIFLEET_HIDE_QUICK_SEARCH) && $user->rights->dolifleet->read) { 174 | $str_search_vin = '&Listview_dolifleet_search_vin=' . urlencode($parameters['search_boxvalue']); 175 | $arrayresult['searchintovehiculevin'] = array( 176 | 'position' => $modDolifleet->numero, 177 | 'text' => img_object('', 'dolifleet@dolifleet') . ' VIN', 178 | 'url' => dol_buildpath('/dolifleet/vehicule_list.php', 1) . '?search_by=Listview_dolifleet_search_vin'.$str_search_vin 179 | ); 180 | 181 | $str_search_immat = '&Listview_dolifleet_search_immatriculation=' . urlencode($parameters['search_boxvalue']); 182 | $arrayresult['searchintovehiculeimmat'] = array( 183 | 'position' => $modDolifleet->numero, 184 | 'text' => img_object('', 'dolifleet@dolifleet') . ' Immat', 185 | 'url' => dol_buildpath('/dolifleet/vehicule_list.php', 1) . '?search_by=Listview_dolifleet_search_immatriculation'.$str_search_immat 186 | ); 187 | 188 | } 189 | 190 | $this->results = $arrayresult; 191 | 192 | return 0; 193 | } 194 | 195 | public function formBuilddocOptions($parameters, &$object, &$action, $hookmanager) 196 | { 197 | // var_dump($parameters); 198 | } 199 | 200 | /** 201 | * @param bool $parameters 202 | * @param $object 203 | * @param string $action 204 | * @return int 205 | */ 206 | public function moreHtmlRef($parameters=false, &$object, &$action='') 207 | { 208 | global $conf; 209 | global $mc; 210 | 211 | // if global sharings is enabled 212 | if (! empty($conf->global->MULTICOMPANY_SHARINGS_ENABLED) 213 | && ! empty($conf->global->MULTICOMPANY_DOLIFLEET_SHARING_ENABLED) 214 | && $object->element == 'dolifleet_vehicule' 215 | && ! empty($conf->dolifleet->enabled) 216 | && ! empty($mc->sharings['dolifleet_vehicule']) 217 | && $object->entity!=$conf->entity) 218 | { 219 | dol_include_once('/multicompany/class/actions_multicompany.class.php'); 220 | $actMulticomp= new ActionsMulticompany($this->db); 221 | $actMulticomp->getInfo($object->entity); 222 | 223 | $this->resprints = "\n" . '' . "\n"; 224 | 225 | $this->resprints .= '
'; 226 | $this->resprints .= '' . $actMulticomp->label . ''; 227 | $this->resprints .= '
'; 228 | 229 | $this->resprints .= "\n" . '' . "\n"; 230 | } 231 | return 0; 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /class/vehiculeOperation.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | class dolifleetVehiculeOperation extends SeedObject 28 | { 29 | /** 30 | * Draft status 31 | */ 32 | const STATUS_DRAFT = 0; 33 | 34 | /** 35 | * To Plan status 36 | */ 37 | const STATUS_TOPLAN = 1; 38 | 39 | /** 40 | * Planned status 41 | */ 42 | const STATUS_PLANNED = 2; 43 | 44 | /** 45 | * Done status 46 | */ 47 | const STATUS_DONE = 3; 48 | 49 | /** @var array $TStatus Array of translate key for each const */ 50 | public static $TStatus = array( 51 | self::STATUS_DRAFT => 'doliFleetOperationStatusShortDraft' 52 | ,self::STATUS_TOPLAN => 'doliFleetOperationStatusShortToPlan' 53 | ,self::STATUS_PLANNED => 'doliFleetOperationStatusShortPlanned' 54 | ,self::STATUS_DONE => 'doliFleetOperationStatusShortDone' 55 | ); 56 | 57 | /** @var string $table_element Table name in SQL */ 58 | public $table_element = 'dolifleet_vehicule_operation'; 59 | 60 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 61 | public $element = 'dolifleet_vehicule_operation'; 62 | 63 | /** @var int $fk_vehicule Object link to vehicule */ 64 | public $fk_vehicule; 65 | 66 | public $fk_soc_vehicule; 67 | 68 | public $fk_product; 69 | 70 | public $status; 71 | 72 | public $km; 73 | 74 | public $delay_from_last_op; 75 | 76 | public $date_done; 77 | 78 | public $rang; 79 | 80 | public $km_done; 81 | 82 | public $fields = array( 83 | 'fk_vehicule' => array( 84 | 'type' => 'integer:doliFleetVehicule:dolifleet/class/vehicule.class.php', 85 | 'label' => 'doliFleetVehicule', 86 | 'visible' => 1, 87 | 'enabled' => 1, 88 | 'position' => 10, 89 | 'index' => 1, 90 | ), 91 | 92 | 'fk_soc_vehicule' => array( 93 | 'type' => 'integer:Societe:societe/class/societe.class.php', 94 | 'label' => 'ThirdParty', 95 | 'visible' => 1, 96 | 'notnull' =>1, 97 | 'default' => 0, 98 | 'enabled' => 1, 99 | 'position' => 80, 100 | 'index' => 1, 101 | 'help' => 'LinkToThirparty' 102 | ), 103 | 104 | 'fk_product' => array( 105 | 'type' => 'integer:Product:product/class/product.class.php', 106 | 'label' => 'VehiculeOperation', 107 | 'visible' => 1, 108 | 'enabled' => 1, 109 | 'position' => 20, 110 | 'index' => 1, 111 | ), 112 | 113 | 'status' => array( 114 | 'type' => 'integer', 115 | 'label' => 'Status', 116 | 'enabled' => 1, 117 | 'visible' => 0, 118 | 'notnull' => 1, 119 | 'default' => 0, 120 | 'index' => 1, 121 | 'position' => 30, 122 | 'arrayofkeyval' => array( 123 | self::STATUS_DRAFT => 'doliFleetOperationStatusShortDraft' 124 | ,self::STATUS_TOPLAN => 'doliFleetOperationStatusShortToPlan' 125 | ,self::STATUS_PLANNED => 'doliFleetOperationStatusShortPlanned' 126 | ,self::STATUS_DONE => 'doliFleetOperationStatusShortDone' 127 | ) 128 | ), 129 | 130 | 'rang' => array( 131 | 'type' => 'integer', 132 | 'visible' => 0, 133 | 'enabled' => 1, 134 | 'position' => 40 135 | ), 136 | 137 | 'km' => array( 138 | 'type' => 'double', 139 | 'visible' => 1, 140 | 'enabled' => 1, 141 | 'position' => 50 142 | ), 143 | 144 | 'delai_from_last_op' => array( 145 | 'type' => 'integer', 146 | 'label' => 'VehiculeOperationDelai', 147 | 'visible' => 1, 148 | 'enabled' => 1, 149 | 'position' => 60, 150 | 'comment' => 'delay from last operation in months' 151 | ), 152 | 153 | 'date_done' => array( 154 | 'type' => 'date', 155 | 'label' => 'VehiculeOperationDateDone', 156 | 'visible' => 1, 157 | 'enabled' => 1, 158 | 'position' => 70, 159 | ), 160 | 161 | 'km_done' => array( 162 | 'type' => 'double', 163 | 'label' => 'VehiculeOperationKmDone', 164 | 'visible' => 1, 165 | 'enabled' => 1, 166 | 'position' => 80, 167 | ) 168 | 169 | ); 170 | 171 | /** 172 | * doliFleetVehiculeOperation constructor. 173 | * @param DoliDB $db Database connector 174 | */ 175 | public function __construct($db) 176 | { 177 | global $conf; 178 | 179 | parent::__construct($db); 180 | 181 | $this->init(); 182 | 183 | $this->entity = $conf->entity; 184 | } 185 | 186 | /** 187 | * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto 188 | * @return string 189 | */ 190 | public function getLibStatut($mode = 0) 191 | { 192 | return self::LibStatut($this->status, $mode); 193 | } 194 | 195 | /** 196 | * @param int $status Status 197 | * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto 198 | * @return string 199 | */ 200 | public static function LibStatut($status, $mode) 201 | { 202 | global $langs; 203 | 204 | $langs->load('dolifleet@dolifleet'); 205 | $res = ''; 206 | 207 | if ($status==self::STATUS_DRAFT) { $statusType='status0'; $statusLabel=$langs->trans('doliFleetOperationStatusDraft'); $statusLabelShort=$langs->trans('doliFleetOperationStatusShortDraft'); } 208 | elseif ($status==self::STATUS_TOPLAN) { $statusType='status6'; $statusLabel=$langs->trans('doliFleetOperationStatusToPlan'); $statusLabelShort=$langs->trans('doliFleetOperationStatusShortToPlan'); } 209 | elseif ($status==self::STATUS_PLANNED) { $statusType='status1'; $statusLabel=$langs->trans('doliFleetOperationStatusPlanned'); $statusLabelShort=$langs->trans('doliFleetOperationStatusShortPlanned'); } 210 | elseif ($status==self::STATUS_DONE) { $statusType='status4'; $statusLabel=$langs->trans('doliFleetOperationStatusDone'); $statusLabelShort=$langs->trans('doliFleetOperationStatusShortDone'); } 211 | 212 | if (function_exists('dolGetStatus')) 213 | { 214 | $res = dolGetStatus($statusLabel, $statusLabelShort, '', $statusType, $mode); 215 | } 216 | else 217 | { 218 | if ($mode == 0) $res = $statusLabel; 219 | elseif ($mode == 1) $res = $statusLabelShort; 220 | elseif ($mode == 2) $res = img_picto($statusLabel, $statusType).$statusLabelShort; 221 | elseif ($mode == 3) $res = img_picto($statusLabel, $statusType); 222 | elseif ($mode == 4) $res = img_picto($statusLabel, $statusType).$statusLabel; 223 | elseif ($mode == 5) $res = $statusLabelShort.img_picto($statusLabel, $statusType); 224 | elseif ($mode == 6) $res = $statusLabel.img_picto($statusLabel, $statusType); 225 | } 226 | 227 | return $res; 228 | } 229 | 230 | public function getName() 231 | { 232 | $ret = $this->fetch_product(); 233 | if ($ret > 0) return $this->product->getNomUrl(1); 234 | else return ''; 235 | } 236 | 237 | public function create(User &$user, $notrigger = false) 238 | { 239 | global $langs; 240 | 241 | if (empty($this->fk_vehicule) || $this->fk_vehicule == '-1') 242 | { 243 | $this->errors[] = $langs->trans('ErrInvalidFkVehicule'); 244 | } 245 | 246 | if (empty($this->fk_product)) 247 | { 248 | $this->errors[] = $langs->trans('ErrOperationNoProdId'); 249 | } 250 | 251 | require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; 252 | $prod = new Product($this->db); 253 | $ret = $prod->fetch($this->fk_product); 254 | if ($ret <= 0) 255 | { 256 | $this->errors[] = $langs->trans('ErrOperationInvalidProduct'); 257 | } 258 | 259 | if (empty($this->km) && empty($this->delai_from_last_op)) 260 | { 261 | $this->errors[] = $langs->trans('ErrOperationNoCritera'); 262 | } 263 | 264 | if (!empty($this->km)) 265 | { 266 | $maxKM = $this->getMaxOperationKM(); 267 | if ($this->km < $maxKM) $this->errors[] = $langs->trans('ErrOperationMaxKM', $maxKM); 268 | } 269 | 270 | if (!empty($this->errors)) return -1; 271 | 272 | if (empty($this->id)) $this->rang = (int) $this->getMaxRank() + 1; 273 | 274 | return parent::create($user, $notrigger); // TODO: Change the autogenerated stub 275 | } 276 | 277 | public function getMaxRank() 278 | { 279 | $sql = "SELECT MAX(rang) as maxrank FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE fk_vehicule = ".$this->fk_vehicule; 280 | $resql = $this->db->query($sql); 281 | if ($resql) 282 | { 283 | $obj = $this->db->fetch_object($resql); 284 | return $obj->maxrank; 285 | } 286 | 287 | return 0; 288 | } 289 | 290 | public function getMaxOperationKM() 291 | { 292 | $sql = "SELECT MAX(km) as km FROM ".MAIN_DB_PREFIX.$this->table_element; 293 | $sql.= " WHERE fk_vehicule = ".$this->fk_vehicule; 294 | 295 | $resql = $this->db->query($sql); 296 | if ($resql) 297 | { 298 | $obj = $this->db->fetch_object($resql); 299 | return (int) $obj->km; 300 | } 301 | 302 | return 0; 303 | } 304 | } 305 | -------------------------------------------------------------------------------- /langs/fr_FR/dolifleet.lang: -------------------------------------------------------------------------------- 1 | Module104087Name = Véhicules 2 | Module104087Desc = Module de gestion de flotte de véhicules 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 | doliFleet=Véhicules 7 | AbricotNeedUpdate=Le module abricot doit être mis à jour 8 | 9 | c_dolifleet_contract_type=DoliFleet - Types de contrat véhicule 10 | c_dolifleet_vehicule_type=DoliFleet - Types de véhicule 11 | c_dolifleet_vehicule_mark=DoliFleet - Marques de véhicule 12 | c_dolifleet_vehicule_activity_type=DoliFleet - Type d'activité véhicule 13 | 14 | # DROITS 15 | vehicule_read=Voir les véhicules 16 | vehicule_write=Créez/modifier les véhicules 17 | vehicule_delete=Supprimer les véhicules 18 | rental_read=Voir les loyers 19 | rental_write=Créer/modifier les loyers 20 | rental_validate=Valider les loyers 21 | rental_delete=Supprimer les loyers 22 | matrix_read=Voir les matrices de loyers 23 | matrix_write=Créer une matrice de loyers 24 | matrix_delete=Supprimer une matrice de loyers 25 | rentalproposal_read=Voir les propositions de loyers 26 | rentalproposal_write=Créer/modifier les propositions de loyers 27 | rentalproposal_validate=Valider/accepter les propositions de loyers 28 | rentalproposal_delete=Supprimer les propositions de loyers 29 | 30 | # SETUP 31 | ParamLabel=Nom du paramètre 32 | ParamDesc=Une description si besoin 33 | ParamHelp=Le contenu de l'aide 34 | doliFleetSetup = Configuration du module doliFleet 35 | doliFleetAbout = A propos du module doliFleet 36 | DOLIFLEET_MOTRICE_TYPES=Type de véhicule tracteur 37 | rentalMatrix=Matrice de loyers 38 | DOLIFLEET_DEFAULT_RENTAL_AMOUNT=Loyer par défaut (si aucun n'est trouvé dans la matrice client ou générale) 39 | DOLIFLEET_DELAY_SEARCH_OPERATIONS=Délai en mois pour rechercher les opérations précédentes dans la planification des opérations véhicules 40 | ShareDolifleet_vehicule=Activer le partage des véhicules 41 | DOLIFLEET_VEHICULESharing=Partage des véhicules 42 | DOLIFLEET_VEHICULESharingDescription=Sélection des entités qui partagerons leur base véhicules avec cette entité. 43 | Multicompany=Options du module multi sociétés 44 | ActivateVehiculeSharing=Activer le partage des véhicules entre entités (pensez à configurer le partage ci-dessous) 45 | MulticompanyConfiguration=Configuration des partages entre entités 46 | ShareWith=Reprend les données dans 47 | multicompanySharing=Partage entre entités 48 | RentalproposalPDFModules=Modèles PDF Proposition de loyer 49 | 50 | # MENU 51 | TopMenudoliFleet=Vehicule 52 | MenudoliFleetVehicule=Vehicule 53 | LeftMenudoliFleetVehiculeCreate=Créer un véhicule 54 | LeftMenudoliFleetVehiculeList=Liste de véhicule 55 | MenudolifleetRentalProposal=Proposition de loyer 56 | LeftMenudoliFleetRentalProposalCreate=Nouvelle proposition 57 | LeftMenudoliFleetRentalProposalList=Liste propositions 58 | 59 | # STATUS 60 | doliFleetVehiculeStatusDraft=Inactif 61 | doliFleetVehiculeStatusActivated=Actif 62 | doliFleetVehiculeStatusValidate=Actif 63 | 64 | doliFleetOperationStatusDraft=Brouillon 65 | doliFleetOperationStatusToPlan=à planifier 66 | doliFleetOperationStatusPlanned=Planifié 67 | doliFleetOperationStatusDone=Réalisé 68 | 69 | doliFleetVehiculeStatusShortDraft=Inactif 70 | doliFleetVehiculeStatusShortActivated=Actif 71 | doliFleetVehiculeStatusShortValidate=Actif 72 | 73 | doliFleetOperationStatusShortDraft=Brouillon 74 | doliFleetOperationStatusShortToPlan=à planifier 75 | doliFleetOperationStatusShortPlanned=Planifié 76 | doliFleetOperationStatusShortDone=Réalisé 77 | 78 | doliFleetProposalStatusDraft=Brouillon (à valider) 79 | doliFleetProposalStatusShortDraft=Brouillon 80 | doliFleetProposalStatusInProgress=Validation en cours (à accepter) 81 | doliFleetProposalStatusShortInProgress=Validation en cours 82 | doliFleetProposalStatusValidated=Validée 83 | doliFleetProposalStatusCloture=Cloturée 84 | 85 | # LIST 86 | doliFleetVehiculeList=Liste de véhicules 87 | NodoliFleet=(vide) 88 | 89 | # CARD 90 | NewdoliFleetVehicule=Création véhicule 91 | doliFleetVehiculeCard=Fiche véhicule 92 | doliFleetVehicule=Véhicule 93 | NewdoliFleet=Nouveau véhicule 94 | immatriculation_date=date de première mise en circulation 95 | immatriculation_date_short=Mise en circulation 96 | vehiculeDelayExploit=Durée maximum d'exploitation 97 | LinkToThirparty=Lien vers le tiers 98 | km_date=Date de relevé kilométrique 99 | date_customer_exploit=Date de mise en exploitation 100 | date_customer_exploit_help=Mise en exploitation peut différer de la mise en circulation 101 | date_end_contract=Date fin de contrat 102 | contractType=Type de contrat 103 | vehiculeType=Type de véhicule 104 | vehiculeMark=Marque du véhicule 105 | ShowdoliFleetVehicule=Voir le véhicule 106 | ActivityType=Type d'activité 107 | NodoliFleetActivity=Pas d'activité 108 | ActivityAdded=Activité ajoutée 109 | VehiculeActivities=Activités véhicule 110 | LinkedVehicules=Véhicules liés 111 | VehiculeUnlinked=Le véhicule a été délié 112 | VehiculeRentals=Loyers 113 | VehiculeRental=Loyer 114 | rentDeleted=Loyer supprimé 115 | VehiculeOperations=Opérations 116 | VehiculeOperation=Opération 117 | VehiculeOperationDelay=Délais depuis dernière opé. 118 | VehiculeOperationLastDateDone=Date dernière opé. 119 | VehiculeOperationLastKmDone=Km dernière opé. 120 | dolifleetRentalProposal=Proposition de loyers 121 | doliFleetRentalProposalCard=Fiche proposition de loyers 122 | ShowdolifleetRentalProposal=Voir la proposition de loyers 123 | NewdolifleetRentalProposal=Nouvelle proposition de loyers 124 | dolifleetRentalProposalList=Liste de propositions de loyers 125 | NoMatrixDefined=Aucune matrice définie pour le tiers 126 | CanImportMatrix=Vous pouvez importer la matrice générale pour ce tiers 127 | ImportConf=Importer 128 | AmountIsFromThirdpartyMatrix=Prix repris depuis la matrice client 129 | AmountIsFromGlobalMatrix=Prix repris de la matrice globale 130 | AmountIsFromGlobalConf=Prix par défaut 131 | OnlyUserWhoValidatedCanReopen=Seul l'utilisateur qui a validé la proposition peut la rouvrir 132 | UserMustBeDifferentFromValider=Seul un autre utilisateur ayant le droit approprié peut accepter la proposition 133 | CanNotDeleteClosedProposal=Impossible de supprimer une proposition cloturée 134 | 135 | doliFleetModify=Modifier 136 | doliFleetClone=Cloner 137 | doliFleetClose=Cloturer 138 | doliFleetValid=Valider 139 | doliFleetActivate=Activer 140 | doliFleetUnactivate=Désactiver 141 | doliFleetAccept=Accepter 142 | doliFleetRefuse=Refuser 143 | doliFleetReopen=Rouvrir 144 | doliFleetCancel=Abandonner 145 | doliFleetDelete=Supprimer 146 | 147 | # formConfirm 148 | ConfirmActivatedoliFleetVehiculeTitle=Confirmation d'activation 149 | ConfirmActivatedoliFleetVehiculeBody=Souhaitez-vous vraiment activer cette fiche véhicule %s ? 150 | ConfirmReopendoliFleetVehiculeTitle=Confirmation de désactivation 151 | ConfirmReopendoliFleetVehiculeBody=Souhaitez-vous vraiment désactiver cette fiche véhicule %s ? 152 | ConfirmDeletedoliFleetVehiculeTitle=Confirmation de suppression 153 | ConfirmDeletedoliFleetVehiculeBody=Souhaitez-vous vraiment supprimer cette fiche véhicule %s ? 154 | ConfirmClonedoliFleetVehiculeTitle=Confirmation de clonage 155 | ConfirmClonedoliFleetVehiculeBody=Souhaitez-vous vraiment clone cette fiche véhicule %s ? 156 | ConfirmDelActivitydoliFleetVehiculeBody=Voulez-vous vraiment supprimer cette activité ? 157 | ConfirmUnlinkVehiculedoliFleetVehiculeTitle=Confirmation de suppression du lien 158 | ConfirmUnlinkVehiculedoliFleetVehiculeBody=Voulez-vous vraiment supprimer le lien avec le véhicule ? 159 | ConfirmDelRentaldoliFleetVehiculeBody=Voulez-vous vraiment supprimer ce loyer ? 160 | ConfirmDelOperationdoliFleetVehiculeBody=Voulez-vous vraiment supprimer cette opération ? 161 | ConfirmDeldoliFleetLineBody=Voulez-vous vraiment supprimer cette ligne ? 162 | ConfirmValidateRentalProposalTitle=Confirmation de validation 163 | ConfirmValidateRentalProposalBody=Voulez-vous vraiment valider cette proposition ? 164 | ConfirmAcceptRentalProposalTitle=Confirmation d'acceptation 165 | ConfirmAcceptRentalProposalBody=Voulez-vous vraiment accepter cette proposition ? 166 | ConfirmDeleteRentalBody=Voulez-vous vraiment supprimer cette proposition de loyers ? 167 | ConfirmCloseRentalProposalTitle=Confirmation de cloture 168 | ConfirmCloseRentalProposalBody=Voulez-vous vraiment cloturer cette proposition ?

Ceci créera les loyers clients pour chaque véhicule listé dans cette proposition. 169 | 170 | # Erreur 171 | ErrNoVinNumber=Aucun VIN renseigné 172 | ErrVinAlreadyUsed=Le VIN est déjà utilisé pour le véhicule %s 173 | ErrInvalidFkVehicule=Véhicule invalide 174 | ErrNoActivityType=Pas de type d'activité renseigné 175 | ErrAlreadyInActivity=Le véhicule est déjà en activité pour les date spécifiées 176 | ErrNoVehiculeToLink=Pas de véhicule à lier 177 | ErrVehiculeAlreadyLinkedDates=Le véhicule %s est déjà lié au véhicule %s du %s au %s 178 | ErrVehiculeUnlink=Impossible de délier le véhicule 179 | ErrEmptyAmountForRental=Le montant du loyer ne peut être vide 180 | ErrPeriodReservedForRental=Un ou plusieur loyers sont déjà définis sur la période du %s au %s 181 | ErrOperationNoProdId=Opération : pas de produit sélectionné 182 | ErrOperationInvalidProduct=Produit erroné 183 | ErrOperationNoCritera=Vous devez renseigner un des critères km ou délai 184 | ErrOperationMaxKM=Le critère km est inférieur à %s (plus grand km saisi dans les opérations du véhicule) 185 | ErrInvalidType=Type de véhicule invalide 186 | ErrInvalidMark=Marque de véhicule invalide 187 | ErrNoDelayForLine=Pas de durée saisi 188 | ErrInvalidAmount=Montant saisie invalide 189 | ErrDuplicateMatrix=Il existe déjà une ligne de matrice pour ce type, cette marque, et cette durée 190 | ErrVehiculeThirPartiesAreDifferent=Les tiers des véhicules à lier sont différents 191 | ErrEmptyVehiculeImmatDate=Date de mise en circulation invalide 192 | ErrInvalidSocid=Tiers invalide 193 | 194 | SelectVehicule=Selection de vehicule : 195 | -------------------------------------------------------------------------------- /admin/rental_matrix.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * \file admin/about.php 20 | * \ingroup dolifleet 21 | * \brief This file is an example about page 22 | * Put some comments here 23 | */ 24 | // Dolibarr environment 25 | $res = @include '../../main.inc.php'; // From htdocs directory 26 | if (! $res) { 27 | $res = @include '../../../main.inc.php'; // From "custom" directory 28 | } 29 | 30 | // Libraries 31 | require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; 32 | require_once '../lib/dolifleet.lib.php'; 33 | dol_include_once('/dolifleet/class/vehiculeRentalMatrix.class.php'); 34 | dol_include_once('/dolifleet/class/dictionaryVehiculeType.class.php'); 35 | dol_include_once('/dolifleet/class/dictionaryVehiculeMark.class.php'); 36 | 37 | $action = GETPOST('action'); 38 | if (!GETPOST('cancel')) 39 | { 40 | $type = GETPOST('fk_c_type_vh'); 41 | $mark = GETPOST('fk_c_mark_vh'); 42 | $delay = GETPOST('delay'); 43 | $amount = GETPOST('amount_ht'); 44 | $id = GETPOST('id'); 45 | } 46 | 47 | $search_type = GETPOST('search_fk_c_type_vh'); 48 | $search_mark = GETPOST('search_fk_c_mark_vh'); 49 | 50 | if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) 51 | { 52 | $search_type = ''; 53 | $search_mark = ''; 54 | } 55 | 56 | 57 | // Translations 58 | $langs->load('dolifleet@dolifleet'); 59 | 60 | $userCanRead = $user->rights->dolifleet->matrix->read; 61 | $userCanCreate = $user->rights->dolifleet->matrix->write; 62 | $userCanDelete = $user->rights->dolifleet->matrix->delete; 63 | 64 | // Access control 65 | if (! $user->admin || ! $userCanRead) { 66 | accessforbidden(); 67 | } 68 | 69 | $object = new doliFleetVehiculeRentalMatrix($db); 70 | 71 | /* 72 | * Actions 73 | */ 74 | if ($action == 'addMatrixLine' || $action == 'editMatrixLine') 75 | { 76 | if (!GETPOST('cancel')) 77 | { 78 | $object->setValues($_REQUEST); 79 | $ret = $object->create($user); 80 | if ($ret < 0 || !empty($object->errors)) 81 | { 82 | setEventMessages('', $object->errors, "errors"); 83 | if ($action == 'editMatrixLine') $action = 'edit'; 84 | } 85 | else 86 | { 87 | setEventMessage('RecordSaved'); 88 | header('Location: '.$_SERVER['PHP_SELF']); 89 | exit; 90 | } 91 | } 92 | } 93 | if ($action == 'confirm_delMatrixLine') 94 | { 95 | $object->id = $id; 96 | $ret = $object->delete($user); 97 | } 98 | 99 | 100 | $dictType = new dictionaryVehiculeType($db); 101 | $TType = $dictType->getAllActiveArray('label'); 102 | 103 | $dictMark = new dictionaryVehiculeMark($db); 104 | $TMark = $dictMark->getAllActiveArray('label'); 105 | 106 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$object->table_element; 107 | $sql.= " WHERE fk_soc = 0"; 108 | if (!empty($search_type) && $search_type != -1) $sql.= " AND fk_c_type_vh = ".$search_type; 109 | if (!empty($search_mark) && $search_mark != -1) $sql.= " AND fk_c_mark_vh = ".$search_mark; 110 | $sql.= " ORDER BY fk_c_type_vh ASC, fk_c_mark_vh ASC, delay ASC"; 111 | 112 | $resql = $db->query($sql); 113 | if (!$resql) dol_print_error($db); 114 | else $num = $db->num_rows($resql); 115 | 116 | /* 117 | * View 118 | */ 119 | $page_name = 'rentalMatrix'; 120 | llxHeader('', $langs->trans($page_name)); 121 | 122 | // Subheader 123 | $linkback = '' 124 | . $langs->trans('BackToModuleList') . ''; 125 | print load_fiche_titre($langs->trans($page_name), $linkback); 126 | 127 | // Configuration header 128 | $head = dolifleetAdminPrepareHead(); 129 | dol_fiche_head( 130 | $head, 131 | 'matrix', 132 | $langs->trans('Module104087Name'), 133 | -1, 134 | 'dolifleet@dolifleet' 135 | ); 136 | 137 | $formconfirm = getFormConfirmdoliFleetVehicule($form, $object, $action); 138 | if (!empty($formconfirm)) print $formconfirm; 139 | 140 | print '
'; 141 | 142 | if ($userCanCreate) 143 | { 144 | print '
'; 145 | print ''; 146 | print ''; 147 | 148 | print ''; 149 | 150 | // table header 151 | print ''; 152 | print ''; 155 | print ''; 158 | print ''; 161 | print ''; 164 | print ''; 165 | print ''; 166 | 167 | // new line 168 | print '' 169 | ; 170 | print ''; 173 | 174 | print ''; 177 | 178 | print ''; 181 | 182 | print ''; 185 | 186 | print ''; 189 | 190 | print ''; 191 | 192 | 193 | print '
'; 153 | print $langs->trans('vehiculeType'); 154 | print ''; 156 | print $langs->trans('vehiculeMark'); 157 | print ''; 159 | print $langs->trans('vehiculeDelayExploit'); 160 | print ''; 162 | print $langs->trans('VehiculeRental'); 163 | print '
'; 171 | print $form->selectarray('fk_c_type_vh', $TType, $type,1, 0, 0, '', 0, 0, 0, '', '', 1); 172 | print ''; 175 | print $form->selectarray('fk_c_mark_vh', $TMark, $mark,1, 0, 0, '', 0, 0, 0, '', '', 1); 176 | print ''; 179 | print ' '.$langs->trans('Months'); 180 | print ''; 183 | print ''; 184 | print ''; 187 | print ''; 188 | print '
'; 194 | 195 | print '
'; 196 | 197 | print '
'; 198 | } 199 | 200 | print '
'; 201 | print ''; 202 | 203 | print ''; 204 | 205 | // table filters 206 | print ''; 207 | print ''; 210 | print ''; 213 | print ''; 215 | print ''; 217 | print ''; 221 | print ''; 222 | 223 | // table header 224 | print ''; 225 | print ''; 228 | print ''; 231 | print ''; 234 | print ''; 237 | print ''; 238 | print ''; 239 | 240 | if (empty($num)) 241 | { 242 | print ''; 243 | print ''; 246 | print ''; 247 | } 248 | else 249 | { 250 | while ($obj = $db->fetch_object($resql)) 251 | { 252 | $matrixline = new doliFleetVehiculeRentalMatrix($db); 253 | $matrixline->fetch($obj->rowid); 254 | 255 | if ($action == "edit" && $id == $matrixline->id && $userCanCreate) 256 | { 257 | print ''; 258 | print ''; 263 | print ''; 266 | print ''; 269 | print ''; 272 | // actions 273 | print ''; 277 | print ''; 278 | } 279 | else 280 | { 281 | print ''; 282 | print ''; 285 | print ''; 288 | print ''; 291 | print ''; 294 | // actions 295 | print ''; 299 | print ''; 300 | } 301 | 302 | 303 | } 304 | } 305 | 306 | 307 | print '
'; 208 | print $form->selectarray('search_fk_c_type_vh', $TType, $search_type,1, 0, 0, '', 0, 0, 0, '', '', 1); 209 | print ''; 211 | print $form->selectarray('search_fk_c_mark_vh', $TMark, $search_mark,1, 0, 0, '', 0, 0, 0, '', '', 1); 212 | print ''; 214 | print ''; 216 | print ''; 218 | $searchpicto = $form->showFilterAndCheckAddButtons(0); 219 | print $searchpicto; 220 | print '
'; 226 | print $langs->trans('vehiculeType'); 227 | print ''; 229 | print $langs->trans('vehiculeMark'); 230 | print ''; 232 | print $langs->trans('vehiculeDelayExploit'); 233 | print ''; 235 | print $langs->trans('VehiculeRental'); 236 | print '
'; 244 | print $langs->trans('NodoliFleet'); 245 | print '
'; 259 | print ''; 260 | print ''; 261 | print $form->selectarray('fk_c_type_vh', $TType, $matrixline->fk_c_type_vh,1, 0, 0, '', 0, 0, 0, '', '', 1); 262 | print ''; 264 | print $form->selectarray('fk_c_mark_vh', $TMark, $matrixline->fk_c_mark_vh,1, 0, 0, '', 0, 0, 0, '', '', 1); 265 | print ''; 267 | print ' '.$langs->trans('Months'); 268 | print ''; 270 | print ''; 271 | print ''; 274 | print ''; 275 | print ''; 276 | print '
'; 283 | print $dictType->getValueFromId($matrixline->fk_c_type_vh); 284 | print ''; 286 | print $dictMark->getValueFromId($matrixline->fk_c_mark_vh); 287 | print ''; 289 | print $matrixline->delay.' '.$langs->trans('Months'); 290 | print ''; 292 | print price($matrixline->amount_ht); 293 | print ''; 296 | if ($userCanCreate) print ''.img_edit().''; 297 | if ($userCanDelete) print ''.img_delete().''; 298 | print '
'; 308 | 309 | print '
'; 310 | 311 | print '
'; 312 | 313 | dol_fiche_end(); 314 | 315 | llxFooter(); 316 | $db->close(); 317 | -------------------------------------------------------------------------------- /vehicule_list.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | require 'config.php'; 19 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; 20 | dol_include_once('dolifleet/class/vehicule.class.php'); 21 | dol_include_once('dolifleet/class/dictionaryContractType.class.php'); 22 | dol_include_once('dolifleet/class/dictionaryVehiculeType.class.php'); 23 | dol_include_once('dolifleet/class/dictionaryVehiculeMark.class.php'); 24 | 25 | if(empty($user->rights->dolifleet->read)) accessforbidden(); 26 | 27 | $langs->load('abricot@abricot'); 28 | $langs->load('dolifleet@dolifleet'); 29 | 30 | $fk_soc = GETPOST('fk_soc', 'int'); 31 | $search_by=GETPOST('search_by', 'alpha'); 32 | if (!empty($search_by)) { 33 | $sall=GETPOST('sall'); 34 | if (!empty($sall)) { 35 | $_GET[$search_by]=$sall; 36 | } 37 | } 38 | 39 | $massaction = GETPOST('massaction', 'alpha'); 40 | $action = GETPOST('action', 'alpha'); 41 | $confirmmassaction = GETPOST('confirmmassaction', 'alpha'); 42 | $toselect = GETPOST('toselect', 'array'); 43 | 44 | $object = new doliFleetVehicule($db); 45 | $dictCT = new dictionaryContractType($db); 46 | $dictVT = new dictionaryVehiculeType($db); 47 | $dictVM = new dictionaryVehiculeMark($db); 48 | 49 | $hookmanager->initHooks(array('vehiculelist')); 50 | 51 | if ($object->isextrafieldmanaged) 52 | { 53 | $extrafields = new ExtraFields($db); 54 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); 55 | } 56 | 57 | /* 58 | * Actions 59 | */ 60 | 61 | $parameters=array(); 62 | $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 63 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 64 | 65 | if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') 66 | { 67 | $massaction = ''; 68 | } 69 | 70 | if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) 71 | { 72 | unset($fk_soc); 73 | } 74 | 75 | if (empty($reshook)) 76 | { 77 | // do action from GETPOST ... 78 | } 79 | 80 | 81 | /* 82 | * View 83 | */ 84 | 85 | llxHeader('', $langs->trans('doliFleetVehiculeList'), '', ''); 86 | 87 | //$type = GETPOST('type'); 88 | //if (empty($user->rights->dolifleet->all->read)) $type = 'mine'; 89 | 90 | $formconfirm = ''; 91 | 92 | $parameters = array('formConfirm' => $formconfirm); 93 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook 94 | if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; 95 | elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; 96 | 97 | // Print form confirm 98 | print $formconfirm; 99 | 100 | 101 | // TODO ajouter les champs de son objet que l'on souhaite afficher 102 | $keys = array_keys($object->fields); 103 | $fieldList = 't.'.implode(', t.', $keys); 104 | if (!empty($object->isextrafieldmanaged)) 105 | { 106 | $keys = array_keys($extralabels); 107 | if(!empty($keys)) { 108 | $fieldList .= ', et.' . implode(', et.', $keys); 109 | } 110 | } 111 | 112 | $sql = 'SELECT '.$fieldList; 113 | 114 | // Add fields from hooks 115 | $parameters=array('sql' => $sql); 116 | $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook 117 | $sql.=$hookmanager->resPrint; 118 | 119 | $sql.= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' t '; 120 | 121 | if (!empty($object->isextrafieldmanaged) && array_keys($extralabels)) 122 | { 123 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.$object->table_element.'_extrafields et ON (et.fk_object = t.rowid)'; 124 | } 125 | 126 | $sql.= ' WHERE 1=1'; 127 | $sql.= ' AND t.entity IN ('.getEntity('dolifleet', 1).')'; 128 | //if ($type == 'mine') $sql.= ' AND t.fk_user = '.$user->id; 129 | if (!empty($fk_soc) && $fk_soc > 0) $sql.= ' AND t.fk_soc = '.$fk_soc; 130 | // Add where from hooks 131 | $parameters=array('sql' => $sql); 132 | $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook 133 | $sql.=$hookmanager->resPrint; 134 | 135 | //print $sql; 136 | 137 | $formcore = new TFormCore($_SERVER['PHP_SELF'], 'form_list_dolifleet', 'GET'); 138 | $form = new Form($db); 139 | 140 | $nbLine = GETPOST('limit'); 141 | if (empty($nbLine)) $nbLine = !empty($user->conf->MAIN_SIZE_LISTE_LIMIT) ? $user->conf->MAIN_SIZE_LISTE_LIMIT : $conf->global->MAIN_SIZE_LISTE_LIMIT; 142 | 143 | // configuration listView 144 | 145 | $TTitle = array(); 146 | 147 | foreach ($object->fields as $fieldKey => $infos) 148 | { 149 | if (isset($infos['label']) && $infos['visible'] > 0) $TTitle[$fieldKey] = $langs->trans($infos['label']); 150 | } 151 | 152 | $TTitle['status'] = $langs->trans('Status'); 153 | 154 | if (!empty(array_keys($extralabels))) 155 | { 156 | foreach ($extralabels as $k => $v) 157 | { 158 | if (in_array(abs($extrafields->attributes[$object->table_element]['list'][$k]),array(1,2,4)) && !empty(abs($extrafields->attributes[$object->table_element]['list'][$k]))) { 159 | $TTitle[$k] = $v; 160 | } 161 | } 162 | } 163 | 164 | $listViewConfig = array( 165 | 'view_type' => 'list' // default = [list], [raw], [chart] 166 | ,'allow-fields-select' => true 167 | ,'limit'=>array( 168 | 'nbLine' => $nbLine 169 | ) 170 | ,'list' => array( 171 | 'title' => $langs->trans('doliFleetVehiculeList') 172 | ,'image' => 'title_generic.png' 173 | ,'picto_precedent' => '<' 174 | ,'picto_suivant' => '>' 175 | ,'noheader' => 0 176 | ,'messageNothing' => $langs->trans('NodoliFleet') 177 | ,'picto_search' => img_picto('', 'search.png', '', 0) 178 | ,'massactions'=>array( 179 | // 'yourmassactioncode' => $langs->trans('YourMassActionLabel') 180 | ) 181 | ,'param_url' => '&limit='.$nbLine 182 | ) 183 | ,'subQuery' => array() 184 | ,'link' => array() 185 | ,'type' => array( 186 | 'date_creation' => 'date' // [datetime], [hour], [money], [number], [integer] 187 | ,'tms' => 'date' 188 | ,'date_immat'=>'date' 189 | ,'date_customer_exploit'=>'date' 190 | ,'km_date'=>'date' 191 | ,'date_end_contract'=>'date' 192 | ) 193 | ,'search' => array( 194 | // 'date_creation' => array('search_type' => 'calendars', 'allow_is_null' => true) 195 | // ,'tms' => array('search_type' => 'calendars', 'allow_is_null' => false) 196 | // ,'label' => array('search_type' => true, 'table' => array('t', 't'), 'field' => array('label')) // input text de recherche sur plusieurs champs 197 | 'vin' => array('search_type' => true, 'table' => 't', 'field' => 'vin') 198 | ,'fk_vehicule_type' => array('search_type' => $dictVT->getAllActiveArray('label')) 199 | ,'fk_vehicule_mark' => array('search_type' => $dictVM->getAllActiveArray('label')) 200 | ,'immatriculation' => array('search_type' => true, 'table' => 't', 'field' => 'immatriculation') 201 | ,'date_immat' => array('search_type' => 'calendars', 'allow_is_null' => false) 202 | ,'fk_soc' => array('search_type' => 'override', 'override'=> $form->select_company($fk_soc, 'fk_soc')) 203 | ,'date_customer_exploit' => array('search_type' => 'calendars', 'allow_is_null' => false) 204 | ,'km' => array('search_type' => true, 'table' => 't', 'field' => 'km') 205 | ,'km_date' => array('search_type' => 'calendars', 'allow_is_null' => false) 206 | ,'fk_contract_type' => array('search_type' => $dictCT->getAllActiveArray('label')) 207 | ,'date_end_contract' => array('search_type' => 'calendars', 'allow_is_null' => false) 208 | ,'status' => array('search_type' => doliFleetVehicule::$TStatus, 'to_translate' => true) // select html, la clé = le status de l'objet, 'to_translate' à true si nécessaire 209 | ) 210 | ,'translate' => array() 211 | ,'hide' => array( 212 | 'rowid' // important : rowid doit exister dans la query sql pour les checkbox de massaction 213 | ) 214 | ,'title'=>$TTitle 215 | ,'eval'=>array( 216 | 'vin' => '_getObjectNomUrl(\'@rowid@\', \'@val@\')' 217 | ,'fk_vehicule_type' => '_getValueFromId("@val@", "dictionaryVehiculeType")' 218 | ,'fk_vehicule_mark' => '_getValueFromId("@val@", "dictionaryVehiculeMark")' 219 | ,'fk_soc' => '_getSocieteNomUrl("@val@")' 220 | ,'fk_contract_type' => '_getValueFromId("@val@", "dictionaryContractType")' 221 | ,'status' => 'doliFleetVehicule::LibStatut("@val@", 5)' // Si on a un fk_user dans notre requête 222 | ) 223 | ); 224 | 225 | if (!empty($extralabels)) 226 | { 227 | foreach ($extralabels as $k => $v) 228 | { 229 | if (in_array(abs($extrafields->attributes[$object->table_element]['list'][$k]),array(1,2,4)) && !empty(abs($extrafields->attributes[$object->table_element]['list'][$k]))) { 230 | $listViewConfig['eval'][$k] = '_evalEF("' . $k . '", "@val@")'; 231 | } 232 | } 233 | 234 | } 235 | 236 | $r = new Listview($db, 'dolifleet'); 237 | 238 | // Change view from hooks 239 | $parameters=array( 'listViewConfig' => $listViewConfig); 240 | $reshook=$hookmanager->executeHooks('listViewConfig',$parameters,$r); // Note that $action and $object may have been modified by hook 241 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 242 | if ($reshook>0) 243 | { 244 | $listViewConfig = $hookmanager->resArray; 245 | } 246 | 247 | 248 | echo $r->render($sql, $listViewConfig); 249 | 250 | $parameters=array('sql'=>$sql); 251 | $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook 252 | print $hookmanager->resPrint; 253 | 254 | $formcore->end_form(); 255 | 256 | llxFooter(''); 257 | $db->close(); 258 | 259 | /** 260 | * TODO remove if unused 261 | */ 262 | function _getObjectNomUrl($id) 263 | { 264 | global $db; 265 | 266 | $o = new doliFleetVehicule($db); 267 | $res = $o->fetch($id, false); 268 | if ($res > 0) 269 | { 270 | return $o->getNomUrl(1); 271 | } 272 | 273 | return ''; 274 | } 275 | 276 | /** 277 | * TODO remove if unused 278 | */ 279 | function _getSocieteNomUrl($fk_soc) 280 | { 281 | global $db; 282 | 283 | $soc = new Societe($db); 284 | if ($soc->fetch($fk_soc) > 0) 285 | { 286 | return $soc->getNomUrl(1); 287 | } 288 | 289 | return ''; 290 | } 291 | 292 | function _getValueFromId($id, $dictionaryClassname) 293 | { 294 | global $db; 295 | 296 | if (class_exists($dictionaryClassname)) 297 | { 298 | $dict = new $dictionaryClassname($db); 299 | return $dict->getValueFromId($id, 'label'); 300 | } 301 | else return ''; 302 | } 303 | 304 | function _evalEF($key, $val) 305 | { 306 | global $extrafields; 307 | 308 | return $extrafields->showOutputField($key, $val); 309 | } 310 | -------------------------------------------------------------------------------- /admin/dolifleet_setup.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * \file admin/dolifleet.php 20 | * \ingroup dolifleet 21 | * \brief This file is an example module setup page 22 | * Put some comments here 23 | */ 24 | // Dolibarr environment 25 | $res = @include '../../main.inc.php'; // From htdocs directory 26 | if (! $res) { 27 | $res = @include '../../../main.inc.php'; // From "custom" directory 28 | } 29 | 30 | // Libraries 31 | require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; 32 | require_once '../lib/dolifleet.lib.php'; 33 | dol_include_once('abricot/includes/lib/admin.lib.php'); 34 | 35 | // Translations 36 | $langs->loadLangs(array('dolifleet@dolifleet', 'admin', 'other')); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | // Parameters 44 | $action = GETPOST('action', 'alpha'); 45 | $value = GETPOST('value', 'alpha'); 46 | $label = GETPOST('label', 'alpha'); 47 | $scandir = GETPOST('scan_dir', 'alpha'); 48 | 49 | /* 50 | * Actions 51 | */ 52 | if (preg_match('/set_(.*)/', $action, $reg)) 53 | { 54 | $code=$reg[1]; 55 | if ($code == "DOLIFLEET_MOTRICE_TYPES") 56 | { 57 | if (dolibarr_set_const($db, $code, serialize(GETPOST($code)), 'chaine', 0, '', $conf->entity) > 0) 58 | { 59 | header("Location: ".$_SERVER["PHP_SELF"]); 60 | exit; 61 | } 62 | else 63 | { 64 | dol_print_error($db); 65 | } 66 | } 67 | elseif (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) 68 | { 69 | header("Location: ".$_SERVER["PHP_SELF"]); 70 | exit; 71 | } 72 | else 73 | { 74 | dol_print_error($db); 75 | } 76 | } 77 | 78 | if (preg_match('/del_(.*)/', $action, $reg)) 79 | { 80 | $code=$reg[1]; 81 | if (dolibarr_del_const($db, $code, 0) > 0) 82 | { 83 | Header("Location: ".$_SERVER["PHP_SELF"]); 84 | exit; 85 | } 86 | else 87 | { 88 | dol_print_error($db); 89 | } 90 | } 91 | 92 | if ($action == 'set') 93 | { 94 | $ret = addDocumentModel($value, 'rentalproposal', $label, $scandir); 95 | } 96 | 97 | if ($action == 'setdoc') 98 | { 99 | 100 | if (dolibarr_set_const($db, "DOLIFLEET_RENTALPROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) 101 | { 102 | // La constante qui a ete lue en avant du nouveau set 103 | // on passe donc par une variable pour avoir un affichage coherent 104 | $conf->global->DOLIFLEET_RENTALPROPOSAL_ADDON_PDF = $value; 105 | } 106 | 107 | // On active le modele 108 | $ret = delDocumentModel($value, 'rentalproposal'); 109 | if ($ret > 0) 110 | { 111 | $ret = addDocumentModel($value, 'rentalproposal', $label, $scandir); 112 | } 113 | } 114 | 115 | /* 116 | * View 117 | */ 118 | $page_name = "doliFleetSetup"; 119 | llxHeader('', $langs->trans($page_name)); 120 | 121 | // Subheader 122 | $linkback = '' 123 | . $langs->trans("BackToModuleList") . ''; 124 | print load_fiche_titre($langs->trans($page_name), $linkback); 125 | 126 | // Configuration header 127 | $head = dolifleetAdminPrepareHead(); 128 | dol_fiche_head( 129 | $head, 130 | 'settings', 131 | $langs->trans("Module104087Name"), 132 | -1, 133 | "dolifleet@dolifleet" 134 | ); 135 | 136 | // Setup page goes here 137 | $form=new Form($db); 138 | $var=false; 139 | print ''; 140 | 141 | 142 | if(!function_exists('setup_print_title')){ 143 | print '
'.$langs->trans('AbricotNeedUpdate').' : Wiki
'; 144 | exit; 145 | } 146 | 147 | setup_print_title("Parameters"); 148 | 149 | print ''; 150 | print ''; 151 | print ''; 152 | print ''; 160 | print ''; 161 | 162 | setup_print_input_form_part('DOLIFLEET_DEFAULT_RENTAL_AMOUNT', $langs->trans('DOLIFLEET_DEFAULT_RENTAL_AMOUNT')); 163 | 164 | if (empty($conf->global->DOLIFLEET_DELAY_SEARCH_OPERATIONS)) 165 | { 166 | dolibarr_set_const($db, 'DOLIFLEET_DELAY_SEARCH_OPERATIONS', 12, 'chaine', 0, '', $conf->entity); 167 | } 168 | setup_print_input_form_part('DOLIFLEET_DELAY_SEARCH_OPERATIONS'); 169 | 170 | // Example with a yes / no select 171 | //setup_print_on_off('CONSTNAME', $langs->trans('ParamLabel'), 'ParamDesc'); 172 | 173 | // Example with imput 174 | //setup_print_input_form_part('CONSTNAME', $langs->trans('ParamLabel')); 175 | 176 | // Example with color 177 | //setup_print_input_form_part('CONSTNAME', $langs->trans('ParamLabel'), 'ParamDesc', array('type'=>'color'), 'input', 'ParamHelp'); 178 | 179 | // Example with placeholder 180 | //setup_print_input_form_part('CONSTNAME',$langs->trans('ParamLabel'),'ParamDesc',array('placeholder'=>'http://'),'input','ParamHelp'); 181 | 182 | // Example with textarea 183 | //setup_print_input_form_part('CONSTNAME',$langs->trans('ParamLabel'),'ParamDesc',array(),'textarea'); 184 | 185 | 186 | print '
'.$langs->trans('DOLIFLEET_MOTRICE_TYPES').'
'; 153 | print ''; 154 | dol_include_once('/dolifleet/class/dictionaryVehiculeType.class.php'); 155 | $dict = new dictionaryVehiculeType($db); 156 | $TType = $dict->getAllActiveArray('label'); 157 | print $form->multiselectarray('DOLIFLEET_MOTRICE_TYPES', $TType, unserialize($conf->global->DOLIFLEET_MOTRICE_TYPES)); 158 | print ''; 159 | print '
'; 187 | 188 | /* 189 | * Document templates generators 190 | * Copy of invoice document code 191 | */ 192 | print '
'; 193 | print load_fiche_titre($langs->trans("RentalproposalPDFModules"), '', ''); 194 | 195 | // Load array def with activated templates 196 | $def = array(); 197 | $sql = "SELECT nom"; 198 | $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; 199 | $sql.= " WHERE type = 'rentalproposal'"; 200 | $sql.= " AND entity = ".$conf->entity; 201 | $resql=$db->query($sql); 202 | if ($resql) 203 | { 204 | $i = 0; 205 | $num_rows=$db->num_rows($resql); 206 | while ($i < $num_rows) 207 | { 208 | $array = $db->fetch_array($resql); 209 | array_push($def, $array[0]); 210 | $i++; 211 | } 212 | } 213 | else 214 | { 215 | dol_print_error($db); 216 | } 217 | 218 | print ''; 219 | print ''; 220 | print ''; 221 | print ''; 222 | print ''; 223 | print ''; 224 | print ''; 225 | print ''; 226 | print "\n"; 227 | 228 | clearstatcache(); 229 | $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); 230 | $activatedModels = array(); 231 | 232 | foreach ($dirmodels as $reldir) 233 | { 234 | foreach (array('','/doc') as $valdir) 235 | { 236 | $dir = dol_buildpath($reldir."core/modules/dolifleet".$valdir); 237 | 238 | if (is_dir($dir)) 239 | { 240 | $handle=opendir($dir); 241 | if (is_resource($handle)) 242 | { 243 | while (($file = readdir($handle))!==false) 244 | { 245 | $filelist[]=$file; 246 | } 247 | closedir($handle); 248 | arsort($filelist); 249 | 250 | foreach($filelist as $file) 251 | { 252 | if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) 253 | { 254 | if (file_exists($dir.'/'.$file)) 255 | { 256 | $name = substr($file, 4, dol_strlen($file) -16); 257 | $classname = substr($file, 0, dol_strlen($file) -12); 258 | 259 | require_once $dir.'/'.$file; 260 | $module = new $classname($db); 261 | 262 | $modulequalified=1; 263 | if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; 264 | if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; 265 | 266 | if ($modulequalified) 267 | { 268 | print ''; 274 | 275 | // Active 276 | if (in_array($name, $def)) 277 | { 278 | print ''; 283 | } 284 | else 285 | { 286 | print '"; 289 | } 290 | 291 | // Defaut 292 | print ''; 302 | 303 | // Info 304 | $htmltooltip = ''.$langs->trans("Name").': '.$module->name; 305 | $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); 306 | if ($module->type == 'pdf') 307 | { 308 | $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; 309 | } 310 | $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; 311 | $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); 312 | $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); 313 | $htmltooltip.='
'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1); 314 | 315 | 316 | print ''; 319 | 320 | // Preview 321 | print ''; 331 | 332 | print "\n"; 333 | } 334 | } 335 | } 336 | } 337 | } 338 | } 339 | } 340 | } 341 | print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; 269 | print (empty($module->name)?$name:$module->name); 270 | print "\n"; 271 | if (method_exists($module, 'info')) print $module->info($langs); 272 | else print $module->description; 273 | print ''."\n"; 279 | print ''; 280 | print img_picto($langs->trans("Enabled"), 'switch_on'); 281 | print ''; 282 | print ''."\n"; 287 | print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').''; 288 | print "'; 293 | if ($conf->global->DOLIFLEET_RENTALPROPOSAL_ADDON_PDF == $name) 294 | { 295 | print img_picto($langs->trans("Default"), 'on'); 296 | } 297 | else 298 | { 299 | print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').''; 300 | } 301 | print ''; 317 | print $form->textwithpicto('', $htmltooltip, 1, 0); 318 | print ''; 322 | if ($module->type == 'pdf') 323 | { 324 | print ''.img_object($langs->trans("Preview"), 'bill').''; 325 | } 326 | else 327 | { 328 | print img_object($langs->trans("PreviewNotAvailable"), 'generic'); 329 | } 330 | print '
'; 342 | 343 | dol_fiche_end(-1); 344 | 345 | llxFooter(); 346 | 347 | $db->close(); 348 | -------------------------------------------------------------------------------- /matrix_tab.php: -------------------------------------------------------------------------------- 1 | loadLangs(array("companies", "commercial", "bills", "banks", "users", "dolifleet@dolifleet")); 11 | 12 | $userCanRead = $user->rights->dolifleet->matrix->read; 13 | $userCanCreate = $user->rights->dolifleet->matrix->write; 14 | $userCanDelete = $user->rights->dolifleet->matrix->delete; 15 | 16 | $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); 17 | $cancel = GETPOST('cancel', 'alpha'); 18 | $backtopage = GETPOST('backtopage', 'alpha'); 19 | $confirm = GETPOST('confirm', 'alpha'); 20 | 21 | $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : 0; 22 | if ($user->socid) $socid = $user->socid; 23 | 24 | if (!GETPOST('cancel')) 25 | { 26 | $type = GETPOST('fk_c_type_vh'); 27 | $mark = GETPOST('fk_c_mark_vh'); 28 | $delay = GETPOST('delay'); 29 | $amount = GETPOST('amount_ht'); 30 | $id = GETPOST('id'); 31 | } 32 | 33 | $search_type = GETPOST('search_fk_c_type_vh'); 34 | $search_mark = GETPOST('search_fk_c_mark_vh'); 35 | 36 | if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) 37 | { 38 | $search_type = ''; 39 | $search_mark = ''; 40 | } 41 | 42 | $object = new Societe($db); 43 | $matrix = new doliFleetVehiculeRentalMatrix($db); 44 | 45 | $extrafields = new ExtraFields($db); 46 | 47 | $hookmanager->initHooks(array('thirdpartymatrixcard', 'globalcard')); 48 | 49 | if ($socid > 0) $object->fetch($socid); 50 | 51 | /* 52 | * Actions 53 | */ 54 | 55 | $parameters = array('id'=>$socid); 56 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 57 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 58 | 59 | if (empty($reshook)) 60 | { 61 | if ($action == 'addMatrixLine' || $action == 'editMatrixLine') 62 | { 63 | if (!GETPOST('cancel')) 64 | { 65 | $matrix->setValues($_REQUEST); 66 | $ret = $matrix->create($user); 67 | if ($ret < 0 || !empty($matrix->errors)) 68 | { 69 | setEventMessages('', $matrix->errors, "errors"); 70 | if ($action == 'editMatrixLine') $action = 'edit'; 71 | } 72 | else 73 | { 74 | setEventMessage('RecordSaved'); 75 | header('Location: '.$_SERVER['PHP_SELF']."?socid=".$socid); 76 | exit; 77 | } 78 | } 79 | } 80 | 81 | if ($action == 'confirm_delMatrixLine') 82 | { 83 | $matrix->id = $id; 84 | $ret = $matrix->delete($user); 85 | } 86 | 87 | if ($action == 'importGeneral') 88 | { 89 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$matrix->table_element; 90 | $sql.= " WHERE fk_soc = 0"; 91 | 92 | $res = $db->query($sql); 93 | if ($res) 94 | { 95 | while ($obj = $db->fetch_object($res)) 96 | { 97 | $mat = new doliFleetVehiculeRentalMatrix($db); 98 | $mat->fetch($obj->rowid); 99 | $mat->id = 0; 100 | $mat->fk_soc = $socid; 101 | $mat->create($user); 102 | } 103 | } 104 | } 105 | } 106 | 107 | /* 108 | * View 109 | */ 110 | 111 | $form = new Form($db); 112 | 113 | if ($socid > 0 && empty($object->id)) 114 | { 115 | $result = $object->fetch($socid); 116 | if ($result <= 0) dol_print_error('', $object->error); 117 | } 118 | 119 | $dictType = new dictionaryVehiculeType($db); 120 | $TType = $dictType->getAllActiveArray('label'); 121 | 122 | $dictMark = new dictionaryVehiculeMark($db); 123 | $TMark = $dictMark->getAllActiveArray('label'); 124 | 125 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$matrix->table_element; 126 | $sql.= " WHERE fk_soc = ".$object->id; 127 | if (!empty($search_type) && $search_type != -1) $sql.= " AND fk_c_type_vh = ".$search_type; 128 | if (!empty($search_mark) && $search_mark != -1) $sql.= " AND fk_c_mark_vh = ".$search_mark; 129 | $sql.= " ORDER BY fk_c_type_vh ASC, fk_c_mark_vh ASC, delay ASC"; 130 | 131 | $resql = $db->query($sql); 132 | if (!$resql) dol_print_error($db); 133 | else $num = $db->num_rows($resql); 134 | 135 | $title = $langs->trans("ThirdParty"); 136 | if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card'); 137 | $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; 138 | llxHeader('', $title, $help_url); 139 | 140 | $head = societe_prepare_head($object); 141 | 142 | dol_fiche_head($head, 'matrix', $langs->trans("ThirdParty"), 0, 'company'); 143 | 144 | //$formconfirm = getFormConfirmdoliFleetVehicule($form, $matrix, $action); 145 | 146 | if ($action === 'delMatrixLine' && $userCanCreate) 147 | { 148 | $body = $langs->trans('ConfirmDeldoliFleetLineBody'); 149 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?socid=' . $object->id . '&id='.$id, $langs->trans('ConfirmDeletedoliFleetVehiculeTitle'), $body, 'confirm_delMatrixLine', '', 0, 1); 150 | } 151 | 152 | if (!empty($formconfirm)) print $formconfirm; 153 | 154 | $linkback = ''.$langs->trans("BackToList").''; 155 | 156 | dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); 157 | 158 | dol_fiche_end(); 159 | 160 | print '
'; 161 | 162 | print '
'; 163 | 164 | if (empty($num)) 165 | { 166 | $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$matrix->table_element; 167 | $sql.= " WHERE fk_soc = 0"; 168 | $resql = $db->query($sql); 169 | if ($resql) 170 | { 171 | print '
'; 172 | print ''; 173 | print ''; 174 | print '
'; 175 | print '

'.$langs->trans('NoMatrixDefined').'

'; 176 | 177 | $obj = $db->fetch_object($resql); 178 | if ($obj->nb > 0 && $userCanCreate) 179 | { 180 | print '

'.$langs->trans('CanImportMatrix'); 181 | print '

'; 182 | } 183 | 184 | print '
'; 185 | print '
'; 186 | } 187 | 188 | } 189 | 190 | if ($userCanCreate) 191 | { 192 | print '
'; 193 | print ''; 194 | print ''; 195 | print ''; 196 | print ''; 197 | 198 | print ''; 199 | 200 | // table header 201 | print ''; 202 | print ''; 205 | print ''; 208 | print ''; 211 | print ''; 214 | print ''; 215 | print ''; 216 | 217 | // new line 218 | print '' 219 | ; 220 | print ''; 223 | 224 | print ''; 227 | 228 | print ''; 231 | 232 | print ''; 235 | 236 | print ''; 239 | 240 | print ''; 241 | 242 | 243 | print '
'; 203 | print $langs->trans('vehiculeType'); 204 | print ''; 206 | print $langs->trans('vehiculeMark'); 207 | print ''; 209 | print $langs->trans('vehiculeDelayExploit'); 210 | print ''; 212 | print $langs->trans('VehiculeRental'); 213 | print '
'; 221 | print $form->selectarray('fk_c_type_vh', $TType, $type,1, 0, 0, '', 0, 0, 0, '', '', 1); 222 | print ''; 225 | print $form->selectarray('fk_c_mark_vh', $TMark, $mark,1, 0, 0, '', 0, 0, 0, '', '', 1); 226 | print ''; 229 | print ' '.$langs->trans('Months'); 230 | print ''; 233 | print ''; 234 | print ''; 237 | print ''; 238 | print '
'; 244 | 245 | print '
'; 246 | 247 | print '
'; 248 | } 249 | 250 | print '
'; 251 | print ''; 252 | print ''; 253 | print ''; 254 | 255 | print ''; 256 | 257 | // table filters 258 | print ''; 259 | print ''; 262 | print ''; 265 | print ''; 267 | print ''; 269 | print ''; 273 | print ''; 274 | 275 | // table header 276 | print ''; 277 | print ''; 280 | print ''; 283 | print ''; 286 | print ''; 289 | print ''; 290 | print ''; 291 | 292 | if (empty($num)) 293 | { 294 | print ''; 295 | print ''; 298 | print ''; 299 | } 300 | else 301 | { 302 | while ($obj = $db->fetch_object($resql)) 303 | { 304 | $matrixline = new doliFleetVehiculeRentalMatrix($db); 305 | $matrixline->fetch($obj->rowid); 306 | 307 | if ($action == "edit" && $id == $matrixline->id && $userCanCreate) 308 | { 309 | print ''; 310 | print ''; 315 | print ''; 318 | print ''; 321 | print ''; 324 | // actions 325 | print ''; 329 | print ''; 330 | } 331 | else 332 | { 333 | print ''; 334 | print ''; 337 | print ''; 340 | print ''; 343 | print ''; 346 | // actions 347 | print ''; 351 | print ''; 352 | } 353 | 354 | 355 | } 356 | } 357 | 358 | 359 | print '
'; 260 | print $form->selectarray('search_fk_c_type_vh', $TType, $search_type,1, 0, 0, '', 0, 0, 0, '', '', 1); 261 | print ''; 263 | print $form->selectarray('search_fk_c_mark_vh', $TMark, $search_mark,1, 0, 0, '', 0, 0, 0, '', '', 1); 264 | print ''; 266 | print ''; 268 | print ''; 270 | $searchpicto = $form->showFilterAndCheckAddButtons(0); 271 | print $searchpicto; 272 | print '
'; 278 | print $langs->trans('vehiculeType'); 279 | print ''; 281 | print $langs->trans('vehiculeMark'); 282 | print ''; 284 | print $langs->trans('vehiculeDelayExploit'); 285 | print ''; 287 | print $langs->trans('VehiculeRental'); 288 | print '
'; 296 | print $langs->trans('NodoliFleet'); 297 | print '
'; 311 | print ''; 312 | print ''; 313 | print $form->selectarray('fk_c_type_vh', $TType, $matrixline->fk_c_type_vh,1, 0, 0, '', 0, 0, 0, '', '', 1); 314 | print ''; 316 | print $form->selectarray('fk_c_mark_vh', $TMark, $matrixline->fk_c_mark_vh,1, 0, 0, '', 0, 0, 0, '', '', 1); 317 | print ''; 319 | print ' '.$langs->trans('Months'); 320 | print ''; 322 | print ''; 323 | print ''; 326 | print ''; 327 | print ''; 328 | print '
'; 335 | print $dictType->getValueFromId($matrixline->fk_c_type_vh); 336 | print ''; 338 | print $dictMark->getValueFromId($matrixline->fk_c_mark_vh); 339 | print ''; 341 | print $matrixline->delay.' '.$langs->trans('Months'); 342 | print ''; 344 | print price($matrixline->amount_ht); 345 | print ''; 348 | if ($userCanCreate) print ''.img_edit().''; 349 | if ($userCanDelete) print ''.img_delete().''; 350 | print '
'; 360 | 361 | print '
'; 362 | 363 | print '
'; 364 | 365 | llxFooter(); 366 | $db->close(); 367 | -------------------------------------------------------------------------------- /class/dolifleet.class.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | if (!class_exists('SeedObject')) 19 | { 20 | /** 21 | * Needed if $form->showLinkedObjectBlock() is call or for session timeout on our module page 22 | */ 23 | define('INC_FROM_DOLIBARR', true); 24 | require_once dirname(__FILE__).'/../config.php'; 25 | } 26 | 27 | 28 | class doliFleet extends SeedObject 29 | { 30 | /** 31 | * Canceled status 32 | */ 33 | const STATUS_CANCELED = -1; 34 | /** 35 | * Draft status 36 | */ 37 | const STATUS_DRAFT = 0; 38 | /** 39 | * Validated status 40 | */ 41 | const STATUS_VALIDATED = 1; 42 | /** 43 | * Refused status 44 | */ 45 | const STATUS_REFUSED = 3; 46 | /** 47 | * Accepted status 48 | */ 49 | const STATUS_ACCEPTED = 4; 50 | 51 | /** @var array $TStatus Array of translate key for each const */ 52 | public static $TStatus = array( 53 | self::STATUS_CANCELED => 'doliFleetStatusShortCanceled' 54 | ,self::STATUS_DRAFT => 'doliFleetStatusShortDraft' 55 | ,self::STATUS_VALIDATED => 'doliFleetStatusShortValidated' 56 | // ,self::STATUS_REFUSED => 'doliFleetStatusShortRefused' 57 | // ,self::STATUS_ACCEPTED => 'doliFleetStatusShortAccepted' 58 | ); 59 | 60 | /** @var string $table_element Table name in SQL */ 61 | public $table_element = 'dolifleet'; 62 | 63 | /** @var string $element Name of the element (tip for better integration in Dolibarr: this value should be the reflection of the class name with ucfirst() function) */ 64 | public $element = 'dolifleet'; 65 | 66 | /** @var int $isextrafieldmanaged Enable the fictionalises of extrafields */ 67 | public $isextrafieldmanaged = 1; 68 | 69 | /** @var int $ismultientitymanaged 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ 70 | public $ismultientitymanaged = 1; 71 | 72 | /** 73 | * 'type' is the field format. 74 | * 'label' the translation key. 75 | * 'enabled' is a condition when the field must be managed. 76 | * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) 77 | * 'noteditable' says if field is not editable (1 or 0) 78 | * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). 79 | * 'default' is a default value for creation (can still be replaced by the global setup of default values) 80 | * 'index' if we want an index in database. 81 | * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). 82 | * 'position' is the sort order of field. 83 | * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. 84 | * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). 85 | * 'css' is the CSS style to use on field. For example: 'maxwidth200' 86 | * 'help' is a string visible as a tooltip on field 87 | * 'comment' is not used. You can store here any text of your choice. It is not used by application. 88 | * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record 89 | * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") 90 | */ 91 | 92 | public $fields = array( 93 | 94 | 'ref' => array( 95 | 'type' => 'varchar(50)', 96 | 'length' => 50, 97 | 'label' => 'Ref', 98 | 'enabled' => 1, 99 | 'visible' => 1, 100 | 'notnull' => 1, 101 | 'showoncombobox' => 1, 102 | 'index' => 1, 103 | 'position' => 10, 104 | 'searchall' => 1, 105 | 'comment' => 'Reference of object' 106 | ), 107 | 108 | 'entity' => array( 109 | 'type' => 'integer', 110 | 'label' => 'Entity', 111 | 'enabled' => 1, 112 | 'visible' => 0, 113 | 'default' => 1, 114 | 'notnull' => 1, 115 | 'index' => 1, 116 | 'position' => 20 117 | ), 118 | 119 | 'status' => array( 120 | 'type' => 'integer', 121 | 'label' => 'Status', 122 | 'enabled' => 1, 123 | 'visible' => 0, 124 | 'notnull' => 1, 125 | 'default' => 0, 126 | 'index' => 1, 127 | 'position' => 30, 128 | 'arrayofkeyval' => array( 129 | 0 => 'Draft', 130 | 1 => 'Active', 131 | -1 => 'Canceled' 132 | ) 133 | ), 134 | 135 | 'label' => array( 136 | 'type' => 'varchar(255)', 137 | 'label' => 'Label', 138 | 'enabled' => 1, 139 | 'visible' => 1, 140 | 'position' => 40, 141 | 'searchall' => 1, 142 | 'css' => 'minwidth200', 143 | 'help' => 'Help text', 144 | 'showoncombobox' => 1 145 | ), 146 | 147 | 'fk_soc' => array( 148 | 'type' => 'integer:Societe:societe/class/societe.class.php', 149 | 'label' => 'ThirdParty', 150 | 'visible' => 1, 151 | 'enabled' => 1, 152 | 'position' => 50, 153 | 'index' => 1, 154 | 'help' => 'LinkToThirparty' 155 | ), 156 | 157 | 'description' => array( 158 | 'type' => 'text', // or html for WYSWYG 159 | 'label' => 'Description', 160 | 'enabled' => 1, 161 | 'visible' => -1, // un bug sur la version 9.0 de Dolibarr necessite de mettre -1 pour ne pas apparaitre sur les listes au lieu de la valeur 3 162 | 'position' => 60 163 | ), 164 | 165 | // 'fk_user_valid' =>array( 166 | // 'type' => 'integer', 167 | // 'label' => 'UserValidation', 168 | // 'enabled' => 1, 169 | // 'visible' => -1, 170 | // 'position' => 512 171 | // ), 172 | 173 | 'import_key' => array( 174 | 'type' => 'varchar(14)', 175 | 'label' => 'ImportId', 176 | 'enabled' => 1, 177 | 'visible' => -2, 178 | 'notnull' => -1, 179 | 'index' => 0, 180 | 'position' => 1000 181 | ), 182 | 183 | ); 184 | 185 | /** @var string $ref Object reference */ 186 | public $ref; 187 | 188 | /** @var int $entity Object entity */ 189 | public $entity; 190 | 191 | /** @var int $status Object status */ 192 | public $status; 193 | 194 | /** @var string $label Object label */ 195 | public $label; 196 | 197 | /** @var string $description Object description */ 198 | public $description; 199 | 200 | 201 | 202 | /** 203 | * doliFleet constructor. 204 | * @param DoliDB $db Database connector 205 | */ 206 | public function __construct($db) 207 | { 208 | global $conf; 209 | 210 | parent::__construct($db); 211 | 212 | $this->init(); 213 | 214 | $this->status = self::STATUS_DRAFT; 215 | $this->entity = $conf->entity; 216 | } 217 | 218 | /** 219 | * @param User $user User object 220 | * @return int 221 | */ 222 | public function save($user) 223 | { 224 | if (!empty($this->is_clone)) 225 | { 226 | // TODO determinate if auto generate 227 | $this->ref = '(PROV'.$this->id.')'; 228 | } 229 | 230 | return $this->create($user); 231 | } 232 | 233 | 234 | /** 235 | * @see cloneObject 236 | * @return void 237 | */ 238 | public function clearUniqueFields() 239 | { 240 | $this->ref = 'Copy of '.$this->ref; 241 | } 242 | 243 | 244 | /** 245 | * @param User $user User object 246 | * @return int 247 | */ 248 | public function delete(User &$user) 249 | { 250 | $this->deleteObjectLinked(); 251 | 252 | unset($this->fk_element); // avoid conflict with standard Dolibarr comportment 253 | return parent::delete($user); 254 | } 255 | 256 | /** 257 | * @return string 258 | */ 259 | public function getRef() 260 | { 261 | if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) 262 | { 263 | return $this->getNextRef(); 264 | } 265 | 266 | return $this->ref; 267 | } 268 | 269 | /** 270 | * @return string 271 | */ 272 | private function getNextRef() 273 | { 274 | global $db,$conf; 275 | 276 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 277 | 278 | $mask = !empty($conf->global->DOLIFLEET_REF_MASK) ? $conf->global->DOLIFLEET_REF_MASK : 'MM{yy}{mm}-{0000}'; 279 | $ref = get_next_value($db, $mask, 'dolifleet', 'ref'); 280 | 281 | return $ref; 282 | } 283 | 284 | 285 | /** 286 | * @param User $user User object 287 | * @return int 288 | */ 289 | public function setDraft($user) 290 | { 291 | if ($this->status === self::STATUS_VALIDATED) 292 | { 293 | $this->status = self::STATUS_DRAFT; 294 | $this->withChild = false; 295 | 296 | return $this->update($user); 297 | } 298 | 299 | return 0; 300 | } 301 | 302 | /** 303 | * @param User $user User object 304 | * @return int 305 | */ 306 | public function setValid($user) 307 | { 308 | if ($this->status === self::STATUS_DRAFT) 309 | { 310 | // TODO determinate if auto generate 311 | // $this->ref = $this->getRef(); 312 | // $this->fk_user_valid = $user->id; 313 | $this->status = self::STATUS_VALIDATED; 314 | $this->withChild = false; 315 | 316 | return $this->update($user); 317 | } 318 | 319 | return 0; 320 | } 321 | 322 | /** 323 | * @param User $user User object 324 | * @return int 325 | */ 326 | public function setAccepted($user) 327 | { 328 | if ($this->status === self::STATUS_VALIDATED) 329 | { 330 | $this->status = self::STATUS_ACCEPTED; 331 | $this->withChild = false; 332 | 333 | return $this->update($user); 334 | } 335 | 336 | return 0; 337 | } 338 | 339 | /** 340 | * @param User $user User object 341 | * @return int 342 | */ 343 | public function setRefused($user) 344 | { 345 | if ($this->status === self::STATUS_VALIDATED) 346 | { 347 | $this->status = self::STATUS_REFUSED; 348 | $this->withChild = false; 349 | 350 | return $this->update($user); 351 | } 352 | 353 | return 0; 354 | } 355 | 356 | /** 357 | * @param User $user User object 358 | * @return int 359 | */ 360 | public function setReopen($user) 361 | { 362 | if ($this->status === self::STATUS_ACCEPTED || $this->status === self::STATUS_REFUSED) 363 | { 364 | $this->status = self::STATUS_VALIDATED; 365 | $this->withChild = false; 366 | 367 | return $this->update($user); 368 | } 369 | 370 | return 0; 371 | } 372 | 373 | 374 | /** 375 | * @param int $withpicto Add picto into link 376 | * @param string $moreparams Add more parameters in the URL 377 | * @return string 378 | */ 379 | public function getNomUrl($withpicto = 0, $moreparams = '') 380 | { 381 | global $langs; 382 | 383 | $result=''; 384 | $label = '' . $langs->trans("ShowdoliFleet") . ''; 385 | if (! empty($this->ref)) $label.= '
'.$langs->trans('Ref').': '.$this->ref; 386 | 387 | $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; 388 | $link = 'ref.$linkend; 399 | 400 | return $result; 401 | } 402 | 403 | /** 404 | * @param int $id Identifiant 405 | * @param null $ref Ref 406 | * @param int $withpicto Add picto into link 407 | * @param string $moreparams Add more parameters in the URL 408 | * @return string 409 | */ 410 | public static function getStaticNomUrl($id, $ref = null, $withpicto = 0, $moreparams = '') 411 | { 412 | global $db; 413 | 414 | $object = new doliFleet($db); 415 | $object->fetch($id, false, $ref); 416 | 417 | return $object->getNomUrl($withpicto, $moreparams); 418 | } 419 | 420 | 421 | /** 422 | * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto 423 | * @return string 424 | */ 425 | public function getLibStatut($mode = 0) 426 | { 427 | return self::LibStatut($this->status, $mode); 428 | } 429 | 430 | /** 431 | * @param int $status Status 432 | * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto 433 | * @return string 434 | */ 435 | public static function LibStatut($status, $mode) 436 | { 437 | global $langs; 438 | 439 | $langs->load('dolifleet@dolifleet'); 440 | $res = ''; 441 | 442 | if ($status==self::STATUS_CANCELED) { $statusType='status9'; $statusLabel=$langs->trans('doliFleetStatusCancel'); $statusLabelShort=$langs->trans('doliFleetStatusShortCancel'); } 443 | elseif ($status==self::STATUS_DRAFT) { $statusType='status0'; $statusLabel=$langs->trans('doliFleetStatusDraft'); $statusLabelShort=$langs->trans('doliFleetStatusShortDraft'); } 444 | elseif ($status==self::STATUS_VALIDATED) { $statusType='status1'; $statusLabel=$langs->trans('doliFleetStatusValidated'); $statusLabelShort=$langs->trans('doliFleetStatusShortValidate'); } 445 | elseif ($status==self::STATUS_REFUSED) { $statusType='status5'; $statusLabel=$langs->trans('doliFleetStatusRefused'); $statusLabelShort=$langs->trans('doliFleetStatusShortRefused'); } 446 | elseif ($status==self::STATUS_ACCEPTED) { $statusType='status6'; $statusLabel=$langs->trans('doliFleetStatusAccepted'); $statusLabelShort=$langs->trans('doliFleetStatusShortAccepted'); } 447 | 448 | if (function_exists('dolGetStatus')) 449 | { 450 | $res = dolGetStatus($statusLabel, $statusLabelShort, '', $statusType, $mode); 451 | } 452 | else 453 | { 454 | if ($mode == 0) $res = $statusLabel; 455 | elseif ($mode == 1) $res = $statusLabelShort; 456 | elseif ($mode == 2) $res = img_picto($statusLabel, $statusType).$statusLabelShort; 457 | elseif ($mode == 3) $res = img_picto($statusLabel, $statusType); 458 | elseif ($mode == 4) $res = img_picto($statusLabel, $statusType).$statusLabel; 459 | elseif ($mode == 5) $res = $statusLabelShort.img_picto($statusLabel, $statusType); 460 | elseif ($mode == 6) $res = $statusLabel.img_picto($statusLabel, $statusType); 461 | } 462 | 463 | return $res; 464 | } 465 | 466 | /** 467 | * Return HTML string to show a field into a page 468 | * 469 | * @param string $key Key of attribute 470 | * @param string $moreparam To add more parameters on html input tag 471 | * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) 472 | * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) 473 | * @param mixed $morecss Value for css to define size. May also be a numeric. 474 | * @return string 475 | */ 476 | public function showOutputFieldQuick($key, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = ''){ 477 | return $this->showOutputField($this->fields[$key], $key, $this->{$key}, $moreparam, $keysuffix, $keyprefix, $morecss); 478 | } 479 | } 480 | 481 | 482 | //class doliFleetDet extends SeedObject 483 | //{ 484 | // public $table_element = 'dolifleetdet'; 485 | // 486 | // public $element = 'dolifleetdet'; 487 | // 488 | // 489 | // /** 490 | // * doliFleetDet constructor. 491 | // * @param DoliDB $db Database connector 492 | // */ 493 | // public function __construct($db) 494 | // { 495 | // $this->db = $db; 496 | // 497 | // $this->init(); 498 | // } 499 | //} 500 | -------------------------------------------------------------------------------- /vehicule_card.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | require 'config.php'; 19 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; 20 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; 21 | dol_include_once('dolifleet/class/vehicule.class.php'); 22 | dol_include_once('dolifleet/class/vehiculeLink.class.php'); 23 | dol_include_once('/dolifleet/class/dictionaryVehiculeActivityType.class.php'); 24 | dol_include_once('dolifleet/lib/dolifleet.lib.php'); 25 | 26 | if(empty($user->rights->dolifleet->read)) accessforbidden(); 27 | 28 | $langs->load('dolifleet@dolifleet'); 29 | 30 | $action = GETPOST('action'); 31 | $id = GETPOST('id', 'int'); 32 | $ref = GETPOST('ref'); 33 | $vin = GETPOST('vin'); 34 | 35 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vehiculecard'; // To manage different context of search 36 | $backtopage = GETPOST('backtopage', 'alpha'); 37 | 38 | $object = new doliFleetVehicule($db); 39 | 40 | if (!empty($id) || !empty($ref)) $object->fetch($id, true, $ref); 41 | if (!empty($vin)) $object->fetchBy($vin,'vin', false); 42 | 43 | $hookmanager->initHooks(array($contextpage, 'globalcard')); 44 | 45 | 46 | if ($object->isextrafieldmanaged) 47 | { 48 | $extrafields = new ExtraFields($db); 49 | 50 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); 51 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); 52 | } 53 | 54 | // Initialize array of search criterias 55 | //$search_all=trim(GETPOST("search_all",'alpha')); 56 | //$search=array(); 57 | //foreach($object->fields as $key => $val) 58 | //{ 59 | // if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); 60 | //} 61 | 62 | /* 63 | * Actions 64 | */ 65 | 66 | $parameters = array('id' => $id, 'ref' => $ref); 67 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some 68 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 69 | 70 | // Si vide alors le comportement n'est pas remplacé 71 | if (empty($reshook)) 72 | { 73 | 74 | if ($cancel) 75 | { 76 | if (! empty($backtopage)) 77 | { 78 | header("Location: ".$backtopage); 79 | exit; 80 | } 81 | $action=''; 82 | } 83 | 84 | // For object linked 85 | include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once 86 | 87 | $error = 0; 88 | switch ($action) { 89 | case 'add': 90 | case 'update': 91 | $object->setValues($_REQUEST); // Set standard attributes 92 | 93 | if ($object->isextrafieldmanaged) 94 | { 95 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); 96 | if ($ret < 0) $error++; 97 | } 98 | 99 | if ($error > 0) 100 | { 101 | $action = 'edit'; 102 | break; 103 | } 104 | 105 | $res = $object->save($user); 106 | 107 | if ($res < 0) 108 | { 109 | setEventMessage($object->errors, 'errors'); 110 | if (empty($object->id)) $action = 'create'; 111 | else $action = 'edit'; 112 | break; 113 | } 114 | else 115 | { 116 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 117 | exit; 118 | } 119 | case 'update_extras': 120 | 121 | $object->oldcopy = dol_clone($object); 122 | 123 | // Fill array 'array_options' with data from update form 124 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); 125 | if ($ret < 0) $error++; 126 | 127 | if (! $error) 128 | { 129 | $result = $object->insertExtraFields('DOLIFLEET_MODIFY'); 130 | if ($result < 0) 131 | { 132 | setEventMessages($object->error, $object->errors, 'errors'); 133 | $error++; 134 | } 135 | } 136 | 137 | if ($error) $action = 'edit_extras'; 138 | else 139 | { 140 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 141 | exit; 142 | } 143 | break; 144 | case 'confirm_clone': 145 | $object->cloneObject($user); 146 | 147 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 148 | exit; 149 | 150 | case 'confirm_modif': 151 | case 'confirm_reopen': 152 | if (!empty($user->rights->dolifleet->write)) $object->setDraft($user); 153 | 154 | break; 155 | case 'confirm_validate': 156 | if (!empty($user->rights->dolifleet->write)) $object->setValid($user); 157 | 158 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 159 | exit; 160 | 161 | case 'confirm_delete': 162 | if (!empty($user->rights->dolifleet->delete)) $object->delete($user); 163 | 164 | header('Location: '.dol_buildpath('/dolifleet/vehicule_list.php', 1)); 165 | exit; 166 | 167 | // link from llx_element_element 168 | case 'dellink': 169 | $object->deleteObjectLinked(null, '', null, '', GETPOST('dellinkid')); 170 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 171 | exit; 172 | 173 | case 'addActivity': 174 | $type = GETPOST('activityTypes', 'int'); 175 | $date_start = dol_mktime(0, 0, 0, GETPOST('activityDate_startmonth'), GETPOST('activityDate_startday'), GETPOST('activityDate_startyear')); 176 | $date_end = dol_mktime(23, 59, 59, GETPOST('activityDate_endmonth'), GETPOST('activityDate_endday'), GETPOST('activityDate_endyear')); 177 | 178 | if ($date_end < $date_start) $date_end = dol_mktime(23, 59, 59, GETPOST('activityDate_startmonth'), GETPOST('activityDate_startday'), GETPOST('activityDate_startyear')); 179 | 180 | $ret = $object->addActivity($type, $date_start, $date_end); 181 | if ($ret < 0) 182 | { 183 | setEventMessage($langs->trans($object->error), 'errors'); 184 | break; 185 | } 186 | else 187 | { 188 | setEventMessage($langs->trans('ActivityAdded')); 189 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 190 | exit; 191 | } 192 | 193 | case 'confirm_delActivity': 194 | $activityId = GETPOST('act_id', 'int'); 195 | 196 | $ret = $object->delActivity($user, $activityId); 197 | if ($ret < 0) 198 | { 199 | setEventMessage($object->error, "errors"); 200 | } 201 | 202 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 203 | exit; 204 | 205 | case 'addVehiculeLink': 206 | $veh_id = GETPOST('linkVehicule_id'); 207 | if (empty($veh_id) || $veh_id == '-1') 208 | { 209 | setEventMessage($langs->trans('ErrNoVehiculeToLink'), "errors"); 210 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 211 | exit; 212 | } 213 | 214 | $date_start = dol_mktime(0, 0, 0, GETPOST('linkDate_startmonth'), GETPOST('linkDate_startday'), GETPOST('linkDate_startyear')); 215 | $date_end = dol_mktime(23, 59, 59, GETPOST('linkDate_endmonth'), GETPOST('linkDate_endday'), GETPOST('linkDate_endyear')); 216 | 217 | if ($date_end < $date_start) $date_end = dol_mktime(23, 59, 59, GETPOST('linkDate_startmonth'), GETPOST('linkDate_startday'), GETPOST('linkDate_startyear')); 218 | 219 | $ret = $object->addLink($veh_id, $date_start, $date_end); 220 | 221 | if ($ret < 0) { 222 | setEventMessages('', $object->errors, "errors"); 223 | break; 224 | } 225 | else 226 | { 227 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 228 | exit; 229 | } 230 | 231 | case 'confirm_unlinkVehicule': 232 | $veh_id = GETPOST('linkVehicule_id'); 233 | 234 | $ret = $object->delLink($veh_id); 235 | if ($ret < 0) { 236 | setEventMessage($langs->trans('ErrVehiculeUnlink'), "errors"); 237 | break; 238 | } 239 | else { 240 | setEventMessage($langs->trans('VehiculeUnlinked')); 241 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 242 | exit; 243 | } 244 | 245 | case 'addVehiculeRental': 246 | $date_start = dol_mktime(0, 0, 0, GETPOST('RentalDate_startmonth'), GETPOST('RentalDate_startday'), GETPOST('RentalDate_startyear')); 247 | $date_end = dol_mktime(23, 59, 59, GETPOST('RentalDate_endmonth'), GETPOST('RentalDate_endday'), GETPOST('RentalDate_endyear')); 248 | 249 | if ($date_end < $date_start) $date_end = dol_mktime(23, 59, 59, GETPOST('RentalDate_startmonth'), GETPOST('RentalDate_startday'), GETPOST('RentalDate_startyear')); 250 | 251 | $amountHT = GETPOST('RentalTotal_HT', 'int'); 252 | 253 | $ret = $object->addRental($date_start, $date_end, $amountHT); 254 | if ($ret < 0) { 255 | setEventMessages('', $object->errors, "errors"); 256 | break; 257 | } 258 | else 259 | { 260 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 261 | exit; 262 | } 263 | 264 | case 'confirm_delRental': 265 | $rent_id = GETPOST('rent_id', 'int'); 266 | 267 | $ret = $object->delRental($rent_id); 268 | if ($ret < 0) 269 | { 270 | setEventMessages('', $object->errors, "errors"); 271 | break; 272 | } 273 | else 274 | { 275 | setEventMessage($langs->trans('rentDeleted')); 276 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 277 | exit; 278 | } 279 | 280 | case 'addVehiculeOperation': 281 | $productid = GETPOST('productid', 'int'); 282 | $km = GETPOST('km', 'int'); 283 | $delay = GETPOST('delay', 'int'); 284 | 285 | $ret = $object->addOperation($productid, $km, $delay); 286 | if ($ret < 0) { 287 | setEventMessages('', $object->errors, "errors"); 288 | break; 289 | } 290 | else 291 | { 292 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 293 | exit; 294 | } 295 | 296 | case 'confirm_delOperation': 297 | $ope_id = GETPOST('ope_id', 'int'); 298 | 299 | $ret = $object->delOperation($ope_id); 300 | if ($ret < 0) 301 | { 302 | setEventMessages('', $object->errors, "errors"); 303 | break; 304 | } 305 | else 306 | { 307 | setEventMessage($langs->trans('operationDeleted')); 308 | header('Location: '.dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id); 309 | exit; 310 | } 311 | } 312 | } 313 | 314 | 315 | /** 316 | * View 317 | */ 318 | $form = new Form($db); 319 | 320 | $title=$langs->trans('doliFleet'); 321 | llxHeader('', $title); 322 | 323 | if ($action == 'create') 324 | { 325 | print load_fiche_titre($langs->trans('NewdoliFleet'), '', 'dolifleet@dolifleet'); 326 | 327 | print '
'; 328 | print ''; 329 | print ''; 330 | print ''; 331 | 332 | dol_fiche_head(array(), ''); 333 | 334 | print ''."\n"; 335 | 336 | // Common attributes 337 | include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; 338 | 339 | // Other attributes 340 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; 341 | 342 | print '
'."\n"; 343 | 344 | dol_fiche_end(); 345 | 346 | print '
'; 347 | print ''; 348 | print '  '; 349 | print ''; // Cancel for create does not post form if we don't know the backtopage 350 | print '
'; 351 | 352 | print '
'; 353 | } 354 | else 355 | { 356 | if (empty($object->id)) 357 | { 358 | $langs->load('errors'); 359 | print $langs->trans('ErrorRecordNotFound'); 360 | } 361 | else 362 | { 363 | if (!empty($object->id) && $action === 'edit') 364 | { 365 | print '
'; 366 | print ''; 367 | print ''; 368 | print ''; 369 | print ''; 370 | 371 | $head = vehicule_prepare_head($object); 372 | $picto = 'dolifleet@dolifleet'; 373 | dol_fiche_head($head, 'card', $langs->trans('doliFleet'), 0, $picto); 374 | 375 | print ''."\n"; 376 | 377 | // Common attributes 378 | include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; 379 | 380 | // Other attributes 381 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; 382 | 383 | print '
'; 384 | 385 | dol_fiche_end(); 386 | 387 | print '
'; 388 | print '   '; 389 | print '
'; 390 | 391 | print '
'; 392 | } 393 | elseif ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) 394 | { 395 | $head = vehicule_prepare_head($object); 396 | $picto = 'dolifleet@dolifleet'; 397 | dol_fiche_head($head, 'card', $langs->trans('doliFleet'), -1, $picto); 398 | 399 | $formconfirm = getFormConfirmdoliFleetVehicule($form, $object, $action); 400 | if (!empty($formconfirm)) print $formconfirm; 401 | 402 | printBannerVehicleCard($object); 403 | 404 | print '
'; 405 | 406 | print '
'; // Auto close by commonfields_view.tpl.php 407 | print '
'; 408 | print ''."\n"; 409 | 410 | // Common attributes 411 | //$keyforbreak='fieldkeytoswithonsecondcolumn'; 412 | include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; 413 | 414 | // Other attributes 415 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; 416 | print '
'; 417 | 418 | print '
'; // Fin fichehalfright & ficheaddleft 419 | print '
'; // Fin fichecenter 420 | 421 | print '

'; 422 | 423 | print '
'; 424 | 425 | print '
'; 426 | print '
'; 427 | 428 | // Activités véhicule 429 | printVehiculeActivities($object/*, true*/); 430 | 431 | print '
'; // fin fichehalfleft 432 | 433 | print '
'; 434 | print '
'; 435 | 436 | // véhicules liés 437 | printLinkedVehicules($object/*, true*/); 438 | 439 | print '
'; // fin fichehalfright 440 | print '
'; // fin fichecenter 441 | print '

'; 442 | 443 | print '
'; 444 | 445 | print '
'; 446 | print '
'; 447 | 448 | // Opérations 449 | printVehiculeOpérations($object); 450 | 451 | print '
'; // fin fichehalfleft 452 | 453 | print '
'; 454 | print '
'; 455 | 456 | // Loyers 457 | printVehiculeRental($object/*, true*/); 458 | 459 | print '
'; // fin fichehalfright 460 | print '
'; // fin fichecenter 461 | print '

'; 462 | 463 | print '
'; 464 | 465 | print '
'; 466 | print '
'; 467 | 468 | printVehiculeRental($object, false, true); 469 | 470 | print '
'; // fin fichehalfleft 471 | 472 | print '
'; 473 | print '
'; 474 | 475 | print '
'; // fin fichehalfright 476 | print '
'; // fin fichecenter 477 | print '

'; 478 | 479 | print '
'."\n"; 480 | $parameters=array(); 481 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook 482 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 483 | 484 | if (empty($reshook)) 485 | { 486 | 487 | // Modify 488 | if (!empty($user->rights->dolifleet->write)) 489 | { 490 | 491 | // Modify 492 | print ''."\n"; 493 | 494 | // Clone 495 | // print ''."\n"; 496 | 497 | // Activer 498 | if ($object->status === doliFleetVehicule::STATUS_DRAFT) print ''."\n"; 499 | 500 | // Désactiver 501 | if ($object->status === doliFleetVehicule::STATUS_ACTIVE) print ''."\n"; 502 | 503 | } 504 | else 505 | { 506 | 507 | // Modify 508 | if ($object->status !== doliFleetVehicule::STATUS_ACTIVE) print ''."\n"; 509 | 510 | // Clone 511 | // print ''."\n"; 512 | 513 | // Activer 514 | if ($object->status === doliFleetVehicule::STATUS_DRAFT) print ''."\n"; 515 | 516 | // Désactiver 517 | if ($object->status === doliFleetVehicule::STATUS_ACTIVE) print ''."\n"; 518 | 519 | } 520 | 521 | if (!empty($user->rights->dolifleet->delete)) 522 | { 523 | print ''."\n"; 524 | } 525 | else 526 | { 527 | print ''."\n"; 528 | } 529 | } 530 | print '
'."\n"; 531 | 532 | 533 | 534 | print ''; 535 | 536 | dol_fiche_end(-1); 537 | } 538 | } 539 | } 540 | 541 | 542 | llxFooter(); 543 | $db->close(); 544 | -------------------------------------------------------------------------------- /rental_proposal_card.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | require 'config.php'; 19 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; 20 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; 21 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 22 | dol_include_once('dolifleet/class/rentalProposal.class.php'); 23 | dol_include_once('dolifleet/class/vehicule.class.php'); 24 | dol_include_once('dolifleet/class/dictionaryVehiculeActivityType.class.php'); 25 | dol_include_once('dolifleet/class/dictionaryVehiculeType.class.php'); 26 | dol_include_once('dolifleet/lib/dolifleet.lib.php'); 27 | 28 | if(empty($user->rights->dolifleet->rentalproposal->read)) accessforbidden(); 29 | 30 | $langs->load('dolifleet@dolifleet'); 31 | 32 | $action = GETPOST('action'); 33 | $id = GETPOST('id', 'int'); 34 | $ref = GETPOST('ref'); 35 | $lineid = GETPOST('lineid', 'int'); 36 | 37 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'dolifleetrentalproposalcard'; // To manage different context of search 38 | $backtopage = GETPOST('backtopage', 'alpha'); 39 | 40 | $object = new dolifleetRentalProposal($db); 41 | 42 | if (!empty($id) || !empty($ref)) $object->fetch($id, true, $ref); 43 | 44 | $hookmanager->initHooks(array('dolifleetrentalproposalcard', 'globalcard')); 45 | 46 | 47 | if ($object->isextrafieldmanaged) 48 | { 49 | $extrafields = new ExtraFields($db); 50 | 51 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); 52 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); 53 | } 54 | 55 | $permissiontoadd = $user->rights->dolifleet->rentalproposal->write; 56 | $upload_dir = $conf->dolifleet->multidir_output[$conf->entity]; 57 | 58 | // Initialize array of search criterias 59 | //$search_all=trim(GETPOST("search_all",'alpha')); 60 | //$search=array(); 61 | //foreach($object->fields as $key => $val) 62 | //{ 63 | // if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); 64 | //} 65 | 66 | /* 67 | * Actions 68 | */ 69 | 70 | $parameters = array('id' => $id, 'ref' => $ref); 71 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some 72 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 73 | 74 | // Si vide alors le comportement n'est pas remplacé 75 | if (empty($reshook)) 76 | { 77 | 78 | if ($cancel) 79 | { 80 | if (! empty($backtopage)) 81 | { 82 | header("Location: ".$backtopage); 83 | exit; 84 | } 85 | $action=''; 86 | } 87 | 88 | // For object linked 89 | include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once 90 | 91 | // Action to build doc 92 | // $action must be defined 93 | // $id must be defined 94 | // $object must be defined and must have a method generateDocument(). 95 | // $permissiontoadd must be defined 96 | // $upload_dir must be defined (example $conf->projet->dir_output . "/";) 97 | // $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not. 98 | include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; 99 | 100 | $error = 0; 101 | switch ($action) { 102 | case 'add': 103 | case 'update': 104 | $object->setValues($_REQUEST); // Set standard attributes 105 | 106 | if ($object->isextrafieldmanaged) 107 | { 108 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); 109 | if ($ret < 0) $error++; 110 | } 111 | 112 | if ($error > 0) 113 | { 114 | $action = 'edit'; 115 | break; 116 | } 117 | 118 | $res = $object->save($user); 119 | if ($res <= 0) 120 | { 121 | setEventMessages('', $object->errors, 'errors'); 122 | if (empty($object->id)) $action = 'create'; 123 | else $action = 'edit'; 124 | } 125 | else 126 | { 127 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 128 | exit; 129 | } 130 | case 'update_extras': 131 | 132 | $object->oldcopy = dol_clone($object); 133 | 134 | // Fill array 'array_options' with data from update form 135 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); 136 | if ($ret < 0) $error++; 137 | 138 | if (! $error) 139 | { 140 | $result = $object->insertExtraFields('DOLIFLEETRENTALPROPOSAL_MODIFY'); 141 | if ($result < 0) 142 | { 143 | setEventMessages($object->error, $object->errors, 'errors'); 144 | $error++; 145 | } 146 | } 147 | 148 | if ($error) $action = 'edit_extras'; 149 | else 150 | { 151 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 152 | exit; 153 | } 154 | break; 155 | case 'confirm_clone': 156 | $object->cloneObject($user); 157 | 158 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 159 | exit; 160 | 161 | case 'modif': 162 | case 'reopen': 163 | if (!empty($user->rights->dolifleet->rentalproposal->write)) $object->setDraft($user); 164 | 165 | break; 166 | 167 | case 'confirm_validate': 168 | if (!empty($user->rights->dolifleet->rentalproposal->validate)) $object->setValid($user); 169 | 170 | if (!empty($object->errors)) setEventMessages('', $object->errors, "errors"); 171 | 172 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 173 | exit; 174 | 175 | case 'confirm_accept': 176 | if (!empty($user->rights->dolifleet->rentalproposal->validate)) $object->setAccepted($user); 177 | 178 | if (!empty($object->errors)) setEventMessages('', $object->errors, "errors"); 179 | 180 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 181 | exit; 182 | 183 | case 'confirm_close': 184 | if (!empty($user->rights->dolifleet->rentalproposal->validate)) $object->setClosed($user); 185 | 186 | if (!empty($object->errors)) setEventMessages('', $object->errors, "errors"); 187 | 188 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 189 | exit; 190 | 191 | case 'confirm_delete': 192 | if (!empty($user->rights->dolifleet->rentalproposal->delete)) $object->delete($user); 193 | 194 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_list.php', 1)); 195 | exit; 196 | 197 | // link from llx_element_element 198 | case 'dellink': 199 | $object->deleteObjectLinked(null, '', null, '', GETPOST('dellinkid')); 200 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 201 | exit; 202 | 203 | case 'updateLine': 204 | if (!GETPOST('cancel')) 205 | { 206 | $line = new dolifleetRentalProposalDet($db); 207 | $line->fetch($lineid); 208 | 209 | $line->setValues($_REQUEST); 210 | $line->id = $lineid; 211 | 212 | $ret = $line->create($user); 213 | if ($ret < 0) 214 | { 215 | setEventMessages('', array_merge($line->errors, array($line->error)), 'errors'); 216 | $action = 'editline'; 217 | } 218 | else 219 | { 220 | header('Location: '.dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id); 221 | exit; 222 | } 223 | } 224 | break; 225 | 226 | } 227 | } 228 | 229 | 230 | /** 231 | * View 232 | */ 233 | $form = new Form($db); 234 | $formfile = new FormFile($db); 235 | $dictTypeAct = new dictionaryVehiculeActivityType($db); 236 | $dictTypeVeh = new dictionaryVehiculeType($db); 237 | 238 | $title=$langs->trans('dolifleetRentalProposal'); 239 | llxHeader('', $title); 240 | 241 | if ($action == 'create') 242 | { 243 | print load_fiche_titre($langs->trans('NewdolifleetRentalProposal'), '', 'dolifleet@dolifleet'); 244 | 245 | print '
'; 246 | print ''; 247 | print ''; 248 | print ''; 249 | 250 | dol_fiche_head(array(), ''); 251 | 252 | print ''."\n"; 253 | 254 | // Common attributes 255 | include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; 256 | 257 | // Other attributes 258 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; 259 | 260 | print '
'."\n"; 261 | 262 | dol_fiche_end(); 263 | 264 | print '
'; 265 | print ''; 266 | print '  '; 267 | print ''; // Cancel for create does not post form if we don't know the backtopage 268 | print '
'; 269 | 270 | print '
'; 271 | } 272 | else 273 | { 274 | if (empty($object->id)) 275 | { 276 | $langs->load('errors'); 277 | print $langs->trans('ErrorRecordNotFound'); 278 | } 279 | else 280 | { 281 | if (!empty($object->id) && $action === 'edit') 282 | { 283 | print '
'; 284 | print ''; 285 | print ''; 286 | print ''; 287 | print ''; 288 | 289 | $head = rental_proposal_prepare_head($object); 290 | $picto = 'dolifleet@dolifleet'; 291 | dol_fiche_head($head, 'card', $langs->trans('dolifleetRentalProposal'), 0, $picto); 292 | 293 | print ''."\n"; 294 | 295 | // Common attributes 296 | include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; 297 | 298 | // Other attributes 299 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; 300 | 301 | print '
'; 302 | 303 | dol_fiche_end(); 304 | 305 | print '
'; 306 | print '   '; 307 | print '
'; 308 | 309 | print '
'; 310 | } 311 | elseif ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) 312 | { 313 | $head = rental_proposal_prepare_head($object); 314 | $picto = 'dolifleet@dolifleet'; 315 | dol_fiche_head($head, 'card', $langs->trans('dolifleetRentalProposal'), -1, $picto); 316 | 317 | $formconfirm = getFormConfirmdoliFleetVehicule($form, $object, $action); 318 | if (!empty($formconfirm)) print $formconfirm; 319 | 320 | 321 | $linkback = '' . $langs->trans('BackToList') . ''; 322 | 323 | $morehtmlref='
'; 324 | /* 325 | // Ref bis 326 | $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->dolifleet->rentalproposal->write, 'string', '', 0, 1); 327 | $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->dolifleet->rentalproposal->write, 'string', '', null, null, '', 1); 328 | // Thirdparty 329 | $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); 330 | */ 331 | $morehtmlref.='
'; 332 | 333 | 334 | $morehtmlstatus.=''; //$object->getLibStatut(2); // pas besoin fait doublon 335 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); 336 | 337 | print '
'; 338 | 339 | print '
'; // Auto close by commonfields_view.tpl.php 340 | print '
'; 341 | print ''."\n"; 342 | 343 | // Common attributes 344 | //$keyforbreak='fieldkeytoswithonsecondcolumn'; 345 | include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; 346 | 347 | // Other attributes 348 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; 349 | 350 | print '
'; 351 | 352 | print ''; 353 | 354 | $object->fetchLines(); 355 | // Amount HT 356 | print ''; 357 | 358 | $total_ht = 0; 359 | $subtotals = array(); 360 | 361 | if (!empty($object->lines)) 362 | { 363 | foreach ($object->lines as $l) { 364 | $total_ht+= $l->total_ht; 365 | $subtotals[$l->activity_type]['total'] += $l->total_ht; 366 | $subtotals[$l->activity_type][$l->fk_vehicule_type] += $l->total_ht; 367 | } 368 | } 369 | 370 | print ''; 371 | print ''; 372 | 373 | print '
'.$langs->trans('AmountHT').''.price($total_ht, '', $langs, 0, - 1, - 1, $conf->currency).'
'; 374 | 375 | print '
'; // Fin fichehalfright & ficheaddleft 376 | print ''; // Fin fichecenter 377 | 378 | print '

'; 379 | 380 | if (!empty($object->lines)) 381 | { 382 | print '
'; 383 | 384 | print '
'; 385 | 386 | if ($action == "editline" && $object->status == dolifleetRentalProposal::STATUS_DRAFT) 387 | { 388 | print '
'; 389 | print ''; 390 | print ''; 391 | print ''; 392 | print ''; 393 | } 394 | 395 | print ''; 396 | 397 | print ''; 398 | print ''; 399 | print ''; 400 | print ''; 401 | print ''; 402 | print ''; 403 | print ''; 404 | 405 | $typeAct = $typeVeh = 0; 406 | 407 | foreach ($object->lines as $line) 408 | { 409 | 410 | $modeEdit = ($action == 'editline' && $lineid == $line->id); 411 | 412 | if ($typeAct !== $line->activity_type) 413 | { 414 | $activityLabel = $dictTypeAct->getValueFromId($line->activity_type); 415 | print ''; 416 | print ''; 419 | print ''; 420 | print ''; 421 | print ''; 422 | $typeAct = $line->activity_type; 423 | $typeVeh = 0; 424 | } 425 | 426 | if ($typeVeh !== $line->fk_vehicule_type) 427 | { 428 | $VtypeLabel = $dictTypeVeh->getValueFromId($line->fk_vehicule_type); 429 | print ''; 432 | print ''; 433 | print ''; 434 | print ''; 435 | $typeVeh = $line->fk_vehicule_type; 436 | } 437 | 438 | print ''; 439 | print ''; 444 | print ''; 445 | print ''; 446 | print ''; 447 | print ''; 458 | print ''; 459 | } 460 | 461 | print '
'.$langs->trans('Immatriculation').''.$langs->trans('date_customer_exploit').''.$langs->trans('Description').''.$langs->trans('TotalHT').'
'; 417 | print $activityLabel; 418 | print ''.$langs->trans('Total').' '.$activityLabel.' : '.price($subtotals[$line->activity_type]['total']).'
'; 430 | print $VtypeLabel; 431 | print ''.$langs->trans('Total').' '.$VtypeLabel.' : '.price($subtotals[$line->activity_type][$line->fk_vehicule_type]).'
'; 440 | $vehicule = new doliFleetVehicule($db); 441 | $vehicule->fetch($line->fk_vehicule); 442 | print $vehicule->getLinkUrl(0, '', 'immatriculation'); 443 | print ''.dol_print_date($vehicule->date_customer_exploit).''.(!$modeEdit ? $line->showOutputField($line->fields['description'], 'description', $line->description) : $line->showInputField($line->fields['description'], 'description', $line->description)).''.(!$modeEdit ? price($line->total_ht) : $line->showInputField($line->fields['total_ht'], 'total_ht', $line->total_ht)).''; 448 | if ($modeEdit && $object->status == dolifleetRentalProposal::STATUS_DRAFT) 449 | { 450 | print ''; 451 | print ''; 452 | } 453 | else 454 | { 455 | if ($object->status == dolifleetRentalProposal::STATUS_DRAFT) print ''.img_edit().''; 456 | } 457 | print '
'; 462 | 463 | if ($action == "editline" && $object->status == dolifleetRentalProposal::STATUS_DRAFT) print '
'; 464 | 465 | print '
'; 466 | 467 | print '
'; // Fin fichecenter 468 | 469 | print '

'; 470 | } 471 | 472 | print '
'."\n"; 473 | $parameters=array(); 474 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook 475 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 476 | 477 | if (empty($reshook)) 478 | { 479 | // Send 480 | // print '' . $langs->trans('SendMail') . ''."\n"; 481 | 482 | // Modify 483 | if (!empty($user->rights->dolifleet->rentalproposal->validate)) 484 | { 485 | // Valid 486 | if ($object->status === dolifleetRentalProposal::STATUS_DRAFT) print ''."\n"; 487 | 488 | if ($object->status === dolifleetRentalProposal::STATUS_INPROGRESS ) 489 | { 490 | // Reopen 491 | if ($object->fk_first_valid == $user->id) print ''."\n"; 492 | else print ''."\n"; 493 | 494 | // Accept 495 | if ($object->fk_first_valid != $user->id) print ''."\n"; 496 | else print ''."\n"; 497 | } 498 | 499 | // Close 500 | if ($object->status === dolifleetRentalProposal::STATUS_VALIDATED) print ''."\n"; 501 | } 502 | else 503 | { 504 | // Valid 505 | if ($object->status === dolifleetRentalProposal::STATUS_DRAFT) print ''."\n"; 506 | 507 | if ($object->status === dolifleetRentalProposal::STATUS_INPROGRESS ) { 508 | // Reopen 509 | print '' . "\n"; 510 | 511 | // Accept 512 | print ''."\n"; 513 | } 514 | 515 | if ($object->status === dolifleetRentalProposal::STATUS_VALIDATED) print ''."\n"; 516 | } 517 | 518 | if ($object->status != dolifleetRentalProposal::STATUS_CLOSED) 519 | { 520 | if (!empty($user->rights->dolifleet->rentalproposal->delete)) 521 | { 522 | print ''."\n"; 523 | } 524 | else 525 | { 526 | print ''."\n"; 527 | } 528 | } 529 | else 530 | { 531 | print ''."\n"; 532 | } 533 | 534 | } 535 | print '
'."\n"; 536 | 537 | print '
'; 538 | 539 | print ''; // ancre 540 | // Documents 541 | $propalref = dol_sanitizeFileName($object->ref); 542 | $relativepath = $propalref.'/'.$propalref.'.pdf'; 543 | $filedir = $conf->dolifleet->multidir_output[$conf->entity].'/'.$propalref; 544 | $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; 545 | $genallowed = $user->rights->dolifleet->rentalproposal->read; 546 | $delallowed = $user->rights->dolifleet->rentalproposal->write; 547 | print $formfile->showdocuments('dolifleet:rentalproposal', $propalref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, 'entity='.$conf->entity, '', '', $soc->default_lang, '', $object); 548 | 549 | $linktoelem = $form->showLinkToObjectBlock($object, null, array($object->element)); 550 | $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); 551 | 552 | print '
'; 553 | 554 | // List of actions on element 555 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; 556 | $formactions = new FormActions($db); 557 | $somethingshown = $formactions->showactions($object, $object->element, $socid, 1); 558 | 559 | print '
'; 560 | 561 | dol_fiche_end(-1); 562 | } 563 | } 564 | } 565 | 566 | 567 | llxFooter(); 568 | $db->close(); 569 | -------------------------------------------------------------------------------- /lib/dolifleet.lib.php: -------------------------------------------------------------------------------- 1 | 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /** 19 | * \file lib/dolifleet.lib.php 20 | * \ingroup dolifleet 21 | * \brief This file is an example module library 22 | * Put some comments here 23 | */ 24 | 25 | /** 26 | * @return array 27 | */ 28 | function dolifleetAdminPrepareHead() 29 | { 30 | global $langs, $conf; 31 | 32 | $langs->load('dolifleet@dolifleet'); 33 | 34 | $h = 0; 35 | $head = array(); 36 | 37 | $head[$h][0] = dol_buildpath("/dolifleet/admin/dolifleet_setup.php", 1); 38 | $head[$h][1] = $langs->trans("Parameters"); 39 | $head[$h][2] = 'settings'; 40 | $h++; 41 | 42 | $head[$h][0] = dol_buildpath("/dolifleet/admin/rental_matrix.php", 1); 43 | $head[$h][1] = $langs->trans("rentalMatrix"); 44 | $head[$h][2] = 'matrix'; 45 | $h++; 46 | 47 | $head[$h][0] = dol_buildpath("/dolifleet/admin/vehicule_extrafields.php", 1); 48 | $head[$h][1] = $langs->trans("ExtraFields"); 49 | $head[$h][2] = 'extrafields'; 50 | $h++; 51 | 52 | if (!empty($conf->multicompany->enabled)) 53 | { 54 | $head[$h][0] = dol_buildpath("/dolifleet/admin/multicompany_sharing.php", 1); 55 | $head[$h][1] = $langs->trans("multicompanySharing"); 56 | $head[$h][2] = 'multicompanySharing'; 57 | $h++; 58 | } 59 | 60 | $head[$h][0] = dol_buildpath("/dolifleet/admin/dolifleet_about.php", 1); 61 | $head[$h][1] = $langs->trans("About"); 62 | $head[$h][2] = 'about'; 63 | $h++; 64 | 65 | // Show more tabs from modules 66 | // Entries must be declared in modules descriptor with line 67 | //$this->tabs = array( 68 | // 'entity:+tabname:Title:@dolifleet:/dolifleet/mypage.php?id=__ID__' 69 | //); // to add new tab 70 | //$this->tabs = array( 71 | // 'entity:-tabname:Title:@dolifleet:/dolifleet/mypage.php?id=__ID__' 72 | //); // to remove a tab 73 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'dolifleet'); 74 | 75 | return $head; 76 | } 77 | 78 | /** 79 | * Return array of tabs to used on pages for third parties cards. 80 | * 81 | * @param doliFleetVehicule $object Object company shown 82 | * @return array Array of tabs 83 | */ 84 | function vehicule_prepare_head(doliFleetVehicule $object) 85 | { 86 | global $langs, $conf; 87 | $h = 0; 88 | $head = array(); 89 | $head[$h][0] = dol_buildpath('/dolifleet/vehicule_card.php', 1).'?id='.$object->id; 90 | $head[$h][1] = $langs->trans("doliFleetVehiculeCard"); 91 | $head[$h][2] = 'card'; 92 | $h++; 93 | 94 | // Show more tabs from modules 95 | // Entries must be declared in modules descriptor with line 96 | // $this->tabs = array('entity:+tabname:Title:@dolifleet:/dolifleet/mypage.php?id=__ID__'); to add new tab 97 | // $this->tabs = array('entity:-tabname:Title:@dolifleet:/dolifleet/mypage.php?id=__ID__'); to remove a tab 98 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'dolifleetVehicule'); 99 | 100 | return $head; 101 | } 102 | 103 | /** 104 | * Return array of tabs to used on pages for third parties cards. 105 | * 106 | * @param dolifleetRentalProposal $object Object company shown 107 | * @return array Array of tabs 108 | */ 109 | function rental_proposal_prepare_head(dolifleetRentalProposal $object) 110 | { 111 | global $langs, $conf; 112 | $h = 0; 113 | $head = array(); 114 | $head[$h][0] = dol_buildpath('/dolifleet/rental_proposal_card.php', 1).'?id='.$object->id; 115 | $head[$h][1] = $langs->trans("doliFleetRentalProposalCard"); 116 | $head[$h][2] = 'card'; 117 | $h++; 118 | 119 | // Show more tabs from modules 120 | // Entries must be declared in modules descriptor with line 121 | // $this->tabs = array('entity:+tabname:Title:@dolifleet:/dolifleet/mypage.php?id=__ID__'); to add new tab 122 | // $this->tabs = array('entity:-tabname:Title:@dolifleet:/dolifleet/mypage.php?id=__ID__'); to remove a tab 123 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'dolifleetRentalProposal'); 124 | 125 | return $head; 126 | } 127 | 128 | /** 129 | * @param Form $form Form object 130 | * @param doliFleet $object doliFleet object 131 | * @param string $action Triggered action 132 | * @return string 133 | */ 134 | function getFormConfirmdoliFleetVehicule($form, $object, $action) 135 | { 136 | global $langs, $user; 137 | 138 | $formconfirm = ''; 139 | 140 | if ($action === 'valid' && !empty($user->rights->dolifleet->write)) 141 | { 142 | $body = $langs->trans('ConfirmActivatedoliFleetVehiculeBody', $object->immatriculation); 143 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmActivatedoliFleetVehiculeTitle'), $body, 'confirm_validate', '', 0, 1); 144 | } 145 | elseif ($action === 'validate' && !empty($user->rights->dolifleet->write)) 146 | { 147 | $body = $langs->trans('ConfirmValidateRentalProposalBody'); 148 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmValidateRentalProposalTitle'), $body, 'confirm_validate', '', 0, 1); 149 | } 150 | elseif ($action === 'accept' && !empty($user->rights->dolifleet->write)) 151 | { 152 | $body = $langs->trans('ConfirmAcceptRentalProposalBody'); 153 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmAcceptRentalProposalTitle'), $body, 'confirm_accept', '', 0, 1); 154 | } 155 | elseif ($action === 'close' && !empty($user->rights->dolifleet->write)) 156 | { 157 | $body = $langs->trans('ConfirmCloseRentalProposalBody'); 158 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmCloseRentalProposalTitle'), $body, 'confirm_close', '', 0, 1); 159 | } 160 | elseif ($action === 'modif' && !empty($user->rights->dolifleet->write)) 161 | { 162 | $body = $langs->trans('ConfirmReopendoliFleetVehiculeBody', $object->immatriculation); 163 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmReopendoliFleetVehiculeTitle'), $body, 'confirm_modif', '', 0, 1); 164 | } 165 | elseif ($action === 'delete' && !empty($user->rights->dolifleet->delete)) 166 | { 167 | $body = $langs->trans('ConfirmDeletedoliFleetVehiculeBody'); 168 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmDeletedoliFleetVehiculeTitle'), $body, 'confirm_delete', '', 0, 1); 169 | } 170 | elseif ($action === 'deleteRental' && !empty($user->rights->dolifleet->delete)) 171 | { 172 | $body = $langs->trans('ConfirmDeleteRentalBody'); 173 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmDeletedoliFleetVehiculeTitle'), $body, 'confirm_delete', '', 0, 1); 174 | } 175 | elseif ($action === 'clone' && !empty($user->rights->dolifleet->write)) 176 | { 177 | $body = $langs->trans('ConfirmClonedoliFleetVehiculeBody', $object->immatriculation); 178 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ConfirmClonedoliFleetVehiculeTitle'), $body, 'confirm_clone', '', 0, 1); 179 | } 180 | elseif ($action === 'delActivity' && !empty($user->rights->dolifleet->write)) 181 | { 182 | $body = $langs->trans('ConfirmDelActivitydoliFleetVehiculeBody'); 183 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&act_id='.GETPOST('act_id'), $langs->trans('ConfirmDeletedoliFleetVehiculeTitle'), $body, 'confirm_delActivity', '', 0, 1); 184 | } 185 | elseif ($action === 'unlinkVehicule' && !empty($user->rights->dolifleet->write)) 186 | { 187 | $body = $langs->trans('ConfirmUnlinkVehiculedoliFleetVehiculeBody'); 188 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&linkVehicule_id='.GETPOST('linkVehicule_id'), $langs->trans('ConfirmUnlinkVehiculedoliFleetVehiculeTitle'), $body, 'confirm_unlinkVehicule', '', 0, 1); 189 | } 190 | elseif ($action === 'delRental' && !empty($user->rights->dolifleet->write)) 191 | { 192 | $body = $langs->trans('ConfirmDelRentaldoliFleetVehiculeBody'); 193 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&rent_id='.GETPOST('rent_id'), $langs->trans('ConfirmDeletedoliFleetVehiculeTitle'), $body, 'confirm_delRental', '', 0, 1); 194 | } 195 | elseif ($action === 'delOperation' && !empty($user->rights->dolifleet->write)) 196 | { 197 | $body = $langs->trans('ConfirmDelOperationdoliFleetVehiculeBody'); 198 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&ope_id='.GETPOST('ope_id'), $langs->trans('ConfirmDeletedoliFleetVehiculeTitle'), $body, 'confirm_delOperation', '', 0, 1); 199 | } 200 | elseif ($action === 'delMatrixLine' && !empty($user->rights->dolifleet->write)) 201 | { 202 | $body = $langs->trans('ConfirmDeldoliFleetLineBody'); 203 | $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id='.GETPOST('id'), $langs->trans('ConfirmDeletedoliFleetVehiculeTitle'), $body, 'confirm_delMatrixLine', '', 0, 1); 204 | } 205 | 206 | return $formconfirm; 207 | } 208 | 209 | /** 210 | * @param doliFleetVehicule $object 211 | */ 212 | function printVehiculeActivities($object, $fromcard = false) 213 | { 214 | global $langs, $db, $form; 215 | print load_fiche_titre($langs->trans('VehiculeActivities'), '', ''); 216 | 217 | print '
'; 218 | print ''; 219 | print ''; 220 | print ''; 221 | 222 | print ''."\n"; 223 | print ' 224 | 225 | 226 | 227 | 228 | '; 229 | 230 | $date_start = $date_end = ''; 231 | if ($fromcard) 232 | { 233 | $date_start = dol_now(); 234 | $date_end = strtotime("+3 month", $date_start); 235 | } 236 | 237 | $ret = $object->getActivities($date_start, $date_end); 238 | if ($ret == 0) 239 | { 240 | print ''; 241 | } 242 | else if ($ret > 0) 243 | { 244 | /** @var doliFleetVehiculeActivity $activity */ 245 | foreach ($object->activities as $activity) 246 | { 247 | print ''; 248 | print ''; 249 | print ''; 250 | print ''; 251 | print ''; 254 | print ''; 255 | } 256 | } 257 | 258 | // ligne nouvelle activité 259 | print ''; 260 | print ''; 267 | 268 | print ''; 271 | 272 | print ''; 275 | 276 | print ''; 279 | 280 | print ''; 281 | 282 | print '
'.$langs->trans('ActivityType').''.$langs->trans('DateStart').''.$langs->trans('DateEnd').'
'.$langs->trans('NodoliFleetActivity').'
'.$activity->getType().''.dol_print_date($activity->date_start, "%d/%m/%Y").''.(!empty($activity->date_end) ? dol_print_date($activity->date_end, "%d/%m/%Y") : '').''; 252 | print ''.img_delete().''; 253 | print '
'; 261 | 262 | $dict = new dictionaryVehiculeActivityType($db); 263 | $TTypeActivity = $dict->getAllActiveArray('label'); 264 | print $form->selectArray('activityTypes', $TTypeActivity, GETPOST('activityTypes'), 1); 265 | 266 | print ''; 269 | print $form->selectDate('', 'activityDate_start'); 270 | print ''; 273 | print $form->selectDate('', 'activityDate_end'); 274 | print ''; 277 | print ''; 278 | print '
'; 283 | 284 | print '
'; 285 | ?> 286 | 291 | trans('LinkedVehicules'), '', ''); 303 | 304 | print '
'; 305 | print ''; 306 | print ''; 307 | print ''; 308 | 309 | print ''."\n"; 310 | print ''; 311 | print ''; 312 | print ''; 313 | print ''; 314 | print ''; 315 | print ''; 316 | 317 | $date_start = $date_end = ''; 318 | if ($fromcard) 319 | { 320 | $date_start = dol_now(); 321 | $date_end = strtotime("+3 month", $date_start); 322 | } 323 | 324 | $object->getLinkedVehicules($date_start, $date_end); 325 | if (empty($object->linkedVehicules)) 326 | { 327 | print ''; 328 | } 329 | else 330 | { 331 | foreach ($object->linkedVehicules as $vehiculelink) 332 | { 333 | $veh = new doliFleetVehicule($db); 334 | print ''; 335 | print ''; 341 | print ''; 342 | print ''; 343 | print ''; 344 | print ''; 345 | } 346 | } 347 | 348 | // new link 349 | print ''; 350 | $sql = "SELECT v.rowid, v.immatriculation, vt.label FROM ".MAIN_DB_PREFIX."dolifleet_vehicule as v"; 351 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_dolifleet_vehicule_type as vt ON vt.rowid = v.fk_vehicule_type"; 352 | $sql.= " WHERE v.status = 1"; 353 | $DOLIFLEET_MOTRICE_TYPES = unserialize($conf->global->DOLIFLEET_MOTRICE_TYPES); 354 | if (!empty($DOLIFLEET_MOTRICE_TYPES)) 355 | { 356 | if (in_array($object->fk_vehicule_type, $DOLIFLEET_MOTRICE_TYPES)) 357 | $sql.= " AND v.fk_vehicule_type NOT IN (".implode(', ', $DOLIFLEET_MOTRICE_TYPES).")"; 358 | else 359 | $sql.= " AND v.fk_vehicule_type IN (".implode(', ', $DOLIFLEET_MOTRICE_TYPES).")"; 360 | } 361 | else 362 | { 363 | // a minima on ne peut lier 2 véhicules de même nature 364 | $sql.= " AND v.fk_vehicule_type <> ".$object->fk_vehicule_type; 365 | } 366 | $sql .= " AND v.fk_soc = ".$object->fk_soc; 367 | $resql = $db->query($sql); 368 | $Tab = array(); 369 | if ($resql) 370 | { 371 | while ($obj = $db->fetch_object($resql)) 372 | { 373 | $Tab[$obj->rowid] = $obj->label.' - '.$obj->immatriculation; 374 | } 375 | } 376 | 377 | print ''; 380 | print ''; 383 | 384 | print ''; 387 | 388 | print ''; 391 | print ''; 392 | 393 | print '
Immatriculation'.$langs->trans('DateStart').''.$langs->trans('DateEnd').'
'.$langs->trans('NodoliFleet').'
'; 336 | 337 | $veh->fetch($vehiculelink->fk_other_vehicule); 338 | 339 | print $veh->getLinkUrl(0, '', 'immatriculation'); 340 | print ''.dol_print_date($vehiculelink->date_start, "%d/%m/%Y").''.(!empty($vehiculelink->date_end) ? dol_print_date($vehiculelink->date_end, "%d/%m/%Y") : '').'
'; 378 | print $form->selectarray('linkVehicule_id', $Tab, GETPOST('linkVehicule_id'),1, 0, 0, '', 0, 0, 0, '', '', 1); 379 | print ''; 381 | print $form->selectDate('', 'linkDate_start'); 382 | print ''; 385 | print $form->selectDate('', 'linkDate_end'); 386 | print ''; 389 | print ''; 390 | print '
'; 394 | 395 | print '
'; 396 | } 397 | 398 | /** 399 | * @param doliFleetVehicule $object 400 | */ 401 | function printVehiculeRental($object, $fromcard = false, $external = false) 402 | { 403 | global $langs, $form; 404 | 405 | $title = $langs->trans('VehiculeRentals'); 406 | if ($external) $title.= ' '.$langs->trans('Customer'); 407 | 408 | print load_fiche_titre($title, '', ''); 409 | 410 | print '
'; 411 | print ''; 412 | print ''; 413 | print ''; 414 | 415 | print ''."\n"; 416 | print ''; 417 | print ''; 418 | print ''; 419 | print ''; 420 | print ''; 421 | print ''; 422 | 423 | $date_start = $date_end = ''; 424 | if ($fromcard) 425 | { 426 | $date_start = dol_now(); 427 | $date_end = strtotime("+3 month", $date_start); 428 | } 429 | 430 | $object->getRentals($date_start, $date_end, $external); 431 | if (empty($object->rentals)) 432 | { 433 | print ''; 434 | print ''; 435 | print ''; 436 | } 437 | else 438 | { 439 | 440 | foreach ($object->rentals as $rent) 441 | { 442 | print ''; 443 | 444 | print ''; 447 | 448 | print ''; 451 | 452 | print ''; 455 | 456 | print ''; 459 | 460 | print ''; 461 | } 462 | } 463 | 464 | if (!$external) 465 | { 466 | // new line 467 | print ''; 468 | 469 | print ''; 472 | 473 | print ''; 476 | 477 | print ''; 480 | 481 | print ''; 484 | 485 | print ''; 486 | } 487 | 488 | 489 | print '
'.$langs->trans('DateStart').''.$langs->trans('DateEnd').''.$langs->trans('TotalHT').'
'.$langs->trans('NodoliFleet').'
'; 445 | print dol_print_date($rent->date_start, "%d/%m/%Y"); 446 | print ''; 449 | print dol_print_date($rent->date_end, "%d/%m/%Y"); 450 | print ''; 453 | print price($rent->total_ht); 454 | print ''; 457 | if (!$external) print ''.img_delete().''; 458 | print '
'; 470 | print $form->selectDate('', 'RentalDate_start'); 471 | print ''; 474 | print $form->selectDate('', 'RentalDate_end'); 475 | print ''; 478 | print ''; 479 | print ''; 482 | print ''; 483 | print '
'; 490 | 491 | print '
'; 492 | } 493 | 494 | /** 495 | * @param doliFleetVehicule $object 496 | */ 497 | function printVehiculeOpérations($object) 498 | { 499 | global $langs, $form; 500 | 501 | print load_fiche_titre($langs->trans('VehiculeOperations'), '', ''); 502 | 503 | print '
'; 504 | print ''; 505 | print ''; 506 | print ''; 507 | 508 | print ''."\n"; 509 | print ''; 510 | print ''; 511 | print ''; 512 | print ''; 513 | print ''; 514 | print ''; 515 | print ''; 516 | print ''; 517 | 518 | $res = $object->getOperations(); 519 | if ($res < 0) { 520 | setEventMessage($object->error,'errors'); 521 | } 522 | if (empty($object->operations)) 523 | { 524 | print ''; 525 | } 526 | else 527 | { 528 | foreach ($object->operations as $operation) 529 | { 530 | print ''; 531 | print ''; 532 | print ''; 533 | print ''; 534 | print ''; 539 | print ''; 540 | print ''; 543 | print ''; 544 | } 545 | } 546 | 547 | // new line 548 | print ''; 549 | 550 | print ''; 553 | 554 | print ''; 557 | 558 | print ''; 561 | 562 | print ''; 565 | 566 | print ''; 567 | 568 | print '
'.$langs->trans('VehiculeOperation').''.$langs->trans('KM').''.$langs->trans('VehiculeOperationDelay').''.$langs->trans('VehiculeOperationLastDateDone').''.$langs->trans('VehiculeOperationLastKmDone').'
'.$langs->trans('NodoliFleet').'
'.$operation->getName().''.(!empty($operation->km) ? price2num($operation->km) : '').''.(!empty($operation->delai_from_last_op) ? $operation->delai_from_last_op.' '.$langs->trans('Months') : '').''; 535 | if (!empty($operation->date_done)) { 536 | print dol_print_date($operation->date_done, "%d/%m/%Y"); 537 | } 538 | print ''.(!empty($operation->km_done)?$operation->km_done:'').''; 541 | print ''.img_delete().''; 542 | print '
'; 551 | print $form->select_produits(GETPOST('productid'), 'productid', '', 20, 0, 1, 2, '', 2); 552 | print ''; 555 | print ''; 556 | print ''; 559 | print ' '.$langs->trans('Months'); 560 | print ''; 563 | print ''; 564 | print '
'; 569 | 570 | print '
'; 571 | ?> 572 | 576 | ' . $langs->trans('BackToList') . ''; 584 | 585 | $morehtmlref='
'; 586 | if (! empty($vehicle->immatriculation)) $morehtmlref.= '
'.$langs->trans('immatriculation').': '.$vehicle->immatriculation; 587 | 588 | // marque 589 | dol_include_once('/dolifleet/class/dictionaryVehiculeMark.class.php'); 590 | $dict = new dictionaryVehiculeMark($db); 591 | $morehtmlref.= '
'.$langs->trans('vehiculeMark').': '.$dict->getValueFromId($vehicle->fk_vehicule_mark); 592 | 593 | // type de véhicule 594 | dol_include_once('/dolifleet/class/dictionaryVehiculeType.class.php'); 595 | $dict = new dictionaryVehiculeType($db); 596 | $morehtmlref.= '
'.$langs->trans('vehiculeType').': '.$dict->getValueFromId($vehicle->fk_vehicule_type); 597 | 598 | // client 599 | $vehicle->fetch_thirdparty(); 600 | $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$vehicle->thirdparty->getNomUrl(1, 'customer'); 601 | /* 602 | // Ref bis 603 | $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->dolifleet->write, 'string', '', 0, 1); 604 | $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->dolifleet->write, 'string', '', null, null, '', 1); 605 | // Thirdparty 606 | $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); 607 | */ 608 | $morehtmlref.='
'; 609 | 610 | $vehicle->ref = $vehicle->vin; 611 | dol_banner_tab($vehicle, 'vin', $linkback, 1, 'vin', 'ref', $morehtmlref, '', 0, '', ''); 612 | } 613 | --------------------------------------------------------------------------------