diff --git a/ChangeLog.md b/ChangeLog.md index 37347d0..a0eba6f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## Unreleased ## Release 1.4 +- FIX : Compat v23 - *12/12/2025* - 1.4.3 - FIX : Ne pas afficher le bouton actions disponibles si ils sont de type input et donc envoi des données via formulaire - *06/02/2024* - 1.4.2 - FIX : Compat 21 - *10/12/2024* - 1.4.1 - NEW : Dolibarr compatibility V20 - *02/07/2024* - 1.4.0 diff --git a/admin/upbuttons_setup.php b/admin/upbuttons_setup.php index 20effe1..806c1b6 100644 --- a/admin/upbuttons_setup.php +++ b/admin/upbuttons_setup.php @@ -23,16 +23,14 @@ * 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 require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; require_once '../lib/upbuttons.lib.php'; -require_once __DIR__ . '/../backport/v17/core/lib/functions.lib.php'; - // Translations $langs->load("upbuttons@upbuttons"); @@ -40,7 +38,7 @@ // Access control if (! $user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -49,30 +47,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); } } @@ -85,17 +75,17 @@ // Subheader $linkback = '' - . $langs->trans("BackToModuleList") . ''; + . $langs->trans("BackToModuleList") . ''; print_fiche_titre($langs->trans($page_name), $linkback); // Configuration header $head = upbuttonsAdminPrepareHead(); dol_fiche_head( - $head, - 'settings', - $langs->trans("Module104830Name"), - -1, - "upbuttons@upbuttons" + $head, + 'settings', + $langs->trans("Module104830Name"), + -1, + "upbuttons@upbuttons" ); dol_fiche_end(-1); @@ -114,14 +104,14 @@ $var=!$var; print ''; print ''; -print $form->textwithtooltip( $langs->trans("ConvertTabToStickyTab") , $langs->trans("ConvertTabToStickyTabHelp"),2,1,img_help(1,'')); +print $form->textwithtooltip($langs->trans("ConvertTabToStickyTab"), $langs->trans("ConvertTabToStickyTabHelp"), 2, 1, img_help(1, '')); print ''; print ' '; print ''; print '
'; print ''; print ''; -print $form->selectyesno("UPBUTTON_STICKY_TAB",getDolGlobalInt('UPBUTTON_STICKY_TAB'),1); +print $form->selectyesno("UPBUTTON_STICKY_TAB", getDolGlobalInt('UPBUTTON_STICKY_TAB'), 1); print ''; print '
'; print ''; @@ -129,14 +119,14 @@ $var=!$var; print ''; print ''; -print $form->textwithtooltip( $langs->trans("HideAvailableActionButtons") , '',0,1,img_help(1,'')); +print $form->textwithtooltip($langs->trans("HideAvailableActionButtons"), '', 0, 1, img_help(1, '')); print ''; print ' '; print ''; print '
'; print ''; print ''; -print $form->selectyesno("UPBUTTON_HIDE_AVAILABLE_ACTION",getDolGlobalInt('UPBUTTON_HIDE_AVAILABLE_ACTION'),1); +print $form->selectyesno("UPBUTTON_HIDE_AVAILABLE_ACTION", getDolGlobalInt('UPBUTTON_HIDE_AVAILABLE_ACTION'), 1); print ''; print '
'; print ''; @@ -144,21 +134,21 @@ $var=!$var; print ''; print ''; -print $form->textwithtooltip( $langs->trans("DisplayFloatingMenu") , $langs->trans("DisplayFloatingMenuHelp"),2,1,img_help(1,'')); +print $form->textwithtooltip($langs->trans("DisplayFloatingMenu"), $langs->trans("DisplayFloatingMenuHelp"), 2, 1, img_help(1, '')); print ''; print ' '; print ''; print '
'; print ''; print ''; -print $form->selectyesno("UPBUTTON_DISPLAY_FLOATING_MENU",getDolGlobalInt('UPBUTTON_DISPLAY_FLOATING_MENU'),1); +print $form->selectyesno("UPBUTTON_DISPLAY_FLOATING_MENU", getDolGlobalInt('UPBUTTON_DISPLAY_FLOATING_MENU'), 1); print ''; print '
'; print ''; -if(getDolGlobalInt('UPBUTTON_DISPLAY_FLOATING_MENU')) { +if (getDolGlobalInt('UPBUTTON_DISPLAY_FLOATING_MENU')) { $var = ! $var; print ''; print ''; @@ -169,7 +159,7 @@ print '
'; print ''; print ''; - print Form::selectarray("UPBUTTON_DISPLAY_FLOATING_MENU_TYPE", array('vertical' => 'Vertical', 'horizontal' => 'Horizontal') , getDolGlobalString('UPBUTTON_DISPLAY_FLOATING_MENU_TYPE')); + print Form::selectarray("UPBUTTON_DISPLAY_FLOATING_MENU_TYPE", array('vertical' => 'Vertical', 'horizontal' => 'Horizontal'), getDolGlobalString('UPBUTTON_DISPLAY_FLOATING_MENU_TYPE')); print ''; print '
'; print ''; diff --git a/backport/v17/core/lib/functions.lib.php b/backport/v17/core/lib/functions.lib.php deleted file mode 100644 index 20ddd7c..0000000 --- a/backport/v17/core/lib/functions.lib.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * 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 . - */ - - - diff --git a/class/techatm.class.php b/class/techatm.class.php index ec050d7..ed44961 100644 --- a/class/techatm.class.php +++ b/class/techatm.class.php @@ -6,69 +6,64 @@ */ namespace upbuttons; - +/** + * Class TechATM + */ class TechATM { - /** * @var DoliDb Database handler (result of a new DoliDB) */ public $db; - /** * @var string Error string * @see $errors */ public $error; - /** * @var string[] Array of error strings */ public $errors = array(); - /** * @var reponse_code a http_response_header parsed reponse code */ public $reponse_code; - /** * @var http_response_header the last call $http_response_header */ - public $http_response_header; - /** * @var TResponseHeader the last call $http_response_header parsed <- for most common usage (see self::parseHeaders() function) */ public $TResponseHeader; - /** * url vers le domaine des appels techniques */ const ATM_TECH_URL = 'https://tech.atm-consulting.fr'; - - /** * il s'agit de la version de ce cette class * Si jamais on change la façon de faire * Au moins on peut gérer des redescentes d'info différentes ex json au lieu de html simple */ const CALL_VERSION = 1.0; - /** - * Constructor + * 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 + * + * @param object $moduleDescriptor Module descriptor + * @param bool $useCache Use cache + * @return string */ - function getAboutPage($moduleDescriptor, $useCache = true){ + public function getAboutPage($moduleDescriptor, $useCache = true) + { global $langs; $url = self::ATM_TECH_URL.'/modules/modules-page-about.php'; @@ -82,11 +77,11 @@ function getAboutPage($moduleDescriptor, $useCache = true){ $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,7 +89,7 @@ function getAboutPage($moduleDescriptor, $useCache = true){ $content = $this->getContents($url); - if(!$content){ + if (!$content) { $content = ''; // About page goes here $content.= '
'; @@ -104,14 +99,14 @@ function getAboutPage($moduleDescriptor, $useCache = true){ $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){ + if ($res) { $comment = ''."\r\n"; file_put_contents( @@ -125,18 +120,26 @@ function getAboutPage($moduleDescriptor, $useCache = true){ } /** - * @param string $moduleTechMane + * Get module doc URL + * + * @param string $moduleTechMane Module name + * @return string */ - public static function getModuleDocUrl($moduleTechMane){ + public static function getModuleDocUrl($moduleTechMane) + { $url = self::ATM_TECH_URL.'/modules/doc-redirect.php'; $url.= '?module='.$moduleTechMane; return $url; } /** - * @param DolibarrModules $moduleDescriptor + * Get last module version URL + * + * @param object $moduleDescriptor Module descriptor + * @return string */ - public static function getLastModuleVersionUrl($moduleDescriptor){ + public static function getLastModuleVersionUrl($moduleDescriptor) + { $url = self::ATM_TECH_URL.'/modules/modules-last-version.php'; $url.= '?module='.$moduleDescriptor->name; $url.= '&number='.$moduleDescriptor->numero; @@ -148,17 +151,20 @@ public static function getLastModuleVersionUrl($moduleDescriptor){ /** - * @param $url + * Get JSON data + * + * @param string $url URL to reach * @return false|object */ - 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,168 +176,101 @@ public function getJsonData($url){ } /** - * @param $url + * Get Contents + * + * @param string $url URL to reach * @return false|string */ - 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 message + * + * @param int|null $code HTTP code + * @return string + */ + public static function httpResponseCodeMsg($code = null) { - if ($code !== NULL) { - + if ($code !== null) { switch ($code) { - case 100: - $text = 'Continue'; - break; - case 101: - $text = 'Switching Protocols'; - break; - case 200: - $text = 'OK'; - break; - case 201: - $text = 'Created'; - break; - case 202: - $text = 'Accepted'; - break; - case 203: - $text = 'Non-Authoritative Information'; - break; - case 204: - $text = 'No Content'; - break; - case 205: - $text = 'Reset Content'; - break; - case 206: - $text = 'Partial Content'; - break; - case 300: - $text = 'Multiple Choices'; - break; - case 301: - $text = 'Moved Permanently'; - break; - case 302: - $text = 'Moved Temporarily'; - break; - case 303: - $text = 'See Other'; - break; - case 304: - $text = 'Not Modified'; - break; - case 305: - $text = 'Use Proxy'; - break; - case 400: - $text = 'Bad Request'; - break; - case 401: - $text = 'Unauthorized'; - break; - case 402: - $text = 'Payment Required'; - break; - case 403: - $text = 'Forbidden'; - break; - case 404: - $text = 'Not Found'; - break; - case 405: - $text = 'Method Not Allowed'; - break; - case 406: - $text = 'Not Acceptable'; - break; - case 407: - $text = 'Proxy Authentication Required'; - break; - case 408: - $text = 'Request Time-out'; - break; - case 409: - $text = 'Conflict'; - break; - case 410: - $text = 'Gone'; - break; - case 411: - $text = 'Length Required'; - break; - case 412: - $text = 'Precondition Failed'; - break; - case 413: - $text = 'Request Entity Too Large'; - break; - case 414: - $text = 'Request-URI Too Large'; - break; - case 415: - $text = 'Unsupported Media Type'; - break; - case 500: - $text = 'Internal Server Error'; - break; - case 501: - $text = 'Not Implemented'; - break; - case 502: - $text = 'Bad Gateway'; - break; - case 503: - $text = 'Service Unavailable'; - break; - case 504: - $text = 'Gateway Time-out'; - break; - case 505: - $text = 'HTTP Version not supported'; - break; + case 100: $text = 'Continue'; break; + case 101: $text = 'Switching Protocols'; break; + case 200: $text = 'OK'; break; + case 201: $text = 'Created'; break; + case 202: $text = 'Accepted'; break; + case 203: $text = 'Non-Authoritative Information'; break; + case 204: $text = 'No Content'; break; + case 205: $text = 'Reset Content'; break; + case 206: $text = 'Partial Content'; break; + case 300: $text = 'Multiple Choices'; break; + case 301: $text = 'Moved Permanently'; break; + case 302: $text = 'Moved Temporarily'; break; + case 303: $text = 'See Other'; break; + case 304: $text = 'Not Modified'; break; + case 305: $text = 'Use Proxy'; break; + case 400: $text = 'Bad Request'; break; + case 401: $text = 'Unauthorized'; break; + case 402: $text = 'Payment Required'; break; + case 403: $text = 'Forbidden'; break; + case 404: $text = 'Not Found'; break; + case 405: $text = 'Method Not Allowed'; break; + case 406: $text = 'Not Acceptable'; break; + case 407: $text = 'Proxy Authentication Required'; break; + case 408: $text = 'Request Time-out'; break; + case 409: $text = 'Conflict'; break; + case 410: $text = 'Gone'; break; + case 411: $text = 'Length Required'; break; + case 412: $text = 'Precondition Failed'; break; + case 413: $text = 'Request Entity Too Large'; break; + case 414: $text = 'Request-URI Too Large'; break; + case 415: $text = 'Unsupported Media Type'; break; + case 500: $text = 'Internal Server Error'; break; + case 501: $text = 'Not Implemented'; break; + case 502: $text = 'Bad Gateway'; break; + case 503: $text = 'Service Unavailable'; break; + case 504: $text = 'Gateway Time-out'; break; + case 505: $text = 'HTTP Version not supported'; break; default: $text = 'Unknown http status code "' . htmlentities($code) . '"'; break; } return $text; - } else { - return $text = 'Unknown http status code NULL'; + return 'Unknown http status code NULL'; } } - - public static function parseHeaders( $headers ) + /** + * Parse headers + * + * @param array $headers Headers array + * @return 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 e819aa5..2768a32 100644 --- a/config.default.php +++ b/config.default.php @@ -1,17 +1,29 @@ . + */ + 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; - } - \ No newline at end of file +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; +} diff --git a/config.php b/config.php index a20fa5a..b4e0eb3 100644 --- a/config.php +++ b/config.php @@ -1,4 +1,18 @@ . + */ - require('config.default.php'); - + require 'config.default.php'; diff --git a/core/modules/modUpbuttons.class.php b/core/modules/modUpbuttons.class.php index 13c87e4..457220d 100644 --- a/core/modules/modUpbuttons.class.php +++ b/core/modules/modUpbuttons.class.php @@ -38,11 +38,11 @@ class modUpbuttons 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; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). @@ -54,11 +54,11 @@ function __construct($db) // It is used to group modules in module setup page $this->family = "ATM Consulting"; // 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 = "Description of module Upbuttons"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = '1.4.2'; + $this->version = '1.4.3'; // Url to the file with your last numberversion of this module require_once __DIR__ . '/../../class/techatm.class.php'; $this->url_last_version = \upbuttons\TechATM::getLastModuleVersionUrl($this); @@ -85,7 +85,7 @@ 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('/upbuttons/css/upbuttons.css.php'), // Set this to relative path of css file if module has its own css file - // 'js' => array('/upbuttons/js/upbuttons.js'), // Set this to relative path of js file if module must load a js on all pages + // 'js' => array('/upbuttons/js/upbuttons.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'=>'isModEnabled("module1") && isModEnabled("module2")', 'picto'=>'yourpicto@upbuttons')) // Set here all workflow context managed by module @@ -119,9 +119,9 @@ function __construct($db) $this->const = array(); // Array to add new pages in new tabs - // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@upbuttons:$user->rights->upbuttons->read:/upbuttons/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:Title2:mylangfile@upbuttons:$user->rights->othermodule->read:/upbuttons/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@upbuttons:$user->hasRight('upbuttons', 'read'):/upbuttons/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:Title2:mylangfile@upbuttons:$user->hasRight('othermodule', 'read'):/upbuttons/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 @@ -142,34 +142,33 @@ 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(); + $this->tabs = array(); - // Dictionaries - if (!isModEnabled("upbuttons")) - { - $conf->upbuttons=new stdClass(); - $conf->upbuttons->enabled=0; - } + // Dictionaries + if (!isModEnabled("upbuttons")) { + $conf->upbuttons=new stdClass(); + $conf->upbuttons->enabled=0; + } $this->dictionaries=array(); - /* Example: - if (! isModEnabled("upbuttons")) $conf->upbuttons->enabled=0; // This is to avoid warnings - $this->dictionaries=array( - 'langs'=>'mylangfile@upbuttons', - '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(isModEnabled("upbuttons"),isModEnabled("upbuttons"),isModEnabled("upbuttons")) // Condition to show each dictionary - ); - */ + /* Example: + if (! isModEnabled("upbuttons")) $conf->upbuttons->enabled=0; // This is to avoid warnings + $this->dictionaries=array( + 'langs'=>'mylangfile@upbuttons', + '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(isModEnabled("upbuttons"),isModEnabled("upbuttons"),isModEnabled("upbuttons")) // 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'=>''));); @@ -235,7 +234,7 @@ function __construct($db) // 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'); @@ -252,14 +251,14 @@ 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); + define('INC_FROM_DOLIBARR', true); dol_include_once('/upbuttons/config.php'); dol_include_once('/upbuttons/script/create-maj-base.php'); @@ -274,14 +273,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_modUpbuttons_Upbuttonstrigger.class.php b/core/triggers/interface_99_modUpbuttons_Upbuttonstrigger.class.php index 139299a..e684194 100644 --- a/core/triggers/interface_99_modUpbuttons_Upbuttonstrigger.class.php +++ b/core/triggers/interface_99_modUpbuttons_Upbuttonstrigger.class.php @@ -17,17 +17,9 @@ */ /** - * \file core/triggers/interface_99_modMyodule_Upbuttonstrigger.class.php - * \ingroup upbuttons - * \brief Sample trigger - * \remarks You can create other triggers by copying this one - * - File name should be either: - * interface_99_modMymodule_Mytrigger.class.php - * interface_99_all_Mytrigger.class.php - * - The file must stay in core/triggers - * - The class name must be InterfaceMytrigger - * - The constructor method must be named InterfaceMytrigger - * - The name property name must be Mytrigger + * \file core/triggers/interface_99_modMyodule_Upbuttonstrigger.class.php + * \ingroup upbuttons + * \brief Sample trigger */ /** @@ -35,84 +27,110 @@ */ class InterfaceUpbuttonstrigger { + /** + * @var DoliDB Database handler + */ + protected $db; - private $db; + /** + * @var string Name + */ + public $name; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + /** + * @var string Family + */ + public $family; - $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 = 'upbuttons@upbuttons'; - } + /** + * @var string Description + */ + public $description; - /** - * Trigger name - * - * @return string Name of trigger file - */ - public function getName() - { - return $this->name; - } + /** + * @var string Version + */ + public $version; - /** - * Trigger description - * - * @return string Description of trigger file - */ - public function getDesc() - { - return $this->description; - } + /** + * @var string Picto + */ + public $picto; - /** - * Trigger version - * - * @return string Version of trigger file - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - if ($this->version == 'development') { - return $langs->trans("Development"); - } elseif ($this->version == 'experimental') + $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 = 'upbuttons@upbuttons.png'; + } - return $langs->trans("Experimental"); - elseif ($this->version == 'dolibarr') return DOL_VERSION; - elseif ($this->version) return $this->version; - else { - return $langs->trans("Unknown"); - } - } + /** + * Return name of trigger + * + * @return string Name of trigger file + */ + public function getName() + { + return $this->name; + } - /** - * 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; - } + /** + * Return description of trigger + * + * @return string Description of trigger file + */ + public function getDesc() + { + return $this->description; + } + + /** + * Return version of trigger + * + * @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') { + 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 runTrigger($action, $object, $user, $langs, $conf) + { + return 0; + } } diff --git a/js/upbuttons.js.php b/js/upbuttons.js.php index ff56501..3de6523 100644 --- a/js/upbuttons.js.php +++ b/js/upbuttons.js.php @@ -1,4 +1,19 @@ . + */ header('Content-Type: application/javascript'); @@ -7,7 +22,7 @@ } require __DIR__ . '/../config.php'; -require_once __DIR__ . '/../backport/v17/core/lib/functions.lib.php'; + if (!$user->hasRight('upbuttons', 'UseAllButton') && !$user->hasRight('upbuttons', 'UseSingleButton')) exit; @@ -16,14 +31,14 @@ ?>$(document).ready(function () { - $.fn.isInViewport = function () { - var elementTop = $(this).offset().top; - var elementBottom = elementTop+$(this).outerHeight(); + $.fn.isInViewport = function () { + var elementTop = $(this).offset().top; + var elementBottom = elementTop+$(this).outerHeight(); - var viewportTop = $(window).scrollTop(); - var viewportBottom = viewportTop+$(window).height(); - return elementBottom > viewportTop && elementTop < viewportBottom; - }; + var viewportTop = $(window).scrollTop(); + var viewportBottom = viewportTop+$(window).height(); + return elementBottom > viewportTop && elementTop < viewportBottom; + }; var $upbuttons_container = $('div.tabsAction').first(); window.setTimeout(getButtonInBanner, 300); //delai for js button @@ -45,7 +60,7 @@ function scrollButtonsToUp() { && $(window).width() > 1000 // disbled for smartphone ) { //console.log("tabsAction not in screen "); - + $upbuttons_container.css({ position: "fixed" , bottom: '-1px' @@ -57,7 +72,7 @@ function scrollButtonsToUp() { , 'margin': '0 0 0 0' , 'opacity': 1 }); - + $upbuttons_container.addClass('upbuttonsdiv'); @@ -76,10 +91,10 @@ function scrollButtonsToUp() { hasRight('upbuttons', 'UseAllButton') - && $user->hasRight('upbuttons', 'UseSingleButton') + if ( !$user->hasRight('upbuttons', 'UseAllButton') + && $user->hasRight('upbuttons', 'UseSingleButton') ) { - ?> + ?> $upbuttons_container.hide(); $('#justOneButton').css({ position: "fixed" @@ -89,7 +104,7 @@ function scrollButtonsToUp() { , 'opacity': 0.7 }).show(); - } else { @@ -117,23 +132,23 @@ function scrollButtonsToUp() { } $(window).resize(function () { scrollButtonsToUp(); - if($('div.tabsAction').isInViewport()) $('#upbuttons-floating-menu').hide(); - else $('#upbuttons-floating-menu').show(); + if($('div.tabsAction').isInViewport()) $('#upbuttons-floating-menu').hide(); + else $('#upbuttons-floating-menu').show(); }); $(window).on('scroll', function () { scrollButtonsToUp(); - if($('div.tabsAction').isInViewport()) $('#upbuttons-floating-menu').hide(); - else $('#upbuttons-floating-menu').show(); + if($('div.tabsAction').isInViewport()) $('#upbuttons-floating-menu').hide(); + else $('#upbuttons-floating-menu').show(); }); scrollButtonsToUp(); } +if ( getDolGlobalInt('UPBUTTON_STICKY_TAB')) { + ?> if($(window).width() > 1000 && $('.tabs').length > 0 && window.location.href.indexOf("&optioncss=print") == -1) { // disabled for smartphone and print $('body').addClass('upbutton-allow-sticky-tab'); // for css filter @@ -160,7 +175,7 @@ function scrollButtonsToUp() { observer.observe(document.querySelector(".sentinal")); } } - }); @@ -196,56 +211,55 @@ function getButtonInBanner() { }); - - $nav = $(''); - $nav.hover( - function () { - $(this).find('ul').show(); - } - , function () { - $(this).find('ul').hide(); - } - ); - - $nav.append($ul); + + $nav = $(''); + $nav.hover( + function () { + $(this).find('ul').show(); + } + , function () { + $(this).find('ul').hide(); + } + ); - $dropdownbutton.append($nav); - + $nav.append($ul); - + $dropdownbutton.append($nav); + - let menuClass = '--vertical'; + + let menuClass = '--vertical'; - - menuClass = '--horizontal'; - + + menuClass = '--horizontal'; + - $nav = $(''); + $nav = $(''); - $dropdownbutton.append($nav); - let ul = $($ul).clone(); - ul.show(); - $('.upbuttons-container').append(ul); - if(menuClass == '--horizontal'){ - $('#upbuttons-floating-menu').width($('.upbuttons-container').width()+80); - } + $dropdownbutton.append($nav); + let ul = $($ul).clone(); + ul.show(); + $('.upbuttons-container').append(ul); + if(menuClass == '--horizontal'){ + $('#upbuttons-floating-menu').width($('.upbuttons-container').width()+80); + } - $(document).on('click', '#upbuttons-floating-menu .upbuttons-close-button', function (event) { - $('#upbuttons-floating-menu').toggleClass('--closed'); - }); + $(document).on('click', '#upbuttons-floating-menu .upbuttons-close-button', function (event) { + $('#upbuttons-floating-menu').toggleClass('--closed'); + }); - $(document).on('mouseover', '#upbuttons-floating-menu.--closed .upbuttons-close-button', function (event) { - $('#upbuttons-floating-menu').toggleClass('--closed'); - }); + $(document).on('mouseover', '#upbuttons-floating-menu.--closed .upbuttons-close-button', function (event) { + $('#upbuttons-floating-menu').toggleClass('--closed'); + }); - // sur click out close - $(document).on("click", function(event) { + // sur click out close + $(document).on("click", function(event) { if (!$(event.target).closest("#nav-dropdown").length) { - $('#upbuttons-floating-menu').addClass('--closed'); - } - }); - if ($('div.tabsAction').isInViewport()) $('#upbuttons-floating-menu').hide(); - else $('#upbuttons-floating-menu').show(); + $('#upbuttons-floating-menu').addClass('--closed'); + } + }); + if ($('div.tabsAction').isInViewport()) $('#upbuttons-floating-menu').hide(); + else $('#upbuttons-floating-menu').show();