NEW : Quick memo module (#37422)

* Add quick memo module

* remove backport

* remove under v24 code

* fix css

* remove dirt

* Fix icon and z index

* Fix option coherance

* Missing trad

* css

* Move sql files

* Mv langs files

* missing langs files

* PHP stan add lang trans from Dolibarr JS context

* missing langs

* remove duplicate lang

* Fix lang load after lang move

* remove useless try to include main

* mv jsonResponce.class.php

* rm comment

* rm useless files

* Fix lang load and remove module backport

* Fix lang duplicate

* fix php stan errors

* fix php stan errors

* fix query

* Update memo.class.php

* Update properties to allow null values

* Remove old img

* Fix sql filter

* fields def change for php stan

* PHP doc update

* Comment

* Fix php doc

* Fix php doc

* Fix php doc

* Fix php doc

* Fix php doc

* Fix php stan feedback

* Fix php stan feedback

* Fix php stan feedback

* Fix php stan feedback

* Fix php stan feedback

* Fix php stan feedback

* Use new native css tooltips

* php doc

* php doc

* php doc

* Fix sql

* remove static method

* travis

* travis

* travis

* Move modQuickMemo.class.php

* Update llx_quickmemo_memo-quickmemo.sql

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
John BOTELLA 2026-04-15 17:47:50 +02:00 committed by GitHub
parent b23e968ed6
commit 3ab77d673e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 9055 additions and 12 deletions

View file

@ -152,6 +152,7 @@ $VALID_MODULE_MAPPING = array(
'productsupplierprice' => null,
'project' => 'Projet',
'propal' => 'Propale',
'quickmemo' => null,
'receiptprinter' => 'ReceiptPrinter',
'reception' => 'Reception',
'recruitment' => 'Recruitment',

View file

@ -74,7 +74,7 @@ sort -u \
#
EXTRACT_STR=""
JOIN_STR=""
for t in '->trans' '->transnoentities' '->transnoentitiesnoconv' '->newItem' '->buttonsSaveCancel'; do
for t in '->trans' '->transnoentities' '->transnoentitiesnoconv' '->newItem' '->buttonsSaveCancel' 'Dolibarr.tools.langs.trans' 'Dolibarr.tools.langs.transNoEntities'; do
MATCH_STR="$MATCH_STR$JOIN_STR$t"
EXTRACT_STR="$EXTRACT_STR$JOIN_STR(?<=${t}\\([\"'])([^\"']+)(?=[\"']\$)"
JOIN_STR="|"
@ -90,7 +90,7 @@ done
# With std grep: `grep --no-filename -r ${GREP_OPTS} -- '->trans(' . `
# Using git grep avoiding to look into unversioned files
# transnoentitiesnoconv
git grep -h -r -P -- "${MATCH_STR}\\(" ':*.php' ':*.html' \
git grep -h -r -P -- "${MATCH_STR}\\(" ':*.php' ':*.html' ':*.js' \
| sed 's@\(^#\|[^:]//\|/\*\|^\s*\*\).*@@' \
| sed 's@)\|\(['"'"'"]\)\(,\)@\1\n@g' \
| grep -aPo "$EXTRACT_STR(?=.$)"
@ -162,7 +162,7 @@ if [ -s "${MISSING_FILE}.grep" ] ; then
echo "##[group]List missing translations (used by code but not found into lang files) - Generate CTI errors"
git grep -n --column -r -F -f "${MISSING_FILE}.grep" -- ':*.php' ':*.html' \
git grep -n --column -r -F -f "${MISSING_FILE}.grep" -- ':*.php' ':*.html' ':*.js' \
| sort -t: -k 4 \
| sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Missing translation; @' > "${MISSING_FILE}.result"

View file

@ -153,8 +153,40 @@ abstract class CommonObject
/**
* @var array<string,array{type:string,label:string,langfile?:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-6,6>|string,alwayseditable?:int<0,1>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,cssview?:string,csslist?:string,help?:string,showoncombobox?:int<0,4>|string,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>|string,showonheader?:int<0,1>,searchmulti?:int<0,1>}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*
* @var array<string,array<string,mixed>>
* @phpstan-var array<string, array{
* type: string,
* label: string,
* enabled: int<0, 2>|string,
* position: int,
* visible: int<-6, 6>|string,
* langfile?: string,
* notnull?: int<-1, 1>,
* noteditable?: int<0, 1>,
* alwayseditable?: int<0, 1>|string,
* default?: string|int,
* index?: int<0, 1>,
* foreignkey?: string,
* searchall?: int<0, 1>,
* isameasure?: int<0, 1>,
* css?: string,
* cssview?: string,
* csslist?: string,
* help?: string,
* helplist?: string,
* showoncombobox?: int<0, 4>|string,
* disabled?: int<0, 1>|string,
* arrayofkeyval?: array<int|string, string>,
* autofocusoncreate?: int<0, 1>,
* comment?: string,
* copytoclipboard?: int<1, 2>,
* validate?: int<0, 1>|string,
* showonheader?: int<0, 1>,
* searchmulti?: int<0, 1>,
* picto?: string,
* required?: int<0, 1>,
* placeholder?: string
* }>
* 'type' field format:
* 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',
* 'select' (list of values are in 'options'. for integer list of values are in 'arrayofkeyval'),
@ -8702,13 +8734,13 @@ abstract class CommonObject
* Return HTML string to show a field into a page
* Code very similar with showOutputField of extra fields
*
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $val Array of properties of field to show
* @param string $key Key of attribute
* @param string|int $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
* @param string $moreparam To add more parameters on html tag
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
* @param mixed $morecss Value for CSS to use (Old usage: May also be a numeric to define a size).
* @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-6,6>,noteditable?:int,default?:int|string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,cssview?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int,required?:int,picto?:string} $val Array of properties of field to show
* @param string $key Key of attribute
* @param string|int|null $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
* @param string $moreparam To add more parameters on html tag
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
* @param mixed $morecss Value for CSS to use (Old usage: May also be a numeric to define a size).
* @return string
*/
public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '')

View file

@ -0,0 +1,90 @@
<?php
/* Copyright (C) 2024 John BOTELLA
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* Class JsonResponse
* used for ajax responses in Dolibarr
*/
class JsonResponse
{
/**
* the call status to determine if success or fail
*
* @var int $result 0|1
*/
public $result = 0;
/**
* data to return to call can be all type you want
*
* @var mixed
*/
public $data;
/**
* debug data
*
* @var mixed
*/
public $debug;
/**
* returned message used usually as set event message
*
* @var string $msg
*/
public $msg = '';
/**
* the current newToken
*
* @var mixed|string
*/
public $newToken = '';
/**
* JsonResponse constructor.
*/
public function __construct()
{
$this->newToken = newToken();
}
/**
* return json encoded of object
*
* @return string JSON
*/
public function getResponse()
{
if (!$this->result && !headers_sent()) {
http_response_code(400);
}
$jsonResponse = new stdClass();
$jsonResponse->result = $this->result;
$jsonResponse->msg = $this->msg;
$jsonResponse->newToken = $this->newToken;
$jsonResponse->data = $this->data;
$jsonResponse->debug = $this->debug;
return json_encode($jsonResponse, JSON_PRETTY_PRINT);
}
}

View file

@ -0,0 +1,401 @@
<?php
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 John BOTELLA
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \defgroup quickmemo Module QuickMemo
* \brief QuickMemo module descriptor.
*
* \file htdocs/quickmemo/core/modules/modQuickMemo.class.php
* \ingroup quickmemo
* \brief Description and activation file for module QuickMemo
*/
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Description and activation class for module QuickMemo
*/
class modQuickMemo extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
global $conf, $langs;
$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).
$this->numero = 141916;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'quickmemo';
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
// It is used to group modules by family in module setup page
$this->family = "other";
// Module position in the family on 2 digits ('01', '10', '20', ...)
$this->module_position = '90';
// Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
// Module label (no space allowed), used if translation string 'ModuleQuickMemoName' not found (QuickMemo is name of module).
$this->name = preg_replace('/^mod/i', '', get_class($this));
// DESCRIPTION_FLAG
// Module description, used if translation string 'ModuleQuickMemoDesc' not found (QuickMemo is name of module).
$this->description = "QuickMemoDescription";
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "QuickMemoDescription";
// Author
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@quickmemo'
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
$this->version = 'experimental';
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
// Key used in llx_const table to save module status enabled/disabled (where QUICKMEMO is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// 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'
// To use a supported fa-xxx css style of font awesome, use this->picto='xxx'
$this->picto = 'fa-sticky-note_far_#9bdb07';
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
$this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers)
'triggers' => 0,
// Set this to 1 if module has its own login method file (core/login)
'login' => 0,
// Set this to 1 if module has its own substitution function file (core/substitutions)
'substitutions' => 0,
// Set this to 1 if module has its own menus handler directory (core/menus)
'menus' => 0,
// Set this to 1 if module overwrite template dir (core/tpl)
'tpl' => 0,
// Set this to 1 if module has its own barcode directory (core/modules/barcode)
'barcode' => 0,
// Set this to 1 if module has its own models directory (core/modules/xxx)
'models' => 0,
// Set this to 1 if module has its own printing directory (core/modules/printing)
'printing' => 0,
// Set this to 1 if module has its own theme directory (theme)
'theme' => 0,
// Set this to relative path of css file if module has its own css file
'css' => array(
// '/quickmemo/css/quickmemo.css.php',
),
// Set this to relative path of js file if module must load a js on all pages
'js' => array(
// '/quickmemo/js/quickmemo.js.php',
),
// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
'hooks' => array(
'data' => array(
'globalcard',
'index',
),
'entity' => '0',
),
// Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0,
// Set this to 1 if the module provides a website template into doctemplates/websites/website_template-mytemplate
'websitetemplates' => 0,
// Set this to 1 if the module provides a captcha driver
'captcha' => 0
);
// Data directories to create when module is enabled.
// Example: this->dirs = array("/quickmemo/temp","/quickmemo/subdir");
$this->dirs = array("");
// Config pages. Put here list of php page, stored into quickmemo/admin directory, to use to setup module.
$this->config_page_url = array("setup.php@quickmemo");
// Dependencies
// A condition to hide module
$this->hidden = getDolGlobalInt('MODULE_QUICKMEMO_DISABLED'); // A condition to disable module;
// List of module class names that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR')...)
$this->depends = array();
// List of module class names to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
$this->requiredby = array();
// List of module class names this module is in conflict with. Example: array('modModuleToDisable1', ...)
$this->conflictwith = array();
// The language file dedicated to your module
$this->langfiles = array("quickmemo@quickmemo");
// Prerequisites
$this->phpmin = array(7, 2); // Minimum version of PHP required by module
// $this->phpmax = array(8, 0); // Maximum version of PHP required by module
$this->need_dolibarr_version = array(19, -3); // Minimum version of Dolibarr required by module
// $this->max_dolibarr_version = array(19, -3); // Maximum version of Dolibarr required by module
$this->need_javascript_ajax = 0;
// Messages at activation
$this->warnings_activation = array(); // Warning to show when we activate a module. Example: array('always'='text') or array('FR'='textfr','MX'='textmx'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate a module if another module is on. Example: array('modOtherModule' => array('always'=>'text')) or array('always' => array('FR'=>'textfr','MX'=>'textmx'...))
//$this->automatic_activation = array('FR'=>'QuickMemoWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = false; // If true, can't be disabled. Value true is reserved for core modules. Not allowed for external modules.
// Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(1 => array('QUICKMEMO_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
// 2 => array('QUICKMEMO_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// );
$this->const = array();
// Some keys to add into the overwriting translation tables
/*$this->overwrite_translation = array(
'en_US:ParentCompany'=>'Parent company or reseller',
'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
)*/
if (!isModEnabled("quickmemo")) {
$conf->quickmemo = new stdClass();
$conf->quickmemo->enabled = 0;
}
// Array to add new pages in new tabs
/* BEGIN MODULEBUILDER TABS */
// Don't forget to deactivate/reactivate your module to test your changes
$this->tabs = array();
/* END MODULEBUILDER TABS */
// Example:
// To add a new tab identified by code tabname1
// $this->tabs[] = array('data' => 'objecttype:+tabname1:Title1:mylangfile@quickmemo:$user->hasRight('quickmemo', 'memo', 'read'):/quickmemo/mynewtab1.php?id=__ID__');
// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data' => 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@quickmemo:$user->hasRight('othermodule', 'otherobject', 'read'):/quickmemo/mynewtab2.php?id=__ID__',
// To remove an existing tab identified by code tabname
// $this->tabs[] = array('data' => 'objecttype:-tabname:NU:conditiontoremove');
//
// 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
// 'contract' to add a tab in contract view
// 'delivery' to add a tab in delivery view
// 'group' to add a tab in group view
// 'intervention' to add a tab in intervention view
// 'invoice' to add a tab in customer invoice view
// 'supplier_invoice' to add a tab in supplier invoice view
// 'member' to add a tab in foundation member view
// 'opensurveypoll' to add a tab in opensurvey poll view
// 'order' to add a tab in sale order view
// 'supplier_order' to add a tab in supplier order view
// 'payment' to add a tab in payment view
// 'supplier_payment' to add a tab in supplier payment view
// 'product' to add a tab in product view
// 'propal' to add a tab in propal view
// 'project' to add a tab in project view
// '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
// Dictionaries
/* Example:
$this->dictionaries=array(
'langs' => 'quickmemo@quickmemo',
// List of tables we want to see into dictionary editor
'tabname' => array("table1", "table2", "table3"),
// Label of tables
'tablib' => array("Table1", "Table2", "Table3"),
// Request to select fields
'tabsql' => array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.$this->db->prefix().'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.$this->db->prefix().'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.$this->db->prefix().'table3 as f'),
// Sort order
'tabsqlsort' => array("label ASC", "label ASC", "label ASC"),
// List of fields (result of select to show dictionary)
'tabfield' => array("code,label", "code,label", "code,label"),
// List of fields (list of fields to edit a record)
'tabfieldvalue' => array("code,label", "code,label", "code,label"),
// List of fields (list of fields for insert)
'tabfieldinsert' => array("code,label", "code,label", "code,label"),
// Name of columns with primary key (try to always name it 'rowid')
'tabrowid' => array("rowid", "rowid", "rowid"),
// Condition to show each dictionary
'tabcond' => array(isModEnabled('quickmemo'), isModEnabled('quickmemo'), isModEnabled('quickmemo')),
// Tooltip for every fields of dictionaries: DO NOT PUT AN EMPTY ARRAY
'tabhelp' => array(array('code' => $langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), array('code' => $langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip'), ...),
);
*/
/* BEGIN MODULEBUILDER DICTIONARIES */
$this->dictionaries = array();
/* END MODULEBUILDER DICTIONARIES */
// Boxes/Widgets
// Add here list of php file(s) stored in quickmemo/core/boxes that contains a class to show a widget.
/* BEGIN MODULEBUILDER WIDGETS */
$this->boxes = array(
// 0 => array(
// 'file' => 'quickmemowidget1.php@quickmemo',
// 'note' => 'Widget provided by QuickMemo',
// 'enabledbydefaulton' => 'Home',
// ),
// ...
);
/* END MODULEBUILDER WIDGETS */
// Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
/* BEGIN MODULEBUILDER CRON */
$this->cronjobs = array(
// 0 => array(
// 'label' => 'MyJob label',
// 'jobtype' => 'method',
// 'class' => '/quickmemo/class/memo.class.php',
// 'objectname' => 'Memo',
// 'method' => 'doScheduledJob',
// 'parameters' => '',
// 'comment' => 'Comment',
// 'frequency' => 2,
// 'unitfrequency' => 3600,
// 'status' => 0,
// 'test' => 'isModEnabled("quickmemo")',
// 'priority' => 50,
// ),
);
/* END MODULEBUILDER CRON */
// Example: $this->cronjobs=array(
// 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'isModEnabled("quickmemo")', 'priority'=>50),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'isModEnabled("quickmemo")', 'priority'=>50)
// );
// Permissions provided by this module
$this->rights = array();
$r = 0;
// Add here entries to declare new permissions
$o = 1;
$this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 1); // Permission id (must not be already used)
$this->rights[$r][1] = 'Read objects of QuickMemo'; // Permission label
$this->rights[$r][4] = 'memo';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->hasRight('quickmemo', 'memo', 'read'))
$r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 2); // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/Update objects of QuickMemo'; // Permission label
$this->rights[$r][4] = 'memo';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->hasRight('quickmemo', 'memo', 'write'))
$r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 3); // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete objects of QuickMemo'; // Permission label
$this->rights[$r][4] = 'memo';
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->hasRight('quickmemo', 'memo', 'delete'))
$r++;
// Main menu entries to add
$this->menu = array();
$r = 0;
// Add here entries to declare new menus
$this->menu[$r++] = array(
'fk_menu' => 'fk_mainmenu=tools',
'type' => 'left',
'titre' => 'Memo',
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'),
'mainmenu' => 'tools',
'leftmenu' => 'memo',
'url' => '/quickmemo/memo_list.php',
'langs' => 'quickmemo',
'position' => 1000 + $r,
'enabled' => 'isModEnabled("quickmemo")',
'perms' => '1',
'target' => '',
'user' => 2,
'object' => 'Memo'
);
$this->menu[$r++] = array(
'fk_menu' => 'fk_mainmenu=tools,fk_leftmenu=memo',
'type' => 'left',
'titre' => 'List Memo',
'mainmenu' => 'tools',
'leftmenu' => 'quickmemo_memo_list',
'url' => '/quickmemo/memo_list.php',
'langs' => 'quickmemo',
'position' => 1000 + $r,
'enabled' => 'isModEnabled("quickmemo")',
'perms' => '1',
'target' => '',
'user' => 2,
'object' => 'Memo'
);
}
/**
* Function called when module is enabled.
* 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')
* @return int<-1,1> 1 if OK, <=0 if KO
*/
public function init($options = '')
{
// Create tables of module at module activation
$result = $this->_load_tables('/install/mysql/', 'quickmemo');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}
// Create extrafields during init
//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
//$extrafields = new ExtraFields($this->db);
//$result0=$extrafields->addExtraField('quickmemo_separator1', "Separator 1", 'separator', 1, 0, 'thirdparty', 0, 0, '', array('options'=>array(1=>1)), 1, '', 1, 0, '', '', 'quickmemo@quickmemo', 'isModEnabled("quickmemo")');
//$result1=$extrafields->addExtraField('quickmemo_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', -1, 0, '', '', 'quickmemo@quickmemo', 'isModEnabled("quickmemo")');
//$result2=$extrafields->addExtraField('quickmemo_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', -1, 0, '', '', 'quickmemo@quickmemo', 'isModEnabled("quickmemo")');
//$result3=$extrafields->addExtraField('quickmemo_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', -1, 0, '', '', 'quickmemo@quickmemo', 'isModEnabled("quickmemo")');
//$result4=$extrafields->addExtraField('quickmemo_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', -1, 0, '', '', 'quickmemo@quickmemo', 'isModEnabled("quickmemo")');
//$result5=$extrafields->addExtraField('quickmemo_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', -1, 0, '', '', 'quickmemo@quickmemo', 'isModEnabled("quickmemo")');
// Permissions
$this->remove($options);
$sql = array();
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int<-1,1> 1 if OK, <=0 if KO
*/
public function remove($options = '')
{
$sql = array();
return $this->_remove($sql, $options);
}
}

