├── .gitignore ├── img ├── gplv3.png ├── lead.png ├── ATM_logo.jpg ├── unlink.png ├── object_lead.png └── object_module.svg ├── sql ├── update.sql ├── llx_c_lead_type.key.sql ├── llx_lead_extrafields.key.sql ├── llx_c_lead_status.key.sql ├── llx_c_lead_type.sql ├── llx_c_lead_status.sql ├── llx_lead_extrafields.sql ├── llx_lead.key.sql ├── llx_lead.sql └── data.sql ├── backport └── v19 │ └── core │ └── class │ └── commonhookactions.class.php ├── lib ├── php-markdown │ └── License.text └── lead.lib.php ├── lead ├── info.php ├── manage_link.php ├── note.php ├── document.php └── contact.php ├── README.md ├── core ├── modules │ ├── lead │ │ ├── modules_lead.php │ │ ├── mod_lead_simple.php │ │ └── mod_lead_universal.php │ └── modLead.class.php └── boxes │ ├── box_lead.php │ ├── box_lead_current.php │ └── box_lead_late.php ├── admin ├── about.php ├── lead_extrafields.php └── admin_lead.php ├── langs ├── en_US │ └── lead.lang ├── it_IT │ └── lead.lang ├── es_ES │ └── lead.lang └── fr_FR │ └── lead.lang ├── ChangeLog.md ├── tpl └── contacts.tpl.php ├── class ├── techatm.class.php ├── html.formlead.class.php ├── leadstats.class.php └── actions_lead.class.php └── index.php /.gitignore: -------------------------------------------------------------------------------- 1 | .buildpath 2 | .project 3 | .settings/ 4 | -------------------------------------------------------------------------------- /img/gplv3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_lead/main/img/gplv3.png -------------------------------------------------------------------------------- /img/lead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_lead/main/img/lead.png -------------------------------------------------------------------------------- /img/ATM_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_lead/main/img/ATM_logo.jpg -------------------------------------------------------------------------------- /img/unlink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_lead/main/img/unlink.png -------------------------------------------------------------------------------- /img/object_lead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_lead/main/img/object_lead.png -------------------------------------------------------------------------------- /sql/update.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE llx_lead ADD COLUMN note_public text; 2 | ALTER TABLE llx_lead ADD COLUMN note_private text; 3 | ALTER TABLE llx_c_lead_status ADD COLUMN position integer; 4 | ALTER TABLE llx_c_lead_status ADD COLUMN percent double(5,2) AFTER position; 5 | UPDATE llx_c_lead_status SET position='10' , percent='0' WHERE code='PROSP'; 6 | UPDATE llx_c_lead_status SET position='20' , percent='20' WHERE code='QUAL'; 7 | UPDATE llx_c_lead_status SET position='30' , percent='40' WHERE code='PROPO'; 8 | UPDATE llx_c_lead_status SET position='40' , percent='60' WHERE code='NEGO'; 9 | UPDATE llx_c_lead_status SET position='50' , percent='50' WHERE code='PENDING'; 10 | UPDATE llx_c_lead_status SET position='60' , percent='100' WHERE code='WIN'; 11 | UPDATE llx_c_lead_status SET position='70' , percent='0' WHERE code='LOST'; 12 | ALTER TABLE llx_lead ADD COLUMN fk_user_modif integer; 13 | -------------------------------------------------------------------------------- /sql/llx_c_lead_type.key.sql: -------------------------------------------------------------------------------- 1 | -- ======================================================================== 2 | -- Copyright (C) 2015 Florian Henry 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 | ALTER TABLE llx_c_lead_type ADD UNIQUE INDEX uk_c_lead_type_code(code); 20 | -------------------------------------------------------------------------------- /sql/llx_lead_extrafields.key.sql: -------------------------------------------------------------------------------- 1 | -- =================================================================== 2 | -- Copyright (C) 2014 HENRY Florian 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 | 20 | ALTER TABLE llx_lead_extrafields ADD INDEX idxlead_extrafields (fk_object); 21 | -------------------------------------------------------------------------------- /sql/llx_c_lead_status.key.sql: -------------------------------------------------------------------------------- 1 | -- ======================================================================== 2 | -- Copyright (C) 2012 Florian Henry 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 | ALTER TABLE llx_c_lead_status ADD UNIQUE INDEX uk_c_lead_status_code(code); 20 | -------------------------------------------------------------------------------- /sql/llx_c_lead_type.sql: -------------------------------------------------------------------------------- 1 | -- Manage Lead 2 | -- Copyright (C) 2014 Florian HENRY 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 | CREATE TABLE IF NOT EXISTS llx_c_lead_type 18 | ( 19 | rowid integer AUTO_INCREMENT PRIMARY KEY, 20 | code varchar(10) NOT NULL, 21 | label varchar(50), 22 | active tinyint DEFAULT 1 NOT NULL 23 | )ENGINE=innodb; 24 | -------------------------------------------------------------------------------- /sql/llx_c_lead_status.sql: -------------------------------------------------------------------------------- 1 | -- Manage Lead 2 | -- Copyright (C) 2014 Florian HENRY 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 | CREATE TABLE IF NOT EXISTS llx_c_lead_status 18 | ( 19 | rowid integer AUTO_INCREMENT PRIMARY KEY, 20 | code varchar(10) NOT NULL, 21 | label varchar(50), 22 | position integer, 23 | percent double(5,2), 24 | active tinyint DEFAULT 1 NOT NULL 25 | )ENGINE=innodb; 26 | -------------------------------------------------------------------------------- /sql/llx_lead_extrafields.sql: -------------------------------------------------------------------------------- 1 | -- ======================================================================== 2 | -- Copyright (C) 2014 Florian HENRY 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 | CREATE TABLE IF NOT EXISTS llx_lead_extrafields 20 | ( 21 | rowid integer AUTO_INCREMENT PRIMARY KEY, 22 | tms timestamp, 23 | fk_object integer NOT NULL, 24 | import_key varchar(14) -- import key 25 | ) ENGINE=innodb; 26 | 27 | -------------------------------------------------------------------------------- /sql/llx_lead.key.sql: -------------------------------------------------------------------------------- 1 | -- Manage Lead 2 | -- Copyright (C) 2014 Florian HENRY 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 | ALTER TABLE llx_lead ADD INDEX idx_llx_lead_fk_c_status (fk_c_status); 18 | ALTER TABLE llx_lead ADD CONSTRAINT llx_lead_ibfk_1 FOREIGN KEY (fk_c_status) REFERENCES llx_c_lead_status (rowid); 19 | 20 | ALTER TABLE llx_lead ADD INDEX idx_llx_lead_fk_c_type (fk_c_type); 21 | ALTER TABLE llx_lead ADD CONSTRAINT llx_lead_ibfk_2 FOREIGN KEY (fk_c_type) REFERENCES llx_c_lead_type (rowid); 22 | 23 | ALTER TABLE llx_lead ADD INDEX idx_llx_lead_fk_soc (fk_soc); 24 | ALTER TABLE llx_lead ADD CONSTRAINT llx_lead_ibfk_3 FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); -------------------------------------------------------------------------------- /sql/llx_lead.sql: -------------------------------------------------------------------------------- 1 | -- Manage Lead 2 | -- Copyright (C) 2014 Florian HENRY 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 | CREATE TABLE IF NOT EXISTS llx_lead ( 19 | rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, 20 | ref varchar(50) NOT NULL, 21 | entity integer NOT NULL DEFAULT 0, 22 | ref_ext text, 23 | ref_int text, 24 | fk_soc integer NOT NULL, 25 | fk_c_status integer NOT NULL, 26 | fk_c_type integer NOT NULL, 27 | date_closure datetime NOT NULL, 28 | amount_prosp double(24,8) NOT NULL, 29 | fk_user_resp integer NOT NULL, 30 | description text, 31 | note_public text, 32 | note_private text, 33 | fk_user_author integer NOT NULL, 34 | fk_user_modif integer NOT NULL DEFAULT 0, 35 | datec datetime NOT NULL, 36 | fk_user_mod integer NOT NULL, 37 | tms timestamp NOT NULL 38 | )ENGINE=InnoDB; 39 | 40 | -------------------------------------------------------------------------------- /backport/v19/core/class/commonhookactions.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 htdocs/core/class/commonhookactions.class.php 20 | * \ingroup core 21 | * \brief File of parent class of all other hook actions classes 22 | */ 23 | 24 | namespace lead; 25 | 26 | if(file_exists(DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php')) { 27 | require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php'; 28 | /** 29 | * Parent class of all other hook actions classes 30 | */ 31 | abstract class RetroCompatCommonHookActions extends \CommonHookActions { 32 | 33 | } 34 | } 35 | else { 36 | /** 37 | * Parent class of all other hook actions classes 38 | */ 39 | abstract class RetroCompatCommonHookActions { 40 | /** 41 | * @var string String of results. 42 | */ 43 | public $resprints; 44 | 45 | /** 46 | * @var array Array of results. 47 | */ 48 | public $results = array(); 49 | } 50 | } -------------------------------------------------------------------------------- /lib/php-markdown/License.text: -------------------------------------------------------------------------------- 1 | PHP Markdown 2 | Copyright (c) 2004-2013 Michel Fortin 3 | 4 | All rights reserved. 5 | 6 | Based on Markdown 7 | Copyright (c) 2003-2006 John Gruber 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are 13 | met: 14 | 15 | * Redistributions of source code must retain the above copyright notice, 16 | this list of conditions and the following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | * Neither the name "Markdown" nor the names of its contributors may 23 | be used to endorse or promote products derived from this software 24 | without specific prior written permission. 25 | 26 | This software is provided by the copyright holders and contributors "as 27 | is" and any express or implied warranties, including, but not limited 28 | to, the implied warranties of merchantability and fitness for a 29 | particular purpose are disclaimed. In no event shall the copyright owner 30 | or contributors be liable for any direct, indirect, incidental, special, 31 | exemplary, or consequential damages (including, but not limited to, 32 | procurement of substitute goods or services; loss of use, data, or 33 | profits; or business interruption) however caused and on any theory of 34 | liability, whether in contract, strict liability, or tort (including 35 | negligence or otherwise) arising in any way out of the use of this 36 | software, even if advised of the possibility of such damage. 37 | -------------------------------------------------------------------------------- /lead/info.php: -------------------------------------------------------------------------------- 1 | 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 lead/lead/info.php 21 | * \ingroup lead 22 | * \brief info of lead 23 | */ 24 | $res = @include '../../main.inc.php'; // For root directory 25 | if (! $res) 26 | $res = @include '../../../main.inc.php'; // For "custom" directory 27 | if (! $res) 28 | die("Include of main fails"); 29 | 30 | require_once '../class/lead.class.php'; 31 | require_once '../lib/lead.lib.php'; 32 | require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; 33 | 34 | // Security check 35 | if (! $user->hasRight('lead', 'read')) 36 | accessforbidden(); 37 | 38 | $id = GETPOST('id', 'int'); 39 | 40 | /* 41 | * View 42 | */ 43 | 44 | llxHeader('', $langs->trans("LeadInfo")); 45 | 46 | $object = new Lead($db); 47 | $object->info($id); 48 | 49 | $head = lead_prepare_head($object); 50 | 51 | dol_fiche_head($head, 'info', $langs->trans("LeadLead"), 0, 'bill'); 52 | 53 | print '
'; 54 | dol_print_object_info($object); 55 | print '
'; 56 | print ''; 57 | 58 | dol_fiche_end(); 59 | llxFooter(); 60 | $db->close(); 61 | -------------------------------------------------------------------------------- /sql/data.sql: -------------------------------------------------------------------------------- 1 | -- Manage Lead 2 | -- Copyright (C) 2014 Florian HENRY 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 | INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (1,'PROSP' ,'Prospection', 10, 0,1); 18 | INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (2,'QUAL' ,'Chiffrage',20, 20,1); 19 | INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (3,'PROPO' ,'Proposition', 30, 40,1); 20 | INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (4,'NEGO' ,'Négociation', 40, 60,1); 21 | INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (5,'PENDING','Reconduction', 50, 50,0); 22 | INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (6,'WON' ,'Gagné', 60, 100,1); 23 | INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (7,'LOST' ,'Perdu', 70, 0,1); 24 | 25 | INSERT INTO llx_c_lead_type(rowid,code,label,active) VALUES (1,'SUPP','Support',1); 26 | INSERT INTO llx_c_lead_type(rowid,code,label,active) VALUES (2,'TRAIN','Formation',1); 27 | INSERT INTO llx_c_lead_type(rowid,code,label,active) VALUES (3,'ADVI','Conseil',1); 28 | 29 | INSERT INTO llx_c_type_contact(rowid, element, source, code, libelle, active, module) VALUES (1031111,'lead','internal','ORIG','Commercial à l''origine de l''affaire','1',null); 30 | INSERT INTO llx_c_type_contact(rowid, element, source, code, libelle, active, module) VALUES (1031112,'lead','external','SALESREPFOLL','Responsable suivi du paiement','1',null); 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lead/manage_link.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 lead/lead/manage_link.php 20 | * \ingroup lead 21 | * \brief lead manage link 22 | */ 23 | $res = @include '../../main.inc.php'; // For root directory 24 | if (! $res) 25 | $res = @include '../../../main.inc.php'; // For "custom" directory 26 | if (! $res) 27 | die("Include of main fails"); 28 | 29 | dol_include_once('/lead/class/lead.class.php'); 30 | 31 | $object = new Lead($db); 32 | 33 | /* 34 | * Actions 35 | */ 36 | 37 | $tablename = GETPOST("tablename",'alpha'); 38 | $leadid = GETPOST("leadid",'int'); 39 | $elementselectid = GETPOST("elementselect",'int'); 40 | $redirect = GETPOST('redirect', 'alpha'); 41 | $action=GETPOST('action','alpha'); 42 | 43 | if (empty($leadid) || $leadid==-1) { 44 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lead")), null, 'errors'); 45 | $error ++; 46 | } 47 | 48 | if (! $error) { 49 | $result = $object->fetch($leadid); 50 | if ($result < 0) { 51 | setEventMessages(null, $object->errors, 'errors'); 52 | $error ++; 53 | } 54 | } 55 | if (! $error) { 56 | if ($action == 'link') { 57 | 58 | $result = $object->add_object_linked($tablename, $elementselectid); 59 | if ($result < 0) { 60 | setEventMessages(null, $object->errors, 'errors'); 61 | } 62 | } 63 | if ($action == 'unlink') { 64 | $sourceid = GETPOST('sourceid','int'); 65 | $sourcetype = GETPOST('sourcetype','alpha'); 66 | 67 | $result = $object->deleteObjectLinked($sourceid, $sourcetype); 68 | if ($result < 0) { 69 | setEventMessages(null, $object->errors, 'errors'); 70 | } 71 | } 72 | } 73 | 74 | header("Location:" . $redirect); 75 | exit(); -------------------------------------------------------------------------------- /img/object_module.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | 20 | 21 | 22 | 40 | 45 | 68 | 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LEAD 2 | ========= 3 | 4 | Module LEAD 5 | 6 | Licence 7 | ------- 8 | 9 | GPLv3 or (at your option) any later version. 10 | 11 | See COPYING for more information. 12 | 13 | INSTALL 14 | ------- 15 | 16 | - Make sure Dolibarr (v >= 3.8) is already installed and configured on your server. 17 | 18 | - In your Dolibarr installation directory, edit the htdocs/conf/conf.php file 19 | 20 | - Find the following lines: 21 | 22 | //$=dolibarr_main_url_root_alt ... 23 | //$=dolibarr_main_document_root_alt ... 24 | 25 | - Uncomment these lines (delete the leading "//") and assign a sensible value according to your Dolibarr installation 26 | 27 | For example : 28 | 29 | - UNIX: 30 | 31 | $dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs'; 32 | $dolibarr_main_document_root = '/var/www/Dolibarr/htdocs'; 33 | $dolibarr_main_url_root_alt = '/custom'; 34 | $dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom'; 35 | 36 | - Windows: 37 | 38 | $dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs'; 39 | $dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs'; 40 | $dolibarr_main_url_root_alt = '/custom'; 41 | $dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom'; 42 | 43 | 44 | - Clone the repository in $dolibarr\_main\_document\_root\_alt/mymodule 45 | 46 | *(You may have to create the custom directory first if it doesn't exist yet.)* 47 | 48 | ``` 49 | git clone --recursive https://github.com/ATM-Consulting/dolibarr_module_lead.git 50 | ``` 51 | 52 | **The template now uses a git submodule to fetch the PHP Markdown library.** 53 | 54 | If your git version is less than 1.6.5, the --recursive parameter won't work. 55 | 56 | Please use this instead to fetch the latest version: 57 | 58 | git clone https://github.com/ATM-Consulting/dolibarr_module_lead.git lead 59 | cd lead 60 | git submodule update --init 61 | php composer.php install 62 | php composer.php update 63 | 64 | - From your browser: 65 | 66 | - log in as a Dolibarr administrator 67 | 68 | - go to "Setup" -> "Modules" 69 | 70 | - the module is under tabs "module interface" 71 | 72 | - Find module Lead and activate it 73 | 74 | - Go to module configuration and set it up 75 | 76 | 77 | Contributions 78 | ------------- 79 | 80 | Feel free to contribute and report defects at 81 | 82 | Other Licences 83 | -------------- 84 | 85 | Uses [Michel Fortin's PHP Markdown](http://michelf.ca/projets/php-markdown/) Licensed under BSD to display this README in the module's about page. 86 | -------------------------------------------------------------------------------- /core/modules/lead/modules_lead.php: -------------------------------------------------------------------------------- 1 | 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 lead/core/modules/lead/modules_lead.php 21 | * \ingroup businesscase 22 | * \brief businesscase for numbering businesscase 23 | */ 24 | 25 | /** 26 | * Classe mere des modeles de numerotation des references de lead 27 | */ 28 | abstract class ModeleNumRefLead 29 | { 30 | 31 | public $error = ''; 32 | public $version = ''; 33 | 34 | /** 35 | * Return if a module can be used or not 36 | * 37 | * @return boolean true if module can be used 38 | */ 39 | function isEnabled() 40 | { 41 | return true; 42 | } 43 | 44 | /** 45 | * Renvoi la description par defaut du modele de numerotation 46 | * 47 | * @return string Texte descripif 48 | */ 49 | function info() 50 | { 51 | global $langs; 52 | $langs->load("lead@lead"); 53 | return $langs->trans("NoDescription"); 54 | } 55 | 56 | /** 57 | * Renvoi un exemple de numerotation 58 | * 59 | * @return string Example 60 | */ 61 | function getExample() 62 | { 63 | global $langs; 64 | $langs->load("lead"); 65 | return $langs->trans("NoExample"); 66 | } 67 | 68 | /** 69 | * Test si les numeros deja en vigueur dans la base ne provoquent pas de 70 | * de conflits qui empechera cette numerotation de fonctionner. 71 | * 72 | * @return boolean false si conflit, true si ok 73 | */ 74 | function canBeActivated() 75 | { 76 | return true; 77 | } 78 | 79 | /** 80 | * Renvoi prochaine valeur attribuee 81 | * 82 | * @param int $fk_user User creating 83 | * @param Societe $objsoc party 84 | * @param Lead $lead Lead 85 | * @return string Valeur 86 | */ 87 | function getNextValue($fk_user, $objsoc, $lead) 88 | { 89 | global $langs; 90 | return $langs->trans("NotAvailable"); 91 | } 92 | 93 | /** 94 | * Module version 95 | * 96 | * @return string The module version 97 | */ 98 | function getVersion() 99 | { 100 | global $langs; 101 | $langs->load("admin"); 102 | 103 | switch($this->version) { 104 | case 'development': 105 | return $langs->trans("VersionDevelopment"); 106 | break; 107 | case 'experimental': 108 | return $langs->trans("VersionExperimental"); 109 | break; 110 | case 'dolibarr': 111 | return DOL_VERSION; 112 | break; 113 | default: 114 | return $langs->trans("NotAvailable"); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /admin/about.php: -------------------------------------------------------------------------------- 1 | 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 lead 22 | * \brief This file is an example about page 23 | * Put some comments here 24 | */ 25 | 26 | // Load Dolibarr environment 27 | $res = 0; 28 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 29 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 30 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 31 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 32 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 33 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 34 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 35 | // Try main.inc.php using relative path 36 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 37 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 38 | if (!$res) die("Include of main fails"); 39 | 40 | // Libraries 41 | require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; 42 | require_once '../lib/lead.lib.php'; 43 | 44 | dol_include_once('/lead/lib/php-markdown/markdown.php'); 45 | 46 | // require_once "../class/myclass.class.php"; 47 | // Translations 48 | $langs->load("lead@lead"); 49 | 50 | // Access control 51 | if (!$user->admin) accessforbidden(); 52 | 53 | // Parameters 54 | $action = GETPOST('action', 'aZ09'); 55 | $backtopage = GETPOST('backtopage', 'alpha'); 56 | 57 | 58 | /* 59 | * Actions 60 | */ 61 | 62 | /* 63 | * View 64 | */ 65 | $page_name = "LeadAbout"; 66 | llxHeader('', $langs->trans($page_name)); 67 | 68 | // Subheader 69 | $linkback = ''.$langs->trans("BackToModuleList").''; 70 | 71 | print load_fiche_titre($langs->trans($page_name), $linkback, 'tools'); 72 | 73 | // Configuration header 74 | $head = leadAdminPrepareHead(); 75 | print dol_get_fiche_head($head, 'about', $langs->trans("Module103111Name"), 0, 'lead@lead'); 76 | 77 | require_once __DIR__ . '/../class/techatm.class.php'; 78 | $techATM = new \lead\TechATM($db); 79 | 80 | require_once __DIR__ . '/../core/modules/modLead.class.php'; 81 | $moduleDescriptor = new modLead($db); 82 | 83 | print $techATM->getAboutPage($moduleDescriptor); 84 | 85 | // Page end 86 | print dol_get_fiche_end(); 87 | llxFooter(); 88 | 89 | $db->close(); 90 | -------------------------------------------------------------------------------- /lead/note.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2008 Laurent Destailleur 4 | * Copyright (C) 2005-2012 Regis Houssin 5 | * Copyright (C) 2015 Florian Henry 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | $res = @include '../../main.inc.php'; // For root directory 22 | if (! $res) 23 | $res = @include '../../../main.inc.php'; // For "custom" directory 24 | if (! $res) 25 | die("Include of main fails"); 26 | 27 | require_once '../class/lead.class.php'; 28 | require_once '../class/html.formlead.class.php'; 29 | require_once '../lib/lead.lib.php'; 30 | 31 | $langs->load('lead@lead'); 32 | 33 | $id=GETPOST('id','int'); 34 | $ref=GETPOST('ref','alpha'); 35 | $action=GETPOST('action','alpha'); 36 | 37 | // Security check 38 | if (! $user->hasRight('lead', 'read')) 39 | accessforbidden(); 40 | 41 | $object = new Lead($db); 42 | if ($id > 0) { 43 | $ret = $object->fetch($id); 44 | if ($ret < 0) 45 | setEventMessage($object->error, 'errors'); 46 | if ($ret > 0) 47 | $ret = $object->fetch_thirdparty(); 48 | if ($ret < 0) 49 | setEventMessage($object->error, 'errors'); 50 | } 51 | 52 | $permissionnote=$user->hasRight('lead', 'write'); // Used by the include of actions_setnotes.inc.php 53 | $permission=$user->hasRight('lead', 'write'); 54 | 55 | /* 56 | * Actions 57 | */ 58 | 59 | include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once 60 | 61 | 62 | 63 | /* 64 | * View 65 | */ 66 | 67 | llxHeader(); 68 | 69 | $form = new Form($db); 70 | $formlead = new FormLead($db); 71 | 72 | if ($id > 0) 73 | { 74 | 75 | $head = lead_prepare_head($object); 76 | dol_fiche_head($head, 'note', $langs->trans('Module103111Name'), 0, dol_buildpath('/lead/img/object_lead.png', 1), 1); 77 | 78 | 79 | print ''; 80 | 81 | if (is_object($object->thirdparty)){ 82 | $urlBackToList = dol_buildpath('/lead/lead/list.php?socid=' . $object->thirdparty->id, 1); 83 | }else{ 84 | $urlBackToList = dol_buildpath('/lead/lead/list.php', 1); 85 | } 86 | $linkback = '' . $langs->trans("BackToList") . ''; 87 | 88 | print ''; 89 | print ''; 92 | print ''; 95 | print ''; 96 | 97 | print ''; 98 | print ''; 101 | print ''; 104 | print ''; 105 | print "
'; 90 | print $langs->trans('Ref'); 91 | print ''; 93 | print $formlead->showrefnav_custom($object, 'id', $linkback, 1, 'rowid', 'ref', ''); 94 | print '
'; 99 | print $langs->trans('LeadRefInt'); 100 | print ''; 102 | print $object->ref_int; 103 | print '
\n"; 106 | 107 | print '
'; 108 | 109 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; 110 | 111 | dol_fiche_end(); 112 | } 113 | 114 | 115 | llxFooter(); 116 | 117 | $db->close(); 118 | -------------------------------------------------------------------------------- /core/modules/lead/mod_lead_simple.php: -------------------------------------------------------------------------------- 1 | 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 lead/core/modules/lead/mod_lead_simple.php 21 | * \ingroup lead 22 | * \brief File with class to manage the numbering module Simple for lead references 23 | */ 24 | dol_include_once('/lead/core/modules/lead/modules_lead.php'); 25 | 26 | /** 27 | * Class to manage the numbering module Simple for lead references 28 | */ 29 | class mod_lead_simple extends ModeleNumRefLead 30 | { 31 | 32 | var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' 33 | var $prefix = 'LEA-'; 34 | 35 | var $error = ''; 36 | 37 | var $nom = "Simple"; 38 | 39 | /** 40 | * Return description of numbering module 41 | * 42 | * @return string Text with description 43 | */ 44 | function info() 45 | { 46 | global $langs; 47 | return $langs->trans("LeadSimpleNumRefModelDesc", $this->prefix); 48 | } 49 | 50 | /** 51 | * Return an example of numbering module values 52 | * 53 | * @return string Example 54 | */ 55 | function getExample() 56 | { 57 | return $this->prefix . "1402-0001"; 58 | } 59 | 60 | /** 61 | * Test si les numeros deja en vigueur dans la base ne provoquent pas de 62 | * de conflits qui empechera cette numerotation de fonctionner. 63 | * 64 | * @return boolean false si conflit, true si ok 65 | */ 66 | function canBeActivated() 67 | { 68 | global $conf, $langs; 69 | 70 | $coyymm = ''; 71 | $max = ''; 72 | 73 | $posindice = 8; 74 | $sql = "SELECT MAX(SUBSTRING(ref FROM " . $posindice . ")) as max"; 75 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead"; 76 | $sql .= " WHERE ref LIKE '" . $this->prefix . "____-%'"; 77 | // $sql.= " AND entity = ".$conf->entity; 78 | $resql = $db->query($sql); 79 | if ($resql) { 80 | $row = $db->fetch_row($resql); 81 | if ($row) { 82 | $coyymm = substr($row[0], 0, 6); 83 | $max = $row[0]; 84 | } 85 | } 86 | if (! $coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) { 87 | return true; 88 | } else { 89 | $langs->load("errors"); 90 | $this->error = $langs->trans('ErrorNumRefModel', $max); 91 | return false; 92 | } 93 | } 94 | 95 | /** 96 | * Return next value 97 | * 98 | * @param int $fk_user User creating 99 | * @param Societe $objsoc Party 100 | * @param Lead $lead Lead 101 | * @return string Valeur 102 | */ 103 | function getNextValue($fk_user, $objsoc, $lead) 104 | { 105 | global $db, $conf; 106 | 107 | // D'abord on recupere la valeur max 108 | $posindice = 10; 109 | $sql = "SELECT MAX(SUBSTRING(ref FROM " . $posindice . ")) as max"; 110 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead"; 111 | $sql .= " WHERE ref like '" . $this->prefix . "____-%'"; 112 | 113 | $resql = $db->query($sql); 114 | if ($resql) { 115 | $obj = $db->fetch_object($resql); 116 | if ($obj) 117 | $max = intval($obj->max); 118 | else 119 | $max = 0; 120 | } else { 121 | dol_syslog("mod_lead_simple::getNextValue sql=" . $sql); 122 | return - 1; 123 | } 124 | 125 | $date = empty($lead->datec) ? dol_now() : $lead->datec; 126 | 127 | // $yymm = strftime("%y%m",time()); 128 | $yymm = strftime("%y%m", $date); 129 | $num = sprintf("%04s", $max + 1); 130 | 131 | dol_syslog("mod_lead_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num); 132 | return $this->prefix . $yymm . "-" . $num; 133 | } 134 | } -------------------------------------------------------------------------------- /core/modules/lead/mod_lead_universal.php: -------------------------------------------------------------------------------- 1 | 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 lead/core/modules/lead/mod_lead_universal.php 21 | * \ingroup businesscase 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de Lead Universal 23 | */ 24 | dol_include_once('/lead/core/modules/lead/modules_lead.php'); 25 | 26 | /** 27 | * Classe du modele de numerotation de reference de projet Universal 28 | */ 29 | class mod_lead_universal extends ModeleNumRefLead 30 | { 31 | 32 | var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' 33 | var $error = ''; 34 | 35 | var $nom = 'Universal'; 36 | 37 | /** 38 | * Renvoi la description du modele de numerotation 39 | * 40 | * @return string Texte descripif 41 | */ 42 | function info() 43 | { 44 | global $conf, $db, $langs; 45 | 46 | $langs->load("lead@lead"); 47 | $langs->load("admin"); 48 | 49 | $form = new Form($db); 50 | 51 | $texte = $langs->trans('GenericNumRefModelDesc') . "
\n"; 52 | $texte .= '
'; 53 | $texte .= ''; 54 | $texte .= ''; 55 | $texte .= ''; 56 | $texte .= ''; 57 | 58 | $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("LeadLead"), $langs->transnoentities("LeadLead")); 59 | $tooltip .= $langs->trans("GenericMaskCodes2"); 60 | $tooltip .= $langs->trans("GenericMaskCodes3"); 61 | $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("LeadLead"), $langs->transnoentities("LeadLead")); 62 | $tooltip .= $langs->trans("GenericMaskCodes5"); 63 | 64 | // Parametrage du prefix 65 | $texte .= ''; 66 | $texte .= ''; 67 | 68 | $texte .= ''; 69 | 70 | $texte .= ''; 71 | 72 | $texte .= '
' . $langs->trans("Mask") . ':' . $form->textwithpicto('', $tooltip, 1, 1) . ' 
'; 73 | $texte .= '
'; 74 | 75 | return $texte; 76 | } 77 | 78 | /** 79 | * Renvoi un exemple de numerotation 80 | * 81 | * @return string Example 82 | */ 83 | function getExample() 84 | { 85 | global $conf, $langs, $mysoc, $user; 86 | 87 | // $old_code_client = $mysoc->code_client; 88 | // $mysoc->code_client='CCCCCCCCCC'; 89 | $numExample = $this->getNextValue($user->id, $mysoc, null); 90 | // $mysoc->code_client=$old_code_client; 91 | 92 | if (! $numExample) { 93 | $numExample = $langs->trans('NotConfigured'); 94 | } 95 | return $numExample; 96 | } 97 | 98 | /** 99 | * Return next value 100 | * 101 | * @param int $fk_user User creating 102 | * @param Societe $objsoc Party 103 | * @param Lead $lead Lead 104 | * @return string Valeur 105 | */ 106 | function getNextValue($fk_user, $objsoc, $lead) 107 | { 108 | global $db, $conf; 109 | 110 | require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; 111 | 112 | // On defini critere recherche compteur 113 | $mask = getDolGlobalString('LEAD_UNIVERSAL_MASK'); 114 | 115 | if (! $mask) { 116 | $this->error = 'NotConfigured'; 117 | return 0; 118 | } 119 | 120 | $numFinal = get_next_value($db, $mask, 'lead', 'ref', '', $objsoc->code_client, dol_now()); 121 | 122 | return $numFinal; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /core/boxes/box_lead.php: -------------------------------------------------------------------------------- 1 | 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 mymodule 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 box_lead extends ModeleBoxes 31 | { 32 | 33 | public $boxcode = "lead"; 34 | 35 | public $boximg = "lead@lead"; 36 | 37 | public $boxlabel; 38 | 39 | public $depends = array( 40 | "lead" 41 | ); 42 | 43 | public $db; 44 | 45 | public $param; 46 | 47 | public $info_box_head = array(); 48 | 49 | public $info_box_contents = array(); 50 | 51 | /** 52 | * Constructor 53 | */ 54 | public function __construct() 55 | { 56 | global $langs, $user; 57 | $langs->load("boxes"); 58 | $langs->load("lead@lead"); 59 | 60 | $this->boxlabel = $langs->transnoentitiesnoconv("LeadLate"); 61 | $this->hidden=! ($user->hasRight('lead', 'read')); 62 | } 63 | 64 | /** 65 | * Load data into info_box_contents array to show array later. 66 | * 67 | * @param int $max of records to load 68 | * 69 | * @return void 70 | */ 71 | public function loadBox($max = 5) 72 | { 73 | global $conf, $user, $langs, $db; 74 | 75 | $this->max = $max; 76 | 77 | dol_include_once('/lead/class/lead.class.php'); 78 | 79 | $lead = new Lead($db); 80 | 81 | //[COMPAT v17] Pas besoin de versioncompare, le nom de la fonction ayant été changé pour la nouvelle realease du module 82 | $lead->fetchAll('DESC', 't.date_closure', $max, 0, array( 83 | 't.date_closure<' => dol_now() 84 | )); 85 | 86 | $text = $langs->trans("LeadLate", $max); 87 | $this->info_box_head = array( 88 | 'text' => $text, 89 | 'limit' => dol_strlen($text) 90 | ); 91 | 92 | $i = 0; 93 | foreach ($lead->lines as $line) { 94 | // FIXME: line is an array, not an object 95 | $line->fetch_thirdparty(); 96 | // Ref 97 | $this->info_box_contents[$i][0] = array( 98 | 'td' => 'align="left" width="16"', 99 | 'logo' => $this->boximg, 100 | 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id 101 | ); 102 | 103 | $this->info_box_contents[$i][1] = array( 104 | 'td' => 'align="left"', 105 | 'text' => $line->ref, 106 | 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id 107 | ); 108 | 109 | $this->info_box_contents[$i][2] = array( 110 | 'td' => 'align="left" width="16"', 111 | 'logo' => 'company', 112 | 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc 113 | ); 114 | 115 | $this->info_box_contents[$i][3] = array( 116 | 'td' => 'align="left"', 117 | 'text' => dol_trunc($line->thirdparty->name, 40), 118 | 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc 119 | ); 120 | 121 | // Amount Guess 122 | 123 | $this->info_box_contents[$i][4] = array( 124 | 'td' => 'align="left"', 125 | 'text' => price($line->amount_prosp, 'HTML') . $langs->getCurrencySymbol($conf->currency) 126 | ); 127 | 128 | // Amount real 129 | $this->info_box_contents[$i][5] = array( 130 | 'td' => 'align="left"', 131 | 'text' => $line->getRealAmount() . $langs->getCurrencySymbol($conf->currency) 132 | ); 133 | 134 | $i ++; 135 | } 136 | } 137 | 138 | /** 139 | * Method to show box 140 | * 141 | * @param array $head with properties of box title 142 | * @param array $contents with properties of box lines 143 | * @param integer $nooutput nooutput 144 | * @return void 145 | */ 146 | public function showBox($head = null, $contents = null, $nooutput = 0) { 147 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /core/boxes/box_lead_current.php: -------------------------------------------------------------------------------- 1 | 4 | * Copyright (C) 2015 Raphaël Doursenaud 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /** 21 | * \file core/boxes/box_lead_current.php 22 | * \ingroup lead 23 | * \brief Current leads box 24 | */ 25 | include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; 26 | 27 | /** 28 | * Class to manage the box 29 | */ 30 | class box_lead_current extends ModeleBoxes 31 | { 32 | 33 | public $boxcode = "lead_current"; 34 | 35 | public $boximg = "lead@lead"; 36 | 37 | public $boxlabel; 38 | 39 | public $depends = array( 40 | "lead" 41 | ); 42 | 43 | public $db; 44 | 45 | public $param; 46 | 47 | public $info_box_head = array(); 48 | 49 | public $info_box_contents = array(); 50 | 51 | /** 52 | * Constructor 53 | */ 54 | public function __construct() 55 | { 56 | global $langs, $user; 57 | $langs->load("boxes"); 58 | $langs->load("lead@lead"); 59 | 60 | $this->boxlabel = $langs->transnoentitiesnoconv("LeadList"); 61 | $this->hidden=! ($user->hasRight('lead', 'read')); 62 | } 63 | 64 | /** 65 | * Load data into info_box_contents array to show array later. 66 | * 67 | * @param int $max of records to load 68 | * @return void 69 | */ 70 | public function loadBox($max = 5) 71 | { 72 | global $conf, $user, $langs, $db; 73 | 74 | $this->max = $max; 75 | 76 | dol_include_once('/lead/class/lead.class.php'); 77 | 78 | $lead = new Lead($db); 79 | 80 | //[COMPAT v17] Pas besoin de versioncompare, le nom de la fonction ayant été changé pour la nouvelle realease du module 81 | $lead->fetchAll('DESC', 't.ref', $max, 0); 82 | 83 | $text = $langs->trans("LeadList"); 84 | $text .= " (" . $langs->trans("LastN", $max) . ")"; 85 | $this->info_box_head = array( 86 | 'text' => $text, 87 | 'limit' => dol_strlen($text) 88 | ); 89 | 90 | $i = 0; 91 | foreach ($lead->lines as $line) { 92 | // FIXME: line is an array, not an object 93 | $line->fetch_thirdparty(); 94 | // Ref 95 | $this->info_box_contents[$i][0] = array( 96 | 'td' => 'align="left" width="16"', 97 | 'logo' => $this->boximg, 98 | 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id 99 | ); 100 | 101 | $this->info_box_contents[$i][1] = array( 102 | 'td' => 'align="left"', 103 | 'text' => $line->ref, 104 | 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id 105 | ); 106 | 107 | $this->info_box_contents[$i][2] = array( 108 | 'td' => 'align="left" width="16"', 109 | 'logo' => 'company', 110 | 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $line->fk_soc 111 | ); 112 | 113 | $this->info_box_contents[$i][3] = array( 114 | 'td' => 'align="left"', 115 | 'text' => dol_trunc($line->thirdparty->name, 40), 116 | 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $line->fk_soc 117 | ); 118 | 119 | // Amount Guess 120 | 121 | $this->info_box_contents[$i][4] = array( 122 | 'td' => 'align="left"', 123 | 'text' => price($line->amount_prosp, 'HTML') . $langs->getCurrencySymbol($conf->currency) 124 | ); 125 | 126 | // Amount real 127 | $this->info_box_contents[$i][5] = array( 128 | 'td' => 'align="left"', 129 | 'text' => $line->getRealAmount() . $langs->getCurrencySymbol($conf->currency) 130 | ); 131 | 132 | $i ++; 133 | } 134 | } 135 | 136 | /** 137 | * Method to show box 138 | * 139 | * @param array $head with properties of box title 140 | * @param array $contents with properties of box lines 141 | * @param integer $nooutput nooutput 142 | * @return void 143 | */ 144 | public function showBox($head = null, $contents = null, $nooutput = 0) { 145 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /core/boxes/box_lead_late.php: -------------------------------------------------------------------------------- 1 | 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/box_lead_late.php 21 | * \ingroup lead 22 | * \brief Late leads box 23 | */ 24 | include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; 25 | 26 | /** 27 | * Class to manage the box 28 | */ 29 | class box_lead_late extends ModeleBoxes 30 | { 31 | 32 | public $boxcode = "lead_late"; 33 | 34 | public $boximg = "lead@lead"; 35 | 36 | public $boxlabel; 37 | 38 | public $depends = array( 39 | "lead" 40 | ); 41 | 42 | public $db; 43 | 44 | public $param; 45 | 46 | public $info_box_head = array(); 47 | 48 | public $info_box_contents = array(); 49 | 50 | /** 51 | * Constructor 52 | */ 53 | public function __construct() 54 | { 55 | global $langs, $user; 56 | $langs->load("boxes"); 57 | $langs->load("lead@lead"); 58 | 59 | $this->boxlabel = $langs->transnoentitiesnoconv("LeadListLate"); 60 | $this->hidden=! ($user->hasRight('lead', 'read')); 61 | } 62 | 63 | /** 64 | * Load data into info_box_contents array to show array later. 65 | * 66 | * @param int $max Max number of records to load 67 | * @return void 68 | */ 69 | public function loadBox($max = 5) 70 | { 71 | global $conf, $user, $langs, $db; 72 | 73 | $this->max = $max; 74 | 75 | dol_include_once('/lead/class/lead.class.php'); 76 | 77 | $lead = new Lead($db); 78 | 79 | //[COMPAT v17] Pas besoin de versioncompare, le nom de la fonction ayant été changé pour la nouvelle realease du module 80 | $lead->fetchAll('DESC', 't.date_closure', $max, 0, array( 81 | 't.date_closure<' => dol_now() 82 | )); 83 | 84 | $text = $langs->trans("LeadListLate", $max); 85 | $text .= " (" . $langs->trans("LastN", $max) . ")"; 86 | $this->info_box_head = array( 87 | 'text' => $text, 88 | 'limit' => dol_strlen($text) 89 | ); 90 | 91 | $i = 0; 92 | foreach ($lead->lines as $line) { 93 | /** 94 | * @var Lead $line 95 | */ 96 | $line->fetch_thirdparty(); 97 | // Ref 98 | $this->info_box_contents[$i][0] = array( 99 | 'td' => 'align="left" width="16"', 100 | 'logo' => $this->boximg, 101 | 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id 102 | ); 103 | 104 | $this->info_box_contents[$i][1] = array( 105 | 'td' => 'align="left"', 106 | 'text' => $line->ref, 107 | 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id 108 | ); 109 | 110 | $this->info_box_contents[$i][2] = array( 111 | 'td' => 'align="left" width="16"', 112 | 'logo' => 'company', 113 | 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $line->fk_soc 114 | ); 115 | 116 | $this->info_box_contents[$i][3] = array( 117 | 'td' => 'align="left"', 118 | 'text' => dol_trunc($line->thirdparty->name, 40), 119 | 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $line->fk_soc 120 | ); 121 | 122 | // Amount Guess 123 | 124 | $this->info_box_contents[$i][4] = array( 125 | 'td' => 'align="left"', 126 | 'text' => price($line->amount_prosp, 'HTML') . $langs->getCurrencySymbol($conf->currency) 127 | ); 128 | 129 | // Amount real 130 | $this->info_box_contents[$i][5] = array( 131 | 'td' => 'align="left"', 132 | 'text' => $line->getRealAmount() . $langs->getCurrencySymbol($conf->currency) 133 | ); 134 | 135 | $i ++; 136 | } 137 | } 138 | 139 | /** 140 | * Method to show box 141 | * 142 | * @param array $head with properties of box title 143 | * @param array $contents with properties of box lines 144 | * @param integer $nooutput nooutput 145 | * @return void 146 | */ 147 | public function showBox($head = null, $contents = null, $nooutput = 0) { 148 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /langs/en_US/lead.lang: -------------------------------------------------------------------------------- 1 | # Manage Lead 2 | # Copyright (C) 2014 Florian HENRY 3 | # Copyright (C) 2015 Raphaël Doursenaud 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 | # Generic 20 | # 21 | 22 | # Module label 'ModuleXXXName' 23 | # (where XXX is value of numeric property 'numero' of module) 24 | Module103111Name = Lead 25 | LeadLead= Lead 26 | # Module description 'ModuleXXXDesc' 27 | # (where XXX is value of numeric property 'numero' of module) 28 | Module103111Desc = Manages Lead 29 | LeadSimpleNumRefModelDesc=Return a reference like LEA-yymm-nnnn where yy is the year, mm the month and nnnn a sequencial counter without reset 30 | 31 | # 32 | # Admin page 33 | # 34 | LeadSetup = Lead setup 35 | SettingsLead = Settings 36 | LeadSetupPage = Lead setup page 37 | LeadNbDayDefaultClosure = Number of days to add to the current date for closure's default 38 | LeadAdmVar=Admin value 39 | LeadUserGroupAffect = Limit list of users assignable to lead to user group 40 | LeadForceUseThirdparty = Force use thirdparty on Lead 41 | LeadForceUseThirdpartyHelp = Is set to No, Lead without customer will never be visible for users without user permissions "Extend access to all third parties" 42 | LeadAllowMultipleOnContract=Allow users to attach several leads to a single contract 43 | 44 | # 45 | # About page 46 | # 47 | About = About 48 | LeadAbout = About Lead 49 | LeadAboutPage = Lead about page 50 | 51 | 52 | # 53 | # Permissions 54 | # 55 | Permission1031111=See Lead 56 | Permission1031112=Update Lead 57 | Permission1031113=Delete Lead 58 | Permission1031114=Export Lead 59 | 60 | # 61 | # Dictionnaires 62 | # 63 | LeadStatusDict=Module Lead - Steps 64 | LeadTypeDict=Module Lead - Types 65 | 66 | # 67 | # Menu 68 | # 69 | LeadList = List Lead 70 | LeadInfo = Lead Info 71 | LeadCreate = Create Lead 72 | LeadContact=Lead Contact 73 | LeadListCurrent=Current Lead 74 | LeadListMyLead=My Lead 75 | LeadListLate = Late Lead 76 | 77 | 78 | # 79 | # Status 80 | # 81 | LeadStatus=Selling step 82 | LeadStatus_PROSP=Prospect 83 | LeadStatus_CHIFF=Budget 84 | LeadStatus_PROPO=Proposal 85 | LeadStatus_NEGO=Deal 86 | LeadStatus_RECOND=Renew 87 | LeadStatus_WIN=Win 88 | LeadStatus_LOST=Lost 89 | 90 | # 91 | # Type 92 | # 93 | LeadType=Type 94 | LeadType_SUPP=Support 95 | LeadType_TRAIN = Training 96 | LeadType_ADVI=Consulting 97 | 98 | # 99 | # Card 100 | # 101 | LeadCommercial=Commercial 102 | LeadAmountGuess = Budget w/o VAT 103 | LeadDeadLine=Deadline 104 | LeadDelete=Delete Lead 105 | LeadConfirmDelete = Are you sure you want to delete the lead ? 106 | LeadRefInt = Internal reference 107 | LeadRealAmount = Real amount w/o VAT 108 | LeadDescription=Description 109 | LeadDocuments=Link Document 110 | LeadAddElement=Link 111 | LeadLate=Lead Late 112 | ConfirmCloneLead=Are you sure to clone Lead 113 | LeadShowLead=Display lead 114 | SelectElement=Select element 115 | LeadLink=Link(ed) Lead 116 | LeadLost=Lead close 117 | LeadConfirmLost=All proposals link to this lead will be close (not signed) ? 118 | LeadPropalCloseByLead=Proposal close by lost lead %s 119 | LeadObjectWindExists=Proposal signed or invoice exist (lead status should be win) 120 | LeadLastLeadUpdated=Last %s lead updated 121 | LeadCreatePropale=Create proposal 122 | LeadConfirmCreatePropale=Confirm proposal creation 123 | LeadClonePropale=Clone proposal 124 | LeadChoosePropale=Choose a proposal 125 | LeadCreateContract=Create contract 126 | LeadConfirmCreateContract=Confirm create contract 127 | 128 | # 129 | # Export 130 | # 131 | ExportDataset_lead=Lead 132 | LeadRefExt=Ref. Ext 133 | LeadStepCode=Steps Code 134 | LeadStepLabel=Steps Label 135 | LeadTypeCode=Type code 136 | LeadTypeLabel=Types Label 137 | lead@lead=Leads 138 | ExportDataset_leadPropal=Propal not linked with lead 139 | 140 | # 141 | # List 142 | # 143 | LeadDateDebut = Start Date 144 | 145 | # 146 | # Graph 147 | # 148 | LeadNbLeadByType=Nb lead by type 149 | LeadNbLeadByStatus=Nb lead by steps 150 | LeadStats=Lead statisitics 151 | LeadNbLead=Nb lead 152 | LeadNbLeadByMonth=Nb lead by month 153 | LeadAmountOfLead=Lead amount 154 | LeadAmountOfLeadsByMonth=lead amount by month 155 | LeadTransRateOfLead=Transformation rate 156 | LeadTransRateOfLeadsByMonth=Transformation rate by month 157 | 158 | # 159 | # Boxes 160 | # 161 | LastN=Last %s 162 | -------------------------------------------------------------------------------- /langs/it_IT/lead.lang: -------------------------------------------------------------------------------- 1 | # Manage Lead 2 | # Copyright (C) 2014 Florian HENRY 3 | # Copyright (C) 2015 Raphaël Doursenaud 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 | # Generic 20 | # 21 | 22 | # Module label 'ModuleXXXName' 23 | # (where XXX is value of numeric property 'numero' of module) 24 | Module103111Name = Lead 25 | LeadLead= Lead 26 | # Module description 'ModuleXXXDesc' 27 | # (where XXX is value of numeric property 'numero' of module) 28 | Module103111Desc = Manages Lead 29 | LeadSimpleNumRefModelDesc=Return reference like LEA-yymm-nnnn where yy is the year, mm the month and nnnn a counter sequancial without reset 30 | 31 | # 32 | # Admin page 33 | # 34 | LeadSetup = Lead setup 35 | SettingsLead = Settings 36 | LeadSetupPage = Lead setup page 37 | LeadNbDayDefaultClosure = Number of days to add to the current date for closure's default 38 | LeadAdmVar=Admin value 39 | LeadUserGroupAffect = Limit user list assignable on lead to user group 40 | LeadForceUseThirdparty = Force use thirdparty on Lead 41 | LeadForceUseThirdpartyHelp = Is set to No, Lead without customer will never be visible for users without user permissions "Extend access to all third parties" 42 | LeadAllowMultipleOnContract=Allow users to attach several leads to a single contract 43 | 44 | # 45 | # About page 46 | # 47 | About = About 48 | LeadAbout = About Lead 49 | LeadAboutPage = Lead about page 50 | 51 | 52 | # 53 | # Permissions 54 | # 55 | Permission1031111=Abilitazione modulo 56 | Permission1031112=Aggiornamento Lead 57 | Permission1031113=Elimina Lead 58 | Permission1031114=Esporta Lead 59 | 60 | # 61 | # Dictionnaires 62 | # 63 | LeadStatusDict=Module Lead - Steps 64 | LeadTypeDict=Module Lead - Types 65 | 66 | # 67 | # Menu 68 | # 69 | LeadList = Tutti i lead 70 | LeadInfo = Lead Info 71 | LeadCreate = Nuovo 72 | LeadContact=Lead Contact 73 | LeadListCurrent=Tutti i lead aperti 74 | LeadListMyLead=Lead personali 75 | LeadListLate = Lead scaduti 76 | 77 | 78 | # 79 | # Status 80 | # 81 | LeadStatus=Stadio di vendita 82 | LeadStatus_PROSP=In Prospettiva 83 | LeadStatus_CHIFF=Ammontare 84 | LeadStatus_PROPO=Proposto il valore 85 | LeadStatus_NEGO=Trattativa o preventivo 86 | LeadStatus_RECOND=Rinnovo 87 | LeadStatus_WIN=Chiuso VINTO 88 | LeadStatus_LOST=Chiuso PERSO 89 | 90 | # 91 | # Type 92 | # 93 | LeadType=Tipo 94 | LeadType_SUPP=Supporto 95 | LeadType_TRAIN =Formazione 96 | LeadType_ADVI=Consulenza 97 | 98 | # 99 | # Card 100 | # 101 | LeadCommercial=Commerciale 102 | LeadAmountGuess =Ammontare stimato 103 | LeadDeadLine=Scadenza 104 | LeadDelete=Elimina lead 105 | LeadConfirmDelete = Sicuro di voler eliminare il lead? 106 | LeadRefInt = Riferimento interno 107 | LeadRealAmount = Importo offerto (link preventivi) 108 | LeadDescription=Descrizione 109 | LeadDocuments=Collegamento ai documenti 110 | LeadAddElement=Link 111 | LeadLate=Lead scaduto 112 | ConfirmCloneLead=Sicuro di voler duplicare il lead? 113 | LeadShowLead=Display lead 114 | SelectElement=Select element 115 | LeadLink=Link(ed) Lead 116 | LeadLost=Chiudi Lead 117 | LeadConfirmLost=Sicuro divoler chiudere il lead? 118 | LeadPropalCloseByLead=Proposal close by lost lead %s 119 | LeadObjectWindExists=Proposal signed or invoice exist (lead status should be win) 120 | LeadLastLeadUpdated=Last %s lead updated 121 | LeadCreateContract=Create a contract 122 | LeadConfirmCreateContract=Confirm create contract 123 | 124 | # 125 | # Export 126 | # 127 | ExportDataset_lead=Lead 128 | LeadRefExt=Ref. Ext 129 | LeadStepCode=Steps Code 130 | LeadStepLabel=Steps Label 131 | LeadTypeCode=Type code 132 | LeadTypeLabel=Types Label 133 | lead@lead=Leads 134 | ExportDataset_leadPropal=Propal not linked with lead 135 | 136 | # 137 | # List 138 | # 139 | LeadDateDebut = Start Date 140 | 141 | # 142 | # Graph 143 | # 144 | LeadNbLeadByType=Numero di Lead per tipo 145 | LeadNbLeadByStatus=Numero di Lead per stadio di vendita 146 | LeadStats=Lead statistiche 147 | LeadNbLead=Numero di lead 148 | LeadNbLeadByMonth=Numero di Lead per mese 149 | LeadAmountOfLead=Ammontare finanziario per Lead 150 | LeadAmountOfLeadsByMonth=Ammontare finanziario mese per Lead 151 | LeadTransRateOfLead=Transformation rate 152 | LeadTransRateOfLeadsByMonth=Percentuale di chiusura mese con esito positivo 153 | 154 | # 155 | # Boxes 156 | # 157 | LastN=Last %s -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | ### Unreleased 5 | 6 | ## Release 2.7 7 | - NEW : Compat V22, change dolibarr compatibility range : 17.0 -> 22.0 - **08/08/2025** - 2.7.0 8 | 9 | ## Release 2.6 10 | 11 | - FIX : when you check a a object to confirm win or loss, this redirects to a lead with the id of propal selected - *15/04/2025* - 2.6.6 12 | - FIX : fatal when you to confirm win or loss without checking checkbox - *01/04/2025* - 2.6.5 13 | - FIX : fatal loading widget on welcome page - *03/03/2025* - 2.6.4 14 | - FIX : files size logo - *20/02/2025* - 2.6.3 15 | - FIX : Compat v21 - *11/12/2024* - 2.6.2 16 | - FIX : Refonte onglet Affaires DA025406 - *29/08/2024* - 2.6.1 17 | - NEW : Compat v20 - *19/07/2024* - 2.6.0 18 | 19 | ## Release 2.5 20 | 21 | - NEW : TechATM + PAge About + logo - *17/01/2024* - 2.5.0 22 | - NEW : Compat v19 - *12/12/2023* - 2.4.0 23 | Change dolibarr compatibility 15 min - 19 max 24 | 25 | ## Release 2.3 26 | 27 | 28 | - FIX : remove warning array in action file - *25/03/2024* - 2.3.21 29 | 30 | - FIX : change parameters order for implode function (deprecated since PHP 7.4) - *08/11/2023* - 2.3.20 31 | - FIX : protected field to public field in lead.class - *19/05/2023* - 2.3.19 32 | - FIX : Fix box display with access control - *05/06/2023* - 2.3.18 33 | - FIX : Compat v17 - *04/04/2023* - 2.3.17 34 | - FIX : Fix missing list total - *03/04/2023* -2.3.16 35 | - FIX : Fix bad display of lead in opportunity block - *03/04/2023* - 2.3.15 36 | - FIX : Compat v15 - *16/02/2023* - 2.3.14 37 | - FIX : Compatibility PHP 8.1 - *02/08/2022* - 2.3.13 38 | - FIX : Compatibility V16 - *14/06/2022* - 2.3.12 39 | - remove db_prefix in dictionnary definitions 40 | - add token to index 41 | - add token to list search form 42 | - add token to url and list sortfield 43 | - fix fatal : createfromclone does not work... 44 | - fix module family 45 | - FIX : Multi Module Hook compatibility - *06/05/2022* - 2.3.11 46 | - FIX : Compat V15 : newToken() - *20/04/2022* - 2.3.10 47 | - FIX : change status invoice in lead card *2022-02-22* - 2.3.9 48 | - FIX : Liaison automatique d'une facture à une affaire si la propale d'origine est liée à cette affaire. - *2022-02-22* - 2.3.8 49 | - FIX : Compat V13 : newToken() et $user->socid - *2021-01-11* - 2.3.7 50 | - FIX : Compat V15 - *2021-12-21* - 2.3.6 51 | - FIX : GETPOST (external fix by user @l00ptr) - *2021-12-06* - 2.3.5 52 | - FIX : function name is now closeProposal() and not cloture(), then we use mthod_exists - *2021-10-28* - 2.3.4 53 | - FIX : Compatibility with Dolibarr v14 (removal of `total` fields from 54 | the invoice table and the proposal table) - *2021-10-07* - 2.3.3 55 | - FIX : List compatibility with Dolibarr v14 (empty value for sales 56 | person selector is now -1) - *2021-09-09* - 2.3.2 57 | - FIX : Box compatibility for Dolibarr V13 - *2021-yy-mm* - 2.3.1 58 | - NEW : Add tab count badges for tabs "Contacts", "Files" and "Notes" 59 | 60 | 61 | --- 62 | ## Old Changelog 63 | 64 | ***** ChangeLog for 2.2 compared to 2.1.7 ***** 65 | FIX : delete "setPrecisionY" function 66 | 67 | ***** ChangeLog for 2.0 compared to 1.16 ***** 68 | NEW : Better management of close or open leads 69 | 70 | ***** ChangeLog for 1.16 compared to 1.15 ***** 71 | NEW : Only for 5.0 with good list management 72 | NEW : Can create contract from lead 73 | 74 | ***** ChangeLog for 1.15 compared to 1.14 ***** 75 | FIX : error into log on addSearchEntry hook 76 | 77 | ***** ChangeLog for 1.14 compared to 1.12 ***** 78 | FIX : Lead visibility according user right on thirdparties 79 | NEW : Can create propal on Lead page 80 | NEW : Can clone propal on Lead page 81 | 82 | ***** ChangeLog for 1.12 compared to 1.11 ***** 83 | NEW : Add developer feature to manage template 84 | NEW : Add quick search on Lead Ref 85 | 86 | ***** ChangeLog for 1.11 compared to 1.10 ***** 87 | NEW : Add feature to create event linked to lead 88 | 89 | ***** ChangeLog for 1.10 compared to 1.9 ***** 90 | NEW : Add more information into lead box under contract/propal/etc... 91 | NEW : Add export on Propal not linked to Lead 92 | 93 | ***** ChangeLog for 1.9 compared to 1.8 ***** 94 | FIX : Add option to link multiple lead on contract (from contract card) 95 | 96 | ***** ChangeLog for 1.8 compared to 1.7 ***** 97 | NEW : Add setting to disabeld thirdparty mandatory field 98 | NEW : Add option to link multiple lead on contract 99 | FIX : Shouldn't propose disabled users #13 100 | 101 | ***** ChangeLog for 1.7 compared to 1.6 ***** 102 | FIX : Fix problem with Dolibarr 3.8 103 | 104 | ***** ChangeLog for 1.5.1 compared to 1.5 ***** 105 | NEW : Italian language 106 | 107 | ***** ChangeLog for 1.5 compared to 1.3 ***** 108 | FIX : Problem on extrafields creation 109 | NEW : Merge from GPC solution repository code review 110 | 111 | ***** ChangeLog for 1.3 compared to 1.2 ***** 112 | FIX : problem on tab File attached 113 | 114 | ***** ChangeLog for 1.2 compared to 1.1 ***** 115 | NEW : Can link to lead directly from proposal/order/invoice/contract 116 | NEW : close lead (status lost) will update all proposal to status not signed 117 | NEW : Some graph and data 118 | NEW : New tabs notes and attached documents 119 | NEW : Add list lead into cutomer tabs (thridparty module) 120 | NEW : Add lead export into export module 121 | -------------------------------------------------------------------------------- /langs/es_ES/lead.lang: -------------------------------------------------------------------------------- 1 | # Manage Lead 2 | # Copyright (C) 2014 Florian HENRY 3 | # Copyright (C) 2015 Raphaël Doursenaud 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 | # Generic 20 | # 21 | 22 | # Module label 'Leads' 23 | # (where XXX is value of numeric property 'numero' of module) 24 | Lead = Lead 25 | LeadLead= Lead 26 | # Module description 'ModuleXXXDesc' 27 | # (where XXX is value of numeric property 'numero' of module) 28 | Module103111Desc = Manages Lead 29 | LeadSimpleNumRefModelDesc=Return a reference like LEA-yymm-nnnn where yy is the year, mm the month and nnnn a sequencial counter without reset 30 | 31 | # 32 | # Admin page 33 | # 34 | LeadSetup = Configuración Lead 35 | SettingsLead = Configuración 36 | LeadSetupPage = Cargar Lead Setup Page 37 | LeadNbDayDefaultClosure = Número de días a añadir a la fecha actual para calcular fecha cierre. 38 | LeadAdmVar=Admin valor 39 | LeadUserGroupAffect = Limitar usuarios asignables a un Lead a un grupo de usuarios. 40 | LeadForceUseThirdparty = Forzar usar Tercero en Leads. 41 | LeadForceUseThirdpartyHelp = Si seleccionas NO, los Lead sin Terceros asignados nunca serán visibles a usuarios sin el permiso "Extender acceso a todos los Terceros". 42 | LeadAllowMultipleOnContract=Permitir a los usuarios añadir varios Leads a un solo contrato. 43 | 44 | # 45 | # About page 46 | # 47 | About = Sobre 48 | LeadAbout = Sobre Lead 49 | LeadAboutPage = Lead about page 50 | 51 | 52 | # 53 | # Permissions 54 | # 55 | Permission1031111=Ver Lead 56 | Permission1031112=Actualizar Lead 57 | Permission1031113=Eliminar Lead 58 | Permission1031114=Exportar Lead 59 | 60 | # 61 | # Dictionnaires 62 | # 63 | LeadStatusDict=Modulo Lead - Pasos 64 | LeadTypeDict=Modulo Lead - Tipos 65 | 66 | # 67 | # Menu 68 | # 69 | LeadList = Listado Leads 70 | LeadInfo = Info Leads 71 | LeadCreate = Crear Lead 72 | LeadContact=Contacto Lead 73 | LeadListCurrent=Leads Actuales 74 | LeadListMyLead=Mis Leads 75 | LeadListLate = Leads atrasados 76 | 77 | 78 | # 79 | # Status 80 | # 81 | LeadStatus=Proceso de venta 82 | LeadStatus_PROSP=Prospección 83 | LeadStatus_CHIFF=Interesado 84 | LeadStatus_PROPO=Presupuesto 85 | LeadStatus_NEGO=Negociando 86 | LeadStatus_RECOND=Renovar 87 | LeadStatus_WIN=Won 88 | LeadStatus_LOST=Perdido 89 | 90 | # 91 | # Type 92 | # 93 | LeadType=Interés 94 | LeadType_SUPP=Soporte 95 | LeadType_TRAIN = Formación 96 | LeadType_ADVI=Consultoría 97 | 98 | # 99 | # Card 100 | # 101 | LeadCommercial=Comercial 102 | LeadAmountGuess = Presupuesto SIN IVA 103 | LeadDeadLine=Fecha Tope 104 | LeadDelete=Eliminar Lead 105 | LeadConfirmDelete = Estás seguro que quieres borrar este Lead? 106 | LeadRefInt = Referencia Interna 107 | LeadRealAmount = Cantidad real sin IVA 108 | LeadDescription=Descripción 109 | LeadDocuments=Enlazar documento 110 | LeadAddElement=Enlazar 111 | LeadLate=Lead retrasado 112 | ConfirmCloneLead=Estás seguro que quieres clonar Lead? 113 | LeadShowLead=Mostrar Lead 114 | SelectElement=Seleccionar elemento 115 | LeadLink=Enlace Lead 116 | LeadLost=Lead Perdido 117 | LeadConfirmLost=Todos los presupuestos enlazados a este Lead serán cerrados (no firmados) 118 | LeadPropalCloseByLead=Presupuestos cerrados vs Leads perdidos. LeadObjectWindExists=Presupuesto cerrado o factura existe. (Estado del Lead debería ser Ganado) 119 | LeadLastLeadUpdated=Últimos %s Leads actualizados. 120 | LeadCreatePropale=Crear presupuesto 121 | LeadConfirmCreatePropale=Confirmar creación presupuesto. 122 | LeadClonePropale=Clonar presupuesto 123 | LeadChoosePropale=Elege presupuesto 124 | LeadCreateContract=Crear contrato 125 | LeadConfirmCreateContract=Confirma creación contrato 126 | Leadwin = Lead ganado 127 | LeadWin = Lead ganado 128 | LeadConfirmWin = Los presupuestos seleccionados vinculados a este Lead serán firmados o aceptados 129 | CreateRelance=Crear Evento 130 | LeadStatus_WIN=Won 131 | LeadDateRelance=Fecha Creación 1er Seguimiento 132 | ConfirmCreateRelance=Selecciona fecha y confirma (Se programará a las 12.00 del día seleccionado) 133 | 134 | # 135 | # Export 136 | # 137 | ExportDataset_lead=Lead 138 | LeadRefExt=Ref. Ext 139 | LeadStepCode=Código pasos 140 | LeadStepLabel=Etiqueta pasos 141 | LeadTypeCode=Código tipo 142 | LeadTypeLabel=Etiqueta tipos 143 | lead@lead=Leads 144 | ExportDataset_leadPropal=Propal not linked with lead 145 | 146 | # 147 | # List 148 | # 149 | LeadDateDebut = Fecha de inicio 150 | 151 | # 152 | # Graph 153 | # 154 | LeadNbLeadByType=Nº Leads por Tipo. 155 | LeadNbLeadByStatus=Nº Leads por Estado. 156 | LeadStats=Estadísticas Leads. 157 | LeadNbLead=Nº Leads 158 | LeadNbLeadByMonth=Nº Leads por mes 159 | LeadAmountOfLead=Cantidad Leads 160 | LeadAmountOfLeadsByMonth=Total € Leads por mes 161 | LeadTransRateOfLead=Ratio de cierre 162 | LeadTransRateOfLeadsByMonth=Ratio de cierre por mes 163 | 164 | # 165 | # Boxes 166 | # 167 | LastN=Últimos %s -------------------------------------------------------------------------------- /lead/document.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2008 Laurent Destailleur 4 | * Copyright (C) 2005 Marc Barilley / Ocebo 5 | * Copyright (C) 2005-2011 Regis Houssin 6 | * Copyright (C) 2013 Cédric Salvador 7 | * Copyright (C) 2015 Florian HENRY 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | $res = @include '../../main.inc.php'; // For root directory 24 | if (! $res) 25 | $res = @include '../../../main.inc.php'; // For "custom" directory 26 | if (! $res) 27 | die("Include of main fails"); 28 | 29 | require_once '../class/lead.class.php'; 30 | require_once '../class/html.formlead.class.php'; 31 | require_once '../lib/lead.lib.php'; 32 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 35 | 36 | $langs->load('lead@lead'); 37 | $langs->load('other'); 38 | 39 | $id=GETPOST('id','int'); 40 | $action=GETPOST('action','alpha'); 41 | $confirm=GETPOST('confirm', 'alpha'); 42 | 43 | // Security check 44 | if (! $user->hasRight('lead', 'read')) 45 | accessforbidden(); 46 | 47 | // Get parameters 48 | $sortfield = GETPOST("sortfield",'alpha'); 49 | $sortorder = GETPOST("sortorder",'alpha'); 50 | $page = GETPOST("page",'int'); 51 | $page = intval($page); 52 | if ($page == -1) { $page = 0; } 53 | $offset = $conf->liste_limit * $page; 54 | $pageprev = $page - 1; 55 | $pagenext = $page + 1; 56 | if (! $sortorder) $sortorder="ASC"; 57 | if (! $sortfield) $sortfield="name"; 58 | $permissiontoadd = $user->hasRight('lead', 'write'); 59 | $object = new Lead($db); 60 | if ($id > 0) { 61 | $ret = $object->fetch($id); 62 | if ($ret < 0) 63 | setEventMessage($object->error, 'errors'); 64 | if ($ret > 0) 65 | $ret = $object->fetch_thirdparty(); 66 | if ($ret < 0) 67 | setEventMessage($object->error, 'errors'); 68 | 69 | $upload_dir = $conf->lead->dir_output . "/" . dol_sanitizeFileName($object->ref); 70 | } 71 | 72 | /* 73 | * Actions 74 | */ 75 | 76 | if ($object->id > 0) 77 | { 78 | $object->fetch_thirdparty(); 79 | $upload_dir = $conf->lead->dir_output.'/'.dol_sanitizeFileName($object->ref); 80 | include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; 81 | } 82 | 83 | 84 | /* 85 | * View 86 | */ 87 | 88 | llxHeader(); 89 | 90 | $form = new Form($db); 91 | $formlead = new FormLead($db); 92 | 93 | if ($id > 0 || ! empty($ref)) 94 | { 95 | if ($object->fetch($id) > 0) 96 | { 97 | $object->fetch_thirdparty(); 98 | 99 | $head = lead_prepare_head($object); 100 | dol_fiche_head($head, 'documents', $langs->trans('Module103111Name'), 0, dol_buildpath('/lead/img/object_lead.png', 1), 1); 101 | 102 | 103 | // Construit liste des fichiers 104 | $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); 105 | $totalsize=0; 106 | foreach($filearray as $key => $file) 107 | { 108 | $totalsize+=$file['size']; 109 | } 110 | 111 | 112 | 113 | print ''; 114 | 115 | if (is_object($object->thirdparty)){ 116 | $urlBackToList = dol_buildpath('/lead/lead/list.php?socid=' . $object->thirdparty->id, 1); 117 | }else{ 118 | $urlBackToList = dol_buildpath('/lead/lead/list.php', 1); 119 | } 120 | $linkback = '' . $langs->trans("BackToList") . ''; 121 | 122 | print ''; 123 | print ''; 126 | print ''; 129 | print ''; 130 | 131 | print ''; 132 | print ''; 135 | print ''; 138 | print ''; 139 | print ''; 140 | print ''; 141 | print "
'; 124 | print $langs->trans('Ref'); 125 | print ''; 127 | print $formlead->showrefnav_custom($object, 'id', $linkback, 1, 'rowid', 'ref', ''); 128 | print '
'; 133 | print $langs->trans('LeadRefInt'); 134 | print ''; 136 | print $object->ref_int; 137 | print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
\n"; 142 | print "\n"; 143 | 144 | 145 | $modulepart = 'lead'; 146 | $permission = $user->hasRight('lead', 'write'); 147 | $param = '&id=' . $object->id; 148 | include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; 149 | 150 | } 151 | else 152 | { 153 | dol_print_error($db); 154 | } 155 | } 156 | else 157 | { 158 | print $langs->trans("ErrorUnknown"); 159 | } 160 | 161 | $db->close(); 162 | 163 | dol_fiche_end(); 164 | 165 | llxFooter(); 166 | -------------------------------------------------------------------------------- /lead/contact.php: -------------------------------------------------------------------------------- 1 | 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 htdocs/comm/propal/contact.php 21 | * \ingroup propal 22 | * \brief Onglet de gestion des contacts de propal 23 | */ 24 | $res = @include '../../main.inc.php'; // For root directory 25 | if (! $res) 26 | $res = @include '../../../main.inc.php'; // For "custom" directory 27 | if (! $res) 28 | die("Include of main fails"); 29 | require_once '../class/lead.class.php'; 30 | require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; 31 | require_once '../lib/lead.lib.php'; 32 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; 33 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; 34 | require_once '../class/html.formlead.class.php'; 35 | 36 | $langs->load("facture"); 37 | $langs->load("lead@lead"); 38 | $langs->load("orders"); 39 | $langs->load("sendings"); 40 | $langs->load("companies"); 41 | 42 | $id = GETPOST('id', 'int'); 43 | $ref = GETPOST('ref', 'alpha'); 44 | $lineid = GETPOST('lineid', 'int'); 45 | $action = GETPOST('action', 'alpha'); 46 | 47 | // Security check 48 | if (! $user->hasRight('lead', 'read')) 49 | accessforbidden(); 50 | 51 | $object = new Lead($db); 52 | 53 | // Load object 54 | if ($id > 0) { 55 | $ret = $object->fetch($id); 56 | if ($ret == 0) { 57 | $langs->load("errors"); 58 | setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); 59 | $error ++; 60 | } else if ($ret < 0) { 61 | setEventMessages(null, $object->errors, 'errors'); 62 | $error ++; 63 | } 64 | } 65 | if (! $error) { 66 | $object->fetch_thirdparty(); 67 | } else { 68 | header('Location: list.php'); 69 | exit(); 70 | } 71 | 72 | /* 73 | * Ajout d'un nouveau contact 74 | */ 75 | 76 | if ($action == 'addcontact' && $user->hasRight('lead', 'write')) { 77 | if ($object->id > 0) { 78 | $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); 79 | $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); 80 | } 81 | 82 | if ($result >= 0) { 83 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); 84 | exit(); 85 | } else { 86 | if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { 87 | $langs->load("errors"); 88 | setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); 89 | } else { 90 | setEventMessages(null, $object->errors, 'errors'); 91 | } 92 | } 93 | } 94 | 95 | // Bascule du statut d'un contact 96 | else if ($action == 'swapstatut' && $user->hasRight('lead', 'write')) { 97 | if ($object->id > 0) { 98 | $result = $object->swapContactStatus(GETPOST('ligne','alpha')); 99 | } 100 | } 101 | 102 | // Efface un contact 103 | else if ($action == 'deletecontact' && $user->hasRight('lead', 'write')) { 104 | $result = $object->delete_contact($lineid); 105 | 106 | if ($result >= 0) { 107 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); 108 | exit(); 109 | } else { 110 | dol_print_error($db); 111 | } 112 | } 113 | 114 | /* 115 | * View 116 | */ 117 | 118 | llxHeader('', $langs->trans('LeadContact')); 119 | 120 | $form = new Form($db); 121 | $formcompany = new FormCompany($db); 122 | $formother = new FormOther($db); 123 | $formlead = new FormLead($db); 124 | 125 | if ($object->id > 0) { 126 | $head = lead_prepare_head($object); 127 | dol_fiche_head($head, 'contact', $langs->trans("LeadContact"), 0, 'contact'); 128 | 129 | /* 130 | * Lead synthese pour rappel 131 | */ 132 | print ''; 133 | if (is_object($object->thirdparty)){ 134 | $urlBackToList = dol_buildpath('/lead/lead/list.php?socid=' . $object->thirdparty->id, 1); 135 | }else{ 136 | $urlBackToList = dol_buildpath('/lead/lead/list.php', 1); 137 | } 138 | $linkback = '' . $langs->trans("BackToList") . ''; 139 | 140 | // Ref 141 | print ''; 144 | 145 | print ''; 146 | print ''; 149 | print ''; 157 | print ''; 158 | 159 | print ''; 160 | print ''; 163 | print ''; 166 | print ''; 167 | 168 | print ''; 169 | print ''; 172 | print ''; 175 | print ''; 176 | 177 | print ''; 178 | print ''; 181 | print ''; 184 | print ''; 185 | 186 | print "
' . $langs->trans('Ref') . ''; 142 | print $formlead->showrefnav_custom($object, 'id', $linkback, 1, 'rowid', 'ref', ''); 143 | print '
'; 147 | print $langs->trans('LeadCommercial'); 148 | print ''; 150 | $userstatic = new User($db); 151 | $result = $userstatic->fetch($object->fk_user_resp); 152 | if ($result < 0) { 153 | setEventMessages(null, $userstatic->errors, 'errors'); 154 | } 155 | print $userstatic->getFullName($langs); 156 | print '
'; 161 | print $langs->trans('Company'); 162 | print ''; 164 | print $object->thirdparty->getNomUrl(); 165 | print '
'; 170 | print $langs->trans('LeadStatus'); 171 | print ''; 173 | print $object->status_label; 174 | print '
'; 179 | print $langs->trans('LeadType'); 180 | print ''; 182 | print $object->type_label; 183 | print '
"; 187 | 188 | print ''; 189 | 190 | print '
'; 191 | 192 | $res = @include '../tpl/contacts.tpl.php'; 193 | } 194 | 195 | dol_fiche_end(); 196 | 197 | llxFooter(); 198 | 199 | $db->close(); 200 | -------------------------------------------------------------------------------- /langs/fr_FR/lead.lang: -------------------------------------------------------------------------------- 1 | # Manage Lead 2 | # Copyright (C) 2014 Florian HENRY 3 | # Copyright (C) 2015 Raphaël Doursenaud 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 | # Générique 20 | # 21 | 22 | # Module label 'ModuleXXXName' 23 | # (where XXX is value of numeric property 'numero' of module) 24 | Module103111Name = Affaires 25 | LeadLead = Affaires 26 | # Module description 'ModuleXXXDesc' 27 | # (where XXX is value of numeric property 'numero' of module) 28 | Module103111Desc = Gestion d'affaires 29 | LeadSimpleNumRefModelDesc = Retourne un numéro sous la forme LEA-yymm-nnnn où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0 30 | 31 | # 32 | # Page d'administration 33 | # 34 | LeadSetup = Configuration du module Affaires 35 | SettingsLead = Réglages 36 | LeadSetupPage = Page de réglages des Affaires 37 | LeadNbDayDefaultClosure = Nombre de jours à ajouter à la date du jour pour obtenir la date de clôture par défaut 38 | LeadAdmVar=Administration 39 | LeadUserGroupAffect = Limiter les utilisateurs affectables à une affaire au groupe 40 | LeadForceUseThirdparty = Forcer l'utilisation des client sur les Affaires 41 | LeadForceUseThirdpartyHelp = Si configuré à Non, les affaires sans clients ne seront jamais visible pour les utilisateur n'ayant pas la permission "Étendre l'accès à tous les tiers". 42 | LeadAllowMultipleOnContract=Autoriser l'association de plusieurs affaire sur un contrat 43 | 44 | # 45 | # Page À propos 46 | # 47 | About = À propos 48 | LeadAbout = À propos de Affaires 49 | LeadAboutPage = Page à propos de Affaires 50 | 51 | # 52 | # Permissions 53 | # 54 | Permission1031111=Voir les affaires 55 | Permission1031112=Modifier les affaires 56 | Permission1031113=Supprimer les affaires 57 | Permission1031114=Exporter les affaires 58 | 59 | # 60 | # Dictionnaires 61 | # 62 | LeadStatusDict = Module Affaires — Étapes 63 | LeadTypeDict = Module Affaires — Types 64 | 65 | 66 | # 67 | # Menu 68 | # 69 | LeadList=Liste des affaires 70 | LeadInfo = Informations des affaires 71 | LeadCreate=Nouvelle affaire 72 | LeadContact=Contact Affaires 73 | LeadListCurrent=Affaires en cours 74 | LeadListMyLead=Mes affaires 75 | LeadListLate=Affaires en retard 76 | 77 | 78 | # 79 | # Status 80 | # 81 | LeadStatus = Étape de vente 82 | LeadStatus_PROSP=Prospection 83 | LeadStatus_CHIFF=Chiffrage 84 | LeadStatus_PROPO=Proposition 85 | LeadStatus_NEGO=Négociation 86 | LeadStatus_RECOND=Reconduction 87 | LeadStatus_WIN=Gagné 88 | LeadStatus_WON=Gagné 89 | LeadStatus_LOST=Perdu 90 | 91 | # 92 | # Type 93 | # 94 | LeadType=Type 95 | LeadType_SUPP=Support 96 | LeadType_TRAIN=Formation 97 | LeadType_ADVI=Conseil 98 | 99 | # 100 | # Card 101 | # 102 | LeadCommercial=Responsable 103 | LeadAmountGuess=Montant annoncé HT 104 | LeadDeadLine=Date de clôture 105 | LeadDelete=Supprimer l'affaire 106 | LeadRefInt=Référence interne 107 | LeadRealAmount=Montant réel HT 108 | LeadConfirmDelete = Êtes-vous sur de vouloir supprimer l'affaire ? 109 | LeadDescription=Description 110 | LeadDocuments = Documents associés 111 | LeadAddElement=Associer 112 | LeadLate=Affaire en retard 113 | ConfirmCloneLead=Êtes-vous certain de vouloir cloner l'affaire ? 114 | LeadShowLead=Afficher l'affaire 115 | SelectElement=Selectionner l'élément 116 | LeadLink=Affaire(s) associé(s) 117 | LeadLost=Affaire perdue 118 | LeadConfirmLost=Les proposition commerciales selectionnées à cette affaire seront mises au statut « Non Signées ». 119 | LeadPropalCloseByLead=Proposition cloturée par l'affaire %s perdue 120 | LeadObjectWindExists=Des propositions signées ou des factures existent (Le statut de l'affaire devrait être « Gagné ») 121 | LeadLastLeadUpdated=Les %s dernières affaires modifiées 122 | LeadCreatePropale=Créer une proposition commerciale 123 | LeadConfirmCreatePropale=Confirmer la création d'une proposition commerciale 124 | LeadClonePropale=Cloner une proposition commerciale 125 | LeadChoosePropale=Choisir une proposition commerciale 126 | LeadCreateContract=Créer un contrat 127 | LeadConfirmCreateContract=Confirmer la création d'un contrat 128 | LeadWin=Affaire gagnée 129 | LeadConfirmWin=Les proposition commerciales selectionnées à cette affaire seront mises au statut « Signées ». 130 | anoughPermissions = Pas de permission 131 | 132 | # 133 | # Export 134 | # 135 | ExportDataset_lead=Affaires 136 | LeadRefExt=Ref. Ext 137 | LeadStepCode=Étape de vente Code 138 | LeadStepLabel=Étape de vente Libellé 139 | LeadTypeCode=Type code 140 | LeadTypeLabel=Types Libellé 141 | lead@lead=Affaires 142 | ExportDataset_leadPropal=Proposition commercial non liée à un Lead 143 | 144 | # 145 | # List 146 | # 147 | LeadDateDebut = Date de début 148 | 149 | # 150 | # Graph 151 | # 152 | LeadNbLeadByType=Nb Affaires par type 153 | LeadNbLeadByStatus=Nb Affaires par étape de vente 154 | LeadStats=Statistiques des affaires 155 | LeadNbLead=Nb Affaires 156 | LeadNbLeadByMonth=Nb Affaires par mois 157 | LeadAmountOfLead=Montant des affaires 158 | LeadAmountOfLeadsByMonth=Montant des affaires par mois 159 | LeadTransRateOfLead=Taux de transformation 160 | LeadTransRateOfLeadsByMonth=Taux de transformation par mois 161 | 162 | # 163 | # Boxes 164 | # 165 | LastN=%s dernières 166 | 167 | #relance 168 | relanceAdded=Relance ajoutée 169 | CreateRelance=Créer une relance 170 | ConfirmCreateRelance=Entrez la date de relance 171 | LeadTypeRelance=Type de l'évènement relance 172 | LeadDateRelance=Date de relance 173 | leadRelanceEvent=Relance sur une affaire %s 174 | ImpossibleToCreateEventLead=Impossible de créer l'évènement de relance 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /lib/lead.lib.php: -------------------------------------------------------------------------------- 1 | 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/lead.lib.php 21 | * \ingroup lead 22 | * \brief This file is an example module library 23 | * Put some comments here 24 | */ 25 | function leadAdminPrepareHead() 26 | { 27 | global $langs, $conf; 28 | 29 | if (function_exists('newToken')) $urlToken = "?token=".newToken(); 30 | 31 | $langs->load("lead@lead"); 32 | $langs->load("admin"); 33 | 34 | $h = 0; 35 | $head = array(); 36 | 37 | $head[$h][0] = dol_buildpath("/lead/admin/admin_lead.php".$urlToken, 1); 38 | $head[$h][1] = $langs->trans("SettingsLead"); 39 | $head[$h][2] = 'settings'; 40 | $h ++; 41 | 42 | $head[$h][0] = dol_buildpath("/lead/admin/lead_extrafields.php".$urlToken, 1); 43 | $head[$h][1] = $langs->trans("ExtraFields"); 44 | $head[$h][2] = 'attributes'; 45 | $h ++; 46 | 47 | $head[$h][0] = dol_buildpath("/lead/admin/about.php".$urlToken, 1); 48 | $head[$h][1] = $langs->trans("About"); 49 | $head[$h][2] = 'about'; 50 | $h ++; 51 | 52 | // Show more tabs from modules 53 | // Entries must be declared in modules descriptor with line 54 | // $this->tabs = array( 55 | // 'entity:+tabname:Title:@lead:/lead/mypage.php?id=__ID__' 56 | // ); // to add new tab 57 | // $this->tabs = array( 58 | // 'entity:-tabname:Title:@lead:/lead/mypage.php?id=__ID__' 59 | // ); // to remove a tab 60 | complete_head_from_modules($conf, $langs, null, $head, $h, 'lead_admin'); 61 | 62 | return $head; 63 | } 64 | 65 | /** 66 | * Prepare page head 67 | * 68 | * @param Lead $object The lead 69 | * 70 | * @return array Header contents (tabs) 71 | */ 72 | function lead_prepare_head($object) 73 | { 74 | global $langs, $conf, $db; 75 | 76 | $langs->load("lead@lead"); 77 | 78 | $h = 0; 79 | $head = array(); 80 | 81 | if (function_exists('newToken')) $urlToken = "&token=".newToken(); 82 | 83 | $head[$h][0] = dol_buildpath("/lead/lead/card.php", 1) . '?id=' . $object->id.$urlToken; 84 | $head[$h][1] = $langs->trans("LeadLead"); 85 | $head[$h][2] = 'card'; 86 | $h ++; 87 | 88 | // CONTACTS 89 | $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); 90 | $head[$h][0] = dol_buildpath("/lead/lead/contact.php", 1) . '?id=' . $object->id.$urlToken; 91 | $head[$h][1] = $langs->trans("Contacts"); 92 | if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; 93 | $head[$h][2] = 'contact'; 94 | $h ++; 95 | 96 | 97 | // DOCUMENTS 98 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 99 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; 100 | if(isset($conf->lead->multidir_output) && !empty($object->entity)){ // maybe one day the lead module will use entities 101 | $upload_dir = $conf->lead->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); 102 | } 103 | else{ 104 | $upload_dir = $conf->lead->dir_output . "/" . dol_sanitizeFileName($object->ref); 105 | } 106 | 107 | $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); 108 | $nbLinks = Link::count($db, $object->element, $object->id); 109 | 110 | $head[$h][0] = dol_buildpath("/lead/lead/document.php", 1) . '?id=' . $object->id.$urlToken; 111 | $head[$h][1] = $langs->trans("Documents"); 112 | if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; 113 | $head[$h][2] = 'documents'; 114 | $h ++; 115 | 116 | // NOTES 117 | if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) 118 | { 119 | $nbNote = 0; 120 | if(!empty($object->note_private)) $nbNote++; 121 | if(!empty($object->note_public)) $nbNote++; 122 | $head[$h][0] = dol_buildpath("/lead/lead/note.php", 1) . '?id=' . $object->id.$urlToken; 123 | $head[$h][1] = $langs->trans('Notes'); 124 | if($nbNote > 0) $head[$h][1].= ''.$nbNote.''; 125 | $head[$h][2] = 'note'; 126 | $h++; 127 | } 128 | 129 | $head[$h][0] = dol_buildpath("/lead/lead/info.php", 1) . '?id=' . $object->id.$urlToken; 130 | $head[$h][1] = $langs->trans("Info"); 131 | $head[$h][2] = 'info'; 132 | $h ++; 133 | 134 | // Show more tabs from modules 135 | // Entries must be declared in modules descriptor with line 136 | // $this->tabs = array( 137 | // 'entity:+tabname:Title:@lead:/lead/mypage.php?id=__ID__' 138 | // ); // to add new tab 139 | // $this->tabs = array( 140 | // 'entity:-tabname:Title:@lead:/lead/mypage.php?id=__ID__' 141 | // ); // to remove a tab 142 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'lead'); 143 | 144 | return $head; 145 | } 146 | 147 | /** 148 | * Prepare head for statistics page 149 | * 150 | * @return array Header contents (tabs) 151 | */ 152 | function lead_stats_prepare_head() 153 | { 154 | global $langs, $conf; 155 | 156 | $langs->load("lead@lead"); 157 | 158 | if (function_exists('newToken')) $urlToken = "?token=".newToken(); 159 | 160 | $h = 0; 161 | $head = array(); 162 | 163 | $head[$h][0] = dol_buildpath("/lead/index.php".$urlToken, 1); 164 | $head[$h][1] = $langs->trans("LeadStats"); 165 | $head[$h][2] = 'stat'; 166 | $h ++; 167 | 168 | // Show more tabs from modules 169 | // Entries must be declared in modules descriptor with line 170 | // $this->tabs = array( 171 | // 'entity:+tabname:Title:@lead:/lead/mypage.php?id=__ID__' 172 | // ); // to add new tab 173 | // $this->tabs = array( 174 | // 'entity:-tabname:Title:@lead:/lead/mypage.php?id=__ID__' 175 | // ); // to remove a tab 176 | complete_head_from_modules($conf, $langs, null, $head, $h, 'lead_stats'); 177 | 178 | return $head; 179 | } 180 | -------------------------------------------------------------------------------- /admin/lead_extrafields.php: -------------------------------------------------------------------------------- 1 | 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 lead/admin/lead_extrafields.php 21 | * \ingroup agenda 22 | * \brief Page to setup extra fields of lead 23 | */ 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 | require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; 31 | require_once '../lib/lead.lib.php'; 32 | 33 | if (! $user->admin) 34 | accessforbidden(); 35 | 36 | $langs->load("admin"); 37 | $langs->load("other"); 38 | $langs->load("agenda"); 39 | $langs->load("lead@lead"); 40 | 41 | $extrafields = new ExtraFields($db); 42 | $form = new Form($db); 43 | 44 | // List of supported format 45 | $tmptype2label = ExtraFields::$type2label; 46 | $type2label = array( 47 | '' 48 | ); 49 | foreach ($tmptype2label as $key => $val) 50 | $type2label[$key] = $langs->trans($val); 51 | 52 | $action = GETPOST('action', 'alpha'); 53 | $attrname = GETPOST('attrname', 'alpha'); 54 | $elementtype = 'lead'; // Must be the $table_element of the class that manage extrafield 55 | 56 | if (! $user->admin) 57 | accessforbidden(); 58 | 59 | /* 60 | * Actions 61 | */ 62 | if (file_exists(DOL_DOCUMENT_ROOT . '/core/admin_extrafields.inc.php')) 63 | require_once DOL_DOCUMENT_ROOT . '/core/admin_extrafields.inc.php'; 64 | 65 | if (file_exists(DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php')) 66 | require_once DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php'; 67 | 68 | /* 69 | * View 70 | */ 71 | 72 | $textobject = $langs->transnoentitiesnoconv("Module103111Name"); 73 | 74 | llxHeader('', $langs->trans("LeadSetup")); 75 | 76 | $linkback = '' . $langs->trans("BackToModuleList") . ''; 77 | print load_fiche_titre($langs->trans("LeadSetup"), $linkback, 'tools'); 78 | print "
\n"; 79 | 80 | // Configuration header 81 | $head = leadAdminPrepareHead(); 82 | print dol_get_fiche_head($head, 'attributes', $langs->trans("Module103111Name"), -1, "lead@lead"); 83 | 84 | print $langs->trans("DefineHereComplementaryAttributes", $langs->transnoentitiesnoconv("Module103111Name")) . '
' . "\n"; 85 | print '
'; 86 | 87 | // Load attribute_label 88 | $extrafields->fetch_name_optionals_label($elementtype); 89 | 90 | print ""; 91 | 92 | print ''; 93 | print ''; 94 | print ''; 95 | print ''; 96 | print ''; 97 | print ''; 98 | print ''; 99 | print ''; 100 | print "\n"; 101 | 102 | $var = True; 103 | if(!empty($extrafields->attributes['lead']['type'])) $TExtrafieldsTypes = $extrafields->attributes['lead']['type']; 104 | if(!empty($TExtrafieldsTypes)) { 105 | foreach($TExtrafieldsTypes as $key => $value) { 106 | $var = ! $var; 107 | print ""; 108 | print "\n"; 109 | print "\n"; 110 | print "\n"; 111 | print '\n"; 112 | print '\n"; 113 | print '\n"; 114 | print '\n"; 116 | print ""; 117 | } 118 | } 119 | 120 | print "
' . $langs->trans("Label") . '' . $langs->trans("AttributeCode") . '' . $langs->trans("Type") . '' . $langs->trans("Size") . '' . $langs->trans("Unique") . '' . $langs->trans("Required") . ' 
".$extrafields->attributes['lead']['label'][$key]."".$key."".$extrafields->attributes['lead']['type'][$key]."'.$extrafields->attributes['lead']['size'][$key]."'.yn($extrafields->attributes['lead']['unique'][$key])."'.yn($extrafields->attributes['lead']['required'][$key])."'.img_edit().''; 115 | print "  ".img_delete()."
"; 121 | 122 | print dol_get_fiche_end(-1); 123 | 124 | // Buttons 125 | if ($action != 'create' && $action != 'edit') { 126 | print '
'; 127 | print "" . $langs->trans("NewAttribute") . ""; 128 | print "
"; 129 | } 130 | 131 | /* ************************************************************************* */ 132 | /* */ 133 | /* Creation d'un champ optionnel */ 134 | /* */ 135 | /* ************************************************************************** */ 136 | 137 | if ($action == 'create') { 138 | print "
"; 139 | print load_fiche_titre($langs->trans('NewAttribute')); 140 | 141 | require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_add.tpl.php'; 142 | } 143 | 144 | /* ************************************************************************* */ 145 | /* */ 146 | /* Edition d'un champ optionnel */ 147 | /* */ 148 | /* ************************************************************************** */ 149 | if ($action == 'edit' && ! empty($attrname)) { 150 | print "
"; 151 | print load_fiche_titre($langs->trans("FieldEdition", $attrname)); 152 | 153 | require DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php'; 154 | } 155 | 156 | llxFooter(); 157 | 158 | $db->close(); 159 | -------------------------------------------------------------------------------- /tpl/contacts.tpl.php: -------------------------------------------------------------------------------- 1 | 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 | if (! class_exists('Contact')) { 19 | require DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; 20 | } 21 | if (! class_exists('FormCompany')) { 22 | require DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; 23 | } 24 | 25 | $module = $object->element; 26 | 27 | $permission = $user->rights->$module->write; 28 | 29 | $formcompany = new FormCompany($db); 30 | $companystatic = new Societe($db); 31 | $contactstatic = new Contact($db); 32 | $userstatic = new User($db); 33 | 34 | ?> 35 | 36 | 37 |
38 | 39 | 40 |
41 |
trans("Source"); ?>
42 |
trans("Company"); ?>
43 |
trans("Contacts"); ?>
44 |
trans("ContactType"); ?>
45 |
 
46 |
 
47 |
48 | 49 | 50 | 51 | 52 |
" /> 60 |
trans("Users"); ?>
61 |
62 |
select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56); ?>
63 |
selectTypeContact($object, '', 'type','internal'); ?>
64 |
 
65 |
66 | "> 68 |
69 |
70 | 71 | 72 | 73 |
" /> 81 |
trans("ThirdPartyContacts"); ?>
82 | use_javascript_ajax && getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) { ?> 83 |
84 | 'getContacts', 88 | 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 89 | 'htmlname' => 'contactid', 90 | 'params' => array( 91 | 'add-customer-contact' => 'disabled' 92 | ) 93 | ); 94 | print $form->select_thirdparty_list($object->socid, 'socid', '', 1, 0, 0, $events); 95 | ?> 96 |
97 |
98 | selectcontacts($object->socid, '', 'contactid'); ?> 99 |
100 | 101 |
102 | socid; ?> 103 | selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); ?> 104 |
105 |
106 | selectcontacts($selectedCompany, '', 'contactid'); ?> 107 |
108 | 109 |
110 | selectTypeContact($object, '', 'type','external'); ?> 111 |
112 |
 
