diff --git a/.gitignore b/.gitignore index 7125b52..2836ad2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .buildpath .project .settings/ -/nbproject \ No newline at end of file +/nbproject diff --git a/ChangeLog.md b/ChangeLog.md index 185e23d..8e1fbac 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,28 +2,55 @@ ## Unreleased +## release 1.9 +- FIX : Compatibility Dolibarr 23 - *02/12/2025* - 1.9.6 +- FIX : COMPAT 22 - *02/10/2025* - 1.9.5 +- FIX : Warning Constant INC_FROM_DOLIBARR already defined - *18/08/2025* - 1.9.4 +- FIX : définition d'une valeur par défaut si aucun titre trouvé pour éviter une erreur sur la fonction trim - *14/03/2025* - 1.9.3 +- FIX : Add compatibility with conf MAIN_CHECKBOX_LEFT_COLUMN - *20/01/2024* - 1.9.2 +- FIX : COMPAT 21 - *10/12/2024* - 1.9.1 +- FIX : Nettoyage et compatibilité Dolibarr 20 - *02/08/2024* - 1.9.1 +- NEW : DA025083 - Création d'un hook listInCSVFooterContext permettant à des modules externes d'utiliser ListInCSV. - *11/06/2024* - 1.9.0 -## 1.5 +## release 1.8 +- FIX : DA024994 - Problème de sélection sur la liste des demandes de congés (car elle contient des valeurs dans des inputs) - *21/05/2024* - 1.8.4 +- FIX : object test - *25/03/2024* - 1.8.3 +- FIX : Compat agefodd session onglet participant sur tableau stagiaire *20/03/2024* - 1.8.2 +- FIX : Module logo Image *18/12/2023* - 1.8.1 +- FIX : Compat v19 et php8.2 *07/10/2023* - 1.8.0 + +## release 1.7 + +- NEW : Ajout de la possibilité d'exporter la liste des prix clients *07/10/2023* - 1.7.0 + +## release 1.6 + +- NEW : Ajout icône listincsv sur objets référents produit et tiers *07/02/2023* - 1.6.0 + +## release 1.5 - NEW : Ajout de la class TechATM pour l'affichage de la page "A propos" *10/05/2022* 1.15.0 -## 1.4 +## release 1.4 - FIX: Family name - *02/06/2022* - 1.4.3 - FIX: Delete Trigger - *02/06/2022* - 1.4.2 - FIX: context detection - *15/03/2022* - 1.4.1 - NEW: Include Dolibarr V13 stock to date - *28/02/2022* - 1.4.0 -## 1.3 +## release 1.3 + - FIX: Appel de `call_trigger()` sur un non-objet - *08/10/2021* - 1.3.1 - NEW: Déclenchement d'un trigger sur export d'un fichier avec listincsv - *19/05/2021* - 1.3.0 -## 1.2 +## release 1.2 + - FIX: La liste ne s'exporte plus - *20/05/2021* - 1.2.4 - FIX: Les champs de type "case à cocher" ne sont pas exportés - *17/05/2021* - 1.2.3 - FIX: Suppression du dossier Box ainsi que tu fichier box *11/05/2021* - 1.2.2 - FIX: $_SESSION devient newToken() *11/05/2021* - 1.2.1 - NEW: Déplacement du code qui crée le boutton vert "CSV" pour utilisation dans des modules externes avec un contexte ajax *06/05/2021* - 1.2.0 -## 1.1 +## release 1.1 + - NEW: Ajout d'une gestion de récupération des informations via un autre paramètre que l'action du formulaire le plus proche *06/05/2021* - 1.1.0 diff --git a/README b/README index 1e68a53..ec06e65 100644 --- a/README +++ b/README @@ -1,8 +1,8 @@ -/* +/* * Copyright (C) 2015 ATM Consulting * - * This program and files/directory inner it is free software: you can - * redistribute it and/or modify it under the terms of the + * This program and files/directory inner it is free software: you can + * redistribute it and/or modify it under the terms of the * GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -15,5 +15,3 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - - diff --git a/admin/listincsv_about.php b/admin/listincsv_about.php index ac56edb..77ea66b 100644 --- a/admin/listincsv_about.php +++ b/admin/listincsv_about.php @@ -23,9 +23,9 @@ * Put some comments here */ // Dolibarr environment -$res = @include("../../main.inc.php"); // From htdocs directory +$res = @include "../../main.inc.php"; // From htdocs directory if (! $res) { - $res = @include("../../../main.inc.php"); // From "custom" directory + $res = @include "../../../main.inc.php"; // From "custom" directory } // Libraries @@ -37,7 +37,7 @@ // Access control if (! $user->admin) { - accessforbidden(); + accessforbidden(); } /* @@ -48,17 +48,17 @@ // Subheader $linkback = '' - . $langs->trans("BackToModuleList") . ''; + . $langs->trans("BackToModuleList") . ''; print_fiche_titre($langs->trans($page_name), $linkback); // Configuration header $head = listincsvAdminPrepareHead(); dol_fiche_head( - $head, - 'about', - $langs->trans("Module104856Name"), - 0, - 'listincsv@listincsv' + $head, + 'about', + $langs->trans("Module104856Name"), + 0, + 'listincsv@listincsv' ); // About page goes here diff --git a/admin/listincsv_setup.php b/admin/listincsv_setup.php index 0f9995d..f9e9688 100644 --- a/admin/listincsv_setup.php +++ b/admin/listincsv_setup.php @@ -23,9 +23,9 @@ * Put some comments here */ // Dolibarr environment -$res = @include("../../main.inc.php"); // From htdocs directory +$res = @include "../../main.inc.php"; // From htdocs directory if (! $res) { - $res = @include("../../../main.inc.php"); // From "custom" directory + $res = @include "../../../main.inc.php"; // From "custom" directory } // Libraries @@ -37,7 +37,7 @@ // Access control if (! $user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -46,30 +46,22 @@ /* * Actions */ -if (preg_match('/set_(.*)/',$action,$reg)) -{ +if (preg_match('/set_(.*)/', $action, $reg)) { $code=$reg[1]; - if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else - { + } else { dol_print_error($db); } } -if (preg_match('/del_(.*)/',$action,$reg)) -{ +if (preg_match('/del_(.*)/', $action, $reg)) { $code=$reg[1]; - if (dolibarr_del_const($db, $code, 0) > 0) - { + if (dolibarr_del_const($db, $code, 0) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else - { + } else { dol_print_error($db); } } @@ -82,17 +74,17 @@ // Subheader $linkback = '' - . $langs->trans("BackToModuleList") . ''; + . $langs->trans("BackToModuleList") . ''; print_fiche_titre($langs->trans($page_name), $linkback); // Configuration header $head = listincsvAdminPrepareHead(); dol_fiche_head( - $head, - 'settings', - $langs->trans("Module104856Name"), - 0, - "listincsv@listincsv" + $head, + 'settings', + $langs->trans("Module104856Name"), + 0, + "listincsv@listincsv" ); //echo $langs->trans('NoSetupAvailable'); @@ -116,7 +108,7 @@ print '
'; print ''; print ''; -print $form->selectyesno("LISTINCSV_DELETESPACEFROMNUMBER",$conf->global->LISTINCSV_DELETESPACEFROMNUMBER,1); +print $form->selectyesno("LISTINCSV_DELETESPACEFROMNUMBER", getDolGlobalInt('LISTINCSV_DELETESPACEFROMNUMBER'), 1); print ''; print '
'; print ''; diff --git a/backport/v19/core/class/commonhookactions.class.php b/backport/v19/core/class/commonhookactions.class.php new file mode 100644 index 0000000..202e9e4 --- /dev/null +++ b/backport/v19/core/class/commonhookactions.class.php @@ -0,0 +1,54 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/commonhookactions.class.php + * \ingroup core + * \brief File of parent class of all other hook actions classes + */ + + +if (file_exists(DOL_DOCUMENT_ROOT . '/core/class/commonhookactions.class.php')) { + require_once DOL_DOCUMENT_ROOT . '/core/class/commonhookactions.class.php'; + /** + * Parent class of all other hook actions classes + */ + abstract class RetroCompatCommonHookActions extends \CommonHookActions + { + + } +} else { + /** + * Parent class of all other hook actions classes + */ + abstract class RetroCompatCommonHookActions + { + /** + * @var string String of results. + */ + public $resprints; + + /** + * @var array Array of results. + */ + public $results = array(); + } + +} diff --git a/class/actions_listincsv.class.php b/class/actions_listincsv.class.php index 6d0d113..edebc6a 100644 --- a/class/actions_listincsv.class.php +++ b/class/actions_listincsv.class.php @@ -17,184 +17,259 @@ */ /** - * \file class/actions_listincsv.class.php + * \file class/actions_listincsv.class.php * \ingroup listincsv * \brief This file is an example hook overload class file - * Put some comments here + * Put some comments here */ +require_once __DIR__ . '/../backport/v19/core/class/commonhookactions.class.php'; /** * Class ActionsListInCSV */ -class ActionsListInCSV +class ActionsListInCSV extends \listincsv\RetroCompatCommonHookActions { - /** - * @var array Hook results. Propagated to $hookmanager->resArray for later reuse - */ - public $results = array(); - - /** - * @var string String displayed by executeHook() immediately after return - */ - public $resprints; - - /** - * @var array Errors - */ - public $errors = array(); - - /** - * Constructor - */ - public function __construct() - { - } - - /** - * doActions - * - * @param array() $parameters Hook metadatas (context, etc...) - * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string &$action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - function doActions($parameters, &$object, &$action, $hookmanager) { - - global $db, $user; - - if(GETPOSTISSET('exportlistincsv', 'bool') && method_exists($object, 'call_trigger')) { - $object->call_trigger('LISTINCSV_EXPORT_FILE_'.strtoupper($object->element), $user); - } - - } - - /** - * printCommonFooter - * - * @param array() $parameters Hook metadatas (context, etc...) - * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string &$action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - function printCommonFooter($parameters, &$object, &$action, $hookmanager) - { - $TContext = explode(':', $parameters['context']); - $context_list = preg_grep('/(.*list$)/i', $TContext); - if (!empty($context_list) || in_array('stockatdate', $TContext)) - { - global $langs, $user, $conf; - $langs->load('listincsv@listincsv'); - - if(!empty($user->rights->listincsv->export)) { - - require_once __DIR__ . './../lib/listincsv.lib.php'; - - $pathtojs = dol_buildpath('/listincsv/js/listincsv.js.php',1); - - $download = getListInCSVDownloadLink(); - - $socid = GETPOST('socid'); - if(empty($socid)) $socid = 0; - - // Inclusion d'un JS qui va permettre de télécharger la liste - ?> - - - resArray for later reuse + */ + public $results = array(); + + /** + * @var string String displayed by executeHook() immediately after return + */ + public $resprints; + + /** + * @var array Errors + */ + public $errors = array(); + + /** + * Constructor + * + * @return void + */ + public function __construct() + { + } + + /** + * doActions + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doActions($parameters, &$object, &$action, $hookmanager) + { + + global $db, $user; + + if (GETPOSTISSET('exportlistincsv', 'bool') && is_object($object) && method_exists($object, 'call_trigger')) { + $object->call_trigger('LISTINCSV_EXPORT_FILE_' . strtoupper($object->element), $user); + } + } + + /** + * printCommonFooter + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function printCommonFooter($parameters, &$object, &$action, $hookmanager) + { + $TContext = explode(':', $parameters['context']); + $context_list = preg_grep('/(.*list$)/i', $TContext); + + // Gestion des objets référents produits + if (empty($context_list)) { + $context_list = preg_grep('/(productstats.*)/i', $TContext); + } + + // Gestion des écrans objets référents tiers + if (empty($context_list)) { + $context_list = preg_grep('/(consumptionthirdparty)/i', $TContext); + } + + // Gestion des écrans objets référents tiers + if (empty($context_list)) { + $context_list = preg_grep('/(stockatdate)/i', $TContext); + } + + // Gestion des écrans objets référents tiers + if (empty($context_list)) { + $context_list = preg_grep('/(thirdpartycustomerprice)/i', $TContext); + } + if (empty($context_list)) { + $context_list = preg_grep('/(agefoddsessionsubscribers)/i', $TContext); + } + + // Permettre à d'autres modules externes d'utiliser listInCSV + $parameters['context_list'] = &$context_list; + $reshook = $hookmanager->executeHooks('listInCSVFooterContext', $parameters); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (!empty($context_list)) { + global $langs, $user, $conf; + $langs->load('listincsv@listincsv'); + + if (!empty($user->hasRight('listincsv', 'export'))) { + require_once __DIR__ . './../lib/listincsv.lib.php'; + + $pathtojs = dol_buildpath('/listincsv/js/listincsv.js.php', 1); + + $download = getListInCSVDownloadLink(); + + $socid = GETPOST('socid'); + if (empty($socid)) + $socid = 0; + + $varsForJs = array( + 'downloadButton' => $download, + 'TContexts' => explode(':', $parameters['context']), + 'socid' => $socid, + 'langs' => array( + 'FileGenerationInProgress' => $langs->trans('FileGenerationInProgress') + ), + 'conf' => array( + 'LISTINCSV_DONT_REMOVE_TOTAL' => !empty(getDolGlobalInt('LISTINCSV_DONT_REMOVE_TOTAL')), + 'LISTINCSV_DELETESPACEFROMNUMBER' => !empty(getDolGlobalInt('LISTINCSV_DELETESPACEFROMNUMBER')) + ), + ); + // Inclusion d'un JS qui va permettre de télécharger la liste + ?> + + + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + /** * Class TechATM - * Class utilisée pour des mises à jours technique du module + * + * Technical class used for module technical updates + * Handles communication with ATM tech server for module information and updates */ namespace listincsv; +/** + * Class TechATM + * Class utilisée pour des mises à jours technique du module + */ class TechATM { @@ -58,35 +80,40 @@ class TechATM /** * Constructor * - * @param DoliDB $db + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } /** - * @param DolibarrModules $moduleDescriptor + * Get about page content for a module + * + * @param DolibarrModules $moduleDescriptor Module descriptor + * @param bool $useCache Whether to use cached version + * @return string HTML content of the about page */ - function getAboutPage($moduleDescriptor, $useCache = true){ + public function getAboutPage($moduleDescriptor, $useCache = true) + { global $langs; - $url = self::ATM_TECH_URL.'/modules/modules-page-about.php'; - $url.= '?module='.$moduleDescriptor->name; - $url.= '&id='.$moduleDescriptor->numero; - $url.= '&version='.$moduleDescriptor->version; - $url.= '&langs='.$langs->defaultlang; - $url.= '&callv='.self::CALL_VERSION; + $url = self::ATM_TECH_URL . '/modules/modules-page-about.php'; + $url .= '?module=' . $moduleDescriptor->name; + $url .= '&id=' . $moduleDescriptor->numero; + $url .= '&version=' . $moduleDescriptor->version; + $url .= '&langs=' . $langs->defaultlang; + $url .= '&callv=' . self::CALL_VERSION; $cachePath = DOL_DATA_ROOT . "/modules-atm/temp/about_page"; - $cacheFileName = dol_sanitizeFileName($moduleDescriptor->name.'_'.$langs->defaultlang).'.html'; - $cacheFilePath = $cachePath.'/'.$cacheFileName; + $cacheFileName = dol_sanitizeFileName($moduleDescriptor->name . '_' . $langs->defaultlang) . '.html'; + $cacheFilePath = $cachePath . '/' . $cacheFileName; - if($useCache && is_readable($cacheFilePath)){ + if ($useCache && is_readable($cacheFilePath)) { $lastChange = filemtime($cacheFilePath); - if($lastChange > time() - 86400){ + if ($lastChange > time() - 86400) { $content = @file_get_contents($cacheFilePath); - if($content !== false){ + if ($content !== false) { return $content; } } @@ -94,29 +121,29 @@ function getAboutPage($moduleDescriptor, $useCache = true){ $content = $this->getContents($url); - if(!$content){ + if (!$content) { $content = ''; // About page goes here - $content.= '
'; - $content.= '
'.$langs->trans('ATMAbout').'
'; - $content.= '
'; - $content.= ''; - $content.= '
'; + $content .= '
'; + $content .= '
' . $langs->trans('ATMAbout') . '
'; + $content .= '
'; + $content .= ''; + $content .= '
'; } - if($useCache){ - if(!is_dir($cachePath)){ + if ($useCache) { + if (!is_dir($cachePath)) { $res = dol_mkdir($cachePath, DOL_DATA_ROOT); - }else{ + } else { $res = true; } - if($res){ - $comment = ''."\r\n"; + if ($res) { + $comment = '' . "\r\n"; file_put_contents( $cacheFilePath, - $comment.$content + $comment . $content ); } } @@ -125,40 +152,51 @@ function getAboutPage($moduleDescriptor, $useCache = true){ } /** - * @param string $moduleTechMane + * Get module documentation URL + * + * @param string $moduleTechMane Module technical name + * @return string URL to module documentation */ - public static function getModuleDocUrl($moduleTechMane){ - $url = self::ATM_TECH_URL.'/modules/doc-redirect.php'; - $url.= '?module='.$moduleTechMane; + public static function getModuleDocUrl($moduleTechMane) + { + $url = self::ATM_TECH_URL . '/modules/doc-redirect.php'; + $url .= '?module=' . $moduleTechMane; return $url; } /** - * @param DolibarrModules $moduleDescriptor + * Get URL to check for last module version + * + * @param DolibarrModules $moduleDescriptor Module descriptor + * @return string URL to check module version */ - public static function getLastModuleVersionUrl($moduleDescriptor){ - $url = self::ATM_TECH_URL.'/modules/modules-last-version.php'; - $url.= '?module='.$moduleDescriptor->name; - $url.= '&number='.$moduleDescriptor->numero; - $url.= '&version='.$moduleDescriptor->version; - $url.= '&dolversion='.DOL_VERSION; - $url.= '&callv='.self::CALL_VERSION; + public static function getLastModuleVersionUrl($moduleDescriptor) + { + $url = self::ATM_TECH_URL . '/modules/modules-last-version.php'; + $url .= '?module=' . $moduleDescriptor->name; + $url .= '&number=' . $moduleDescriptor->numero; + $url .= '&version=' . $moduleDescriptor->version; + $url .= '&dolversion=' . DOL_VERSION; + $url .= '&callv=' . self::CALL_VERSION; return $url; } /** - * @param $url - * @return false|object + * Get JSON data from a URL + * + * @param string $url URL to fetch JSON data from + * @return false|object JSON decoded object or false on failure */ - public function getJsonData($url){ + public function getJsonData($url) + { $this->data = false; $res = @file_get_contents($url); $this->http_response_header = $http_response_header; $this->TResponseHeader = self::parseHeaders($http_response_header); - if($res !== false){ + if ($res !== false) { $pos = strpos($res, '{'); - if($pos > 0){ + if ($pos > 0) { // cela signifie qu'il y a une erreur ou que la sortie n'est pas propre $res = substr($res, $pos); } @@ -170,24 +208,32 @@ public function getJsonData($url){ } /** - * @param $url - * @return false|string + * Get contents from a URL + * + * @param string $url URL to fetch contents from + * @return false|string Contents or false on failure */ - public function getContents($url){ + public function getContents($url) + { $this->data = false; $res = @file_get_contents($url); $this->http_response_header = $http_response_header; $this->TResponseHeader = self::parseHeaders($http_response_header); - if($res !== false){ + if ($res !== false) { $this->data = $res; } return $this->data; } - public static function http_response_code_msg($code = NULL) + /** + * Get HTTP response code message + * + * @param int|null $code HTTP response code + * @return string HTTP response message + */ + public static function httpResponseCodeMsg($code = null) { - if ($code !== NULL) { - + if ($code !== null) { switch ($code) { case 100: $text = 'Continue'; @@ -306,32 +352,34 @@ public static function http_response_code_msg($code = NULL) } return $text; - } else { return $text = 'Unknown http status code NULL'; } } - public static function parseHeaders( $headers ) + /** + * Parse HTTP response headers + * + * @param array $headers Array of HTTP headers + * @return array Parsed headers as associative array + */ + public static function parseHeaders($headers) { $head = array(); - if(!is_array($headers)){ + if (!is_array($headers)) { return $head; } - foreach( $headers as $k=>$v ) - { - $t = explode( ':', $v, 2 ); - if( isset( $t[1] ) ) - $head[ trim($t[0]) ] = trim( $t[1] ); - else - { + foreach ($headers as $k => $v) { + $t = explode(':', $v, 2); + if (isset($t[1])) + $head[trim($t[0])] = trim($t[1]); + else { $head[] = $v; - if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) ) + if (preg_match("#HTTP/[0-9\.]+\s+([0-9]+)#", $v, $out)) $head['reponse_code'] = intval($out[1]); } } return $head; } - } diff --git a/config.default.php b/config.default.php index 4be23d6..50ce938 100644 --- a/config.default.php +++ b/config.default.php @@ -1,31 +1,37 @@ . + */ + if (is_file('../main.inc.php'))$dir = '../'; +elseif (is_file('../../../main.inc.php'))$dir = '../../../'; +else $dir = '../../'; - if(!defined('INC_FROM_DOLIBARR') && defined('INC_FROM_CRON_SCRIPT')) { - include($dir."master.inc.php"); - } - elseif(!defined('INC_FROM_DOLIBARR')) { - include($dir."main.inc.php"); - } else { - global $dolibarr_main_db_host, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass; - } - if(!defined('DB_HOST')) { - define('DB_HOST',$dolibarr_main_db_host); - define('DB_NAME',$dolibarr_main_db_name); - define('DB_USER',$dolibarr_main_db_user); - define('DB_PASS',$dolibarr_main_db_pass); - define('DB_DRIVER',$dolibarr_main_db_type); - } - - if(!dol_include_once('/abricot/inc.core.php')) { - print $langs->trans('AbricotNotFound'). ' : Abricot'; - exit; - } - - +if (!defined('INC_FROM_DOLIBARR') && defined('INC_FROM_CRON_SCRIPT')) { + include $dir."master.inc.php"; +} elseif (!defined('INC_FROM_DOLIBARR')) { + include $dir."main.inc.php"; +} else { + global $dolibarr_main_db_host, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_type; +} +if (!defined('DB_HOST')) { + define('DB_HOST', $dolibarr_main_db_host); + define('DB_NAME', $dolibarr_main_db_name); + define('DB_USER', $dolibarr_main_db_user); + define('DB_PASS', $dolibarr_main_db_pass); + define('DB_DRIVER', $dolibarr_main_db_type); +} diff --git a/config.php b/config.php index 720094e..fe26e23 100644 --- a/config.php +++ b/config.php @@ -1,4 +1,18 @@ . + */ require __DIR__.'/config.default.php'; - diff --git a/core/modules/modListInCSV.class.php b/core/modules/modListInCSV.class.php index e445306..8174b7d 100644 --- a/core/modules/modListInCSV.class.php +++ b/core/modules/modListInCSV.class.php @@ -25,7 +25,7 @@ * \ingroup listincsv * \brief Description and activation file for module ListInCSV */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php'; /** @@ -38,11 +38,11 @@ class modListInCSV extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs,$conf; + global $langs, $conf; - $this->db = $db; + $this->db = $db; $this->editor_name = 'ATM Consulting'; $this->editor_url = 'https://www.atm-consulting.fr'; @@ -56,24 +56,24 @@ function __construct($db) // It is used to group modules in module setup page $this->family = 'ATM Consulting - CRM'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i','',get_class($this)); + $this->name = preg_replace('/^mod/i', '', get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "ListInCSV permet d'exporter en CSV une liste Dolibarr telle qu'elle apparaît à l'écran."; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = '1.5.0'; + $this->version = '1.9.6'; // Url to the file with your last numberversion of this module require_once __DIR__ . '/../../class/techatm.class.php'; $this->url_last_version = \listincsv\TechATM::getLastModuleVersionUrl($this); // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) $this->special = 0; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='listincsv@listincsv'; + $this->picto = 'modulelistincsv@listincsv'; // Defined all module parts (triggers, login, substitutions, menus, css, etc...) // for default path (eg: /listincsv/core/xxxxx) (0=disable, 1=enable) @@ -89,13 +89,13 @@ function __construct($db) // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) // 'css' => array('/listincsv/css/listincsv.css.php'), // Set this to relative path of css file if module has its own css file - // 'js' => array('/listincsv/js/listincsv.js'), // Set this to relative path of js file if module must load a js on all pages + // 'js' => array('/listincsv/js/listincsv.js'), // Set this to relative path of js file if module must load a js on all pages // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module // 'dir' => array('output' => 'othermodulename'), // To force the default directories names // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@listincsv')) // Set here all workflow context managed by module // ); $this->module_parts = array( - 'hooks'=>array( + 'hooks' => array( 'main' ) ); @@ -112,8 +112,8 @@ function __construct($db) $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->phpmin = array(5,0); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3,9); // Minimum version of Dolibarr required by module + $this->phpmin = array(7, 4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3, 9); // Minimum version of Dolibarr required by module $this->langfiles = array("listincsv@listincsv"); // Constants @@ -124,9 +124,9 @@ function __construct($db) $this->const = array(); // Array to add new pages in new tabs - // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@listincsv:$user->rights->listincsv->read:/listincsv/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:Title2:mylangfile@listincsv:$user->rights->othermodule->read:/listincsv/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 - // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@listincsv:$user->hasRight('listincsv', 'read'):/listincsv/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:Title2:mylangfile@listincsv:$user->hasRight('othermodule', 'read'):/listincsv/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 + // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // where objecttype can be // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) // 'contact' to add a tab in contact view @@ -147,59 +147,58 @@ function __construct($db) // 'stock' to add a tab in stock view // 'thirdparty' to add a tab in third party view // 'user' to add a tab in user view - $this->tabs = array(); - - // Dictionaries - if (! isset($conf->listincsv->enabled)) - { - $conf->listincsv=new stdClass(); - $conf->listincsv->enabled=0; - } - $this->dictionaries=array(); - /* Example: - if (! isset($conf->listincsv->enabled)) $conf->listincsv->enabled=0; // This is to avoid warnings - $this->dictionaries=array( - 'langs'=>'mylangfile@listincsv', - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Table1","Table2","Table3"), // Label of tables - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order - 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->listincsv->enabled,$conf->listincsv->enabled,$conf->listincsv->enabled) // Condition to show each dictionary - ); - */ + $this->tabs = array(); + + // Dictionaries + if (!isset($conf->listincsv->enabled)) { + $conf->listincsv = new stdClass(); + $conf->listincsv->enabled = 0; + } + $this->dictionaries = array(); + /* Example: + if (! isset($conf->listincsv->enabled)) $conf->listincsv->enabled=0; // This is to avoid warnings + $this->dictionaries=array( + 'langs'=>'mylangfile@listincsv', + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor + 'tablib'=>array("Table1","Table2","Table3"), // Label of tables + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order + 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) + 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') + 'tabcond'=>array($conf->listincsv->enabled,$conf->listincsv->enabled,$conf->listincsv->enabled) // Condition to show each dictionary + ); + */ - // Boxes + // Boxes // Add here list of php file(s) stored in core/boxes that contains class to show a box. - $this->boxes = array(); // List of boxes + $this->boxes = array(); // List of boxes // Example: //$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>''));); // Permissions $this->rights = array(); // Permission array used by this module - $r=0; + $r = 0; // Add here list of permission defined by an id, a label, a boolean and two constant strings. // Example: // $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) // $this->rights[$r][1] = 'Permision label'; // Permission label // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->hasRight('permkey', 'level1', 'level2')) + // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->hasRight('permkey', 'level1', 'level2')) // $r++; $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('LISTINCSVExport'); // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'export'; // In php code, permission will be checked by test if ($user->rights->permkey->level1) + $this->rights[$r][4] = 'export'; // In php code, permission will be checked by test if ($user->hasRight('permkey', 'level1')) $r++; // Main menu entries $this->menu = array(); // List of menus to add - $r=0; + $r = 0; // Add here entries to declare new menus // @@ -213,7 +212,7 @@ function __construct($db) // 'langs'=>'mylangfile@listincsv', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. // 'position'=>100, // 'enabled'=>'$conf->listincsv->enabled', // Define condition to show or hide menu entry. Use '$conf->listincsv->enabled' if entry must be visible if module is enabled. - // 'perms'=>'1', // Use 'perms'=>'$user->rights->listincsv->level1->level2' if you want your menu with a permission rules + // 'perms'=>'1', // Use 'perms'=>'$user->hasRight('listincsv', 'level1', 'level2')' if you want your menu with a permission rules // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; @@ -228,19 +227,19 @@ function __construct($db) // 'langs'=>'mylangfile@listincsv', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. // 'position'=>100, // 'enabled'=>'$conf->listincsv->enabled', // Define condition to show or hide menu entry. Use '$conf->listincsv->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - // 'perms'=>'1', // Use 'perms'=>'$user->rights->listincsv->level1->level2' if you want your menu with a permission rules + // 'perms'=>'1', // Use 'perms'=>'$user->hasRight('listincsv', 'level1', 'level2')' if you want your menu with a permission rules // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; // Exports - $r=1; + $r = 1; // Example: // $this->export_code[$r]=$this->rights_class.'_'.$r; // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. + // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. // $this->export_permission[$r]=array(array("facture","facture","export")); // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); @@ -257,19 +256,21 @@ function __construct($db) * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options='') + public function init($options = '') { $sql = array(); - define('INC_FROM_DOLIBARR',true); + if (!defined('INC_FROM_DOLIBARR')) { + define('INC_FROM_DOLIBARR', true); + } dol_include_once('/listincsv/config.php'); dol_include_once('/listincsv/script/create-maj-base.php'); - $result=$this->_load_tables('/listincsv/sql/'); + $result = $this->_load_tables('/listincsv/sql/'); return $this->_init($sql, $options); } @@ -279,14 +280,13 @@ function init($options='') * Remove from database constants, boxes and permissions from Dolibarr database. * Data directories are not deleted * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function remove($options='') + public function remove($options = '') { $sql = array(); return $this->_remove($sql, $options); } - } diff --git a/core/triggers/interface_99_modListInCSV_ListInCSVtrigger.class.php b/core/triggers/interface_99_modListInCSV_ListInCSVtrigger.class.php index 57d7081..4c33eb3 100644 --- a/core/triggers/interface_99_modListInCSV_ListInCSVtrigger.class.php +++ b/core/triggers/interface_99_modListInCSV_ListInCSVtrigger.class.php @@ -36,83 +36,83 @@ class InterfaceListInCSVtrigger { - private $db; + private $db; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = "demo"; - $this->description = "Triggers of this module are empty functions." - . "They have no effect." - . "They are provided for tutorial purpose only."; - // 'development', 'experimental', 'dolibarr' or version - $this->version = 'development'; - $this->picto = 'listincsv@listincsv'; - } + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "ATM Consulting - CRM"; + $this->description = "Triggers of this module are empty functions. They have no effect. They are provided for tutorial purpose only."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; + $this->picto = 'listincsv@listincsv'; + } - /** - * Trigger name - * - * @return string Name of trigger file - */ - public function getName() - { - return $this->name; - } + /** + * Trigger name + * + * @return string Name of trigger file + */ + public function getName() + { + return $this->name; + } - /** - * Trigger description - * - * @return string Description of trigger file - */ - public function getDesc() - { - return $this->description; - } + /** + * Trigger description + * + * @return string Description of trigger file + */ + public function getDesc() + { + return $this->description; + } - /** - * Trigger version - * - * @return string Version of trigger file - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); + /** + * Trigger version + * + * @return string Version of trigger file + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); - if ($this->version == 'development') { - return $langs->trans("Development"); - } elseif ($this->version == 'experimental') + if ($this->version == 'development') { + return $langs->trans("Development"); + } elseif ($this->version == 'experimental') - return $langs->trans("Experimental"); - elseif ($this->version == 'dolibarr') return DOL_VERSION; - elseif ($this->version) return $this->version; - else { - return $langs->trans("Unknown"); - } - } + return $langs->trans("Experimental"); + elseif ($this->version == 'dolibarr') + return DOL_VERSION; + elseif ($this->version) + return $this->version; + else { + return $langs->trans("Unknown"); + } + } - /** - * Function called when a Dolibarrr business event is done. - * All functions "run_trigger" are triggered if file - * is inside directory core/triggers - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - public function run_trigger($action, $object, $user, $langs, $conf) - { - return 0; - } -} \ No newline at end of file + /** + * Function called when a Dolibarrr business event is done. + * All functions "run_trigger" are triggered if file + * is inside directory core/triggers + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, $user, $langs, $conf) + { + return 0; + } +} diff --git a/img/logo list in csv.svg b/img/logo list in csv.svg new file mode 100644 index 0000000..5b1c0fa --- /dev/null +++ b/img/logo list in csv.svg @@ -0,0 +1,90 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/img/object_modulelistincsv.png b/img/object_modulelistincsv.png new file mode 100644 index 0000000..2cfdf03 Binary files /dev/null and b/img/object_modulelistincsv.png differ diff --git a/js/listincsv.js.php b/js/listincsv.js.php index 196a37a..9b203ef 100644 --- a/js/listincsv.js.php +++ b/js/listincsv.js.php @@ -19,23 +19,23 @@ */ /** - * \file htdocs/listincsv/js/lib_head.js.php - * \brief File that include javascript functions (included if option use_javascript activated) + * \file /listincsv/js/listincsv.js.php + * \brief Functions for Dolibarr module ListInCSV * JQuery (providing object $) and JQuery-UI (providing $datepicker) libraries must be loaded before this file. */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); -if (! defined('NOLOGIN')) define('NOLOGIN',1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (! defined('NOLOGIN')) define('NOLOGIN', 1); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -session_cache_limiter(FALSE); +session_cache_limiter(false); $res=0; if (! $res && file_exists("../../main.inc.php")) $res=@include_once '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory @@ -71,8 +71,8 @@ function exportTableToCSV($table, filename) { tmpRowDelim = String.fromCharCode(0), // null character // actual delimiter characters for CSV format - colDelim = '"global->EXPORT_CSV_SEPARATOR_TO_USE)?$conf->global->EXPORT_CSV_SEPARATOR_TO_USE:';')?>"', - rowDelim = '"\r\n"', + colDelim = '""', + rowDelim = '"\r\n"', // Grab text from table into CSV formatted string csv = '\ufeff"' + $rows.map(function(i, row) { @@ -86,11 +86,14 @@ function exportTableToCSV($table, filename) { let $colFirstChild = $col.children().first(); if ($col.find("span.linkobject:not(.hideobject)").length > 0) { // Fix sur liste produit si conf MAIN_DIRECT_STATUS_UPDATE active - text = $col.find("span.linkobject:not(.hideobject)").children().first().attr('title').trim(); + text = ($col.find("span.linkobject:not(.hideobject)").children().first().attr('title') || "").trim(); } else if ($col.find('a').length > 0 && $col.find('a')[0].href.indexOf('mailto:') == 0) { // Fix mails tronqués dans les listes par dol_trunc dans la fonction dol_print_email link=$col.find('a')[0].href; text = link.substr(7); + } else if ($col.find('input').length > 0 && $col.find('input').prop('type') === 'text') { + // Fix DA024994 liste avec des inputs + text=$col.find('input').val(); } else text = $col.text().trim(); // Spécifique pour "nettoyer" les données @@ -115,6 +118,7 @@ function exportTableToCSV($table, filename) { .split(tmpRowDelim).join(rowDelim) .split(tmpColDelim).join(colDelim) + '"'; + // Deliberate 'false', see comment below if (false && window.navigator.msSaveBlob) { diff --git a/langs/en_US/listincsv.lang b/langs/en_US/listincsv.lang index 5dc2988..259defb 100644 --- a/langs/en_US/listincsv.lang +++ b/langs/en_US/listincsv.lang @@ -9,4 +9,4 @@ ListInCSVAbout = About List in CSV NoSetupAvailable = No setup available. You can now dowload in CSV format any list from Dolibarr. An icon is available next to each list title. FileGenerationInProgress = CSV file generation in progress. -LISTINCSVExport=Allow user to export list in CSV \ No newline at end of file +LISTINCSVExport=Allow user to export list in CSV diff --git a/langs/es_MX/listincsv.lang b/langs/es_MX/listincsv.lang new file mode 100644 index 0000000..190313f --- /dev/null +++ b/langs/es_MX/listincsv.lang @@ -0,0 +1,13 @@ +Module104856Name = Lista en CSV +Module104856Desc = Agrega un ícono que le permite descargar listas en formato CSV + +ATMAbout = Este módulo fue desarrollado por ATM Consulting
Puede encontrar la documentación en nuestro wiki

Para cualquier pregunta técnica o comentario, contáctenos en support@atm-consulting.fr

Para cualquier pregunta comercial, contáctenos en contact@atm-consulting.fr o +33 9 77 19 50 70

Encuentre nuestros otros módulos en Dolistore + +ListInCSVSetup = Configuración del módulo Lista en CSV +ListInCSVAbout = Acerca del módulo Lista en CSV + +NoSetupAvailable = No es necesaria ninguna configuración. Ahora está disponible un ícono junto al título de cada lista que le permite descargarla en un archivo CSV. + +FileGenerationInProgress = Generación del archivo CSV en curso. +LISTINCSVExport=Permitir exportación de listas en CSV +LISTINCSV_DELETESPACEFROMNUMBER=Eliminar espacios contenidos en números diff --git a/langs/it_IT/listincsv.lang b/langs/it_IT/listincsv.lang index 2b95126..a9be562 100644 --- a/langs/it_IT/listincsv.lang +++ b/langs/it_IT/listincsv.lang @@ -4,9 +4,9 @@ Module104856Desc = Aggiunge un icona per l'esportazione degli elenchi in formato ATMAbout = Questo modulo è stato sviluppato da ATM Consulting
Ulteriore documentazione disponibile nel wiki

Per domande e feedback contattateci a support@atm-consulting.fr

Per questioni commerciali contattateci acontact@atm-consulting.fr or at +33 9 77 19 50 70

Scoprite altri moduli sul Dolistore -ListInCSVSetup = Impostazioni modulo +ListInCSVSetup = Impostazioni modulo ListInCSVAbout = A proposito del modulo Elenco in CSV NoSetupAvailable = Nessuna impostazione disponibile. È possibile scaricare in formato CSV ogni elenco di Dolibarr. Un'icona è disponibile al fianco di ogni titolo degli elenchi -FileGenerationInProgress = Generazione file CSV in corso. \ No newline at end of file +FileGenerationInProgress = Generazione file CSV in corso. diff --git a/lib/listincsv.lib.php b/lib/listincsv.lib.php index be5c37e..eefbf3d 100644 --- a/lib/listincsv.lib.php +++ b/lib/listincsv.lib.php @@ -23,46 +23,56 @@ * Put some comments here */ +/** + * Prepare admin pages header + * + * @return array Array of tabs to show + */ function listincsvAdminPrepareHead() { - global $langs, $conf; + global $langs, $conf; - $langs->load("listincsv@listincsv"); + $langs->load("listincsv@listincsv"); - $h = 0; - $head = array(); + $h = 0; + $head = array(); - $head[$h][0] = dol_buildpath("/listincsv/admin/listincsv_setup.php", 1); - $head[$h][1] = $langs->trans("Parameters"); - $head[$h][2] = 'settings'; - $h++; - $head[$h][0] = dol_buildpath("/listincsv/admin/listincsv_about.php", 1); - $head[$h][1] = $langs->trans("About"); - $head[$h][2] = 'about'; - $h++; + $head[$h][0] = dol_buildpath("/listincsv/admin/listincsv_setup.php", 1); + $head[$h][1] = $langs->trans("Parameters"); + $head[$h][2] = 'settings'; + $h++; + $head[$h][0] = dol_buildpath("/listincsv/admin/listincsv_about.php", 1); + $head[$h][1] = $langs->trans("About"); + $head[$h][2] = 'about'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - //$this->tabs = array( - // 'entity:+tabname:Title:@listincsv:/listincsv/mypage.php?id=__ID__' - //); // to add new tab - //$this->tabs = array( - // 'entity:-tabname:Title:@listincsv:/listincsv/mypage.php?id=__ID__' - //); // to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'listincsv'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@listincsv:/listincsv/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@listincsv:/listincsv/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'listincsv'); - return $head; + return $head; } -function getListInCSVDownloadLink() { +/** + * Get ListInCSV download link with icon + * + * @return string HTML link with icon for CSV download + */ +function getListInCSVDownloadLink() +{ - $pathtoimg = dol_buildpath('/listincsv/img/listincsv.png',1); + $pathtoimg = dol_buildpath('/listincsv/img/listincsv.png', 1); //$pathtoimg = dol_buildpath('/theme/eldy/img/upload.png',1); $link = ''; $endlink = ''; - $img = ' '; + $img = ' '; return $link . $img . $endlink; - } diff --git a/script/create-maj-base.php b/script/create-maj-base.php index 7f9e890..b88beb6 100644 --- a/script/create-maj-base.php +++ b/script/create-maj-base.php @@ -1,13 +1,28 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + /* * Script créant et vérifiant que les champs requis s'ajoutent bien */ -if(!defined('INC_FROM_DOLIBARR')) { +if (!defined('INC_FROM_DOLIBARR')) { define('INC_FROM_CRON_SCRIPT', true); - require('../config.php'); - + require '../config.php'; }