View file

@ -0,0 +1,19 @@
-- Copyright (C) 2026 John BOTELLA
--
-- 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 https://www.gnu.org/licenses/.
ALTER TABLE llx_quickmemo_memo ADD INDEX idx_quickmemo_memo_rowid (rowid);
ALTER TABLE llx_quickmemo_memo ADD INDEX idx_quickmemo_memo_element (fk_element, element_type);
ALTER TABLE llx_quickmemo_memo ADD INDEX idx_quickmemo_memo_status (status);

View file

@ -0,0 +1,49 @@
-- Copyright (C) 2026 John BOTELLA
--
-- 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 https://www.gnu.org/licenses/.
CREATE TABLE llx_quickmemo_memo(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
entity integer DEFAULT 1 NOT NULL,
fk_element integer NOT NULL,
element_type varchar(64) NOT NULL,
quick_note text,
date_creation datetime NOT NULL,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
fk_user_archived integer,
date_archived timestamp DEFAULT NULL,
import_key varchar(14),
pos_z integer NOT NULL DEFAULT 0,
pos_y integer NOT NULL DEFAULT 0,
pos_x integer NOT NULL DEFAULT 0,
pos_w integer NOT NULL DEFAULT 0,
pos_h integer NOT NULL DEFAULT 0,
color varchar(10),
context_tab varchar(64),
private tinyint NOT NULL DEFAULT 1,
private_tpl tinyint NULL DEFAULT 0,
rank_tpl integer DEFAULT 0,
name_tpl varchar(256),
shared_on_element integer NOT NULL DEFAULT 0,
status integer NOT NULL DEFAULT 1
) ENGINE=innodb;

View file

@ -0,0 +1,19 @@
-- Copyright (C) 2026 John BOTELLA
--
-- 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 https://www.gnu.org/licenses/.
-- BEGIN MODULEBUILDER INDEXES
ALTER TABLE llx_quickmemo_memo_extrafields ADD UNIQUE INDEX uk_memo_fk_object(fk_object);
-- END MODULEBUILDER INDEXES

View file