113 |
114 | " 116 | > 117 |
118 |
119 | 120 | 121 | 122 |
123 |
trans("Source"); ?>
124 |
trans("Company"); ?>
125 |
trans("Contacts"); ?>
126 |
trans("ContactType"); ?>
127 |
trans("Status"); ?>
128 |
 
129 |
130 | 131 | 132 | 133 | liste_contact(- 1, $source); 139 | $num = count($tab); 140 | 141 | $i = 0; 142 | while ($i < $num) { 143 | $var = ! $var; 144 | ?> 145 | 146 |
"> 147 |
148 | trans("User"); ?> 149 | trans("ThirdPartyContact"); ?> 150 |
151 |
152 | 0) { 154 | $companystatic->fetch($tab[$i]['socid']); 155 | echo $companystatic->getNomUrl(1); 156 | } 157 | if ($tab[$i]['socid'] < 0) { 158 | echo getDolGlobalString('MAIN_INFO_SOCIETE_NOM'); 159 | } 160 | if (! $tab[$i]['socid']) { 161 | echo ' '; 162 | } 163 | ?> 164 |
165 |
166 | id = $tab[$i]['id']; 169 | $userstatic->lastname = $tab[$i]['lastname']; 170 | $userstatic->firstname = $tab[$i]['firstname']; 171 | echo $userstatic->getNomUrl(1); 172 | } 173 | if ($tab[$i]['source'] == 'external') { 174 | $contactstatic->id = $tab[$i]['id']; 175 | $contactstatic->lastname = $tab[$i]['lastname']; 176 | $contactstatic->firstname = $tab[$i]['firstname']; 177 | echo $contactstatic->getNomUrl(1); 178 | } 179 | ?> 180 |
181 |
182 | 200 |
201 | 202 |  "> 204 | 205 |
206 |
207 | 208 | 209 | 210 | 211 |
212 | 213 | -------------------------------------------------------------------------------- /class/techatm.class.php: -------------------------------------------------------------------------------- 1 | db = $db; 66 | } 67 | 68 | /** 69 | * @param DolibarrModules $moduleDescriptor 70 | */ 71 | function getAboutPage($moduleDescriptor, $useCache = true){ 72 | global $langs; 73 | 74 | $url = self::ATM_TECH_URL.'/modules/modules-page-about.php'; 75 | $url.= '?module='.$moduleDescriptor->name; 76 | $url.= '&id='.$moduleDescriptor->numero; 77 | $url.= '&version='.$moduleDescriptor->version; 78 | $url.= '&langs='.$langs->defaultlang; 79 | $url.= '&callv='.self::CALL_VERSION; 80 | 81 | $cachePath = DOL_DATA_ROOT . "/modules-atm/temp/about_page"; 82 | $cacheFileName = dol_sanitizeFileName($moduleDescriptor->name.'_'.$langs->defaultlang).'.html'; 83 | $cacheFilePath = $cachePath.'/'.$cacheFileName; 84 | 85 | if($useCache && is_readable($cacheFilePath)){ 86 | $lastChange = filemtime($cacheFilePath); 87 | if($lastChange > time() - 86400){ 88 | $content = @file_get_contents($cacheFilePath); 89 | if($content !== false){ 90 | return $content; 91 | } 92 | } 93 | } 94 | 95 | $content = $this->getContents($url); 96 | 97 | if(!$content){ 98 | $content = ''; 99 | // About page goes here 100 | $content.= '
'; 101 | $content.= '
'.$langs->trans('ATMAbout').'
'; 102 | $content.= '
'; 103 | $content.= ''; 104 | $content.= '
'; 105 | } 106 | 107 | if($useCache){ 108 | if(!is_dir($cachePath)){ 109 | $res = dol_mkdir($cachePath, DOL_DATA_ROOT); 110 | }else{ 111 | $res = true; 112 | } 113 | 114 | if($res){ 115 | $comment = ''."\r\n"; 116 | 117 | file_put_contents( 118 | $cacheFilePath, 119 | $comment.$content 120 | ); 121 | } 122 | } 123 | 124 | return $content; 125 | } 126 | 127 | /** 128 | * @param string $moduleTechMane 129 | */ 130 | public static function getModuleDocUrl($moduleTechMane){ 131 | $url = self::ATM_TECH_URL.'/modules/doc-redirect.php'; 132 | $url.= '?module='.$moduleTechMane; 133 | return $url; 134 | } 135 | 136 | /** 137 | * @param DolibarrModules $moduleDescriptor 138 | */ 139 | public static function getLastModuleVersionUrl($moduleDescriptor){ 140 | $url = self::ATM_TECH_URL.'/modules/modules-last-version.php'; 141 | $url.= '?module='.$moduleDescriptor->name; 142 | $url.= '&number='.$moduleDescriptor->numero; 143 | $url.= '&version='.$moduleDescriptor->version; 144 | $url.= '&dolversion='.DOL_VERSION; 145 | $url.= '&callv='.self::CALL_VERSION; 146 | return $url; 147 | } 148 | 149 | 150 | /** 151 | * @param $url 152 | * @return false|object 153 | */ 154 | public function getJsonData($url){ 155 | $this->data = false; 156 | $res = @file_get_contents($url); 157 | $this->http_response_header = $http_response_header; 158 | $this->TResponseHeader = self::parseHeaders($http_response_header); 159 | if($res !== false){ 160 | $pos = strpos($res, '{'); 161 | if($pos > 0){ 162 | // cela signifie qu'il y a une erreur ou que la sortie n'est pas propre 163 | $res = substr($res, $pos); 164 | } 165 | 166 | $this->data = json_decode($res); 167 | } 168 | 169 | return $this->data; 170 | } 171 | 172 | /** 173 | * @param $url 174 | * @return false|string 175 | */ 176 | public function getContents($url){ 177 | $this->data = false; 178 | $res = @file_get_contents($url); 179 | $this->http_response_header = $http_response_header; 180 | $this->TResponseHeader = self::parseHeaders($http_response_header); 181 | if($res !== false){ 182 | $this->data = $res; 183 | } 184 | return $this->data; 185 | } 186 | 187 | public static function http_response_code_msg($code = NULL) 188 | { 189 | if ($code !== NULL) { 190 | 191 | switch ($code) { 192 | case 100: 193 | $text = 'Continue'; 194 | break; 195 | case 101: 196 | $text = 'Switching Protocols'; 197 | break; 198 | case 200: 199 | $text = 'OK'; 200 | break; 201 | case 201: 202 | $text = 'Created'; 203 | break; 204 | case 202: 205 | $text = 'Accepted'; 206 | break; 207 | case 203: 208 | $text = 'Non-Authoritative Information'; 209 | break; 210 | case 204: 211 | $text = 'No Content'; 212 | break; 213 | case 205: 214 | $text = 'Reset Content'; 215 | break; 216 | case 206: 217 | $text = 'Partial Content'; 218 | break; 219 | case 300: 220 | $text = 'Multiple Choices'; 221 | break; 222 | case 301: 223 | $text = 'Moved Permanently'; 224 | break; 225 | case 302: 226 | $text = 'Moved Temporarily'; 227 | break; 228 | case 303: 229 | $text = 'See Other'; 230 | break; 231 | case 304: 232 | $text = 'Not Modified'; 233 | break; 234 | case 305: 235 | $text = 'Use Proxy'; 236 | break; 237 | case 400: 238 | $text = 'Bad Request'; 239 | break; 240 | case 401: 241 | $text = 'Unauthorized'; 242 | break; 243 | case 402: 244 | $text = 'Payment Required'; 245 | break; 246 | case 403: 247 | $text = 'Forbidden'; 248 | break; 249 | case 404: 250 | $text = 'Not Found'; 251 | break; 252 | case 405: 253 | $text = 'Method Not Allowed'; 254 | break; 255 | case 406: 256 | $text = 'Not Acceptable'; 257 | break; 258 | case 407: 259 | $text = 'Proxy Authentication Required'; 260 | break; 261 | case 408: 262 | $text = 'Request Time-out'; 263 | break; 264 | case 409: 265 | $text = 'Conflict'; 266 | break; 267 | case 410: 268 | $text = 'Gone'; 269 | break; 270 | case 411: 271 | $text = 'Length Required'; 272 | break; 273 | case 412: 274 | $text = 'Precondition Failed'; 275 | break; 276 | case 413: 277 | $text = 'Request Entity Too Large'; 278 | break; 279 | case 414: 280 | $text = 'Request-URI Too Large'; 281 | break; 282 | case 415: 283 | $text = 'Unsupported Media Type'; 284 | break; 285 | case 500: 286 | $text = 'Internal Server Error'; 287 | break; 288 | case 501: 289 | $text = 'Not Implemented'; 290 | break; 291 | case 502: 292 | $text = 'Bad Gateway'; 293 | break; 294 | case 503: 295 | $text = 'Service Unavailable'; 296 | break; 297 | case 504: 298 | $text = 'Gateway Time-out'; 299 | break; 300 | case 505: 301 | $text = 'HTTP Version not supported'; 302 | break; 303 | default: 304 | $text = 'Unknown http status code "' . htmlentities($code) . '"'; 305 | break; 306 | } 307 | 308 | return $text; 309 | 310 | } else { 311 | return $text = 'Unknown http status code NULL'; 312 | } 313 | } 314 | 315 | public static function parseHeaders( $headers ) 316 | { 317 | $head = array(); 318 | if(!is_array($headers)){ 319 | return $head; 320 | } 321 | 322 | foreach( $headers as $k=>$v ) 323 | { 324 | $t = explode( ':', $v, 2 ); 325 | if( isset( $t[1] ) ) 326 | $head[ trim($t[0]) ] = trim( $t[1] ); 327 | else 328 | { 329 | $head[] = $v; 330 | if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) ) 331 | $head['reponse_code'] = intval($out[1]); 332 | } 333 | } 334 | return $head; 335 | } 336 | 337 | } 338 | -------------------------------------------------------------------------------- /class/html.formlead.class.php: -------------------------------------------------------------------------------- 1 | 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 lead/class/html.fromlead.class.php 21 | * \ingroup lead 22 | * \brief File of class with all html predefined components 23 | */ 24 | class FormLead extends Form 25 | { 26 | 27 | var $db; 28 | 29 | var $error; 30 | 31 | var $num; 32 | 33 | /** 34 | * Build Select List of element associable to a businesscase 35 | * 36 | * @param string $tablename To parse 37 | * @param Lead $lead The lead 38 | * @param string $htmlname Name of the component 39 | * 40 | * @return string HTML select list of element 41 | */ 42 | function select_element($tablename, $lead, $htmlname = 'elementselect') 43 | { 44 | global $langs, $conf; 45 | 46 | $primary = 'rowid'; 47 | switch ($tablename) { 48 | case "facture": 49 | $sql = "SELECT $primary, facnumber as ref, total as total_ht, date_valid as date_element"; 50 | break; 51 | case "contrat": 52 | $sql = "SELECT $primary, ref as ref, 0 as total_ht, date_contrat as date_element"; 53 | break; 54 | case "commande": 55 | $sql = "SELECT $primary, ref as ref, total_ht as total_ht, date_commande as date_element"; 56 | break; 57 | case "actioncomm": 58 | $primary = 'id'; 59 | $sql = "SELECT $primary as rowid, ref_ext as ref, '' as total_ht, datep as date_element"; 60 | break; 61 | default: 62 | $sql = "SELECT $primary, ref, total_ht, datep as date_element"; 63 | break; 64 | } 65 | 66 | $sql .= " FROM " . MAIN_DB_PREFIX . $tablename; 67 | //TODO Fix sourcetype can be different from tablename (exemple project/projet) 68 | $sqlwhere=array(); 69 | if ($tablename!='contrat') { 70 | $sql_inner= $primary.' NOT IN (SELECT fk_source FROM ' . MAIN_DB_PREFIX . 'element_element WHERE targettype=\'' . $this->db->escape($lead->element) . '\''; 71 | $sql_inner.=' AND sourcetype=\''.$this->db->escape($tablename).'\')'; 72 | $sqlwhere[]= $sql_inner; 73 | } else { 74 | /* 75 | * A lead can be linked to only 1 contract 76 | * If there's already on contract linked to this lead 77 | * Then return an empty list 78 | */ 79 | $sql_inner=' '. $lead->id .' NOT IN (SELECT fk_target FROM ' . MAIN_DB_PREFIX . 'element_element WHERE targettype=\'' . $this->db->escape($lead->element) . '\''; 80 | $sql_inner.=' AND sourcetype=\''.$this->db->escape($tablename).'\')'; 81 | $sqlwhere[]= $sql_inner; 82 | } 83 | 84 | // Manage filter 85 | $sqlwhere[]= ' fk_soc=' . $this->db->escape($lead->fk_soc); 86 | $sqlwhere[]= ' entity IN ('.getEntity($tablename,1).')'; 87 | 88 | if (count($sqlwhere)>0) { 89 | $sql .= ' WHERE ' . implode(' AND ', $sqlwhere); 90 | } 91 | $sql .= $this->db->order('ref','DESC'); 92 | 93 | dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); 94 | 95 | $resql = $this->db->query($sql); 96 | if ($resql) { 97 | $num = $this->db->num_rows($resql); 98 | $i = 0; 99 | if ($num > 0) { 100 | $sellist = ''; 108 | return $sellist; 109 | } 110 | } 111 | $this->db->free($resql); 112 | 113 | return null; 114 | } 115 | 116 | /** 117 | * Return a HTML area with the reference of object and a navigation bar for a business object 118 | * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. 119 | * 120 | * @param object $object Show 121 | * @param string $paramid ID off parameter to use to name the id into the URL link 122 | * @param string $morehtml HTML content to output just before the nav bar 123 | * @param int $shownav Condition (navigation is shown if value is 1) 124 | * @param string $fieldid ID du champ en base a utiliser pour select next et previous 125 | * @param string $fieldref Ref du champ objet ref (object->ref) a utiliser pour select next et previous 126 | * @param string $morehtmlref HTML supplementaire a afficher apres ref 127 | * @param string $moreparam Param to add in nav link url. 128 | * 129 | * @return string Portion HTML avec ref + boutons nav 130 | */ 131 | function showrefnav_custom($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlright = '') 132 | { 133 | global $langs, $conf; 134 | 135 | $ret = ''; 136 | if (empty($fieldid)) 137 | $fieldid = 'rowid'; 138 | if (empty($fieldref)) 139 | $fieldref = 'ref'; 140 | 141 | // print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; 142 | $object->load_previous_next_ref_custom((isset($object->next_prev_filter) ? $object->next_prev_filter : ''), $fieldid); 143 | $previous_ref = $object->ref_previous ? '' . (empty($conf->dol_use_jmobile) ? img_picto($langs->trans("Previous"), 'previous.png') : ' ') . '' : ''; 144 | $next_ref = $object->ref_next ? '' . (empty($conf->dol_use_jmobile) ? img_picto($langs->trans("Next"), 'next.png') : ' ') . '' : ''; 145 | 146 | // print "xx".$previous_ref."x".$next_ref; 147 | if ($previous_ref || $next_ref || $morehtml) { 148 | $ret .= ''; 161 | $ret .= '
'; 149 | } 150 | 151 | $ret .= $object->$fieldref; 152 | if ($morehtmlref) { 153 | $ret .= ' ' . $morehtmlref; 154 | } 155 | 156 | if ($morehtml) { 157 | $ret .= '' . $morehtml; 158 | } 159 | if ($shownav && ($previous_ref || $next_ref)) { 160 | $ret .= '' . $previous_ref . '' . $next_ref; 162 | } 163 | if ($previous_ref || $next_ref || $morehtml) { 164 | $ret .= '
'; 165 | } 166 | return $ret; 167 | } 168 | 169 | /** 170 | * Return combo list of differents status 171 | * 172 | * @param string $selected Value 173 | * @param string $htmlname Name of the component 174 | * @param int $showempty Row 175 | * 176 | * @return string HTML select 177 | */ 178 | function select_lead_status($selected = '', $htmlname = 'leadstatus', $showempty = 1) 179 | { 180 | require_once 'lead.class.php'; 181 | $lead = new Lead($this->db); 182 | 183 | return $this->selectarray($htmlname, $lead->status, $selected, $showempty); 184 | } 185 | 186 | /** 187 | * Return combo list of differents type 188 | * 189 | * @param string $selected Value 190 | * @param string $htmlname Name of the component 191 | * @param int $showempty Row 192 | * 193 | * @return string HTML select 194 | */ 195 | function select_lead_type($selected = '', $htmlname = 'leadtype', $showempty = 1) 196 | { 197 | require_once 'lead.class.php'; 198 | $lead = new Lead($this->db); 199 | 200 | return $this->selectarray($htmlname, $lead->type, $selected, $showempty); 201 | } 202 | 203 | /** 204 | * Return combo list of differents type 205 | * 206 | * @param string $selected Value 207 | * @param string $htmlname Name of the component 208 | * @param int $showempty Row 209 | * @param array $filter Filter results 210 | * 211 | * @return string HTML select 212 | */ 213 | function select_lead($selected = '', $htmlname = 'leadid', $showempty = 1, $filter=array()) 214 | { 215 | $lead_array=array(); 216 | require_once 'lead.class.php'; 217 | 218 | $lead = new Lead($this->db); 219 | 220 | //[COMPAT v17] Pas besoin de versioncompare, le nom de la fonction ayant été changé pour la nouvelle realease du module 221 | $result = $lead->fetchAll('DESC', 't.ref', 0, 0, $filter); 222 | if ($result<0) { 223 | setEventMessages(null, $lead->errors, 'errors'); 224 | } 225 | foreach($lead->lines as $line) { 226 | $lead_array[$line->id] = $line->ref . '-'.$line->ref_int.' ('.$line->status_label.'-'.$line->type_label.')'; 227 | } 228 | if (count($lead_array)>0) { 229 | return $this->selectarray($htmlname, $lead_array, $selected, $showempty); 230 | } 231 | return null; 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /admin/admin_lead.php: -------------------------------------------------------------------------------- 1 | 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/lead.php 21 | * \ingroup lead 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/lead.lib.php'; 34 | require_once '../class/lead.class.php'; 35 | 36 | // Translations 37 | $langs->load("lead@lead"); 38 | $langs->load("admin"); 39 | 40 | // Access control 41 | if (! $user->admin) { 42 | accessforbidden(); 43 | } 44 | 45 | // Parameters 46 | $action = GETPOST('action', 'alpha'); 47 | $value = GETPOST('value', 'alpha'); 48 | $label = GETPOST('label', 'alpha'); 49 | $scandir = GETPOST('scandir', 'alpha'); 50 | 51 | /* 52 | * Actions 53 | */ 54 | 55 | if ($action == 'updateMask') { 56 | $maskconstlead = GETPOST('maskconstlead', 'alpha'); 57 | $masklead = GETPOST('masklead', 'alpha'); 58 | if ($maskconstlead) 59 | $res = dolibarr_set_const($db, $maskconstlead, $masklead, 'chaine', 0, '', $conf->entity); 60 | 61 | if (! $res > 0) 62 | $error ++; 63 | 64 | if (! $error) { 65 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 66 | } else { 67 | setEventMessages($langs->trans("Error"), null, 'errors'); 68 | } 69 | } else if ($action == 'setmod') { 70 | dolibarr_set_const($db, "LEAD_ADDON", $value, 'chaine', 0, '', $conf->entity); 71 | } else if ($action == 'setvar') { 72 | 73 | $nb_day = GETPOST('LEAD_NB_DAY_COSURE_AUTO', 'int'); 74 | if (! empty($nb_day)) { 75 | $res = dolibarr_set_const($db, 'LEAD_NB_DAY_COSURE_AUTO', $nb_day, 'chaine', 0, '', $conf->entity); 76 | } 77 | if (! $res > 0) { 78 | $error ++; 79 | } 80 | 81 | $user_goup = GETPOST('LEAD_GRP_USER_AFFECT', 'int'); 82 | if ($user_goup == - 1) 83 | $user_goup = ''; 84 | 85 | $res = dolibarr_set_const($db, 'LEAD_GRP_USER_AFFECT', $user_goup, 'chaine', 0, '', $conf->entity); 86 | if (! $res > 0) { 87 | $error ++; 88 | } 89 | 90 | $template = GETPOST('LEAD_PERSONNAL_TEMPLATE', 'alpha'); 91 | if (! file_exists(dol_buildpath($template))) { 92 | $template = ''; 93 | } 94 | 95 | $res = dolibarr_set_const($db, 'LEAD_PERSONNAL_TEMPLATE', $template, 'chaine', 0, '', $conf->entity); 96 | if (! $res > 0) { 97 | $error ++; 98 | } 99 | 100 | $force_use_thirdparty = GETPOST('LEAD_FORCE_USE_THIRDPARTY', 'int'); 101 | $res = dolibarr_set_const($db, 'LEAD_FORCE_USE_THIRDPARTY', $force_use_thirdparty, 'yesno', 0, '', $conf->entity); 102 | if (! $res > 0) { 103 | $error ++; 104 | } 105 | 106 | $allow_multiple = GETPOST('LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT', 'int'); 107 | $res = dolibarr_set_const($db, 'LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT', $allow_multiple, 'yesno', 0, '', $conf->entity); 108 | if (! $res > 0) { 109 | $error ++; 110 | } 111 | 112 | $LEAD_EVENT_RELANCE_TYPE = GETPOST('LEAD_EVENT_RELANCE_TYPE','none'); 113 | $res = dolibarr_set_const($db, 'LEAD_EVENT_RELANCE_TYPE', $LEAD_EVENT_RELANCE_TYPE, 'chaine', 0, '', $conf->entity); 114 | if (! $res > 0) { 115 | $error ++; 116 | } 117 | 118 | $errordb = 0; 119 | $errors = array(); 120 | if ($force_use_thirdparty == 1) { 121 | $sql = 'ALTER TABLE llx_lead ADD INDEX idx_llx_lead_fk_soc (fk_soc)'; 122 | $resql = $db->query($sql); 123 | if (! $resql && $db->errno() != 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') { 124 | $errordb ++; 125 | $errors[] = $db->lasterror; 126 | } 127 | 128 | $sql = 'ALTER TABLE llx_lead ADD CONSTRAINT llx_lead_ibfk_3 FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid)'; 129 | $resql = $db->query($sql); 130 | if (! $resql && $db->errno() != 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') { 131 | $errordb ++; 132 | $errors[] = $db->lasterror; 133 | } 134 | } else { 135 | $sql = 'ALTER TABLE llx_lead DROP FOREIGN KEY llx_lead_ibfk_3'; 136 | $resql = $db->query($sql); 137 | if (! $resql && ($db->errno() != 'DB_ERROR_NOSUCHFIELD' && $db->errno() != 'DB_ERROR_NO_INDEX_TO_DROP')) { 138 | $errordb ++; 139 | $errors[] = $db->lasterror; 140 | } 141 | $sql = 'ALTER TABLE llx_lead DROP INDEX idx_llx_lead_fk_soc'; 142 | $resql = $db->query($sql); 143 | if (! $resql && ($db->errno() != 'DB_ERROR_NOSUCHFIELD' && $db->errno() != 'DB_ERROR_NO_INDEX_TO_DROP')) { 144 | $errordb ++; 145 | $errors[] = $db->lasterror; 146 | } 147 | } 148 | if (! empty($errordb)) { 149 | setEventMessages(null, $errors, 'warnings'); 150 | } 151 | 152 | if (! $error) { 153 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 154 | } else { 155 | setEventMessages($langs->trans("Error"), null, 'errors'); 156 | } 157 | } 158 | 159 | /* 160 | * View 161 | */ 162 | $page_name = "LeadSetup"; 163 | llxHeader('', $langs->trans($page_name)); 164 | 165 | // Subheader 166 | $linkback = '' . $langs->trans("BackToModuleList") . ''; 167 | print load_fiche_titre($langs->trans($page_name), $linkback, "tools"); 168 | 169 | // Configuration header 170 | $head = leadAdminPrepareHead(); 171 | print dol_get_fiche_head($head, 'settings', $langs->trans("Module103111Name"), -1, "tools"); 172 | 173 | /* 174 | * Module numerotation 175 | */ 176 | print load_fiche_titre($langs->trans("LeadSetupPage"), '',"tools"); 177 | 178 | $dirmodels = array_merge(array( 179 | '/' 180 | ), ( array ) $conf->modules_parts['models']); 181 | 182 | print ''; 183 | print ''; 184 | print '\n"; 185 | print '\n"; 186 | print '\n"; 187 | print ''; 188 | print ''; 189 | print '' . "\n"; 190 | 191 | clearstatcache(); 192 | 193 | $form = new Form($db); 194 | 195 | foreach ( $dirmodels as $reldir ) { 196 | $dir = dol_buildpath($reldir . "core/modules/lead/"); 197 | 198 | if (is_dir($dir)) { 199 | $handle = opendir($dir); 200 | if (is_resource($handle)) { 201 | $var = true; 202 | 203 | while ( ($file = readdir($handle)) !== false ) { 204 | if ((substr($file, 0, 9) == 'mod_lead_') && substr($file, dol_strlen($file) - 3, 3) == 'php') { 205 | $file = substr($file, 0, dol_strlen($file) - 4); 206 | require_once $dir . $file . '.php'; 207 | 208 | /** 209 | * 210 | * @var ModeleNumRefLead $module 211 | */ 212 | $module = new $file(); 213 | 214 | // Show modules according to features level 215 | if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) 216 | continue; 217 | if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) 218 | continue; 219 | 220 | if ($module->isEnabled()) { 221 | $var = ! $var; 222 | print ''; 225 | 226 | // Show example of numbering module 227 | print '' . "\n"; 236 | 237 | print ''; 246 | 247 | $businesscase = new Lead($db); 248 | $businesscase->initAsSpecimen(); 249 | 250 | // Info 251 | $htmltooltip = ''; 252 | $htmltooltip .= '' . $langs->trans("Version") . ': ' . $module->getVersion() . '
'; 253 | $nextval = $module->getNextValue($user->id, $mysoc, $businesscase); 254 | if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval 255 | { 256 | $htmltooltip .= '' . $langs->trans("NextValue") . ': '; 257 | if ($nextval) { 258 | $htmltooltip .= $nextval . '
'; 259 | } else { 260 | $htmltooltip .= $langs->trans($module->error) . '
'; 261 | } 262 | } 263 | 264 | print ''; 267 | 268 | print "\n"; 269 | } 270 | } 271 | } 272 | closedir($handle); 273 | } 274 | } 275 | } 276 | print "
' . $langs->trans("Name") . "' . $langs->trans("Description") . "' . $langs->trans("Example") . "' . $langs->trans("Status") . '' . $langs->trans("Infos") . '
' . $module->nom . "\n"; 223 | print $module->info(); 224 | print ''; 228 | $tmp = $module->getExample(); 229 | if (preg_match('/^Error/', $tmp)) 230 | print '
' . $langs->trans($tmp) . '
'; 231 | elseif ($tmp == 'NotConfigured') 232 | print $langs->trans($tmp); 233 | else 234 | print $tmp; 235 | print '
'; 238 | if (getDolGlobalString('LEAD_ADDON') == "$file") { 239 | print img_picto($langs->trans("Activated"), 'switch_on'); 240 | } else { 241 | print ''; 242 | print img_picto($langs->trans("Disabled"), 'switch_off'); 243 | print ''; 244 | } 245 | print ''; 265 | print $form->textwithpicto('', $htmltooltip, 1, 0); 266 | print '

\n"; 277 | 278 | // Admin var of module 279 | print load_fiche_titre($langs->trans("LeadAdmVar"), '',"tools"); 280 | 281 | print '
'; 282 | print ''; 283 | print ''; 284 | 285 | print ''; 286 | 287 | print ''; 288 | print ''; 289 | print ''; 290 | print "\n"; 291 | 292 | // Nb Days 293 | print ''; 294 | print ''; 296 | print ''; 297 | 298 | // template 299 | print ''; 300 | print ''; 302 | print ''; 303 | 304 | // User Group 305 | print ''; 306 | print ''; 309 | 310 | // Force use thirdparty 311 | print ''; 312 | print ''; 319 | 320 | // Allow multiple lead on contract 321 | print ''; 322 | print ''; 329 | 330 | if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { 331 | 332 | print ''; 333 | print ''; 338 | } 339 | 340 | print '
' . $langs->trans("Name") . '' . $langs->trans("Valeur") . '
' . $langs->trans("LeadNbDayDefaultClosure") . ''; 295 | print '
Chemin du template personnel'; 301 | print '
' . $langs->trans("LeadUserGroupAffect") . ''; 307 | print $form->select_dolgroups(getDolGlobalInt('LEAD_GRP_USER_AFFECT'), 'LEAD_GRP_USER_AFFECT', 1, array(), 0, '', '', $conf->entity); 308 | print '
' . $langs->trans("LeadForceUseThirdparty") . info_admin($langs->trans("LeadForceUseThirdpartyHelp"),1) . ''; 313 | $arrval = array( 314 | '0' => $langs->trans("No"), 315 | '1' => $langs->trans("Yes") 316 | ); 317 | print $form->selectarray("LEAD_FORCE_USE_THIRDPARTY", $arrval, getDolGlobalInt('LEAD_FORCE_USE_THIRDPARTY')); 318 | print '
' . $langs->trans("LeadAllowMultipleOnContract") . ''; 323 | $arrval = array( 324 | '0' => $langs->trans("No"), 325 | '1' => $langs->trans("Yes") 326 | ); 327 | print $form->selectarray("LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT", $arrval, getDolGlobalInt('LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT')); 328 | print '
' . $langs->trans("LeadTypeRelance") . ''; 334 | dol_include_once('/core/class/html.formactions.class.php'); 335 | $formactions = new FormActions($db); 336 | $formactions->select_type_actions(getDolGlobalInt('LEAD_EVENT_RELANCE_TYPE'), "LEAD_EVENT_RELANCE_TYPE", "systemauto", 0, - 1); 337 | print '
'; 341 | 342 | print ''; 343 | print ''; 344 | 345 | print '
'; 346 | print '
'; 347 | 348 | print dol_get_fiche_end(-1); 349 | 350 | llxFooter(); 351 | 352 | $db->close(); 353 | -------------------------------------------------------------------------------- /class/leadstats.class.php: -------------------------------------------------------------------------------- 1 | 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 | include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; 19 | include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; 20 | 21 | /** 22 | * Class LeadStats 23 | * 24 | * Lead statistics 25 | */ 26 | class LeadStats extends Stats 27 | { 28 | /** @var DoliDB Database handler */ 29 | protected $db; 30 | /** @var Lead Current lead */ 31 | private $lead; 32 | /** @var int User ID */ 33 | public $userid; 34 | /** @var int Company ID */ 35 | public $socid; 36 | /** @var int Year */ 37 | public $year; 38 | /** @var int Month of the year */ 39 | public $yearmonth; 40 | /** @var int Status ID */ 41 | public $status; 42 | /** @var string Error message */ 43 | public $error; 44 | 45 | /** 46 | * Instanciate a new lead stat 47 | * 48 | * @param DoliDB $db Database handler 49 | */ 50 | function __construct($db) { 51 | global $conf, $user; 52 | 53 | $this->db = $db; 54 | 55 | require_once 'lead.class.php'; 56 | 57 | $this->lead = new Lead($this->db); 58 | } 59 | 60 | /** 61 | * Returns all leads grouped by type 62 | * 63 | * @param int $limit Limit results 64 | * 65 | * @return array|int 66 | * @throws Exception 67 | */ 68 | function getAllLeadByType($limit = 5) { 69 | global $conf, $user, $langs; 70 | 71 | $datay = array (); 72 | 73 | $sql = "SELECT"; 74 | $sql .= " count(DISTINCT t.rowid), t.fk_c_type"; 75 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; 76 | $sql .= $this->buildWhere(); 77 | $sql .= " GROUP BY t.fk_c_type"; 78 | 79 | $result = array (); 80 | $res = array (); 81 | 82 | dol_syslog(get_class($this) . '::' . __METHOD__ . "", LOG_DEBUG); 83 | $resql = $this->db->query($sql); 84 | if ($resql) { 85 | $num = $this->db->num_rows($resql); 86 | $i = 0; 87 | $other = 0; 88 | while ( $i < $num ) { 89 | $row = $this->db->fetch_row($resql); 90 | if ($i < $limit || $num == $limit) 91 | $result[$i] = array ( 92 | $this->lead->type[$row[1]] . '(' . $row[0] . ')', 93 | $row[0] 94 | ); 95 | else 96 | $other += $row[1]; 97 | $i ++; 98 | } 99 | if ($num > $limit) 100 | $result[$i] = array ( 101 | $langs->transnoentitiesnoconv("Other"), 102 | $other 103 | ); 104 | $this->db->free($resql); 105 | } else { 106 | $this->error = "Error " . $this->db->lasterror(); 107 | dol_syslog(get_class($this) . '::' . __METHOD__ . ' ' . $this->error, LOG_ERR); 108 | return - 1; 109 | } 110 | 111 | return $result; 112 | } 113 | 114 | /** 115 | * Return all leads grouped by status 116 | * 117 | * @param int $limit Limit results 118 | * 119 | * @return array|int 120 | * @throws Exception 121 | */ 122 | function getAllLeadByStatus($limit = 5) { 123 | global $conf, $user, $langs; 124 | 125 | $datay = array (); 126 | 127 | $sql = "SELECT"; 128 | $sql .= " count(DISTINCT t.rowid), t.fk_c_status"; 129 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; 130 | $sql .= $this->buildWhere(); 131 | $sql .= " GROUP BY t.fk_c_status"; 132 | 133 | $result = array (); 134 | $res = array (); 135 | 136 | dol_syslog(get_class($this) . '::' . __METHOD__ . "", LOG_DEBUG); 137 | $resql = $this->db->query($sql); 138 | if ($resql) { 139 | $num = $this->db->num_rows($resql); 140 | $i = 0; 141 | $other = 0; 142 | while ( $i < $num ) { 143 | $row = $this->db->fetch_row($resql); 144 | if ($i < $limit || $num == $limit) 145 | $result[$i] = array ( 146 | $this->lead->status[$row[1]] . '(' . $row[0] . ')', 147 | $row[0] 148 | ); 149 | else 150 | $other += $row[1]; 151 | $i ++; 152 | } 153 | if ($num > $limit) 154 | $result[$i] = array ( 155 | $langs->transnoentitiesnoconv("Other"), 156 | $other 157 | ); 158 | $this->db->free($resql); 159 | } else { 160 | $this->error = "Error " . $this->db->lasterror(); 161 | dol_syslog(get_class($this) . '::' . __METHOD__ . ' ' . $this->error, LOG_ERR); 162 | return - 1; 163 | } 164 | 165 | return $result; 166 | } 167 | 168 | /** 169 | * Return count, and sum of products 170 | * 171 | * @return array of values 172 | */ 173 | function getAllByYear() { 174 | global $conf, $user, $langs; 175 | 176 | $sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.amount_prosp) as total, AVG(t.amount_prosp) as avg"; 177 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; 178 | if (! $user->hasRight('societe', 'client', 'voir') ? $user->societe_id : $user->socid) 179 | $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; 180 | $sql .= $this->buildWhere(); 181 | $sql .= " GROUP BY year"; 182 | $sql .= $this->db->order('year', 'DESC'); 183 | 184 | return $this->_getAllByYear($sql); 185 | } 186 | 187 | /** 188 | * Build a where SQL snippet 189 | * 190 | * @return string SQL snippet 191 | */ 192 | public function buildWhere() { 193 | $sqlwhere_str = ''; 194 | $sqlwhere = array (); 195 | 196 | $sqlwhere[] = ' t.entity IN (' . getEntity('lead') . ')'; 197 | 198 | if (! empty($this->userid)) 199 | $sqlwhere[] = ' t.fk_user_resp=' . $this->userid; 200 | if (! empty($this->socid)) 201 | $sqlwhere[] = ' t.fk_soc=' . $this->socid; 202 | if (! empty($this->year) && empty($this->yearmonth)) 203 | $sqlwhere[] = " date_format(t.datec,'%Y')='" . $this->year . "'"; 204 | if (! empty($this->yearmonth)) 205 | $sqlwhere[] = " t.datec BETWEEN '" . $this->db->idate(dol_get_first_day($this->yearmonth)) . "' AND '" . $this->db->idate(dol_get_last_day($this->yearmonth)) . "'"; 206 | 207 | if (! empty($this->status)) 208 | $sqlwhere[] = " t.fk_c_status IN (" . $this->status . ")"; 209 | 210 | if (count($sqlwhere) > 0) { 211 | $sqlwhere_str = ' WHERE ' . implode(' AND ', $sqlwhere); 212 | } 213 | 214 | return $sqlwhere_str; 215 | } 216 | 217 | /** 218 | * Return Lead number by month for a year 219 | * 220 | * @param int $year scan 221 | * @return array of values 222 | */ 223 | function getNbByMonth($year, $format = 0) { 224 | global $user; 225 | 226 | $this->yearmonth = $year; 227 | 228 | $sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(*) as nb"; 229 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; 230 | if (! $user->hasRight('societe', 'client', 'voir') ? $user->societe_id : $user->socid) 231 | $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; 232 | $sql .= $this->buildWhere(); 233 | $sql .= " GROUP BY dm"; 234 | $sql .= $this->db->order('dm', 'DESC'); 235 | 236 | $this->yearmonth=0; 237 | 238 | $res = $this->_getNbByMonth($year, $sql); 239 | // var_dump($res);print '
'; 240 | return $res; 241 | } 242 | 243 | /** 244 | * Return the Lead amount by month for a year 245 | * 246 | * @param int $year scan 247 | * @return array with amount by month 248 | */ 249 | function getAmountByMonth($year, $format = 0) { 250 | global $user; 251 | 252 | $this->yearmonth = $year; 253 | 254 | $sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.amount_prosp)"; 255 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; 256 | if (! $user->hasRight('societe', 'client', 'voir') ? $user->societe_id : $user->socid) 257 | $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; 258 | $sql .= $this->buildWhere(); 259 | $sql .= " GROUP BY dm"; 260 | $sql .= $this->db->order('dm', 'DESC'); 261 | $this->yearmonth=0; 262 | 263 | $res = $this->_getAmountByMonth($year, $sql); 264 | // var_dump($res);print '
'; 265 | return $res; 266 | } 267 | 268 | /** 269 | * Return amount of elements by month for several years 270 | * 271 | * @param int $endyear End year 272 | * @param int $startyear Start year 273 | * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save) 274 | * @return array of values 275 | */ 276 | function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0) { 277 | global $conf, $user, $langs; 278 | 279 | if ($startyear > $endyear) 280 | return - 1; 281 | 282 | $datay = array (); 283 | 284 | // Search into cache 285 | if (! empty($cachedelay)) { 286 | include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; 287 | include_once DOL_DOCUMENT_ROOT . '/core/lib/json.lib.php'; 288 | } 289 | 290 | $newpathofdestfile = $conf->user->dir_temp . '/' . get_class($this) . '_' . __FUNCTION__ . '_' . (empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix . '_') . $langs->defaultlang . '_user' . $user->id . '.cache'; 291 | $newmask = '0644'; 292 | 293 | $nowgmt = dol_now(); 294 | 295 | $foundintocache = 0; 296 | if ($cachedelay > 0) { 297 | $filedate = dol_filemtime($newpathofdestfile); 298 | if ($filedate >= ($nowgmt - $cachedelay)) { 299 | $foundintocache = 1; 300 | 301 | $this->_lastfetchdate[get_class($this) . '_' . __FUNCTION__] = $filedate; 302 | } else { 303 | dol_syslog(get_class($this) . '::' . __FUNCTION__ . " cache file " . $newpathofdestfile . " is not found or older than now - cachedelay (" . $nowgmt . " - " . $cachedelay . ") so we can't use it."); 304 | } 305 | } 306 | 307 | // Load file into $data 308 | if ($foundintocache) // Cache file found and is not too old 309 | { 310 | dol_syslog(get_class($this) . '::' . __FUNCTION__ . " read data from cache file " . $newpathofdestfile . " " . $filedate . "."); 311 | $data = json_decode(file_get_contents($newpathofdestfile), true); 312 | } else { 313 | $year = $startyear; 314 | while ( $year <= $endyear ) { 315 | $datay[$year] = $this->getTransformRateByMonth($year); 316 | $year ++; 317 | } 318 | 319 | $data = array (); 320 | // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) 321 | for($i = 0; $i < 12; $i ++) { 322 | $data[$i][] = $datay[$endyear][$i][0]; // set label 323 | $year = $startyear; 324 | while ( $year <= $endyear ) { 325 | $data[$i][] = $datay[$year][$i][1]; // set yval for x=i 326 | $year ++; 327 | } 328 | } 329 | } 330 | 331 | // Save cache file 332 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) { 333 | dol_syslog(get_class($this) . '::' . __FUNCTION__ . " save cache file " . $newpathofdestfile . " onto disk."); 334 | if (! dol_is_dir($conf->user->dir_temp)) 335 | dol_mkdir($conf->user->dir_temp); 336 | $fp = fopen($newpathofdestfile, 'w'); 337 | fwrite($fp, json_encode($data)); 338 | fclose($fp); 339 | if (getDolGlobalString('MAIN_UMASK')) 340 | $newmask = getDolGlobalString('MAIN_UMASK'); 341 | @chmod($newpathofdestfile, octdec($newmask)); 342 | 343 | $this->_lastfetchdate[get_class($this) . '_' . __FUNCTION__] = $nowgmt; 344 | } 345 | 346 | return $data; 347 | } 348 | 349 | /** 350 | * Return the Lead transformation rate by month for a year 351 | * 352 | * @param int $year scan 353 | * @return array with amount by month 354 | */ 355 | function getTransformRateByMonth($year) { 356 | global $user; 357 | 358 | $this->yearmonth = $year; 359 | 360 | $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.amount_prosp)"; 361 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; 362 | if (! $user->hasRight('societe', 'client', 'voir') ? $user->societe_id : $user->socid) 363 | $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; 364 | $sql .= $this->buildWhere(); 365 | $sql .= " GROUP BY dm"; 366 | $sql .= $this->db->order('dm', 'DESC'); 367 | 368 | $res_total = $this->_getNbByMonth($year, $sql); 369 | 370 | $this->status=6; 371 | 372 | $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.amount_prosp)"; 373 | $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t"; 374 | if (! $user->hasRight('societe', 'client', 'voir') ? $user->societe_id : $user->socid) 375 | $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; 376 | $sql .= $this->buildWhere(); 377 | $sql .= " GROUP BY dm"; 378 | $sql .= $this->db->order('dm', 'DESC'); 379 | 380 | $this->status=0; 381 | $this->yearmonth=0; 382 | 383 | $res_only_wined = $this->_getNbByMonth($year, $sql); 384 | 385 | $res=array(); 386 | 387 | foreach($res_total as $key=>$total_row) { 388 | //var_dump($total_row); 389 | if (!empty($total_row[1])) { 390 | $res[$key]=array($total_row[0],(100*$res_only_wined[$key][1])/$total_row[1]); 391 | } else { 392 | $res[$key]=array($total_row[0],0); 393 | } 394 | 395 | } 396 | // var_dump($res);print '
'; 397 | return $res; 398 | } 399 | 400 | /** 401 | * @param int $year year number 402 | * @return int value 403 | */ 404 | public function getAverageByMonth($year) 405 | { 406 | 407 | } 408 | } 409 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 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 | $res = @include '../main.inc.php'; // For root directory 20 | if (! $res) 21 | $res = @include '../../main.inc.php'; // For "custom" directory 22 | if (! $res) 23 | die("Include of main fails"); 24 | 25 | require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; 26 | require_once 'lib/lead.lib.php'; 27 | 28 | require_once './class/leadstats.class.php'; 29 | 30 | // Security check 31 | if (! $user->hasRight('lead', 'read')) 32 | accessforbidden(); 33 | 34 | 35 | $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); 36 | $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); 37 | 38 | $userid=GETPOST('userid','int'); 39 | $socid=GETPOST('socid','int'); 40 | $mode=GETPOST('mode','alpha'); 41 | 42 | // Security check 43 | if ($user->socid > 0) 44 | { 45 | $action = ''; 46 | $socid = $user->socid; 47 | } 48 | $nowyear=strftime("%Y", dol_now()); 49 | $year = GETPOST('year','int')>0?GETPOST('year','int'):$nowyear; 50 | //$startyear=$year-2; 51 | $startyear=$year-1; 52 | $endyear=$year; 53 | 54 | $showpointvalue=1; 55 | $nocolor=0; 56 | 57 | $includeuserlist=array(); 58 | if (getDolGlobalInt('LEAD_GRP_USER_AFFECT')) { 59 | dol_include_once('/user/class/usergroup.class.php'); 60 | $usergroup=new UserGroup($db); 61 | $result=$usergroup->fetch(getDolGlobalInt('LEAD_GRP_USER_AFFECT')); 62 | if ($result < 0) 63 | setEventMessage($usergroup->error, 'errors'); 64 | 65 | $includeuserlisttmp=$usergroup->listUsersForGroup(); 66 | if (is_array($includeuserlisttmp) && count($includeuserlisttmp)>0) { 67 | foreach($includeuserlisttmp as $usertmp) { 68 | $includeuserlist[]=$usertmp->id; 69 | } 70 | 71 | } 72 | } 73 | 74 | $langs->load('lead@lead'); 75 | 76 | llxHeader('', $langs->trans('Module103111Name')); 77 | 78 | $stats_lead= new LeadStats($db); 79 | if (!empty($userid) && $userid!=-1) $stats_lead->userid=$userid; 80 | if (!empty($socid) && $socid!=-1) $stats_lead->socid=$socid; 81 | if (!empty($year)) $stats_lead->year=$year; 82 | 83 | $stats_lead->year=0; 84 | $data_all_year = $stats_lead->getAllByYear(); 85 | if (!empty($year)) $stats_lead->year=$year; 86 | $arrayyears=array(); 87 | foreach($data_all_year as $val) { 88 | $arrayyears[$val['year']]=$val['year']; 89 | } 90 | if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; 91 | 92 | 93 | $data1 = $stats_lead->getAllLeadByType(); 94 | if (!is_array($data1) && $data1<0) { 95 | setEventMessages($stats_lead->error, null, 'errors'); 96 | } 97 | if (empty($data1)) 98 | { 99 | $showpointvalue=0; 100 | $nocolor=1; 101 | $data1=array(array(0=>$langs->trans("None"),1=>1)); 102 | } 103 | 104 | $filenamenb = $conf->lead->dir_output . "/stats/leadbytype.png"; 105 | $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=leadstats&file=leadbytype.png'; 106 | $px = new DolGraph(); 107 | $mesg = $px->isGraphKo(); 108 | if (empty($mesg)) { 109 | $i=0;$tot=count($data1);$legend=array(); 110 | while ($i < $tot) 111 | { 112 | $data1[$i][0]=$data1[$i][0]; // Required to avoid error "Could not draw pie with labels contained inside canvas" 113 | $legend[]=$data1[$i][0]; 114 | $i++; 115 | } 116 | $px->SetData($data1); 117 | unset($data1); 118 | 119 | if ($nocolor) 120 | $px->SetDataColor(array ( 121 | array ( 122 | 220, 123 | 220, 124 | 220 125 | ) 126 | )); 127 | 128 | if(function_exists('SetPrecisionY')){ 129 | $px->SetPrecisionY(0); 130 | } 131 | 132 | $px->SetLegend($legend); 133 | $px->setShowLegend(0); 134 | $px->setShowPointValue($showpointvalue); 135 | $px->setShowPercent(1); 136 | $px->SetMaxValue($px->GetCeilMaxValue()); 137 | $px->SetWidth(300); 138 | $px->SetHeight(300); 139 | $px->SetShading(3); 140 | $px->SetHorizTickIncrement(1); 141 | $px->SetCssPrefix("cssboxes"); 142 | $px->SetType(array ( 143 | 'pie' 144 | )); 145 | $px->SetTitle($langs->trans('LeadNbLeadByType')); 146 | $result=$px->draw($filenamenb, $fileurlnb); 147 | if ($result<0) { 148 | setEventMessages($px->error, null, 'errors'); 149 | } 150 | } else { 151 | setEventMessages(null, $mesgs, 'errors'); 152 | } 153 | 154 | 155 | 156 | $stringtoshow = '
'; 157 | $stringtoshow .= $px->show(); 158 | $stringtoshow .= '
'; 159 | 160 | 161 | $data1 = $stats_lead->getAllLeadByStatus(); 162 | if (!is_array($data1) && $data1<0) { 163 | setEventMessages($stats_lead->error, null, 'errors'); 164 | } 165 | if (empty($data1)) 166 | { 167 | $showpointvalue=0; 168 | $nocolor=1; 169 | $data1=array(array(0=>$langs->trans("None"),1=>1)); 170 | } 171 | 172 | $filenamenb = $conf->lead->dir_output . "/stats/leadbystatus.png"; 173 | $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=leadstats&file=leadbystatus.png'; 174 | $px = new DolGraph(); 175 | $mesg = $px->isGraphKo(); 176 | 177 | 178 | if (empty($mesg)) { 179 | $i=0;$tot=count($data1);$legend=array(); 180 | while ($i < $tot) 181 | { 182 | $data1[$i][0]=$data1[$i][0]; // Required to avoid error "Could not draw pie with labels contained inside canvas" 183 | $legend[]=$data1[$i][0]; 184 | $i++; 185 | } 186 | $px->SetData($data1); 187 | unset($data1); 188 | 189 | if ($nocolor) 190 | $px->SetDataColor(array ( 191 | array ( 192 | 220, 193 | 220, 194 | 220 195 | ) 196 | )); 197 | 198 | if(function_exists('SetPrecisionY')) $px->SetPrecisionY(0); 199 | $px->setShowLegend(0); 200 | $px->setShowPointValue($showpointvalue); 201 | $px->setShowPercent(1); 202 | $px->SetMaxValue($px->GetCeilMaxValue()); 203 | $px->SetWidth(300); 204 | $px->SetHeight(300); 205 | $px->SetShading(3); 206 | $px->SetHorizTickIncrement(1); 207 | $px->SetCssPrefix("cssboxes"); 208 | $px->SetType(array ( 209 | 'pie' 210 | )); 211 | $px->SetTitle($langs->trans('LeadNbLeadByStatus')); 212 | $result=$px->draw($filenamenb, $fileurlnb); 213 | if ($result<0) { 214 | setEventMessages($px->error, null, 'errors'); 215 | } 216 | } else { 217 | setEventMessages(null, $mesgs, 'errors'); 218 | } 219 | 220 | 221 | $stringtoshow .='
'; 222 | $stringtoshow .= $px->show(); 223 | $stringtoshow .= '
'; 224 | 225 | // Build graphic number of object 226 | // $data = array(array('Lib',val1,val2,val3),...) 227 | $data = $stats_lead->getNbByMonthWithPrevYear($endyear,$startyear); 228 | //var_dump($data); 229 | 230 | $filenamenb = $conf->lead->dir_output . "/stats/leadnbprevyear-".$year.".png"; 231 | $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=leadstats&file=leadnbprevyear-'.$year.'.png'; 232 | 233 | $px1 = new DolGraph(); 234 | $mesg = $px1->isGraphKo(); 235 | if (! $mesg) 236 | { 237 | $px1->SetData($data); 238 | if(function_exists('SetPrecisionY')) $px->SetPrecisionY(0); 239 | $i=$startyear;$legend=array(); 240 | while ($i <= $endyear) 241 | { 242 | $legend[]=$i; 243 | $i++; 244 | } 245 | $px1->SetLegend($legend); 246 | $px1->SetMaxValue($px1->GetCeilMaxValue()); 247 | $px1->SetWidth($WIDTH); 248 | $px1->SetHeight($HEIGHT); 249 | $px1->SetYLabel($langs->trans("LeadNbLead")); 250 | $px1->SetShading(3); 251 | $px1->SetHorizTickIncrement(1); 252 | if(function_exists('SetPrecisionY')) $px->SetPrecisionY(0); 253 | $px1->mode='depth'; 254 | $px1->SetTitle($langs->trans("LeadNbLeadByMonth")); 255 | 256 | $px1->draw($filenamenb,$fileurlnb); 257 | } 258 | 259 | // Build graphic amount of object 260 | $data = $stats_lead->getAmountByMonthWithPrevYear($endyear,$startyear); 261 | //var_dump($data); 262 | // $data = array(array('Lib',val1,val2,val3),...) 263 | 264 | $filenamenb = $conf->lead->dir_output . "/stats/leadamountprevyear-".$year.".png"; 265 | $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=leadstats&file=leadamountprevyear-'.$year.'.png'; 266 | 267 | $px2 = new DolGraph(); 268 | $mesg = $px2->isGraphKo(); 269 | if (! $mesg) 270 | { 271 | $px2->SetData($data); 272 | $i=$startyear;$legend=array(); 273 | while ($i <= $endyear) 274 | { 275 | $legend[]=$i; 276 | $i++; 277 | } 278 | $px2->SetLegend($legend); 279 | $px2->SetMaxValue($px2->GetCeilMaxValue()); 280 | $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); 281 | $px2->SetWidth($WIDTH); 282 | $px2->SetHeight($HEIGHT); 283 | $px2->SetYLabel($langs->trans("LeadAmountOfLead")); 284 | $px2->SetShading(3); 285 | $px2->SetHorizTickIncrement(1); 286 | if(function_exists('SetPrecisionY')) $px->SetPrecisionY(0); 287 | $px2->mode='depth'; 288 | $px2->SetTitle($langs->trans("LeadAmountOfLeadsByMonth")); 289 | 290 | $px2->draw($filenamenb,$fileurlnb); 291 | } 292 | 293 | // Build graphic with transformation rate 294 | $data = $stats_lead->getTransformRateByMonthWithPrevYear($endyear,$startyear); 295 | //var_dump($data); 296 | // $data = array(array('Lib',val1,val2,val3),...) 297 | 298 | $filenamenb = $conf->lead->dir_output . "/stats/leadtransrateprevyear-".$year.".png"; 299 | $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=leadstats&file=leadtransrateprevyear-'.$year.'.png'; 300 | 301 | $px3 = new DolGraph(); 302 | $mesg = $px3->isGraphKo(); 303 | if (! $mesg) 304 | { 305 | $px3->SetData($data); 306 | $i=$startyear;$legend=array(); 307 | while ($i <= $endyear) 308 | { 309 | $legend[]=$i; 310 | $i++; 311 | } 312 | $px3->SetLegend($legend); 313 | $px3->SetMaxValue($px3->GetCeilMaxValue()); 314 | $px3->SetMinValue(min(0,$px3->GetFloorMinValue())); 315 | $px3->SetWidth($WIDTH); 316 | $px3->SetHeight($HEIGHT); 317 | $px3->SetYLabel($langs->trans("LeadTransRateOfLead")); 318 | $px3->SetShading(3); 319 | $px3->SetHorizTickIncrement(1); 320 | if(function_exists('SetPrecisionY')) $px3->SetPrecisionY(0); 321 | $px3->mode='depth'; 322 | $px3->SetTitle($langs->trans("LeadTransRateOfLeadsByMonth")); 323 | 324 | $px3->draw($filenamenb,$fileurlnb); 325 | } 326 | 327 | $stringtoshow.= '
'; 328 | if ($mesg) { print $mesg; } 329 | else { 330 | $stringtoshow.= $px1->show(); 331 | $stringtoshow.= "
\n"; 332 | $stringtoshow.= $px2->show(); 333 | $stringtoshow.= "
\n"; 334 | $stringtoshow.= $px3->show(); 335 | } 336 | $stringtoshow.= '
'; 337 | 338 | $head = lead_stats_prepare_head(); 339 | 340 | dol_fiche_head($head,'stat',$langs->trans("Statistics"), 0, dol_buildpath('/lead/img/object_lead.png', 1), 1); 341 | 342 | $form=new Form($db); 343 | 344 | print '
'; 345 | 346 | print '
'; 347 | 348 | $newToken = function_exists('newToken') ? newToken() : $_SESSION['newtoken']; 349 | print ''; 350 | 351 | print ''; 352 | print ''; 353 | // Company 354 | print ''; 360 | // User 361 | print ''; 364 | // Year 365 | print ''; 371 | print ''; 372 | print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; 355 | $filter=''; 356 | if ($mode == 'customer') $filter='s.client in (1,2,3)'; 357 | if ($mode == 'supplier') $filter='s.fournisseur = 1'; 358 | print $form->select_thirdparty_list($socid,'socid',$filter,1); 359 | print '
'.$langs->trans("LeadCommercial").''; 362 | print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist); 363 | print '
'.$langs->trans("Year").''; 366 | if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; 367 | if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; 368 | arsort($arrayyears); 369 | print $form->selectarray('year',$arrayyears,$year,0); 370 | print '
'; 373 | print '
'; 374 | print '

'; 375 | 376 | print ''; 377 | print ''; 378 | print ''; 379 | print ''; 380 | print ''; 381 | print ''; 382 | print ''; 383 | 384 | $oldyear=0; 385 | foreach ($data_all_year as $val) 386 | { 387 | $year = $val['year']; 388 | while ($year && $oldyear > $year+1) 389 | { // If we have empty year 390 | $oldyear--; 391 | print ''; 392 | print ''; 393 | print ''; 394 | print ''; 395 | print ''; 396 | print ''; 397 | } 398 | print ''; 399 | print ''; 400 | print ''; 401 | print ''; 402 | print ''; 403 | print ''; 404 | $oldyear=$year; 405 | } 406 | 407 | print '
'.$langs->trans("Year").''.$langs->trans("LeadNbLead").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
0?'&userid='.$userid:'').'">'.$oldyear.'000
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).'
'; 408 | 409 | print '
'; 410 | 411 | 412 | // Show graphs 413 | print '
'; 414 | if ($mesg) { print $mesg; } 415 | else { 416 | print $stringtoshow; 417 | } 418 | print '
'; 419 | 420 | 421 | print '
'; 422 | print '
'; 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | print ''; 431 | 432 | print '
'; 433 | 434 | dol_fiche_end(); 435 | llxFooter(); 436 | $db->close(); 437 | -------------------------------------------------------------------------------- /class/actions_lead.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 htdocs/lead/class/actions_lead.class.php 20 | * \ingroup lead 21 | * \brief Fichier de la classe des actions/hooks des lead 22 | */ 23 | require_once __DIR__.'/../backport/v19/core/class/commonhookactions.class.php'; 24 | 25 | class ActionsLead extends lead\RetroCompatCommonHookActions // extends CommonObject 26 | { 27 | 28 | /** 29 | * Overloading the doActions function : replacing the parent's function with the one below 30 | * 31 | * @param string[] $parameters meta datas of the hook (context, etc...) 32 | * @param Lead $object the object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 33 | * @param string $action current action (if set). Generally create or edit or null 34 | * @return int Hook status 35 | */ 36 | function showLinkedObjectBlock($parameters, $object, $action) { 37 | global $conf, $langs, $db, $user; 38 | 39 | if (!$user->hasRight('lead', 'read')) 40 | { 41 | return 0; 42 | } 43 | 44 | require_once 'lead.class.php'; 45 | 46 | $lead = new Lead($db); 47 | 48 | $authorized_object = array (); 49 | foreach ( $lead->listofreferent as $referent ) { 50 | $authorized_object[] = $referent['table']; 51 | } 52 | 53 | if (is_object($object) && in_array($object->table_element, $authorized_object)) { 54 | $langs->load("lead@lead"); 55 | require_once 'html.formlead.class.php'; 56 | 57 | $formlead = new FormLead($db); 58 | 59 | $ret = $lead->fetchLeadLink((!empty($object->rowid) ? $id = $object->rowid : $object->id), $object->table_element); 60 | if ($ret < 0) { 61 | setEventMessages(null, $lead->errors, 'errors'); 62 | } 63 | // Build exlcude already linked lead 64 | $array_exclude_lead = array (); 65 | foreach ( $lead->doclines as $line ) { 66 | $array_exclude_lead[] = $line->id; 67 | } 68 | 69 | print '
'; 70 | print_fiche_titre($langs->trans('Lead')); 71 | if (count($lead->doclines) == 0 || ($object->table_element=='contrat' && getDolGlobalString('LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT'))) { 72 | print '
'; 73 | print ''; 74 | print ''; 75 | print ''; 76 | print ''; 77 | print ''; 78 | } 79 | print ""; 80 | print ""; 81 | print ""; 82 | print ""; 83 | $filter = array ( 84 | 'so.rowid' => (!empty($object->fk_soc) ? $object->fk_soc : $object->socid) 85 | ); 86 | if (count($array_exclude_lead) > 0) { 87 | $filter['t.rowid !IN'] = implode(',', $array_exclude_lead); 88 | } 89 | $selectList = $formlead->select_lead('', 'leadid', 1, $filter); 90 | if (! empty($selectList) && (count($lead->doclines) == 0 || ($object->table_element=='contrat' && getDolGlobalString('LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT')))) { 91 | print ''; 92 | print ''; 96 | print ''; 97 | } 98 | 99 | foreach ( $lead->doclines as $line ) { 100 | print ''; 108 | print ''; 109 | } 110 | print "
" . $langs->trans('LeadLink') . "
'; 93 | print $selectList; 94 | print ""; 95 | print '
'; 101 | print $line->getNomUrl(1).' - '.$line->ref_int.' ('.$line->status_label.' - '.$line->type_label.')'; 102 | print 'rowid) ? $object->rowid : $object->id); 103 | print '&sourcetype=' . $object->table_element; 104 | print '&leadid=' . $line->id; 105 | print '&redirect=' . urlencode($_SERVER['REQUEST_URI']); 106 | print '">' . img_picto($langs->trans('LeadUnlinkDoc'), 'unlink.png@lead') . ''; 107 | print '
"; 111 | if (count($lead->doclines) == 0 || ($object->table_element=='contrat' && getDolGlobalString('LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT'))) { 112 | print "
"; 113 | } 114 | } 115 | 116 | // Always OK 117 | return 0; 118 | } 119 | 120 | /** 121 | * addMoreActionsButtons Method Hook Call 122 | * 123 | * @param string[] $parameters parameters 124 | * @param CommonObject $object Object to use hooks on 125 | * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) 126 | * @param HookManager $hookmanager class instance 127 | * @return int Hook status 128 | */ 129 | function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) { 130 | global $langs, $conf, $user, $db ,$bc; 131 | 132 | $current_context = explode(':', $parameters['context']); 133 | 134 | if (in_array('commcard', $current_context) || in_array('thirdpartycomm', $current_context)) { 135 | $langs->load("lead@lead"); 136 | 137 | if ($user->hasRight('lead', 'write')) { 138 | $html = ''; 139 | } else { 140 | $html = ''; 141 | } 142 | 143 | $html = str_replace('"', '\"', $html); 144 | 145 | $js= ''; 151 | print $js; 152 | 153 | if ($user->hasRight('lead', 'read')) { 154 | 155 | require_once 'lead.class.php'; 156 | $lead = new Lead($db); 157 | 158 | $filter['so.rowid'] = $object->id; 159 | 160 | //[COMPAT v17] Pas besoin de versioncompare, le nom de la fonction ayant été changé pour la nouvelle realease du module 161 | $resql = $lead->fetchAll('DESC', 't.date_closure', 0, 0, $filter); 162 | 163 | if ($resql == - 1) { 164 | setEventMessages(null, $object->errors, 'errors'); 165 | } 166 | 167 | $total_lead = count($lead->lines); 168 | 169 | // $filter['so.rowid'] = $object->id; 170 | //[COMPAT v17] Pas besoin de versioncompare, le nom de la fonction ayant été changé pour la nouvelle realease du module 171 | $resql = $lead->fetchAll('DESC', 't.date_closure', 3, 0, $filter); 172 | if ($resql == - 1) { 173 | setEventMessages(null, $object->errors, 'errors'); 174 | } 175 | 176 | $num = count($lead->lines); 177 | 178 | $html = ''; 179 | 180 | $html .= ''; 181 | $html .= ''; 185 | $html .= ''; 186 | 187 | foreach ( $lead->lines as $lead_line ) { 188 | $var = ! $var; 189 | $html .=''; 190 | $html .= ''; 191 | $html .= ''; 192 | $html .= ''; 193 | $html .= ''; 194 | $html .= ''; 195 | $html .= ''; 196 | $html .= ''; 197 | } 198 | 199 | $html .= '
'; 182 | $html .= ''; 183 | $html .= ''; 184 | $html .= '
' . $langs->trans("LeadLastLeadUpdated", ($num <= 4 ? $num : 4)) . '' . $langs->trans("LeadList") . ' (' . $total_lead . ')' . img_picto($langs->trans("Statistics"), 'stats') . '
'.$lead_line->getNomUrl(1).''.$lead_line->ref_int.''.$lead_line->type_label.''.price($lead_line->amount_prosp) . ' ' . $langs->getCurrencySymbol($conf->currency).''.dol_print_date($lead_line->date_closure, 'daytextshort').''.$lead_line->getLibStatut(2).'
'; 200 | $html = str_replace('"', '\"', $html); 201 | $classToAppend = 'fichehalfright'; 202 | $js= ''; 208 | print $js; 209 | } 210 | } 211 | if (in_array('propalcard', $current_context)) { 212 | require_once 'lead.class.php'; 213 | $lead = new Lead($db); 214 | 215 | $ret = $lead->fetchLeadLink((!empty($object->rowid) ? $id = $object->rowid : $object->id), $object->table_element); 216 | if ($ret < 0) { 217 | setEventMessages(null, $lead->errors, 'errors'); 218 | } 219 | 220 | if (count($lead->doclines) == 0) { 221 | $langs->load("lead@lead"); 222 | 223 | if ($user->hasRight('lead', 'write')) { 224 | $html = ''; 225 | } else { 226 | $html = ''; 227 | } 228 | 229 | $html = str_replace('"', '\"', $html); 230 | $js= ''; 236 | print $js; 237 | } 238 | } 239 | 240 | // Always OK 241 | return 0; 242 | } 243 | 244 | /** 245 | * addSearchEntry Method Hook Call 246 | * 247 | * @param array $parameters parameters 248 | * @param Object &$object Object to use hooks on 249 | * @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) 250 | * @param object $hookmanager class instance 251 | * @return void 252 | */ 253 | public function addSearchEntry($parameters, &$object, &$action, $hookmanager) { 254 | global $langs, $db, $user; 255 | 256 | if (!$user->hasRight('lead', 'read')){ 257 | return 0; 258 | } 259 | 260 | $search_boxvalue = $parameters['search_boxvalue']; 261 | 262 | $langs->load('lead@lead'); 263 | $this->results['searchintolead'] = array ( 264 | 'position' => 103111, 265 | 'text' => img_object('', 'lead@lead') . ' ' . $langs->trans("Module103111Name"), 266 | 'url' => dol_buildpath('/lead/lead/list.php', 1) . '?search_ref=' . urlencode($parameters['search_boxvalue']) 267 | ); 268 | 269 | return 0; 270 | } 271 | 272 | /** 273 | * @param $parameters 274 | * @param $object 275 | * @param $action 276 | * @param $hookmanager 277 | * @return void 278 | * @throws Exception 279 | */ 280 | public function createFrom($parameters, &$object, &$action, $hookmanager){ 281 | global $db; 282 | 283 | if (in_array('invoicecard',explode(':',$parameters['context']))) 284 | { 285 | // lorsque qu'une propal est liée à une affaire et que l'on créer une facture 286 | // depuis cette propale, nous voulons que cette facture soit également liée à l'affaire. 287 | // 288 | // on test que le objFRom est bien un obj propal 289 | if ($parameters['objFrom'] instanceof Propal ){ 290 | 291 | // on recupere l'id de l'affaire linké à la propal 292 | $obj = $parameters['objFrom']; 293 | $obj->fetchObjectLinked(); 294 | 295 | 296 | if (is_array($obj->linkedObjectsIds) && array_key_exists('lead',$obj->linkedObjectsIds) && count($obj->linkedObjectsIds['lead']) == 1) { 297 | $leadId = array_pop($obj->linkedObjectsIds['lead']); 298 | $lead = new Lead($db); 299 | $result = $lead->fetch($leadId); 300 | if ($result){ 301 | // link de la facture à l'affaire 302 | $lead->add_object_linked('facture', $object->id); 303 | dol_syslog("linked lead to invoice. ",6); 304 | }else{ 305 | dol_syslog("fetch lead error. id lead : ".$leadId . ", facture id : ".$object->id ,3); 306 | } 307 | } 308 | } 309 | } 310 | } 311 | 312 | /** 313 | * count tab incident 314 | * 315 | * @param array $parameters Array of parameters 316 | * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 317 | * @param string $action 'add', 'update', 'view' 318 | * @param Hookmanager $hookmanager hookmanager 319 | * @return int Return integer <0 if KO, 320 | * =0 if OK but we want to process standard actions too, 321 | * >0 if OK and we want to replace standard actions. 322 | */ 323 | public function completeTabsHead(&$parameters, $object, &$action, $hookmanager) 324 | { 325 | global $langs, $db; 326 | if (in_array('thirdpartydao', explode(':',$parameters['context']))){ 327 | require_once __DIR__.'/lead.class.php'; 328 | $lead = new Lead($db); 329 | foreach ($parameters['head'] as $h => &$headV) if(!empty($headV) && $headV[1] == $langs->trans("Module103111Name")){ 330 | $nbtotalofrecords = $lead->fetchAll('', '', 0, 0, array('so.rowid' => $object->id)); 331 | if ($nbtotalofrecords > 0) { 332 | $headV[1] = $headV[1] . ' ' . $nbtotalofrecords . ''; 333 | } 334 | } 335 | $this->results = $parameters['head']; 336 | return 1; 337 | } 338 | return 0; 339 | } 340 | 341 | } 342 | -------------------------------------------------------------------------------- /core/modules/modLead.class.php: -------------------------------------------------------------------------------- 1 | 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 | * \defgroup lead Lead module 21 | * \brief Lead module descriptor. 22 | * \file core/modules/modLead.class.php 23 | * \ingroup lead 24 | * \brief Description and activation file for module Lead 25 | */ 26 | include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php"; 27 | 28 | /** 29 | * Description and activation class for module Lead 30 | */ 31 | class modLead extends DolibarrModules 32 | { 33 | 34 | /** 35 | * Constructor. 36 | * Define names, constants, directories, boxes, permissions 37 | * 38 | * @param DoliDB $db 39 | */ 40 | public function __construct($db) 41 | { 42 | global $langs, $conf; 43 | 44 | $this->db = $db; 45 | 46 | // Id for module (must be unique). 47 | // Use a free id here 48 | // (See in Home -> System information -> Dolibarr for list of used modules id). 49 | $this->numero = 103111; 50 | $this->editor_name = 'ATM Consulting'; 51 | $this->editor_url = 'https://www.atm-consulting.fr'; 52 | // Key text used to identify module (for permissions, menus, etc...) 53 | $this->rights_class = 'lead'; 54 | 55 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' 56 | // It is used to group modules in module setup page 57 | $this->family = "ATM Consulting"; 58 | // Module label (no space allowed) 59 | // used if translation string 'ModuleXXXName' not found 60 | // (where XXX is value of numeric property 'numero' of module) 61 | $this->name = preg_replace('/^mod/i', '', get_class($this)); 62 | // Module description 63 | // used if translation string 'ModuleXXXDesc' not found 64 | // (where XXX is value of numeric property 'numero' of module) 65 | $this->description = "Description of module Lead"; 66 | // Possible values for version are: 'development', 'experimental' or version 67 | 68 | 69 | $this->version = '2.7.0'; 70 | 71 | 72 | // Key used in llx_const table to save module status enabled/disabled 73 | // (where MYMODULE is value of property name of module in uppercase) 74 | $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); 75 | // Where to store the module in setup page 76 | // (0=common,1=interface,2=others,3=very specific) 77 | $this->special = 0; 78 | // Name of image file used for this module. 79 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png 80 | // use this->picto='pictovalue' 81 | // If file is in module/img directory under name object_pictovalue.png 82 | // use this->picto='pictovalue@module' 83 | $this->picto = 'module.svg@lead'; // mypicto@lead 84 | // Defined all module parts (triggers, login, substitutions, menus, css, etc...) 85 | // for default path (eg: /lead/core/xxxxx) (0=disable, 1=enable) 86 | // for specific path of parts (eg: /lead/core/modules/barcode) 87 | // for specific css file (eg: /lead/css/lead.css.php) 88 | $this->module_parts = array( 89 | // Set this to 1 if module has its own trigger directory 90 | // 'triggers' => 1, 91 | // Set this to 1 if module has its own login method directory 92 | // 'login' => 0, 93 | // Set this to 1 if module has its own substitution function file 94 | // 'substitutions' => 0, 95 | // Set this to 1 if module has its own menus handler directory 96 | // 'menus' => 0, 97 | // Set this to 1 if module has its own barcode directory 98 | // 'barcode' => 0, 99 | // Set this to 1 if module has its own models directory 100 | 'models' => 1, 101 | // Set this to relative path of css if module has its own css file 102 | // 'css' => '/lead/css/mycss.css.php', 103 | // Set here all hooks context managed by module 104 | 'hooks' => array('commonobject','commcard','propalcard','contractcard','ordercard','searchform','invoicecard', 'thirdpartycard'), 105 | // Set here all workflow context managed by module 106 | // 'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) 107 | ); 108 | 109 | // Data directories to create when module is enabled. 110 | // Example: this->dirs = array("/lead/temp"); 111 | $this->dirs = array( 112 | '/lead', 113 | '/lead/stats' 114 | ); 115 | 116 | 117 | // Url to the file with your last numberversion of this module 118 | require_once __DIR__ . '/../../class/techatm.class.php'; 119 | $this->url_last_version = \lead\TechATM::getLastModuleVersionUrl($this); 120 | 121 | // Config pages. Put here list of php pages 122 | // stored into lead/admin directory, used to setup module. 123 | $this->config_page_url = array( 124 | "admin_lead.php@lead" 125 | ); 126 | 127 | // Dependencies 128 | // List of modules id that must be enabled if this module is enabled 129 | $this->depends = array(); 130 | // List of modules id to disable if this one is disabled 131 | $this->requiredby = array(); 132 | // Minimum version of PHP required by module 133 | $this->phpmin = array( 134 | 7, 135 | 0 136 | ); 137 | // Minimum version of Dolibarr required by module 138 | $this->need_dolibarr_version = array( 139 | 17, 140 | 0 141 | ); 142 | $this->langfiles = array( 143 | "lead@lead" 144 | ); // langfiles@lead 145 | // Constants 146 | // List of particular constants to add when module is enabled 147 | // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) 148 | // Example: 149 | $this->const = array( 150 | 0 => array( 151 | 'LEAD_ADDON', 152 | 'chaine', 153 | 'mod_lead_simple', 154 | 'Numbering lead rule', 155 | 0, 156 | 'current', 157 | 1 158 | ), 159 | 1 => array( 160 | 'LEAD_UNIVERSAL_MASK', 161 | 'chaine', 162 | '', 163 | 'Numbering lead rule', 164 | 0, 165 | 'current', 166 | 1 167 | ), 168 | 2 => array( 169 | 'LEAD_NB_DAY_COSURE_AUTO', 170 | 'chaine', 171 | '30', 172 | 'Numbering lead rule', 173 | 0, 174 | 'current', 175 | 1 176 | ), 177 | 3 => array( 178 | 'LEAD_GRP_USER_AFFECT', 179 | 'chaine', 180 | '', 181 | 'User Group that can affected', 182 | 0, 183 | 'current', 184 | 1 185 | ), 186 | 4 => array( 187 | 'LEAD_FORCE_USE_THIRDPARTY', 188 | 'yesno', 189 | '1', 190 | 'force LEad to use customer', 191 | 0, 192 | 'current', 193 | 1 194 | ), 195 | 5 => array( 196 | 'LEAD_ALLOW_MULIPLE_LEAD_ON_CONTRACT', 197 | 'yesno', 198 | '0', 199 | 'Allow to attach several leads to a single contract', 200 | 0, 201 | 'current', 202 | 1 203 | ) 204 | ); 205 | 206 | // Array to add new pages in new tabs 207 | // Example: 208 | $this->tabs = array( 209 | 'thirdparty:+tabLead:Module103111Name:lead@lead:$user->hasRight("lead", "read"):/lead/lead/list.php?socid=__ID__', 210 | // 'thirdparty:+tabLead:Module103111Name:lead@lead:$user->hasRight("lead", "read") && ($object->client > 0 || $soc->client > 0):/lead/lead/list.php?socid=__ID__', 211 | //'invoice:+tabAgefodd:AgfMenuSess:agefodd@agefodd:/lead/lead/list.php?search_invoiceid=__ID__', 212 | //'propal:+tabAgefodd:AgfMenuSess:agefodd@agefodd:/lead/lead/list.php?search_propalid=__ID__', 213 | // // To add a new tab identified by code tabname1 214 | // 'objecttype:+tabname1:Title1:langfile@lead:$user->hasRight('lead', 'read'):/lead/mynewtab1.php?id=__ID__', 215 | // // To add another new tab identified by code tabname2 216 | // 'objecttype:+tabname2:Title2:langfile@lead:$user->hasRight('othermodule', 'read'):/lead/mynewtab2.php?id=__ID__', 217 | // // To remove an existing tab identified by code tabname 218 | // 'objecttype:-tabname' 219 | ); 220 | // where objecttype can be 221 | // 'thirdparty' to add a tab in third party view 222 | // 'intervention' to add a tab in intervention view 223 | // 'order_supplier' to add a tab in supplier order view 224 | // 'invoice_supplier' to add a tab in supplier invoice view 225 | // 'invoice' to add a tab in customer invoice view 226 | // 'order' to add a tab in customer order view 227 | // 'product' to add a tab in product view 228 | // 'stock' to add a tab in stock view 229 | // 'propal' to add a tab in propal view 230 | // 'member' to add a tab in fundation member view 231 | // 'contract' to add a tab in contract view 232 | // 'user' to add a tab in user view 233 | // 'group' to add a tab in group view 234 | // 'contact' to add a tab in contact view 235 | // 'categories_x' to add a tab in category view 236 | // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) 237 | // Dictionnaries 238 | if (! isModEnabled('lead')) { 239 | $conf->lead = (object) array(); 240 | $conf->lead->enabled = 0; 241 | } 242 | 243 | $this->dictionnaries = array( 244 | 'langs' => 'lead@lead', 245 | 'tabname' => array( 246 | $db->prefix() . "c_lead_status", 247 | $db->prefix() . "c_lead_type" 248 | ), 249 | 'tablib' => array( 250 | "LeadStatusDict", 251 | "LeadTypeDict" 252 | ), 253 | 'tabsql' => array( 254 | 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM ' . MAIN_DB_PREFIX . 'c_lead_status as f', 255 | 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM ' . MAIN_DB_PREFIX . 'c_lead_type as f' 256 | ), 257 | 'tabsqlsort' => array( 258 | 'code ASC', 259 | 'code ASC' 260 | ), 261 | 'tabfield' => array( 262 | "code,label", 263 | "code,label" 264 | ), 265 | 'tabfieldvalue' => array( 266 | "code,label", 267 | "code,label" 268 | ), 269 | 'tabfieldinsert' => array( 270 | "code,label", 271 | "code,label" 272 | ), 273 | 'tabrowid' => array( 274 | "rowid", 275 | "rowid" 276 | ), 277 | 'tabcond' => array( 278 | 'isModEnabled(\'lead\')', 279 | 'isModEnabled(\'lead\')' 280 | ) 281 | ); 282 | 283 | // Boxes 284 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. 285 | $this->boxes = array(); // Boxes list 286 | $r = 0; 287 | // Example: 288 | 289 | $this->boxes[$r][1] = "box_lead_current@lead"; 290 | $r ++; 291 | $this->boxes[$r][1] = "box_lead_late@lead"; 292 | /* 293 | * $this->boxes[$r][1] = "myboxb.php"; $r++; 294 | */ 295 | 296 | // Permissions 297 | $this->rights = array(); // Permission array used by this module 298 | $r = 0; 299 | $this->rights[$r][0] = 1031111; 300 | $this->rights[$r][1] = 'See Leads'; 301 | $this->rights[$r][3] = 0; 302 | $this->rights[$r][4] = 'read'; 303 | $r ++; 304 | 305 | $this->rights[$r][0] = 1031112; 306 | $this->rights[$r][1] = 'Update Leads'; 307 | $this->rights[$r][3] = 0; 308 | $this->rights[$r][4] = 'write'; 309 | $r ++; 310 | 311 | $this->rights[$r][0] = 1031113; 312 | $this->rights[$r][1] = 'Delete Leads'; 313 | $this->rights[$r][3] = 0; 314 | $this->rights[$r][4] = 'delete'; 315 | $r ++; 316 | 317 | $this->rights[$r][0] = 1031114; 318 | $this->rights[$r][1] = 'Export Leads'; 319 | $this->rights[$r][3] = 0; 320 | $this->rights[$r][4] = 'export'; 321 | $r ++; 322 | 323 | // $r++; 324 | // Main menu entries 325 | $this->menus = array(); // List of menus to add 326 | $r = 0; 327 | 328 | $this->menu[$r] = array( 329 | 'fk_menu' => 0, 330 | 'type' => 'top', 331 | 'titre' => 'Module103111Name', 332 | 'mainmenu' => 'lead', 333 | 'leftmenu' => '0', 334 | 'url' => '/lead/index.php', 335 | 'langs' => 'lead@lead', 336 | 'position' => 100, 337 | 'enabled' => '$user->hasRight("lead", "read")', 338 | 'perms' => '$user->hasRight("lead", "read")', 339 | 'target' => '', 340 | 'user' => 0 341 | ); 342 | $r ++; 343 | 344 | $this->menu[$r] = array( 345 | 'fk_menu' => 'fk_mainmenu=lead', 346 | 'type' => 'left', 347 | 'titre' => 'Module103111Name', 348 | 'leftmenu' => 'Module103111Name', 349 | 'url' => '/lead/lead/list.php', 350 | 'langs' => 'lead@lead', 351 | 'position' => 100+$r, 352 | 'enabled' => '$user->hasRight("lead", "read")', 353 | 'perms' => '$user->hasRight("lead", "read")', 354 | 'target' => '', 355 | 'user' => 0 356 | ); 357 | $r ++; 358 | 359 | $this->menu[$r] = array( 360 | 'fk_menu' => 'fk_mainmenu=lead,fk_leftmenu=Module103111Name', 361 | 'type' => 'left', 362 | 'titre' => 'LeadCreate', 363 | 'url' => '/lead/lead/card.php?action=create', 364 | 'langs' => 'lead@lead', 365 | 'position' => 100+$r, 366 | 'enabled' => '$user->hasRight("lead", "write")', 367 | 'perms' => '$user->hasRight("lead", "write")', 368 | 'target' => '', 369 | 'user' => 0 370 | ); 371 | $r ++; 372 | 373 | $this->menu[$r] = array( 374 | 'fk_menu' => 'fk_mainmenu=lead,fk_leftmenu=Module103111Name', 375 | 'type' => 'left', 376 | 'titre' => 'LeadList', 377 | 'url' => '/lead/lead/list.php', 378 | 'langs' => 'lead@lead', 379 | 'position' => 100+$r, 380 | 'enabled' => '$user->hasRight("lead", "read")', 381 | 'perms' => '$user->hasRight("lead", "read")', 382 | 'target' => '', 383 | 'user' => 0 384 | ); 385 | $r ++; 386 | 387 | $this->menu[$r] = array( 388 | 'fk_menu' => 'fk_mainmenu=lead,fk_leftmenu=Module103111Name', 389 | 'type' => 'left', 390 | 'titre' => 'LeadListCurrent', 391 | 'url' => '/lead/lead/list.php?viewtype=current', 392 | 'langs' => 'lead@lead', 393 | 'position' => 100+$r, 394 | 'enabled' => '$user->hasRight("lead", "read")', 395 | 'perms' => '$user->hasRight("lead", "read")', 396 | 'target' => '', 397 | 'user' => 0 398 | ); 399 | $r ++; 400 | 401 | $this->menu[$r] = array( 402 | 'fk_menu' => 'fk_mainmenu=lead,fk_leftmenu=Module103111Name', 403 | 'type' => 'left', 404 | 'titre' => 'LeadListMyLead', 405 | 'url' => '/lead/lead/list.php?viewtype=my', 406 | 'langs' => 'lead@lead', 407 | 'position' => 100+$r, 408 | 'enabled' => '$user->hasRight("lead", "read")', 409 | 'perms' => '$user->hasRight("lead", "read")', 410 | 'target' => '', 411 | 'user' => 0 412 | ); 413 | $r ++; 414 | 415 | $this->menu[$r] = array( 416 | 'fk_menu' => 'fk_mainmenu=lead,fk_leftmenu=Module103111Name', 417 | 'type' => 'left', 418 | 'titre' => 'LeadListLate', 419 | 'url' => '/lead/lead/list.php?viewtype=late', 420 | 'langs' => 'lead@lead', 421 | 'position' => 100+$r, 422 | 'enabled' => '$user->hasRight("lead", "read")', 423 | 'perms' => '$user->hasRight("lead", "read")', 424 | 'target' => '', 425 | 'user' => 0 426 | ); 427 | $r ++; 428 | 429 | // Exports 430 | $r = 0; 431 | $r ++; 432 | $this->export_code [$r] = $this->rights_class . '_' . $r; 433 | $this->export_label [$r] = 'ExportDataset_lead'; 434 | $this->export_icon [$r] = 'lead@lead'; 435 | $this->export_permission [$r] = array ( 436 | array ( 437 | "lead", 438 | "export" 439 | ) 440 | ); 441 | $this->export_fields_array [$r] = array ( 442 | 'l.rowid' => 'Id', 443 | 'l.ref' => 'Ref', 444 | 'l.ref_ext' => 'LeadRefExt', 445 | 'l.ref_int' => 'LeadRefInt', 446 | 'so.nom' => 'Company', 447 | 'dictstep.code' => 'LeadStepCode', 448 | 'dictstep.label' => 'LeadStepLabel', 449 | 'dicttype.code' => 'LeadTypeCode', 450 | 'dicttype.label' => 'LeadTypeLabel', 451 | 'l.date_closure' => 'LeadDeadLine', 452 | 'l.amount_prosp' => 'LeadAmountGuess', 453 | 'l.description' => 'LeadDescription', 454 | ); 455 | $this->export_TypeFields_array [$r] = array ( 456 | 'l.rowid' => 'Text', 457 | 'l.ref' => 'Text', 458 | 'l.ref_ext' => 'Text', 459 | 'l.ref_int' => 'Text', 460 | 'so.nom' => 'Text', 461 | 'dictstep.code' => 'Text', 462 | 'dictstep.label' => 'Text', 463 | 'dicttype.code' => 'Text', 464 | 'dicttype.label' => 'Text', 465 | 'l.date_closure' => 'Date', 466 | 'l.amount_prosp' => 'Numeric', 467 | 'l.description' => 'Text', 468 | ); 469 | $this->export_entities_array [$r] = array ( 470 | 'l.rowid' => 'lead@lead', 471 | 'l.ref' => 'lead@lead', 472 | 'l.ref_ext' => 'lead@lead', 473 | 'l.ref_int' => 'lead@lead', 474 | 'so.nom' => 'company', 475 | 'dictstep.code' => 'lead@lead', 476 | 'dictstep.label' => 'lead@lead', 477 | 'dicttype.code' => 'lead@lead', 478 | 'dicttype.label' => 'lead@lead', 479 | 'l.date_closure' => 'lead@lead', 480 | 'l.amount_prosp' => 'lead@lead', 481 | 'l.description' => 'lead@lead', 482 | ); 483 | 484 | $this->export_sql_start [$r] = 'SELECT DISTINCT '; 485 | $this->export_sql_end [$r] = ' FROM ' . MAIN_DB_PREFIX . 'lead as l'; 486 | $this->export_sql_end [$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as so ON so.rowid=l.fk_soc"; 487 | $this->export_sql_end [$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as usr ON usr.rowid=l.fk_user_resp"; 488 | $this->export_sql_end [$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_lead_status as dictstep ON dictstep.rowid=l.fk_c_status"; 489 | $this->export_sql_end [$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_lead_type as dicttype ON dicttype.rowid=l.fk_c_type"; 490 | $this->export_sql_end [$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "lead_extrafields as extra ON extra.fk_object=l.rowid"; 491 | $this->export_sql_end [$r] .= ' WHERE l.entity IN (' . getEntity("lead", 1) . ')'; 492 | 493 | $keyforselect='lead'; $keyforelement='lead@lead'; $keyforaliasextra='extra'; 494 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; 495 | 496 | //Export propal not linked with lead 497 | $r ++; 498 | $propalTotalSqlCol = 'p.total_ttc'; 499 | $this->export_code [$r] = $this->rights_class . '_' . $r; 500 | $this->export_label [$r] = 'ExportDataset_leadPropal'; 501 | $this->export_icon [$r] = 'lead@lead'; 502 | $this->export_permission [$r] = array ( 503 | array ( 504 | "lead", 505 | "export" 506 | ) 507 | ); 508 | $this->export_fields_array [$r] = array ( 509 | 'p.rowid' => 'Id', 510 | 'p.ref' => 'Ref', 511 | 'so.nom' => 'Company', 512 | $propalTotalSqlCol => 'TotalTTC', 513 | 'p.fk_statut' => 'Status', 514 | ); 515 | $this->export_TypeFields_array [$r] = array ( 516 | 'p.rowid' => 'Text', 517 | 'p.ref' => 'Text', 518 | 'so.nom' => 'Text', 519 | $propalTotalSqlCol => 'Numeric', 520 | 'p.fk_statut' => 'Status', 521 | ); 522 | $this->export_entities_array [$r] = array ( 523 | 'p.rowid' => 'propal', 524 | 'p.ref' => 'propal', 525 | 'so.nom' => 'company', 526 | $propalTotalSqlCol => 'propal', 527 | 'p.fk_statut' => 'propal', 528 | ); 529 | 530 | $this->export_sql_start [$r] = 'SELECT DISTINCT '; 531 | $this->export_sql_end [$r] = ' FROM ' . MAIN_DB_PREFIX . 'propal as p'; 532 | $this->export_sql_end [$r] .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as so ON so.rowid=p.fk_soc"; 533 | $this->export_sql_end [$r] .= ' WHERE so.entity IN (' . getEntity("societe", 1) . ')'; 534 | $this->export_sql_end [$r] .= ' AND p.rowid NOT IN (SELECT t.fk_source FROM ' . MAIN_DB_PREFIX . 'element_element as t WHERE t.sourcetype=\'propal\' AND t.targettype=\'lead\')'; 535 | 536 | 537 | // Example: 538 | // $this->export_code[$r]=$this->rights_class.'_'.$r; 539 | // // Translation key (used only if key ExportDataset_xxx_z not found) 540 | // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; 541 | // // Condition to show export in list (ie: '$user->id==3'). 542 | // // Set to 1 to always show when module is enabled. 543 | // $this->export_enabled[$r]='1'; 544 | // $this->export_permission[$r]=array(array("facture","facture","export")); 545 | // $this->export_fields_array[$r]=array( 546 | // 's.rowid'=>"IdCompany", 547 | // 's.nom'=>'CompanyName', 548 | // 's.address'=>'Address', 549 | // 's.cp'=>'Zip', 550 | // 's.ville'=>'Town', 551 | // 's.fk_pays'=>'Country', 552 | // 's.tel'=>'Phone', 553 | // 's.siren'=>'ProfId1', 554 | // 's.siret'=>'ProfId2', 555 | // 's.ape'=>'ProfId3', 556 | // 's.idprof4'=>'ProfId4', 557 | // 's.code_compta'=>'CustomerAccountancyCode', 558 | // 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 559 | // 'f.rowid'=>"InvoiceId", 560 | // 'f.facnumber'=>"InvoiceRef", 561 | // 'f.datec'=>"InvoiceDateCreation", 562 | // 'f.datef'=>"DateInvoice", 563 | // 'f.total'=>"TotalHT", 564 | // 'f.total_ttc'=>"TotalTTC", 565 | // 'f.tva'=>"TotalVAT", 566 | // 'f.paye'=>"InvoicePaid", 567 | // 'f.fk_statut'=>'InvoiceStatus', 568 | // 'f.note'=>"InvoiceNote", 569 | // 'fd.rowid'=>'LineId', 570 | // 'fd.description'=>"LineDescription", 571 | // 'fd.price'=>"LineUnitPrice", 572 | // 'fd.tva_tx'=>"LineVATRate", 573 | // 'fd.qty'=>"LineQty", 574 | // 'fd.total_ht'=>"LineTotalHT", 575 | // 'fd.total_tva'=>"LineTotalTVA", 576 | // 'fd.total_ttc'=>"LineTotalTTC", 577 | // 'fd.date_start'=>"DateStart", 578 | // 'fd.date_end'=>"DateEnd", 579 | // 'fd.fk_product'=>'ProductId', 580 | // 'p.ref'=>'ProductRef' 581 | // ); 582 | // $this->export_entities_array[$r]=array('s.rowid'=>"company", 583 | // 's.nom'=>'company', 584 | // 's.address'=>'company', 585 | // 's.cp'=>'company', 586 | // 's.ville'=>'company', 587 | // 's.fk_pays'=>'company', 588 | // 's.tel'=>'company', 589 | // 's.siren'=>'company', 590 | // 's.siret'=>'company', 591 | // 's.ape'=>'company', 592 | // 's.idprof4'=>'company', 593 | // 's.code_compta'=>'company', 594 | // 's.code_compta_fournisseur'=>'company', 595 | // 'f.rowid'=>"invoice", 596 | // 'f.facnumber'=>"invoice", 597 | // 'f.datec'=>"invoice", 598 | // 'f.datef'=>"invoice", 599 | // 'f.total'=>"invoice", 600 | // 'f.total_ttc'=>"invoice", 601 | // 'f.tva'=>"invoice", 602 | // 'f.paye'=>"invoice", 603 | // 'f.fk_statut'=>'invoice', 604 | // 'f.note'=>"invoice", 605 | // 'fd.rowid'=>'invoice_line', 606 | // 'fd.description'=>"invoice_line", 607 | // 'fd.price'=>"invoice_line", 608 | // 'fd.total_ht'=>"invoice_line", 609 | // 'fd.total_tva'=>"invoice_line", 610 | // 'fd.total_ttc'=>"invoice_line", 611 | // 'fd.tva_tx'=>"invoice_line", 612 | // 'fd.qty'=>"invoice_line", 613 | // 'fd.date_start'=>"invoice_line", 614 | // 'fd.date_end'=>"invoice_line", 615 | // 'fd.fk_product'=>'product', 616 | // 'p.ref'=>'product' 617 | // ); 618 | // $this->export_sql_start[$r] = 'SELECT DISTINCT '; 619 | // $this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, ' 620 | // . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)'; 621 | // $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX 622 | // . 'product as p on (fd.fk_product = p.rowid)'; 623 | // $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid ' 624 | // . 'AND f.rowid = fd.fk_facture'; 625 | // $r++; 626 | } 627 | 628 | /** 629 | * Function called when module is enabled. 630 | * The init function add constants, boxes, permissions and menus 631 | * (defined in constructor) into Dolibarr database. 632 | * It also creates data directories 633 | * 634 | * @param string $options Enabling module ('', 'noboxes') 635 | * @return int if OK, 0 if KO 636 | */ 637 | public function init($options = '') 638 | { 639 | $sql = array(); 640 | 641 | $result = $this->loadTables(); 642 | 643 | return $this->_init($sql, $options); 644 | } 645 | 646 | /** 647 | * Function called when module is disabled. 648 | * Remove from database constants, boxes and permissions from Dolibarr database. 649 | * Data directories are not deleted 650 | * 651 | * @param string $options Enabling module ('', 'noboxes') 652 | * @return int if OK, 0 if KO 653 | */ 654 | public function remove($options = '') 655 | { 656 | $sql = array(); 657 | 658 | return $this->_remove($sql, $options); 659 | } 660 | 661 | /** 662 | * Create tables, keys and data required by module 663 | * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys 664 | * and create data commands must be stored in directory /lead/sql/ 665 | * This function is called by this->init 666 | * 667 | * @return int if KO, >0 if OK 668 | */ 669 | private function loadTables() 670 | { 671 | return $this->_load_tables('/lead/sql/'); 672 | } 673 | } 674 | --------------------------------------------------------------------------------