├── .gitignore ├── config.php ├── img ├── kelio.png ├── ATM_logo.jpg ├── object_kelio.png └── Dolibarr_Preferred_Partner_logo.png ├── script ├── test.php └── create-maj-base.php ├── README ├── langs ├── en_US │ └── kelio.lang └── fr_FR │ └── kelio.lang ├── config.default.php ├── lib └── kelio.lib.php ├── admin ├── kelio_about.php └── kelio_setup.php ├── core ├── boxes │ └── kelio_box.php ├── modules │ └── modKelio.class.php └── triggers │ └── interface_99_modKelio_Keliotrigger.class.php └── class ├── actions_kelio.class.php └── kelio.class.php /.gitignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | .project 3 | 4 | *.log 5 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | getTimeFromOuterSpace(); 13 | //$k->getClocking() 14 | //$k->getEmployees(); -------------------------------------------------------------------------------- /script/create-maj-base.php: -------------------------------------------------------------------------------- 1 | init_db_by_vars($PDOdb); 23 | */ 24 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 ATM Consulting 3 | * 4 | * This program and files/directory inner it is free software: you can 5 | * redistribute it and/or modify it under the terms of the 6 | * GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | -------------------------------------------------------------------------------- /langs/en_US/kelio.lang: -------------------------------------------------------------------------------- 1 | Module104054Name = Kelio 2 | Module104054Desc = Kelio 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 | KelioSetup = Kelio module setup 7 | KelioAbout = About Kelio 8 | -------------------------------------------------------------------------------- /config.default.php: -------------------------------------------------------------------------------- 1 | trans('AbricotNotFound'). ' : Abricot'; 27 | exit; 28 | } 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /langs/fr_FR/kelio.lang: -------------------------------------------------------------------------------- 1 | Module104054Name = Kelio 2 | Module104054Desc = Kelio Description 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 | KelioSetup = Configuration du module Kelio 7 | KelioAbout = A propos du module Kelio 8 | 9 | KelioBadgeId=Id. du badge 10 | KELIO_WSLD_USER=login du webservice 11 | KELIO_WSLD_PASS=Mot de passe du webservice 12 | KELIO_SERVICE_URI=Url des webservices 13 | TimeFromKelio=Temps issu de Kelio -------------------------------------------------------------------------------- /lib/kelio.lib.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file lib/kelio.lib.php 21 | * \ingroup kelio 22 | * \brief This file is an example module library 23 | * Put some comments here 24 | */ 25 | 26 | function kelioAdminPrepareHead() 27 | { 28 | global $langs, $conf; 29 | 30 | $langs->load("kelio@kelio"); 31 | 32 | $h = 0; 33 | $head = array(); 34 | 35 | $head[$h][0] = dol_buildpath("/kelio/admin/kelio_setup.php", 1); 36 | $head[$h][1] = $langs->trans("Parameters"); 37 | $head[$h][2] = 'settings'; 38 | $h++; 39 | $head[$h][0] = dol_buildpath("/kelio/admin/kelio_about.php", 1); 40 | $head[$h][1] = $langs->trans("About"); 41 | $head[$h][2] = 'about'; 42 | $h++; 43 | 44 | // Show more tabs from modules 45 | // Entries must be declared in modules descriptor with line 46 | //$this->tabs = array( 47 | // 'entity:+tabname:Title:@kelio:/kelio/mypage.php?id=__ID__' 48 | //); // to add new tab 49 | //$this->tabs = array( 50 | // 'entity:-tabname:Title:@kelio:/kelio/mypage.php?id=__ID__' 51 | //); // to remove a tab 52 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'kelio'); 53 | 54 | return $head; 55 | } 56 | -------------------------------------------------------------------------------- /admin/kelio_about.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file admin/about.php 21 | * \ingroup kelio 22 | * \brief This file is an example about page 23 | * Put some comments here 24 | */ 25 | // Dolibarr environment 26 | $res = @include("../../main.inc.php"); // From htdocs directory 27 | if (! $res) { 28 | $res = @include("../../../main.inc.php"); // From "custom" directory 29 | } 30 | 31 | // Libraries 32 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 33 | require_once '../lib/kelio.lib.php'; 34 | 35 | // Translations 36 | $langs->load("kelio@kelio"); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | /* 44 | * View 45 | */ 46 | $page_name = "KelioAbout"; 47 | llxHeader('', $langs->trans($page_name)); 48 | 49 | // Subheader 50 | $linkback = '' 51 | . $langs->trans("BackToModuleList") . ''; 52 | print_fiche_titre($langs->trans($page_name), $linkback); 53 | 54 | // Configuration header 55 | $head = kelioAdminPrepareHead(); 56 | dol_fiche_head( 57 | $head, 58 | 'about', 59 | $langs->trans("Module104054Name"), 60 | 0, 61 | 'kelio@kelio' 62 | ); 63 | 64 | // About page goes here 65 | print '
'; 66 | print '
'.$langs->trans('ATMAbout').'
'; 67 | 68 | dol_fiche_end(); 69 | 70 | print '
'; 71 | print ''; 72 | print '
'; 73 | 74 | llxFooter(); 75 | 76 | $db->close(); -------------------------------------------------------------------------------- /core/boxes/kelio_box.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file core/boxes/mybox.php 21 | * \ingroup kelio 22 | * \brief This file is a sample box definition file 23 | * Put some comments here 24 | */ 25 | include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; 26 | 27 | /** 28 | * Class to manage the box 29 | */ 30 | class keliobox extends ModeleBoxes 31 | { 32 | 33 | public $boxcode = "mybox"; 34 | public $boximg = "kelio@kelio"; 35 | public $boxlabel; 36 | public $depends = array("kelio"); 37 | public $db; 38 | public $param; 39 | public $info_box_head = array(); 40 | public $info_box_contents = array(); 41 | 42 | /** 43 | * Constructor 44 | */ 45 | public function __construct() 46 | { 47 | global $langs; 48 | $langs->load("boxes"); 49 | 50 | $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); 51 | } 52 | 53 | /** 54 | * Load data into info_box_contents array to show array later. 55 | * 56 | * @param int $max Maximum number of records to load 57 | * @return void 58 | */ 59 | public function loadBox($max = 5) 60 | { 61 | global $conf, $user, $langs, $db; 62 | 63 | $this->max = $max; 64 | 65 | //include_once DOL_DOCUMENT_ROOT . "/kelio/class/kelio.class.php"; 66 | 67 | $text = $langs->trans("MyBoxDescription", $max); 68 | $this->info_box_head = array( 69 | 'text' => $text, 70 | 'limit' => dol_strlen($text) 71 | ); 72 | 73 | $this->info_box_contents[0][0] = array('td' => 'align="left"', 74 | 'text' => $langs->trans("MyBoxContent")); 75 | } 76 | 77 | /** 78 | * Method to show box 79 | * 80 | * @param array $head Array with properties of box title 81 | * @param array $contents Array with properties of box lines 82 | * @return void 83 | */ 84 | public function showBox($head = null, $contents = null) 85 | { 86 | parent::showBox($this->info_box_head, $this->info_box_contents); 87 | } 88 | } -------------------------------------------------------------------------------- /class/actions_kelio.class.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file class/actions_kelio.class.php 21 | * \ingroup kelio 22 | * \brief This file is an example hook overload class file 23 | * Put some comments here 24 | */ 25 | 26 | /** 27 | * Class ActionsKelio 28 | */ 29 | class ActionsKelio 30 | { 31 | /** 32 | * @var array Hook results. Propagated to $hookmanager->resArray for later reuse 33 | */ 34 | public $results = array(); 35 | 36 | /** 37 | * @var string String displayed by executeHook() immediately after return 38 | */ 39 | public $resprints; 40 | 41 | /** 42 | * @var array Errors 43 | */ 44 | public $errors = array(); 45 | 46 | /** 47 | * Constructor 48 | */ 49 | public function __construct() 50 | { 51 | } 52 | 53 | /** 54 | * Overloading the doActions function : replacing the parent's function with the one below 55 | * 56 | * @param array() $parameters Hook metadatas (context, etc...) 57 | * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 58 | * @param string &$action Current action (if set). Generally create or edit or null 59 | * @param HookManager $hookmanager Hook manager propagated to allow calling another hook 60 | * @return int < 0 on error, 0 on success, 1 to replace standard code 61 | */ 62 | function doActions($parameters, &$object, &$action, $hookmanager) 63 | { 64 | $error = 0; // Error counter 65 | $myvalue = 'test'; // A result value 66 | 67 | print_r($parameters); 68 | echo "action: " . $action; 69 | print_r($object); 70 | 71 | if (in_array('somecontext', explode(':', $parameters['context']))) 72 | { 73 | // do something only for the context 'somecontext' 74 | } 75 | 76 | if (! $error) 77 | { 78 | $this->results = array('myreturn' => $myvalue); 79 | $this->resprints = 'A text to show'; 80 | return 0; // or return 1 to replace standard code 81 | } 82 | else 83 | { 84 | $this->errors[] = 'Error message'; 85 | return -1; 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /admin/kelio_setup.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file admin/kelio.php 21 | * \ingroup kelio 22 | * \brief This file is an example module setup page 23 | * Put some comments here 24 | */ 25 | // Dolibarr environment 26 | $res = @include("../../main.inc.php"); // From htdocs directory 27 | if (! $res) { 28 | $res = @include("../../../main.inc.php"); // From "custom" directory 29 | } 30 | 31 | // Libraries 32 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; 33 | require_once '../lib/kelio.lib.php'; 34 | 35 | // Translations 36 | $langs->load("kelio@kelio"); 37 | 38 | // Access control 39 | if (! $user->admin) { 40 | accessforbidden(); 41 | } 42 | 43 | // Parameters 44 | $action = GETPOST('action', 'alpha'); 45 | 46 | /* 47 | * Actions 48 | */ 49 | if (preg_match('/set_(.*)/',$action,$reg)) 50 | { 51 | $code=$reg[1]; 52 | if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) 53 | { 54 | header("Location: ".$_SERVER["PHP_SELF"]); 55 | exit; 56 | } 57 | else 58 | { 59 | dol_print_error($db); 60 | } 61 | } 62 | 63 | if (preg_match('/del_(.*)/',$action,$reg)) 64 | { 65 | $code=$reg[1]; 66 | if (dolibarr_del_const($db, $code, 0) > 0) 67 | { 68 | Header("Location: ".$_SERVER["PHP_SELF"]); 69 | exit; 70 | } 71 | else 72 | { 73 | dol_print_error($db); 74 | } 75 | } 76 | 77 | /* 78 | * View 79 | */ 80 | $page_name = "KelioSetup"; 81 | llxHeader('', $langs->trans($page_name)); 82 | 83 | // Subheader 84 | $linkback = '' 85 | . $langs->trans("BackToModuleList") . ''; 86 | print_fiche_titre($langs->trans($page_name), $linkback); 87 | 88 | // Configuration header 89 | $head = kelioAdminPrepareHead(); 90 | dol_fiche_head( 91 | $head, 92 | 'settings', 93 | $langs->trans("Module104054Name"), 94 | 0, 95 | "kelio@kelio" 96 | ); 97 | 98 | // Setup page goes here 99 | $form=new Form($db); 100 | $var=false; 101 | print ''; 102 | print ''; 103 | print ''."\n"; 104 | print ''; 105 | print ''."\n"; 106 | 107 | 108 | $var=!$var; 109 | print ''; 110 | print ''; 111 | print ''; 112 | print ''; 120 | 121 | $var=!$var; 122 | print ''; 123 | print ''; 124 | print ''; 125 | print ''; 133 | 134 | $var=!$var; 135 | print ''; 136 | print ''; 137 | print ''; 138 | print ''; 146 | 147 | print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans("KELIO_WSLD_USER").' '; 113 | print '
'; 114 | print ''; 115 | print ''; 116 | print ''; 117 | print ''; 118 | print '
'; 119 | print '
'.$langs->trans("KELIO_WSLD_PASS").' '; 126 | print '
'; 127 | print ''; 128 | print ''; 129 | print ''; 130 | print ''; 131 | print '
'; 132 | print '
'.$langs->trans("KELIO_SERVICE_URI").' '; 139 | print '
'; 140 | print ''; 141 | print ''; 142 | print ''; 143 | print ''; 144 | print '
'; 145 | print '
'; 148 | 149 | llxFooter(); 150 | 151 | $db->close(); -------------------------------------------------------------------------------- /class/kelio.class.php: -------------------------------------------------------------------------------- 1 | db = &$db; 9 | 10 | } 11 | 12 | /* 13 | * En mode startrek, beyond the star, la recherche est infinie 14 | */ 15 | function getTimeFromOuterSpace($date='') { 16 | global $conf; 17 | 18 | $client = new SoapClient($conf->global->KELIO_SERVICE_URI.'JobTotalService?wsdl' 19 | , array( 20 | 'login'=> $conf->global->KELIO_WSLD_USER 21 | ,'password' => $conf->global->KELIO_WSLD_PASS 22 | ,'trace'=>true 23 | ) 24 | ); 25 | 26 | if(empty($date)) $date=date('Y-m-d',strtotime('-1day')); 27 | 28 | $parameters= array( 29 | 'populationFilter'=>'' 30 | ,'groupFilter'=>'' 31 | ,'date'=>$date 32 | ); 33 | try { 34 | // Cette fonction renvoie le temps passé pour un user, un jour, une affaire et un job 35 | $res = $client->exportActualPerpetualJobTotalsListFromDate($parameters); 36 | } 37 | catch(Exception $e) { 38 | pre($e,1); 39 | } 40 | 41 | $this->_gtfos_parseData($res->exportedPerpetualJobTotals->PerpetualJobTotal); 42 | } 43 | 44 | private function _gtfos_parseData(&$TData) { 45 | global $db, $user,$langs; 46 | $langs->load('kelio@kelio'); 47 | 48 | $this->errors = array(); 49 | 50 | ob_start(); 51 | foreach($TData as &$data) { 52 | 53 | $projectKey = $data->costCentreAbbreviation; 54 | $userKey = $data->employeeBadgeCode; 55 | $taskKey = $data->jobCode; 56 | 57 | $userTime = $this->_get_user_from_key($userKey,$data); 58 | $task = $this->_get_task_from_key($projectKey,$taskKey, $data->jobDescription); 59 | 60 | if($task!==false && $userTime!==false) { 61 | $ret = $task->add_contact($userTime->id, 181,'internal'); 62 | if($ret<0) { 63 | $this->errors[]='user already ad contact of task '.$task->ref; 64 | } 65 | 66 | $task->timespent_date = strtotime($data->date); 67 | $task->timespent_duration = $data->hours * 3600; 68 | $task->timespent_fk_user = $userTime->id; 69 | $task->timespent_note = $langs->trans('TimeFromKelio'); 70 | 71 | // On vérifie si le temps n'existe pas déjà pour le même user, la même tâche et la même date 72 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."projet_task_time "; 73 | $sql.= "WHERE fk_user = ".$task->timespent_fk_user." "; 74 | $sql.= "AND fk_task = ".$task->id." "; 75 | $sql.= "AND task_date = '".$data->date."' "; 76 | 77 | $res = $db->query($sql); 78 | if($obj = $db->fetch_object($res)) { 79 | $task->timespent_id = $obj->rowid; 80 | $task->updateTimeSpent($user); 81 | } 82 | else{ 83 | $task->addTimeSpent($user); 84 | } 85 | } 86 | } 87 | 88 | ob_get_clean(); 89 | 90 | if(count($this->errors)>0) { 91 | 92 | var_dump($this->errors); 93 | } 94 | 95 | echo 1; 96 | 97 | } 98 | private function _get_task_from_key($projectKey,$taskKey, $label) { 99 | 100 | global $TTask,$TProject,$db, $user; 101 | 102 | dol_include_once('/projet/class/project.class.php'); 103 | dol_include_once('/projet/class/task.class.php'); 104 | 105 | $key = $projectKey.'-'.$taskKey; 106 | if(empty($TTask))$TTask=array(); 107 | if(empty($TProject))$TProject=array(); 108 | 109 | if(!isset($TTask[$key])) { 110 | 111 | if(!isset($TProject[$projectKey])) { 112 | $project=new Project($db); 113 | $project->fetch(0, $projectKey); 114 | 115 | if($project->id<=0) { 116 | $this->errors[] = 'unknown project '.$projectKey; 117 | return false; // on ne trouve pas le projet associé 118 | } 119 | 120 | $TProject[$projectKey] = $project; 121 | } 122 | 123 | $project = $TProject[$projectKey]; 124 | 125 | $res = $db->query("SELECT rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE ref='".$key."'"); 126 | $task=new Task($db); 127 | if($obj= $db->fetch_object($res)) { 128 | 129 | $task->fetch($obj->rowid); 130 | 131 | } 132 | else { 133 | 134 | $task=new Task($db); 135 | $task->fk_project = $project->id; 136 | $task->ref=$key; 137 | $task->fk_task_parent = 0; 138 | $task->date_c = time(); 139 | $task->label =$label; 140 | $task->description=''; 141 | $task->date_start = $project->date_start; 142 | $task->date_end = $project->date_end; 143 | $task->planned_workload = 0; 144 | 145 | $task->progress = 0; 146 | 147 | $res = $task->create($user); 148 | if($res<0) { 149 | 150 | var_dump($task);exit; 151 | } 152 | 153 | } 154 | 155 | $TTask[$key] = $task; 156 | } 157 | 158 | return $TTask[$key]; 159 | } 160 | 161 | private function _get_user_from_key($userKey,$data) { 162 | global $TUser,$db, $user; 163 | 164 | if(empty($TUser))$TUser=array(); 165 | 166 | if(!isset($TUser[$userKey])) { 167 | $res = $db->query("SELECT fk_object FROM ".MAIN_DB_PREFIX."user_extrafields WHERE kelio_badge_id='".$userKey."'"); 168 | if($res===false) { 169 | var_dump($db);exit; 170 | 171 | } 172 | 173 | if($obj= $db->fetch_object($res)) { 174 | 175 | $u =new User($db); 176 | $u->fetch($obj->fk_object); 177 | 178 | $TUser[$userKey] = $u; 179 | 180 | } 181 | else { 182 | 183 | $res = $db->query("SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE firstname='".$db->escape($data->employeeFirstName)."' AND lastname='".$db->escape($data->employeeSurname)."'"); 184 | if($obj= $db->fetch_object($res)) { 185 | 186 | $u =new User($db); 187 | $u->fetch($obj->rowid); 188 | 189 | $TUser[$userKey] = $u; 190 | 191 | } 192 | else { 193 | 194 | $this->errors[] = 'unknown user '.$userKey; 195 | 196 | return false; 197 | 198 | } 199 | } 200 | } 201 | 202 | return $TUser[$userKey]; 203 | } 204 | 205 | function getEmployees() { 206 | 207 | global $conf; 208 | 209 | $client = new SoapClient($conf->global->KELIO_SERVICE_URI.'EmployeeService?wsdl' 210 | , array( 211 | 'login'=> $conf->global->KELIO_WSLD_USER 212 | ,'password' => $conf->global->KELIO_WSLD_PASS 213 | ,'trace'=>true 214 | ) 215 | ); 216 | 217 | var_dump($client, $client->__getFunctions()); 218 | 219 | $parameters= array( 220 | 'populationFilter'=>'' 221 | ); 222 | try { 223 | $res = $client->exportEmployees($parameters); 224 | } 225 | catch(Exception $e) { 226 | pre($e,1); 227 | 228 | } 229 | pre($res,1); 230 | var_dump($client->__getLastResponse() ); 231 | } 232 | 233 | function getClocking() { 234 | // works !! 235 | global $conf; 236 | 237 | $client = new SoapClient($conf->global->KELIO_SERVICE_URI.'ClockingService?wsdl' 238 | , array( 239 | 'login'=> $conf->global->KELIO_WSLD_USER 240 | ,'password' => $conf->global->KELIO_WSLD_PASS 241 | ,'trace'=>true 242 | ) 243 | ); 244 | 245 | var_dump($client, $client->__getFunctions()); 246 | 247 | $t1day=strtotime('-1day'); 248 | 249 | $parameters= array( 250 | 'endDate'=>date('Y-m-d',$t1day) 251 | ,'startDate'=>date('Y-m-d',$t1day) 252 | ,'groupFilter'=>'' 253 | ,'populationFilter'=>'' 254 | ); 255 | try { 256 | $res = $client->exportClockingsByDate($parameters); 257 | } 258 | catch(Exception $e) { 259 | pre($e,1); 260 | 261 | } 262 | pre($res,1); 263 | var_dump($client->__getLastResponse() ); 264 | 265 | 266 | } 267 | 268 | } 269 | -------------------------------------------------------------------------------- /core/modules/modKelio.class.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2012 Laurent Destailleur 4 | * Copyright (C) 2005-2012 Regis Houssin 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /** 21 | * \defgroup kelio Module Kelio 22 | * \brief Example of a module descriptor. 23 | * Such a file must be copied into htdocs/kelio/core/modules directory. 24 | * \file htdocs/kelio/core/modules/modKelio.class.php 25 | * \ingroup kelio 26 | * \brief Description and activation file for module Kelio 27 | */ 28 | include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; 29 | 30 | 31 | /** 32 | * Description and activation class for module Kelio 33 | */ 34 | class modKelio extends DolibarrModules 35 | { 36 | /** 37 | * Constructor. Define names, constants, directories, boxes, permissions 38 | * 39 | * @param DoliDB $db Database handler 40 | */ 41 | function __construct($db) 42 | { 43 | global $langs,$conf; 44 | 45 | $this->db = $db; 46 | 47 | $this->editor_name = 'ATM-Consulting'; 48 | // Id for module (must be unique). 49 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). 50 | $this->numero = 104054; // 104000 to 104999 for ATM CONSULTING 51 | // Key text used to identify module (for permissions, menus, etc...) 52 | $this->rights_class = 'kelio'; 53 | 54 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' 55 | // It is used to group modules in module setup page 56 | $this->family = "ATM"; 57 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) 58 | $this->name = preg_replace('/^mod/i','',get_class($this)); 59 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) 60 | $this->description = "Description of module Kelio"; 61 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version 62 | $this->version = '1.0'; 63 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) 64 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); 65 | // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) 66 | $this->special = 0; 67 | // Name of image file used for this module. 68 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' 69 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' 70 | $this->picto='kelio@kelio'; 71 | 72 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) 73 | // for default path (eg: /kelio/core/xxxxx) (0=disable, 1=enable) 74 | // for specific path of parts (eg: /kelio/core/modules/barcode) 75 | // for specific css file (eg: /kelio/css/kelio.css.php) 76 | //$this->module_parts = array( 77 | // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) 78 | // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) 79 | // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) 80 | // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) 81 | // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) 82 | // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 83 | // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 84 | // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 85 | // 'css' => array('/kelio/css/kelio.css.php'), // Set this to relative path of css file if module has its own css file 86 | // 'js' => array('/kelio/js/kelio.js'), // Set this to relative path of js file if module must load a js on all pages 87 | // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module 88 | // 'dir' => array('output' => 'othermodulename'), // To force the default directories names 89 | // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@kelio')) // Set here all workflow context managed by module 90 | // ); 91 | $this->module_parts = array(); 92 | 93 | // Data directories to create when module is enabled. 94 | // Example: this->dirs = array("/kelio/temp"); 95 | $this->dirs = array(); 96 | 97 | // Config pages. Put here list of php page, stored into kelio/admin directory, to use to setup module. 98 | $this->config_page_url = array("kelio_setup.php@kelio"); 99 | 100 | // Dependencies 101 | $this->hidden = false; // A condition to hide module 102 | $this->depends = array(); // List of modules id that must be enabled if this module is enabled 103 | $this->requiredby = array(); // List of modules id to disable if this one is disabled 104 | $this->conflictwith = array(); // List of modules id this module is in conflict with 105 | $this->phpmin = array(5,0); // Minimum version of PHP required by module 106 | $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module 107 | $this->langfiles = array("kelio@kelio"); 108 | 109 | // Constants 110 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) 111 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), 112 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) 113 | // ); 114 | $this->const = array(); 115 | 116 | // Array to add new pages in new tabs 117 | // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@kelio:$user->rights->kelio->read:/kelio/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 118 | // 'objecttype:+tabname2:Title2:mylangfile@kelio:$user->rights->othermodule->read:/kelio/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 119 | // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname 120 | // where objecttype can be 121 | // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) 122 | // 'contact' to add a tab in contact view 123 | // 'contract' to add a tab in contract view 124 | // 'group' to add a tab in group view 125 | // 'intervention' to add a tab in intervention view 126 | // 'invoice' to add a tab in customer invoice view 127 | // 'invoice_supplier' to add a tab in supplier invoice view 128 | // 'member' to add a tab in fundation member view 129 | // 'opensurveypoll' to add a tab in opensurvey poll view 130 | // 'order' to add a tab in customer order view 131 | // 'order_supplier' to add a tab in supplier order view 132 | // 'payment' to add a tab in payment view 133 | // 'payment_supplier' to add a tab in supplier payment view 134 | // 'product' to add a tab in product view 135 | // 'propal' to add a tab in propal view 136 | // 'project' to add a tab in project view 137 | // 'stock' to add a tab in stock view 138 | // 'thirdparty' to add a tab in third party view 139 | // 'user' to add a tab in user view 140 | $this->tabs = array(); 141 | 142 | // Dictionaries 143 | if (! isset($conf->kelio->enabled)) 144 | { 145 | $conf->kelio=new stdClass(); 146 | $conf->kelio->enabled=0; 147 | } 148 | $this->dictionaries=array(); 149 | /* Example: 150 | if (! isset($conf->kelio->enabled)) $conf->kelio->enabled=0; // This is to avoid warnings 151 | $this->dictionaries=array( 152 | 'langs'=>'mylangfile@kelio', 153 | 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor 154 | 'tablib'=>array("Table1","Table2","Table3"), // Label of tables 155 | 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields 156 | 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order 157 | 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) 158 | 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) 159 | 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) 160 | 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') 161 | 'tabcond'=>array($conf->kelio->enabled,$conf->kelio->enabled,$conf->kelio->enabled) // Condition to show each dictionary 162 | ); 163 | */ 164 | 165 | // Boxes 166 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. 167 | $this->boxes = array(); // List of boxes 168 | // Example: 169 | //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); 170 | 171 | // Permissions 172 | $this->rights = array(); // Permission array used by this module 173 | $r=0; 174 | 175 | // Add here list of permission defined by an id, a label, a boolean and two constant strings. 176 | // Example: 177 | // $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) 178 | // $this->rights[$r][1] = 'Permision label'; // Permission label 179 | // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) 180 | // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 181 | // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) 182 | // $r++; 183 | 184 | 185 | // Main menu entries 186 | $this->menu = array(); // List of menus to add 187 | $r=0; 188 | 189 | // Add here entries to declare new menus 190 | // 191 | // Example to declare a new Top Menu entry and its Left menu entry: 192 | // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu 193 | // 'type'=>'top', // This is a Top menu entry 194 | // 'titre'=>'Kelio top menu', 195 | // 'mainmenu'=>'kelio', 196 | // 'leftmenu'=>'kelio', 197 | // 'url'=>'/kelio/pagetop.php', 198 | // 'langs'=>'mylangfile@kelio', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 199 | // 'position'=>100, 200 | // 'enabled'=>'$conf->kelio->enabled', // Define condition to show or hide menu entry. Use '$conf->kelio->enabled' if entry must be visible if module is enabled. 201 | // 'perms'=>'1', // Use 'perms'=>'$user->rights->kelio->level1->level2' if you want your menu with a permission rules 202 | // 'target'=>'', 203 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 204 | // $r++; 205 | // 206 | // Example to declare a Left Menu entry into an existing Top menu entry: 207 | // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 208 | // 'type'=>'left', // This is a Left menu entry 209 | // 'titre'=>'Kelio left menu', 210 | // 'mainmenu'=>'xxx', 211 | // 'leftmenu'=>'kelio', 212 | // 'url'=>'/kelio/pagelevel2.php', 213 | // 'langs'=>'mylangfile@kelio', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 214 | // 'position'=>100, 215 | // 'enabled'=>'$conf->kelio->enabled', // Define condition to show or hide menu entry. Use '$conf->kelio->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 216 | // 'perms'=>'1', // Use 'perms'=>'$user->rights->kelio->level1->level2' if you want your menu with a permission rules 217 | // 'target'=>'', 218 | // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 219 | // $r++; 220 | 221 | 222 | // Exports 223 | $r=1; 224 | 225 | // Example: 226 | // $this->export_code[$r]=$this->rights_class.'_'.$r; 227 | // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) 228 | // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. 229 | // $this->export_permission[$r]=array(array("facture","facture","export")); 230 | // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); 231 | // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); 232 | // $this->export_sql_start[$r]='SELECT DISTINCT '; 233 | // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; 234 | // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; 235 | // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; 236 | // $this->export_sql_order[$r] .=' ORDER BY s.nom'; 237 | // $r++; 238 | } 239 | 240 | /** 241 | * Function called when module is enabled. 242 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. 243 | * It also creates data directories 244 | * 245 | * @param string $options Options when enabling module ('', 'noboxes') 246 | * @return int 1 if OK, 0 if KO 247 | */ 248 | function init($options='') 249 | { 250 | $sql = array(); 251 | 252 | define('INC_FROM_DOLIBARR',true); 253 | 254 | dol_include_once('/kelio/config.php'); 255 | dol_include_once('/kelio/script/create-maj-base.php'); 256 | 257 | dol_include_once('/core/class/extrafields.class.php'); 258 | $extrafields=new ExtraFields($this->db); 259 | $res = $extrafields->addExtraField('kelio_badge_id', 'KelioBadgeId', 'varchar', 0, '255', 'user'); 260 | if($res<=0) { 261 | var_dump($extrafields);exit; 262 | } 263 | $result=$this->_load_tables('/kelio/sql/'); 264 | 265 | return $this->_init($sql, $options); 266 | } 267 | 268 | /** 269 | * Function called when module is disabled. 270 | * Remove from database constants, boxes and permissions from Dolibarr database. 271 | * Data directories are not deleted 272 | * 273 | * @param string $options Options when enabling module ('', 'noboxes') 274 | * @return int 1 if OK, 0 if KO 275 | */ 276 | function remove($options='') 277 | { 278 | $sql = array(); 279 | 280 | return $this->_remove($sql, $options); 281 | } 282 | 283 | } 284 | -------------------------------------------------------------------------------- /core/triggers/interface_99_modKelio_Keliotrigger.class.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2015 ATM Consulting 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file core/triggers/interface_99_modMyodule_Keliotrigger.class.php 21 | * \ingroup kelio 22 | * \brief Sample trigger 23 | * \remarks You can create other triggers by copying this one 24 | * - File name should be either: 25 | * interface_99_modMymodule_Mytrigger.class.php 26 | * interface_99_all_Mytrigger.class.php 27 | * - The file must stay in core/triggers 28 | * - The class name must be InterfaceMytrigger 29 | * - The constructor method must be named InterfaceMytrigger 30 | * - The name property name must be Mytrigger 31 | */ 32 | 33 | /** 34 | * Trigger class 35 | */ 36 | class InterfaceKeliotrigger 37 | { 38 | 39 | private $db; 40 | 41 | /** 42 | * Constructor 43 | * 44 | * @param DoliDB $db Database handler 45 | */ 46 | public function __construct($db) 47 | { 48 | $this->db = $db; 49 | 50 | $this->name = preg_replace('/^Interface/i', '', get_class($this)); 51 | $this->family = "demo"; 52 | $this->description = "Triggers of this module are empty functions." 53 | . "They have no effect." 54 | . "They are provided for tutorial purpose only."; 55 | // 'development', 'experimental', 'dolibarr' or version 56 | $this->version = 'development'; 57 | $this->picto = 'kelio@kelio'; 58 | } 59 | 60 | /** 61 | * Trigger name 62 | * 63 | * @return string Name of trigger file 64 | */ 65 | public function getName() 66 | { 67 | return $this->name; 68 | } 69 | 70 | /** 71 | * Trigger description 72 | * 73 | * @return string Description of trigger file 74 | */ 75 | public function getDesc() 76 | { 77 | return $this->description; 78 | } 79 | 80 | /** 81 | * Trigger version 82 | * 83 | * @return string Version of trigger file 84 | */ 85 | public function getVersion() 86 | { 87 | global $langs; 88 | $langs->load("admin"); 89 | 90 | if ($this->version == 'development') { 91 | return $langs->trans("Development"); 92 | } elseif ($this->version == 'experimental') 93 | 94 | return $langs->trans("Experimental"); 95 | elseif ($this->version == 'dolibarr') return DOL_VERSION; 96 | elseif ($this->version) return $this->version; 97 | else { 98 | return $langs->trans("Unknown"); 99 | } 100 | } 101 | 102 | /** 103 | * Function called when a Dolibarrr business event is done. 104 | * All functions "run_trigger" are triggered if file 105 | * is inside directory core/triggers 106 | * 107 | * @param string $action Event action code 108 | * @param Object $object Object 109 | * @param User $user Object user 110 | * @param Translate $langs Object langs 111 | * @param conf $conf Object conf 112 | * @return int <0 if KO, 0 if no triggered ran, >0 if OK 113 | */ 114 | public function run_trigger($action, $object, $user, $langs, $conf) 115 | { 116 | // Put here code you want to execute when a Dolibarr business events occurs. 117 | // Data and type of action are stored into $object and $action 118 | // Users 119 | if ($action == 'USER_LOGIN') { 120 | dol_syslog( 121 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 122 | ); 123 | } elseif ($action == 'USER_UPDATE_SESSION') { 124 | // Warning: To increase performances, this action is triggered only if 125 | // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. 126 | dol_syslog( 127 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 128 | ); 129 | } elseif ($action == 'USER_CREATE') { 130 | dol_syslog( 131 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 132 | ); 133 | } elseif ($action == 'USER_CREATE_FROM_CONTACT') { 134 | dol_syslog( 135 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 136 | ); 137 | } elseif ($action == 'USER_MODIFY') { 138 | dol_syslog( 139 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 140 | ); 141 | } elseif ($action == 'USER_NEW_PASSWORD') { 142 | dol_syslog( 143 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 144 | ); 145 | } elseif ($action == 'USER_ENABLEDISABLE') { 146 | dol_syslog( 147 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 148 | ); 149 | } elseif ($action == 'USER_DELETE') { 150 | dol_syslog( 151 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 152 | ); 153 | } elseif ($action == 'USER_LOGOUT') { 154 | dol_syslog( 155 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 156 | ); 157 | } elseif ($action == 'USER_SETINGROUP') { 158 | dol_syslog( 159 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 160 | ); 161 | } elseif ($action == 'USER_REMOVEFROMGROUP') { 162 | dol_syslog( 163 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 164 | ); 165 | } 166 | 167 | // Groups 168 | elseif ($action == 'GROUP_CREATE') { 169 | dol_syslog( 170 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 171 | ); 172 | } elseif ($action == 'GROUP_MODIFY') { 173 | dol_syslog( 174 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 175 | ); 176 | } elseif ($action == 'GROUP_DELETE') { 177 | dol_syslog( 178 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 179 | ); 180 | } 181 | 182 | // Companies 183 | elseif ($action == 'COMPANY_CREATE') { 184 | dol_syslog( 185 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 186 | ); 187 | } elseif ($action == 'COMPANY_MODIFY') { 188 | dol_syslog( 189 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 190 | ); 191 | } elseif ($action == 'COMPANY_DELETE') { 192 | dol_syslog( 193 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 194 | ); 195 | } 196 | 197 | // Contacts 198 | elseif ($action == 'CONTACT_CREATE') { 199 | dol_syslog( 200 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 201 | ); 202 | } elseif ($action == 'CONTACT_MODIFY') { 203 | dol_syslog( 204 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 205 | ); 206 | } elseif ($action == 'CONTACT_DELETE') { 207 | dol_syslog( 208 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 209 | ); 210 | } 211 | 212 | // Products 213 | elseif ($action == 'PRODUCT_CREATE') { 214 | dol_syslog( 215 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 216 | ); 217 | } elseif ($action == 'PRODUCT_MODIFY') { 218 | dol_syslog( 219 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 220 | ); 221 | } elseif ($action == 'PRODUCT_DELETE') { 222 | dol_syslog( 223 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 224 | ); 225 | } 226 | 227 | // Customer orders 228 | elseif ($action == 'ORDER_CREATE') { 229 | dol_syslog( 230 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 231 | ); 232 | } elseif ($action == 'ORDER_CLONE') { 233 | dol_syslog( 234 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 235 | ); 236 | } elseif ($action == 'ORDER_VALIDATE') { 237 | dol_syslog( 238 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 239 | ); 240 | } elseif ($action == 'ORDER_DELETE') { 241 | dol_syslog( 242 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 243 | ); 244 | } elseif ($action == 'ORDER_BUILDDOC') { 245 | dol_syslog( 246 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 247 | ); 248 | } elseif ($action == 'ORDER_SENTBYMAIL') { 249 | dol_syslog( 250 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 251 | ); 252 | } elseif ($action == 'LINEORDER_INSERT') { 253 | dol_syslog( 254 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 255 | ); 256 | } elseif ($action == 'LINEORDER_DELETE') { 257 | dol_syslog( 258 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 259 | ); 260 | } 261 | 262 | // Supplier orders 263 | elseif ($action == 'ORDER_SUPPLIER_CREATE') { 264 | dol_syslog( 265 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 266 | ); 267 | } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { 268 | dol_syslog( 269 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 270 | ); 271 | } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { 272 | dol_syslog( 273 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 274 | ); 275 | } elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') { 276 | dol_syslog( 277 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 278 | ); 279 | } 280 | 281 | // Proposals 282 | elseif ($action == 'PROPAL_CREATE') { 283 | dol_syslog( 284 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 285 | ); 286 | } elseif ($action == 'PROPAL_CLONE') { 287 | dol_syslog( 288 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 289 | ); 290 | } elseif ($action == 'PROPAL_MODIFY') { 291 | dol_syslog( 292 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 293 | ); 294 | } elseif ($action == 'PROPAL_VALIDATE') { 295 | dol_syslog( 296 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 297 | ); 298 | } elseif ($action == 'PROPAL_BUILDDOC') { 299 | dol_syslog( 300 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 301 | ); 302 | } elseif ($action == 'PROPAL_SENTBYMAIL') { 303 | dol_syslog( 304 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 305 | ); 306 | } elseif ($action == 'PROPAL_CLOSE_SIGNED') { 307 | dol_syslog( 308 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 309 | ); 310 | } elseif ($action == 'PROPAL_CLOSE_REFUSED') { 311 | dol_syslog( 312 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 313 | ); 314 | } elseif ($action == 'PROPAL_DELETE') { 315 | dol_syslog( 316 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 317 | ); 318 | } elseif ($action == 'LINEPROPAL_INSERT') { 319 | dol_syslog( 320 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 321 | ); 322 | } elseif ($action == 'LINEPROPAL_MODIFY') { 323 | dol_syslog( 324 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 325 | ); 326 | } elseif ($action == 'LINEPROPAL_DELETE') { 327 | dol_syslog( 328 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 329 | ); 330 | } 331 | 332 | // Contracts 333 | elseif ($action == 'CONTRACT_CREATE') { 334 | dol_syslog( 335 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 336 | ); 337 | } elseif ($action == 'CONTRACT_MODIFY') { 338 | dol_syslog( 339 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 340 | ); 341 | } elseif ($action == 'CONTRACT_ACTIVATE') { 342 | dol_syslog( 343 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 344 | ); 345 | } elseif ($action == 'CONTRACT_CANCEL') { 346 | dol_syslog( 347 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 348 | ); 349 | } elseif ($action == 'CONTRACT_CLOSE') { 350 | dol_syslog( 351 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 352 | ); 353 | } elseif ($action == 'CONTRACT_DELETE') { 354 | dol_syslog( 355 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 356 | ); 357 | } 358 | 359 | // Bills 360 | elseif ($action == 'BILL_CREATE') { 361 | dol_syslog( 362 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 363 | ); 364 | } elseif ($action == 'BILL_CLONE') { 365 | dol_syslog( 366 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 367 | ); 368 | } elseif ($action == 'BILL_MODIFY') { 369 | dol_syslog( 370 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 371 | ); 372 | } elseif ($action == 'BILL_VALIDATE') { 373 | dol_syslog( 374 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 375 | ); 376 | } elseif ($action == 'BILL_BUILDDOC') { 377 | dol_syslog( 378 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 379 | ); 380 | } elseif ($action == 'BILL_SENTBYMAIL') { 381 | dol_syslog( 382 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 383 | ); 384 | } elseif ($action == 'BILL_CANCEL') { 385 | dol_syslog( 386 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 387 | ); 388 | } elseif ($action == 'BILL_DELETE') { 389 | dol_syslog( 390 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 391 | ); 392 | } elseif ($action == 'LINEBILL_INSERT') { 393 | dol_syslog( 394 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 395 | ); 396 | } elseif ($action == 'LINEBILL_DELETE') { 397 | dol_syslog( 398 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 399 | ); 400 | } 401 | 402 | // Payments 403 | elseif ($action == 'PAYMENT_CUSTOMER_CREATE') { 404 | dol_syslog( 405 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 406 | ); 407 | } elseif ($action == 'PAYMENT_SUPPLIER_CREATE') { 408 | dol_syslog( 409 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 410 | ); 411 | } elseif ($action == 'PAYMENT_ADD_TO_BANK') { 412 | dol_syslog( 413 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 414 | ); 415 | } elseif ($action == 'PAYMENT_DELETE') { 416 | dol_syslog( 417 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 418 | ); 419 | } 420 | 421 | // Interventions 422 | elseif ($action == 'FICHEINTER_CREATE') { 423 | dol_syslog( 424 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 425 | ); 426 | } elseif ($action == 'FICHEINTER_MODIFY') { 427 | dol_syslog( 428 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 429 | ); 430 | } elseif ($action == 'FICHEINTER_VALIDATE') { 431 | dol_syslog( 432 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 433 | ); 434 | } elseif ($action == 'FICHEINTER_DELETE') { 435 | dol_syslog( 436 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 437 | ); 438 | } 439 | 440 | // Members 441 | elseif ($action == 'MEMBER_CREATE') { 442 | dol_syslog( 443 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 444 | ); 445 | } elseif ($action == 'MEMBER_VALIDATE') { 446 | dol_syslog( 447 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 448 | ); 449 | } elseif ($action == 'MEMBER_SUBSCRIPTION') { 450 | dol_syslog( 451 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 452 | ); 453 | } elseif ($action == 'MEMBER_MODIFY') { 454 | dol_syslog( 455 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 456 | ); 457 | } elseif ($action == 'MEMBER_NEW_PASSWORD') { 458 | dol_syslog( 459 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 460 | ); 461 | } elseif ($action == 'MEMBER_RESILIATE') { 462 | dol_syslog( 463 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 464 | ); 465 | } elseif ($action == 'MEMBER_DELETE') { 466 | dol_syslog( 467 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 468 | ); 469 | } 470 | 471 | // Categories 472 | elseif ($action == 'CATEGORY_CREATE') { 473 | dol_syslog( 474 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 475 | ); 476 | } elseif ($action == 'CATEGORY_MODIFY') { 477 | dol_syslog( 478 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 479 | ); 480 | } elseif ($action == 'CATEGORY_DELETE') { 481 | dol_syslog( 482 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 483 | ); 484 | } 485 | 486 | // Projects 487 | elseif ($action == 'PROJECT_CREATE') { 488 | dol_syslog( 489 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 490 | ); 491 | } elseif ($action == 'PROJECT_MODIFY') { 492 | dol_syslog( 493 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 494 | ); 495 | } elseif ($action == 'PROJECT_DELETE') { 496 | dol_syslog( 497 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 498 | ); 499 | } 500 | 501 | // Project tasks 502 | elseif ($action == 'TASK_CREATE') { 503 | dol_syslog( 504 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 505 | ); 506 | } elseif ($action == 'TASK_MODIFY') { 507 | dol_syslog( 508 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 509 | ); 510 | } elseif ($action == 'TASK_DELETE') { 511 | dol_syslog( 512 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 513 | ); 514 | } 515 | 516 | // Task time spent 517 | elseif ($action == 'TASK_TIMESPENT_CREATE') { 518 | dol_syslog( 519 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 520 | ); 521 | } elseif ($action == 'TASK_TIMESPENT_MODIFY') { 522 | dol_syslog( 523 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 524 | ); 525 | } elseif ($action == 'TASK_TIMESPENT_DELETE') { 526 | dol_syslog( 527 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 528 | ); 529 | } 530 | 531 | // Shipping 532 | elseif ($action == 'SHIPPING_CREATE') { 533 | dol_syslog( 534 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 535 | ); 536 | } elseif ($action == 'SHIPPING_MODIFY') { 537 | dol_syslog( 538 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 539 | ); 540 | } elseif ($action == 'SHIPPING_VALIDATE') { 541 | dol_syslog( 542 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 543 | ); 544 | } elseif ($action == 'SHIPPING_SENTBYMAIL') { 545 | dol_syslog( 546 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 547 | ); 548 | } elseif ($action == 'SHIPPING_DELETE') { 549 | dol_syslog( 550 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 551 | ); 552 | } elseif ($action == 'SHIPPING_BUILDDOC') { 553 | dol_syslog( 554 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 555 | ); 556 | } 557 | 558 | // File 559 | elseif ($action == 'FILE_UPLOAD') { 560 | dol_syslog( 561 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 562 | ); 563 | } elseif ($action == 'FILE_DELETE') { 564 | dol_syslog( 565 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id 566 | ); 567 | } 568 | 569 | return 0; 570 | } 571 | } --------------------------------------------------------------------------------