@ -0,0 +1,22 @@
-- Copyright (C) 2026 John BOTELLA
--
-- 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 https://www.gnu.org/licenses/.
create table llx_quickmemo_memo_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View file

@ -0,0 +1,17 @@
-- Copyright (C) 2026 John BOTELLA
--
-- 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 https://www.gnu.org/licenses/.
ALTER TABLE llx_quickmemo_memo_user ADD INDEX idx_quickmemo_memo_rowid (fk_memo);
ALTER TABLE llx_quickmemo_memo_user ADD UNIQUE KEY uk_memo_user (fk_memo, fk_user);

View file

@ -0,0 +1,28 @@
-- Copyright (C) 2026 John BOTELLA
--
-- 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 https://www.gnu.org/licenses/.
CREATE TABLE llx_quickmemo_memo_user(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
fk_memo integer NOT NULL,
date_creation datetime NOT NULL,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user integer NOT NULL,
pos_z integer NOT NULL DEFAULT 0,
pos_y integer NOT NULL DEFAULT 0,
pos_x integer NOT NULL DEFAULT 0,
pos_w integer NOT NULL DEFAULT 0,
pos_h integer NOT NULL DEFAULT 0
) ENGINE=innodb;

View file

@ -0,0 +1,100 @@
ModuleQuickMemoName = Quick Memo
ModuleQuickMemoDesc = Allows adding quick notes on documents
QuickMemoSetup = QuickMemo Setup
QUICKMEMO_COLORS_PRESET = Define your custom memo colors here
QuickMemoSetupPage = QuickMemo Configuration Page
QuickMemoAbout = About QuickMemo
QuickMemoAboutPage = QuickMemo Home Page
QuickMemoArea = QuickMemo Home
MyPageName = My Page Name
QuickMemoCreated = Created
QuickMemoModified = Modified
QuickMemoBy = by
QuickMemoEnterNote = Enter your memo
QuickMemoEnterNoteMdCompabible = Markdown style compatible
QuickMemoMd_Bold = Bold
QuickMemoMd_Italic = Italic
QuickMemoMd_Title = Title
QuickMemoMd_TaskNotDone = Task not done
QuickMemoMd_TaskDone = Task done
QuickMemoMd_List = List
QuickMemoMd_Link = Link
QuickMemoMd_LinkText = Link text
QuickMemoTemplateName = Template name
QuickMemoActionArchive = Archive memo
QuickMemoActionDelete = Delete memo
QuickMemoActionDeleteEmpty = Delete empty memo
QuickMemoActionShareMode = Share mode
QuickMemoActionShareModeNotActive = Share mode is inactive
QuickMemoActionShareModeActive = Share mode is active
QuickMemoActionChangeColor = Change color
QuickMemoActionPrivateMode = Public or private display mode
QuickMemoActionPrivateModeActive = Current display mode: Private
QuickMemoActionPrivateModeNotActive = Current display mode: Public
QuickMemoSavePositionError = An error occurred while saving memo position
QuickMemoSaveError = An error occurred while saving the memo
QuickMemoLoadModelError = An error occurred while loading memo templates
QuickMemoCreateError = An error occurred while creating the memo
QuickMemoLoadMemosError = An error occurred while loading memos
QuickMemoArchiveError = An error occurred while archiving the memo
QuickMemoArchived = Archived
QuickMemoAdd = Add memo
QuickMemoSavedTemplate = Saved templates
QuickMemoColorsPresets = Preset colors
QuickMemoShowArchives = View archives
QuickMemoCantDeleteThisPrivateNote = You cannot delete this memo
QuickMemoCantArchiveThisPrivateNote = You cannot archive this memo
QuickMemoCantMoveThisPrivateNote = You cannot move this memo
QuickMemoCantChangeThisPrivateNote = You cannot edit this memo
MemoLinkedTo = Memo linked to
ContextTab = Context
ContextTab_card = Card
SharedBetweenElement = Shared memo
Archived = Archived
QuickMemoElementType = Element type
QuickMemoElementType_facture = Invoice
ArchivedBy = Archived by
DateArchived = Archive date
UnarchiveMemo = Retrieve memo
NoTemplatesFound = No templates available
QuickMemoCreateAModelFromThisMemo = Create template from this memo
QuickMemoAskCreateAModelFromThisMemo = Create a template from this memo?
QuickMemoAskLabelModelMemoIsCommon = Template shared for all element types
QuickMemoAskLabelModelMemoIsPrivate = Private template for my use only
PrivateTemplate = Private template
QuickMemoModelName = Template name
QuickMemoModelNamePlaceHolder = Ex: Todo list
QuickMemoConfirmDeleteModel = Are you sure you want to delete this memo template?
DialogAskConfirm = Confirmation
QuickMemoDeleteModel = Delete template
QuickMemoUnArchiveError = An error occurred while retrieving the memo
QuickMemoUnArchiveCount = %s memos retrieved
QuickMemoUnArchived = Recovered memo
QuickMemoMd_HelpIntro = Markdown is a simple system for formatting your notes without using the mouse. Simply add a few symbols around your text:
QuickMemoMd_SectionStyle = Formatting
QuickMemoMd_SectionTitles = Titles and Structure
QuickMemoMd_SectionTasks = Task lists
QuickMemoMd_SectionLinks = Internet links
QuickMemoMd_HelpFooter = Symbols are automatically transformed into visual styles as soon as you exit note editing.
QuickMemoMd_SectionUniversal = A universal standard
QuickMemoMd_UniversalDesc = It's a universal, non-proprietary format. It's the standard used for Wikipedia documentation, on GitLab, Mattermost and by the majority of Open Source projects worldwide, including Dolibarr.
QuickMemoDropDownTitle = Add a memo
QuickMemoHelp_Title = Master your memos with these expert shortcuts and tips
QuickMemoHelp_Visibility = Instant visibility
QuickMemoHelp_EscKey = Hold down the <strong>Esc</strong> key to temporarily hide all memos and read the content below.
QuickMemoHelp_Management = Model management
QuickMemoHelp_DeleteHover = To delete a model: hover your mouse over it to reveal the delete icon.
QuickMemoHelp_ShiftKeyDelete = <strong>Quick tip:</strong> Hold down the <strong>Shift</strong> key while deleting to skip the confirmation (ideal for quick cleanup).
QuickMemoHelp_Organization = Organization
QuickMemoHelp_DragDrop = Templates can be reordered. Click and drag to organize your list according to your priorities.
QuickMemoHelp_Footer = These functionalities respect ergonomic standards to offer you a fluid and productive interface.
ShowMemo = Show memo
NotEnoughRights = Not enough rights
Memo = Memo
Memos = Memos
UpdateError = Update error
QuickMemoCantDeleteThisPrivateModel = Can't delete this private model
PleaseSelectAtLeastOneRow = Please select at least one row

View file

@ -0,0 +1,95 @@
# Translation file
ModuleQuickMemoName = Mémo rapide
ModuleQuickMemoDesc = Permettre l'ajout de notes rapides sur les documents
QuickMemoSetup = Configuration du QuickMemo
QuickMemoSetupPage = Page de configuration de QuickMemo
QuickMemoAbout = A propos de QuickMemo
QuickMemoAboutPage = Page d'accueil de QuickMemo
QuickMemoArea = Accueil QuickMemo
MyPageName = Nom de ma page
QuickMemoCreated = Créée
QuickMemoModified = Modifié
QuickMemoBy = par
QuickMemoEnterNote = Saisissez votre mémo
QuickMemoEnterNoteMdCompabible = Compatible Markdown
QuickMemoMd_Bold = Gras
QuickMemoMd_Italic = Italique
QuickMemoMd_Title = Titre
QuickMemoMd_TaskNotDone = Tâche à faire
QuickMemoMd_TaskDone = Tâche terminée
QuickMemoMd_List = Liste
QuickMemoMd_Link = Lien
QuickMemoMd_LinkText = Texte du lien
QuickMemoMd_HelpIntro = Le Markdown est un système simple pour mettre en forme vos notes sans utiliser la souris. Il suffit d'ajouter quelques symboles autour de votre texte :
QuickMemoMd_SectionStyle = Mise en forme
QuickMemoMd_SectionTitles = Titres et Structure
QuickMemoMd_SectionTasks = Listes de tâches
QuickMemoMd_SectionLinks = Liens internet
QuickMemoMd_HelpFooter = Les symboles se transforment automatiquement en style visuel dès que vous quittez l'édition de la note.
QuickMemoMd_SectionUniversal = Un standard universel
QuickMemoMd_UniversalDesc = C'est un format universel non-propriétaire. C'est le standard utilisé pour la documentation de Wikipédia, sur GitLab, Mattermost et par la majorité des projets Open Source à travers le monde dont Dolibarr.
QuickMemoTemplateName = Nom du modèle
QuickMemoDropDownTitle = Ajouter un mémo
QuickMemoActionArchive = Archiver le mémo
QuickMemoActionDelete = Supprimer le mémo
QuickMemoActionDeleteEmpty = Supprimer le mémo vide
QuickMemoActionShareMode = Mode partage
QuickMemoActionShareModeNotActive = Le mode partage est désactivé
QuickMemoActionShareModeActive = Le mode partage est actif
QuickMemoActionChangeColor = Changer de couleur
QuickMemoHelp_Title = Maîtrisez vos mémos grâce à ces raccourcis et astuces d'expert
QuickMemoHelp_Visibility = Visibilité instantanée
QuickMemoHelp_EscKey = Maintenez la touche <strong>Échap</strong> pour masquer temporairement tous les mémos et lire le contenu situé en dessous.
QuickMemoHelp_Management = Gestion des modèles
QuickMemoHelp_DeleteHover = Pour supprimer un modèle : survolez-le quelques instants avec votre souris pour révéler l'icône de suppression.
QuickMemoHelp_ShiftKeyDelete = <strong>Astuce rapidité :</strong> Maintenez la touche <strong>MAJ</strong> lors de la suppression pour ignorer la confirmation (idéal pour le nettoyage rapide).
QuickMemoHelp_Organization = Organisation
QuickMemoHelp_DragDrop = Les modèles sont réordonnables. Cliquez et faites-les glisser pour organiser votre liste selon vos priorités.
QuickMemoHelp_Footer = Ces fonctionnalités respectent les standards d'ergonomie pour vous offrir une interface fluide et productive.
QuickMemoActionPrivateMode = Mode d'affichage public ou privé
QuickMemoActionPrivateModeActive = Mode d'affichage en cours : Privé
QuickMemoActionPrivateModeNotActive = Mode d'affichage en cours : Public
QuickMemoSavePositionError = Une erreur c'est produite lors de l'enregistrement de la position du mémo
QuickMemoSaveError = Une erreur c'est produite lors de l'enregistrement du mémo
QuickMemoLoadModelError = Une erreur c'est produite lors du chargement des models de mémos
QuickMemoCreateError = Une erreur c'est produite lors de la création du mémo
QuickMemoLoadMemosError = Une erreur c'est produite lors du chargement des mémos
QuickMemoArchiveError = Une erreur c'est produite lors de l'archivage du mémo
QuickMemoUnArchiveError = Une erreur c'est produite lors de la récupération du mémo
QuickMemoUnArchiveCount = %s mémos récupérés
QuickMemoUnArchived = Mémo récupéré
QuickMemoArchived = Archivé
QuickMemoAdd = Ajouter le mémo
QuickMemoSavedTemplate = Modèles enregistrés
QuickMemoColorsPresets = Couleurs prédéfinies
QuickMemoShowArchives = Consulter les archives
QuickMemoCantDeleteThisPrivateNote = Vous ne pouvez pas supprimer ce mémo
QuickMemoCantArchiveThisPrivateNote = Vous ne pouvez pas archiver ce mémo
QuickMemoCantMoveThisPrivateNote = Vous ne pouvez pas déplacer ce mémo
QuickMemoCantChangeThisPrivateNote = Vous ne pouvez pas modifier ce mémo
MemoLinkedTo = Memo lié à
ContextTab = Context
ContextTab_card = Fiche
SharedBetweenElement = Mémo partagé
Archived = Archivé
QuickMemoElementType = Type d'éléments
QuickMemoElementType_facture = Facture
ArchivedBy = Archivé par
DateArchived = Date archivage
UnarchiveMemo = Récupérer le mémo
NoTemplatesFound = Aucun modèle disponible
QuickMemoCreateAModelFromThisMemo = Créer modèle depuis ce mémo
QuickMemoAskCreateAModelFromThisMemo = Créer un modèle depuis cette mémo ?
QuickMemoAskLabelModelMemoIsCommon = Modèle commun à tous les types d'élément
QuickMemoAskLabelModelMemoIsPrivate = Modèle privé utilisable uniquement par moi
PrivateTemplate = Modèle privé
QuickMemoModelName = Nom du modèle
QuickMemoModelNamePlaceHolder = Ex: Todo list
QuickMemoConfirmDeleteModel = Souhaitez-vous vraiment supprimer ce modèle de mémo ?
DialogAskConfirm = Confirmation
QuickMemoDeleteModel = Supprimer le modèle
ShowMemo = Consulter le mémo
QUICKMEMO_COLORS_PRESET=Définissez ici vos couleurs de mémo personnalisées

View file

@ -0,0 +1,128 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file admin/memo_extrafields.php
* \ingroup quickmemo
* \brief Page to setup extra fields of memo
*/
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once '../lib/quickmemo.lib.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
// Load translation files required by the page
$langs->loadLangs(array('quickmemo', 'admin'));
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$type2label = ExtraFields::getListOfTypesLabels();
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'quickmemo_memo'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) {
accessforbidden();
}
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject = $langs->transnoentitiesnoconv("Memo");
$help_url = '';
$page_name = "QuickMemoSetup";
llxHeader('', $langs->trans("QuickMemoSetup"), $help_url, '', 0, 0, '', '', '', 'mod-quickmemo page-admin_extrafields');
$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
$head = quickmemoAdminPrepareHead();
print dol_get_fiche_head($head, 'memo_extrafields', $langs->trans($page_name), -1, 'quickmemo@quickmemo');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
print dol_get_fiche_end();
// Buttons
if ((float) DOL_VERSION < 17) { // On v17+, the "New Attribute" button is included into tpl. @phpstan-ignore-line
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print '<a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a>';
print "</div>";
}
}
/*
* Creation of an optional field
*/
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/*
* Edition of an optional field
*/
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();

View file

@ -0,0 +1,287 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 John BOTELLA
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file quickmemo/admin/setup.php
* \ingroup quickmemo
* \brief QuickMemo setup page.
*/
// Load Dolibarr environment
require '../../main.inc.php';
// Libraries
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
require_once __DIR__ . '/../lib/quickmemo.lib.php';
require_once __DIR__ . '/../class/memo.class.php';
//require_once "../class/myclass.class.php";
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
// Translations
$langs->loadLangs(array("admin", "quickmemo"));
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
/** @var HookManager $hookmanager */
$hookmanager->initHooks(array('quickmemosetup', 'globalsetup'));
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
$error = 0;
$setupnotempty = 0;
// Access control
if (!$user->admin) {
accessforbidden();
}
// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
$useFormSetup = 1;
if (!class_exists('FormSetup')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
}
$formSetup = new FormSetup($db);
$item = $formSetup->newItem('QUICKMEMO_COLORS_PRESET');
$item->fieldInputOverride = '
<div class="color-manager">
<div class="controls">
<input type="color" id="colorPicker" list="predefinedColors">
<datalist id="predefinedColors">
<option value="#fff8a6">
<option value="#ffd6d6">
<option value="#d6ffd9">
<option value="#d6e6ff">
<option value="#f3d6ff">
<option value="#ffffff">
<option value="#f5f5f5">
</datalist>
<button title="'.$langs->trans('Add').'" class="btn-low-emphasis --btn-icon" type="button" id="addColor"><span class="fa fa-plus"></span></button>
</div>
<div class="palette" id="palette"></div>
<div class="colors-container" id="colorsContainer"></div>
<input type="hidden" name="QUICKMEMO_COLORS_PRESET" id="colorsInput">
</div>';
$setupnotempty += count($formSetup->items);
/*
* Actions
*/
// For retrocompatibility Dolibarr < 15.0
if (versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) {
$formSetup->saveConfFromPost();
}
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (empty($action)) {
$action = 'edit';
}
/*
* View
*/
$form = new Form($db);
$help_url = '';
$title = "QuickMemoSetup";
llxHeader('', $langs->trans($title), $help_url, '', 0, 0, '', ['quickmemo/css/setup.css'], '', 'mod-quickmemo page-admin');
if ($action == 'edit') : ?>
<script nonce="<?php print getNonce(); ?>">
document.addEventListener('DOMContentLoaded', function () {
const PRELOADED_COLORS = <?php print json_encode(Memo::getColorPreset()); ?>;
const colorPicker = document.getElementById('colorPicker');
const addColorBtn = document.getElementById('addColor');
const colorsContainer = document.getElementById('colorsContainer');
const colorsInput = document.getElementById('colorsInput');
let colors = [];
let draggedElement = null;
const placeholder = document.createElement('div');
placeholder.className = 'color-placeholder';
function updateHiddenInput() {
colorsInput.value = colors.join(',');
}
function normalize(color) {
return color.toLowerCase();
}
function rebuildColorsFromDOM() {
colors = Array.from(colorsContainer.querySelectorAll('.color-badge'))
.map(el => el.dataset.color);
updateHiddenInput();
}
function addColor(color) {
color = normalize(color);
if (colors.includes(color)) return;
colors.push(color);
const badge = document.createElement('div');
badge.className = 'color-badge';
badge.style.backgroundColor = color;
badge.dataset.color = color;
badge.draggable = true;
const removeBtn = document.createElement('span');
removeBtn.textContent = '×';
removeBtn.addEventListener('click', function(e) {
e.stopPropagation();
badge.remove();
rebuildColorsFromDOM();
});
badge.addEventListener('dragstart', function () {
draggedElement = badge;
badge.classList.add('dragging');
placeholder.style.width = badge.offsetWidth + 'px';
placeholder.style.height = badge.offsetHeight + 'px';
setTimeout(() => {
badge.style.display = 'none';
});
});
badge.addEventListener('dragend', function () {
badge.classList.remove('dragging');
badge.style.display = '';
placeholder.remove();
draggedElement = null;
});
colorsContainer.addEventListener('dragover', function (e) {
e.preventDefault();
const afterElement = getDragAfterElement(colorsContainer, e.clientX);
if (afterElement == null) {
colorsContainer.appendChild(placeholder);
} else {
colorsContainer.insertBefore(placeholder, afterElement);
}
});
colorsContainer.addEventListener('drop', function (e) {
e.preventDefault();
if (!draggedElement) return;
colorsContainer.insertBefore(draggedElement, placeholder);
rebuildColorsFromDOM();
});
badge.appendChild(removeBtn);
colorsContainer.appendChild(badge);
updateHiddenInput();
}
function getDragAfterElement(container, x) {
const elements = [...container.querySelectorAll('.color-badge:not(.dragging)')];
return elements.reduce((closest, child) => {
const box = child.getBoundingClientRect();
const offset = x - box.left - box.width / 2;
if (offset < 0 && offset > closest.offset) {
return { offset: offset, element: child };
} else {
return closest;
}
}, { offset: Number.NEGATIVE_INFINITY }).element;
}
addColorBtn.addEventListener('click', function () {
addColor(colorPicker.value);
});
PRELOADED_COLORS.forEach(color => {
addColor(color);
});
});
</script>
<?php endif;
// Subheader
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
// Configuration header
$head = quickmemoAdminPrepareHead();
print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "quickmemo@quickmemo");
// Setup page goes here
echo '<span class="opacitymedium">'.$langs->trans("QuickMemoSetupPage").'</span><br><br>';
if (!empty($formSetup->items)) {
print $formSetup->generateOutput(true);
print '<br>';
}
if (empty($setupnotempty)) {
print '<br>'.$langs->trans("NothingToSetup");
}
// Page end
print dol_get_fiche_end();
llxFooter();
$db->close();

View file

@ -0,0 +1,138 @@
<?php
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2026 John BOTELLA
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file quickmemo/class/actions_quickmemo.class.php
* \ingroup quickmemo
* \brief Example hook overload.
*
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php';
require_once __DIR__ . '/memo.class.php';
/**
* Class ActionsQuickMemo
*/
class ActionsQuickMemo extends CommonHookActions
{
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string[] Errors
*/
public $errors = array();
/**
* @var mixed[] Hook results. Propagated to $hookmanager->resArray for later reuse
*/
public $results = array();
/**
* @var ?string String displayed by executeHook() immediately after return
*/
public $resprints;
/**
* @var int Priority of hook (50 is used if value is not defined)
*/
public $priority;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
}
/**
* Overload the llxFooter function : add or replace array of object linkable
*
* @param array<string,mixed> $parameters Hook metadata (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 Return integer < 0 on error, 0 on success, 1 to replace standard code
*/
public function llxFooter($parameters, &$object, &$action, $hookmanager)
{
$context = Memo::getMemoContext($parameters['context']??'');
if (empty($context)) { return 0; }
$jsConfVars = [
'context' => $context,
];
if (!empty($object) && is_object($object) && isset($object->element)) {
$jsConfVars = array_merge([
'archivesUrlParams' => '&search_fk_element='. (int) $object->id .'&search_element_type='.$object->element,
'elementId' => (int) $object->id,
'elementType' => $object->element
], $jsConfVars);
}
Memo::loadQuickMemoJsInterface($jsConfVars);
return 0;
}
/**
* Overload the addHtmlHeader function : add or replace array of object linkable
*
* @param array<string,mixed> $parameters Hook metadata (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 Return integer < 0 on error, 0 on success, 1 to replace standard code
*/
public function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
{
if (empty($object) || !is_object($object) || !isset($object->element)) {
return 0;
}
$jsConfVars = [
'archivesUrlParams' => '&search_fk_element='. (int) $object->id .'&search_element_type='.$object->element,
'elementId' => (int) $object->id,
'elementType' => $object->element,
'context' => Memo::getMemoContext($parameters['context']??''),
];
Memo::loadQuickMemoJsInterface($jsConfVars);
return 0;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,276 @@
dialog.quickmemo-modal {
--default-padding: 10px;
color: #121c2f;
border: none;
outline: none;
background: #fff;
padding: 20px;
border-radius: 8px;
max-width: 400px;
max-height: 90vh;
width: 90%;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
dialog.quickmemo-modal.dialog-lg {
max-width: 800px;
}
dialog.quickmemo-modal.dialog-xl {
max-width: 80%;
}
dialog.quickmemo-modal.dialog-full-screen {
width: 80vw;
max-width: 95vw;
height: 90vh;
max-height: 95vh;
}
.dialog-content{
display: flex;
flex-direction: column; /* Stack header, body, and footer vertically */
max-height: 90vh; /* Inherit the max-height constraint */
}
dialog.quickmemo-modal::backdrop {
background: rgba(0,0,0,0.5);
}
dialog.quickmemo-modal.--dialog-danger::backdrop {
background: rgba(30, 0, 0, 0.5);
backdrop-filter: blur(5px);
}
.quickmemo-modal-actions {
margin-top: 16px;
display: flex;
justify-content: flex-end;
gap: 8px;
}
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */
}
.quickmemo-modal-input-group{
margin-bottom: 10px;
}
.quickmemo-modal-text-input {
width: 100%;
}
.quickmemo-modal header{
flex-shrink: 0; /* Prevent header from being squashed */
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
padding: 0;
margin-bottom: 20px;
}
.quickmemo-modal-title{
padding: 0;
margin: 0;
font-size: 1rem;
font-weight: 600;
text-align: left;
word-break: break-word;
}
.header-actions {
display: flex;
gap: 5px;
transform: translateY( calc(-1 * var(--default-padding))) translateX(calc(var(--default-padding)));
flex-shrink: 0; /* Empêche le bouton de s'écraser */
}
/* Scrollable Body */
.dialog-body {
flex: 1 1 auto; /* Take up all remaining vertical space */
overflow-y: auto; /* Enable vertical scrolling only for this section */
line-height: 1.6;
/* Subtle inner shadows to indicate more content is available */
/* 1. Shadow that scrolls with the content (hides the fixed shadow) */
/* 2. Fixed shadow that stays at the top/bottom */
background:
linear-gradient(white 30%, rgba(255,255,255,0)),
linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,
radial-gradient(farthest-side at 50% 0, rgba(0,0,0,0.2), rgba(0,0,0,0)),
radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,0.2), rgba(0,0,0,0)) 0 100%;
background-repeat: no-repeat;
background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
background-attachment: local, local, scroll, scroll;
}
/* Custom scrollbar for a cleaner look */
.dialog-body::-webkit-scrollbar {
width: 6px;
}
.dialog-body::-webkit-scrollbar-thumb {
background-color: rgba(0,0,0,0.1);
border-radius: 10px;
}
.quickmemo-modal-confirm-text{
font-size: .875rem;
line-height: calc(1.25 / .875);
}
.dialog-btn {
display: inline-flex;
justify-content: center;
align-items: center;
height: 36px;
padding: 0 16px;
font-family: InterVariable, system-ui, sans-serif;
font-size: 14px;
font-weight: 600;
line-height: 20px;
border-radius: 6px;
border: 0;
box-shadow:
inset 0 0 0 1px transparent,
0 1px 2px rgba(0, 0, 0, 0.05);
cursor: pointer;
transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
/* CANCEL */
.dialog-btn.dialog-btn-secondary {
background: #ffffff;
color: #1f2433;
box-shadow:
inset 0 0 0 1px #d9dee6,
0 1px 2px rgba(0, 0, 0, 0.05);
}
.dialog-btn.dialog-btn-secondary:hover {
background: #f5f7fa;
}
/* PRIMARY */
.dialog-btn.dialog-btn-primary {
position: relative;
background: var(--colortextlink);
color: #fff;
}
.dialog-btn.dialog-btn-primary::after {
content: "";
position: absolute;
inset: 0;
background: rgba(0,0,0,0);
transition: background 0.15s;
}
.dialog-btn.dialog-btn-primary:hover::after {
background: rgba(0,0,0,0.1); /* léger assombrissement */
}
/* DANGER */
.dialog-btn.dialog-btn-destructive {
background: #dc2626;
color: #ffffff;
}
.dialog-btn.dialog-btn-destructive:hover {
background: #b91c1c;
}
@media (min-width: 40rem) {
dialog.quickmemo-modal {
max-width: 32rem;
}
}
@media (min-width: 40rem) {
dialog.quickmemo-modal {
width: 100%;
}
}
.dialog-content footer{
flex-shrink: 0; /* Keep footer size constant */
}
/* close btn */
/* The Close Button Design */
.dialog-close-icon {
/* Reset default button styles */
appearance: none;
background: transparent;
border: none;
padding: 0;
cursor: pointer;
/* Perfect Circle Shape */
width: 28px;
height: 28px;
border-radius: 50%; /* Makes it round */
/* Content Alignment (centering the ×) */
display: flex;
align-items: center;
justify-content: center;
/* Typography for the '×' character */
font-size: 20px;
line-height: 1;
font-family: Arial, sans-serif; /* Clean font for the multiplication sign */
color: #888; /* Subtle default color */
/* Smooth Transitions */
transition:
background-color 0.2s ease,
color 0.2s ease,
transform 0.1s ease;
/* Ensure it doesn't shrink in flex headers */
flex-shrink: 0;
}
/* --- Interactive States --- */
/* Hover State */
.dialog-close-icon:hover {
background-color: rgba(0, 174, 255, 0.08);
color: #3599dc;
}
/* Active State (Clicking) */
.dialog-close-icon:active {
transform: scale(0.92);
background-color: rgba(0, 0, 255, 0.15);
}
/* Focus State (Accessibility - when tabbing) */
.dialog-close-icon:focus-visible {
outline: 2px solid #3599dc;
outline-offset: 1px;
}

View file

@ -0,0 +1,601 @@
#quickmemo-create-dropdown {
position: relative;
}
.dropdown-quickmemo-create{
min-width: 250px;
}
/* fix Dolibarr < 22 */
.login_block .dropdown-menu.dropdown-quickmemo-create {
right: 0;
transform: translateX(30px);
}
@media (max-width: 1118px) {
.login_block .dropdown-menu.dropdown-quickmemo-create {
right: auto;
transform: translateX(0);
}
}
/* end fix Dolibarr < 22 */
#quickmemo-create-dropdown .dropdown-menu{
--colortextbackhmenu : #333;
/*color: var(--colortextbackhmenu) !important;*/
animation: dropdown-quickmemo-slide-up 0.3s ease-in-out;
}
@keyframes dropdown-quickmemo-slide-up {
0% {
transform: translate(0, 5px) translateX(30px);
opacity: 0;
}
100% {
transform: translate(0, 0%) translateX(30px);
opacity: 1;
}
}
.dropdown-quickmemo-create .dropdown-header{
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 10px 10px 10px 15px;
}
.dropdown-header-title{
padding: 0;
margin: 0;
font-size: 14px;
line-height: 1.2;
font-weight: 600;
text-align: left;
word-break: break-word;
}
.dropdown-header-actions {
display: flex;
align-items: center;
gap: 5px;
flex-shrink: 0;
}
.quickmemo-archive-list,.quickmemo-tpl-title{
margin: 20px 0 5px 0;
}
#quickmemo-create-dropdown a.top-menu-dropdown-quicknote-link{
color: var(--colortextlink);;
}
.quickmemo-tpl-title{
color: #333;
padding: 5px 0;
}
.quickmemo-tpl-title:first-child{
margin-top: 0px;
padding-top: 0;
}
.quickmemo-tpl-list {
color: #3d3d3d;
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.no-models {
opacity: 0.5;
text-align: center;
width: 100%;
}
.quickmemo-model-btn, .quickmemo-model-placeholder{
--color-block-size : 36px;
width: var(--color-block-size);
height: var(--color-block-size);
border-radius: 6px;
position: relative;
border: 1px solid #ccc;
cursor: pointer;
}
.quickmemo-model-placeholder{
border-style: dashed;
cursor: default;
}
.quickmemo-model-btn:hover:before {
content: "\f067";
-webkit-font-smoothing: antialiased;
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
line-height: var(--color-block-size, 36px);
font-weight: 900;
font-family: "Font Awesome 5 Free";
opacity: 0.5;
color: white;
mix-blend-mode: difference;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.quickmemo-model-delete {
display: none;
position: absolute;
top: 0px;
right: 0px;
width: 16px;
height: 16px;
align-items: center;
justify-content: center;
font-size: 14px;
background: rgba(0,0,0,0.4);
color: #fff;
border-radius: 50%;
cursor: pointer;
transform: translateX(50%) translateY(-50%);
}
.quickmemo-model-delete:before{
content: '\00d7'; /* code Unicode pour × */
}
.quickmemo-model-delete.--show {
display: flex;
}
#quickmemo-model-list:has(.quickmemo-model-btn.--dragging) .quickmemo-model-btn:hover:before,
#quickmemo-model-list:has(.quickmemo-model-btn.--dragging) .quickmemo-model-delete.--show {
display:none;
}
.quickmemo-model-placeholder {
border: 1px dashed #999;
margin: 0 0;
border-radius: 4px;
}
.quickmemo-note{
--memo-color: #fff8a6;
box-sizing: border-box;
position: relative;
filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.25));
padding: 6px;
border-radius: 2px;
background: var(--memo-color);
border: 2px dotted var(--memo-color);
position: absolute;
cursor: grab;
opacity: 1;
transition: opacity 0.3s ease;
}
.quickmemo-note[data-private="1"] {
background-image: url("../img/private.svg");
background-position: center;
background-repeat: no-repeat;
background-size: 50% 50% ;
background-blend-mode: exclusion;
}
.quickmemo-note[data-shared="1"] {
border: 2px dotted rgba(0, 0, 0, 0.2);
}
.quickmemo-note.--memo-is-dark[data-shared="1"] {
border: 2px dotted rgba(255, 255, 255, 0.8);
}
.quickmemo-note.--memo-is-dark, .info-box-quickmemo.--memo-is-dark {
color: #ffffff;
}
body.hide-quickmemo .quickmemo-note {
opacity: 0;
pointer-events: none;
}
.quickmemo-footer{
padding-top: 5px;
}
.quickmemo-header{
position: relative;
}
.quickmemo-actions{
position: absolute;
right: 0;
top: 0;
transform: translateY(-20%);
opacity: 0;
pointer-events: none;
border-radius: 10px 10px 0 0 ;
padding: 3px 5px;
background: var(--memo-color);
transition:
transform 0.25s ease, /* delay sur transform si nécessaire */
opacity 0.2s ease; /* delay sur fade in */
}
.quickmemo-note:hover .quickmemo-actions{
transform: translateY(-100%);
opacity: 1;
pointer-events: auto;
z-index: -1;
}
.quickmemo-note.--dragging * {
cursor: grabbing;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently */
}
input[type="color"].quickmemo-color-input {
padding: 0;
width: 20px;
height: 20px;
box-sizing: border-box;
margin: 0 5px;
}
.quickmemo-actions {
cursor: default;
}
.quickmemo-info {
font-size: 0.7em;
opacity: 70%;
cursor: grab;
min-height: 20px;
}
.quickmemo-info__user-create-name {
font-weight: bold;
}
.quickmemo-info__date_create, .quickmemo-info__date_update, .quickmemo-info__user-change-name {
}
.quickmemo-info__create{
display: block;
}
.quickmemo-meta{
text-align: right;
}
.quickmemo-note {
display: flex;
flex-direction: column;
}
.quickmemo-note textarea, .quickmemo-markdown-preview {
flex: 1 1 auto; /* prend tout l'espace restant */
width: 100%;
height: 100%;
min-height: 0; /* important pour que flex calcule bien */
font-size: 1.1em;
padding: 5px;
margin: 0px;
line-height: 1.1em;
border: none !important;
outline: none !important;
box-sizing: border-box !important;
background: transparent;
background-color: transparent !important;
resize: none;
/* Subtle inner shadows to indicate more content is available */
/* 1. Shadow that scrolls with the content (hides the fixed shadow) */
/* 2. Fixed shadow that stays at the top/bottom */
background:
linear-gradient(var(--memo-color) 30%, rgba(255,255,255,0)),
linear-gradient(rgba(255,255,255,0), var(--memo-color) 70%) 0 100%,
radial-gradient(farthest-side at 50% 0, rgba(0,0,0,0.1), rgba(0,0,0,0)),
radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,0.1), rgba(0,0,0,0)) 0 100%;
background-repeat: no-repeat;
background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
background-attachment: local, local, scroll, scroll;
}
/* Custom scrollbar for a cleaner look */
:is(.quickmemo-note textarea, .quickmemo-markdown-preview )::-webkit-scrollbar {
width: 6px;
}
:is(.quickmemo-note textarea, .quickmemo-markdown-preview )::-webkit-scrollbar-thumb {
background-color: rgba(0,0,0,0.2);
border-radius: 10px;
}
.quickmemo-note.--memo-is-dark :is(.quickmemo-note textarea, .quickmemo-markdown-preview )::-webkit-scrollbar-thumb {
background-color: rgba(255,255,255,0.7);
}
.quickmemo-note.--edit-mode textarea {
display: block;
}
.quickmemo-note.--edit-mode .quickmemo-markdown-preview {
display: none;
}
.markdown-line:has(.markdown-checkbox:checked) {
text-decoration: line-through;
}
/*.quickmemo-note textarea:not(:focus) {
display: none;
}*/
.quickmemo-note textarea {
resize: none;
display: none;
}
.quickmemo-note textarea:read-only {
cursor: grab;
}
.quickmemo-note.--memo-is-dark textarea{
color: #ffffff;
}
.quickmemo-note textarea::placeholder,.quickmemo-placeholder {
color: rgba(0, 0, 0, 0.5); /* gris clair, ajustable */
opacity: 1; /* certains navigateurs rendent le placeholder plus transparent par défaut */
}
.quickmemo-note.--memo-is-dark textarea::placeholder,.quickmemo-note.--memo-is-dark .quickmemo-placeholder{
color: rgba(255, 255, 255, 0.5); /* gris clair, ajustable */
}
.quickmemo-markdown-preview {
overflow: auto;
cursor: grab;
}
/* Base styles for post-it headings */
.quickmemo-markdown-preview :is(h1, h2, h3, h4, h5) {
margin: 0.5em 0 0.2em 0;
padding: 0;
font-weight: 700; /* Bold for hierarchy */
line-height: 1.2;
color: inherit;
}
.quickmemo-markdown-preview .markdown-line:first-child > :is(h1, h2, h3, h4, h5) {
margin-top: 0;
}
.quickmemo-markdown-preview .markdown-line:has(:is(h1, h2, h3, h4, h5)) + .markdown-line.empty-line {
display: none;
}
/* Scaled down for Post-it constraints */
.quickmemo-markdown-preview h1 {
font-size: 1.4em; /* Not too big, just enough to lead */
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
padding-bottom: 0.2em;
}
.quickmemo-markdown-preview h2 {
font-size: 1.25em;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
padding-bottom: 0.2em;
}
.quickmemo-markdown-preview h3 {
font-size: 1.15em;
}
.quickmemo-markdown-preview h4 {
font-size: 1.05em;
text-decoration: underline; /* Style hint to distinguish from H3 */
text-underline-offset: 2px;
}
.quickmemo-markdown-preview h5 {
font-size: 1em;
font-style: italic; /* Using style instead of size for the last level */
}
/* Dark mode adjustment */
.quickmemo-note.--memo-is-dark .quickmemo-markdown-preview h1 {
border-bottom-color: rgba(255, 255, 255, 0.2);
}
button.btn-low-emphasis.--btn-icon.quickmemo-btn-archive{
margin-left : 20px
}
.quickmemo-note.--memo-is-dark .btn-low-emphasis{
color: rgba(255, 255, 255, 0.7); /* gris clair, ajustable */
}
.quickmemo-note.--note-delete-animation {
animation: note-delete-animation 0.2s ease-in-out;
}
@keyframes note-delete-animation {
0% {
transform: scale(1) translateY(0);
opacity: 1;
}
100% {
transform: scale(0.8) translateY(50%);
opacity: 0;
}
}
/* *********** */
/* KANBAN VIEW */
/* *********** */
.info-box-quickmemo {
--memo-color: #fff8a6;
box-sizing: border-box;
position: relative;
filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.25));
padding: 8px;
border-radius: 4px 4px 0 0;
background: var(--memo-color);
position: relative;
}
.info-box-content-quicknote {
padding: 5px 0px;
max-height: 100px;
min-height: 64px;
overflow: auto;
}
.info-box-quickmemo .quickmemo-info {
cursor: default;
}
.quickmemo-markdown-preview__badge {
display: inline-block;
position: absolute;
font-weight: bold;
left:0;
top: 0;
padding: 3px 8px 2px 8px;
border-radius: 20px;
font-size: 10px;
line-height: 10px;
color: #666;
background-color: #ededed;
box-shadow: 1px 1px 1px rgba(0,0,0,.2);
transform: translateY(calc(-50% - 5px));
cursor: s-resize;
}
.quickmemo-markdown-preview__badge.success {
background-color: #00ac2d;
color: #ffffff;
}
.quickmemo-editor-toolbar {
display: flex;
position: absolute;
/* --- VERTICAL ALIGN CENTER --- */
top: 50%; /* On place le haut de la barre au milieu du mémo */
left: 4px;
flex-direction: column;
gap: 4px;
background: var(--memo-color);
padding: 4px;
border-right: 1px solid rgba(150,150,150,0.1);
border-radius: 6px;
z-index: 100;
pointer-events: none;
opacity: 0;
/* --- FOR 3D EFFECT --- */
transform-origin: right center;
/** * initial state :
* 1. translateX(-100%) : Sort la barre à gauche du mémo
* 2. translateY(-50%) : Remonte la barre de la moitié de sa propre hauteur pour le centrage
* 3. rotateY(-90deg) : L'effet de rotation "cachée"
*/
transform: translateX(-100%) translateY(-50%) rotateY(-90deg);
transition:
transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
opacity 0.2s ease;
}
/* Show only when parent has the edit mode class */
.quickmemo-note.--edit-mode .quickmemo-editor-toolbar {
/* On garde le X et le Y, on remet juste la rotation à 0 */
transform: translateX(-100%) translateY(-50%) rotateY(0deg);
opacity: 1;
pointer-events: auto;
}
.quickmemo-toolbar-btn {
--btn-size: 24px;
width: var(--btn-size);
height: var(--btn-size);
color: var(--colortextlink, inherit);
font-size: 12px;
border: none;
background: none;
cursor: pointer;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s;
}
.quickmemo-note.--memo-is-dark .quickmemo-toolbar-btn{
color: rgba(255, 255, 255, 0.7);
}
.quickmemo-toolbar-btn:hover {
background: rgba(255, 255, 255, 0.7);
color: #000;
}
.quickmemo-note.--memo-is-dark .quickmemo-toolbar-btn:hover {
color: var(--memo-color);
}
.quickmemo-toolbar-btn.--active {
background: #e2eafc;
color: #007bff;
border: 1px solid #007bff;
}
.quickmemo-note.--memo-is-dark .quickmemo-toolbar-btn.--active {
background: #e2eafc;
color: #007bff;
border: 1px solid #007bff;
}
.quickmemo-note .quickmemo-toolbar-separator {
height: 1px;
width: 50%;
border: none;
background-color: rgba(0, 0, 0, 0.7);
margin: 4px auto;
transform: scaleY(0.5);
transform-origin: center;
}
.quickmemo-note.--memo-is-dark .quickmemo-toolbar-separator {
background-color: rgba(255, 255, 255, 0.7);
}

View file

@ -0,0 +1,72 @@
.color-manager {
max-width: 500px;
}
.controls {
display: flex;
gap: 10px;
margin-bottom: 10px;
}
.palette {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-bottom: 15px;
}
.palette-color {
width: 28px;
height: 28px;
border-radius: 4px;
cursor: pointer;
border: 1px solid #ccc;
}
.colors-container {
box-sizing: border-box;
max-width: 100%;
min-width: 300px;
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.color-badge {
width: 36px;
height: 36px;
border-radius: 6px;
position: relative;
border: 1px solid #ccc;
cursor: grab;
}
.color-badge.dragging {
opacity: 0.4;
}
.color-placeholder {
box-sizing: border-box;
width: 36px;
height: 36px;
border-radius: 6px;
position: relative;
border: 1px dashed #999;
}
.color-badge span {
position: absolute;
top: -6px;
right: -6px;
background: #000;
color: #fff;
width: 16px;
height: 16px;
font-size: 12px;
line-height: 16px;
text-align: center;
border-radius: 50%;
cursor: pointer;
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="800" viewBox="0 0 20 20" xmlns:v="https://vecta.io/nano"><path d="M17.3 3.3c-.4-.4-1.1-.4-1.6 0l-2.4 2.4c-1.1-.4-2.2-.6-3.3-.6-3.8.1-7.2 2.1-9 5.4.2.4.5.8.8 1.2.8 1.1 1.8 2 2.9 2.7L3 16.1c-.4.4-.5 1.1 0 1.6.4.4 1.1.5 1.6 0L17.3 4.9c.4-.5.4-1.2 0-1.6zm-10.6 9l-1.3 1.3c-1.2-.7-2.3-1.7-3.1-2.9C3.5 9 5.1 7.8 7 7.2c-1.3 1.4-1.4 3.6-.3 5.1zM10.1 9c-.5-.5-.4-1.3.1-1.8.5-.4 1.2-.4 1.7 0L10.1 9zm8.2.5c-.5-.7-1.1-1.4-1.8-1.9l-1 1c.8.6 1.5 1.3 2.1 2.2C15.9 13.4 13 15 9.9 15h-.8l-1 1c.7-.1 1.3 0 1.9 0 3.3 0 6.4-1.6 8.3-4.3.3-.4.5-.8.8-1.2-.3-.3-.5-.7-.8-1zM14 10l-4 4c2.2 0 4-1.8 4-4z" fill="gray" fill-opacity=".15"/></svg>

After

Width:  |  Height:  |  Size: 679 B

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,83 @@
<?php
/* Copyright (C) 2026 John BOTELLA
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file quickmemo/lib/quickmemo.lib.php
* \ingroup quickmemo
* \brief Library files with common functions for QuickMemo
*/
/**
* Prepare admin pages header
*
* @return array<array{string,string,string}>
*/
function quickmemoAdminPrepareHead()
{
global $langs, $conf;
// global $db;
// $extrafields = new ExtraFields($db);
// $extrafields->fetch_name_optionals_label('myobject');
$langs->load("quickmemo@quickmemo");
$h = 0;
$head = array();
$head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/admin/setup.php", 1));
$head[$h][1] = $langs->trans("Settings");
$head[$h][2] = 'settings';
$h++;
// $head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/admin/memo_extrafields.php", 1));
// $head[$h][1] = $langs->trans("ExtraFields");
// $nbExtrafields = (isset($extrafields->attributes['memo']['label']) && is_countable($extrafields->attributes['memo']['label'])) ? count($extrafields->attributes['memo']['label']) : 0;
// if ($nbExtrafields > 0) {
// $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
// }
// $head[$h][2] = 'memo_extrafields';
// $h++;
/*
$head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/admin/myobjectline_extrafields.php", 1));
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$nbExtrafields = (isset($extrafields->attributes['myobjectline']['label']) && is_countable($extrafields->attributes['myobjectline']['label'])) ? count($extrafields->attributes['myobject']['label']) : 0;
if ($nbExtrafields > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
}
$head[$h][2] = 'myobject_extrafieldsline';
$h++;
*/
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
// 'entity:+tabname:Title:@quickmemo:/quickmemo/mypage.php?id=__ID__'
//); // to add new tab
//$this->tabs = array(
// 'entity:-tabname:Title:@quickmemo:/quickmemo/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'quickmemo@quickmemo');
complete_head_from_modules($conf, $langs, null, $head, $h, 'quickmemo@quickmemo', 'remove');
return $head;
}

View file

@ -0,0 +1,111 @@
<?php
/* Copyright (C) 2026 John BOTELLA
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file lib/quickmemo_memo.lib.php
* \ingroup quickmemo
* \brief Library files with common functions for Memo
*/
/**
* Prepare array of tabs for Memo
*
* @param Memo $object Memo
* @return array<array{string,string,string}> Array of tabs
*/
function memoPrepareHead($object)
{
global $db, $langs, $conf;
$langs->load("quickmemo@quickmemo");
$showtabofpagecontact = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_CONTACT');
$showtabofpagenote = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_NOTE');
$showtabofpagedocument = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_DOCUMENT');
$showtabofpageagenda = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_AGENDA');
$h = 0;
$head = array();
$head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_card.php", 1), ['id' => $object->id]);
$head[$h][1] = $langs->trans("Memo");
$head[$h][2] = 'card';
$h++;
if ($showtabofpagecontact) {
$head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_contact.php", 1), ['id' => $object->id]);
$head[$h][1] = $langs->trans("Contacts");
$head[$h][2] = 'contact';
$h++;
}
if ($showtabofpagenote) {
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dolBuildUrl(dol_buildpath('/quickmemo/memo_note.php', 1), ['id' => $object->id]);
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) {
$head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
}
$head[$h][2] = 'note';
$h++;
}
}
if ($showtabofpagedocument) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->quickmemo->dir_output."/memo/".dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_document.php", 1), ['id' => $object->id]);
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
}
$head[$h][2] = 'document';
$h++;
}
if ($showtabofpageagenda) {
$head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_agenda.php", 1), ['id' => $object->id]);
$head[$h][1] = $langs->trans("Events");
$head[$h][2] = 'agenda';
$h++;
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
// 'entity:+tabname:Title:@quickmemo:/quickmemo/mypage.php?id=__ID__'
//); // to add new tab
//$this->tabs = array(
// 'entity:-tabname:Title:@quickmemo:/quickmemo/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'memo@quickmemo');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'memo@quickmemo', 'remove');
return $head;
}

View file

@ -0,0 +1,992 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 John BOTELLA
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file memo_list.php
* \ingroup quickmemo
* \brief List page for memo
*/
// General defined Options
//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
// Load Dolibarr environment
require '../main.inc.php';
/**
* The main.inc.php has been included so the following variable are now defined:
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// load module libraries
include_once __DIR__.'/class/memo.class.php';
// for other modules
//dol_include_once('/othermodule/class/otherobject.class.php');
// Load translation files required by the page
$langs->loadLangs(array("quickmemo", "other"));
// Get parameters
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : getDolDefaultContextPage(__FILE__); // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
$id = GETPOSTINT('id');
$ref = GETPOST('ref', 'alpha');
// Load variable for pagination
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
// If $page is not defined, or '' or -1 or if we click on clear filters
$page = 0;
}
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
// Initialize technical objects
$object = new Memo($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->quickmemo->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
//$extrafields->fetch_name_optionals_label($object->table_element_line);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) {
reset($object->fields); // Reset is required to avoid key() to return null.
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Initialize array of search criteria
$search_all = trim(GETPOST('search_all', 'alphanohtml'));
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
}
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
// foreach ($object->fields as $key => $val) {
// if (!empty($val['searchall'])) {
// $fieldstosearchall['t.'.$key] = $val['label'];
// }
// }
// $parameters = array('fieldstosearchall'=>$fieldstosearchall);
// $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// if ($reshook > 0) {
// $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
// } elseif ($reshook == 0) {
// $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
// }
// Definition of array of fields for columns from ->fields
$tableprefix = 't';
$arrayfields = array();
foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = (int) dol_eval((string) $val['visible'], 1);
$arrayfields[$tableprefix.'.'.$key] = array(
'label' => $val['label'],
'checked' => (($visible < 0) ? '0' : '1'),
'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
'position' => $val['position'],
'help' => isset($val['help']) ? $val['help'] : ''
);
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
// Complete arrayfields with special fields
/*$arrayfields = array_merge($arrayfields, array(
'anotherfield' => array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>'1', 'enabled'=>'1', 'position'=>'90', 'csslist'=>'right'),
));*/
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
// There is several ways to check permission.
$permissiontoread = $user->hasRight('quickmemo', 'memo', 'read');
$permissiontoadd = $user->hasRight('quickmemo', 'memo', 'write');
$permissiontodelete = $user->hasRight('quickmemo', 'memo', 'delete');
// Security check (enable the most restrictive one)
if ($user->socid > 0) {
accessforbidden();
}
//if ($user->socid > 0) accessforbidden();
//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->module, 0, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
if (!isModEnabled("quickmemo")) {
accessforbidden('Module quickmemo not enabled');
}
if (!$permissiontoread) {
accessforbidden();
}
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) {
$action = 'list';
$massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array('arrayfields' => &$arrayfields);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
foreach ($object->fields as $key => $val) {
$search[$key] = '';
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = '';
$search[$key.'_dtend'] = '';
}
}
$search_all = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// Mass actions
$objectclass = 'Memo';
$objectlabel = 'Memo';
$uploaddir = $conf->quickmemo->dir_output;
global $error;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// You can add more action here
// if ($action == 'xxx' && $permissiontoxxx) ...
if ($massaction === 'unarchive') {
if (!empty($toselect)) {
$countUnarchived = 0;
foreach ($toselect as $idMemo) {
// TODO Récupérer le mémo attention à ne pas récupérer un model ils ne peuvent pas étre rcupr c'est des models
$selectdModel = new Memo($db);
if ($selectdModel->fetch($idMemo) <= 0) {
$idMemo = (int) $idMemo; // sanitize
setEventMessage($langs->trans('QuickMemoLoadMemosError').' : '. (int) $idMemo, 'errors');
continue;
}
if ($selectdModel->status !== Memo::STATUS_ARCHIVED) {
setEventMessage($langs->trans('QuickMemoCantChangeThisPrivateNote').' : '. (int) $idMemo, 'errors');
continue;
}
if ($user->id != $selectdModel->fk_user_creat && $selectdModel->private_tpl) {
setEventMessage($langs->trans('QuickMemoCantChangeThisPrivateNote').' : '. (int) $idMemo, 'errors');
continue;
}
if ($selectdModel->setUnArchived($user) <= 0) {
setEventMessage($langs->trans('QuickMemoUnArchiveError').' : '. (int) $idMemo, 'errors');
continue;
}
$countUnarchived++;
}
if ($countUnarchived>0) {
setEventMessage($langs->trans($countUnarchived > 1 ? 'QuickMemoUnArchiveCount' : 'QuickMemoUnArchived', $countUnarchived));
}
} else {
setEventMessage($langs->trans('PleaseSelectAtLeastOneRow'), 'warnings');
}
}
}
/*
* View
*/
$form = new Form($db);
$now = dol_now();
$title = $langs->trans("Memos");
//$help_url = "EN:Module_Memo|FR:Module_Memo_FR|ES:Módulo_Memo";
$help_url = '';
$morejs = array();
$morecss = array(
'quickmemo/css/memo.css'
);
// Build and execute select
// --------------------------------------------------------------------
$sql = "SELECT";
$sql .= " ".$object->getFieldList('t');
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : "");
}
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
$sql .= " FROM ".$db->prefix().$object->table_element." as t";
//$sql .= " LEFT JOIN ".$db->prefix()."anothertable as rc ON rc.parent = t.rowid";
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".$db->prefix().$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
if (!empty($object->ismultientitymanaged) && (int) $object->ismultientitymanaged == 1) {
$sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
} elseif (preg_match('/^\w+@\w+$/', (string) $object->ismultientitymanaged)) {
$tmparray = explode('@', (string) $object->ismultientitymanaged);
$sql .= " LEFT JOIN ".$object->db->prefix().$tmparray[1]." as pt ON t.".$db->sanitize($tmparray[0])." = pt.rowid";
$sql .= " WHERE pt.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
} else {
$sql .= " WHERE 1 = 1";
}
$sql .= ' AND ('.implode(' OR ', [
'( t.status = '.Memo::STATUS_ARCHIVED.' AND t.private = 0 OR t.fk_user_creat = '.(int) $user->id.' )',
'( t.status = '.Memo::STATUS_VALIDATED.' AND t.private = 0 OR t.fk_user_creat = '.(int) $user->id.' )',
'( t.status = '.Memo::STATUS_TPL.' AND t.private_tpl = 0 OR t.fk_user_creat = '.(int) $user->id.' )',
]).') ';
foreach ($search as $key => $val) {
if (array_key_exists($key, $object->fields)) {
if ($key == 'status' && $search[$key] == -1) {
continue;
}
if (empty($object->fields[$key])) {
continue;
}
$field_spec = $object->fields[$key];
$mode_search = (($object->isInt($field_spec) || $object->isFloat($field_spec)) ? 1 : 0);
if ((strpos($field_spec['type'], 'integer:') === 0) || (strpos($field_spec['type'], 'sellist:') === 0) || !empty($field_spec['arrayofkeyval'])) {
if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($field_spec['arrayofkeyval']) || !array_key_exists('0', $field_spec['arrayofkeyval'])))) {
$search[$key] = '';
}
$mode_search = 2;
}
if ($field_spec['type'] === 'boolean') {
$mode_search = 1;
if ($search[$key] == '-1') {
$search[$key] = '';
}
}
if (empty($field_spec['searchmulti'])) {
if (!is_array($search[$key]) && $search[$key] != '') {
$sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
}
} else {
if (is_array($search[$key]) && !empty($search[$key])) {
$sql .= natural_search("t.".$db->escape($key), implode(',', $search[$key]), (($key == 'status') ? 2 : $mode_search));
}
}
} else {
if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
$columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
if (preg_match('/_dtstart$/', $key)) {
$sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'";
}
if (preg_match('/_dtend$/', $key)) {
$sql .= " AND t.".$db->sanitize($columnName)." <= '".$db->idate($search[$key])."'";
}
}
}
}
}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
/*
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
}
// Search on sale representative
if ($search_sale && $search_sale != '-1') {
if ($search_sale == -2) {
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
} elseif ($search_sale > 0) {
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
}
}
// Search on socid
if ($socid) {
$sql .= " AND t.fk_soc = ".((int) $socid);
}
*/
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
/* If a group by is required
$sql .= " GROUP BY ";
foreach($object->fields as $key => $val) {
$sql .= "t.".$db->sanitize($key).", ";
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
}
}
// Add groupby from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$sql .= $hookmanager->resPrint;
} else {
$sql = $hookmanager->resPrint;
}
$sql = preg_replace('/,\s*$/', '', $sql);
*/
// Add HAVING from hooks
/*
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
} else {
$sql = $hookmanager->resPrint;
}
*/
// Count total nb of records
$nbtotalofrecords = '';
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
/* The fast and low memory method to get and count full list converts the sql into a sql count */
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
$resql = $db->query($sqlforcount);
if ($resql) {
$objforcount = $db->fetch_object($resql);
$nbtotalofrecords = $objforcount->nbtotalofrecords;
} else {
dol_print_error($db);
}
if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
$db->free($resql);
}
// Complete request and execute it with limit
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/quickmemo/memo_card.php', 1).'?id='.((int) $id));
exit;
}
// Output page
// --------------------------------------------------------------------
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-quickmemo page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for a horizontal scroll in the table instead of page
// Example : Adding jquery code
// print '<script type="text/javascript">
// jQuery(document).ready(function() {
// function init_myfunc()
// {
// jQuery("#myid").removeAttr(\'disabled\');
// jQuery("#myid").attr(\'disabled\',\'disabled\');
// }
// init_myfunc();
// jQuery("#mybutton").click(function() {
// init_myfunc();
// });
// });
// </script>';
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($mode)) {
$param .= '&mode='.urlencode($mode);
}
if (!empty($contextpage) && $contextpage != getDolDefaultContextPage(__FILE__)) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.((int) $limit);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($groupby != '') {
$param .= '&groupby='.urlencode($groupby);
}
foreach ($search as $key => $val) {
if (is_array($search[$key])) {
foreach ($search[$key] as $skey) {
if ($skey != '') {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
}
} elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
$param .= '&search_'.$key.'month='.GETPOSTINT('search_'.$key.'month');
$param .= '&search_'.$key.'day='.GETPOSTINT('search_'.$key.'day');
$param .= '&search_'.$key.'year='.GETPOSTINT('search_'.$key.'year');
} elseif ($search[$key] != '') {
$param .= '&search_'.$key.'='.urlencode((string) $search[$key]);
}
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
$parameters = array('param' => &$param);
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
// List of mass actions available
$arrayofmassactions = array(
'unarchive'=> $langs->trans("UnarchiveMemo"),
//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
);
if (!empty($permissiontodelete)) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="page_y" value="">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
$newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
//$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanbanGroupBy'), '', 'fa fa-grip-vertical imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanbangroupby&groupby=p.fk_opp_status'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'kanbangroupby' ? 2 : 1), array('morecss' => 'reposition'));
//$newcardbutton .= dolGetButtonTitle($langs->trans('HierarchicView'), '', 'fa fa-stream paddingleft imgforviewmode', $_SERVER["PHP_SELF"].'?mode=hierarchy'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', (($mode == 'hierarchy') ? 2 : 1), array('morecss' => 'reposition'));
//$newcardbutton .= dolGetButtonTitleSeparator();
//$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/quickmemo/memo_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
// Add code for pre mass action (confirmation or email presend form)
$topicmail = "SendMemoRef";
$modelmail = "memo";
$objecttmp = new Memo($db);
$trackid = 'xxxx'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all) {
$setupstring = '';
// @phan-suppress-next-line PhanEmptyForeach
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
$setupstring .= $key."=".$val.";";
}
print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
}
$moreforfilter = '';
/*$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';*/
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
$parameters = array(
'arrayfields' => &$arrayfields,
);
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">';
// Action column
if ($conf->main_checkbox_left_column) {
print '<td class="liste_titre center maxwidthsearch">';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print '</td>';
}
foreach ($object->fields as $key => $val) {
//$searchkey = empty($search[$key]) ? '' : $search[$key];
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
if (empty($val['searchmulti'])) {
print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
} else {
print $form->multiselectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), 0, 0, 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
}
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
} elseif ($key == 'lang') {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($db);
print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
} elseif ($val['type'] === 'boolean') {
print $form->selectyesno('search_' . $key, $search[$key] ?? '', 1, false, 1);
} else {
print '<input type="text" class="flat maxwidth'.(in_array($val['type'], array('integer', 'price')) ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
print '</td>';
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters = array('arrayfields' => $arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
/*if (!empty($arrayfields['anotherfield']['checked'])) {
print '<td class="liste_titre"></td>';
}*/
// Action column
if (!$conf->main_checkbox_left_column) {
print '<td class="liste_titre center maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
}
print '</tr>'."\n";
$totalarray = array();
$totalarray['nbfield'] = 0;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
// Action column
if ($conf->main_checkbox_left_column) {
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
$totalarray['nbfield']++;
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
$cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
$totalarray['nbfield']++;
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
/*if (!empty($arrayfields['anotherfield']['checked'])) {
print '<th class="liste_titre">'.$langs->trans("AnotherField").'</th>';
$totalarray['nbfield']++;
}*/
// Action column
if (!$conf->main_checkbox_left_column) {
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
$totalarray['nbfield']++;
}
print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (!is_null($val) && preg_match('/\$object/', $val)) {
$needToFetchEachLine++; // There is at least one compute field that use $object
}
}
}
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$savnbfield = $totalarray['nbfield'];
$totalarray = array();
$totalarray['nbfield'] = 0;
$imaxinloop = ($limit ? min($num, $limit) : $num);
while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object
$object->setVarsFromFetchObj($obj);
/*
$object->thirdparty = null;
if ($obj->fk_soc > 0) {
if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
$companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
} else {
$companyobj = new Societe($db);
$companyobj->fetch($obj->fk_soc);
$conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
}
$object->thirdparty = $companyobj;
}*/
if ($mode == 'kanban' || $mode == 'kanbangroupby') {
if ($i == 0) {
print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
print '<div class="box-flex-container kanban">';
}
// Output Kanban
$selected = -1;
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
}
//print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
print $object->getKanbanView('', array('selected' => $selected));
if ($i == ($imaxinloop - 1)) {
print '</div>';
print '</td></tr>';
}
} else {
// Show line of result
$j = 0;
print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
// Action column
if ($conf->main_checkbox_left_column) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Fields
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
} elseif ($key == 'ref') {
$cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key) && !in_array($key, array('ref'))) {
print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
}
print '>';
if ($key == 'status') {
print $object->getLibStatut(5);
} elseif ($key == 'rowid') {
print $object->showOutputField($val, $key, (string) $object->id, '');
} else {
if ($val['type'] == 'html') {
print '<div class="small lineheightsmall twolinesmax-normallineheight">';
}
print $object->showOutputField($val, $key, (string) $object->$key, '');
if ($val['type'] == 'html') {
print '</div>';
}
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
if (!isset($totalarray['val'])) {
$totalarray['val'] = array();
}
if (!isset($totalarray['val']['t.'.$key])) {
$totalarray['val']['t.'.$key] = 0;
}
$totalarray['val']['t.'.$key] += $object->$key;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
/*if (!empty($arrayfields['anotherfield']['checked'])) {
print '<td class="right">'.$obj->anotherfield.'</td>';
}*/
// Action column
if (empty($conf->main_checkbox_left_column)) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
print '</tr>'."\n";
}
$i++;
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
$db->free($resql);
$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir = $diroutputmassaction;
$genallowed = $permissiontoread;
$delallowed = $permissiontoadd;
print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}
// End of page
llxFooter();
$db->close();

View file

@ -486,6 +486,7 @@ abstract class CommonClassTest extends TestCase
'productsupplierprice' => null,
'project' => 'Projet',
'propal' => 'Propale',
'quickmemo' => 'QuickMemo',
'receiptprinter' => 'ReceiptPrinter',
'reception' => 'Reception',
'recruitment' => 'Recruitment',