From ddf98055a33f4852f42e4c24529ccf8053f924a9 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Sat, 19 Jun 2021 13:45:20 +0200 Subject: [PATCH 001/752] Update README.md List missing features for the REST API --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index b7cbe471426..fdfbbb5a4a2 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,17 @@ These are features that Dolibarr does **not** yet fully support: - Payroll module - No native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc. - Dolibarr can't do coffee (yet) +- The REST API currently cannot: + - Update a supplier order + - Get tickets + - Add new ledger entry + - Output extrafields when getting orders + - Get virtual products (aka lots) + - Add special taxcodes to a line on a supplier invoice + - Get or post shipments + - Do updating or inserting of extrafields on any objects + - Add an image to a product + - Add multiprices to products ## DOCUMENTATION From f56c26a2142444022628c5fa9931b3eeb47e3670 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Fri, 2 Jul 2021 13:00:29 +0200 Subject: [PATCH 002/752] Update README.md Removed a few and added issue links to the rest --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fdfbbb5a4a2..0d0e2d89d00 100644 --- a/README.md +++ b/README.md @@ -221,16 +221,13 @@ These are features that Dolibarr does **not** yet fully support: - No native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc. - Dolibarr can't do coffee (yet) - The REST API currently cannot: - - Update a supplier order - - Get tickets - - Add new ledger entry - - Output extrafields when getting orders - - Get virtual products (aka lots) - - Add special taxcodes to a line on a supplier invoice - - Get or post shipments - - Do updating or inserting of extrafields on any objects - - Add an image to a product - - Add multiprices to products + - Add new ledger entry [#14675](https://github.com/Dolibarr/dolibarr/issues/14675) + - Get virtual products (aka lots) [#14457](https://github.com/Dolibarr/dolibarr/issues/14457) + - Add special taxcodes to a line on a supplier invoice (vat_src_code) [#14404](https://github.com/Dolibarr/dolibarr/issues/14404) + - Get or post shipments on customer orders [#18074](https://github.com/Dolibarr/dolibarr/issues/18074) + - Get or post shipments on supplier orders [#14334](https://github.com/Dolibarr/dolibarr/issues/14334) + - Add an image to a product [#14262](https://github.com/Dolibarr/dolibarr/issues/14262) + - Add multiprices to products [#12812](https://github.com/Dolibarr/dolibarr/issues/12812) ## DOCUMENTATION From 63a47112ae3280e9f921f1e7ad1395cb0f7266f5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 16 Jul 2021 11:14:30 +0200 Subject: [PATCH 003/752] new: #18162 --- htdocs/core/modules/modProjet.class.php | 6 ++++++ htdocs/langs/en_US/admin.lang | 5 +++-- htdocs/langs/fr_FR/admin.lang | 3 ++- htdocs/projet/tasks/time.php | 12 ++++++------ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 25448f239e6..7502fbffa81 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -202,6 +202,12 @@ class modProjet extends DolibarrModules $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'supprimer'; + $r++; + $this->rights[$r][0] = 145; // id de la permission + $this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // libelle de la permission + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'time'; // Menus //------- diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a05c9e7ea97..13dbef8bff3 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -707,7 +707,8 @@ Permission34=Delete products Permission36=See/manage hidden products Permission38=Export products Permission39=Ignore minimum price -Permission41=Read projects and tasks (shared project and projects I'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) +Permission41=Read projects and tasks (shared project and projects I'm contact for). +Permission145=Can enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) Permission42=Create/modify projects (shared project and projects I'm contact for). Can also create tasks and assign users to project and tasks Permission44=Delete projects (shared project and projects I'm contact for) Permission45=Export projects @@ -2145,4 +2146,4 @@ RandomlySelectedIfSeveral=Randomly selected if several pictures are available DatabasePasswordObfuscated=Database password is obfuscated in conf file DatabasePasswordNotObfuscated=Database password is NOT obfuscated in conf file APIsAreNotEnabled=APIs modules are not enabled -YouShouldSetThisToOff=You should set this to 0 or off \ No newline at end of file +YouShouldSetThisToOff=You should set this to 0 or off diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 57a50388a4f..0d0dadf3327 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -707,7 +707,8 @@ Permission34=Supprimer les produits Permission36=Voir/gérer les produits cachés Permission38=Exporter les produits Permission39=Ignorer le prix minimum -Permission41=Lire les projets et tâches (partagés ou dont vous n'êtes pas contact). Permet la saisie de temps passé, pour vous-même et votre hiérarchie (vos subordonnés), sur les tâches assignées (Feuilles de temps). +Permission41=Lire les projets et tâches (partagés ou dont vous n'êtes pas contact). +Permission145=Permet la saisie de temps passé, pour vous-même et votre hiérarchie (vos subordonnés), sur les tâches assignées (Feuilles de temps). Permission42=Créer/modifier les projets (projets partagés et projets pour lesquels je suis contact). Permet aussi de créer des tâches et d'assigner des utilisateurs aux projets et tâches. Permission44=Supprimer les projets et tâches (partagés ou dont je suis contact) Permission45=Exporter les projets diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index a9316bcedcd..4cac12ad801 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -149,7 +149,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $action = ''; } -if ($action == 'addtimespent' && $user->rights->projet->lire) { +if ($action == 'addtimespent' && $user->rights->projet->time) { $error = 0; $timespent_durationhour = GETPOST('timespent_durationhour', 'int'); @@ -281,7 +281,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } } -if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->lire) { +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) { $object->fetchTimeSpent(GETPOST('lineid', 'int')); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) $result = $object->delTimeSpent($user); @@ -722,7 +722,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { $linktocreatetimeBtnStatus = 0; $linktocreatetimeUrl = ''; $linktocreatetimeHelpText = ''; - if ($user->rights->projet->all->lire || $user->rights->projet->lire) { // To enter time, read permission is enough + if ($user->rights->projet->all->lire || $user->rights->projet->time) { if ($projectstatic->public || $userRead > 0) { $linktocreatetimeBtnStatus = 1; @@ -940,7 +940,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { print ''; } elseif ($action == 'splitline') { print ''; - } elseif ($action == 'createtime' && $user->rights->projet->lire) { + } elseif ($action == 'createtime' && $user->rights->projet->time) { print ''; } elseif ($massaction == 'generateinvoice' && $user->rights->facture->lire) { print ''; @@ -1122,7 +1122,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { /* * Form to add a new line of time spent */ - if ($action == 'createtime' && $user->rights->projet->lire) { + if ($action == 'createtime' && $user->rights->projet->time) { print ''."\n"; if (!empty($id)) { print ''; @@ -1537,7 +1537,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { print ''; print '
'; print ''; - } elseif ($user->rights->projet->lire || $user->rights->projet->all->creer) { // Read project and enter time consumed on assigned tasks + } elseif ($user->rights->projet->time || $user->rights->projet->all->creer) { // Read project and enter time consumed on assigned tasks if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) { if ($conf->MAIN_FEATURES_LEVEL >= 2) { print ' '; From aae79a1d0e33849dac8b76e9bfa582211b58e638 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 13 Oct 2021 14:56:10 +0200 Subject: [PATCH 004/752] WIP import select --- htdocs/imports/import.php | 119 +++++++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 27 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 2ab7e3976aa..fc4a6330b71 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -142,6 +142,8 @@ $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); +$import_wip = 0; + $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); @@ -321,15 +323,30 @@ if ($action == 'saveorder') { $serialized_array_match_file_to_database = ''; $array_match_file_to_database = array(); $fieldsarray = explode(',', $list); - $pos = 0; + if (empty($import_wip)) { + $pos = 0; + } foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield - $posbis = 0; $namefield = ''; + if (empty($import_wip)) { + $posbis = 0; + } else { + $pos = 1; + } + + $namefield = ''; foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); - if ($posbis < $pos) { - $posbis++; - continue; + if (empty($import_wip)) { + if ($posbis < $pos) { + $posbis++; + continue; + } + } else { + if ($pos < $fieldnb) { + $pos++; + continue; + } } // We found the key of targets that is at position pos $namefield = $key; @@ -1000,9 +1017,9 @@ if ($step == 4 && $datatoimport) { // List of source fields $var = true; $lefti = 1; - foreach ($array_match_file_to_database as $key => $val) { + foreach ($import_wip?$fieldssource:$array_match_file_to_database as $key => $val) { $var = !$var; - show_elem($fieldssource, $key, $val, $var); // key is field number in source file + show_elem($fieldssource, $key, $val, $var, '', $import_wip); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; $listofkeys[$key] = 1; $fieldsplaced[$key] = 1; @@ -1021,7 +1038,7 @@ if ($step == 4 && $datatoimport) { while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file + show_elem($fieldssource, $newkey, '', $var, '', $import_wip); // key start after field number in source file //print '> '.$lefti.'-'.$newkey; $listofkeys[$key] = 1; $lefti++; @@ -1035,11 +1052,20 @@ if ($step == 4 && $datatoimport) { print ''; // List of target fields - $height = '24px'; //needs px for css height attribute below + if (empty($import_wip)) { + $height = '24px'; //needs px for css height attribute below + } else { + $height = '29px'; + } $i = 0; $mandatoryfieldshavesource = true; - + if (!empty($import_wip)) { + $fieldselect = 1; + } print ''; + if (!empty($import_wip)) { + $pos = 1; + } foreach ($fieldstarget as $code => $label) { print ''; @@ -1054,18 +1080,45 @@ if ($step == 4 && $datatoimport) { print ''; print ''; // Info field print ''; print ''; + if (!empty($import_wip)) { + $fieldselect++; + } } print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; - $newlabel = preg_replace('/\*$/', '', $label); - $text = $langs->trans($newlabel); - $more = ''; - if (preg_match('/\*$/', $label)) { - $text = ''.$text.''; - $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); - if ($mandatoryfieldshavesource) { - $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + if (empty($import_wip)) { + $newlabel = preg_replace('/\*$/', '', $label); + $text = $langs->trans($newlabel); + $more = ''; + if (preg_match('/\*$/', $label)) { + $text = ''.$text.''; + $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); + if ($mandatoryfieldshavesource) { + $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + } + //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; } - //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; + print $text; + } else { + print ''; } - print $text; print ''; @@ -1127,6 +1180,9 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1145,7 +1201,7 @@ if ($step == 4 && $datatoimport) { if (empty($fieldsplaced[$key])) { // $nbofnotimportedfields++; - show_elem($fieldssource, $key, '', $var, 'nostyle'); + show_elem($fieldssource, $key, '', $var, 'nostyle', $import_wip); //print '> '.$lefti.'-'.$key; $listofkeys[$key] = 1; $lefti++; @@ -1154,7 +1210,7 @@ if ($step == 4 && $datatoimport) { // Print one more empty field $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 'nostyle'); + show_elem($fieldssource, $newkey, '', $var, 'nostyle', $import_wip); //print '> '.$lefti.'-'.$newkey; $listofkeys[$newkey] = 1; $nbofnotimportedfields++; @@ -1167,7 +1223,7 @@ if ($step == 4 && $datatoimport) { $i = 0; while ($i < $nbofnotimportedfields) { // Print empty cells - show_elem('', '', 'none', $var, 'nostyle'); + show_elem('', '', 'none', $var, 'nostyle', $import_wip); $i++; } print ''; @@ -2089,13 +2145,18 @@ $db->close(); * @param string $key Key * @param boolean $var Line style (odd or not) * @param int $nostyle Hide style + * @param int $import_wip WIP * @return void */ -function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') +function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = 1) { global $langs, $bc; - $height = '24px'; + if (empty($import_wip)) { + $height = '24px'; + } else { + $height = '29px'; + } if ($key == 'none') { //stop multiple duplicate ids with no number @@ -2112,7 +2173,9 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') if ($pos && $pos > count($fieldssource)) { // No fields print ''; print ''; - print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + if (empty($import_wip)) { + print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + } print ''; print ''; print $langs->trans("NoFields"); @@ -2132,7 +2195,9 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') print ''; print ''; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + if (empty($import_wip)) { + print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + } print ''; print ''; print $langs->trans("Field").' '.$pos; From 5dfb496bad53827355ac28c4db39b00140f2c96e Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 23 Oct 2021 17:16:19 +0200 Subject: [PATCH 005/752] update import.php to start import to line 2 --- htdocs/imports/import.php | 16 +++++++++++++++- htdocs/langs/en_US/exports.lang | 1 + htdocs/langs/fr_FR/exports.lang | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index fc4a6330b71..d24f9057987 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -136,7 +136,7 @@ $step = (GETPOST('step') ? GETPOST('step') : 1); $import_name = GETPOST('import_name'); $hexa = GETPOST('hexa'); $importmodelid = GETPOST('importmodelid'); -$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 1); +$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 2); $endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') : array()); $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); @@ -1524,6 +1524,20 @@ if ($step == 5 && $datatoimport) { if ($action == 'launchsimu') { print '   '.$langs->trans("Modify").''; } + if ($excludefirstline == 2) { + print $form->textwithpicto("", $langs->trans("WarningFirstImportedLine", $excludefirstline), 1, 'warning', "warningexcludefirstline"); + print ''; + } print ''; // Keys for data UPDATE (not INSERT of new data) diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index f2f2d2cf587..a20741472b7 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -135,3 +135,4 @@ NbInsert=Number of inserted lines: %s NbUpdate=Number of updated lines: %s MultipleRecordFoundWithTheseFilters=Multiple records have been found with these filters: %s StocksWithBatch=Stocks and location (warehouse) of products with batch/serial number +WarningFirstImportedLine=The first line(s) will not be imported with the current selection diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 5bed116241b..63f155cf9cd 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -135,3 +135,4 @@ NbInsert=Nombre de lignes insérées: %s NbUpdate=Nombre de lignes mises à jour: %s MultipleRecordFoundWithTheseFilters=Plusieurs enregistrements ont été trouvés avec ces filtres: %s StocksWithBatch=Stocks et entrepôts des produits avec numéro de lot/série +WarningFirstImportedLine=Les première(s) ligne(s) ne seront pas importée(s) avec cette selection From bd125910ab19be9b133cd015d0059a0e79c7fbb4 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 12 Nov 2021 11:18:30 +0100 Subject: [PATCH 006/752] NEW stripe element with more gateways --- htdocs/public/payment/newpayment.php | 57 +++++++++------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index a5e24312ded..62d817ab227 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -3,7 +3,7 @@ * Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2018 Juanjo Menent - * Copyright (C) 2018-2019 Thibault FOUCART + * Copyright (C) 2018-2021 Thibault FOUCART * Copyright (C) 2021 Waël Almoman * Copyright (C) 2021 Dorian Vabre * @@ -2234,7 +2234,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) //{ print ' - +
\n"; From ffa88b803ffd4636b626b6631d1a79b9122597cb Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 16:03:41 +0100 Subject: [PATCH 018/752] FIX: project timesheet by week: cleanup unused code --- htdocs/projet/activity/perweek.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 267106c5721..2e1926c8847 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -98,7 +98,6 @@ $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); -$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { @@ -522,14 +521,6 @@ for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); - - // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow - //$tmparray = dol_getdate($dayinloop); - //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - //print dol_print_date($dayinloop, 'dayhour').' '; - //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; - //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; $statusofholidaytocheck = Holiday::STATUS_APPROVED; @@ -539,7 +530,6 @@ for ($idw = 0; $idw < 7; $idw++) $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code); if ($test) $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } -//var_dump($isavailable); @@ -659,7 +649,6 @@ print ''; @@ -1143,7 +1143,7 @@ if ($step == 4 && $datatoimport) { } // Source required $htmltext .= $langs->trans("SourceRequired").': '.yn(preg_match('/\*$/', $label)).'
'; - $example = $objimport->array_import_examplevalues[0][$code]; + $example = !empty($objimport->array_import_examplevalues[0][$code])?$objimport->array_import_examplevalues[0][$code]:""; // Example if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion if ($example) { From 8e11b1c996764e1feb46f798a26c6bb1c59725d1 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 23 Dec 2021 11:25:57 +0100 Subject: [PATCH 058/752] import with select boxes --- htdocs/imports/import.php | 259 ++++++++++++++++---------------- htdocs/langs/en_US/exports.lang | 3 +- htdocs/langs/fr_FR/exports.lang | 3 +- 3 files changed, 136 insertions(+), 129 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 566c0c725f9..6913309d620 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -142,7 +142,6 @@ $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); -$import_wip = 0; $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); @@ -161,7 +160,7 @@ foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem, 2); $key = $tabelem[0]; $val = (isset($tabelem[1]) ? $tabelem[1] : ''); - if ($key && $val) { + if ($key && $val && ($key > 0 && $step != 4)) { $array_match_file_to_database[$key] = $val; } } @@ -323,31 +322,19 @@ if ($action == 'saveorder') { $serialized_array_match_file_to_database = ''; $array_match_file_to_database = array(); $fieldsarray = explode(',', $list); - if (empty($import_wip)) { - $pos = 0; - } + $pos = 0; foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield - if (empty($import_wip)) { - $posbis = 0; - } else { - $pos = 1; - } + $posbis = 0; $namefield = ''; foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); - if (empty($import_wip)) { - if ($posbis < $pos) { - $posbis++; - continue; - } - } else { - if ($pos < $fieldnb) { - $pos++; - continue; - } + if ($posbis < $pos) { + $posbis++; + continue; } + // We found the key of targets that is at position pos $namefield = $key; //dol_syslog('AjaxImport Field name found for file field nb '.$fieldnb.'='.$namefield); @@ -1018,9 +1005,9 @@ if ($step == 4 && $datatoimport) { // List of source fields $var = true; $lefti = 1; - foreach ($import_wip?$fieldssource:$array_match_file_to_database as $key => $val) { + foreach ($array_match_file_to_database as $key => $val) { $var = !$var; - show_elem($fieldssource, $key, $val, $var, '', $import_wip); // key is field number in source file + show_elem($fieldssource, $key, $val, $var, 1, '', $listofkeys); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; $listofkeys[$key] = 1; $fieldsplaced[$key] = 1; @@ -1039,7 +1026,7 @@ if ($step == 4 && $datatoimport) { while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, '', $import_wip); // key start after field number in source file + show_elem($fieldssource, $newkey, '', $var, 1, '', $listofkeys); // key start after field number in source file //print '> '.$lefti.'-'.$newkey; $listofkeys[$key] = 1; $lefti++; @@ -1053,20 +1040,14 @@ if ($step == 4 && $datatoimport) { print ''; @@ -1235,35 +1187,51 @@ if ($step == 4 && $datatoimport) { if ($conf->use_javascript_ajax) { print ''."\n"; @@ -2162,23 +2130,21 @@ $db->close(); /** * Function to put the movable box of a source field * - * @param array $fieldssource List of source fields - * @param int $pos Pos - * @param string $key Key - * @param boolean $var Line style (odd or not) - * @param int $nostyle Hide style - * @param int $import_wip WIP + * @param array $fieldssource List of source fields + * @param int $pos Pos + * @param string $key Key + * @param boolean $var Line style (odd or not) + * @param boolean $isimportedfield Verify if it's an imported field + * @param int $nostyle Hide style + * @param array $listofkeys List of keys for select boxes * @return void */ -function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = 1) +function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = '', &$listofkeys = array()) { global $langs, $bc; - if (empty($import_wip)) { - $height = '24px'; - } else { - $height = '29px'; - } + // $height = '24px'; + $height = '30px'; if ($key == 'none') { //stop multiple duplicate ids with no number @@ -2195,9 +2161,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = if ($pos && $pos > count($fieldssource)) { // No fields print ''; print ''; print ''; print ''; + } elseif (empty($isimportedfield)) { + $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; + if ($example) { + if (!utf8_check($example)) { + $example = utf8_encode($example); + } + print ''; + print ''; + print ''; + print ''; + } } else { // Print field of source file print ''; print ''; - print ''; print ''; print ''; } diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index a20741472b7..8bbc6f1ad98 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -8,7 +8,7 @@ ImportableDatas=Importable dataset SelectExportDataSet=Choose dataset you want to export... SelectImportDataSet=Choose dataset you want to import... SelectExportFields=Choose the fields you want to export, or select a predefined export profile -SelectImportFields=Choose the source file fields you want to import and their target field in database by moving them up and down with anchor %s, or select a predefined import profile: +SelectImportFields=Choose the source file fields you want to import and their target field in database by choosing the fields with the select box, or select a predefined import profile: NotImportedFields=Fields of source file not imported SaveExportModel=Save your selections as an export profile/template (for reuse). SaveImportModel=Save this import profile (for reuse) ... @@ -136,3 +136,4 @@ NbUpdate=Number of updated lines: %s MultipleRecordFoundWithTheseFilters=Multiple records have been found with these filters: %s StocksWithBatch=Stocks and location (warehouse) of products with batch/serial number WarningFirstImportedLine=The first line(s) will not be imported with the current selection +EmptyField=Empty field \ No newline at end of file diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index d97ed21f0e2..4f4490ef4a5 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -8,7 +8,7 @@ ImportableDatas=Lot de données importables SelectExportDataSet=Choisissez un lot prédéfini de données que vous désirez exporter… SelectImportDataSet=Choisissez un lot prédéfini de données que vous désirez importer… SelectExportFields=Choisissez les champs à exporter, ou choisissez un profil d'export prédéfini -SelectImportFields=Choisissez les champs du fichier source à importer et leur destination dans la base en les déplaçant vers le haut ou vers le bas via l'ancre %s, ou choisissez un profil d'import prédéfini: +SelectImportFields=Choisissez les champs du fichier source à importer et leur destination dans la base en utilisant les boîtes de sélection, ou choisissez un profil d'import prédéfini: NotImportedFields=Champs du fichier source non importés SaveExportModel=Enregistrer ce profil d'export (si vous désirez le réutiliser ultérieurement) … SaveImportModel=Enregistrer ce profil d'import (si vous désirez le réutiliser ultérieurement) … @@ -136,3 +136,4 @@ NbUpdate=Nombre de lignes mises à jour: %s MultipleRecordFoundWithTheseFilters=Plusieurs enregistrements ont été trouvés avec ces filtres: %s StocksWithBatch=Stocks et entrepôts des produits avec numéro de lot/série WarningFirstImportedLine=Les première(s) ligne(s) ne seront pas importée(s) avec cette selection +EmptyField=Champ vide From 9e247859726aa7adacaa95e2acc5847f7e7d73bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Tue, 28 Dec 2021 11:23:46 +0100 Subject: [PATCH 059/752] add getDolGlobalInt --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 99529e8b46f..d99d8311ea2 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -125,7 +125,7 @@ if ($action == 'getProducts') { if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; $sql .= ' ON (p.rowid = ps.fk_product'; - $sql .= " AND ps.fk_entrepot = ".((int) $db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']})) . ')'; + $sql .= " AND ps.fk_entrepot = ".((int) getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])); } $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { From 706ee8ce6236e3de47a3b148a0bed57706ae170b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 28 Dec 2021 16:26:21 +0100 Subject: [PATCH 060/752] Fix #19662 : mysql8 user creation in 2 steps --- htdocs/core/db/mysqli.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 3a8aabd3bf9..c733792b6b6 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -939,7 +939,7 @@ class DoliDBMysqli extends DoliDB public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable - $sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'"; + $sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'"; dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log $resql = $this->query($sql); if (!$resql) { @@ -952,14 +952,14 @@ class DoliDBMysqli extends DoliDB } // Redo with localhost forced (sometimes user is created on %) - $sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'localhost'"; + $sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'localhost' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'"; $resql = $this->query($sql); - $sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'"; + $sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."'"; dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log $resql = $this->query($sql); if (!$resql) { - $this->error = "Connected user not allowed to GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '*****'"; + $this->error = "Connected user not allowed to GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."'"; return -1; } From 2729bd32e666bff46ccdb00a80f54c2afff49006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Thu, 30 Dec 2021 16:14:06 +0100 Subject: [PATCH 061/752] Single quotes --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index d99d8311ea2..3d2979c21f8 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -125,7 +125,7 @@ if ($action == 'getProducts') { if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; $sql .= ' ON (p.rowid = ps.fk_product'; - $sql .= " AND ps.fk_entrepot = ".((int) getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])); + $sql .= ' AND ps.fk_entrepot = '.((int) getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])); } $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { From a85f542668a785aa0a60ffb7c2fc7a97f7703820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Fri, 31 Dec 2021 09:29:56 +0100 Subject: [PATCH 062/752] double quotes --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 3d2979c21f8..ab4c9af2904 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -125,7 +125,7 @@ if ($action == 'getProducts') { if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; $sql .= ' ON (p.rowid = ps.fk_product'; - $sql .= ' AND ps.fk_entrepot = '.((int) getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])); + $sql .= " AND ps.fk_entrepot = ".((int) getDolGlobalInt("CASHDESK_ID_WAREHOUSE".$_SESSION['takeposterminal'])); } $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { From 04cc0a0480459c19837abb4e0f8f88d01689301f Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 10 Jan 2022 17:02:15 +0100 Subject: [PATCH 063/752] NEW : Add column "Total HT" to products array on document creation card --- htdocs/core/class/commonobject.class.php | 2 ++ htdocs/core/tpl/originproductline.tpl.php | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a01e2d7c209..e89990b7b5e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4441,6 +4441,7 @@ abstract class CommonObject print ''; } print ''; + print ''; print ''; print ''; $i = 0; @@ -4593,6 +4594,7 @@ abstract class CommonObject if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; $this->tpl['price'] = price($line->subprice); + $this->tpl['total_ht'] = price($line->total_ht); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; if ($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 1b996556253..cc520039af5 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -40,6 +40,7 @@ if ($conf->global->PRODUCT_USE_UNITS) print ''; print ''; +print ''; $selected = 1; if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected = 0; From 19104236845f5ede2a35fc0d0955837b163808e6 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 11 Jan 2022 09:54:27 +0100 Subject: [PATCH 064/752] FIX : conf name is MAIN_ADD_LINE_AT_POSITION --- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 19aa36e09bc..2c8f87291c4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2088,7 +2088,7 @@ class Facture extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_ADD_LINE_AT_POSITION)) { $facligne->rang = 1; $linecount = count($this->lines); for ($ii = 1; $ii <= $linecount; $ii++) { diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b0c33e934fc..887ed5c0b7e 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -311,7 +311,7 @@ if ($nolinesbefore) { echo ''; } - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_ADD_LINE_AT_POSITION)) { echo '
'.$langs->trans('AddLineOnPosition').' : '; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 04c49d1065e..cc2de5b9df9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1143,7 +1143,7 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_ADD_LINE_AT_POSITION)) { $facligne->rang = 1; $linecount = count($this->lines); for ($ii = 1; $ii <= $linecount; $ii++) { From 400f6b244b5ef91b2752a4e158eec0a7da1b6c0c Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 11 Jan 2022 17:29:02 +0100 Subject: [PATCH 065/752] FIX user actions rights when mulit-company transverse mode is enabled --- htdocs/user/card.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 28fcda3871d..79a55f1604e 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1905,7 +1905,7 @@ else } } - if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1917,7 +1917,7 @@ else } } elseif ($caneditpassword && !$object->ldap_sid && - (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print ''; } @@ -1930,7 +1930,7 @@ else print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print ''; } @@ -1940,7 +1940,7 @@ else print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if ($object->email) print ''; else print ''; @@ -1949,13 +1949,13 @@ else // Enable user if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print ''; } // Disable user if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print ''; } @@ -1968,7 +1968,7 @@ else } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if ($user->admin || !$object->admin) // If user edited is admin, delete is possible on for an admin { From 99fb08240376c647b11bbd708bcb4457377ee9d7 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Mon, 24 Jan 2022 14:50:54 +0100 Subject: [PATCH 066/752] prevent access denied page --- htdocs/core/lib/security.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 3ea554a4a8f..b26c723a014 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -615,6 +615,9 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta if ($feature == 'task') { $feature = 'projet_task'; } + if ($feature == 'banque') { + $feature = 'fk_account@bank_account'; + } $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object From 97850a6fbf56ef92402cc5f5ed9ece80081bc623 Mon Sep 17 00:00:00 2001 From: habot-it Date: Sat, 5 Feb 2022 12:22:18 +0000 Subject: [PATCH 067/752] Add options in function pdf_pagefoot of pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 47 +++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 75443366037..c79cbbca645 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1130,6 +1130,11 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetFont('', '', 7); $pdf->SetDrawColor(224, 224, 224); + // Option for footer text color + if (!empty($conf->global->PDF_FOOTER_TEXT_COLOR)) { + list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_TEXT_COLOR, '%d, %d, %d'); + $pdf->SetTextColor($r, $g, $b); + } // The start of the bottom of this page footer is positioned according to # of lines $freetextheight = 0; @@ -1149,6 +1154,8 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } } + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak + // For customize footer if (is_object($hookmanager)) { $parameters = array('line1' => $line1, 'line2' => $line2, 'line3' => $line3, 'line4' => $line4, 'outputlangs'=>$outputlangs); @@ -1161,6 +1168,12 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $marginwithfooter = $marge_basse + $freetextheight + $mycustomfooterheight; $posy = $marginwithfooter + 0; + // Option for footer background color (without freetext zone) + if (!empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); + $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', '', $fill_color = array($r, $g, $b)); + } + if ($line) { // Free text $pdf->SetXY($dims['lm'], -$posy); if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default @@ -1172,10 +1185,18 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } $pdf->SetY(-$posy); - $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); - $posy--; - $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); + // Hide footer line if footer background color is set + if (empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); + } + + // Option for set top margin height of footer after freetext + if (!empty($conf->global->PDF_FOOTER_TOP_MARGIN) || ($conf->global->PDF_FOOTER_TOP_MARGIN === '0')) { + $posy -= $conf->global->PDF_FOOTER_TOP_MARGIN; + } else { $posy--; } + + $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); $posy -= $mycustomfooterheight - 3; } else { @@ -1183,6 +1204,12 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); $posy = $marginwithfooter + 0; + // Option for footer background color (without freetext zone) + if (!empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); + $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', '', $fill_color = array($r, $g, $b)); + } + if ($line) { // Free text $pdf->SetXY($dims['lm'], -$posy); if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default @@ -1194,8 +1221,16 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } $pdf->SetY(-$posy); - $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); - $posy--; + + // Hide footer line if footer background color is set + if (empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); + } + + // Option for set top margin height of footer after freetext + if (!empty($conf->global->PDF_FOOTER_TOP_MARGIN) || ($conf->global->PDF_FOOTER_TOP_MARGIN === '0')) { + $posy -= $conf->global->PDF_FOOTER_TOP_MARGIN; + } else { $posy--; } if (!empty($line1)) { $pdf->SetFont('', 'B', 7); @@ -1232,6 +1267,8 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); } + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + return $marginwithfooter; } From a15353fa333bd1bfa42a8a1657d2083a48aae89b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 Feb 2022 13:42:40 +0100 Subject: [PATCH 068/752] FIX Disable customer type by default if type prospect/customer is disabled --- htdocs/societe/admin/societe.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index c87289da390..55c42cd4c28 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -1,9 +1,10 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2011 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2022 Alexandre Spangaro * * 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 @@ -225,10 +226,12 @@ if ($action == "setaskforshippingmet") { } } -//Activate "Disable prospect/customer type" +// Activate "Disable prospect/customer type" if ($action == "setdisableprospectcustomer") { $setdisableprospectcustomer = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); + // Remove customer type by default if type prospect/customer is disabled + $res = dolibarr_del_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $conf->entity); if (!($res > 0)) { $error++; } From 5a86f998904f386cb7af9dbb987c8244f5dc825a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 13 Feb 2022 17:53:22 +0100 Subject: [PATCH 069/752] FIX Disable customer type by default if type prospect/customer is disabled --- htdocs/societe/admin/societe.php | 3 --- htdocs/societe/card.php | 41 +++++++++++++++++--------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 55c42cd4c28..ab6c6bd063d 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -4,7 +4,6 @@ * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2022 Alexandre Spangaro * * 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 @@ -230,8 +229,6 @@ if ($action == "setaskforshippingmet") { if ($action == "setdisableprospectcustomer") { $setdisableprospectcustomer = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); - // Remove customer type by default if type prospect/customer is disabled - $res = dolibarr_del_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $conf->entity); if (!($res > 0)) { $error++; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 668d8199b16..8c2c7e85e56 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2020 Juanjo Menent - * Copyright (C) 2011-2013 Alexandre Spangaro + * Copyright (C) 2011-2022 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud @@ -986,21 +986,24 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $modCodeFournisseur = new $module; // Define if customer/prospect or supplier status is set or not - if (GETPOST("type") != 'f') { + if (GETPOST("type", 'aZ') != 'f') { $object->client = -1; if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client = 3; } } // Prospect / Customer - if (GETPOST("type") == 'c') { + if (GETPOST("type", 'aZ') == 'c') { if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; } else { $object->client = 3; } } - if (GETPOST("type") == 'p') { + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { + $object->client = 1; + } + if (GETPOST("type", 'aZ') == 'p') { $object->client = 2; } if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { @@ -1757,21 +1760,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('name')) { // We overwrite with values if posted - $object->name = GETPOST('name', 'alphanohtml'); - $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); - $object->client = GETPOST('client', 'int'); - $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); - $object->address = GETPOST('address', 'alphanohtml'); - $object->zip = GETPOST('zipcode', 'alphanohtml'); - $object->town = GETPOST('town', 'alphanohtml'); - $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id; - $object->state_id = GETPOST('state_id', 'int'); - //$object->skype = GETPOST('skype', 'alpha'); - //$object->twitter = GETPOST('twitter', 'alpha'); - //$object->facebook = GETPOST('facebook', 'alpha'); - //$object->linkedin = GETPOST('linkedin', 'alpha'); + $object->name = GETPOST('name', 'alphanohtml'); + $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); + $object->client = GETPOST('client', 'int'); + $object->code_client = GETPOST('customer_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur', 'int'); + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->address = GETPOST('address', 'alphanohtml'); + $object->zip = GETPOST('zipcode', 'alphanohtml'); + $object->town = GETPOST('town', 'alphanohtml'); + $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id; + $object->state_id = GETPOST('state_id', 'int'); + //$object->skype = GETPOST('skype', 'alpha'); + //$object->twitter = GETPOST('twitter', 'alpha'); + //$object->facebook = GETPOST('facebook', 'alpha'); + //$object->linkedin = GETPOST('linkedin', 'alpha'); $object->socialnetworks = array(); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { From fd478ba3fa6814681cb648d4a28c4c0139daf567 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 16 Feb 2022 15:13:50 +0100 Subject: [PATCH 070/752] add param for md theme --- htdocs/core/lib/usergroups.lib.php | 2 -- htdocs/theme/md/style.css.php | 30 +++++++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 2792b6d9997..c963c74c8b6 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -507,7 +507,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // BorderTableActive - /* Disabled because not supported by md theme if ($foruserprofile) { } else { $default = $langs->trans('No'); @@ -525,7 +524,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print '
'; } - */ // Background color THEME_ELDY_BACKBODY if ($foruserprofile) { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index da706095e17..943060bb581 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -119,7 +119,7 @@ $dol_no_mouse_hover = $conf->dol_no_mouse_hover; $useboldtitle = (isset($conf->global->THEME_ELDY_USEBOLDTITLE) ? $conf->global->THEME_ELDY_USEBOLDTITLE : 0); $borderwidth = 2; -$userborderontable = 1; +$userborderontable = getDolGlobalInt('THEME_ELDY_USEBORDERONTABLE');; // Case of option always editable if (!isset($conf->global->THEME_ELDY_BACKBODY)) { @@ -3641,8 +3641,10 @@ div.colorback margin-top: 5px; } .liste_titre_bydiv { - border-right: 1px solid #ccc; - border-left: 1px solid #ccc; + + border-right: 1px solid var(--colortopbordertitle1); + border-left: 1px solid var(--colortopbordertitle1); + } table.liste, table.noborder, table.formdoc, div.noborder { width: calc(100% - 2px); /* -2 to fix a bug. Without, a scroll appears due to overflow-x: auto; of div-table-responsive */ @@ -3655,12 +3657,15 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-top-style: solid; border-bottom-width: 1px; - border-bottom-color: #BBB; + border-bottom-color: var(--colortopbordertitle1); border-bottom-style: solid; - border-right: 1px solid #ccc; - border-left: 1px solid #ccc; - + + border-right: 1px solid var(--colortopbordertitle1); + border-left: 1px solid var(--colortopbordertitle1); + + margin: 0px 0px 20px 0px; -webkit-border-radius: 0.1em; @@ -4039,7 +4044,9 @@ tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { /* table.nobottomiftotal tr.liste_total td { background-color: #fff; + border-bottom: 0px !important; + } */ div.liste_titre .tagtd { @@ -4052,22 +4059,23 @@ div.liste_titre { padding-bottom: 2px; /*border-right-width: 1px; - border-right-color: #BBB; + border-right-color: var(--colortopbordertitle1); border-right-style: solid; border-left-width: 1px; - border-left-color: #BBB; + border-left-color: var(--colortopbordertitle1); border-left-style: solid;*/ border-top-width: 1px; - border-top-color: #BBB; + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } div.liste_titre_bydiv { + border-top-width: px; border-top-color: var(--colortopbordertitle1); border-top-style: solid; - + border-collapse: collapse; display: table; padding: 2px 0px 2px 0; From 879afaa59e0251639e66981be8d00668f6800da3 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 18 Feb 2022 12:16:50 +0100 Subject: [PATCH 071/752] NEW : Beginning of PMP management on inventory --- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 + .../mysql/tables/llx_inventorydet-stock.sql | 2 + htdocs/langs/en_US/products.lang | 4 + htdocs/product/inventory/inventory.php | 86 ++++++++++++++++++- .../product/stock/tpl/extrafields_add.tpl.php | 2 +- 5 files changed, 91 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index b78e53bd287..85d8763a4fe 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -237,4 +237,6 @@ ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); +ALTER TABLE llx_inventorydet ADD COLUMN pmp_real double DEFAULT NULL; +ALTER TABLE llx_inventorydet ADD COLUMN valuation_real double DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql index 8b75f68460d..5ce878124b6 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql @@ -29,6 +29,8 @@ CREATE TABLE llx_inventorydet qty_stock double DEFAULT NULL, -- Value or real stock we have, when we start the inventory (may be updated during intermediary steps). qty_view double DEFAULT NULL, -- Quantity found during inventory. It is the targeted value, filled during edition of inventory. qty_regulated double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. + pmp_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. + valuation_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. fk_movement integer NULL -- can contain the id of stock movement we recorded to make the inventory regulation of this line ) ENGINE=innodb; diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 14715670882..947b743fa7a 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -411,3 +411,7 @@ Rank=Rank SwitchOnSaleStatus=Switch on sale status SwitchOnPurchaseStatus=Switch on purchase status StockMouvementExtraFields= Extra Fields (stock mouvement) +PMPExpected=Expected PMP +ExpectedValuation=Expected Valuation +PMPReal=Real PMP +RealValuation=Real Valuation \ No newline at end of file diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 95c9e2972cb..795e3ad11bb 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -45,7 +45,8 @@ $fk_warehouse = GETPOST('fk_warehouse', 'int'); $fk_product = GETPOST('fk_product', 'int'); $lineid = GETPOST('lineid', 'int'); $batch = GETPOST('batch', 'alphanohtml'); - +$totalExpectedValuation = 0; +$totalRealValuation = 0; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $result = restrictedArea($user, 'stock', $id); } else { @@ -863,6 +864,12 @@ if ($object->id > 0) { print ''; + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print ''; + print ''; + print ''; + print ''; + } if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { // Actions or link to stock movement print ''; + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print ''; + print ''; + print ''; + print ''; + } // Actions print ''; + if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + //PMP Expected + $pmp_valuation = $product_static->pmp * $valuetoshow; + print ''; + print ''; + //PMP Real + print ''; + print ''; + + $totalExpectedValuation += $pmp_valuation; + $totalRealValuation += $pmp_valuation_real; + } // Picto delete line print ''; - print ''; + print ''; + + //PMP Real + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } print '
'; if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { @@ -2242,18 +2242,14 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } print '
'; - print ''; + //print ''; if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - print '
'; + //print '
'; } - print '
+ print '
-
'; - - print ' -
'; print '
'; @@ -2400,9 +2396,12 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme // Create a Stripe client. var stripe = Stripe(''); - + var cardButton = document.getElementById('buttontopay'); + var clientSecret = cardButton.dataset.secret; + var options = { clientSecret: clientSecret,}; + // Create an instance of Elements - var elements = stripe.elements(); + var elements = stripe.elements(options); // Custom styling can be passed to options when creating an Element. // (Note that this demo uses a wider set of styles than the guide below.) @@ -2423,49 +2422,28 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } }; - var cardElement = elements.create('card', {style: style}); + var paymentElement = elements.create("payment"); // Add an instance of the card Element into the `card-element`
- cardElement.mount('#card-element'); - - // Handle real-time validation errors from the card Element. - cardElement.addEventListener('change', function(event) { - var displayError = document.getElementById('card-errors'); - if (event.error) { - console.log("Show event error (like 'Incorrect card number', ...)"); - displayError.textContent = event.error.message; - } else { - console.log("Reset error message"); - displayError.textContent = ''; - } - }); + paymentElement.mount("#payment-element"); // Handle form submission - var cardholderName = document.getElementById('cardholder-name'); var cardButton = document.getElementById('buttontopay'); - var clientSecret = cardButton.dataset.secret; cardButton.addEventListener('click', function(event) { console.log("We click on buttontopay"); event.preventDefault(); - if (cardholderName.value == '') - { - console.log("Field Card holder is empty"); - var displayError = document.getElementById('card-errors'); - displayError.textContent = 'trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>'; - } - else - { /* Disable button to pay and show hourglass cursor */ jQuery('#hourglasstopay').show(); jQuery('#buttontopay').hide(); - stripe.handleCardPayment( - clientSecret, cardElement, { + stripe.confirmPayment({ + elements,confirmParams: { + return_url: '', payment_method_data: { billing_details: { - name: cardholderName.value + name: 'test' thirdparty) && !empty($object->thirdparty->email))) { ?>, email: 'thirdparty->email); ?>' @@ -2489,6 +2467,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } else { print 'false'; } ?> /* true when a customer was provided when creating payment intent. true ask to save the card */ + }, } ).then(function(result) { console.log(result); @@ -2509,7 +2488,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme jQuery('#payment-form').submit(); } }); - } + }); Date: Fri, 12 Nov 2021 10:22:46 +0000 Subject: [PATCH 007/752] Fixing style errors. --- htdocs/public/payment/newpayment.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 62d817ab227..5cd9a4eefa2 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2396,10 +2396,10 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme // Create a Stripe client. var stripe = Stripe(''); - var cardButton = document.getElementById('buttontopay'); + var cardButton = document.getElementById('buttontopay'); var clientSecret = cardButton.dataset.secret; - var options = { clientSecret: clientSecret,}; - + var options = { clientSecret: clientSecret,}; + // Create an instance of Elements var elements = stripe.elements(options); @@ -2439,8 +2439,8 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme jQuery('#buttontopay').hide(); stripe.confirmPayment({ - elements,confirmParams: { - return_url: '', + elements,confirmParams: { + return_url: '', payment_method_data: { billing_details: { name: 'test' @@ -2467,7 +2467,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } else { print 'false'; } ?> /* true when a customer was provided when creating payment intent. true ask to save the card */ - }, + }, } ).then(function(result) { console.log(result); From 1e0d7d92a956d36c4b6f67a8178bb5d60577a5e6 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 16 Nov 2021 14:09:18 +0100 Subject: [PATCH 008/752] NEW : addline with position choice when MAIN_VIEW_LINE_NUMBER is enabled --- htdocs/comm/propal/card.php | 3 ++- htdocs/comm/propal/class/propal.class.php | 5 +++++ htdocs/commande/card.php | 3 ++- htdocs/commande/class/commande.class.php | 5 +++++ htdocs/compta/facture/card.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 5 +++++ htdocs/core/tpl/objectline_create.tpl.php | 12 ++++++++++++ .../fourn/class/fournisseur.commande.class.php | 16 +++++++++++++--- htdocs/fourn/class/fournisseur.facture.class.php | 5 +++++ htdocs/fourn/commande/card.php | 4 +++- htdocs/fourn/facture/card.php | 3 ++- htdocs/langs/en_US/main.lang | 2 ++ htdocs/supplier_proposal/card.php | 3 ++- .../class/supplier_proposal.class.php | 5 +++++ 14 files changed, 65 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 483f7b543f5..559ceba1548 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -76,6 +76,7 @@ $confirm = GETPOST('confirm', 'alpha'); $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -1127,7 +1128,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $db->commit(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7bdb531ec9b..8ba39410380 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -710,6 +710,11 @@ class Propal extends CommonObject { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la propale meme $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b9900459006..a241222ae73 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -75,6 +75,7 @@ $contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -953,7 +954,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3712a6eea1b..d9921ca1d14 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1658,6 +1658,11 @@ class Commande extends CommonOrder { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la commande meme $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 86d3abedd2b..62dcfaa5ddc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -87,6 +87,7 @@ $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $fac_rec = GETPOST('fac_rec', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -2228,7 +2229,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, $rank, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); if ($result > 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8eb749b1d6b..81e3584b773 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3209,6 +3209,11 @@ class Facture extends CommonInvoice { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la facture meme $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 8da4d30af02..153f1b26775 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -296,6 +296,18 @@ if ($nolinesbefore) { echo ''; echo ''; } + + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $tab = array(-1 => $langs->trans('AtTheEnd')); + if (!empty($object->lines)) { + $langs->load('admin'); + foreach ($object->lines as $k => $v) { + $tab[$v->rang] = $langs->trans('OnLine') . ' ' . ($k + 1); + } + } + echo '
'.$langs->trans('Position').' : '.$form->selectarray('rank', $tab); + } + if (is_object($hookmanager) && empty($senderissupplier)) { $parameters = array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 08516fbc7d2..ff2e07b9600 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1597,9 +1597,10 @@ class CommandeFournisseur extends CommonOrder * @param string $pu_ht_devise Amount in currency * @param string $origin 'order', ... * @param int $origin_id Id of origin object + * @param int $rang Position of line * @return int <=0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = false, $date_start = null, $date_end = null, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = false, $date_start = null, $date_end = null, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1) { global $langs, $mysoc, $conf; @@ -1616,6 +1617,7 @@ class CommandeFournisseur extends CommonOrder if (!$qty) $qty = 1; if (!$info_bits) $info_bits = 0; if (empty($txtva)) $txtva = 0; + if (empty($rang)) $rang = 0; if (empty($txlocaltax1)) $txlocaltax1 = 0; if (empty($txlocaltax2)) $txlocaltax2 = 0; if (empty($remise_percent)) $remise_percent = 0; @@ -1776,8 +1778,11 @@ class CommandeFournisseur extends CommonOrder $localtax1_type = $localtaxes_type[0]; $localtax2_type = $localtaxes_type[2]; - $rangmax = $this->line_max(); - $rang = $rangmax + 1; + if ($rang < 0) + { + $rangmax = $this->line_max(); + $rang = $rangmax + 1; + } // Insert line $this->line = new CommandeFournisseurLigne($this->db); @@ -1839,6 +1844,11 @@ class CommandeFournisseur extends CommonOrder { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la commande meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 72d040583b2..34c9f8de335 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1857,6 +1857,11 @@ class FactureFournisseur extends CommonInvoice { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la facture meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f79f37d16e5..4dee5059223 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -66,6 +66,7 @@ $socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); $cancel = GETPOST('cancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; $lineid = GETPOST('lineid', 'int'); $origin = GETPOST('origin', 'alpha'); @@ -532,7 +533,8 @@ if (empty($reshook)) $productsupplier->fk_unit, $pu_ht_devise, '', - 0 + 0, + $rank ); } if ($idprod == -99 || $idprod == 0) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 985c9a4cc62..b60ee380cf4 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -70,6 +70,7 @@ $lineid = GETPOST('lineid', 'int'); $projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -1379,7 +1380,7 @@ if (empty($reshook)) $tva_npr, $price_base_type, $type, - -1, + $rank, 0, $array_options, $productsupplier->fk_unit, diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 67c78bf2915..3f21e47bc5f 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1074,3 +1074,5 @@ AmountMustBePositive=Amount must be positive ByStatus=By status InformationMessage=Information Used=Used +AtTheEnd=At the end +OnLine=On line diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 708844b71c8..1fc8723951c 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -65,6 +65,7 @@ $confirm = GETPOST('confirm', 'alpha'); $projectid = GETPOST('projectid', 'int'); $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid', 'int'); +$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -678,7 +679,7 @@ if (empty($reshook)) $pu_ttc, $tva_npr, $type, - -1, + $rank, 0, GETPOST('fk_parent_line'), $fournprice, diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d28a0ef3b72..91652248395 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -618,6 +618,11 @@ class SupplierProposal extends CommonObject { // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); + } + } // Mise a jour informations denormalisees au niveau de la propale meme $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. From c55008e8af0b79536c88ea9a1a50d773b48a79ed Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 16 Nov 2021 16:02:55 +0100 Subject: [PATCH 009/752] NEW : insert_discount() functions handle --- htdocs/compta/facture/class/facture.class.php | 9 ++++++++- htdocs/fourn/class/fournisseur.facture.class.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 81e3584b773..44297da0ff3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1954,7 +1954,7 @@ class Facture extends CommonInvoice public function insert_discount($idremise) { // phpcs:enable - global $langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -1986,6 +1986,13 @@ class Facture extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $facligne->rang = 1; + for ($ii = 1; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + } + } + // Get buy/cost price of invoice that is source of discount if ($remise->fk_facture_source > 0) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 34c9f8de335..8e12bf11b45 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1025,7 +1025,7 @@ class FactureFournisseur extends CommonInvoice public function insert_discount($idremise) { // phpcs:enable - global $langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -1058,6 +1058,13 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $facligne->rang = 1; + for ($ii = 1; $ii <= count($this->lines); $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + } + } + // Get buy/cost price of invoice that is source of discount if ($remise->fk_invoice_supplier_source > 0) { From 19171d4f8ea2e0ff588104ff764bf5da45f15511 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 16 Nov 2021 15:15:55 +0000 Subject: [PATCH 010/752] Fixing style errors. --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 5 ++--- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++--- htdocs/supplier_proposal/card.php | 2 +- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a532a874d65..37636e51b54 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -734,7 +734,7 @@ class Propal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 67cb1a1790f..b43a231b7e9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1648,7 +1648,7 @@ class Commande extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d092a25d680..e806bc72dd5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2087,7 +2087,7 @@ class Facture extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $facligne->rang = 1; for ($ii = 1; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); @@ -3362,7 +3362,7 @@ class Facture extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f1a15e0d537..2f5b8397bdd 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -310,7 +310,7 @@ if ($nolinesbefore) { echo ''; } - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $tab = array(-1 => $langs->trans('AtTheEnd')); if (!empty($object->lines)) { $langs->load('admin'); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 790f67623d8..c9e32fbb1f7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1857,8 +1857,7 @@ class CommandeFournisseur extends CommonOrder $localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; - if ($rang < 0) - { + if ($rang < 0) { $rangmax = $this->line_max(); $rang = $rangmax + 1; } @@ -1923,7 +1922,7 @@ class CommandeFournisseur extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + } elseif ($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines for ($ii = $rang; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bb137410b6d..6a46695135a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1111,7 +1111,7 @@ class FactureFournisseur extends CommonInvoice public function insert_discount($idremise) { // phpcs:enable - global $conf, $langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -1142,7 +1142,7 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $facligne->rang = 1; for ($ii = 1; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); @@ -2014,7 +2014,7 @@ class FactureFournisseur extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines + } elseif ($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines for ($ii = $rang; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index eaed94f6529..29c147e142e 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -673,7 +673,7 @@ if (empty($reshook)) { $pu_ttc, $tva_npr, $type, - $rank, + $rank, 0, GETPOST('fk_parent_line'), $fournprice, diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f90555f9f1e..08a3a03476a 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -621,7 +621,7 @@ class SupplierProposal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) { $this->line_order(true, 'DESC'); - } elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines + } elseif ($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } From 375dcf702819705c4478705d3f008502375368cb Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 16 Nov 2021 16:42:48 +0100 Subject: [PATCH 011/752] FIX : dev name --- htdocs/comm/propal/card.php | 1 + htdocs/comm/propal/class/propal.class.php | 1 + htdocs/commande/card.php | 1 + htdocs/commande/class/commande.class.php | 1 + htdocs/compta/facture/card.php | 1 + htdocs/compta/facture/class/facture.class.php | 1 + htdocs/core/tpl/objectline_create.tpl.php | 1 + htdocs/fourn/class/fournisseur.commande.class.php | 1 + htdocs/fourn/class/fournisseur.facture.class.php | 1 + htdocs/fourn/commande/card.php | 1 + htdocs/fourn/facture/card.php | 1 + htdocs/supplier_proposal/card.php | 1 + htdocs/supplier_proposal/class/supplier_proposal.class.php | 1 + 13 files changed, 13 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 98ea79b078f..e6ae2f2ab87 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -14,6 +14,7 @@ * Copyright (C) 2016 Marcos García * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a532a874d65..675ed2e2687 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9e682805d20..cfa21ce1534 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -13,6 +13,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 67cb1a1790f..49012e486b0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index abed475fbb5..c4cb861b2b6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -15,6 +15,7 @@ * Copyright (C) 2014-2019 Ferran Marcet * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d092a25d680..6bec2c37d5c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -17,6 +17,7 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f1a15e0d537..30d0ae09fc4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -9,6 +9,7 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 790f67623d8..b8a0ac93d3d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2021 Josep Lluís Amador + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bb137410b6d..ddd79cc46c2 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c341a529123..70b2908eb45 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ion Agorria * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 57356bbc1e9..aeb0681547f 100755 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -11,6 +11,7 @@ * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Ferran Marcet + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index eaed94f6529..b299176c56e 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -12,6 +12,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Gauthier VERDOL * * 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 diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f90555f9f1e..632b44dba2a 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019-2020 Frédéric France * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Gauthier VERDOL * * 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 From ea8280af9854a81cc9b42bf641a676fd2a574b92 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 17 Nov 2021 17:32:17 +0100 Subject: [PATCH 012/752] FIX : status filter on supplierOrder stats doesn't work --- htdocs/commande/stats/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index bd92dc084c7..e92cd076928 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -95,12 +95,12 @@ dol_mkdir($dir); $stats = new CommandeStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0)); if ($mode == 'customer') { if ($object_status != '' && $object_status >= -1) { - $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($object_status).')'; + $stats->where .= ' AND c.fk_statut IN ('.implode(',',$object_status).')'; } } if ($mode == 'supplier') { if ($object_status != '' && $object_status >= 0) { - $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($object_status).')'; + $stats->where .= ' AND c.fk_statut IN ('.implode(',',$object_status).')'; } } From c5f6c617c91dce34eced356c7605f5a4cd5ff2b9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 19 Nov 2021 08:34:45 +0000 Subject: [PATCH 013/752] Fixing style errors. --- htdocs/commande/stats/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index e92cd076928..4753666b2bc 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -95,12 +95,12 @@ dol_mkdir($dir); $stats = new CommandeStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0)); if ($mode == 'customer') { if ($object_status != '' && $object_status >= -1) { - $stats->where .= ' AND c.fk_statut IN ('.implode(',',$object_status).')'; + $stats->where .= ' AND c.fk_statut IN ('.implode(',', $object_status).')'; } } if ($mode == 'supplier') { if ($object_status != '' && $object_status >= 0) { - $stats->where .= ' AND c.fk_statut IN ('.implode(',',$object_status).')'; + $stats->where .= ' AND c.fk_statut IN ('.implode(',', $object_status).')'; } } From dc23c7f6a3a69ae11367d696cde8a46a587d08a7 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 19 Nov 2021 10:29:27 +0100 Subject: [PATCH 014/752] FIX : Travis --- htdocs/commande/stats/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 4753666b2bc..c93c8888aa9 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -95,12 +95,12 @@ dol_mkdir($dir); $stats = new CommandeStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0)); if ($mode == 'customer') { if ($object_status != '' && $object_status >= -1) { - $stats->where .= ' AND c.fk_statut IN ('.implode(',', $object_status).')'; + $stats->where .= ' AND c.fk_statut IN ('.$db->escape(implode(',', $object_status)).')'; } } if ($mode == 'supplier') { if ($object_status != '' && $object_status >= 0) { - $stats->where .= ' AND c.fk_statut IN ('.implode(',', $object_status).')'; + $stats->where .= ' AND c.fk_statut IN ('.$db->escape(implode(',', $object_status)).')'; } } From 7cb657c99189a02695ba74e1b511ff5b3802e7aa Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 14:49:11 +0100 Subject: [PATCH 015/752] FIX: project timesheets: assume Saturday and Sunday are default weekend days when working days conf is empty or badly formed --- htdocs/projet/activity/perday.php | 5 +++++ htdocs/projet/activity/perweek.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index e315f638dd2..cefdf4d6463 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -620,6 +620,11 @@ $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSI // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 54283681029..becbb86157a 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -521,6 +521,11 @@ $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray[' // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); @@ -530,7 +535,6 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) $numendworkingday = $tmparray[1]; } } - for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 From c5f0faad43315aaaf3a877aa1a6414eaba9b708b Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 15:36:00 +0100 Subject: [PATCH 016/752] FIX: project timesheet: public holidays offset by 1 day --- htdocs/projet/activity/perday.php | 6 +++++- htdocs/projet/activity/perweek.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 79a259f1ccc..159f4f11b6b 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -87,6 +87,10 @@ $daytoparse = $now; if ($yearofday && $monthofday && $dayofday) $daytoparse = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' elseif ($year && $month && $day) $daytoparse = dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect' +$daytoparsegmt = dol_now('gmt'); +if ($yearofday && $monthofday && $dayofday) $daytoparsegmt = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday, 'gmt'); // xxxofday is value of day after submit action 'addtime' +elseif ($year && $month && $day) $daytoparsegmt = dol_mktime(0, 0, 0, $month, $day, $year, 'gmt'); // this are value submited after submit of action 'submitdateselect' + if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { @@ -616,7 +620,7 @@ $statusofholidaytocheck = Holiday::STATUS_APPROVED; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day -$test = num_public_holiday($daytoparse, $daytoparse + 86400, $mysoc->country_code); +$test = num_public_holiday($daytoparsegmt, $daytoparsegmt + 86400, $mysoc->country_code); if ($test) $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); $tmparray = dol_getdate($daytoparse, true); // detail of current day diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index d7c0f874383..267106c5721 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -97,6 +97,7 @@ $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); +$firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) @@ -520,6 +521,7 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow @@ -534,7 +536,7 @@ for ($idw = 0; $idw < 7; $idw++) $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day - $test = num_public_holiday($dayinloopfromfirstdaytoshow, $dayinloopfromfirstdaytoshow + 86400, $mysoc->country_code); + $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code); if ($test) $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } //var_dump($isavailable); From 112922206469e35129ec5198bac125f40ce736fa Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 19 Nov 2021 15:59:34 +0100 Subject: [PATCH 017/752] FIX: user employee tab: offset in open days messes up holiday length calculation --- htdocs/user/bank.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 3bdc6b5390c..e97d6504369 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -327,7 +327,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $holiday->id = $objp->rowid; $holiday->ref = $objp->rowid; $holiday->fk_type = $objp->fk_type; - $nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); + $nbopenedday = num_open_day($db->jdate($objp->date_debut, 'gmt'), $db->jdate($objp->date_fin, 'gmt'), 0, 1, $objp->halfday); print $holiday->getNomUrl(1); print '
'.dol_print_date($db->jdate($objp->date_debut), 'day')."'.$langs->trans("TimeSpent").($usertoprocess for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. From e75b6ae0b408c93c2406c58fe3c635e6510d6438 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 22 Nov 2021 16:13:46 +0100 Subject: [PATCH 019/752] FIX : it's better with an input number --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/core/tpl/objectline_create.tpl.php | 9 +-------- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/langs/en_US/main.lang | 3 +-- htdocs/supplier_proposal/card.php | 2 +- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 559ceba1548..1cd02b05755 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1128,7 +1128,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $db->commit(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index a241222ae73..eabdea93e01 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -954,7 +954,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 62dcfaa5ddc..db984666449 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2229,7 +2229,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, $rank, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, min($rank, count($object->lines) + 1), $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise); if ($result > 0) { diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 153f1b26775..5e0a3bbbec8 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -298,14 +298,7 @@ if ($nolinesbefore) { } if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $tab = array(-1 => $langs->trans('AtTheEnd')); - if (!empty($object->lines)) { - $langs->load('admin'); - foreach ($object->lines as $k => $v) { - $tab[$v->rang] = $langs->trans('OnLine') . ' ' . ($k + 1); - } - } - echo '
'.$langs->trans('Position').' : '.$form->selectarray('rank', $tab); + echo '
'.$langs->trans('AddLineOnPosition').' : '; } if (is_object($hookmanager) && empty($senderissupplier)) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4dee5059223..4fd29a872d8 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -534,7 +534,7 @@ if (empty($reshook)) $pu_ht_devise, '', 0, - $rank + min($rank, count($object->lines) + 1) ); } if ($idprod == -99 || $idprod == 0) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b60ee380cf4..0d8f59aa33d 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1380,7 +1380,7 @@ if (empty($reshook)) $tva_npr, $price_base_type, $type, - $rank, + min($rank, count($object->lines) + 1), 0, $array_options, $productsupplier->fk_unit, diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 3f21e47bc5f..1c7a1d47ebb 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1074,5 +1074,4 @@ AmountMustBePositive=Amount must be positive ByStatus=By status InformationMessage=Information Used=Used -AtTheEnd=At the end -OnLine=On line +AddLineOnPosition=Add line on position (at the end if empty) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 1fc8723951c..1fce863ed84 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -679,7 +679,7 @@ if (empty($reshook)) $pu_ttc, $tva_npr, $type, - $rank, + min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, From 9975587cd59d8905874faaa18837283ed8df84c4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 22 Nov 2021 15:26:46 +0000 Subject: [PATCH 020/752] Fixing style errors. --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index dba5e5be695..b0c33e934fc 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -311,7 +311,7 @@ if ($nolinesbefore) { echo ''; } - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { echo '
'.$langs->trans('AddLineOnPosition').' : '; } From 74f5c092dcfdc84dc56f8b22dea117d2dee4a2d3 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 23 Nov 2021 10:44:43 +0100 Subject: [PATCH 021/752] FIX : use $linecount = count($this->lines); --- htdocs/comm/propal/class/propal.class.php | 3 ++- htdocs/commande/class/commande.class.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 6 ++++-- htdocs/fourn/class/fournisseur.commande.class.php | 3 ++- htdocs/fourn/class/fournisseur.facture.class.php | 14 ++++++++------ .../class/supplier_proposal.class.php | 3 ++- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8ba39410380..c192136fbd2 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -711,7 +711,8 @@ class Propal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d9921ca1d14..e758eaee9a9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1659,7 +1659,8 @@ class Commande extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 44297da0ff3..0ec9db3ea44 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1988,7 +1988,8 @@ class Facture extends CommonInvoice if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $facligne->rang = 1; - for ($ii = 1; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = 1; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); } } @@ -3217,7 +3218,8 @@ class Facture extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ff2e07b9600..5ee4ea285b3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1845,7 +1845,8 @@ class CommandeFournisseur extends CommonOrder // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $rang; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8e12bf11b45..1cf23600e6d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1058,12 +1058,13 @@ class FactureFournisseur extends CommonInvoice $facligne->rang = -1; $facligne->info_bits = 2; - if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $facligne->rang = 1; - for ($ii = 1; $ii <= count($this->lines); $ii++) { - $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $facligne->rang = 1; + $linecount = count($this->lines); + for ($ii = 1; $ii <= $linecount; $ii++) { + $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii+1); + } } - } // Get buy/cost price of invoice that is source of discount if ($remise->fk_invoice_supplier_source > 0) @@ -1865,7 +1866,8 @@ class FactureFournisseur extends CommonInvoice // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $rang; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $rang; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 91652248395..4dee2294fcd 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -619,7 +619,8 @@ class SupplierProposal extends CommonObject // Reorder if child line if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines - for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) { + $linecount = count($this->lines); + for ($ii = $ranktouse; $ii <= $linecount; $ii++) { $this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1); } } From d601f621943173642b393ba6e32979792a553bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 21:38:29 +0100 Subject: [PATCH 022/752] can merge products but experimental --- htdocs/categories/class/categorie.class.php | 17 ++ htdocs/comm/propal/class/propal.class.php | 18 +- htdocs/commande/class/commande.class.php | 17 ++ .../facture/class/facture-rec.class.php | 17 ++ htdocs/compta/facture/class/facture.class.php | 17 ++ htdocs/contrat/class/contrat.class.php | 17 ++ htdocs/core/class/commonobject.class.php | 33 +++- htdocs/delivery/class/delivery.class.php | 17 ++ htdocs/expedition/class/expedition.class.php | 17 ++ htdocs/fichinter/class/fichinter.class.php | 17 ++ htdocs/fichinter/class/fichinterrec.class.php | 18 +- .../class/fournisseur.commande.class.php | 17 ++ htdocs/langs/en_US/products.lang | 4 + htdocs/product/card.php | 185 ++++++++++++++++++ htdocs/product/class/product.class.php | 3 +- 15 files changed, 408 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 9a449d63700..0aee9cbfc81 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1947,6 +1947,23 @@ class Categorie extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'categorie_product' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * Return the addtional SQL JOIN query for filtering a list by a category * diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2f055f54a42..6b9b259fd52 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3740,8 +3740,24 @@ class Propal extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } -} + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'propaldet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } +} /** * Class to manage commercial proposal lines diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 9b315698527..0fe8d52cd1d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3999,6 +3999,23 @@ class Commande extends CommonOrder return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'commandedet', + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * Is the customer order delayed? * diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 100334e046a..c868e1e9992 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1725,6 +1725,23 @@ class FactureRec extends CommonInvoice return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'facturedet_rec' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * Update frequency and unit * diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 649b7b0c093..ffa520b1284 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4738,6 +4738,23 @@ class Facture extends CommonInvoice return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'facturedet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * Is the customer invoice delayed? * diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index fe8edd30ea4..cb97e6bc895 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2459,6 +2459,23 @@ class Contrat extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'contratdet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * Load an object from its id and create a new one in database * diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5dd392ad065..601457aba71 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7990,7 +7990,7 @@ abstract class CommonObject /** * Function used to replace a thirdparty id with another one. - * This function is meant to be called from replaceThirdparty with the appropiate tables + * This function is meant to be called from replaceThirdparty with the appropriate tables * Column name fk_soc MUST be used to identify thirdparties * * @param DoliDB $db Database handler @@ -8007,7 +8007,36 @@ abstract class CommonObject if (!$db->query($sql)) { if ($ignoreerrors) { - return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. + return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B. + } + //$this->errors = $db->lasterror(); + return false; + } + } + + return true; + } + + /** + * Function used to replace a product id with another one. + * This function is meant to be called from replaceProduct with the appropriate tables + * Column name fk_product MUST be used to identify products + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id (the product to delete) + * @param int $dest_id New product id (the product that will received element of the other) + * @param string[] $tables Tables that need to be changed + * @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old product may already exists on new one) + * @return bool True if success, False if error + */ + public static function commonReplaceProduct(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) + { + foreach ($tables as $table) { + $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_product = '.((int) $dest_id).' WHERE fk_product = '.((int) $origin_id); + + if (!$db->query($sql)) { + if ($ignoreerrors) { + return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B. } //$this->errors = $db->lasterror(); return false; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 6bfe3a33dd7..47300702baf 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -1082,6 +1082,23 @@ class Delivery extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'deliverydet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8ef7be75f52..8218e1c6402 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2503,6 +2503,23 @@ class Expedition extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'expeditiondet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 297e03fa379..af5801a48fb 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1374,6 +1374,23 @@ class Fichinter extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'fichinterdet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } } /** diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index d5690265028..9557707ad84 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -40,7 +40,7 @@ class FichinterRec extends Fichinter { public $element = 'fichinterrec'; public $table_element = 'fichinter_rec'; - public $table_element_line = 'fichinter_rec'; + public $table_element_line = 'fichinterdet_rec'; /** * @var string Fieldname with ID of parent key if this field has a parent @@ -693,6 +693,22 @@ class FichinterRec extends Fichinter return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'fichinterdet_rec' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } /** * Update frequency and unit diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9b68ef199db..c5788197c68 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3191,6 +3191,23 @@ class CommandeFournisseur extends CommonOrder return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'commande_fournisseurdet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * Is the supplier order delayed? * We suppose a purchase ordered as late if a the purchase order has been sent and the delivery date is set and before the delay. diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 205a28980a8..f4e196d0b7e 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -408,3 +408,7 @@ mandatoryHelper=Message to the user on the need to enter a start date and an end DefaultBOM=Default BOM DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'. Rank=Rank +MergeOriginProduct=Duplicate product (product you want to delete) +MergeProducts=Merge products +ConfirmMergeProducts=Are you sure you want to merge the chosen product with the current one? All linked objects (invoices, orders, ...) will be moved to the current product, after which the chosen product will be deleted. +ProductsMergeSuccess=Products have been merged diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 420203eedae..06a5a4102ff 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -226,6 +226,177 @@ if (empty($reshook)) { } $action = ''; } + // merge products + if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) { + $error = 0; + $productOriginId = GETPOST('product_origin', 'int'); + $productOrigin = new Product($db); + + if ($productOriginId <= 0) { + $langs->load('errors'); + setEventMessages($langs->trans('ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv('MergeOriginProduct')), null, 'errors'); + } else { + if (!$error && $productOrigin->fetch($productOriginId) < 1) { + setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); + $error++; + } + + if (!$error) { + // TODO Move the merge function into class of object. + $db->begin(); + + // Recopy some data + //$object->client = $object->client | $productOrigin->client; + //$object->fournisseur = $object->fournisseur | $productOrigin->fournisseur; + $listofproperties = array( + 'ref', + 'ref_ext', + 'label', + 'description', + 'url', + 'barcode', + 'fk_barcode_type', + 'import_key', + 'mandatory_period', + 'accountancy_code_buy', + 'accountancy_code_buy_intra', + 'accountancy_code_buy_export', + 'accountancy_code_sell', + 'accountancy_code_sell_intra', + 'accountancy_code_sell_export' + ); + foreach ($listofproperties as $property) { + if (empty($object->$property)) { + $object->$property = $productOrigin->$property; + } + } + // Concat some data + $listofproperties = array( + 'note_public', 'note_private' + ); + foreach ($listofproperties as $property) { + $object->$property = dol_concatdesc($object->$property, $productOrigin->$property); + } + + // Merge extrafields + if (is_array($productOrigin->array_options)) { + foreach ($productOrigin->array_options as $key => $val) { + if (empty($object->array_options[$key])) { + $object->array_options[$key] = $val; + } + } + } + + // Merge categories + $static_cat = new Categorie($db); + $custcats_ori = $static_cat->containing($productOrigin->id, 'product', 'id'); + $custcats = $static_cat->containing($object->id, 'product', 'id'); + $custcats = array_merge($custcats, $custcats_ori); + $object->setCategories($custcats); + + // If product has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys. + if ($productOrigin->barcode == $object->barcode) { + dol_syslog("We clean customer and supplier code so we will be able to make the update of target"); + $productOrigin->barcode = ''; + //$productOrigin->update($productOrigin->id, $user, 0, 'merge'); + } + + // Update + $result = $object->update($object->id, $user, 0, 'merge'); + if ($result <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + + // Move links + if (!$error) { + // This list is also into the api_products.class.php + // TODO Mutualise the list into object product.class.php + $objects = array( + 'Categorie' => '/categories/class/categorie.class.php', + 'Propal' => '/comm/propal/class/propal.class.php', + 'Commande' => '/commande/class/commande.class.php', + 'Facture' => '/compta/facture/class/facture.class.php', + 'FactureRec' => '/compta/facture/class/facture-rec.class.php', + // 'Mo' => '/mrp/class/mo.class.php', + 'Contrat' => '/contrat/class/contrat.class.php', + 'Expedition' => '/expedition/class/expedition.class.php', + 'Fichinter' => '/fichinter/class/fichinter.class.php', + 'FichinterRec' => '/fichinter/class/fichinter.class.php', + 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', + // 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', + // 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', + // 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', + 'Delivery' => '/delivery/class/delivery.class.php', + // 'Project' => '/projet/class/project.class.php', + // 'Ticket' => '/ticket/class/ticket.class.php', + // 'ConferenceOrBoothAttendee' => '/eventorganization/class/conferenceorboothattendee.class.php' + ); + + //First, all core objects must update their tables + foreach ($objects as $object_name => $object_file) { + require_once DOL_DOCUMENT_ROOT.$object_file; + + if (!$error && !$object_name::replaceProduct($db, $productOrigin->id, $object->id)) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + } + + // External modules should update their ones too + if (!$error) { + $reshook = $hookmanager->executeHooks( + 'replaceProduct', + array( + 'soc_origin' => $productOrigin->id, + 'soc_dest' => $object->id, + ), + $object, + $action + ); + + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $error++; + } + } + + + if (!$error) { + $object->context = array( + 'merge' => 1, + 'mergefromid' => $productOrigin->id, + ); + + // Call trigger + $result = $object->call_trigger('PRODUCT_MODIFY', $user); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + // End call triggers + } + + if (!$error) { + // We finally remove the old product + if ($productOrigin->delete($user) < 1) { + $error++; + } + } + + if (!$error) { + setEventMessages($langs->trans('ProductsMergeSuccess'), null, 'mesgs'); + $db->commit(); + } else { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorsProductsMerge'), null, 'errors'); + $db->rollback(); + } + } + } + } // Type if ($action == 'setfk_product_type' && $usercancreate) { @@ -2502,6 +2673,17 @@ if (($action == 'delete' && (empty($conf->use_javascript_ajax) || !empty($conf-> || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js $formconfirm = $form->formconfirm("card.php?id=".$object->id, $langs->trans("DeleteProduct"), $langs->trans("ConfirmDeleteProduct"), "confirm_delete", '', 0, "action-delete"); } +if ($action == 'merge') { + $formquestion = array( + array( + 'name' => 'product_origin', + 'label' => $langs->trans('MergeOriginProduct'), + 'type' => 'other', + 'value' => $form->select_produits('', 'product_origin', '', 0, 0, 1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null, 1), + ) + ); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("MergeProducts"), $langs->trans("ConfirmMergeProducts"), "confirm_merge", $formquestion, 'no', 1, 250); +} // Clone confirmation if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js @@ -2569,6 +2751,9 @@ if ($action != 'create' && $action != 'edit') { } else { print ''.$langs->trans("Delete").''; } + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 1) { + print ''.$langs->trans('Merge').''."\n"; + } } else { print ''.$langs->trans("Delete").''; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a7865474014..1018f43832a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -491,8 +491,7 @@ class Product extends CommonObject 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), - 'mandatory_period' =>array('type'=>'integer', 'label'=>'mandatory_period', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000), - + 'mandatory_period' => array('type'=>'integer', 'label'=>'mandatory_period', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000), ); /** From c56f1805153888a7a43d13ed230c9634a43c362a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 21:52:40 +0100 Subject: [PATCH 023/752] can merge products but experimental --- htdocs/bom/class/bom.class.php | 17 +++++++++++++++++ htdocs/product/card.php | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index fd8d4a19a75..ae352623d42 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1078,6 +1078,23 @@ class BOM extends CommonObject } } } + + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'bom_bomline' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 06a5a4102ff..41ecd4ff56c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -318,7 +318,7 @@ if (empty($reshook)) { 'Commande' => '/commande/class/commande.class.php', 'Facture' => '/compta/facture/class/facture.class.php', 'FactureRec' => '/compta/facture/class/facture-rec.class.php', - // 'Mo' => '/mrp/class/mo.class.php', + 'Bom' => '/bom/class/bom.class.php', 'Contrat' => '/contrat/class/contrat.class.php', 'Expedition' => '/expedition/class/expedition.class.php', 'Fichinter' => '/fichinter/class/fichinter.class.php', @@ -2679,7 +2679,7 @@ if ($action == 'merge') { 'name' => 'product_origin', 'label' => $langs->trans('MergeOriginProduct'), 'type' => 'other', - 'value' => $form->select_produits('', 'product_origin', '', 0, 0, 1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null, 1), + 'value' => $form->select_produits('', 'product_origin', '', 0, 0, 1, 2, '', 1, array(), 0, 1, 0, 'minwidth200', 0, '', null, 1), ) ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("MergeProducts"), $langs->trans("ConfirmMergeProducts"), "confirm_merge", $formquestion, 'no', 1, 250); From d9bcd277642e9c227d8c1d02a0f10aaa007ac1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 21:55:48 +0100 Subject: [PATCH 024/752] can merge products but experimental --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/langs/en_US/products.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 601457aba71..23d6e203bb5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8036,7 +8036,7 @@ abstract class CommonObject if (!$db->query($sql)) { if ($ignoreerrors) { - return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B. + return true; // TODO Not enough. If there is A-B on kept product and B-C on old one, we must get A-B-C after merge. Not A-B. } //$this->errors = $db->lasterror(); return false; diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index f4e196d0b7e..097ea001c48 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -412,3 +412,4 @@ MergeOriginProduct=Duplicate product (product you want to delete) MergeProducts=Merge products ConfirmMergeProducts=Are you sure you want to merge the chosen product with the current one? All linked objects (invoices, orders, ...) will be moved to the current product, after which the chosen product will be deleted. ProductsMergeSuccess=Products have been merged +ErrorsProductsMerge=Errors in products merge From 429e5cf5171c51a29f58f12beb42226896995f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 22:02:55 +0100 Subject: [PATCH 025/752] can merge products but experimental --- .../fourn/class/fournisseur.facture.class.php | 17 +++++++++++++++++ htdocs/product/card.php | 5 +++-- htdocs/reception/class/reception.class.php | 17 +++++++++++++++++ .../class/supplier_proposal.class.php | 18 ++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a1db1826684..dc5560093c0 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2929,6 +2929,23 @@ class FactureFournisseur extends CommonInvoice return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'facture_fourn_det' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * Is the payment of the supplier invoice having a delay? * diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 41ecd4ff56c..c17f3290df9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -321,11 +321,12 @@ if (empty($reshook)) { 'Bom' => '/bom/class/bom.class.php', 'Contrat' => '/contrat/class/contrat.class.php', 'Expedition' => '/expedition/class/expedition.class.php', + 'Reception' => '/reception/class/reception.class.php', 'Fichinter' => '/fichinter/class/fichinter.class.php', 'FichinterRec' => '/fichinter/class/fichinter.class.php', 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', - // 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', - // 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', + 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', + 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', // 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', 'Delivery' => '/delivery/class/delivery.class.php', // 'Project' => '/projet/class/project.class.php', diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 954e7f192cd..fadf013670e 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1949,4 +1949,21 @@ class Reception extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'commande_fournisseur_dispatch' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 9c84e2c2e89..f5b1b44bd85 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2681,6 +2681,24 @@ class SupplierProposal extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'supplier_proposaldet' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + } From 799862362d07a6f5617b4b0c7846cbceebab2a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 22:03:46 +0100 Subject: [PATCH 026/752] can merge products but experimental --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f5b1b44bd85..9c4818edfec 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2698,7 +2698,6 @@ class SupplierProposal extends CommonObject return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); } - } From 99cddfa235feb2d6e07410d5a8188103ad070998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 22:36:14 +0100 Subject: [PATCH 027/752] can merge products but experimental --- htdocs/compta/bank/class/account.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 17 +++++++++++++++++ htdocs/product/card.php | 10 +++------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 685c78f5f1b..d8115e48cac 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1708,7 +1708,7 @@ class Account extends CommonObject if ($dbs->query($sql)) { return true; } else { - //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. + //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B. //$this->errors = $dbs->lasterror(); return false; } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 5b523d8d7e8..f1487c7d8be 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -978,6 +978,23 @@ class ProductFournisseur extends Product return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'product_fournisseur_price' + ); + + return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + } + /** * List supplier prices log of a supplier price * diff --git a/htdocs/product/card.php b/htdocs/product/card.php index c17f3290df9..25503bdbf60 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -246,8 +246,6 @@ if (empty($reshook)) { $db->begin(); // Recopy some data - //$object->client = $object->client | $productOrigin->client; - //$object->fournisseur = $object->fournisseur | $productOrigin->fournisseur; $listofproperties = array( 'ref', 'ref_ext', @@ -310,7 +308,7 @@ if (empty($reshook)) { // Move links if (!$error) { - // This list is also into the api_products.class.php + // TODO add this functionality into the api_products.class.php // TODO Mutualise the list into object product.class.php $objects = array( 'Categorie' => '/categories/class/categorie.class.php', @@ -327,11 +325,8 @@ if (empty($reshook)) { 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', - // 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', + 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', 'Delivery' => '/delivery/class/delivery.class.php', - // 'Project' => '/projet/class/project.class.php', - // 'Ticket' => '/ticket/class/ticket.class.php', - // 'ConferenceOrBoothAttendee' => '/eventorganization/class/conferenceorboothattendee.class.php' ); //First, all core objects must update their tables @@ -382,6 +377,7 @@ if (empty($reshook)) { if (!$error) { // We finally remove the old product + // TODO merge attached files from old product into new one before delete if ($productOrigin->delete($user) < 1) { $error++; } From 6cbc3c60334587b676dac8a62148cea31c110e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 22:55:35 +0100 Subject: [PATCH 028/752] clean code --- htdocs/categories/class/categorie.class.php | 17 ----------------- htdocs/expedition/class/expedition.class.php | 17 ----------------- htdocs/product/card.php | 4 ++-- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 0aee9cbfc81..9a449d63700 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1947,23 +1947,6 @@ class Categorie extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); } - /** - * Function used to replace a product id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool - */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'categorie_product' - ); - - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); - } - /** * Return the addtional SQL JOIN query for filtering a list by a category * diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8218e1c6402..8ef7be75f52 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2503,23 +2503,6 @@ class Expedition extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - - /** - * Function used to replace a product id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool - */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'expeditiondet' - ); - - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); - } } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 25503bdbf60..874930d2ca9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -311,14 +311,14 @@ if (empty($reshook)) { // TODO add this functionality into the api_products.class.php // TODO Mutualise the list into object product.class.php $objects = array( - 'Categorie' => '/categories/class/categorie.class.php', + // do not use Categorie, it cause foreign key error, merge is done before + //'Categorie' => '/categories/class/categorie.class.php', 'Propal' => '/comm/propal/class/propal.class.php', 'Commande' => '/commande/class/commande.class.php', 'Facture' => '/compta/facture/class/facture.class.php', 'FactureRec' => '/compta/facture/class/facture-rec.class.php', 'Bom' => '/bom/class/bom.class.php', 'Contrat' => '/contrat/class/contrat.class.php', - 'Expedition' => '/expedition/class/expedition.class.php', 'Reception' => '/reception/class/reception.class.php', 'Fichinter' => '/fichinter/class/fichinter.class.php', 'FichinterRec' => '/fichinter/class/fichinter.class.php', From 21a3a6cc7a145398308a10bd8de4d8e434f4b478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 23:55:01 +0100 Subject: [PATCH 029/752] clean code --- htdocs/core/class/commonobject.class.php | 2 ++ htdocs/fichinter/class/fichinter.class.php | 17 ----------------- htdocs/product/card.php | 3 +-- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 23d6e203bb5..ab988d11db2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8038,6 +8038,8 @@ abstract class CommonObject if ($ignoreerrors) { return true; // TODO Not enough. If there is A-B on kept product and B-C on old one, we must get A-B-C after merge. Not A-B. } + print $sql; + //$this->errors = $db->lasterror(); return false; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index af5801a48fb..297e03fa379 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1374,23 +1374,6 @@ class Fichinter extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - - /** - * Function used to replace a product id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool - */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'fichinterdet' - ); - - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); - } } /** diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 874930d2ca9..ff73dff45c9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -320,8 +320,7 @@ if (empty($reshook)) { 'Bom' => '/bom/class/bom.class.php', 'Contrat' => '/contrat/class/contrat.class.php', 'Reception' => '/reception/class/reception.class.php', - 'Fichinter' => '/fichinter/class/fichinter.class.php', - 'FichinterRec' => '/fichinter/class/fichinter.class.php', + 'FichinterRec' => '/fichinter/class/fichinterrec.class.php', 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', From 3301790647112734ade5fdf8e38bddd3b32e8230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 23:56:52 +0100 Subject: [PATCH 030/752] clean code --- htdocs/core/class/commonobject.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ab988d11db2..23d6e203bb5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8038,8 +8038,6 @@ abstract class CommonObject if ($ignoreerrors) { return true; // TODO Not enough. If there is A-B on kept product and B-C on old one, we must get A-B-C after merge. Not A-B. } - print $sql; - //$this->errors = $db->lasterror(); return false; } From 4246cd80f9cde7c61601b6e7cd6e0bf571ac9749 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 24 Nov 2021 16:27:01 +0100 Subject: [PATCH 031/752] FIX : Travis + Update dev --- htdocs/commande/stats/index.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index c93c8888aa9..307588adb32 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -46,7 +46,9 @@ if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) { accessforbidden(); } -$object_status = GETPOST('object_status', 'intcomma'); +$object_status = GETPOST('object_status', 'array'); +$object_status = implode(',', $object_status); + $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -95,12 +97,12 @@ dol_mkdir($dir); $stats = new CommandeStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0)); if ($mode == 'customer') { if ($object_status != '' && $object_status >= -1) { - $stats->where .= ' AND c.fk_statut IN ('.$db->escape(implode(',', $object_status)).')'; + $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($object_status).')'; } } if ($mode == 'supplier') { if ($object_status != '' && $object_status >= 0) { - $stats->where .= ' AND c.fk_statut IN ('.$db->escape(implode(',', $object_status)).')'; + $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($object_status).')'; } } From ebc54f82e66710cfdeb17434d966fd1d50b4b633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 24 Nov 2021 18:16:48 +0100 Subject: [PATCH 032/752] move actioncomm --- htdocs/comm/action/class/actioncomm.class.php | 20 +++++++++++++++++++ htdocs/product/card.php | 18 +++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 3e2520f43da..bcfb15b932f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2203,6 +2203,26 @@ class ActionComm extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Function used to replace a product id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool + */ + public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + { + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'actioncomm SET fk_element = ' . ((int) $dest_id) . ' WHERE elementtype="product" AND fk_element = '.((int) $origin_id); + + if (!$db->query($sql)) { + //$this->errors = $db->lasterror(); + return false; + } + + return true; + } + /** * Is the action delayed? * diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ff73dff45c9..625d94e6566 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -311,21 +311,23 @@ if (empty($reshook)) { // TODO add this functionality into the api_products.class.php // TODO Mutualise the list into object product.class.php $objects = array( + 'ActionComm' => '/comm/action/class/actioncomm.class.php', + 'Bom' => '/bom/class/bom.class.php', // do not use Categorie, it cause foreign key error, merge is done before //'Categorie' => '/categories/class/categorie.class.php', - 'Propal' => '/comm/propal/class/propal.class.php', 'Commande' => '/commande/class/commande.class.php', - 'Facture' => '/compta/facture/class/facture.class.php', - 'FactureRec' => '/compta/facture/class/facture-rec.class.php', - 'Bom' => '/bom/class/bom.class.php', - 'Contrat' => '/contrat/class/contrat.class.php', - 'Reception' => '/reception/class/reception.class.php', - 'FichinterRec' => '/fichinter/class/fichinterrec.class.php', 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', + 'Contrat' => '/contrat/class/contrat.class.php', + 'Delivery' => '/delivery/class/delivery.class.php', + 'Facture' => '/compta/facture/class/facture.class.php', 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', + 'FactureRec' => '/compta/facture/class/facture-rec.class.php', + 'FichinterRec' => '/fichinter/class/fichinterrec.class.php', 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', - 'Delivery' => '/delivery/class/delivery.class.php', + 'Propal' => '/comm/propal/class/propal.class.php', + 'Reception' => '/reception/class/reception.class.php', + 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', ); //First, all core objects must update their tables From 38f2a2ca430ef58385233b73023497de773567b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 24 Nov 2021 18:19:59 +0100 Subject: [PATCH 033/752] move actioncomm --- htdocs/product/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 625d94e6566..063e6d04f09 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -323,7 +323,6 @@ if (empty($reshook)) { 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', 'FactureRec' => '/compta/facture/class/facture-rec.class.php', 'FichinterRec' => '/fichinter/class/fichinterrec.class.php', - 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', 'Propal' => '/comm/propal/class/propal.class.php', 'Reception' => '/reception/class/reception.class.php', From 661e404a14500b7185a7852ec46a70f622cd57ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 24 Nov 2021 22:56:32 +0100 Subject: [PATCH 034/752] fix tests --- htdocs/comm/action/class/actioncomm.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index bcfb15b932f..e2f78e82c99 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2206,17 +2206,17 @@ class ActionComm extends CommonObject /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler * @param int $origin_id Old product id * @param int $dest_id New product id * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'actioncomm SET fk_element = ' . ((int) $dest_id) . ' WHERE elementtype="product" AND fk_element = '.((int) $origin_id); - - if (!$db->query($sql)) { - //$this->errors = $db->lasterror(); + // using $dbs, not $this->db because function is static + if (!$dbs->query($sql)) { + //$this->errors = $dbs->lasterror(); return false; } From 4fb125703a73f9ea707ef89ce517a7311c062c89 Mon Sep 17 00:00:00 2001 From: 1ocate Date: Tue, 30 Nov 2021 17:46:06 +0700 Subject: [PATCH 035/752] For easy close shipment --- htdocs/expedition/list.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index ac5704511ef..2b73a8e54f0 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -211,6 +211,39 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } +// If massaction is close +if ($massaction == 'classifyclose') +{ + $error=0; + $selectids = GETPOST('toselect', 'array'); + foreach ($selectids as $selectid) + { + // $object->fetch($selectid); + $object->fetch($selectid); + $result = $object->setClosed(); + + } + + $massaction = $action = 'classifyclose'; + + if ($result < 0) + { + $error++; + } + + + if (!$error) + { + $db->commit(); + + setEventMessage($langs->trans("Close Done")); + header('Location: '.$_SERVER["PHP_SELF"]); + exit; + } else { + $db->rollback(); + exit; + } +} /* * View @@ -473,7 +506,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array( 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - //'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged + 'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if (in_array($massaction, array('presend'))) { From 48c4ddf3477983a63b9c7d9c9aad707ec72011d5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 30 Nov 2021 10:51:09 +0000 Subject: [PATCH 036/752] Fixing style errors. --- htdocs/expedition/list.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 2b73a8e54f0..3787a8fa5a9 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -212,28 +212,23 @@ if (empty($reshook)) { } // If massaction is close -if ($massaction == 'classifyclose') -{ +if ($massaction == 'classifyclose') { $error=0; $selectids = GETPOST('toselect', 'array'); - foreach ($selectids as $selectid) - { - // $object->fetch($selectid); + foreach ($selectids as $selectid) { + // $object->fetch($selectid); $object->fetch($selectid); $result = $object->setClosed(); - } - $massaction = $action = 'classifyclose'; + $massaction = $action = 'classifyclose'; - if ($result < 0) - { + if ($result < 0) { $error++; } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessage($langs->trans("Close Done")); From 169f5e6ad6f55176c921aa49726a82d525eb2207 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Tue, 30 Nov 2021 20:08:56 +0700 Subject: [PATCH 037/752] Update list.php --- htdocs/expedition/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 3787a8fa5a9..2dc8513a361 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -501,7 +501,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array( 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged + 'classifyclose'=>$langs->trans("Close"), 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if (in_array($massaction, array('presend'))) { From 31dd11c9c018004e10f7376870e583789909ac23 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 30 Nov 2021 13:11:28 +0000 Subject: [PATCH 038/752] Fixing style errors. --- htdocs/expedition/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 2dc8513a361..0668a764ea4 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -501,7 +501,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array( 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'classifyclose'=>$langs->trans("Close"), + 'classifyclose'=>$langs->trans("Close"), 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if (in_array($massaction, array('presend'))) { From 3ca67434697e2a4e15a7a10de68dc3ffe448e514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Tue, 30 Nov 2021 16:19:36 +0100 Subject: [PATCH 039/752] Show category description --- htdocs/takepos/index.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 8bd1c4dbca9..e01a81ec94f 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -227,7 +227,12 @@ function PrintCategories(first) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); + global->TAKEPOS_SHOW_CATEGORY_DESCRIPTION == 1) { ?> + $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label'].bold() + ' - ' + ['description']); + + $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); + $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).attr('class', 'wrapper'); @@ -261,7 +266,12 @@ function MoreCategories(moreorless) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).text(categories[i+( * pagecategories)]['label']); + global->TAKEPOS_SHOW_CATEGORY_DESCRIPTION == 1) { ?> + $("#catdesc"+i).html(categories[i+( * pagecategories)]['label'].bold() + ' - ' + categories[i+( * pagecategories)]['description']); + + $("#catdesc"+i).text(categories[i+( * pagecategories)]['label']); + $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+( * pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+( * pagecategories)]['rowid']); $("#catwatermark"+i).show(); From 7dff30126dbe5a783b190125487abaf01e8a1258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Tue, 30 Nov 2021 18:22:59 +0100 Subject: [PATCH 040/752] Show subcategories description --- htdocs/takepos/index.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index e01a81ec94f..f86f710d169 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -300,7 +300,11 @@ function LoadProducts(position, issubcat) { jQuery.each(subcategories, function(i, val) { if (currentcat==val.fk_parent) { $("#prodivdesc"+ishow).show(); - $("#prodesc"+ishow).text(val.label); + global->TAKEPOS_SHOW_CATEGORY_DESCRIPTION == 1) { ?> + $("#prodesc"+ishow).html(val.label.bold() + ' - ' + val.description); + + $("#prodesc"+ishow).text(val.label); + $("#probutton"+ishow).text(val.label); $("#probutton"+ishow).show(); $("#proprice"+ishow).attr("class", "hidden"); From 5c1638227db597ad793d24dc30354e3fb6acdc05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Wed, 1 Dec 2021 09:58:01 +0100 Subject: [PATCH 041/752] =?UTF-8?q?Correction=20description=20cat=C3=A9gor?= =?UTF-8?q?ie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/takepos/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index f86f710d169..47e36ec63ad 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -229,7 +229,7 @@ function PrintCategories(first) { $("#catdivdesc"+i).show(); global->TAKEPOS_SHOW_CATEGORY_DESCRIPTION == 1) { ?> - $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label'].bold() + ' - ' + ['description']); + $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label'].bold() + ' - ' + categories[parseInt(i)+parseInt(first)]['description']); $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); From efc0251a66ad35d1bcbd4511aa36ed1791277058 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 6 Dec 2021 11:40:50 +0100 Subject: [PATCH 042/752] FIX can modify tag in thirdparty card if const THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER enabled --- htdocs/societe/card.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 052d681b0a0..9a6e0888b8c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1126,13 +1126,14 @@ else document.formsoc.private.value=1; }); + var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '0' : '1') . '; init_customer_categ(); $("#customerprospect").change(function() { init_customer_categ(); }); function init_customer_categ() { console.log("is customer or prospect = "+jQuery("#customerprospect").val()); - if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '1' : '0').')) + if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() != 0 || !canHaveCategoryIfNotCustomerProspectSupplier)) { jQuery(".visibleifcustomer").hide(); } @@ -1151,10 +1152,16 @@ else if (jQuery("#fournisseur").val() == 0) { jQuery(".visibleifsupplier").hide(); + if (jQuery("#customerprospect").val() == 0 && canHaveCategoryIfNotCustomerProspectSupplier && jQuery(".visibleifcustomer").is(":hidden")) { + jQuery(".visibleifcustomer").show(); + } } else { jQuery(".visibleifsupplier").show(); + if (jQuery("#customerprospect").val() == 0 && jQuery(".visibleifcustomer").is(":visible")) { + jQuery(".visibleifcustomer").hide(); + } } } @@ -1769,13 +1776,14 @@ else } }); + var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '0' : '1') . '; init_customer_categ(); $("#customerprospect").change(function() { init_customer_categ(); }); function init_customer_categ() { console.log("is customer or prospect = "+jQuery("#customerprospect").val()); - if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '1' : '0').')) + if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() != 0 || !canHaveCategoryIfNotCustomerProspectSupplier)) { jQuery(".visibleifcustomer").hide(); } @@ -1794,10 +1802,16 @@ else if (jQuery("#fournisseur").val() == 0) { jQuery(".visibleifsupplier").hide(); + if (jQuery("#customerprospect").val() == 0 && canHaveCategoryIfNotCustomerProspectSupplier && jQuery(".visibleifcustomer").is(":hidden")) { + jQuery(".visibleifcustomer").show(); + } } else { jQuery(".visibleifsupplier").show(); + if (jQuery("#customerprospect").val() == 0 && jQuery(".visibleifcustomer").is(":visible")) { + jQuery(".visibleifcustomer").hide(); + } } }; From e3a18d117ec6ac115d9205c6a2ebd57d62aa6d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 13 Dec 2021 10:32:07 +0100 Subject: [PATCH 043/752] Only the products in stock --- htdocs/takepos/ajax/ajax.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 6cfbf4b3c1a..6cc9ef7f5fd 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -67,13 +67,21 @@ if ($action == 'getProducts') { if ($result > 0) { $prods = $object->getObjectsInCateg("product", 0, 0, 0, getDolGlobalString('TAKEPOS_SORTPRODUCTFIELD'), 'ASC'); // Removed properties we don't need + $res = array(); if (is_array($prods) && count($prods) > 0) { foreach ($prods as $prod) { + if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + $prod->load_stock('nobatch,novirtual'); + if ($prod->stock_warehouse[$conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}]->real <= 0) { + continue; + } + } unset($prod->fields); unset($prod->db); + $res[] = $prod; } } - echo json_encode($prods); + echo json_encode($res); } else { echo 'Failed to load category with id='.$category; } @@ -109,12 +117,24 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price FROM '.MAIN_DB_PREFIX.'product as p'; + $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price '; + if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + $sql .= ', reel'; + } + $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; + if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; + $sql .= ' ON p.rowid = ps.fk_product'; + } $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))'; } $sql .= ' AND tosell = 1'; + if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + $sql .= ' AND reel > 0'; + $sql .= ' AND fk_entrepot ='.$conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}; + } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); $resql = $db->query($sql); if ($resql) { From 631de455a4d542d48bb2aff3806858d222e64c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 13 Dec 2021 16:51:53 +0100 Subject: [PATCH 044/752] Change line 136 --- htdocs/takepos/ajax/ajax.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 6cc9ef7f5fd..556c1a25646 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -133,7 +133,8 @@ if ($action == 'getProducts') { $sql .= ' AND tosell = 1'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND reel > 0'; - $sql .= ' AND fk_entrepot ='.$conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}; + $sql .= ' AND fk_entrepot ='.$db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}); + } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); $resql = $db->query($sql); From b9f750198f86e532f3dad77627f80a63db65a9ee Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 13 Dec 2021 15:52:38 +0000 Subject: [PATCH 045/752] Fixing style errors. --- htdocs/takepos/ajax/ajax.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 556c1a25646..87741dacf6f 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -134,7 +134,6 @@ if ($action == 'getProducts') { if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND reel > 0'; $sql .= ' AND fk_entrepot ='.$db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}); - } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); $resql = $db->query($sql); From a28ddb5ac6b1293f7e68e518883dfd3354afe268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Tue, 14 Dec 2021 09:18:44 +0100 Subject: [PATCH 046/752] sql correction --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 556c1a25646..031bed03f0f 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -133,7 +133,7 @@ if ($action == 'getProducts') { $sql .= ' AND tosell = 1'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND reel > 0'; - $sql .= ' AND fk_entrepot ='.$db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}); + $sql .= " AND fk_entrepot = '" . $db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}) . "'"; } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); From f21f15fa140928591f051d48e73a18c487706311 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 14 Dec 2021 08:25:37 +0000 Subject: [PATCH 047/752] Fixing style errors. --- htdocs/takepos/ajax/ajax.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 031bed03f0f..e8d6da7ac9a 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -134,7 +134,6 @@ if ($action == 'getProducts') { if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND reel > 0'; $sql .= " AND fk_entrepot = '" . $db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}) . "'"; - } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); $resql = $db->query($sql); From 882bf4b12dfcc9d06f4475f5cfa0d5bf2d4bb12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 20 Dec 2021 10:02:58 +0100 Subject: [PATCH 048/752] cast fk_entrepot --- htdocs/takepos/ajax/ajax.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 031bed03f0f..5eb558e9224 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -133,8 +133,7 @@ if ($action == 'getProducts') { $sql .= ' AND tosell = 1'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND reel > 0'; - $sql .= " AND fk_entrepot = '" . $db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}) . "'"; - + $sql .= " AND fk_entrepot = ".((int) $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}); } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); $resql = $db->query($sql); From 03d43173020ef87fe0fdd7696ad64d02f755e831 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Tue, 26 Oct 2021 18:26:36 +0200 Subject: [PATCH 049/752] add hook 'menuDropdownQuickaddItems' to manipulate dropdown menu --- htdocs/core/class/hookmanager.class.php | 1 + htdocs/main.inc.php | 319 +++++++++++------------- htdocs/theme/eldy/dropdown.inc.php | 10 +- 3 files changed, 158 insertions(+), 172 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index d1b1e08710e..82772418b36 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -195,6 +195,7 @@ class HookManager 'getFormatedSupplierRef', 'getIdProfUrl', 'getInputIdProf', + 'menuDropdownQuickaddItems', 'menuLeftMenuItems', 'moveUploadedFile', 'moreHtmlStatus', diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dec6e389156..d15abb78098 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2264,185 +2264,16 @@ function top_menu_user($hideloginname = 0, $urllogout = '') */ function top_menu_quickadd() { - global $langs, $conf, $db, $hookmanager, $user; - global $menumanager; + global $langs; $html = ''; - // Define $dropDownQuickAddHtml - $dropDownQuickAddHtml = ''; - - $dropDownQuickAddHtml .= ''; $html .= ' '; $html .= ' @@ -2477,6 +2308,152 @@ function top_menu_quickadd() return $html; } +/** + * Generate list of quickadd items + * + * @return string HTML output + */ +function printDropdownQuickadd() +{ + global $conf, $user, $langs, $hookmanager; + + $items = array( + 'items' => array( + array( + "url" => "/societe/card.php?action=create", + "title" => "MenuNewThirdParty@companies", + "name" => "ThirdParty@companies", + "picto" => "object_company", + "activation" => !empty($conf->societe->enabled) && $user->rights->societe->creer, // vs hooking + "position" => 10, + ), + array( + "url" => "/contact/card.php?action=create", + "title" => "NewContactAddress@companies", + "name" => "Contact@companies", + "picto" => "object_contact", + "activation" => !empty($conf->societe->enabled) && $user->rights->societe->contact->creer, // vs hooking + "position" => 20, + ), + array( + "url" => "/comm/propal/card.php?action=create", + "title" => "NewPropal@propal", + "name" => "Proposal@propal", + "picto" => "object_propal", + "activation" => !empty($conf->propal->enabled) && $user->rights->propale->creer, // vs hooking + "position" => 30, + ), + + array( + "url" => "/commande/card.php?action=create", + "title" => "NewOrder@orders", + "name" => "Order@orders", + "picto" => "object_order", + "activation" => !empty($conf->commande->enabled) && $user->rights->commande->creer, // vs hooking + "position" => 40, + ), + array( + "url" => "/compta/facture/card.php?action=create", + "title" => "NewBill@bills", + "name" => "Bill@bills", + "picto" => "object_bill", + "activation" => !empty($conf->facture->enabled) && $user->rights->facture->creer, // vs hooking + "position" => 50, + ), + array( + "url" => "/compta/facture/card.php?action=create", + "title" => "NewContractSubscription@contracts", + "name" => "Contract@contracts", + "picto" => "object_contract", + "activation" => !empty($conf->contrat->enabled) && $user->rights->contrat->creer, // vs hooking + "position" => 60, + ), + array( + "url" => "/supplier_proposal/card.php?action=create", + "title" => "SupplierProposalNew@supplier_proposal", + "name" => "SupplierProposal@supplier_proposal", + "picto" => "object_propal", + "activation" => !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer, // vs hooking + "position" => 70, + ), + array( + "url" => "/fourn/commande/card.php?action=create", + "title" => "NewSupplierOrderShort@orders", + "name" => "SupplierOrder@orders", + "picto" => "object_order", + "activation" => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->creer) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->creer), // vs hooking + "position" => 80, + ), + array( + "url" => "/fourn/facture/card.php?action=create", + "title" => "NewBill@bills", + "name" => "SupplierBill@bills", + "picto" => "object_bill", + "activation" => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->creer) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->creer), // vs hooking + "position" => 90, + ), + array( + "url" => "/product/card.php?action=create&type=0", + "title" => "NewProduct@products", + "name" => "Product@products", + "picto" => "object_product", + "activation" => !empty($conf->product->enabled) && $user->rights->produit->creer, // vs hooking + "position" => 100, + ), + array( + "url" => "/product/card.php?action=create&type=1", + "title" => "NewService@products", + "name" => "Service@products", + "picto" => "object_service", + "activation" => !empty($conf->service->enabled) && $user->rights->service->creer, // vs hooking + "position" => 110, + ), + ), + ); + + $dropDownQuickAddHtml = ''; + + // Define $dropDownQuickAddHtml + $dropDownQuickAddHtml .= ''; + + return $dropDownQuickAddHtml; +} + /** * Build the tooltip on top menu bookmark * diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index dcf7ca787b7..41622afc53c 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -423,7 +423,15 @@ a.top-menu-dropdown-link { .quickadd-body.dropdown-body { padding: unset; - padding-top: 15px; +} + +.quickadd-item { + padding-top: 6px; + padding-bottom: 6px; +} + +.quickadd-item:before { + content: none; } .quickadd-header { From 9329e54fc3dcaa48bb74c32c394cc046f6632eac Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Tue, 26 Oct 2021 18:28:08 +0200 Subject: [PATCH 050/752] fix hook 'menuDropdownQuickaddItems' --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d15abb78098..18095df707c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2421,9 +2421,9 @@ function printDropdownQuickadd() $parameters = array(); $hook_items = $items; $reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks - if (is_numeric($reshook) && !empty($hookmanager->results)) { + if (is_numeric($reshook) && is_array($hookmanager->results)) { if ($reshook == 0) { - $items['items'][] = $hookmanager->results; // add + $items['items'] = array_merge($items['items'],$hookmanager->results); // add } else { $items = $hookmanager->results; // replace } From 0f177274e01a0d83ce5d354c28f7bcfdae197722 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 26 Oct 2021 16:31:06 +0000 Subject: [PATCH 051/752] Fixing style errors. --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 18095df707c..cf0a27efd53 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2423,7 +2423,7 @@ function printDropdownQuickadd() $reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks if (is_numeric($reshook) && is_array($hookmanager->results)) { if ($reshook == 0) { - $items['items'] = array_merge($items['items'],$hookmanager->results); // add + $items['items'] = array_merge($items['items'], $hookmanager->results); // add } else { $items = $hookmanager->results; // replace } From dccd74b0efb8db7a62f6fec47d0ec90fe305b016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 20 Dec 2021 10:42:10 +0100 Subject: [PATCH 052/752] fix prefix --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 5eb558e9224..0c6b90907de 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -132,7 +132,7 @@ if ($action == 'getProducts') { } $sql .= ' AND tosell = 1'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { - $sql .= ' AND reel > 0'; + $sql .= ' AND ps.reel > 0'; $sql .= " AND fk_entrepot = ".((int) $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}); } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); From 8738dc93b57e4898252e28bec2cfac7993ed0837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 20 Dec 2021 11:06:53 +0100 Subject: [PATCH 053/752] fix prefix --- htdocs/takepos/ajax/ajax.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 0c6b90907de..2e0f35041c1 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -117,25 +117,26 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price '; + $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price '; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { - $sql .= ', reel'; + $sql .= ', ps.reel'; } $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; - $sql .= ' ON p.rowid = ps.fk_product'; + $sql .= ' ON (p.rowid = ps.fk_product'; + $sql .= " AND ps.fk_entrepot = ".((int) $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}) . ')'; } $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))'; } - $sql .= ' AND tosell = 1'; + $sql .= ' AND p.tosell = 1'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND ps.reel > 0'; - $sql .= " AND fk_entrepot = ".((int) $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}); + } - $sql .= natural_search(array('ref', 'label', 'barcode'), $term); + $sql .= natural_search(array('p.ref', 'p.label', 'p.barcode'), $term); $resql = $db->query($sql); if ($resql) { $rows = array(); From ce752fe437ad50244123a4902084686d32393fc4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 20 Dec 2021 10:07:25 +0000 Subject: [PATCH 054/752] Fixing style errors. --- htdocs/takepos/ajax/ajax.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 2e0f35041c1..6463f65b327 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -134,7 +134,6 @@ if ($action == 'getProducts') { $sql .= ' AND p.tosell = 1'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND ps.reel > 0'; - } $sql .= natural_search(array('p.ref', 'p.label', 'p.barcode'), $term); $resql = $db->query($sql); From e90c382345082fc5d70371013128c0938100c181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 20 Dec 2021 11:09:54 +0100 Subject: [PATCH 055/752] fix prefix --- htdocs/takepos/ajax/ajax.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 2e0f35041c1..6463f65b327 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -134,7 +134,6 @@ if ($action == 'getProducts') { $sql .= ' AND p.tosell = 1'; if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' AND ps.reel > 0'; - } $sql .= natural_search(array('p.ref', 'p.label', 'p.barcode'), $term); $resql = $db->query($sql); From d267d90ef76c47f516878945c7161bb59eeab8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 20 Dec 2021 14:22:35 +0100 Subject: [PATCH 056/752] escape constant --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 6463f65b327..99529e8b46f 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -125,7 +125,7 @@ if ($action == 'getProducts') { if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; $sql .= ' ON (p.rowid = ps.fk_product'; - $sql .= " AND ps.fk_entrepot = ".((int) $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}) . ')'; + $sql .= " AND ps.fk_entrepot = ".((int) $db->escape($conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']})) . ')'; } $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { From c4efac891a710ca629b7af823efa7d3a75488ad8 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 20 Dec 2021 16:10:07 +0100 Subject: [PATCH 057/752] remove warning --- htdocs/imports/import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index edbba1dea5d..566c0c725f9 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1076,7 +1076,7 @@ if ($step == 4 && $datatoimport) { $tablealias = preg_replace('/(\..*)$/i', '', $code); $tablename = $objimport->array_import_tables[0][$tablealias]; - $entityicon = $entitytoicon[$entity] ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... + $entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; // List of target fields - if (empty($import_wip)) { - $height = '24px'; //needs px for css height attribute below - } else { - $height = '29px'; - } + // $height = '24px'; //needs px for css height attribute below + $height = '30px'; $i = 0; $mandatoryfieldshavesource = true; - if (!empty($import_wip)) { - $fieldselect = 1; - } + $fieldselect = 1; print ''; - if (!empty($import_wip)) { - $pos = 1; - } + $pos = 1; + foreach ($fieldstarget as $code => $label) { print ''; @@ -1081,49 +1062,22 @@ if ($step == 4 && $datatoimport) { print ''; print ''; // Info field print ''; print ''; - if (!empty($import_wip)) { - $fieldselect++; - } + $fieldselect++; } print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; - if (empty($import_wip)) { - $newlabel = preg_replace('/\*$/', '', $label); - $text = $langs->trans($newlabel); - $more = ''; - if (preg_match('/\*$/', $label)) { - $text = ''.$text.''; - $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); - if ($mandatoryfieldshavesource) { - $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); - } - //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; + $newlabel = preg_replace('/\*$/', '', $label); + $text = $langs->trans($newlabel); + $more = ''; + if (preg_match('/\*$/', $label)) { + $text = ''.$text.''; + $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); + if ($mandatoryfieldshavesource) { + $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); } - print $text; - } else { - print ''; + //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; } + print $text; print ''; - $filecolumn = $array_match_database_to_file[$code]; + $filecolumn = !empty($array_match_database_to_file[$code])?$array_match_database_to_file[$code]:0; // Source field info $htmltext = ''.$langs->trans("FieldSource").'
'; if ($filecolumn > count($fieldssource)) { @@ -1181,9 +1135,7 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1202,7 +1154,7 @@ if ($step == 4 && $datatoimport) { if (empty($fieldsplaced[$key])) { // $nbofnotimportedfields++; - show_elem($fieldssource, $key, '', $var, 'nostyle', $import_wip); + show_elem($fieldssource, $key, '', $var, 0, 'nostyle', $listofkeys); //print '> '.$lefti.'-'.$key; $listofkeys[$key] = 1; $lefti++; @@ -1211,7 +1163,7 @@ if ($step == 4 && $datatoimport) { // Print one more empty field $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 'nostyle', $import_wip); + show_elem($fieldssource, $newkey, '', $var, 1, 'nostyle', $listofkeys); //print '> '.$lefti.'-'.$newkey; $listofkeys[$newkey] = 1; $nbofnotimportedfields++; @@ -1224,7 +1176,7 @@ if ($step == 4 && $datatoimport) { $i = 0; while ($i < $nbofnotimportedfields) { // Print empty cells - show_elem('', '', 'none', $var, 'nostyle', $import_wip); + show_elem('', '', 'none', $var, 0, 'nostyle', $listofkeys); $i++; } print '
'; - if (empty($import_wip)) { - print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); - } + //print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; print $langs->trans("NoFields"); @@ -2212,24 +2176,65 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = print ' '; print '
'; + print ' '; + print ''; + print $langs->trans("EmptyField").': '; + print ' ('.$example.')'; + print '
'; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - if (empty($import_wip)) { - print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); - } + //print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; - print $langs->trans("Field").' '.$pos; - $example = $fieldssource[$pos]['example1']; + print ''; + $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; + if ($example != "") { + print $langs->trans("Field").' '.$pos.': '; + } else { + print $langs->trans("EmptyField").': '; + } if ($example) { if (!utf8_check($example)) { $example = utf8_encode($example); } - print ' ('.$example.')'; } + $nameselect = ($pos > 0) ? $pos : (-$pos); + print ''; + print '
'.$langs->trans('Unit').''.$langs->trans('ReductionShort').''.$langs->trans('TotalHT').''.$form->showCheckAddButtons('checkforselect', 1).'
'.$langs->trans($this->tpl['unit']).''.$this->tpl['remise_percent'].''.$this->tpl['total_ht'].'
'; print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print ''.$langs->trans('PMPExpected').''.$langs->trans('ExpectedValuation').''.$langs->trans('PMPReal').''.$langs->trans('RealValuation').''; @@ -893,6 +900,16 @@ if ($object->id > 0) { print ''; print ''; print ''; + print ''; + print ''; + print ''; + print ''; print ''; @@ -902,7 +919,7 @@ if ($object->id > 0) { // Request to show lines of inventory (prefilled after start/validate step) $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.valuation_real'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -988,6 +1005,36 @@ if ($object->id > 0) { print ''; print ''; print ''; + print price($product_static->pmp); + print ''; + print price($pmp_valuation); + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + + if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; + else $pmp_real = $product_static->pmp; + $pmp_valuation_real = $pmp_real * $qty_view; + print ''; + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; @@ -999,7 +1046,31 @@ if ($object->id > 0) { print ''; print $obj->qty_view; // qty found print ''; + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + //PMP Expected + $pmp_valuation = $product_static->pmp * $valuetoshow; + $pmp_valuation_real = $pmp_real * $obj->qty_view; + print ''; + print price($product_static->pmp); + print ''; + print price($pmp_valuation); + print ''; + if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; + else $pmp_real = $product_static->pmp; + print price($pmp_real); + print ''; + print price($pmp_valuation_real); + print ''; + + $totalExpectedValuation += $pmp_valuation; + $totalRealValuation += $pmp_valuation_real; + } if ($obj->fk_movement > 0) { $stockmovment = new MouvementStock($db); $stockmovment->fetch($obj->fk_movement); @@ -1014,7 +1085,14 @@ if ($object->id > 0) { } else { dol_print_error($db); } - + if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print '
'.$langs->trans("Total").''.price($totalExpectedValuation).''.price($totalRealValuation).'
'; print ''; diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php index 62921f0a6e0..aec8c971deb 100644 --- a/htdocs/product/stock/tpl/extrafields_add.tpl.php +++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php @@ -44,7 +44,7 @@ if (empty($reshook)) { $params = array(); if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; $params['cols'] = $parameters['colspanvalue']; - print $movement->showOptionals($extrafields, 'create', $params); +// print $movement->showOptionals($extrafields, 'create', $params); } ?> From 5c2c06de3b2fd5bc6f74c829bf9c28dabfdaa673 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 18 Feb 2022 15:39:56 +0100 Subject: [PATCH 072/752] NEW : JS inventory autocalc input --- htdocs/product/inventory/inventory.php | 76 +++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 795e3ad11bb..06c8ae0d2f5 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1016,20 +1016,15 @@ if ($object->id > 0) { print ''; //PMP Real print ''; - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; + if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; else $pmp_real = $product_static->pmp; $pmp_valuation_real = $pmp_real * $qty_view; - print ''; + print ''; print ''; print ''; - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; - print ''; + print ''; print ''; $totalExpectedValuation += $pmp_valuation; @@ -1089,7 +1084,7 @@ if ($object->id > 0) { print ''; print ''.$langs->trans("Total").''; print ''.price($totalExpectedValuation).''; - print ''.price($totalRealValuation).''; + print ''.price($totalRealValuation).''; print ''; print ''; } @@ -1115,6 +1110,69 @@ if ($object->id > 0) { '; } print ''; + + + if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + ?> + + Date: Mon, 21 Feb 2022 14:25:18 +0100 Subject: [PATCH 073/752] new pmp column --- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 +- .../mysql/tables/llx_inventorydet-stock.sql | 4 +- .../inventory/class/inventory.class.php | 4 ++ htdocs/product/inventory/inventory.php | 62 +++++++++++++------ 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 85d8763a4fe..2667ac03e0e 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -238,5 +238,5 @@ ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); ALTER TABLE llx_inventorydet ADD COLUMN pmp_real double DEFAULT NULL; -ALTER TABLE llx_inventorydet ADD COLUMN valuation_real double DEFAULT NULL; +ALTER TABLE llx_inventorydet ADD COLUMN pmp_expected double DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql index 5ce878124b6..8999b0e298b 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet-stock.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet-stock.sql @@ -29,8 +29,8 @@ CREATE TABLE llx_inventorydet qty_stock double DEFAULT NULL, -- Value or real stock we have, when we start the inventory (may be updated during intermediary steps). qty_view double DEFAULT NULL, -- Quantity found during inventory. It is the targeted value, filled during edition of inventory. qty_regulated double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. - pmp_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. - valuation_real double DEFAULT NULL, -- Never used. Deprecated because we already have the fk_movement now. + pmp_real double DEFAULT NULL, + pmp_expected double DEFAULT NULL, fk_movement integer NULL -- can contain the id of stock movement we recorded to make the inventory regulation of this line ) ENGINE=innodb; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 92061972e60..81300d6bac8 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -755,6 +755,8 @@ class InventoryLine extends CommonObjectLine 'qty_stock' => array('type'=>'double', 'label'=>'QtyFound', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'Qty we found/want (to define during draft edition)'), 'qty_view' => array('type'=>'double', 'label'=>'QtyBefore', 'visible'=>1, 'enabled'=>1, 'position'=>33, 'index'=>1, 'help'=>'Qty before (filled once movements are validated)'), 'qty_regulated' => array('type'=>'double', 'label'=>'QtyDelta', 'visible'=>1, 'enabled'=>1, 'position'=>34, 'index'=>1, 'help'=>'Qty aadded or removed (filled once movements are validated)'), + 'pmp_real' => array('type'=>'double', 'label'=>'PMPReal', 'visible'=>1, 'enabled'=>1, 'position'=>35), + 'pmp_expected' => array('type'=>'double', 'label'=>'PMPExpected', 'visible'=>1, 'enabled'=>1, 'position'=>36), ); /** @@ -771,6 +773,8 @@ class InventoryLine extends CommonObjectLine public $qty_stock; public $qty_view; public $qty_regulated; + public $pmp_real; + public $pmp_expected; /** diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 06c8ae0d2f5..b593fc1b414 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -127,7 +127,7 @@ if (empty($reshook)) { $db->begin(); $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.pmp_real'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -176,14 +176,26 @@ if (empty($reshook)) { $datemovement = ''; //$inventorycode = 'INV'.$object->id; $inventorycode = 'INV-'.$object->ref; + $price = 0; + if(!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) $price = $line->pmp_real; - $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); + $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, $price, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); if ($idstockmove < 0) { $error++; setEventMessages($stockmovment->error, $stockmovment->errors, 'errors'); break; } + if(!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); + $resqlpmp = $db->query($sqlpmp); + if(! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + // Update line with id of stock movement (and the start quantity if it has changed this last recording) $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet"; $sqlupdate .= " SET fk_movement = ".((int) $idstockmove); @@ -247,6 +259,8 @@ if (empty($reshook)) { if ($result > 0) { $inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value that was set in as hidden field $inventoryline->qty_view = $qtytoupdate; // The new value we want + $inventoryline->pmp_real = price2num(GETPOST('realpmp_'.$lineid, 'alpha'), 'MS'); + $inventoryline->pmp_expected = price2num(GETPOST('expectedpmp_'.$lineid, 'alpha'), 'MS'); $resultupdate = $inventoryline->update($user); } } else { @@ -584,6 +598,7 @@ if ($object->id > 0) { var object = $(this)[0]; var objecttofill = $("#"+object.id+"_input")[0]; objecttofill.value = object.innerText; + jQuery(".realqty").trigger("change"); }) console.log("Values filled (after click on fillwithexpected)"); disablebuttonmakemovementandclose(); @@ -829,6 +844,7 @@ if ($object->id > 0) { $("#clearqty").on("click", function() { console.log("Clear all values"); jQuery(".realqty").val(""); + jQuery(".realqty").trigger("change"); return false; /* disable submit */ }); $(".undochangesqty").on("click", function undochangesqty() { @@ -919,7 +935,7 @@ if ($object->id > 0) { // Request to show lines of inventory (prefilled after start/validate step) $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.valuation_real'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -1007,9 +1023,12 @@ if ($object->id > 0) { print ''; if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected - $pmp_valuation = $product_static->pmp * $valuetoshow; + if(! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; + else $pmp_expected = $product_static->pmp; + $pmp_valuation = $pmp_expected * $valuetoshow; print ''; - print price($product_static->pmp); + print price($pmp_expected); + print ''; print ''; print ''; print price($pmp_valuation); @@ -1021,10 +1040,10 @@ if ($object->id > 0) { if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; else $pmp_real = $product_static->pmp; $pmp_valuation_real = $pmp_real * $qty_view; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; $totalExpectedValuation += $pmp_valuation; @@ -1043,10 +1062,11 @@ if ($object->id > 0) { print ''; if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected - $pmp_valuation = $product_static->pmp * $valuetoshow; - $pmp_valuation_real = $pmp_real * $obj->qty_view; + if(! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; + else $pmp_expected = $product_static->pmp; + $pmp_valuation = $pmp_expected * $valuetoshow; print ''; - print price($product_static->pmp); + print price($pmp_expected); print ''; print ''; print price($pmp_valuation); @@ -1056,6 +1076,7 @@ if ($object->id > 0) { print ''; if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; else $pmp_real = $product_static->pmp; + $pmp_valuation_real = $pmp_real * $obj->qty_view; print price($pmp_real); print ''; print ''; @@ -1117,25 +1138,26 @@ if ($object->id > 0) { Date: Tue, 22 Feb 2022 10:06:05 +0100 Subject: [PATCH 076/752] WIP dolGetButtonAction --- htdocs/societe/card.php | 48 +++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b6c483fc026..d99f080ed24 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2444,10 +2444,29 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $formconfirm = ''; // Confirm delete third party - if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); +// if ($action == 'delete' ) { +// var_dump("dlzk,dmz,kdml,zdzd"); +// +// +// $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); +// print $formconfirm; +// } + + + if ($action == 'delete') { + $formquestion = array( + array( + 'label' => $langs->trans('M456465645y'), + 'value' => 'yes', + ) + ); + + $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteThirdParty'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); } + + + if ($action == 'merge') { $formquestion = array( array( @@ -2910,15 +2929,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($user->socid)) { if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); + //TODO replace to dolGetButtonAction + $params = array( + 'attr' => array( + 'title' => '' + ) + ); print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); } else { $langs->load("mails"); + //TODO replace to dolGetButtonAction print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); } } if ($user->rights->societe->creer) { - print ''.$langs->trans("Modify").''."\n"; + //TODO MODIFIER OK + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); } if (!empty($conf->adherent->enabled)) { @@ -2930,16 +2959,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } if ($user->rights->societe->supprimer) { - print ''.$langs->trans('Merge').''."\n"; - } + //TODO FUSIONNER OK + print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); + - if ($user->rights->societe->supprimer) { - if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile - print ''.$langs->trans('Delete').''."\n"; - } else { - print ''.$langs->trans('Delete').''."\n"; - } } + //TODO SUPPRIMER OK + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From b05a5d63b210f3b341bf3017ce0edc3a56d3575d Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 11:28:33 +0100 Subject: [PATCH 077/752] WIP dolGetButtonAction --- htdocs/societe/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d99f080ed24..9b097bfab99 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2929,14 +2929,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($user->socid)) { if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); - //TODO replace to dolGetButtonAction + //TODO ENVOYER EMAIL $params = array( 'attr' => array( 'title' => '' ) ); - print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); + //print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); } else { $langs->load("mails"); //TODO replace to dolGetButtonAction @@ -2947,7 +2947,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->creer) { //TODO MODIFIER OK - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd,$params); } if (!empty($conf->adherent->enabled)) { @@ -2965,7 +2965,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } //TODO SUPPRIMER OK - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer,$params); } print ''."\n"; From 69bb3aaad19884c7c54bae6f9238329899ec692e Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 11:35:55 +0100 Subject: [PATCH 078/752] WIP dolGetButtonAction --- htdocs/societe/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 9b097bfab99..ece24428a2e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2940,8 +2940,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { $langs->load("mails"); //TODO replace to dolGetButtonAction - print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMaiAl'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); + //print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); } } @@ -2960,7 +2960,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->supprimer) { //TODO FUSIONNER OK - print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd, $params); } From b0473c475a2d62518605bf79ce2866cd59a85128 Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 11:48:35 +0100 Subject: [PATCH 079/752] wip dolGetButtonAction --- htdocs/societe/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ece24428a2e..7123bd1d18c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2941,7 +2941,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $langs->load("mails"); //TODO replace to dolGetButtonAction //print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false); + $params['attr']['title'] = $langs->trans('NoEMail'); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false,$params); } } From 059548105c83d0b1d06aa7c85e68c99f4fec01b5 Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Feb 2022 12:14:18 +0100 Subject: [PATCH 080/752] WIP dolGetButtonAction --- htdocs/societe/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7123bd1d18c..4a3a33af83f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2948,7 +2948,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->creer) { //TODO MODIFIER OK - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd,$params); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); } if (!empty($conf->adherent->enabled)) { @@ -2961,12 +2961,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($user->rights->societe->supprimer) { //TODO FUSIONNER OK - print dolGetButtonAction($langs->trans('MergeThirdparties'), '', 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd, $params); + print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); } //TODO SUPPRIMER OK - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer,$params); + print dolGetButtonAction('', $langs->trans('Delete'),'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From e21a9bdd7d832f6ef859af6e0c716f7170c68b78 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 09:25:43 +0100 Subject: [PATCH 081/752] WIP dolGetButtonAction lib --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7be3f5e3351..9a866303eb3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9965,6 +9965,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = if (empty($html)) { $html = $label; + $attr['title'] = ''; // if html not set, leave label on title is redundant } else { $attr['aria-label'] = $label; } From 5dcb4c85ee0ced5776dcf6aec36e4d48d5113297 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 10:03:48 +0100 Subject: [PATCH 082/752] fix dolGetButtonAction societe card --- htdocs/societe/card.php | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 4a3a33af83f..8c1c0102e30 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2444,15 +2444,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $formconfirm = ''; // Confirm delete third party -// if ($action == 'delete' ) { -// var_dump("dlzk,dmz,kdml,zdzd"); -// -// -// $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); -// print $formconfirm; -// } - - if ($action == 'delete') { $formquestion = array( array( @@ -2929,25 +2920,20 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($user->socid)) { if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); - //TODO ENVOYER EMAIL $params = array( 'attr' => array( 'title' => '' ) ); - //print ''.$langs->trans('SendMail').''."\n"; - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '',true,$params); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); } else { $langs->load("mails"); - //TODO replace to dolGetButtonAction - //print ''.$langs->trans('SendMail').''."\n"; $params['attr']['title'] = $langs->trans('NoEMail'); - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '',false,$params); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '', false, $params); } } if ($user->rights->societe->creer) { - //TODO MODIFIER OK print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); } @@ -2960,13 +2946,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } if ($user->rights->societe->supprimer) { - //TODO FUSIONNER OK print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); - - } - //TODO SUPPRIMER OK - print dolGetButtonAction('', $langs->trans('Delete'),'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From f866f9641e1898c6178cd3004894955891709532 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 10:12:43 +0100 Subject: [PATCH 083/752] update change on another PR --- htdocs/core/lib/functions.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9a866303eb3..7be3f5e3351 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9965,7 +9965,6 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = if (empty($html)) { $html = $label; - $attr['title'] = ''; // if html not set, leave label on title is redundant } else { $attr['aria-label'] = $label; } From b95460844396600d4f49b1cf5206233e24a0ce41 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 12:09:15 +0100 Subject: [PATCH 084/752] Update card --- htdocs/societe/card.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 8c1c0102e30..995e731cdca 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2447,12 +2447,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($action == 'delete') { $formquestion = array( array( - 'label' => $langs->trans('M456465645y'), 'value' => 'yes', ) ); - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteThirdParty'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); + $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteACompany'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); } @@ -2933,9 +2932,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } - if ($user->rights->societe->creer) { - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); - } + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); if (!empty($conf->adherent->enabled)) { $adh = new Adherent($db); @@ -2945,10 +2942,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } + print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete); + if ($user->rights->societe->supprimer) { - print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontoadd); + if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), 'action-delete', $permissiontodelete); + } else { + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete); + } } - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->supprimer); } print ''."\n"; From 57ed890b73da8e2ff3ad5a3f209d47b5c9bd71ed Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 23 Feb 2022 12:28:37 +0100 Subject: [PATCH 085/752] NEW : dol_uncompress new extensions --- htdocs/core/lib/files.lib.php | 120 +++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 44 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 60382cc4906..86c740c4f44 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2083,65 +2083,97 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring */ function dol_uncompress($inputfile, $outputdir) { - global $conf, $langs; + global $conf, $langs, $db; - if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS)) { - dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir); - include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; - $archive = new PclZip($inputfile); + include_once DOL_DOCUMENT_ROOT."/core/class/utils.class.php"; + $utils = new Utils($db); + $fileinfo = pathinfo($inputfile); + if ($fileinfo["extension"] == "zip") { + if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS)) { + dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir); + include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; + $archive = new PclZip($inputfile); - // Extract into outputdir, but only files that match the regex '/^((?!\.\.).)*$/' that means "does not include .." - $result = $archive->extract(PCLZIP_OPT_PATH, $outputdir, PCLZIP_OPT_BY_PREG, '/^((?!\.\.).)*$/'); + // Extract into outputdir, but only files that match the regex '/^((?!\.\.).)*$/' that means "does not include .." + $result = $archive->extract(PCLZIP_OPT_PATH, $outputdir, PCLZIP_OPT_BY_PREG, '/^((?!\.\.).)*$/'); - if (!is_array($result) && $result <= 0) { - return array('error'=>$archive->errorInfo(true)); - } else { - $ok = 1; - $errmsg = ''; - // Loop on each file to check result for unzipping file - foreach ($result as $key => $val) { - if ($val['status'] == 'path_creation_fail') { - $langs->load("errors"); - $ok = 0; - $errmsg = $langs->trans("ErrorFailToCreateDir", $val['filename']); - break; + if (!is_array($result) && $result <= 0) { + return array('error'=>$archive->errorInfo(true)); + } else { + $ok = 1; + $errmsg = ''; + // Loop on each file to check result for unzipping file + foreach ($result as $key => $val) { + if ($val['status'] == 'path_creation_fail') { + $langs->load("errors"); + $ok = 0; + $errmsg = $langs->trans("ErrorFailToCreateDir", $val['filename']); + break; + } + } + + if ($ok) { + return array(); + } else { + return array('error'=>$errmsg); } } + } - if ($ok) { + if (class_exists('ZipArchive')) { // Must install php-zip to have it + dol_syslog("Class ZipArchive is set so we unzip using ZipArchive to unzip into ".$outputdir); + $zip = new ZipArchive; + $res = $zip->open($inputfile); + if ($res === true) { + //$zip->extractTo($outputdir.'/'); + // We must extract one file at time so we can check that file name does not contains '..' to avoid transversal path of zip built for example using + // python3 path_traversal_archiver.py test.zip -l 10 -p tmp/ + // with -l is the range of dot to go back in path. + // and path_traversal_archiver.py found at https://github.com/Alamot/code-snippets/blob/master/path_traversal/path_traversal_archiver.py + for ($i = 0; $i < $zip->numFiles; $i++) { + if (preg_match('/\.\./', $zip->getNameIndex($i))) { + dol_syslog("Warning: Try to unzip a file with a transversal path ".$zip->getNameIndex($i), LOG_WARNING); + continue; // Discard the file + } + $zip->extractTo($outputdir.'/', array($zip->getNameIndex($i))); + } + + $zip->close(); return array(); } else { - return array('error'=>$errmsg); + return array('error'=>'ErrUnzipFails'); } } - } - if (class_exists('ZipArchive')) { // Must install php-zip to have it - dol_syslog("Class ZipArchive is set so we unzip using ZipArchive to unzip into ".$outputdir); - $zip = new ZipArchive; - $res = $zip->open($inputfile); - if ($res === true) { - //$zip->extractTo($outputdir.'/'); - // We must extract one file at time so we can check that file name does not contains '..' to avoid transversal path of zip built for example using - // python3 path_traversal_archiver.py test.zip -l 10 -p tmp/ - // with -l is the range of dot to go back in path. - // and path_traversal_archiver.py found at https://github.com/Alamot/code-snippets/blob/master/path_traversal/path_traversal_archiver.py - for ($i = 0; $i < $zip->numFiles; $i++) { - if (preg_match('/\.\./', $zip->getNameIndex($i))) { - dol_syslog("Warning: Try to unzip a file with a transversal path ".$zip->getNameIndex($i), LOG_WARNING); - continue; // Discard the file - } - $zip->extractTo($outputdir.'/', array($zip->getNameIndex($i))); - } - - $zip->close(); - return array(); + return array('error'=>'ErrNoZipEngine'); + } elseif ($fileinfo["extension"] == "gz" || $fileinfo["extension"] == "bz2") { + $extension = pathinfo($fileinfo["filename"], PATHINFO_EXTENSION); + if ($extension == "tar") { + $cmd = "tar -C ".$outputdir." -xvf ".$fileinfo["dirname"]."/".$fileinfo["basename"]; + $resarray = $utils->executeCLI($cmd, $outputdir); } else { - return array('error'=>'ErrUnzipFails'); + $program = ""; + if ($fileinfo["extension"] == "gz") { + $program = "gzip"; + } elseif ($fileinfo["extension"] == "bz2") { + $program = "bzip2"; + } else { + return array('error'=>'ErrFileExtension'); + } + $cmd = $program." -dc ".$fileinfo["dirname"]."/".$fileinfo["basename"]; + $outputfilename = $outputdir."/".$fileinfo["filename"]; + $resarray = $utils->executeCLI($cmd, $outputfilename, 0, $outputfilename); + if ($resarray["output"] == 2) { + $resarray["error"] = "ErrFilePermOrFileNotFound"; + } + if ($resarray["output"] == 1) { + $resarray["error"] = "Error"; + } } + return $resarray["output"] != 0 ? $resarray["error"] : array(); } - return array('error'=>'ErrNoZipEngine'); + return array('error'=>'ErrFileExtension'); } From 74bfdb0842f9e45b8e5a9e1b653ff7f00bcedc10 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 15:34:17 +0100 Subject: [PATCH 086/752] fix retour --- htdocs/societe/card.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 995e731cdca..3a9fcaff07b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2917,19 +2917,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } if (empty($user->socid)) { - if (!empty($object->email) || $at_least_one_email_contact) { - $langs->load("mails"); - $params = array( - 'attr' => array( - 'title' => '' - ) - ); - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); - } else { - $langs->load("mails"); - $params['attr']['title'] = $langs->trans('NoEMail'); - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle'.newToken(), '', false, $params); - } + $langs->load("mails"); + $title = ''; + if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans('NoEMail'); } + print dolGetButtonAction($title, $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', 'btn-send-mail', !empty($object->email) || $at_least_one_email_contact); } print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); @@ -2945,11 +2936,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete); if ($user->rights->societe->supprimer) { + $deleteUrl = $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(); + $buttonId = 'action-delete-no-ajax'; if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), 'action-delete', $permissiontodelete); - } else { - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete); + $deleteUrl = ''; + $buttonId = 'action-delete'; } + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteUrl, $buttonId, $permissiontodelete); } } From 114827934eac8374cfa02f627f282f9139ba9305 Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 23 Feb 2022 15:51:44 +0100 Subject: [PATCH 087/752] Fix merge conflict --- htdocs/societe/card.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d598e310aaf..25b48936341 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2455,19 +2455,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $formconfirm = ''; // Confirm delete third party - if ($action == 'delete') { - $formquestion = array( - array( - 'value' => 'yes', - ) - ); - - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteACompany'), $langs->trans('ConfirmDeleteCompany'), 'confirm_delete', '', 0, 2); + if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); } - - - if ($action == 'merge') { $formquestion = array( array( From 146b432acfed10fd9b57e835de5c48da6e1952af Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 24 Feb 2022 11:07:31 +0100 Subject: [PATCH 088/752] FIX: PR returns --- htdocs/commande/stats/index.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 307588adb32..19092e49a3c 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -45,9 +45,13 @@ if ($mode == 'customer' && !$user->rights->commande->lire) { if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) { accessforbidden(); } +if($mode == 'supplier'){ + $object_status = GETPOST('object_status', 'array:int'); + $object_status = implode(',', $object_status); +} else { + $object_status = GETPOST('object_status', 'intcomma'); +} -$object_status = GETPOST('object_status', 'array'); -$object_status = implode(',', $object_status); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); From fa4e6bd93a068a52f6123fecb3e9062761f8f8a4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 24 Feb 2022 10:10:41 +0000 Subject: [PATCH 089/752] Fixing style errors. --- htdocs/commande/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 19092e49a3c..7d0f9fb5a3a 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -45,7 +45,7 @@ if ($mode == 'customer' && !$user->rights->commande->lire) { if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) { accessforbidden(); } -if($mode == 'supplier'){ +if ($mode == 'supplier') { $object_status = GETPOST('object_status', 'array:int'); $object_status = implode(',', $object_status); } else { From c65680dbcf7f29a59d7cc00a83f0bc98e3d80ad2 Mon Sep 17 00:00:00 2001 From: GregM Date: Thu, 24 Feb 2022 11:48:10 +0100 Subject: [PATCH 090/752] WIP dolGetButtonAction on Product --- htdocs/product/card.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 64c6b6817bd..05475563e17 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2539,6 +2539,11 @@ print $formconfirm; * Action bar */ if ($action != 'create' && $action != 'edit') { + $cloneProductUrl = $_SERVER["PHP_SELF"].'?action=clone&token='.newToken(); + $cloneButtonId = 'action-clone-no-ajax'; + $deleteProductUrl = $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id; + $deleteButtonId = 'action-delete-no-ajax'; + print "\n".'
'."\n"; $parameters = array(); @@ -2547,14 +2552,16 @@ if ($action != 'create' && $action != 'edit') { if ($usercancreate) { if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) { print 'id.'">'.$langs->trans("Modify").''; + print dolGetButtonAction('', $langs->trans('ModifyGREG'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '', $user->rights->societe->creer); } if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) { if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { - print ''.$langs->trans('ToClone').''."\n"; - } else { - print 'id.'">'.$langs->trans("ToClone").''; + //print ''.$langs->trans('ToClone').''."\n"; + $cloneProductUrl = ''; + $cloneButtonId = 'action-clone'; } + print dolGetButtonAction($langs->trans('ToCloneGREG'), '', 'default', $cloneProductUrl, $cloneButtonId, $user->rights->societe->creer); } } $object_is_used = $object->isObjectUsed($object->id); @@ -2563,6 +2570,8 @@ if ($action != 'create' && $action != 'edit') { if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) { if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { print ''.$langs->trans('Delete').''."\n"; + //$deleteProductUrl = ''; + //$cloneButtonId = 'action-delete'; } else { print 'id.'">'.$langs->trans("Delete").''; } @@ -2572,6 +2581,8 @@ if ($action != 'create' && $action != 'edit') { } else { print ''.$langs->trans("Delete").''; } + print dolGetButtonAction($langs->trans('deleteGREG'), '', 'danger', $deleteProductUrl, $deleteButtonId, $user->rights->societe->creer); + print dolGetButtonAction($langs->trans('DeleteNEW'), '', 'danger', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->creer); } print "\n
\n"; From a761afe5ed69680da78ce1ff97d24dbe61acb043 Mon Sep 17 00:00:00 2001 From: GregM Date: Fri, 25 Feb 2022 10:14:39 +0100 Subject: [PATCH 091/752] FIX add dolGetButtonAction on Product --- htdocs/product/card.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 05475563e17..15a6f6e82f9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2551,17 +2551,15 @@ if ($action != 'create' && $action != 'edit') { if (empty($reshook)) { if ($usercancreate) { if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) { - print 'id.'">'.$langs->trans("Modify").''; - print dolGetButtonAction('', $langs->trans('ModifyGREG'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '', $user->rights->societe->creer); + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '', $user->rights->societe->creer); } if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) { if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { - //print ''.$langs->trans('ToClone').''."\n"; $cloneProductUrl = ''; $cloneButtonId = 'action-clone'; } - print dolGetButtonAction($langs->trans('ToCloneGREG'), '', 'default', $cloneProductUrl, $cloneButtonId, $user->rights->societe->creer); + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $cloneProductUrl, $cloneButtonId, $user->rights->societe->creer); } } $object_is_used = $object->isObjectUsed($object->id); @@ -2569,20 +2567,16 @@ if ($action != 'create' && $action != 'edit') { if ($usercandelete) { if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) { if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { - print ''.$langs->trans('Delete').''."\n"; - //$deleteProductUrl = ''; - //$cloneButtonId = 'action-delete'; + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', 'action-delete', true); } else { - print 'id.'">'.$langs->trans("Delete").''; + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); } } else { - print ''.$langs->trans("Delete").''; + print dolGetButtonAction($langs->trans("ProductIsUsed"), $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, '', false); } } else { - print ''.$langs->trans("Delete").''; + print dolGetButtonAction($langs->trans("NotEnoughPermissions"), $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, '', false); } - print dolGetButtonAction($langs->trans('deleteGREG'), '', 'danger', $deleteProductUrl, $deleteButtonId, $user->rights->societe->creer); - print dolGetButtonAction($langs->trans('DeleteNEW'), '', 'danger', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', $user->rights->societe->creer); } print "\n\n"; From 22aae26f71d28f1f17416d2ce715d8a7bf1ffa37 Mon Sep 17 00:00:00 2001 From: GregM Date: Fri, 25 Feb 2022 10:27:26 +0100 Subject: [PATCH 092/752] update product card --- htdocs/product/card.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 15a6f6e82f9..4de5e0406e0 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2541,8 +2541,6 @@ print $formconfirm; if ($action != 'create' && $action != 'edit') { $cloneProductUrl = $_SERVER["PHP_SELF"].'?action=clone&token='.newToken(); $cloneButtonId = 'action-clone-no-ajax'; - $deleteProductUrl = $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id; - $deleteButtonId = 'action-delete-no-ajax'; print "\n".'
'."\n"; From 79a0aa816fedfd2630a367716b8d5c0be4fe913a Mon Sep 17 00:00:00 2001 From: GregM Date: Fri, 25 Feb 2022 16:42:25 +0100 Subject: [PATCH 093/752] DolGetButtonAction add $usercancreate --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 4de5e0406e0..bedeae3264a 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2549,7 +2549,7 @@ if ($action != 'create' && $action != 'edit') { if (empty($reshook)) { if ($usercancreate) { if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) { - print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '', $user->rights->societe->creer); + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '', $usercancreate); } if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) { @@ -2557,7 +2557,7 @@ if ($action != 'create' && $action != 'edit') { $cloneProductUrl = ''; $cloneButtonId = 'action-clone'; } - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $cloneProductUrl, $cloneButtonId, $user->rights->societe->creer); + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $cloneProductUrl, $cloneButtonId, $usercancreate); } } $object_is_used = $object->isObjectUsed($object->id); From 08fa2dfadd3725e917d18da16e850396956946e2 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 28 Feb 2022 15:58:23 +0100 Subject: [PATCH 094/752] wip: add read employee and write employee --- htdocs/core/modules/modHRM.class.php | 16 ++++++++++++++++ htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 18 insertions(+) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 3e75f8efcd5..32bdc267276 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -249,6 +249,22 @@ class modHRM extends DolibarrModules $this->rights[$r][4] = 'compare_advance'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) $r++; + + // Read employee + $this->rights[$r][0] = 4031; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read employee'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read_employee'; + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) + $r++; + + // Write employee + $this->rights[$r][0] = 4032; // Permission id (must not be already used) + $this->rights[$r][1] = 'Write employee'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write_employee'; + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) + $r++; } /** diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 426e1186868..61f40fdb1c1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -969,6 +969,8 @@ Permission4021=Create/modify your evaluation Permission4022=Validate evaluation Permission4023=Delete evaluation Permission4030=See comparison menu +Permission4031=Read employee +Permission4032=Write employee Permission10001=Read website content Permission10002=Create/modify website content (html and javascript content) Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers. From 91ee90ebeba24a8fcb04ef0535efbc95ceca3aa0 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 28 Feb 2022 16:48:08 +0100 Subject: [PATCH 095/752] fix: read employee and write employee --- htdocs/core/lib/usergroups.lib.php | 2 +- htdocs/core/modules/modHRM.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 2792b6d9997..8e764c14ea4 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -141,7 +141,7 @@ function user_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'user'); - if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && !empty($user->rights->hrm->read_employee->read)) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read)) || (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) || (!empty($conf->holiday->enabled) && !empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->readall)) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 32bdc267276..35deea09a07 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -255,7 +255,7 @@ class modHRM extends DolibarrModules $this->rights[$r][1] = 'Read employee'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read_employee'; - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->read_employee->read) $r++; // Write employee @@ -263,7 +263,7 @@ class modHRM extends DolibarrModules $this->rights[$r][1] = 'Write employee'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write_employee'; - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_employee->write) $r++; } From e5fd11c8e075d275e69be05cf6073d0345f0cb7f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 1 Mar 2022 09:28:38 +0100 Subject: [PATCH 096/752] FIX missing advanced perms --- htdocs/comm/propal/card.php | 2 +- htdocs/fourn/paiement/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 9f902c51e29..9e6e68a2ee9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -116,7 +116,7 @@ $usercandelete = $user->rights->propal->supprimer; $usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close))); $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate))); -$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)); $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index f8f484f0cc9..3c077881f99 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -344,7 +344,7 @@ if ($result > 0) { // Send by mail if ($user->socid == 0 && $action == '') { - $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS)); + $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->send))); if ($usercansend) { print ''.$langs->trans('SendMail').''; } else { From e3aae6d2e1343a905f34624368e59d377c0e7a3a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 1 Mar 2022 10:50:22 +0100 Subject: [PATCH 097/752] FIX: object cloning: set unique extrafield values to null to prevent duplicates --- htdocs/core/class/commonobject.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a4fc828ef4b..b2d5ac8e068 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5307,8 +5307,15 @@ abstract class CommonObject $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey]; $attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey]; $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; + $attributeUnique = $extrafields->attributes[$this->table_element]['unique'][$attributeKey]; $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey]; + // If we clone, we have to clean unique extrafields to prevent duplicates. + // This behaviour can be prevented by external code by changing $this->context['createfromclone'] value in createFrom hook + if (! empty($this->context['createfromclone']) && $this->context['createfromclone'] == 'createfromclone' && ! empty($attributeUnique)) { + $new_array_options[$key] = null; + } + // Similar code than into insertExtraFields if ($attributeRequired) { From 1908acb1311150e1fcdb7d3a91dc23f0b21e9a61 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 1 Mar 2022 11:42:10 +0100 Subject: [PATCH 098/752] feat: add Accountancy code --- htdocs/user/bank.php | 6 ++++++ htdocs/user/card.php | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index fa4c7231de5..47cc3826e51 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -502,6 +502,12 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac print ''; } + // Accountancy code + if (!empty($conf->accounting->enabled)) { + print ''.$langs->trans("AccountancyCode").''; + print ''.$object->accountancy_code.''; + } + print ''; print '
'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index de1ca3a5d92..f50a4622cd4 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1577,10 +1577,10 @@ if ($action == 'create' || $action == 'adduserldap') { } // Accountancy code - if (!empty($conf->accounting->enabled)) { - print ''.$langs->trans("AccountancyCode").''; - print ''.$object->accountancy_code.''; - } + //if (!empty($conf->accounting->enabled)) { + // print ''.$langs->trans("AccountancyCode").''; + // print ''.$object->accountancy_code.''; + //} print ''; From cb17f2029ed1bddd2d6b310bd307725fb251242f Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 2 Mar 2022 11:20:07 +0100 Subject: [PATCH 099/752] wip: add ref_employee and national_registration_number fields --- .../install/mysql/migration/15.0.0-16.0.0.sql | 5 ++++- htdocs/install/mysql/tables/llx_user.sql | 2 ++ htdocs/user/bank.php | 13 ++++++++++++ htdocs/user/card.php | 21 +++++++++++++++++++ htdocs/user/class/user.class.php | 21 +++++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 5d838fc8bb1..fd32936fb04 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -272,4 +272,7 @@ ALTER TABLE llx_reception MODIFY COLUMN ref_supplier varchar(128); ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER domiciliation; -- Set default ticket type to OTHER if no default exists -UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1); \ No newline at end of file +UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1); + +ALTER TABLE llx_user ADD COLUMN ref_employee varchar(50) DEFAULT NULL; +ALTER TABLE llx_user ADD COLUMN national_registration_number varchar(50) DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 6cfdf8bfbb8..694ed360b21 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -108,5 +108,7 @@ create table llx_user import_key varchar(14), -- import key default_range integer, default_c_exp_tax_cat integer, + employee_number varchar(50), + national_registration_number varchar(50), fk_warehouse integer -- default warehouse os user )ENGINE=innodb; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 47cc3826e51..17d52d7cbb6 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -508,6 +508,19 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac print ''.$object->accountancy_code.''; } + // Employee Number + if (!empty($conf->accounting->enabled)) { + print ''.$langs->trans("ref_employee").''; + print ''.$object->ref_employee.''; + } + + // National registration number + if (!empty($conf->accounting->enabled)) { + print ''.$langs->trans("NationalRegistrationNumber").''; + print ''.$object->national_registration_number.''; + } + + print ''; print '
'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 00c94feaf44..68b62950811 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -247,6 +247,8 @@ if (empty($reshook)) { $object->civility_code = GETPOST("civility_code", 'aZ09'); $object->lastname = GETPOST("lastname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml'); + $object->ref_employee = GETPOST("ref_employee", 'alphanohtml'); + $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml'); $object->login = GETPOST("login", 'alphanohtml'); $object->api_key = GETPOST("api_key", 'alphanohtml'); $object->gender = GETPOST("gender", 'aZ09'); @@ -259,6 +261,7 @@ if (empty($reshook)) { $object->office_phone = GETPOST("office_phone", 'alphanohtml'); $object->office_fax = GETPOST("office_fax", 'alphanohtml'); $object->user_mobile = GETPOST("user_mobile", 'alphanohtml'); + $object->ref_employee = GETPOST("ref_employee", 'alphanohtml'); if (!empty($conf->socialnetworks->enabled)) { $object->socialnetworks = array(); @@ -402,6 +405,7 @@ if (empty($reshook)) { $object->civility_code = GETPOST("civility_code", 'aZ09'); $object->lastname = GETPOST("lastname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml'); + $object->ref_employee = GETPOST("ref_employee", 'alphanohtml'); $object->gender = GETPOST("gender", 'aZ09'); $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; @@ -845,6 +849,12 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''; + // Ref remployee + print ''.$langs->trans("ref_employee").''; + print ''; + print ''; + print ''; + // Login print ''.$langs->trans("Login").''; print ''; @@ -2089,6 +2099,17 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''; + // Ref employee + print "".''.$langs->trans("ref_employee").''; + print ''; + if ($caneditfield && !$object->ldap_sid) { + print ''; + } else { + print ''; + print $object->ref_employee; + } + print ''; + // Login print "".''.$langs->trans("Login").''; print ''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6c5926f8c43..84118961692 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -339,6 +339,17 @@ class User extends CommonObject public $dateemploymentend; // Define date of employment end by company public $default_c_exp_tax_cat; + + /** + * @var string ref for employee + */ + public $ref_employee; + + /** + * @var string national registration number + */ + public $national_registration_number; + public $default_range; /** @@ -350,6 +361,8 @@ class User extends CommonObject 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'lastname'=>array('type'=>'varchar(50)', 'label'=>'LastName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1), 'firstname'=>array('type'=>'varchar(50)', 'label'=>'FirstName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'ref_employee'=>array('type'=>'varchar(50)', 'label'=>'ref_employee', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30, 'searchall'=>1), + 'national_registration_number'=>array('type'=>'varchar(50)', 'label'=>'national_registration_number', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40, 'searchall'=>1) ); @@ -437,6 +450,8 @@ class User extends CommonObject $sql .= " u.fk_warehouse,"; $sql .= " u.ref_ext,"; $sql .= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode + $sql .= " u.national_registration_number,"; + $sql .= " u.ref_employee,"; $sql .= " c.code as country_code, c.label as country,"; $sql .= " d.code_departement as state_code, d.nom as state"; $sql .= " FROM ".$this->db->prefix()."user as u"; @@ -488,6 +503,8 @@ class User extends CommonObject $this->civility_code = $obj->civility_code; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; + $this->ref_employee = $obj->ref_employee; + $this->national_registration_number = $obj->national_registration_number; $this->employee = $obj->employee; @@ -1755,6 +1772,8 @@ class User extends CommonObject $this->civility_code = trim($this->civility_code); $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); + $this->ref_employee = trim($this->ref_employee); + $this->national_registration_number = trim($this->national_registration_number); $this->employee = $this->employee ? $this->employee : 0; $this->login = trim($this->login); $this->gender = trim($this->gender); @@ -1847,6 +1866,8 @@ class User extends CommonObject $sql .= " civility = '".$this->db->escape($this->civility_code)."'"; $sql .= ", lastname = '".$this->db->escape($this->lastname)."'"; $sql .= ", firstname = '".$this->db->escape($this->firstname)."'"; + $sql .= ", ref_employee = '".$this->db->escape($this->ref_employee)."'"; + $sql .= ", national_registration_number = '".$this->db->escape($this->national_registration_number)."'"; $sql .= ", employee = ".(int) $this->employee; $sql .= ", login = '".$this->db->escape($this->login)."'"; $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null"); From dcabd046d92b16f286542eaf6f59176e9bebdfa7 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 2 Mar 2022 11:52:44 +0100 Subject: [PATCH 100/752] feat: add ref_employee and national_registration_number fields --- htdocs/user/card.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 68b62950811..961ace97f53 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -261,7 +261,6 @@ if (empty($reshook)) { $object->office_phone = GETPOST("office_phone", 'alphanohtml'); $object->office_fax = GETPOST("office_fax", 'alphanohtml'); $object->user_mobile = GETPOST("user_mobile", 'alphanohtml'); - $object->ref_employee = GETPOST("ref_employee", 'alphanohtml'); if (!empty($conf->socialnetworks->enabled)) { $object->socialnetworks = array(); @@ -406,6 +405,7 @@ if (empty($reshook)) { $object->lastname = GETPOST("lastname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml'); $object->ref_employee = GETPOST("ref_employee", 'alphanohtml'); + $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml'); $object->gender = GETPOST("gender", 'aZ09'); $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; @@ -855,6 +855,12 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; + // National registration number + print ''.$langs->trans("national_registration_number").''; + print ''; + print ''; + print ''; + // Login print ''.$langs->trans("Login").''; print ''; @@ -2110,6 +2116,17 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''; + // National registration number + print "".''.$langs->trans("national_registration_number").''; + print ''; + if ($caneditfield && !$object->ldap_sid) { + print ''; + } else { + print ''; + print $object->national_registration_number; + } + print ''; + // Login print "".''.$langs->trans("Login").''; print ''; From e2f727ef55b794c5a0d9b63593040bbc3bcd5687 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 2 Mar 2022 14:21:49 +0100 Subject: [PATCH 101/752] feat: langs trans ref_employee and national registration number --- htdocs/langs/en_US/companies.lang | 2 ++ htdocs/user/bank.php | 2 +- htdocs/user/card.php | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 3e85f1b35f7..edd6f7b7dd8 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -51,6 +51,8 @@ CivilityCode=Civility code RegisteredOffice=Registered office Lastname=Last name Firstname=First name +RefEmployee=Employee reference +NationalRegistrationNumber=National registration number PostOrFunction=Job position UserTitle=Title NatureOfThirdParty=Nature of Third party diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 17d52d7cbb6..b84ae16c55f 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -510,7 +510,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac // Employee Number if (!empty($conf->accounting->enabled)) { - print ''.$langs->trans("ref_employee").''; + print ''.$langs->trans("RefEmployee").''; print ''.$object->ref_employee.''; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 961ace97f53..3bbf6438489 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -850,13 +850,13 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; // Ref remployee - print ''.$langs->trans("ref_employee").''; + print ''.$langs->trans("RefEmployee").''; print ''; print ''; print ''; // National registration number - print ''.$langs->trans("national_registration_number").''; + print ''.$langs->trans("NationalRegistrationNumber").''; print ''; print ''; print ''; @@ -2106,7 +2106,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; // Ref employee - print "".''.$langs->trans("ref_employee").''; + print "".''.$langs->trans("RefEmployee").''; print ''; if ($caneditfield && !$object->ldap_sid) { print ''; @@ -2117,7 +2117,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; // National registration number - print "".''.$langs->trans("national_registration_number").''; + print "".''.$langs->trans("NationalRegistrationNumber").''; print ''; if ($caneditfield && !$object->ldap_sid) { print ''; From 9900e5dd319692905785bbdbbf3406740021490a Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 2 Mar 2022 14:51:16 +0100 Subject: [PATCH 102/752] Clean --- htdocs/user/card.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3bbf6438489..720387e6c47 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1592,12 +1592,6 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; } - // Accountancy code - //if (!empty($conf->accounting->enabled)) { - // print ''.$langs->trans("AccountancyCode").''; - // print ''.$object->accountancy_code.''; - //} - print ''; print '
'; From 436b8fa5b5d94a9df8da0b17e958c00468f38baf Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 3 Mar 2022 16:18:09 +0100 Subject: [PATCH 103/752] apply feedbacks --- htdocs/core/lib/usergroups.lib.php | 2 +- htdocs/core/modules/modHRM.class.php | 16 ----------- htdocs/langs/en_US/admin.lang | 2 -- htdocs/user/bank.php | 41 ++++++++++++++++++++++------ htdocs/user/card.php | 34 ----------------------- 5 files changed, 33 insertions(+), 62 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 8e764c14ea4..2792b6d9997 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -141,7 +141,7 @@ function user_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'user'); - if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && !empty($user->rights->hrm->read_employee->read)) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read)) || (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) || (!empty($conf->holiday->enabled) && !empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->readall)) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 35deea09a07..3e75f8efcd5 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -249,22 +249,6 @@ class modHRM extends DolibarrModules $this->rights[$r][4] = 'compare_advance'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) $r++; - - // Read employee - $this->rights[$r][0] = 4031; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read employee'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'read_employee'; - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->read_employee->read) - $r++; - - // Write employee - $this->rights[$r][0] = 4032; // Permission id (must not be already used) - $this->rights[$r][1] = 'Write employee'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write_employee'; - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_employee->write) - $r++; } /** diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6674f6cb58a..cffd3532c05 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -969,8 +969,6 @@ Permission4021=Create/modify your evaluation Permission4022=Validate evaluation Permission4023=Delete evaluation Permission4030=See comparison menu -Permission4031=Read employee -Permission4032=Write employee Permission10001=Read website content Permission10002=Create/modify website content (html and javascript content) Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers. diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index b84ae16c55f..38b6066e9d2 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -230,6 +230,24 @@ if ($action == 'setpersonal_mobile' && $canadduser && !$cancel) { } } +// update ref_employee +if ($action == 'setref_employee' && $canadduser && !$cancel) { + $object->ref_employee = (string) GETPOST('ref_employee', 'alphanohtml'); + $result = $object->update($user); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// update national_registration_number +if ($action == 'setnational_registration_number' && $canadduser && !$cancel) { + $object->national_registration_number = (string) GETPOST('national_registration_number', 'alphanohtml'); + $result = $object->update($user); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { // update default_c_exp_tax_cat if ($action == 'setdefault_c_exp_tax_cat' && $canadduser) { @@ -509,17 +527,22 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac } // Employee Number - if (!empty($conf->accounting->enabled)) { - print ''.$langs->trans("RefEmployee").''; - print ''.$object->ref_employee.''; - } + print ''; + print ''; + print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer); + print ''; + print $form->editfieldval("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer, 'string', $object->ref_employee); + print ''; + print ''; // National registration number - if (!empty($conf->accounting->enabled)) { - print ''.$langs->trans("NationalRegistrationNumber").''; - print ''.$object->national_registration_number.''; - } - + print ''; + print ''; + print $form->editfieldkey("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer); + print ''; + print $form->editfieldval("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer, 'string', $object->national_registration_number); + print ''; + print ''; print ''; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 720387e6c47..e5381a7271e 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -849,18 +849,6 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''; - // Ref remployee - print ''.$langs->trans("RefEmployee").''; - print ''; - print ''; - print ''; - - // National registration number - print ''.$langs->trans("NationalRegistrationNumber").''; - print ''; - print ''; - print ''; - // Login print ''.$langs->trans("Login").''; print ''; @@ -2099,28 +2087,6 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''; - // Ref employee - print "".''.$langs->trans("RefEmployee").''; - print ''; - if ($caneditfield && !$object->ldap_sid) { - print ''; - } else { - print ''; - print $object->ref_employee; - } - print ''; - - // National registration number - print "".''.$langs->trans("NationalRegistrationNumber").''; - print ''; - if ($caneditfield && !$object->ldap_sid) { - print ''; - } else { - print ''; - print $object->national_registration_number; - } - print ''; - // Login print "".''.$langs->trans("Login").''; print ''; From 665e401564b30079c1f2ba64b016c374e11da60e Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 4 Mar 2022 17:03:40 +0100 Subject: [PATCH 104/752] wip: replace butAction --- htdocs/compta/facture/card.php | 89 +++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a4d85c257f8..5b4acb040d6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5359,6 +5359,12 @@ if ($action == 'create') { $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { + $params = array( + 'attr' => array( + 'title' => '', + 'class' => 'classfortooltip' + ) + ); // Editer une facture deja validee, sans paiement effectue et pas exporte en compta if ($object->statut == Facture::STATUS_VALIDATED) { // We check if lines of invoice are not already transfered into accountancy @@ -5368,18 +5374,27 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) { if (!$objectidnext && $object->is_last_in_cycle()) { if ($usercanunvalidate) { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', true, $params); } else { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('NotEnoughPermissions'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', false, $params); } } elseif (!$object->is_last_in_cycle()) { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('NotLastInCycle'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } else { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } } } else { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } } @@ -5414,7 +5429,8 @@ if ($action == 'create') { // Validate if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($usercanvalidate) { - print ''.$langs->trans('Validate').''; + print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=valid&token='.newToken(), '', true, $params); + //print ''.$langs->trans('Validate').''; } } @@ -5425,9 +5441,11 @@ if ($action == 'create') { print ''.$langs->trans('SendMail').''; } else { if ($usercansend) { - print ''.$langs->trans('SendMail').''; + //print ''.$langs->trans('SendMail').''; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); } else { - print ''.$langs->trans('SendMail').''; + //print ''.$langs->trans('SendMail').''; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params); } } } @@ -5464,10 +5482,13 @@ if ($action == 'create') { } else { if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) { // For down payment, we refuse to receive more than amount to pay. - print ''.$langs->trans('DoPayment').''; + //print ''.$langs->trans('DoPayment').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseRemainderToPayIsZero'); + print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', '#', '', false, $params); } else { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) - print ''.$langs->trans('DoPayment').''; + //print ''.$langs->trans('DoPayment').''; + print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', DOL_URL_ROOT.'/compta/paiement.php?facid='.$object->id.'&action=create&accountid='.$object->fk_account, '', true, $params); } } } @@ -5516,9 +5537,12 @@ if ($action == 'create') { ) { if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpaymentall, 'MT')) { // We can close a down payment only if paid amount is same than amount of down payment (by definition) - print ''.$langs->trans('ClassifyPaid').''; + //print ''.$langs->trans('ClassifyPaid').''; + $params['attr']['title'] = $langs->trans('AmountPaidMustMatchAmountOfDownPayment'); + print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', '#', '', false, $params); } else { - print ''.$langs->trans('ClassifyPaid').''; + //print ''.$langs->trans('ClassifyPaid').''; + print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid', '', true, $params); } } @@ -5563,13 +5587,15 @@ if ($action == 'create') { // Clone if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) { - print ''.$langs->trans("ToClone").''; + //print ''.$langs->trans("ToClone").''; + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=clone&object=invoice', '', true, $params); } // Clone as predefined / Create template if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) { if (!$objectidnext && count($object->lines) > 0) { - print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; + //print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; + print dolGetButtonAction($langs->trans('ChangeIntoRepeatableInvoice'), '', 'default', DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$object->id.'&action=create', '', true, $params); } } @@ -5602,25 +5628,44 @@ if ($action == 'create') { // Delete $isErasable = $object->is_erasable(); + $params = array( + 'attr' => array( + 'title' => '', + 'class' => 'classfortooltip' + ) + ); if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) //var_dump($isErasable); + $enableDelete = false; + $deleteHref = '#'; if ($isErasable == -4) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecausePayments'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -3) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastSituationInvoice'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -2) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastInvoice'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -1) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable <= 0) { // Any other cases - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseNotErasable'); + //print ''.$langs->trans('Delete').''; } elseif ($objectidnext) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); + //print ''.$langs->trans('Delete').''; } else { - print ''.$langs->trans('Delete').''; + //print ''.$langs->trans('Delete').''; + $deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken(); + $enableDelete = true; } + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteHref, '', $enableDelete, $params); } else { - print ''.$langs->trans('Delete').''; + //print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('NotAllowed'); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false, $params); } } print ''; From e4f4a07fc669568f00895100905a5b13854974a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Fri, 4 Mar 2022 17:31:04 +0100 Subject: [PATCH 105/752] correct mass action "classify delivered" --- htdocs/commande/list.php | 8 ++++---- htdocs/langs/en_US/orders.lang | 3 +++ htdocs/langs/fr_FR/orders.lang | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index b534d915914..2033b5626b2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -337,15 +337,15 @@ if ($action == 'shipped' && $permissiontoadd) { $error = 0; foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { - if ($objecttmp->statut == 1) { + if ($objecttmp->statut == 1 || $objecttmp->statut == 2) { if ($objecttmp->cloture($user)) { - setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + setEventMessage($objecttmp->ref." ".$langs->trans('PassedInShippedStatus'), 'mesgs'); } else { - setEventMessage($langs->trans('CantBeValidated'), 'errors'); + setEventMessage($langs->trans('YouCantShipThis'), 'errors'); $error++; } } else { - setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); + setEventMessage($objecttmp->ref." ".$langs->trans('MustBeValidatedBefore'), 'errors'); $error++; } } else { diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 9018db40a5b..e94153db1a9 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -102,6 +102,9 @@ ConfirmCancelOrder=Are you sure you want to cancel this order? ConfirmMakeOrder=Are you sure you want to confirm you made this order on %s? GenerateBill=Generate invoice ClassifyShipped=Classify delivered +PassedInShippedStatus=classified delivered +YouCantShipThis=I can't classify this. Please check user permissions +MustBeValidatedBefore=must be Validated or Shipping in order to be classified as shipped DraftOrders=Draft orders DraftSuppliersOrders=Draft purchase orders OnProcessOrders=In process orders diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index 16d1ecc2b27..3b0a3e38a7d 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -102,6 +102,9 @@ ConfirmCancelOrder=Êtes-vous sûr de vouloir annuler cette commande ? ConfirmMakeOrder=Êtes-vous sûr de vouloir confirmer cette commande en date du %s ? GenerateBill=Facturer ClassifyShipped=Classer livrée +PassedInShippedStatus=classée livrée +YouCantShipThis=Classement impossible : veuillez vérifier les droits utilisateur +MustBeValidatedBefore=doit être Validée ou En cours de livraison pour pouvoir être classée livrée DraftOrders=Commandes brouillons DraftSuppliersOrders=Commandes fournisseurs brouillons OnProcessOrders=Commandes en cours de traitement From cfabaea645a9f8bbe0ad23b668ae770c26264ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Fri, 4 Mar 2022 17:38:39 +0100 Subject: [PATCH 106/752] translation refining --- htdocs/langs/en_US/orders.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index e94153db1a9..cbe9cca4d7a 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -104,7 +104,7 @@ GenerateBill=Generate invoice ClassifyShipped=Classify delivered PassedInShippedStatus=classified delivered YouCantShipThis=I can't classify this. Please check user permissions -MustBeValidatedBefore=must be Validated or Shipping in order to be classified as shipped +MustBeValidatedBefore=must be Validated or In process in order to be classified as shipped DraftOrders=Draft orders DraftSuppliersOrders=Draft purchase orders OnProcessOrders=In process orders From 87b187bded77fc30f63a30986a45619906366e97 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 8 Mar 2022 03:43:40 +0100 Subject: [PATCH 107/752] FIX #20279 Accountancy - PostGreSQL - Error on mass update lines already binded --- htdocs/accountancy/customer/lines.php | 6 +++--- htdocs/accountancy/supplier/lines.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index c45e7b27b0a..63314208883 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -121,9 +121,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { { $db->begin(); - $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); - $sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')'; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); + $sql1 .= ' WHERE rowid IN ('.implode(',', $changeaccount).')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1); $resql1 = $db->query($sql1); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 30976287769..2edf3d01791 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -123,9 +123,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { { $db->begin(); - $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l"; - $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); - $sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')'; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); + $sql1 .= ' WHERE rowid IN ('.implode(',', $changeaccount).')'; dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1); $resql1 = $db->query($sql1); From 397776d4a42edeaddd7a36ece03ae833020b276a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 8 Mar 2022 11:29:01 +0100 Subject: [PATCH 108/752] FIX check mandatory thirdparty fields for mass action --- htdocs/compta/facture/card.php | 39 ----------------- htdocs/compta/facture/class/facture.class.php | 42 ++++++++++++++++++- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d3e5a0062b0..573f1548b9a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -566,45 +566,6 @@ if (empty($reshook)) // Check parameters - // Check for mandatory fields in thirdparty (defined into setup) - $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); - foreach ($array_to_check as $key) - { - $keymin = strtolower($key); - $i = (int) preg_replace('/[^0-9]/', '', $key); - $vallabel = $object->thirdparty->$keymin; - - if ($i > 0) - { - if ($object->thirdparty->isACompany()) - { - // Check for mandatory prof id (but only if country is other than ours) - if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) - { - $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; - if (!$vallabel && !empty($conf->global->$idprof_mandatory)) - { - $langs->load("errors"); - $error++; - setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $object->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors'); - } - } - } - } else { - //var_dump($conf->global->SOCIETE_EMAIL_MANDATORY); - if ($key == 'EMAIL') - { - // Check for mandatory - if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email)) - { - $langs->load("errors"); - $error++; - setEventMessages($langs->trans("ErrorBadEMail", $object->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors'); - } - } - } - } - // Check for mandatory fields in invoice $array_to_check = array('REF_CUSTOMER'=>'RefCustomer'); foreach ($array_to_check as $key => $val) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 63a7b2f8e21..6ae01621b2e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2470,7 +2470,7 @@ class Facture extends CommonInvoice */ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0) { - global $conf, $langs; + global $conf, $langs, $mysoc; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $productStatic = null; @@ -2512,6 +2512,46 @@ class Facture extends CommonInvoice return -1; } + // Check for mandatory fields in thirdparty (defined into setup) + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + foreach ($array_to_check as $key) + { + $keymin = strtolower($key); + $i = (int) preg_replace('/[^0-9]/', '', $key); + $vallabel = $this->thirdparty->$keymin; + + if ($i > 0) + { + if ($this->thirdparty->isACompany()) + { + // Check for mandatory prof id (but only if country is other than ours) + if ($mysoc->country_id > 0 && $this->thirdparty->country_id == $mysoc->country_id) + { + $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) + { + $langs->load("errors"); + $this->error = $langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $this->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')'.' ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } else { + if ($key == 'EMAIL') + { + // Check for mandatory + if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($this->thirdparty->email)) + { + $langs->load("errors"); + $this->error = $langs->trans("ErrorBadEMail", $this->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')'.' ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } + $this->db->begin(); // Check parameters From 19ad2310125a57069ae76ef774664ac051996c03 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 8 Mar 2022 12:02:05 +0100 Subject: [PATCH 109/752] FIX stickler-ci --- htdocs/compta/facture/class/facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6ae01621b2e..00734ccb680 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2531,7 +2531,7 @@ class Facture extends CommonInvoice if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); - $this->error = $langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $this->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')'.' ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + $this->error = $langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $this->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); return -1; } @@ -2544,7 +2544,7 @@ class Facture extends CommonInvoice if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($this->thirdparty->email)) { $langs->load("errors"); - $this->error = $langs->trans("ErrorBadEMail", $this->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')'.' ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + $this->error = $langs->trans("ErrorBadEMail", $this->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); return -1; } From 6e08115aa2f4794dda3ba330691b1722e87e3710 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 1 Mar 2022 14:52:19 +0100 Subject: [PATCH 110/752] introduce constant INVOICE_CHECK_POSTERIOR_DATE in Facture module --- htdocs/core/modules/modFacture.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index fac768b9c60..2d1a742a304 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -106,6 +106,13 @@ class modFacture extends DolibarrModules $this->const[$r][4] = 0; $r++;*/ + $this->const[$r][0] = "INVOICE_CHECK_POSTERIOR_DATE"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = 0; + $this->const[$r][3] = "When validating an invoice, check that its date is posterior to last invoice date for invoices of same type."; + $this->const[$r][4] = 0; + $r++; + // Boxes //$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php')); From 02693ba5eab08ed1d3de0ce5994a5e0d40c751a0 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 1 Mar 2022 15:22:46 +0100 Subject: [PATCH 111/752] Facture : add config option for INVOICE_CHECK_POSTERIOR_DATE --- htdocs/admin/facture.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 9eec54b03a7..f2ab39f6fb4 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -225,6 +225,12 @@ if ($action == 'updateMask') { setEventMessages($langs->trans("Error"), null, 'errors'); } } +} elseif ($action == 'set_INVOICE_CHECK_POSTERIOR_DATE') { + $check_posterior_date = GETPOST('INVOICE_CHECK_POSTERIOR_DATE', 'int'); + $res = dolibarr_set_const($db, 'INVOICE_CHECK_POSTERIOR_DATE', $check_posterior_date, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } } @@ -761,6 +767,25 @@ print '\n"; print ''; + +print ''.$langs->trans("InvoiceCheckPosteriorDate"). ' ' ; +print $form->textwithpicto('', $langs->trans("InvoiceCheckPosteriorDateHelp"), 1, 'help') . ''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE'); +} else { + print '
'; + print ''; + print ''; + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("INVOICE_CHECK_POSTERIOR_DATE", $arrval, $conf->global->INVOICE_CHECK_POSTERIOR_DATE); +} +print ''; +print ''; +print ''; +print '
'; +print ''; + print ''; print ''; From ad416ef7925bc28c70f9bef882b971d6d5a72006 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 1 Mar 2022 16:18:34 +0100 Subject: [PATCH 112/752] Facture: create method willBeLastOfSameType() --- htdocs/compta/facture/class/facture.class.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 70aebe6932c..10bc1b0af62 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5123,6 +5123,38 @@ class Facture extends CommonInvoice return $error; } } + + /** + * See if current invoice date is posterior to the last invoice date among validated invoices of same type. + * @param bool $strict compare precise time or only days. + * @return boolean + */ + public function willBeLastOfSameType() + { + // get date of last validated invoices of same type + $sql = 'SELECT datef'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture'; + $sql .= ' WHERE type = ' . (int) $this->type ; + $sql .= ' AND date_valid IS NOT NULL'; + $sql .= ' ORDER BY datef DESC LIMIT 1'; + + $result = $this->db->query($sql); + if ($result) { + // compare with current validation date + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $last_date = $this->db->jdate($obj->datef); + $invoice_date = $this->date; + + return [$invoice_date >= $last_date, $last_date]; + } else { + // element is first of type to be validated + return [true]; + } + } else { + dol_print_error($this->db); + } + } } /** From eda9622c9ca769ac3a6782b3e5d57d949aac415b Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Wed, 2 Mar 2022 10:16:14 +0100 Subject: [PATCH 113/752] Facture: enhance validation by adding INVOICE_CHECK_POSTERIOR_DATE option --- htdocs/compta/facture/class/facture.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 10bc1b0af62..569f677e66b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2671,6 +2671,13 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); return -1; } + if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { + $last_of_type = $this->willBeLastOfSameType(); + if (!$last_of_type[0]) { + $this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref , dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day')); + return -1; + } + } $this->db->begin(); From 7c866ce6a2086355fbac0af97b1cb28a048fa783 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 1 Mar 2022 17:18:29 +0100 Subject: [PATCH 114/752] facture/card.php: avoid validating invoices with date anterior to last invoice date --- htdocs/compta/facture/card.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a4d85c257f8..f980d1c6bde 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -302,6 +302,15 @@ if (empty($reshook)) { // Validation $object->fetch($id); + if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { + $last_of_type = $object->willBeLastOfSameType(); + if (empty($object->date_validation) && !$last_of_type[0]) { + setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref , dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); + exit; + } + } + // On verifie signe facture if ($object->type == Facture::TYPE_CREDIT_NOTE) { // Si avoir, le signe doit etre negatif From 288663be3682dbd9bdab5600ce45338a4b082abc Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Wed, 2 Mar 2022 10:16:48 +0100 Subject: [PATCH 115/752] Facture mass validation: sort by date to avoid conflicts --- htdocs/core/actions_massactions.inc.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5a4ec3bf02f..4a5fe519acb 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1209,6 +1209,26 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } + if ($objecttmp->element == 'facture') { + if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) { + // order $toselect by date + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; + $sql .= ' WHERE rowid IN ('.$db->escape(implode(', ', $toselect)).')'; + $sql .= ' ORDER BY datef'; + + $resql = $db->query($sql); + if ($resql) { + $toselectnew = []; + while ( !empty($arr = $db->fetch_row($resql))) { + $toselectnew[] = $arr[0]; + } + $toselect = (empty($toselectnew)) ? $toselect : $toselectnew; + } else { + dol_print_error($db); + $error++; + } + } + } if (!$error) { $db->begin(); From 07672b23b92ca503e840c1b721632f1565e7d195 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 1 Mar 2022 17:24:28 +0100 Subject: [PATCH 116/752] Langs/bills.lang: add error string for invoice date check --- htdocs/langs/en_US/admin.lang | 2 ++ htdocs/langs/en_US/bills.lang | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cffd3532c05..fd86b2e7788 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1421,6 +1421,8 @@ WatermarkOnDraftInvoices=Watermark on draft invoices (none if empty) PaymentsNumberingModule=Payments numbering model SuppliersPayment=Vendor payments SupplierPaymentSetup=Vendor payments setup +InvoiceCheckPosteriorDate=Check facture date before validation +InvoiceCheckPosteriorDateHelp=Validating an invoice will be forbidden if its date is anterior to the date of last invoice of same type. ##### Proposals ##### PropalSetup=Commercial proposals module setup ProposalsNumberingModules=Commercial proposal numbering models diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 851323cadd9..993f5a21b2b 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -156,6 +156,7 @@ ErrorInvoiceAvoirMustBeNegative=Error, correct invoice must have a negative amou ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have an amount excluding tax positive (or null) ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice that has been replaced by another invoice that is still in draft status ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or another is already used so discount series cannot be removed. +ErrorInvoiceIsNotLastOfSameType=Error: The date of invoice %s is %s. It must be posterior or equal to last date for same type invoices (%s). Please change the invoice date. BillFrom=From BillTo=To ActionsOnBill=Actions on invoice From 9ce51ba4b73d8cdcdda5c858784faad004f9029b Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Wed, 2 Mar 2022 12:07:40 +0100 Subject: [PATCH 117/752] admin/facture: don't show the modify button if not in an HTML form --- htdocs/admin/facture.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index f2ab39f6fb4..599aac27c3f 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -779,11 +779,11 @@ if ($conf->use_javascript_ajax) { print ''; $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("INVOICE_CHECK_POSTERIOR_DATE", $arrval, $conf->global->INVOICE_CHECK_POSTERIOR_DATE); + print ''; + print ''; + print ''; + print ''; } -print ''; -print ''; -print ''; -print ''; print ''; print ''; From 4ad92a04fc78c45b4654710ef56eb55f62ac4ddb Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Wed, 2 Mar 2022 12:53:44 +0100 Subject: [PATCH 118/752] stickler corrections --- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f980d1c6bde..1540846d99a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -305,7 +305,7 @@ if (empty($reshook)) { if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { $last_of_type = $object->willBeLastOfSameType(); if (empty($object->date_validation) && !$last_of_type[0]) { - setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref , dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); + setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 569f677e66b..0d52e4b9fd0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2674,7 +2674,7 @@ class Facture extends CommonInvoice if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { $last_of_type = $this->willBeLastOfSameType(); if (!$last_of_type[0]) { - $this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref , dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day')); + $this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day')); return -1; } } @@ -5133,7 +5133,6 @@ class Facture extends CommonInvoice /** * See if current invoice date is posterior to the last invoice date among validated invoices of same type. - * @param bool $strict compare precise time or only days. * @return boolean */ public function willBeLastOfSameType() From 93765add38e9ad9754df340a6f20faf5a34b4429 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Wed, 2 Mar 2022 13:08:42 +0100 Subject: [PATCH 119/752] Travis fix, hopefully. --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4a5fe519acb..bdf13214717 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1213,7 +1213,7 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) { // order $toselect by date $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; - $sql .= ' WHERE rowid IN ('.$db->escape(implode(', ', $toselect)).')'; + $sql .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $toselect)).')'; $sql .= ' ORDER BY datef'; $resql = $db->query($sql); From 7f527b85b0c3bc83ee00d8df94a6de6a06a8455b Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Wed, 9 Mar 2022 09:34:50 +0100 Subject: [PATCH 120/752] use double quotes to compose SQL requests --- htdocs/compta/facture/class/facture.class.php | 10 +++++----- htdocs/core/actions_massactions.inc.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0d52e4b9fd0..5ca66ac0cd3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5138,11 +5138,11 @@ class Facture extends CommonInvoice public function willBeLastOfSameType() { // get date of last validated invoices of same type - $sql = 'SELECT datef'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facture'; - $sql .= ' WHERE type = ' . (int) $this->type ; - $sql .= ' AND date_valid IS NOT NULL'; - $sql .= ' ORDER BY datef DESC LIMIT 1'; + $sql = "SELECT datef"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture"; + $sql .= " WHERE type = " . (int) $this->type ; + $sql .= " AND date_valid IS NOT NULL"; + $sql .= " ORDER BY datef DESC LIMIT 1"; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index bdf13214717..39d99c4a03b 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1212,9 +1212,9 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { if ($objecttmp->element == 'facture') { if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) { // order $toselect by date - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; - $sql .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $toselect)).')'; - $sql .= ' ORDER BY datef'; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture"; + $sql .= " WHERE rowid IN (".$db->sanitize(implode(",", $toselect)).")"; + $sql .= " ORDER BY datef"; $resql = $db->query($sql); if ($resql) { From 8ddd37a4190f7dd9a508662ee4aae232077038a3 Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Wed, 9 Mar 2022 13:16:09 +0100 Subject: [PATCH 121/752] Enabled to add links to local object with local browser in email templates It is forbidden by default --- htdocs/admin/mails_templates.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 25a33717c46..6280db04b15 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -739,7 +739,7 @@ if ($action == 'view') { if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 180, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%'); + $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 180, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_4, '90%'); print $doleditor->Create(1); } print ''; @@ -969,7 +969,7 @@ if ($resql) { if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_6, '90%'); print $doleditor->Create(1); } print ''; @@ -1134,7 +1134,7 @@ if ($resql) { $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist.'-'.$i, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%', 1); + $doleditor = new DolEditor($tmpfieldlist.'-'.$i, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_6, '90%', 1); print $doleditor->Create(1); print ''; print ''; From 25fcb83b7490c6abbedbcb953fcc6c30ebbd7c06 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 9 Mar 2022 16:41:26 +0100 Subject: [PATCH 122/752] wip: reopen button --- htdocs/compta/facture/card.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5b4acb040d6..c974a1b053c 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5409,9 +5409,12 @@ if ($action == 'create') { && ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) { // A paid invoice (partially or completely) if ($object->close_code != 'replaced' || (!$objectidnext)) { // Not replaced by another invoice or replaced but the replacement invoice has been deleted - print ''.$langs->trans('ReOpen').''; + //print ''.$langs->trans('ReOpen').''; + print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=reopen&token='.newToken(), '', true, $params); } else { - print ''.$langs->trans('ReOpen').''; + //print ''.$langs->trans('ReOpen').''; + $params['attr']['title'] = $langs->trans("DisabledBecauseReplacedInvoice"); + print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', '#', '', false, $params); } } From c3b22ed26ec1773556140ec2e54e6d62d0e3430a Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 9 Mar 2022 17:10:53 +0100 Subject: [PATCH 123/752] wip: clean comments --- htdocs/compta/facture/card.php | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c974a1b053c..710ae01d1a6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5374,25 +5374,20 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) { if (!$objectidnext && $object->is_last_in_cycle()) { if ($usercanunvalidate) { - //print ''.$langs->trans('Modify').''; print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', true, $params); } else { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('NotEnoughPermissions'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', false, $params); } } elseif (!$object->is_last_in_cycle()) { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('NotLastInCycle'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } else { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } } } else { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } @@ -5409,10 +5404,8 @@ if ($action == 'create') { && ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) { // A paid invoice (partially or completely) if ($object->close_code != 'replaced' || (!$objectidnext)) { // Not replaced by another invoice or replaced but the replacement invoice has been deleted - //print ''.$langs->trans('ReOpen').''; print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=reopen&token='.newToken(), '', true, $params); } else { - //print ''.$langs->trans('ReOpen').''; $params['attr']['title'] = $langs->trans("DisabledBecauseReplacedInvoice"); print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', '#', '', false, $params); } @@ -5433,7 +5426,6 @@ if ($action == 'create') { if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($usercanvalidate) { print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=valid&token='.newToken(), '', true, $params); - //print ''.$langs->trans('Validate').''; } } @@ -5444,10 +5436,8 @@ if ($action == 'create') { print ''.$langs->trans('SendMail').''; } else { if ($usercansend) { - //print ''.$langs->trans('SendMail').''; print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); } else { - //print ''.$langs->trans('SendMail').''; print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params); } } @@ -5485,7 +5475,6 @@ if ($action == 'create') { } else { if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) { // For down payment, we refuse to receive more than amount to pay. - //print ''.$langs->trans('DoPayment').''; $params['attr']['title'] = $langs->trans('DisabledBecauseRemainderToPayIsZero'); print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', '#', '', false, $params); } else { @@ -5540,11 +5529,9 @@ if ($action == 'create') { ) { if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpaymentall, 'MT')) { // We can close a down payment only if paid amount is same than amount of down payment (by definition) - //print ''.$langs->trans('ClassifyPaid').''; $params['attr']['title'] = $langs->trans('AmountPaidMustMatchAmountOfDownPayment'); print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', '#', '', false, $params); } else { - //print ''.$langs->trans('ClassifyPaid').''; print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid', '', true, $params); } } @@ -5590,14 +5577,12 @@ if ($action == 'create') { // Clone if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) { - //print ''.$langs->trans("ToClone").''; print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=clone&object=invoice', '', true, $params); } // Clone as predefined / Create template if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) { if (!$objectidnext && count($object->lines) > 0) { - //print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; print dolGetButtonAction($langs->trans('ChangeIntoRepeatableInvoice'), '', 'default', DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$object->id.'&action=create', '', true, $params); } } @@ -5638,35 +5623,26 @@ if ($action == 'create') { ) ); if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) - //var_dump($isErasable); $enableDelete = false; $deleteHref = '#'; if ($isErasable == -4) { $params['attr']['title'] = $langs->trans('DisabledBecausePayments'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -3) { $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastSituationInvoice'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -2) { $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastInvoice'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -1) { $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable <= 0) { // Any other cases $params['attr']['title'] = $langs->trans('DisabledBecauseNotErasable'); - //print ''.$langs->trans('Delete').''; } elseif ($objectidnext) { $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); - //print ''.$langs->trans('Delete').''; } else { - //print ''.$langs->trans('Delete').''; $deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken(); $enableDelete = true; } print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteHref, '', $enableDelete, $params); } else { - //print ''.$langs->trans('Delete').''; $params['attr']['title'] = $langs->trans('NotAllowed'); print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false, $params); } From 3a5a74478f7f359bac4934f2804ae08437bd3a75 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 18:05:07 +0100 Subject: [PATCH 124/752] Add auther notif --- htdocs/core/class/notify.class.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 853de6d0a41..7e011482f43 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -69,7 +69,9 @@ class Notify 'ORDER_CREATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', + 'PROPAL_CLOSE_REFUSED', 'PROPAL_CLOSE_SIGNED', + 'PROPAL_SENTBYMAIL', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', @@ -80,7 +82,8 @@ class Notify 'EXPENSE_REPORT_APPROVE', 'HOLIDAY_VALIDATE', 'HOLIDAY_APPROVE', - 'ACTION_CREATE' + 'ACTION_CREATE', + 'FUNDING_SENTBYMAIL', ); /** @@ -577,6 +580,13 @@ class Notify $labeltouse = $conf->global->ACTION_CREATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextActionAdded", $link); break; + default: + $object_type = $object->element; + $dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type); + $template = $notifcode.'_TEMPLATE'; + $labeltouse = $conf->global->$template; + $mesg = $outputlangs->transnoentitiesnoconv('Notify_'.$notifcode).' '.$newref.' '.$dir_output; + break; } include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -812,9 +822,14 @@ class Notify $object_type = 'action'; $mesg = $langs->transnoentitiesnoconv("EMailTextActionAdded", $link); break; + default: + $object_type = $object->element; + $dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type); + $mesg = $langs->transnoentitiesnoconv('Notify_'.$notifcode).' '.$newref; + break; } $ref = dol_sanitizeFileName($newref); - $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; + $pdf_path = $dir_output."/".$ref.".pdf"; if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; From 032b8692b1b7425a7ee82bc834f3b32683a6d0a1 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 19:42:17 +0100 Subject: [PATCH 125/752] Add hook --- ...ce_50_modNotification_Notification.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index fe89a05ab20..3c52f89cd41 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -90,9 +90,26 @@ class InterfaceNotification extends DolibarrTriggers public function getListOfManagedEvents() { global $conf; + global $hookmanager; + + + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } + $hookmanager->initHooks(array('notification')); + + $parameters = array('arrayofnotifsupported'=>$arrayofnotifsupported); + $reshook = $hookmanager->executeHooks('notifsupported', $parameters); + if (empty($reshook)) { + if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { + $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']); + } + } $ret = array(); + $sql = "SELECT rowid, code, label, description, elementtype"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger"; $sql .= $this->db->order("rang, elementtype, code"); From e1e573c532d9e00bf86c1b0c1be0f401f57f69fd Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 19:55:40 +0100 Subject: [PATCH 126/752] Add Hook --- htdocs/core/class/notify.class.php | 21 ++++++++++++------- ..._50_modNotification_Notification.class.php | 3 +-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 7e011482f43..df5f19a64bf 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -71,7 +71,6 @@ class Notify 'PROPAL_VALIDATE', 'PROPAL_CLOSE_REFUSED', 'PROPAL_CLOSE_SIGNED', - 'PROPAL_SENTBYMAIL', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', @@ -83,7 +82,6 @@ class Notify 'HOLIDAY_VALIDATE', 'HOLIDAY_APPROVE', 'ACTION_CREATE', - 'FUNDING_SENTBYMAIL', ); /** @@ -358,17 +356,26 @@ class Notify global $dolibarr_main_url_root; global $action; - if (!in_array($notifcode, Notify::$arrayofnotifsupported)) { - return 0; - } - - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('notification')); + + $reshook = $hookmanager->executeHooks('notifsupported'); + if (empty($reshook)) { + if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { + Notify::$arrayofnotifsupported = array_merge(Notify::$arrayofnotifsupported, $hookmanager->resArray['arrayofnotifsupported']); + } + } + + if (!in_array($notifcode, Notify::$arrayofnotifsupported)) { + return 0; + } + + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id); $langs->load("other"); diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 3c52f89cd41..2013933e54b 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -99,8 +99,7 @@ class InterfaceNotification extends DolibarrTriggers } $hookmanager->initHooks(array('notification')); - $parameters = array('arrayofnotifsupported'=>$arrayofnotifsupported); - $reshook = $hookmanager->executeHooks('notifsupported', $parameters); + $reshook = $hookmanager->executeHooks('notifsupported'); if (empty($reshook)) { if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']); From 1a5beb0664ec00a373695c01bfe0ff2fe7b8c2fc Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 9 Mar 2022 19:55:55 +0100 Subject: [PATCH 127/752] Fix style --- htdocs/core/class/notify.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index df5f19a64bf..1078c02e362 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -375,7 +375,7 @@ class Notify } include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - + dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id); $langs->load("other"); From c9cc067075bcc0f7c3c7cc8b436c4eb031f94557 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 11 Mar 2022 10:48:51 +0100 Subject: [PATCH 128/752] FIX missing parenthesis --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 9e6e68a2ee9..a737da87e94 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -116,7 +116,7 @@ $usercandelete = $user->rights->propal->supprimer; $usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close))); $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate))); -$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send))); $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; From f2377627ec01cb8cecd5595a17db9c0684e65e33 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 11 Mar 2022 10:50:11 +0100 Subject: [PATCH 129/752] Add template custom module --- htdocs/admin/notification.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index db79a1503c9..f6d71fe6817 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -267,6 +267,7 @@ $constantes = array(); foreach ($listofnotifiedevents as $notifiedevent) { $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); + $model = $notifiedevent['elementtype'].'_send'; if ($notifiedevent['elementtype'] == 'order_supplier') { $elementLabel = $langs->trans('SupplierOrder'); From 80a2499844965950a154c3ff9397d9a7a9c931f3 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 11 Mar 2022 11:25:49 +0100 Subject: [PATCH 130/752] Clean --- htdocs/core/class/notify.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 1078c02e362..0b92cc47a70 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -69,7 +69,6 @@ class Notify 'ORDER_CREATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', - 'PROPAL_CLOSE_REFUSED', 'PROPAL_CLOSE_SIGNED', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', From 899598bbb348d7afe551b18339c255f95cc8ccf1 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Sat, 12 Mar 2022 16:50:48 +0100 Subject: [PATCH 131/752] Cop --- htdocs/admin/notification.php | 3 ++- htdocs/core/class/notify.class.php | 1 + .../interface_50_modNotification_Notification.class.php | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index f6d71fe6817..ac32d01522d 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -1,9 +1,10 @@ * Copyright (C) 2005-2015 Laurent Destailleur - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2022 Anthony Berton * * 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 diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 0b92cc47a70..8e72d8e4773 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2018 Philippe Grand * Copyright (C) 2021 Thibault FOUCART + * Copyright (C) 2022 Anthony Berton * * 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 diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 2013933e54b..b32b63ba3d0 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2011 Regis Houssin * Copyright (C) 2013-2014 Marcos García + * Copyright (C) 2022 Anthony Berton * * 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 From 316380afd26f4eeca65f5affb3e066508a25b535 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Sat, 12 Mar 2022 23:41:16 +0100 Subject: [PATCH 132/752] 1 --- htdocs/core/class/notify.class.php | 4 ++-- .../interface_50_modNotification_Notification.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 8e72d8e4773..5bb448ad11d 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -81,7 +81,7 @@ class Notify 'EXPENSE_REPORT_APPROVE', 'HOLIDAY_VALIDATE', 'HOLIDAY_APPROVE', - 'ACTION_CREATE', + 'ACTION_CREATE' ); /** @@ -363,7 +363,7 @@ class Notify $hookmanager->initHooks(array('notification')); - $reshook = $hookmanager->executeHooks('notifsupported'); + $reshook = $hookmanager->executeHooks('notifsupported', $parameters, $object, $action); if (empty($reshook)) { if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { Notify::$arrayofnotifsupported = array_merge(Notify::$arrayofnotifsupported, $hookmanager->resArray['arrayofnotifsupported']); diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index b32b63ba3d0..6e4f8cb1563 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -100,7 +100,7 @@ class InterfaceNotification extends DolibarrTriggers } $hookmanager->initHooks(array('notification')); - $reshook = $hookmanager->executeHooks('notifsupported'); + $reshook = $hookmanager->executeHooks('notifsupported', $parameters, $object, $action); if (empty($reshook)) { if (!empty($hookmanager->resArray['arrayofnotifsupported'])) { $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray['arrayofnotifsupported']); From 3eebbc0b14c8eb9f4d5a283651eb61b531ac9e29 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 14 Mar 2022 09:24:26 +0100 Subject: [PATCH 133/752] Fix #20263 Accountancy setup displayed with right Fix #20263 Accountancy setup is displayed only for user with rights->accounting->chartofaccount --- htdocs/accountancy/index.php | 151 ++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index f44b5bc72f8..c71e51ed427 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -93,88 +93,89 @@ if ($conf->accounting->enabled) print '
'; // hideobject is to start hidden print "
\n"; print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; - print "
\n"; print "
\n"; + if (!empty($user->rights->accounting->chartofaccount)){ + print "
\n"; print "
\n"; - print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; - print '
'; - print "
\n"; + print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; + print '
'; + print "
\n"; - // STEPS - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").''); - print "
\n"; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").''); - print "
\n"; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").''); - print "
\n"; + // STEPS + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").''); + print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").''); + print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").''); + print "
\n"; - print "
\n"; - print $langs->trans("AccountancyAreaDescActionOnceBis"); - print "
\n"; - print "
\n"; + print "
\n"; + print $langs->trans("AccountancyAreaDescActionOnceBis"); + print "
\n"; + print "
\n"; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
\n"; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'')."\n"; - print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'')."\n"; + print "
\n"; - $step++; - $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); - print "
\n"; - if (!empty($conf->tax->enabled)) - { - $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); - print "
\n"; + $step++; + $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); + print "
\n"; + if (!empty($conf->tax->enabled)) + { + $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); + print "
\n"; + } + /*if (! empty($conf->salaries->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + // htdocs/admin/salaries.php + print "
\n"; + print "
\n"; + }*/ + if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); + print "
\n"; + } + /* + if (! empty($conf->loan->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
\n"; + } + if (! empty($conf->don->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
\n"; + } + if (! empty($conf->adherents->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
\n"; + }*/ + + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").''); + print "
\n"; + + print '
'; } - /*if (! empty($conf->salaries->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - // htdocs/admin/salaries.php - print "
\n"; - print "
\n"; - }*/ - if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); - print "
\n"; - } - /* - if (! empty($conf->loan->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
\n"; - } - if (! empty($conf->don->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
\n"; - } - if (! empty($conf->adherents->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
\n"; - }*/ - - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").''); - print "
\n"; - - - print '
'; - + // Step A - E print "
\n"; From 19be5f662d9fdbdb443a665da539519778fa0084 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 14 Mar 2022 08:25:15 +0000 Subject: [PATCH 134/752] Fixing style errors. --- htdocs/accountancy/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index c71e51ed427..b0305050840 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -175,7 +175,7 @@ if ($conf->accounting->enabled) print '
'; } - + // Step A - E print "
\n"; From 8d11813ea5fbefc3cfbb6e3295dc8fd5fcfc8d3d Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 14 Mar 2022 11:45:23 +0100 Subject: [PATCH 135/752] fix security problems and add zstd support --- htdocs/core/lib/files.lib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 86c740c4f44..37bc946a8b6 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2146,22 +2146,24 @@ function dol_uncompress($inputfile, $outputdir) } return array('error'=>'ErrNoZipEngine'); - } elseif ($fileinfo["extension"] == "gz" || $fileinfo["extension"] == "bz2") { + } elseif (in_array($fileinfo["extension"], array('gz','bz2','zst'))) { $extension = pathinfo($fileinfo["filename"], PATHINFO_EXTENSION); if ($extension == "tar") { - $cmd = "tar -C ".$outputdir." -xvf ".$fileinfo["dirname"]."/".$fileinfo["basename"]; + $cmd = 'tar -C '.escapeshellcmd(dol_sanitizePathName($outputdir)).' -xvf '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"])); $resarray = $utils->executeCLI($cmd, $outputdir); } else { $program = ""; if ($fileinfo["extension"] == "gz") { - $program = "gzip"; + $program = 'gzip'; } elseif ($fileinfo["extension"] == "bz2") { - $program = "bzip2"; + $program = 'bzip2'; + } elseif ($fileinfo["extension"] == "zst") { + $program = 'zstd'; } else { return array('error'=>'ErrFileExtension'); } - $cmd = $program." -dc ".$fileinfo["dirname"]."/".$fileinfo["basename"]; - $outputfilename = $outputdir."/".$fileinfo["filename"]; + $cmd = $program.' -dc '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"])); + $outputfilename = escapeshellcmd(dol_sanitizePathName($outputdir).'/'.dol_sanitizeFileName($fileinfo["filename"])); $resarray = $utils->executeCLI($cmd, $outputfilename, 0, $outputfilename); if ($resarray["output"] == 2) { $resarray["error"] = "ErrFilePermOrFileNotFound"; From 1555a95ce881bcc8c278c43426c98d784fa63226 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 14 Mar 2022 16:50:43 +0100 Subject: [PATCH 136/752] Activate new rights read and write --- htdocs/core/modules/modHRM.class.php | 16 ++++++ htdocs/langs/en_US/admin.lang | 2 + htdocs/user/bank.php | 86 ++++++++++++++++------------ 3 files changed, 66 insertions(+), 38 deletions(-) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 3e75f8efcd5..35deea09a07 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -249,6 +249,22 @@ class modHRM extends DolibarrModules $this->rights[$r][4] = 'compare_advance'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) $r++; + + // Read employee + $this->rights[$r][0] = 4031; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read employee'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read_employee'; + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->read_employee->read) + $r++; + + // Write employee + $this->rights[$r][0] = 4032; // Permission id (must not be already used) + $this->rights[$r][1] = 'Write employee'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write_employee'; + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_employee->write) + $r++; } /** diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cffd3532c05..6674f6cb58a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -969,6 +969,8 @@ Permission4021=Create/modify your evaluation Permission4022=Validate evaluation Permission4023=Delete evaluation Permission4030=See comparison menu +Permission4031=Read employee +Permission4032=Write employee Permission10001=Read website content Permission10002=Create/modify website content (html and javascript content) Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers. diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 38b6066e9d2..d9bbb16f3aa 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -78,8 +78,8 @@ if (empty($account->userid)) { // Define value to know what current user can do on users -$canadduser = (!empty($user->admin) || $user->rights->user->user->creer); -$canreaduser = (!empty($user->admin) || $user->rights->user->user->lire); +$canadduser = (!empty($user->admin) || $user->rights->user->user->creer || $user->rights->hrm->write_employee->write); +$canreaduser = (!empty($user->admin) || $user->rights->user->user->lire || $user->rights->hrm->read_employee->read); $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer)); // Ok if user->rights->salaries->read or user->rights->hrm->read @@ -281,7 +281,7 @@ llxHeader(null, $langs->trans("BankAccounts")); $head = user_prepare_head($object); -if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) { +if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer || $user->rights->hrm->write_employee->write)) { print '
'; print ''; print ''; @@ -446,31 +446,37 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac print "\n"; // Date of birth - print ''; - print ''; - print $form->editfieldkey("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer); - print ''; - print $form->editfieldval("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer, 'day', $object->birth); - print ''; - print "\n"; + if ($user->rights->hrm->read_employee->read || $user->rights->hrm->write_employee->write) { + print ''; + print ''; + print $form->editfieldkey("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer); + print ''; + print $form->editfieldval("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer, 'day', $object->birth); + print ''; + print "\n"; + } // Personal email - print ''; - print ''; - print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer); - print ''; - print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer, 'email', '', null, null, '', 0, 'dol_print_email'); - print ''; - print ''; + if ($user->rights->hrm->read_employee->read || $user->rights->hrm->write_employee->write) { + print ''; + print ''; + print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write); + print ''; + print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write, 'email', '', null, null, '', 0, 'dol_print_email'); + print ''; + print ''; + } // Personal phone - print ''; - print ''; - print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer); - print ''; - print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer, 'string', '', null, null, '', 0, 'dol_print_phone'); - print ''; - print ''; + if ($user->rights->hrm->read_employee->read || $user->rights->hrm->write_employee->write) { + print ''; + print ''; + print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write); + print ''; + print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write, 'string', '', null, null, '', 0, 'dol_print_phone'); + print ''; + print ''; + } if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; @@ -527,22 +533,26 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac } // Employee Number - print ''; - print ''; - print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer); - print ''; - print $form->editfieldval("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer, 'string', $object->ref_employee); - print ''; - print ''; + if ($user->rights->hrm->read_employee->read || $user->rights->hrm->write_employee->write) { + print ''; + print ''; + print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write); + print ''; + print $form->editfieldval("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write, 'string', $object->ref_employee); + print ''; + print ''; + } // National registration number - print ''; - print ''; - print $form->editfieldkey("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer); - print ''; - print $form->editfieldval("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer, 'string', $object->national_registration_number); - print ''; - print ''; + if ($user->rights->hrm->read_employee->read || $user->rights->hrm->write_employee->write) { + print ''; + print ''; + print $form->editfieldkey("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write); + print ''; + print $form->editfieldval("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_employee->write, 'string', $object->national_registration_number); + print ''; + print ''; + } print ''; From ab87d772c71e0c07fedd1e009c9e9daf0f6aeae1 Mon Sep 17 00:00:00 2001 From: GregM Date: Thu, 17 Mar 2022 15:20:23 +0100 Subject: [PATCH 137/752] update GRH extrafields and more stuff --- htdocs/core/menus/standard/eldy.lib.php | 44 +++--- htdocs/hrm/admin/evaluation_extrafields.php | 143 ++++++++++++++++++++ htdocs/hrm/admin/job_extrafields.php | 143 ++++++++++++++++++++ htdocs/hrm/admin/skill_extrafields.php | 143 ++++++++++++++++++++ htdocs/hrm/evaluation_card.php | 7 +- htdocs/hrm/job_card.php | 4 +- htdocs/hrm/lib/hrm.lib.php | 15 ++ htdocs/hrm/lib/hrm_evaluation.lib.php | 34 +++++ htdocs/hrm/position.php | 4 +- htdocs/hrm/skill_card.php | 19 ++- htdocs/hrm/skill_tab.php | 5 + htdocs/langs/en_US/hrm.lang | 6 + 12 files changed, 535 insertions(+), 32 deletions(-) create mode 100644 htdocs/hrm/admin/evaluation_extrafields.php create mode 100644 htdocs/hrm/admin/job_extrafields.php create mode 100644 htdocs/hrm/admin/skill_extrafields.php diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index efe8d87ff86..77f0077ced4 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2110,7 +2110,7 @@ function get_left_menu_products($mainmenu, &$newmenu, $usemenuhider = 1, $leftme function get_left_menu_mrp($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0) { global $user, $conf, $langs; - + if ($mainmenu == 'mrp') { // BOM if (!empty($conf->bom->enabled) || !empty($conf->mrp->enabled)) { @@ -2144,7 +2144,7 @@ function get_left_menu_mrp($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = function get_left_menu_projects($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0) { global $user, $conf, $langs; - + if ($mainmenu == 'project') { if (!empty($conf->projet->enabled)) { $langs->load("projects"); @@ -2228,30 +2228,28 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->rights->user->user->creer); $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->rights->user->user->lire); - $newmenu->add("/hrm/index.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillsManagement"), 0, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"')); + $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillsManagement"), 0, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"')); - if ($usemenuhider || empty($leftmenu) || $leftmenu == "hrm_sm") { - // Skills - $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Skills"), 1, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="pictofixedwidth"')); - //$newmenu->add("/hrm/skill_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewSkill"), 1, $user->rights->hrm->all->write); - //$newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->all->read); + // Skills + $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Skills"), 1, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="pictofixedwidth"')); + //$newmenu->add("/hrm/skill_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewSkill"), 1, $user->rights->hrm->all->write); + //$newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->all->read); - // Job (Description of work to do and skills required) - $newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("JobsPosition"), 1, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'technic', 'class="pictofixedwidth"')); - //$newmenu->add("/hrm/job_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Job")), 1, $user->rights->hrm->all->write); - //$newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->all->read); + // Job (Description of work to do and skills required) + $newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("JobsPosition"), 1, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'technic', 'class="pictofixedwidth"')); + //$newmenu->add("/hrm/job_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Job")), 1, $user->rights->hrm->all->write); + //$newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->all->read); - // Position = Link job - user - $newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("EmployeePositions"), 1, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user-cog', 'class="pictofixedwidth"')); - //$newmenu->add("/hrm/position.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Position")), 1, $user->rights->hrm->all->write); - //$newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->all->read); + // Position = Link job - user + $newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("EmployeePositions"), 1, $user->rights->hrm->all->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user-cog', 'class="pictofixedwidth"')); + //$newmenu->add("/hrm/position.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Position")), 1, $user->rights->hrm->all->write); + //$newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->all->read); - // Evaluation - $newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Evalutions"), 1, $user->rights->hrm->evaluation->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"')); - //$newmenu->add("/hrm/evaluation_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewEval"), 1, $user->rights->hrm->evaluation->write); - //$newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->evaluation->read); - $newmenu->add("/hrm/compare.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillComparison"), 1, $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read); - } + // Evaluation + $newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Evals"), 1, $user->rights->hrm->evaluation->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"')); + //$newmenu->add("/hrm/evaluation_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewEval"), 1, $user->rights->hrm->evaluation->write); + //$newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->evaluation->read); + $newmenu->add("/hrm/compare.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillComparison"), 1, $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read); } // Leave/Holiday/Vacation module @@ -2325,7 +2323,7 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = 'none', $type_user = 0) { global $user, $conf, $langs; - + if ($mainmenu == 'tools') { if (empty($user->socid)) { // limit to internal users $langs->load("mails"); diff --git a/htdocs/hrm/admin/evaluation_extrafields.php b/htdocs/hrm/admin/evaluation_extrafields.php new file mode 100644 index 00000000000..a9614ccd03f --- /dev/null +++ b/htdocs/hrm/admin/evaluation_extrafields.php @@ -0,0 +1,143 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file admin/evaluation_extrafields.php + * \ingroup hrm + * \brief Page to setup extra fields of hrm + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once '../lib/hrm.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('hrm', 'admin')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'hrm_evaluation'; //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 + */ + +$help_url = ''; +$page_name = "HrmSetup"; + +llxHeader('', $langs->trans("HrmSetup"), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + + +$head = hrmAdminPrepareHead(); + +print dol_get_fiche_head($head, 'evaluationsAttributes', $langs->trans($page_name), -1, 'hrm@hrm'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') { + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* + * Creation of an optional field + */ +if ($action == 'create') { + print '
'; + 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 "
"; + 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(); diff --git a/htdocs/hrm/admin/job_extrafields.php b/htdocs/hrm/admin/job_extrafields.php new file mode 100644 index 00000000000..4b0d76e5187 --- /dev/null +++ b/htdocs/hrm/admin/job_extrafields.php @@ -0,0 +1,143 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file admin/job_extrafields.php + * \ingroup hrm + * \brief Page to setup extra fields of hrm + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once '../lib/hrm.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('hrm', 'admin')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'hrm_job'; //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 + */ + +$help_url = ''; +$page_name = "HrmSetup"; + +llxHeader('', $langs->trans("Setup"), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + + +$head = hrmAdminPrepareHead(); + +print dol_get_fiche_head($head, 'jobsAttributes', $langs->trans($page_name), -1, 'hrm@job'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') { + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* + * Creation of an optional field + */ +if ($action == 'create') { + print '
'; + 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 "
"; + 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(); diff --git a/htdocs/hrm/admin/skill_extrafields.php b/htdocs/hrm/admin/skill_extrafields.php new file mode 100644 index 00000000000..f8d123cce74 --- /dev/null +++ b/htdocs/hrm/admin/skill_extrafields.php @@ -0,0 +1,143 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file admin/skill_extrafields.php + * \ingroup hrm + * \brief Page to setup extra fields of hrm + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once '../lib/hrm.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('hrm', 'admin')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'hrm_skill'; //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 + */ + +$help_url = ''; +$page_name = "HrmSetup"; + +llxHeader('', $langs->trans("HrmSetup"), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + + +$head = hrmAdminPrepareHead(); + +print dol_get_fiche_head($head, 'skillsAttributes', $langs->trans($page_name), -1, 'hrm@skill'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') { + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* + * Creation of an optional field + */ +if ($action == 'create') { + print '
'; + 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 "
"; + 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(); diff --git a/htdocs/hrm/evaluation_card.php b/htdocs/hrm/evaluation_card.php index 7b0b7bcfd7d..3a9b73575d8 100644 --- a/htdocs/hrm/evaluation_card.php +++ b/htdocs/hrm/evaluation_card.php @@ -112,8 +112,8 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/hrm/evaluation_list.php', 1); - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (!empty($backtopage) || ($cancel && empty($id))) { + if (!empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { @@ -159,6 +159,7 @@ if (empty($reshook)) { $line->rankorder = $TNote[$line->fk_skill]; $line->update($user); } + setEventMessage($langs->trans("SaveLevelSkill")); } } @@ -569,7 +570,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '' . $langs->trans("Description") . ''; print '' . $langs->trans("EmployeeRank") . ''; print '' . $langs->trans("RequiredRank") . ''; - print '' . $langs->trans("Result") . ''; + print '' . $langs->trans("Result") . ' ' .$form->textwithpicto('', GetLegendSkills(), 1) .''; print ''; $sk = new Skill($db); diff --git a/htdocs/hrm/job_card.php b/htdocs/hrm/job_card.php index 906eb83b945..4bf2f7d1ac1 100644 --- a/htdocs/hrm/job_card.php +++ b/htdocs/hrm/job_card.php @@ -106,8 +106,8 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/hrm/job_list.php', 1); - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (!empty($backtopage) || ($cancel && empty($id))) { + if (!empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { diff --git a/htdocs/hrm/lib/hrm.lib.php b/htdocs/hrm/lib/hrm.lib.php index e875f61b9e4..508cbef22fd 100644 --- a/htdocs/hrm/lib/hrm.lib.php +++ b/htdocs/hrm/lib/hrm.lib.php @@ -48,6 +48,21 @@ function hrmAdminPrepareHead() $head[$h][2] = 'establishments'; $h++; + $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/evaluation_extrafields.php'; + $head[$h][1] = $langs->trans("EvaluationsExtraFields"); + $head[$h][2] = 'evaluationsAttributes'; + $h++; + + $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/job_extrafields.php'; + $head[$h][1] = $langs->trans("JobsExtraFields"); + $head[$h][2] = 'jobsAttributes'; + $h++; + + $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/skill_extrafields.php'; + $head[$h][1] = $langs->trans("SkillsExtraFields"); + $head[$h][2] = 'skillsAttributes'; + $h++; + /* $head[$h][0] = dol_buildpath("/workstation/admin/myobject_extrafields.php", 1); $head[$h][1] = $langs->trans("ExtraFields"); diff --git a/htdocs/hrm/lib/hrm_evaluation.lib.php b/htdocs/hrm/lib/hrm_evaluation.lib.php index 87e6b80adaa..57a24878c52 100644 --- a/htdocs/hrm/lib/hrm_evaluation.lib.php +++ b/htdocs/hrm/lib/hrm_evaluation.lib.php @@ -93,3 +93,37 @@ function evaluationPrepareHead($object) return $head; } + +/** + * @return string + */ +function GetLegendSkills() +{ + global $langs; + $legendSkills = '
+ ' . $langs->trans('legend') . ' + + + + + + + + + + + + + + + + +
+ ' . $langs->trans('CompetenceAcquiredByOneOrMore') . '
+ ' . $langs->trans('MaxlevelGreaterThan') . '
+ ' . $langs->trans('MaxLevelEqualTo') . '
+ ' . $langs->trans('MaxLevelLowerThan') . '
+ ' . $langs->trans('SkillNotAcquired') . '
+
'; + return $legendSkills; +} diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index 86167ef4024..86f7a5c74d3 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -160,8 +160,8 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/hrm/position_list.php', 1); //$backtopage = dol_buildpath('/hrm/position.php', 1) . '?fk_job=' . ($fk_job > 0 ? $fk_job : '__ID__'); - if (empty($backtopage) || ($cancel && empty($fk_job))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (!empty($backtopage) || ($cancel && empty($fk_job))) { + if (!empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($fk_job) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index e1144f75866..546e4fd5acf 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -51,9 +51,16 @@ $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // Initialize technical objects $object = new Skill($db); +$extrafields = new ExtraFields($db); //$diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('skillcard', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + + // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); @@ -102,8 +109,8 @@ if (empty($reshook)) { $backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php'; - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (!empty($backtopage) || ($cancel && empty($id))) { + if (!empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { @@ -201,6 +208,9 @@ if ($action == 'create') { // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // SKILLDET ADD //@todo je stop ici ... à continuer (affichage des 5 skilled input pour create action @@ -247,6 +257,8 @@ if (($id || $ref) && $action == 'edit') { print ''; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // SKILLDET @@ -416,6 +428,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $object->fields['label']['visible']=0; // Already in banner include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + print ''; print '
'; diff --git a/htdocs/hrm/skill_tab.php b/htdocs/hrm/skill_tab.php index 1ed9e370839..0bbc039152c 100644 --- a/htdocs/hrm/skill_tab.php +++ b/htdocs/hrm/skill_tab.php @@ -123,6 +123,7 @@ if (empty($reshook)) { if ($ret < 0) setEventMessage($skillAdded->error, 'errors'); //else unset($TSkillsToAdd); } + if ($ret > 0) setEventMessage($langs->trans("SaveAddSkill")); } } elseif ($action == 'saveSkill') { if (!empty($TNote)) { @@ -135,10 +136,14 @@ if (empty($reshook)) { } } } + setEventMessage($langs->trans("SaveLevelSkill")); + header("Location: " . dol_buildpath('/hrm/skill_tab.php', 1) . '?id=' . $id. '&objecttype=job'); + exit; } } elseif ($action == 'confirm_deleteskill' && $confirm == 'yes') { $skillToDelete = new SkillRank($db); $ret = $skillToDelete->fetch($lineid); + setEventMessage($langs->trans("DeleteSkill")); if ($ret > 0) { $skillToDelete->delete($user); } diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index ab3628026c5..ff917913eee 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -82,3 +82,9 @@ SkillComparison=Skill comparison ActionsOnJob=Events on this job VacantPosition=job vacancy VacantCheckboxHelper=Checking this option will show unfilled positions (job vacancy) +SaveAddSkill = Skill(s) added +SaveLevelSkill = Skill(s) level saved +DeleteSkill = Skill removed +SkillsExtraFields=Attributs supplémentaires (Compétences) +JobsExtraFields=Attributs supplémentaires (Emplois) +EvaluationsExtraFields=Attributs supplémentaires (Evaluations) From 4d01969a4c6bc88796b96f866c0dd79b9a58365d Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Wed, 2 Feb 2022 16:45:12 +0100 Subject: [PATCH 138/752] Societe: add method to find parent companies --- htdocs/societe/class/societe.class.php | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 89eeeaca8e5..8d0a836ae86 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3462,6 +3462,37 @@ class Societe extends CommonObject } } + /** + * Get parents for company + * + * @param int $company_id ID of company to search parent + * @param array $parents List of companies ID found + * @return array + */ + public function getParentsForCompany($company_id, $parents = []) + { + global $langs; + + if ($company_id > 0) { + $sql = "SELECT parent FROM " . MAIN_DB_PREFIX . "societe WHERE rowid = $company_id"; + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + $parent = $obj->parent; + if ($parent > 0 && !in_array($parent, $parents)) { + $parents[] = $parent; + return $this->getParentsForCompany($parent, $parents); + } else { + return $parents; + } + } + $this->db->free($resql); + } else { + setEventMessage($langs->trans('GetCompanyParentsError', $this->db->lasterror()), 'errors'); + } + } + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns if a profid sould be verified to be unique From a14a63fdad4d0f13469c9424c872405fb03ab526 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 3 Feb 2022 10:01:20 +0100 Subject: [PATCH 139/752] Contrat->getListOfContracts(): allow to sort contracts by contract status, product category, and line status. --- htdocs/contrat/class/contrat.class.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4e4437c1b2c..e6c73164f26 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2130,19 +2130,27 @@ class Contrat extends CommonObject /** * Return list of other contracts for same company than current contract * - * @param string $option 'all' or 'others' - * @return array|int Array of contracts id or <0 if error + * @param string $option 'all' or 'others' + * @param array $status sort contracts having these status + * @param array $product_categories sort contracts containing these product categories + * @param array $line_status sort contracts where lines have these status + * @return array|int Array of contracts id or <0 if error */ - public function getListOfContracts($option = 'all') + public function getListOfContracts($option = 'all', $status = [], $product_categories = [], $line_status = [] ) { $tab = array(); $sql = "SELECT c.rowid, c.ref"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql .= " WHERE fk_soc =".((int) $this->socid); - if ($option == 'others') { - $sql .= " AND c.rowid <> ".((int) $this->id); + if (!empty($product_categories)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON cd.fk_contrat = c.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = cd.fk_product AND cp.fk_categorie IN (".implode(', ', $product_categories).")"; } + $sql .= " WHERE c.fk_soc =".((int) $this->socid); + $sql .= ($option == 'others') ? " AND c.rowid <> ".((int) $this->id) : ""; + $sql .= (!empty($status)) ? " AND c.statut IN (".implode(', ', $status).")" : ""; + $sql .= (!empty($line_status)) ? " AND cd.statut IN (".implode(', ', $line_status).")" : ""; + $sql .= " GROUP BY c.rowid"; dol_syslog(get_class($this)."::getOtherContracts()", LOG_DEBUG); $resql = $this->db->query($sql); From 90ab7da40d37120caca3373a5b2256d30fca3872 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 3 Feb 2022 11:01:07 +0100 Subject: [PATCH 140/752] Workflow : sort contracts when automatic linking to ticket. Introduces constants TICKET_PRODUCT_CATEGORY and WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS. Rename constant TICKET_AUTO_ASSIGN_CONTRACT_CREATE to WORKFLOW_TICKET_LINK_CONTRACT. --- ...e_20_modWorkflow_WorkflowManager.class.php | 35 +++++++++++++++++++ .../install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ htdocs/langs/en_US/interventions.lang | 1 + htdocs/langs/en_US/ticket.lang | 2 ++ htdocs/ticket/card.php | 17 +-------- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 048dc170c0a..1e98ec885bd 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -424,6 +424,41 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } + if ($action == 'TICKET_CREATE') { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + // Auto link contract + if (!empty($conf->contract->enabled) && !empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_TICKET_LINK_CONTRACT) && !empty($conf->global->TICKET_PRODUCT_CATEGORY) && !empty($object->fk_soc)) { + + $societe = new Societe($this->db); + $company_ids = (empty($conf->global->WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS)) ? [$object->fk_soc] : $societe->getParentsForCompany($object->fk_soc, [$object->fk_soc]); + + $contrat = new Contrat($this->db); + $number_contracts_found = 0; + foreach ($company_ids as $company_id) { + $contrat->socid = $company_id; + + $list = $contrat->getListOfContracts($option = 'all', $status = [Contrat::STATUS_DRAFT, Contrat::STATUS_VALIDATED], $product_categories = [$conf->global->TICKET_PRODUCT_CATEGORY], $line_status = [ContratLigne::STATUS_INITIAL, ContratLigne::STATUS_OPEN]); + if (is_array($list) && !empty($list)) { + $number_contracts_found = count($list); + if ($number_contracts_found == 1) { + $contractid = $list[0]->id; + $object->setContract($contractid); + break; + } elseif ($number_contracts_found > 1) { + foreach($list as $linked_contract) { + $object->setContract($linked_contract->id); + // don't set '$contractid' so it is not used when creating an intervention. + } + setEventMessage($langs->trans('TicketManyContractsLinked'), 'warnings'); + break; + } + } + } + if ($number_contracts_found == 0) { + setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs'); + } + } + } return 0; } diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 5e9a0250a38..042ae751e06 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -110,6 +110,8 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value ALTER TABLE llx_ticket ADD COLUMN date_last_msg_sent datetime AFTER date_read; +UPDATE llx_const SET name = 'WORKFLOW_TICKET_LINK_CONTRACT' WHERE name = 'TICKET_AUTO_ASSIGN_CONTRACT_CREATE'; + CREATE TABLE llx_stock_mouvement_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index ef5df43e546..7c117fcd1f2 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -66,3 +66,4 @@ RepeatableIntervention=Template of intervention ToCreateAPredefinedIntervention=To create a predefined or recurring intervention, create a common intervention and convert it into intervention template ConfirmReopenIntervention=Are you sure you want to open back the intervention %s? GenerateInter=Generate intervention +FichinterNoContractLinked=Intervention %s has been created without a linked contract. diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 310ac8dd7f6..204f7c0ed60 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -258,6 +258,8 @@ TicketNotCreatedFromPublicInterface=Not available. Ticket was not created from p ErrorTicketRefRequired=Ticket reference name is required TicketsDelayForFirstResponseTooLong=Too much time elapsed since ticket opening without any answer. TicketsDelayFromLastResponseTooLong=Too much time elapsed since last answer on this ticket. +TicketNoContractFoundToLink=No contract was found to be automatically linked to this ticket. Please link a contract manually. +TicketManyContractsLinked=Many contracts have been automatically linked to this ticket. Make sure to verify which should be chosen. # # Logs diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index aa34c07c361..9afca68c2eb 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -255,22 +255,6 @@ if (empty($reshook)) { $object->add_contact($user->id, "SUPPORTTEC", 'internal'); } - // Auto assign contrat - $contractid = 0; - if (!empty($conf->global->TICKET_AUTO_ASSIGN_CONTRACT_CREATE)) { - $contrat = new Contrat($db); - $contrat->socid = $object->fk_soc; - $list = $contrat->getListOfContracts(); - - if (is_array($list) && !empty($list)) { - if (count($list) == 1) { - $contractid = $list[0]->id; - $object->setContract($contractid); - } else { - } - } - } - // Auto create fiche intervention if (!empty($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE)) { $fichinter = new Fichinter($db); @@ -292,6 +276,7 @@ if (empty($reshook)) { setEventMessages($fichinter->error, null, 'errors'); } } + } if (!$error) { From 8d997de3bbbf8ed9d599ca3e8db4130f8a2f3797 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 8 Feb 2022 11:54:52 +0100 Subject: [PATCH 141/752] add options in workflow admin panel : WORKFLOW_TICKET_LINK_CONTRACT, WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS --- htdocs/admin/workflow.php | 21 ++++++++++++++++++++- htdocs/core/modules/modWorkflow.class.php | 4 +++- htdocs/langs/en_US/workflow.lang | 7 ++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index a58c3378ecd..da82f163a7f 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -161,7 +161,21 @@ $workflowcodes = array( 'position' => 90, 'enabled' => ! empty($conf->expedition->enabled) && ! empty($conf->facture->enabled), 'picto' => 'shipment' - ) + ), + + // Automatic link ticket -> contract + 'WORKFLOW_TICKET_LINK_CONTRACT' => array( + 'family' => 'link_ticket', + 'position' => 75, + 'enabled' => ! empty($conf->ticket->enabled) && ! empty($conf->contract->enabled), + 'picto' => 'ticket' + ), + 'WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS' => array( + 'family' => 'link_ticket', + 'position' => 76, + 'enabled' => ! empty($conf->ticket->enabled) && ! empty($conf->contract->enabled), + 'picto' => 'ticket' + ), ); if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) { @@ -237,6 +251,11 @@ foreach ($workflowcodes as $key => $params) { if ($reg[1] == 'shipping') { $header .= ' - '.$langs->trans('Shipment'); } + } elseif (preg_match('/link_(.*)/', $params['family'], $reg)) { + $header = $langs->trans("AutomaticLinking"); + if ($reg[1] == 'ticket') { + $header .= ' - '.$langs->trans('Ticket'); + } } else { $header = $langs->trans("Description"); } diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index 4122f347664..dc05bf9dc66 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -93,7 +93,9 @@ class modWorkflow extends DolibarrModules 6=>array('WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION', 0, 'current', 0), 7=>array('WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED', 0, 'current', 0), 8=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0), - 9=>array('WORKFLOW_BILL_ON_RECEPTION', 'chaine', '1', 'WORKFLOW_BILL_ON_RECEPTION', 0, 'current', 0) + 9=>array('WORKFLOW_BILL_ON_RECEPTION', 'chaine', '1', 'WORKFLOW_BILL_ON_RECEPTION', 0, 'current', 0), + 10=>array('WORKFLOW_TICKET_LINK_CONTRACT', 'chaine', '0', 'Automatically link a ticket to available contracts', 0, 'current', 0), + 11=>array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0) ); // Boxes diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index b65f8449fef..6ddf8d9c6a3 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -22,9 +22,14 @@ descWORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION=Classify linked source purchase o descWORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED=Classify linked source purchase order as received when a reception is closed (and if the quantity received by all rceptions is the same as in the purchase order to update) # Autoclassify purchase invoice descWORKFLOW_BILL_ON_RECEPTION=Classify receptions to "billed" when a linked supplier order is validated +# Automatically link ticket to contract +descWORKFLOW_TICKET_LINK_CONTRACT=When creating a ticket, link available contracts of matching thirdparty +descWORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS=When linking contracts, search among those of parents companies # Autoclose intervention descWORKFLOW_TICKET_CLOSE_INTERVENTION=Close all interventions linked to the ticket when a ticket is closed AutomaticCreation=Automatic creation AutomaticClassification=Automatic classification # Autoclassify shipment -descWORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE=Classify linked source shipment as closed when customer invoice is validated \ No newline at end of file +descWORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE=Classify linked source shipment as closed when customer invoice is validated +AutomaticClosing=Automatic closing +AutomaticLinking=Automatic linking From 2cf433019e25ff0e9bfd8fa183b1797fb8bd3e20 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 3 Feb 2022 16:03:25 +0100 Subject: [PATCH 142/752] FormCategory : create method to select the product category --- htdocs/core/class/html.form.class.php | 1 - htdocs/core/class/html.formcategory.class.php | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ea6d145641a..2b300b580cd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3708,7 +3708,6 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache list of payment terms diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index 1a2c02deb54..707b5d5d0ac 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -60,4 +60,44 @@ class FormCategory extends Form return $filter; } + + /** + * Prints a select form for products categories + * @param string $selected Id category pre-selection + * @param string $htmlname Name of HTML field + * @param int $showempty Add an empty field + * @return integer|null + */ + public function selectProductCategory($selected = 0, $htmlname = 'product_category_id', $showempty = 0) + { + global $conf; + + $sql = "SELECT cp.fk_categorie as cat_index, cat.label FROM `llx_categorie_product` as cp INNER JOIN llx_categorie as cat ON cat.rowid = cp.fk_categorie GROUP BY cp.fk_categorie;"; + + dol_syslog(get_class($this)."::selectProductCategory", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + print ''); + + return $num_rows; + } else { + dol_print_error($this->db); + } + } } From 5fba0dc237c0c9e294d8bf3ddb32510ab0cde9d0 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 28 Feb 2022 17:51:37 +0100 Subject: [PATCH 143/752] ticket config : select product type matching tickets. --- htdocs/admin/ticket.php | 41 +++++++++++++++++++++++++++++----- htdocs/langs/en_US/ticket.lang | 2 ++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 68f256e2009..aa5acd273d6 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -26,6 +26,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formcategory.class.php"; // Load translation files required by the page $langs->loadLangs(array("admin", "ticket")); @@ -157,6 +158,14 @@ if ($action == 'setvarworkflow') { } } +if ($action == 'setvarworkflowother' || $action == 'setvarworkflow') { + $param_ticket_product_category = GETPOST('product_category_id', 'int'); + $res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } +} + if ($action == 'setvarother') { $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); @@ -219,7 +228,7 @@ if ($action == 'setvarother') { $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -$form = new Form($db); +$form = new FormCategory($db); $help_url = "FR:Module_Ticket"; $page_name = "TicketSetup"; @@ -489,8 +498,7 @@ foreach ($dirmodels as $reldir) { print ''; print '
'; - -if (!$conf->use_javascript_ajax) { +if (empty($conf->use_javascript_ajax)) { print ''; print ''; print ''; @@ -551,10 +559,33 @@ print $form->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp"), 1, ' print ''; print ''; -if (!$conf->use_javascript_ajax) { - print ''; +// Choose which product category is used for tickets +if ($conf->use_javascript_ajax) { + print '
'; + print ''; + print ''; } +print ''.$langs->trans("TicketChooseProductCategory").''; +print ''; + $form->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); + if ($conf->use_javascript_ajax) { + print ajax_combobox('select_'.$htmlname); + } +print ''; +print ''; +print $form->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); +print ''; +print ''; + +print '
'; + +print '
'; +print ''; +print '
'; + +print '
'; + // Define wanted maximum time elapsed before answers to tickets print '
'; print ''; diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 204f7c0ed60..edd54911bad 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -145,6 +145,8 @@ TicketsDelayBetweenAnswersHelp=If an unresolved ticket that has already received TicketsAutoNotifyClose=Automatically notify thirdparty when closing a ticket TicketsAutoNotifyCloseHelp=When closing a ticket, you will be proposed to send a message to one of thirdparty's contacts. On mass closing, a message will be sent to one contact of the thirdparty linked to the ticket. TicketWrongContact=Provided contact is not part of current ticket contacts. Email not sent. +TicketChooseProductCategory=Product category for ticket support +TicketChooseProductCategoryHelp=Select the product category of ticket support. This will be used to automatically link a contract to a ticket. # # Index & list page From f92154d057aae2876893a49e3ba10a91092967c1 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 3 Feb 2022 17:00:21 +0100 Subject: [PATCH 144/752] declare ticket-related constants in modTicket.class.php --- htdocs/core/modules/modTicket.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 86841ce5932..ff7eb1ee18f 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -111,6 +111,7 @@ class modTicket extends DolibarrModules 5 => array('TICKET_DELAY_BEFORE_FIRST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time before a first answer to a ticket (in hours). Display a warning in tickets list if not respected.', 0), 6 => array('TICKET_DELAY_SINCE_LAST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time between two answers on the same ticket (in hours). Display a warning in tickets list if not respected.', 0), 7 => array('TICKET_NOTIFY_AT_CLOSING', 'chaine', '0', 'Default notify contacts when closing a module', 0), + 8 => array('TICKET_PRODUCT_CATEGORY', 'chaine', 0, 'The category of product that is being used for ticket accounting', 0) ); From c745237ee92459bbbc2d3470e432e0b34dd4e7b4 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 8 Feb 2022 15:23:56 +0100 Subject: [PATCH 145/752] Stickler corrections --- htdocs/admin/ticket.php | 8 ++++---- htdocs/contrat/class/contrat.class.php | 2 +- .../interface_20_modWorkflow_WorkflowManager.class.php | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index aa5acd273d6..42a800c9f42 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -568,10 +568,10 @@ if ($conf->use_javascript_ajax) { print ''.$langs->trans("TicketChooseProductCategory").''; print ''; - $form->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); - if ($conf->use_javascript_ajax) { - print ajax_combobox('select_'.$htmlname); - } +$form->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); +if ($conf->use_javascript_ajax) { + print ajax_combobox('select_'.$htmlname); +} print ''; print ''; print $form->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e6c73164f26..aea577cccda 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2136,7 +2136,7 @@ class Contrat extends CommonObject * @param array $line_status sort contracts where lines have these status * @return array|int Array of contracts id or <0 if error */ - public function getListOfContracts($option = 'all', $status = [], $product_categories = [], $line_status = [] ) + public function getListOfContracts($option = 'all', $status = [], $product_categories = [], $line_status = []) { $tab = array(); diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 1e98ec885bd..740abb4a1b9 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -428,7 +428,6 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Auto link contract if (!empty($conf->contract->enabled) && !empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_TICKET_LINK_CONTRACT) && !empty($conf->global->TICKET_PRODUCT_CATEGORY) && !empty($object->fk_soc)) { - $societe = new Societe($this->db); $company_ids = (empty($conf->global->WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS)) ? [$object->fk_soc] : $societe->getParentsForCompany($object->fk_soc, [$object->fk_soc]); @@ -445,7 +444,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers $object->setContract($contractid); break; } elseif ($number_contracts_found > 1) { - foreach($list as $linked_contract) { + foreach ($list as $linked_contract) { $object->setContract($linked_contract->id); // don't set '$contractid' so it is not used when creating an intervention. } From c68e16c087144efb8a146b0aad98a8e84965ddf0 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 28 Feb 2022 18:06:41 +0100 Subject: [PATCH 146/752] admin/ticket.php: correct parameters table --- htdocs/admin/ticket.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 42a800c9f42..6341e641194 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -578,14 +578,6 @@ print $form->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), print ''; print ''; -print '
'; - -print '
'; -print ''; -print '
'; - -print ''; - // Define wanted maximum time elapsed before answers to tickets print '
'; print ''; @@ -612,10 +604,14 @@ print $form->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), print ''; print ''; -print '
'; - print '
'; +print '
'; +print ''; +print '
'; + +print ''; + // Admin var of module print load_fiche_titre($langs->trans("Notification"), '', ''); From ac37c7e4ca822b33b11f22e72e4f9b831206c0f6 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 28 Feb 2022 18:16:19 +0100 Subject: [PATCH 147/752] link intervention to a ticket contract --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 9afca68c2eb..42ec518c585 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -260,7 +260,7 @@ if (empty($reshook)) { $fichinter = new Fichinter($db); $fichinter->socid = $object->fk_soc; $fichinter->fk_project = $projectid; - $fichinter->fk_contrat = $contractid; + $fichinter->fk_contrat = $object->fk_contract; $fichinter->author = $user->id; $fichinter->model_pdf = 'soleil'; $fichinter->origin = $object->element; From 3a82817ad984ff084826bf2150d7abe549e30cb6 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 28 Feb 2022 18:37:09 +0100 Subject: [PATCH 148/752] avoid displaying warning messages on the public interface --- .../interface_20_modWorkflow_WorkflowManager.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 740abb4a1b9..4e98af5c6c7 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -448,13 +448,13 @@ class InterfaceWorkflowManager extends DolibarrTriggers $object->setContract($linked_contract->id); // don't set '$contractid' so it is not used when creating an intervention. } - setEventMessage($langs->trans('TicketManyContractsLinked'), 'warnings'); + if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketManyContractsLinked'), 'warnings'); break; } } } if ($number_contracts_found == 0) { - setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs'); + if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs'); } } } From fc7f097c25a143474b5d02d09a40bd0e6d10929f Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 28 Feb 2022 18:58:01 +0100 Subject: [PATCH 149/752] stickler corrections --- htdocs/ticket/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 42ec518c585..326e42781d0 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -276,7 +276,6 @@ if (empty($reshook)) { setEventMessages($fichinter->error, null, 'errors'); } } - } if (!$error) { From 14d9bf032295b4c651d22eca758c4c490790cf31 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 1 Mar 2022 09:17:56 +0100 Subject: [PATCH 150/752] fix non-sanitize string in SQL request --- htdocs/contrat/class/contrat.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index aea577cccda..b051c69e252 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2144,12 +2144,12 @@ class Contrat extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; if (!empty($product_categories)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON cd.fk_contrat = c.rowid"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = cd.fk_product AND cp.fk_categorie IN (".implode(', ', $product_categories).")"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = cd.fk_product AND cp.fk_categorie IN (".$this->db->sanitize(implode(', ', $product_categories)).")"; } $sql .= " WHERE c.fk_soc =".((int) $this->socid); $sql .= ($option == 'others') ? " AND c.rowid <> ".((int) $this->id) : ""; - $sql .= (!empty($status)) ? " AND c.statut IN (".implode(', ', $status).")" : ""; - $sql .= (!empty($line_status)) ? " AND cd.statut IN (".implode(', ', $line_status).")" : ""; + $sql .= (!empty($status)) ? " AND c.statut IN (".$this->db->sanitize(implode(', ', $status)).")" : ""; + $sql .= (!empty($line_status)) ? " AND cd.statut IN (".$this->db->sanitize(implode(', ', $line_status)).")" : ""; $sql .= " GROUP BY c.rowid"; dol_syslog(get_class($this)."::getOtherContracts()", LOG_DEBUG); From 4fb62ee15adcdfcfc3bfcfbd5b143b246080845e Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 22 Mar 2022 12:04:51 +0100 Subject: [PATCH 151/752] replacing to dolGetButtonAction on Commande card --- htdocs/commande/card.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 471363f74ec..e8f88800693 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2520,27 +2520,27 @@ if ($action == 'create' && $usercancreate) { if (empty($reshook)) { // Reopen a closed order if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) { - print ''.$langs->trans('ReOpen').''; + print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); } // Send if (empty($user->socid)) { if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print ''.$langs->trans('SendMail').''; + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', ''); } else { - print ''.$langs->trans('SendMail').''; + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } } } // Valid if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) { - print ''.$langs->trans('Validate').''; + print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, ''); } // Edit if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { - print ''.$langs->trans('Modify').''; + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=modif&token='.newToken().'&id='.$object->id, ''); } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) @@ -2555,7 +2555,7 @@ if ($action == 'create' && $usercancreate) { if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { - print ''.$langs->trans("AddPurchaseOrder").''; + print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } } } @@ -2566,9 +2566,9 @@ if ($action == 'create' && $usercancreate) { if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { - print ''.$langs->trans('AddIntervention').''; + print dolGetButtonAction('', $langs->trans('AddInterventionGR'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } else { - print ''.$langs->trans('AddIntervention').''; + print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } } } @@ -2578,7 +2578,7 @@ if ($action == 'create' && $usercancreate) { $langs->load("contracts"); if ($user->rights->contrat->creer) { - print ''.$langs->trans('AddContract').''; + print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } } @@ -2590,52 +2590,52 @@ if ($action == 'create' && $usercancreate) { if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { if ($user->rights->expedition->creer) { - print ''.$langs->trans('CreateShipment').''; + print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, ''); } else { - print ''.$langs->trans('CreateShipment').''; + print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } } else { $langs->load("errors"); - print 'transnoentitiesnoconv("Shipment"))).'">'.$langs->trans('CreateShipment').''; + print dolGetButtonAction($langs->trans('ErrorModuleSetupNotComplete'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } } } // Set to shipped if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) { - print ''.$langs->trans('ClassifyShipped').''; + print dolGetButtonAction('', $langs->trans('ClassifyShipped'), 'default', $_SERVER["PHP_SELF"].'?action=shipped&token='.newToken().'&id='.$object->id, ''); } // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) { if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { - print ''.$langs->trans("CreateBill").''; + print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - print ''.$langs->trans("ClassifyBilled").''; + print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&token='.newToken().'&id='.$object->id, ''); } } if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - print ''.$langs->trans("ClassifyUnBilled").''; + print dolGetButtonAction('', $langs->trans('ClassifyUnBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifyunbilled&token='.newToken().'&id='.$object->id, ''); } } // Clone if ($usercancreate) { - print ''.$langs->trans("ToClone").''; + print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.$object->id.'&socid='.$object->socid, ''); } // Cancel order if ($object->statut == Commande::STATUS_VALIDATED && (!empty($usercanclose) || !empty($usercancancel))) { - print ''.$langs->trans("Cancel").''; + print dolGetButtonAction('', $langs->trans('Cancel'), 'danger', $_SERVER["PHP_SELF"].'?action=cancel&token='.newToken().'&id='.$object->id, ''); } // Delete order if ($usercandelete) { if ($numshipping == 0) { - print ''.$langs->trans('Delete').''; + print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); } else { - print ''.$langs->trans("Delete").''; + print dolGetButtonAction($langs->trans('ShippingExist'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } } } From 958b6abdaafa0585ac6d8ef70559207b16cd5bb2 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 23 Mar 2022 17:31:54 +0100 Subject: [PATCH 152/752] pdf_path --- htdocs/core/class/notify.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 5bb448ad11d..54b0fbb749c 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -836,7 +836,7 @@ class Notify break; } $ref = dol_sanitizeFileName($newref); - $pdf_path = $dir_output."/".$ref.".pdf"; + $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; From 2709e69a32610f2152209fd37a910f8794586653 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 24 Mar 2022 10:59:18 +0100 Subject: [PATCH 153/752] rename $form into $formcategory --- htdocs/admin/ticket.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 6341e641194..ebf4187eabf 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -228,7 +228,7 @@ if ($action == 'setvarother') { $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -$form = new FormCategory($db); +$formcategory = new FormCategory($db); $help_url = "FR:Module_Ticket"; $page_name = "TicketSetup"; @@ -335,7 +335,7 @@ foreach ($dirmodels as $reldir) { } print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print $formcategory->textwithpicto('', $htmltooltip, 1, 0); print ''; print ''; @@ -473,7 +473,7 @@ foreach ($dirmodels as $reldir) { print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print $formcategory->textwithpicto('', $htmltooltip, 1, 0); print ''; // Preview @@ -520,11 +520,11 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND); + print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND); } print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help'); print ''; print ''; @@ -536,11 +536,11 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); + print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); } print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help'); print ''; print ''; @@ -551,11 +551,11 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFY_AT_CLOSING'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING); + print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING); } print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp"), 1, 'help'); print ''; print ''; @@ -568,13 +568,13 @@ if ($conf->use_javascript_ajax) { print ''.$langs->trans("TicketChooseProductCategory").''; print ''; -$form->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); +$formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id'); if ($conf->use_javascript_ajax) { print ajax_combobox('select_'.$htmlname); } print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help'); print ''; print ''; @@ -589,7 +589,7 @@ print ' '; print ''; -print $form->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); print ''; print ''; @@ -600,7 +600,7 @@ print ' '; print ''; -print $form->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); print ''; print ''; @@ -639,7 +639,7 @@ print ''.$langs->trans("TicketEmailNotificationFrom").'< print ''; print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); print ''; print ''; @@ -648,7 +648,7 @@ print ''.$langs->trans("TicketEmailNotificationTo").' (' print ''; print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help'); print ''; print ''; @@ -660,11 +660,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + print $formcategory->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); } print ''; print ''; - print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print $formcategory->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); print ''; print ''; } @@ -678,7 +678,7 @@ $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120 $doleditor->Create(); print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"), 1, 'help'); print ''; // Texte de signature @@ -690,12 +690,12 @@ $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '10 $doleditor->Create(); print ''; print ''; -print $form->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help'); +print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help'); print ''; print ''; -print $form->buttonsSaveCancel("Save", ''); +print $formcategory->buttonsSaveCancel("Save", ''); print ''; From 6dfad5d69fc97ae12f681e1ab974db66dc621b3d Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 24 Mar 2022 11:09:39 +0100 Subject: [PATCH 154/752] facture/card.php: replace redirection by = '' --- htdocs/compta/facture/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1540846d99a..02120c57d99 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -306,8 +306,7 @@ if (empty($reshook)) { $last_of_type = $object->willBeLastOfSameType(); if (empty($object->date_validation) && !$last_of_type[0]) { setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); - exit; + $action = ''; } } From 6302e114714752651beec391dd9c8c1a3872da34 Mon Sep 17 00:00:00 2001 From: GregM Date: Thu, 24 Mar 2022 12:24:33 +0100 Subject: [PATCH 155/752] update GRH redirection position --- htdocs/hrm/position.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index 86f7a5c74d3..f2fc49197a7 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -160,9 +160,9 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/hrm/position_list.php', 1); //$backtopage = dol_buildpath('/hrm/position.php', 1) . '?fk_job=' . ($fk_job > 0 ? $fk_job : '__ID__'); - if (!empty($backtopage) || ($cancel && empty($fk_job))) { + if (!empty($backtopage) || ($cancel && $fk_job <= 0)) { if (!empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($fk_job) && (($action != 'add' && $action != 'create') || $cancel)) { + if ($fk_job == -1 && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { if ($fk_job > 0) { @@ -631,7 +631,7 @@ function DisplayPositionList() print ''; print ''; - $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1) . '?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF'].'?fk_job=' . $fk_job).'&fk_job=' . $fk_job, '', $permissiontoadd); + $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1) . '?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF']).'&fk_job=' . $fk_job, '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); From e8dae7a8dbf556b01028fcaec1ca2e02d1754840 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 24 Mar 2022 16:34:08 +0100 Subject: [PATCH 156/752] FIX Multiccompany sharings compatibility --- htdocs/core/class/commonobject.class.php | 30 ++++++++++++++++-------- htdocs/product/class/product.class.php | 14 +++++------ htdocs/societe/class/societe.class.php | 24 +++++++++---------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a0d1079072a..bedc17a8fc2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4374,9 +4374,10 @@ abstract class CommonObject * Check is done into this->childtables. There is no check into llx_element_element. * * @param int $id Force id of object + * @param int $entity Force entity to check * @return int <0 if KO, 0 if not used, >0 if already used */ - public function isObjectUsed($id = 0) + public function isObjectUsed($id = 0, $entity = 0) { global $langs; @@ -4399,11 +4400,21 @@ abstract class CommonObject // Test if child exists $haschild = 0; - foreach ($arraytoscan as $table => $elementname) { + foreach ($arraytoscan as $table => $element) { //print $id.'-'.$table.'-'.$elementname.'
'; - // Check if third party can be deleted - $sql = "SELECT COUNT(*) as nb from ".$this->db->prefix().$table; - $sql .= " WHERE ".$this->fk_element." = ".((int) $id); + // Check if element can be deleted + $sql = "SELECT COUNT(*) as nb"; + $sql.= " FROM ".$this->db->prefix().$table." as c"; + if (!empty($element['parent']) && !empty($element['parentkey'])) { + $sql.= ", ".$this->db->prefix().$element['parent']." as p"; + } + $sql.= " WHERE c.".$this->fk_element." = ".((int) $id); + if (!empty($element['parent']) && !empty($element['parentkey'])) { + $sql.= " AND c.".$element['parentkey']." = p.rowid"; + } + if (!empty($entity)) { + $sql.= " AND entity = ".((int) $entity); + } $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -4411,11 +4422,10 @@ abstract class CommonObject $langs->load("errors"); //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; $haschild += $obj->nb; - if (is_numeric($elementname)) { // old usage - $this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table); - } else // new usage: $elementname=Translation key - { - $this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($elementname)); + if (is_numeric($element) || empty($element['name'])) { // old usage + $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table); + } else { // new usage: $element['name']=Translation key + $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element['name'])); } break; // We found at least one, we stop here } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6e97e80fece..9792b11ce39 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -64,13 +64,13 @@ class Product extends CommonObject * @var array List of child tables. To test if we can delete object. */ protected $childtables = array( - 'supplier_proposaldet', - 'propaldet', - 'commandedet', - 'facturedet', - 'contratdet', - 'facture_fourn_det', - 'commande_fournisseurdet' + 'supplier_proposaldet' => array('parent' => 'supplier_proposal', 'parentkey' => 'fk_supplier_proposal'), + 'propaldet' => array('parent' => 'propal', 'parentkey' => 'fk_propal'), + 'commandedet' => array('parent' => 'commande', 'parentkey' => 'fk_commande'), + 'facturedet' => array('parent' => 'facture', 'parentkey' => 'fk_facture'), + 'contratdet' => array('parent' => 'contrat', 'parentkey' => 'fk_contrat'), + 'facture_fourn_det' => array('parent' => 'facture_fourn', 'parentkey' => 'fk_facture_fourn'), + 'commande_fournisseurdet' => array('parent' => 'commande_fournisseur', 'parentkey' => 'fk_commande') ); /** diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 89eeeaca8e5..bfcdce7d348 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -73,18 +73,18 @@ class Societe extends CommonObject * @var array List of child tables. To test if we can delete object. */ protected $childtables = array( - "supplier_proposal" => 'SupplierProposal', - "propal" => 'Proposal', - "commande" => 'Order', - "facture" => 'Invoice', - "facture_rec" => 'RecurringInvoiceTemplate', - "contrat" => 'Contract', - "fichinter" => 'Fichinter', - "facture_fourn" => 'SupplierInvoice', - "commande_fournisseur" => 'SupplierOrder', - "projet" => 'Project', - "expedition" => 'Shipment', - "prelevement_lignes" => 'DirectDebitRecord', + "supplier_proposal" => array('name' => 'SupplierProposal'), + "propal" => array('name' => 'Proposal'), + "commande" => array('name' => 'Order'), + "facture" => array('name' => 'Invoice'), + "facture_rec" => array('name' => 'RecurringInvoiceTemplate'), + "contrat" => array('name' => 'Contract'), + "fichinter" => array('name' => 'Fichinter'), + "facture_fourn" => array('name' => 'SupplierInvoice'), + "commande_fournisseur" => array('name' => 'SupplierOrder'), + "projet" => array('name' => 'Project'), + "expedition" => array('name' => 'Shipment'), + "prelevement_lignes" => array('name' => 'DirectDebitRecord'), ); /** From 6fdb140f0402a598ae7e2482f38b680859a94fb8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 24 Mar 2022 16:54:02 +0100 Subject: [PATCH 157/752] FIX missing table alias --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bedc17a8fc2..23e66ed2064 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4413,7 +4413,7 @@ abstract class CommonObject $sql.= " AND c.".$element['parentkey']." = p.rowid"; } if (!empty($entity)) { - $sql.= " AND entity = ".((int) $entity); + $sql.= " AND p.entity = ".((int) $entity); } $resql = $this->db->query($sql); if ($resql) { From c38437f0ded7c54fad4c363f6d44ff07119b2339 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 24 Mar 2022 17:12:37 +0100 Subject: [PATCH 158/752] FIX wrong error message --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 23e66ed2064..ea7d0265ec1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4423,9 +4423,9 @@ abstract class CommonObject //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; $haschild += $obj->nb; if (is_numeric($element) || empty($element['name'])) { // old usage - $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table); + $this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table); } else { // new usage: $element['name']=Translation key - $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element['name'])); + $this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element['name'])); } break; // We found at least one, we stop here } From 1c43617d9363eb26a4a65bb0c39bb87531fb103f Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 24 Mar 2022 17:34:50 +0100 Subject: [PATCH 159/752] FIX: contact card: single extrafield update failed --- htdocs/contact/card.php | 23 +++++++++++++++++++++++ htdocs/core/tpl/extrafields_view.tpl.php | 3 +++ 2 files changed, 26 insertions(+) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 0c95ecb7fd4..28a61ce5190 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -479,6 +479,29 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } + // Update extrafields + if ($action == 'update_extras' && ! empty($user->rights->societe->contact->creer)) { + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + if ($ret < 0) { + $error++; + } + + if (!$error) { + $result = $object->insertExtraFields('CONTACT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + + if ($error) { + $action = 'edit_extras'; + } + } + // Actions to send emails $triggersendname = 'CONTACT_SENTBYMAIL'; $paramname = 'id'; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 40ea3e0ce50..7f1ee1f37cb 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -150,6 +150,9 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] if ($object->element == 'productlot') $permok = $user->rights->stock->creer; if ($object->element == 'facturerec') $permok = $user->rights->facture->creer; if ($object->element == 'mo') $permok = $user->rights->mrp->write; + if ($object->element == 'contact') { + $permok = $user->rights->societe->contact->creer; + } $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0)); if (($isdraft || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$tmpkeyextra])) From 391c02993d2a6d2fc8257ebe77d6f5b866eb35e0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 24 Mar 2022 20:26:47 +0100 Subject: [PATCH 160/752] FIX better test for all usage --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ea7d0265ec1..7dcf9d09805 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4422,8 +4422,10 @@ abstract class CommonObject $langs->load("errors"); //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; $haschild += $obj->nb; - if (is_numeric($element) || empty($element['name'])) { // old usage + if (is_numeric($element)) { // very old usage array('table1', 'table2', ...) $this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table); + } elseif (is_string($element)) { // old usage array('table1' => 'TranslateKey1', 'table2' => 'TranslateKey2', ...) + $this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element)); } else { // new usage: $element['name']=Translation key $this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element['name'])); } From ffa79c59f97561f4761fbc939c2ca60e74ebfc3d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 24 Mar 2022 20:48:43 +0100 Subject: [PATCH 161/752] FIX wrong alias of table if no parent and parentkey --- htdocs/core/class/commonobject.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7dcf9d09805..3bb84eac492 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4413,7 +4413,11 @@ abstract class CommonObject $sql.= " AND c.".$element['parentkey']." = p.rowid"; } if (!empty($entity)) { - $sql.= " AND p.entity = ".((int) $entity); + if (!empty($element['parent']) && !empty($element['parentkey'])) { + $sql.= " AND p.entity = ".((int) $entity); + } else { + $sql.= " AND c.entity = ".((int) $entity); + } } $resql = $this->db->query($sql); if ($resql) { From 8236a8e846e49cf6ea6597ac38495012853f3297 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Mar 2022 15:35:49 +0100 Subject: [PATCH 162/752] Fix bad test for button to show / hide canceled orders --- htdocs/projet/element.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index b5e789ec3f2..80fccce7912 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1050,7 +1050,8 @@ foreach ($listofreferent as $key => $value) { } $addform .= '
'; } - if (is_array($elementarray) && !count($elementarray) > 0 && $key == "order_supplier") { + + if (is_array($elementarray) && count($elementarray) > 0 && $key == "order_supplier") { $addform = '
'.$langs->trans("CanceledShown").' @@ -1061,13 +1062,13 @@ foreach ($listofreferent as $key => $value) { if (typeof attr !== "undefined" && attr !== false) { console.log("Show canceled"); $(".tr_canceled").show(); - $("#textBtnShow").text("'.dol_escape_js($langs->trans("CanceledShown")).'"); + $("#textBtnShow").text("'.dol_escape_js($langs->transnoentitiesnoconv("CanceledShown")).'"); $("#btnShow").removeAttr("data-canceledarehidden"); $("#minus-circle").removeClass("fa-eye-slash").addClass("fa-eye"); } else { console.log("Hide canceled"); $(".tr_canceled").hide(); - $("#textBtnShow").text("'.dol_escape_js($langs->trans("CanceledHidden")).'"); + $("#textBtnShow").text("'.dol_escape_js($langs->transnoentitiesnoconv("CanceledHidden")).'"); $("#btnShow").attr("data-canceledarehidden", 1); $("#minus-circle").removeClass("fa-eye").addClass("fa-eye-slash"); } From ab2e6ddf4359584ff1d33ecaccdd1d219c7536d2 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 25 Mar 2022 16:41:41 +0100 Subject: [PATCH 163/752] FIX : forgotten form confirm before various payment delete --- htdocs/compta/bank/various_payment/card.php | 8 +++++++- htdocs/langs/en_US/compta.lang | 4 +++- htdocs/langs/fr_FR/compta.lang | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index dd734074481..def2abba3a1 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -179,7 +179,7 @@ if (empty($reshook)) { $action = 'create'; } - if ($action == 'delete') { + if ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->fetch($id); if ($object->rappro == 0) { @@ -548,6 +548,12 @@ if ($id) { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350); } + // Confirmation of the removal of the Social Contribution + if ($action == 'delete') { + $text = $langs->trans('ConfirmDeleteVariousPayment'); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVariousPayment'), $text, 'confirm_delete', '', '', 2); + } + print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto); $morehtmlref = '
'; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c5e1a58d243..efe1e51482b 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -146,9 +146,11 @@ ConfirmPaySalary=Are you sure you want to classify this salary card as paid? DeleteSocialContribution=Delete a social or fiscal tax payment DeleteVAT=Delete a VAT declaration DeleteSalary=Delete a salary card +DeleteVariousPayment=Delete a various payment ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment ? ConfirmDeleteVAT=Are you sure you want to delete this VAT declaration ? -ConfirmDeleteSalary=Are you sure you want to delete this salary? +ConfirmDeleteSalary=Are you sure you want to delete this salary ? +ConfirmDeleteVariousPayment=Are you sure you want to delete this various payment ? ExportDataset_tax_1=Social and fiscal taxes and payments CalcModeVATDebt=Mode %sVAT on commitment accounting%s. CalcModeVATEngagement=Mode %sVAT on incomes-expenses%s. diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 280069f5cf9..be7a5f464ff 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -146,9 +146,11 @@ ConfirmPaySalary=Voulez-vous vraiment classer ce salaire comme payé ? DeleteSocialContribution=Effacer une charge fiscale ou sociale DeleteVAT=Supprimer une déclaration de TVA DeleteSalary=Supprimer un salaire +DeleteVariousPayment=Supprimer un paiement divers ConfirmDeleteSocialContribution=Voulez-vous vraiment supprimer ce paiement de taxe sociale / fiscale? ConfirmDeleteVAT=Voulez-vous vraiment supprimer cette déclaration de TVA ? ConfirmDeleteSalary=Êtes-vous sûr de vouloir supprimer ce salaire ? +ConfirmDeleteVariousPayment=Voulez-vous vraiment supprimer ce paiement divers ? ExportDataset_tax_1=Taxes sociales et fiscales et paiements CalcModeVATDebt=Mode %sTVA sur débit%s. CalcModeVATEngagement=Mode %sTVA sur encaissement%s. From fdf8a3f4adc655d9e51ac71e1e84f02e93170d82 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 25 Mar 2022 16:43:54 +0100 Subject: [PATCH 164/752] FIX : comment --- htdocs/compta/bank/various_payment/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index def2abba3a1..a2c6c2b21ae 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -548,7 +548,7 @@ if ($id) { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350); } - // Confirmation of the removal of the Social Contribution + // Confirmation of the removal of the Various Payment if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteVariousPayment'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVariousPayment'), $text, 'confirm_delete', '', '', 2); From 8a7b97bed150e33f37e9601ef1b75e2fd42f644e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 25 Mar 2022 16:47:41 +0100 Subject: [PATCH 165/752] FIX check thirdparty object loaded and properties exist --- htdocs/compta/facture/class/facture.class.php | 14 ++++++++++++++ htdocs/langs/en_US/errors.lang | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 00734ccb680..0269babd064 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2518,6 +2518,20 @@ class Facture extends CommonInvoice { $keymin = strtolower($key); $i = (int) preg_replace('/[^0-9]/', '', $key); + if ($i == 1) { + if (!is_object($this->thirdparty)) { + $langs->load('errors'); + $this->error = $langs->trans('ErrorInvoiceLoadThirdParty', $this->ref); + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + if (!property_exists($this->thirdparty, $keymin)) { + $langs->load('errors'); + $this->error = $langs->trans('ErrorInvoiceLoadThirdPartyKey', $keymin, $this->ref); + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } $vallabel = $this->thirdparty->$keymin; if ($i > 0) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 087fcba9e56..94a1cf16a38 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -257,6 +257,8 @@ ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation ErrorYouMustFirstSetupYourChartOfAccount=You must first setup your chart of account +ErrorInvoiceLoadThirdParty=Can't load third-party object for invoice "%s" +ErrorInvoiceLoadThirdPartyKey=Third-party key "%s" no set for invoice "%s" # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. @@ -289,4 +291,4 @@ WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into E WarningTheHiddenOptionIsOn=Warning, the hidden option %s is on. WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. -WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. \ No newline at end of file +WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. From 4479ba801552c09e462e2346f9ec9880f4c651c7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 26 Mar 2022 08:32:20 +0100 Subject: [PATCH 166/752] FIX missing translation keys --- htdocs/product/class/product.class.php | 14 +++---- htdocs/projet/class/task.class.php | 4 +- htdocs/societe/class/societe.class.php | 56 +++++++++++++------------- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9792b11ce39..d308ceb8e53 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -64,13 +64,13 @@ class Product extends CommonObject * @var array List of child tables. To test if we can delete object. */ protected $childtables = array( - 'supplier_proposaldet' => array('parent' => 'supplier_proposal', 'parentkey' => 'fk_supplier_proposal'), - 'propaldet' => array('parent' => 'propal', 'parentkey' => 'fk_propal'), - 'commandedet' => array('parent' => 'commande', 'parentkey' => 'fk_commande'), - 'facturedet' => array('parent' => 'facture', 'parentkey' => 'fk_facture'), - 'contratdet' => array('parent' => 'contrat', 'parentkey' => 'fk_contrat'), - 'facture_fourn_det' => array('parent' => 'facture_fourn', 'parentkey' => 'fk_facture_fourn'), - 'commande_fournisseurdet' => array('parent' => 'commande_fournisseur', 'parentkey' => 'fk_commande') + 'supplier_proposaldet' => array('name' => 'SupplierProposal', 'parent' => 'supplier_proposal', 'parentkey' => 'fk_supplier_proposal'), + 'propaldet' => array('name' => 'Proposal', 'parent' => 'propal', 'parentkey' => 'fk_propal'), + 'commandedet' => array('name' => 'Order', 'parent' => 'commande', 'parentkey' => 'fk_commande'), + 'facturedet' => array('name' => 'Invoice', 'parent' => 'facture', 'parentkey' => 'fk_facture'), + 'contratdet' => array('name' => 'Contract', 'parent' => 'contrat', 'parentkey' => 'fk_contrat'), + 'facture_fourn_det' => array('name' => 'SupplierInvoice', 'parent' => 'facture_fourn', 'parentkey' => 'fk_facture_fourn'), + 'commande_fournisseurdet' => array('name' => 'SupplierOrder', 'parent' => 'commande_fournisseur', 'parentkey' => 'fk_commande') ); /** diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 443e945aecb..d99b13b29c7 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -59,7 +59,9 @@ class Task extends CommonObjectLine /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables = array('projet_task_time'); + protected $childtables = array( + 'projet_task_time' => array('name' => 'Task', 'parent' => 'projet_task', 'parentkey' => 'fk_task') + ); /** * @var int ID parent task diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bfcdce7d348..7fab734a12c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -73,18 +73,18 @@ class Societe extends CommonObject * @var array List of child tables. To test if we can delete object. */ protected $childtables = array( - "supplier_proposal" => array('name' => 'SupplierProposal'), - "propal" => array('name' => 'Proposal'), - "commande" => array('name' => 'Order'), - "facture" => array('name' => 'Invoice'), - "facture_rec" => array('name' => 'RecurringInvoiceTemplate'), - "contrat" => array('name' => 'Contract'), - "fichinter" => array('name' => 'Fichinter'), - "facture_fourn" => array('name' => 'SupplierInvoice'), - "commande_fournisseur" => array('name' => 'SupplierOrder'), - "projet" => array('name' => 'Project'), - "expedition" => array('name' => 'Shipment'), - "prelevement_lignes" => array('name' => 'DirectDebitRecord'), + 'supplier_proposal' => array('name' => 'SupplierProposal'), + 'propal' => array('name' => 'Proposal'), + 'commande' => array('name' => 'Order'), + 'facture' => array('name' => 'Invoice'), + 'facture_rec' => array('name' => 'RecurringInvoiceTemplate'), + 'contrat' => array('name' => 'Contract'), + 'fichinter' => array('name' => 'Fichinter'), + 'facture_fourn' => array('name' => 'SupplierInvoice'), + 'commande_fournisseur' => array('name' => 'SupplierOrder'), + 'projet' => array('name' => 'Project'), + 'expedition' => array('name' => 'Shipment'), + 'prelevement_lignes' => array('name' => 'DirectDebitRecord'), ); /** @@ -92,22 +92,22 @@ class Societe extends CommonObject * if name like with @ClassName:FilePathClass:ParentFkFieldName' it will call method deleteByParentField (with parentId as parameters) and FieldName to fetch and delete child object */ protected $childtablesoncascade = array( - "societe_prices", - "societe_address", - "product_fournisseur_price", - "product_customer_price_log", - "product_customer_price", - "@Contact:/contact/class/contact.class.php:fk_soc", - "adherent", - "societe_account", - "societe_rib", - "societe_remise", - "societe_remise_except", - "societe_commerciaux", - "categorie", - "notify", - "notify_def", - "actioncomm", + 'societe_prices', + 'societe_address', + 'product_fournisseur_price', + 'product_customer_price_log', + 'product_customer_price', + '@Contact:/contact/class/contact.class.php:fk_soc', + 'adherent', + 'societe_account', + 'societe_rib', + 'societe_remise', + 'societe_remise_except', + 'societe_commerciaux', + 'categorie', + 'notify', + 'notify_def', + 'actioncomm', ); /** From 396b5324001257e0e6bae997c211b3dc2bf2c05b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 09:40:22 +0100 Subject: [PATCH 167/752] Can cumulate error message on different authentication modes --- htdocs/core/lib/security2.lib.php | 4 +++- htdocs/main.inc.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index e156c83b147..1cacd70d602 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -69,6 +69,8 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Validation of login/pass/entity with standard modules if (empty($login)) { + unset($_SESSION["dol_loginmesg"]); + $test = true; foreach ($authmode as $mode) { if ($test && $mode && !$login) { @@ -111,7 +113,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Load translation files required by the page $langs->loadLangs(array('other', 'main', 'errors')); - $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode); + $_SESSION["dol_loginmesg"] = (isset($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"].', ' : '').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode); } } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a8e99f05856..51a7dcfafcb 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -736,6 +736,7 @@ if (!defined('NOLOGIN')) { // Validation of login/pass/entity // If ok, the variable login will be returned // If error, we will put error message in session under the name dol_loginmesg + // Note authmode is an array for example: array('0'=>'dolibarr', '1'=>'google'); if ($test && $goontestloop && (GETPOST('actionlogin', 'aZ09') == 'login' || $dolibarr_main_authentication != 'dolibarr')) { $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); if ($login === '--bad-login-validity--') { From e8a9a7b73213eafcf3448e728faa088e5420111d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 09:40:34 +0100 Subject: [PATCH 168/752] Responsive --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/core/tpl/objectline_edit.tpl.php | 6 +++--- htdocs/fourn/facture/card.php | 11 +++++++---- htdocs/theme/eldy/global.inc.php | 6 ++++++ htdocs/theme/md/style.css.php | 6 ++++++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 9c5ddf44229..428a1163df9 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -371,7 +371,7 @@ if ($nolinesbefore) { if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines $coldisplay++; ?> - "> + "> '; $coldisplay++; diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index b07ea5042f0..c59949d5fb7 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -90,7 +90,7 @@ $coldisplay = 0; $coldisplay++; ?> - +
@@ -196,7 +196,7 @@ $coldisplay++; if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines $coldisplay++; ?> - + - + info_bits & 2) != 2) { print ''.$langs->trans('AmountHT').''.price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).''; - print ''.$langs->trans('AmountVAT').''.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).'
        '; + print ''.$langs->trans('AmountVAT').''.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency); if (GETPOST('calculationrule')) { $calculationrule = GETPOST('calculationrule', 'alpha'); } else { @@ -3177,13 +3177,16 @@ if ($action == 'create') { } // Show link for "recalculate" if ($object->getVentilExportCompta() == 0) { - $s = $langs->trans("ReCalculate").' '; + $s = ''.$langs->trans("ReCalculate").' '; $s .= ''.$langs->trans("Mode1").''; $s .= ' / '; $s .= ''.$langs->trans("Mode2").''; - print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help')); + print '
'; + print '         '; + print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help'), '', 3, '', 0, 'recalculate'); + print '
'; } - print '
'; + print ''; // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 65b8bdcf542..4ce28a34cf2 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1555,6 +1555,11 @@ table[summary="list_of_modules"] .fa-cog { .maxwidth1000 { max-width: 1000px; } .maxwidth50imp { max-width: 50px !important; } .maxwidth75imp { max-width: 75px !important; } + +.minwidth100onall { min-width: 100px !important; } +.minwidth200onall { min-width: 200px !important; } +.minwidth250onall { min-width: 250px !important; } + .minheight20 { min-height: 20px; } .minheight30 { min-height: 30px; } .minheight40 { min-height: 40px; } @@ -1763,6 +1768,7 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select .maxwidth50onsmartphone { max-width: 40px; } .maxwidth75onsmartphone { max-width: 50px; } .maxwidth100onsmartphone { max-width: 70px; } + .maxwidth125onsmartphone { max-width: 100px; } .maxwidth150onsmartphone { max-width: 120px; } .maxwidth150onsmartphoneimp { max-width: 120px !important; } .maxwidth200onsmartphone { max-width: 200px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8fbe02beba9..15095b3b3e8 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1643,6 +1643,11 @@ tr.nobottom td { .maxwidth500 { max-width: 500px; } .maxwidth50imp { max-width: 50px !important; } .maxwidth75imp { max-width: 75px !important; } + +.minwidth100onall { min-width: 100px !important; } +.minwidth200onall { min-width: 200px !important; } +.minwidth250onall { min-width: 250px !important; } + .minheight20 { min-height: 20px; } .minheight30 { min-height: 30px; } .minheight40 { min-height: 40px; } @@ -1835,6 +1840,7 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select .maxwidth50onsmartphone { max-width: 40px; } .maxwidth75onsmartphone { max-width: 50px; } .maxwidth100onsmartphone { max-width: 70px; } + .maxwidth125onsmartphone { max-width: 100px; } .maxwidth150onsmartphone { max-width: 120px; } .maxwidth150onsmartphoneimp { max-width: 120px !important; } .maxwidth200onsmartphone { max-width: 200px; } From bc938d86bae39a8d6b0ed5cc79299c0624a31b60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 11:22:54 +0100 Subject: [PATCH 169/752] NEW Can enter price with tax for predefined products on purchase objects --- htdocs/core/tpl/objectline_create.tpl.php | 12 +- .../class/fournisseur.commande.class.php | 4 +- htdocs/fourn/commande/card.php | 66 +++++----- htdocs/fourn/facture/card.php | 25 +++- htdocs/supplier_proposal/card.php | 123 +++++++++++++----- 5 files changed, 153 insertions(+), 77 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 428a1163df9..b09a33f44f6 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -1034,18 +1034,18 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#multicurrency_price_ht").val('').show(); jQuery("#title_up_ht, #title_up_ht_currency").show(); - jQuery("#price_ht").val('').hide(); + //jQuery("#price_ht").val('').hide(); jQuery("#multicurrency_price_ht").val('').hide(); jQuery("#title_up_ht, #title_up_ht_currency").hide(); - global->MAIN_ENABLE_EDIT_PREDEF_PRICETTC)) { ?> - jQuery("#price_ttc").val('').hide(); - jQuery("#multicurrency_price_ttc").val('').hide(); - jQuery("#title_up_ttc, #title_up_ttc_currency").hide(); - + global->MAIN_DISABLE_EDIT_PREDEF_PRICETTC)) { ?> jQuery("#price_ttc").val('').show(); jQuery("#multicurrency_price_ttc").val('').show(); jQuery("#title_up_ttc, #title_up_ttc_currency").show(); + + jQuery("#price_ttc").val('').hide(); + jQuery("#multicurrency_price_ttc").val('').hide(); + jQuery("#title_up_ttc, #title_up_ttc_currency").hide(); jQuery("#fourn_ref, #tva_tx, #title_vat").hide(); /* jQuery("#title_fourn_ref").hide(); */ diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index a195a2ed2e1..2dcf70765f9 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1718,7 +1718,7 @@ class CommandeFournisseur extends CommonOrder * Add order line * * @param string $desc Description - * @param float $pu_ht Unit price + * @param float $pu_ht Unit price (used if $price_base_type is 'HT') * @param float $qty Quantity * @param float $txtva Taux tva * @param float $txlocaltax1 Localtax1 tax @@ -1728,7 +1728,7 @@ class CommandeFournisseur extends CommonOrder * @param string $ref_supplier Supplier reference price * @param float $remise_percent Remise * @param string $price_base_type HT or TTC - * @param float $pu_ttc Unit price TTC + * @param float $pu_ttc Unit price TTC (used if $price_base_type is 'TTC') * @param int $type Type of line (0=product, 1=service) * @param int $info_bits More information * @param bool $notrigger Disable triggers diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index c7a937518d7..b71ba0de941 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -412,10 +412,9 @@ if (empty($reshook)) { // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); - $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; @@ -425,6 +424,8 @@ if (empty($reshook)) { $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); // Can be '1.2' or '1.2 (CODE)' + $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2); $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2); $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); @@ -461,7 +462,7 @@ if (empty($reshook)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (GETPOST('qty', 'int') == '') { + if (GETPOST('qty', 'alpha') == '') { // 0 is allowed for order setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } @@ -506,13 +507,14 @@ if (empty($reshook)) { } } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { $qtytosearch = $qty; // Just to see if a price exists for the quantity. Not used to found vat. - //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist + //$qtytosearch = -1; // We force qty to -1 to be sure to find if a supplier price exist $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); $res = $productsupplier->fetch($idprod); } if ($idprod > 0) { $label = $productsupplier->label; + // Define output language if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; @@ -550,41 +552,44 @@ if (empty($reshook)) { $ref_supplier = $productsupplier->ref_supplier; - $type = $productsupplier->type; - if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') { - $price_base_type = 'HT'; - $pu = price2num($price_ht, 'MU'); - $pu_ht_devise = price2num($price_ht_devise, 'CU'); - } elseif (GETPOST('price_ttc') != '' || GETPOST('price_ttc_devise') != '') { - $price_base_type = 'TTC'; - $pu = price2num($price_ttc, 'MU'); - $pu_ht_devise = price2num($price_ttc_devise, 'CU'); - } else { - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); - if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency - $pu = $productsupplier->fourn_pu; - $pu_ht_devise = 0; - } else { - $pu = $productsupplier->fourn_pu; - $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice; - } + // Get vat rate + if (!GETPOSTISSET('tva_tx')) { // If vat rate not provided from the form (the form has the priority) + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); } - - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); if (empty($tva_tx)) { $tva_npr = 0; } $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + $type = $productsupplier->type; + if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') { + $price_base_type = 'HT'; + $pu = price2num($price_ht, 'MU'); + $pu_devise = price2num($price_ht_devise, 'CU'); + } elseif (GETPOST('price_ttc') != '' || GETPOST('price_ttc_devise') != '') { + $price_base_type = 'TTC'; + $pu = price2num($price_ttc, 'MU'); + $pu_devise = price2num($price_ttc_devise, 'CU'); + } else { + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency + $pu = $productsupplier->fourn_pu; + $pu_devise = 0; + } else { + $pu = $productsupplier->fourn_pu; + $pu_devise = $productsupplier->fourn_multicurrency_unitprice; + } + } + if (empty($pu)) { $pu = 0; // If pu is '' or null, we force to have a numeric value } $result = $object->addline( $desc, - $pu, + ($price_base_type == 'HT' ? $pu : 0), $qty, $tva_tx, $localtax1_tx, @@ -594,7 +599,7 @@ if (empty($reshook)) { $ref_supplier, $remise_percent, $price_base_type, - $pu_ttc, + ($price_base_type == 'TTC' ? $pu : 0), $type, $tva_npr, '', @@ -602,7 +607,7 @@ if (empty($reshook)) { $date_end, $array_options, $productsupplier->fk_unit, - $pu_ht_devise, + $pu_devise, '', 0 ); @@ -645,7 +650,7 @@ if (empty($reshook)) { } $price_base_type = 'HT'; $pu_ht_devise = price2num($price_ht_devise, 'CU'); - // var_dump($pu_ht.' '.$tva_tx.' '.$pu_ttc.' '.$price_base_type.' '.$pu_ht_devise); exit; + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, '', '', $date_start, $date_end, $array_options, $fk_unit, $pu_ht_devise); } @@ -759,6 +764,7 @@ if (empty($reshook)) { $price_base_type = 'HT'; $ht = price2num(GETPOST('price_ht'), '', 2); } else { + $reg = array(); $vatratecleaned = $vat_rate; if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)" $vatratecleaned = trim($reg[1]); @@ -770,7 +776,7 @@ if (empty($reshook)) { $price_base_type = 'HT'; } - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); + $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU', 2); // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 8778e0d40b8..f4d628d5882 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1447,7 +1447,7 @@ if (empty($reshook)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (!GETPOST('qty')) { + if (!GETPOST('qty', 'alpha')) { // 0 is NOT allowed for invoices setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } @@ -1499,12 +1499,27 @@ if (empty($reshook)) { if ($idprod > 0) { $label = $productsupplier->label; - + // Define output language + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang]["description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang]["description"] : $productsupplier->description; + } else { + $desc = $productsupplier->description; + } // if we use supplier description of the products if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { $desc = $productsupplier->desc_supplier; - } else { - $desc = $productsupplier->description; } //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time @@ -3555,7 +3570,7 @@ if ($action == 'create') { } print '
'; - print ''; + print '
'; global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index b66dfc94ed6..f0594b90b6f 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -541,21 +541,28 @@ if (empty($reshook)) { $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $ref_supplier = GETPOST('fourn_ref', 'alpha'); + $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); - $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); // Can be '1.2' or '1.2 (CODE)' + + $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2); + $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2); + $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); + + $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); + if (empty($remise_percent)) { + $remise_percent = 0; + } // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -568,6 +575,10 @@ if (empty($reshook)) { } } + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { + setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error++; + } if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error++; @@ -589,10 +600,7 @@ if (empty($reshook)) { $db->begin(); - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if (($prod_entry_mode != 'free') && empty($error)) { // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + if ($prod_entry_mode != 'free' && empty($error)) { // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' $productsupplier = new ProductFournisseur($db); $idprod = 0; @@ -603,7 +611,7 @@ if (empty($reshook)) { $reg = array(); if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { $idprod = $reg[1]; - $res = $productsupplier->fetch($idprod); // Load product from its ID + $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { @@ -626,42 +634,85 @@ if (empty($reshook)) { if ($idprod > 0) { $label = $productsupplier->label; - // if we use supplier description of the products - if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { - $desc = $productsupplier->desc_supplier; + // Define output language + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang]["description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang]["description"] : $productsupplier->description; } else { $desc = $productsupplier->description; } + // if we use supplier description of the products + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + $desc = $productsupplier->desc_supplier; + } - if (trim($product_desc) != trim($desc)) { + //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time + if (trim($product_desc) == trim($desc) && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc=''; + } + + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) { + $desc = $product_desc; + } + if (!empty($product_desc) && trim($product_desc) != trim($desc)) { $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); } - $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); - $ref_supplier = $productsupplier->ref_supplier; - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + // Get vat rate + if (!GETPOSTISSET('tva_tx')) { // If vat rate not provided from the form (the form has the priority) + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + } if (empty($tva_tx)) { $tva_npr = 0; } $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - if (empty($pu_ht)) { - $pu_ht = 0; // If pu is '' or null, we force to have a numeric value + $type = $productsupplier->type; + if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') { + $price_base_type = 'HT'; + $pu = price2num($price_ht, 'MU'); + $pu_devise = price2num($price_ht_devise, 'CU'); + } elseif (GETPOST('price_ttc') != '' || GETPOST('price_ttc_devise') != '') { + $price_base_type = 'TTC'; + $pu = price2num($price_ttc, 'MU'); + $pu_devise = price2num($price_ttc_devise, 'CU'); + } else { + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency + $pu = $productsupplier->fourn_pu; + $pu_devise = 0; + } else { + $pu = $productsupplier->fourn_pu; + $pu_devise = $productsupplier->fourn_multicurrency_unitprice; + } + } + + if (empty($pu)) { + $pu = 0; // If pu is '' or null, we force to have a numeric value } // If GETPOST('idprodfournprice') is a numeric, we can use it. If it is empty or if it is 'idprod_123', we should use -1 (not used) $fournprice = (is_numeric(GETPOST('idprodfournprice', 'alpha')) ? GETPOST('idprodfournprice', 'alpha') : -1); $buyingprice = 0; - $pu_ht_devise = price2num($price_ht_devise, 'MU'); $result = $object->addline( $desc, - $pu_ht, + ($price_base_type == 'HT' ? $pu : 0), $qty, $tva_tx, $localtax1_tx, @@ -669,7 +720,7 @@ if (empty($reshook)) { $productsupplier->id, $remise_percent, $price_base_type, - $pu_ttc, + ($price_base_type == 'TTC' ? $pu : 0), $tva_npr, $type, -1, @@ -683,7 +734,7 @@ if (empty($reshook)) { $productsupplier->fk_unit, '', 0, - $pu_ht_devise, + $pu_devise, $date_start, $date_end ); @@ -709,6 +760,7 @@ if (empty($reshook)) { } elseif ((GETPOST('price_ht') !== '' || GETPOST('price_ttc') !== '' || GETPOST('multicurrency_price_ht') != '') && empty($error)) { // Free product. // $price_ht is already set $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); @@ -718,21 +770,22 @@ if (empty($reshook)) { $fk_unit = GETPOST('units', 'alpha'); if (!preg_match('/\((.*)\)/', $tva_tx)) { - $tva_tx = price2num($tva_tx); // When vat is text input field + $tva_tx = price2num($tva_tx); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' } // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - if ($price_ht !== '') { + if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') { $pu_ht = price2num($price_ht, 'MU'); // $pu_ht must be rounded according to settings } else { $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } $price_base_type = 'HT'; - $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $pu_ht_devise = price2num($price_ht_devise, 'CU'); + $info_bits = 0; $result = $object->addline( $desc, @@ -800,6 +853,7 @@ if (empty($reshook)) { unset($_POST['price_ht']); unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); + unset($_POST['fourn_ref']); unset($_POST['tva_tx']); unset($_POST['label']); unset($_POST['product_ref']); @@ -813,6 +867,8 @@ if (empty($reshook)) { unset($_POST['np_markRate']); unset($_POST['dp_desc']); unset($_POST['idprodfournprice']); + unset($_POST['units']); + unset($_POST['idprod']); unset($_POST['date_starthour']); @@ -852,10 +908,9 @@ if (empty($reshook)) { $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); if (GETPOST('price_ht') != '') { + $price_base_type = 'HT'; $ht = price2num(GETPOST('price_ht'), '', 2); - } - - if (GETPOST('price_ttc') != '') { + } else { $reg = array(); $vatratecleaned = $vat_rate; if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)" @@ -865,10 +920,10 @@ if (empty($reshook)) { $ttc = price2num(GETPOST('price_ttc'), '', 2); $ht = $ttc / (1 + ($vatratecleaned / 100)); + $price_base_type = 'HT'; } - $price_base_type = 'HT'; - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU'); + $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU', 2); // Add buying price $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); From 50847efdf8fe0f5bd0e248c916f852937b72d768 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 11:44:36 +0100 Subject: [PATCH 170/752] Add the country into the popup with info on company. --- htdocs/core/tpl/objectline_create.tpl.php | 17 ++++++++++------- htdocs/main.inc.php | 5 ++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b09a33f44f6..17683562be5 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -645,17 +645,20 @@ if (!empty($usemargins) && $user->rights->margins->creer) { $("#select_type").change(function() { setforfree(); - if (jQuery('#select_type').val() >= 0) - { - /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ + + if (jQuery('#select_type').val() >= 0) { + console.log("Set focus on description field"); + /* this focus code works on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); - /* focus if CKEDITOR */ - if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") - { + /* this focus code works for CKEDITOR */ + if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") { var editor = CKEDITOR.instances['dp_desc']; - if (editor) { editor.focus(); } + if (editor) { + editor.focus(); + } } } + console.log("Hide/show date according to product type"); if (jQuery('#select_type').val() == '0') { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 51a7dcfafcb..fe0986e8d13 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2104,6 +2104,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID6"), 6).''; } $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA"), 'VAT').''; + $dropdownBody .= '
'.$langs->trans("Country").': '.$langs->trans("Country".$mysoc->country_code).''; $dropdownBody .= ''; @@ -2242,7 +2243,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') '; } else { $btnUser = ' -
'; } + print ''; } else { print ''; @@ -501,26 +503,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Bank check number print ''; print ''; // Check transmitter print ''; print ''; // Bank name print ''; print ''; // Comments print ''; print ''; + print ''; + print ''; print '
'; + print '
aa'; $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '

'."\n".$langs->trans($constname . 'Tooltip2') : ''); print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; print '
'; @@ -314,6 +315,7 @@ if ($action == 'edit') { $setupnotempty++; print '
'; $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '

'."\n".$langs->trans($constname . 'Tooltip2') : ''); print $form->textwithpicto($langs->trans($constname), $tooltiphelp); print '
'; diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 516c2b41e13..3bec23d0d37 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -75,7 +75,7 @@ class modPartnership extends DolibarrModules // $this->editor_url = 'https://www.example.com'; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'development'; + $this->version = 'experimental'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index bc334fe08cf..9cd52930714 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -37,7 +37,8 @@ EventOrganization=Event organization Settings=Settings EventOrganizationSetupPage = Event Organization setup page EVENTORGANIZATION_TASK_LABEL = Label of tasks to create automatically when project is validated -EVENTORGANIZATION_TASK_LABELTooltip = When you validate an organized event, some tasks can be automatically created in the project

For example:
Send Call for Conference
Send Call for Booth
Receive call for conferences
Receive call for Booth
Open subscriptions to events for attendees
Send remind of event to speakers
Send remind of event to Booth hoster
Send remind of event to attendees +EVENTORGANIZATION_TASK_LABELTooltip = When you validate an event to organize, some tasks can be automatically created in the project

For example:
Send Call for Conferences
Send Call for Booths
Validate suggestions of Conferences
Validate application for Booths
Open subscriptions to the event for attendees
Send a remind of the event to speakers
Send a remind of the event to Booth hosters
Send a remind of the event to attendees +EVENTORGANIZATION_TASK_LABELTooltip2=Keep empty if you don't need to create tasks automatically. EVENTORGANIZATION_CATEG_THIRDPARTY_CONF = Category to add to third-parties automatically created when someone suggests a conference EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH = Category to add to third-parties automatically created when they suggests a booth EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF = Template of email to send after receiving a suggestion of a conference. diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 4ce28a34cf2..062f0592020 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2402,7 +2402,7 @@ img.photorefnoborder { } .trextrafieldseparator td, .trextrafields_collapse_last td { /* border-bottom: 2px solid var(--colorbackhmenu1) !important; */ - border-bottom: 2px solid var(--colortopbordertitle1) !important; + /* border-bottom: 2px solid var(--colortopbordertitle1) !important; */ } .tdhrthin { From 453c8981e835c6dbd956be607dfdc5325e1da4b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 12:24:28 +0100 Subject: [PATCH 172/752] CSS --- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 996f1f90f9c..08e4503748f 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1886,7 +1886,7 @@ class ExtraFields $out = '<'.$tagtype.' id="trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'">'; $out .= '<'.$tagtype_dyn.' '.(!empty($colspan)?'colspan="' . $colspan . '"':'').'>'; // Some js code will be injected here to manage the collapsing of extrafields - $out .= ' '; + $out .= ' '; $out .= ''; $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]); $out .= ''; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index ac243396c72..da6f90892c4 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021 Frédéric France * * 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 From c2a088c5ff022e3eec4eb4342f401950fde1a5a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 12:34:52 +0100 Subject: [PATCH 173/752] Fix regression in phpunit --- htdocs/core/lib/security2.lib.php | 4 +--- test/phpunit/SecurityTest.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 1cacd70d602..4b70419630f 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -69,8 +69,6 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Validation of login/pass/entity with standard modules if (empty($login)) { - unset($_SESSION["dol_loginmesg"]); - $test = true; foreach ($authmode as $mode) { if ($test && $mode && !$login) { @@ -113,7 +111,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Load translation files required by the page $langs->loadLangs(array('other', 'main', 'errors')); - $_SESSION["dol_loginmesg"] = (isset($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"].', ' : '').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode); + $_SESSION["dol_loginmesg"] = (empty($_SESSION["dol_loginmesg"]) ? '' : $_SESSION["dol_loginmesg"].', ').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode); } } } diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index eabfe389174..e1180c980ef 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -604,7 +604,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); print __METHOD__." login=".$login."\n"; - $this->assertEquals($login, ''); // Expected '' because should failed because login 'auto' does not exists + $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists } /** From 97a1774bf3a55fec7e92e563f934103f5027fc7a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 26 Mar 2022 12:57:30 +0100 Subject: [PATCH 174/752] NEW add hooks contact tab badge and hooks parameter for avoid conflicts --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/company.lib.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index eca88386656..0f8a55960c9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8864,7 +8864,7 @@ class Form // Add where from hooks if (is_object($hookmanager)) { - $parameters = array(); + $parameters = array('showrefnav' => true); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $object->next_prev_filter .= $hookmanager->resPrint; } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8ebf2e02047..a98931ab79f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -65,6 +65,15 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".((int) $object->id); + // Add table from hooks + $parameters = array('contacttab' => true); + $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= " WHERE p.fk_soc = ".$object->id; + // Add where from hooks + $parameters = array('contacttab' => true); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); From 009ad3be0f052e239f7a60f2db2effe6fc5c90c1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 26 Mar 2022 13:10:23 +0100 Subject: [PATCH 175/752] FIX remove unused code --- htdocs/core/lib/company.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index a98931ab79f..116c2beeb20 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -64,12 +64,11 @@ function societe_prepare_head(Societe $object) } else { $sql = "SELECT COUNT(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; - $sql .= " WHERE p.fk_soc = ".((int) $object->id); // Add table from hooks $parameters = array('contacttab' => true); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " WHERE p.fk_soc = ".$object->id; + $sql .= " WHERE p.fk_soc = ".((int) $object->id); // Add where from hooks $parameters = array('contacttab' => true); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook From d75483552d3400da9b7a8e1919460032c19ae4df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 15:48:36 +0100 Subject: [PATCH 176/752] Responsive --- htdocs/compta/paiement.php | 13 ++++++++----- htdocs/fourn/facture/paiement.php | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 9f40d2daa88..324c4161ac6 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -491,8 +491,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($facture->type == 2) { print '
'.$langs->trans('AccountToDebit').''; - print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, '', 1); + print img_picto('', 'bank_account'); + print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1); print ' 
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print '
'.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; + print ' ('.$langs->trans("ChequeMaker").')'; print '
'.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; + print ' ('.$langs->trans("ChequeBank").')'; print '
'.$langs->trans('Comments').''; - print '
'; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 4b6e5bf151c..2662e38951d 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -499,7 +499,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->banque->enabled)) { print ''.$langs->trans('Account').''; print img_picto('', 'bank_account', 'class="pictofixedwidth"'); - $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid, 'accountid', 0, '', 2); + print $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1); print ''; } else { print ' '; From 55e414ca306aae45118a7ba5f271421fb8b527e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 16:02:53 +0100 Subject: [PATCH 177/752] Fix sql --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 85e9350eac3..59f0d640ba7 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -261,7 +261,7 @@ ALTER TABLE llx_product_attribute CHANGE rang position INTEGER DEFAULT 0 NOT NUL ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; -ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); +ALTER TABLE llx_mailing ADD UNIQUE INDEX uk_mailing(titre, entity); create table llx_inventory_extrafields ( From 35c57988a06a84c359d2fa691fafb024b0fe70cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Mar 2022 20:06:50 +0100 Subject: [PATCH 178/752] Responsive --- htdocs/takepos/css/pos.css.php | 16 +++++++++++++++- htdocs/takepos/index.php | 4 ++-- htdocs/takepos/invoice.php | 2 +- htdocs/takepos/split.php | 4 ++-- htdocs/theme/eldy/global.inc.php | 3 ++- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index c57b145d94c..ba85c111bcd 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -794,7 +794,8 @@ div#moreinfo, div#infowarehouse { .headersplit { height: 10%; width: 100%; - padding: 10px; + padding-top: 20px; + padding-bottom: 2px; } .headercontent { @@ -806,6 +807,19 @@ div#moreinfo, div#infowarehouse { background-color: rgb(233,234,237); } + +@media only screen and (max-width: 767px) +{ + .headercontent { + width: 80%; + } + + .headersplit .headercontent { + font-size: 1em; + } +} + + .row:after { content: ""; display: table; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 5650c0d4fdd..31c51a4c7b1 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -910,7 +910,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
'."\n"; -print ''; +print ''."\n"; // End of page llxFooter(); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index bd37c650f2f..ba260737678 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -6475,6 +6475,17 @@ dd.dropdowndd ul li { white-space: nowrap; } +/* ============================================================================== */ +/* Kanban */ +/* ============================================================================== */ + +.info-box-label { + max-width: 180px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + /* ============================================================================== */ /* Markdown rendering */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 117bebe12ca..764b21bba77 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6345,6 +6345,18 @@ dd.dropdowndd ul li { } +/* ============================================================================== */ +/* Kanban */ +/* ============================================================================== */ + +.info-box-label { + max-width: 180px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + + /* ============================================================================== */ /* Markdown rendering */ /* ============================================================================== */ From e7db103b57d527a15f7a8fc4e52ee7e8077a3995 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 31 Mar 2022 18:55:54 +0200 Subject: [PATCH 247/752] fix: on update with action reminder in future there is user key error --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 0833929c82a..adfd3f34429 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -659,7 +659,7 @@ if (empty($reshook) && $action == 'update') { $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $object->loadReminders(); + $object->loadReminders($remindertype,0,false); if (!empty($object->reminders) && $object->datep > dol_now()) { foreach ($object->reminders as $reminder) { $reminder->delete($user); From 7f4e71f66f7db0a7b4699ac4871c74a4bd836223 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 31 Mar 2022 21:43:48 +0200 Subject: [PATCH 248/752] Comments --- htdocs/takepos/invoice.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d7de5ffd7e8..1dbf033482d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -535,6 +535,7 @@ if ($action == "addline") { } $idoflineadded = 0; + // Group if enabled. Skip group if line already sent to the printer if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT) && $line->special_code != "4") { foreach ($invoice->lines as $line) { if ($line->product_ref == $prod->ref) { From 5df5050418461383fbabb72fad6dac0eb5df1c04 Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Fri, 1 Apr 2022 09:14:04 +0200 Subject: [PATCH 249/752] Apply suggestions from code review replace spaces with tabs --- htdocs/core/boxes/box_dolibarr_state_board.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 028547f7867..9661b1d363e 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -79,9 +79,9 @@ class box_dolibarr_state_board extends ModeleBoxes if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { $hookmanager = new HookManager($this->db); $hookmanager->initHooks(array('index')); - $object = new stdClass; - $action = ''; - $hookmanager->executeHooks('addStatisticLine', array(), $object, $action); + $object = new stdClass; + $action = ''; + $hookmanager->executeHooks('addStatisticLine', array(), $object, $action); $boxstatItems = array(); $boxstatFromHook = ''; $boxstatFromHook = $hookmanager->resPrint; From 113af78a9c4f0e042578bc78e68606a8b8b01630 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2022 09:35:45 +0200 Subject: [PATCH 250/752] Add column for private widgets --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 1 + htdocs/install/mysql/tables/llx_boxes_def.sql | 2 ++ 2 files changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 59f0d640ba7..e62ee2fa8aa 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -299,3 +299,4 @@ UPDATE llx_c_availability SET type_duration = 'w', qty = 2 WHERE code = 'AV_2W'; UPDATE llx_c_availability SET type_duration = 'w', qty = 3 WHERE code = 'AV_3W'; UPDATE llx_c_availability SET type_duration = 'w', qty = 4 WHERE code = 'AV_4W'; +ALTER TABLE llx_boxes_def ADD COLUMN fk_user integer DEFAULT 0 NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_boxes_def.sql b/htdocs/install/mysql/tables/llx_boxes_def.sql index fbdf0e3ed36..804079df8b5 100644 --- a/htdocs/install/mysql/tables/llx_boxes_def.sql +++ b/htdocs/install/mysql/tables/llx_boxes_def.sql @@ -18,11 +18,13 @@ -- -- =========================================================================== +-- Table create table llx_boxes_def ( rowid integer AUTO_INCREMENT PRIMARY KEY, file varchar(200) NOT NULL, -- Do not increase this as file+note must be small to allow index entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_user integer DEFAULT 0 NOT NULL, -- if widget is privte to one user tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, note varchar(130) -- Do not increase this as file+note must be small to allow index )ENGINE=innodb; From 0c44f164c73d6da4db054da03bf2e150c2fa0b56 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 1 Apr 2022 09:38:06 +0200 Subject: [PATCH 251/752] fix: Show error message on inventory input line for serial num product --- htdocs/product/inventory/inventory.php | 12 +++++++++--- htdocs/product/stock/class/mouvementstock.class.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 6026e4316e4..6a6d4c345ce 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -307,6 +307,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';*/ if (GETPOST('addline', 'alpha')) { + $qty= (GETPOST('qtytoadd') != '' ? price2num(GETPOST('qtytoadd', 'MS')) : null); if ($fk_warehouse <= 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); @@ -323,12 +324,17 @@ if (empty($reshook)) { $tmpproduct = new Product($db); $result = $tmpproduct->fetch($fk_product); - if (!$error && $tmpproduct->status_batch && !$batch) { + if (empty($error) && $tmpproduct->status_batch>0 && empty($batch)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorProductNeedBatchNumber", $tmpproduct->ref), null, 'errors'); } - if (!$error && !$tmpproduct->status_batch && $batch) { + if (empty($error) && $tmpproduct->status_batch==2 && !empty($batch) && $qty>1) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("TooManyQtyForSerialNumber", $tmpproduct->ref, $batch), null, 'errors'); + } + if (empty($error) && empty($tmpproduct->status_batch) && !empty($batch)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorProductDoesNotNeedBatchNumber", $tmpproduct->ref), null, 'errors'); @@ -341,7 +347,7 @@ if (empty($reshook)) { $tmp->fk_product = $fk_product; $tmp->batch = $batch; $tmp->datec = $now; - $tmp->qty_view = (GETPOST('qtytoadd') != '' ? price2num(GETPOST('qtytoadd', 'MS')) : null); + $tmp->qty_view = $qty; $result = $tmp->create($user); if ($result < 0) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 44b91549c40..f64c83fa015 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -597,7 +597,7 @@ class MouvementStock extends CommonObject if ($product->status_batch == 2 && $qty > 0) { // We check only if we increased qty if ($this->getBatchCount($fk_product, $batch) > 1) { $error++; - $this->errors[] = $langs->trans("TooManyQtyForSerialNumber", $batch, $product->ref); + $this->errors[] = $langs->trans("TooManyQtyForSerialNumber", $product->ref, $batch); } } } From fa0e7a641c7d2c0030e304f550ec1020584f41e0 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 1 Apr 2022 09:52:16 +0200 Subject: [PATCH 252/752] FIX : Missing unset fields after updateline expensereport --- htdocs/expensereport/card.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 240fdcfb73c..a1b26318a1b 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1282,6 +1282,16 @@ if (empty($reshook)) { $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } + + unset($qty); + unset($value_unit_ht); + unset($value_unit); + unset($vatrate); + unset($comments); + unset($fk_c_type_fees); + unset($fk_project); + unset($date); + } //header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); From d188f44a4c036e484bbfd740652163ccdfbbeb90 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 1 Apr 2022 07:58:41 +0000 Subject: [PATCH 253/752] Fixing style errors. --- htdocs/expensereport/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a1b26318a1b..50ee78b4097 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1291,7 +1291,6 @@ if (empty($reshook)) { unset($fk_c_type_fees); unset($fk_project); unset($date); - } //header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); From 8349e4855993f74300f8e53518730dbac457ecfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2022 11:24:45 +0200 Subject: [PATCH 254/752] Reponsive --- htdocs/compta/accounting-files.php | 27 ++++++++++++++++------- htdocs/core/class/html.formfile.class.php | 10 ++++++--- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 1f821bf733b..ea0bd9de49e 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -672,7 +672,7 @@ if (!empty($date_start) && !empty($date_stop)) { print ''; // Type - print ''.$langs->trans($data['item']).''; + print ''.$langs->trans($data['item']).''; // Date print ''; @@ -685,7 +685,7 @@ if (!empty($date_start) && !empty($date_stop)) { print "\n"; // Ref - print ''; + print ''; if ($data['item'] == 'Invoice') { $invoice->id = $data['id']; @@ -733,23 +733,33 @@ if (!empty($date_start) && !empty($date_stop)) { print ''; // File link - print ''; + print ''; if (!empty($data['files'])) { foreach ($data['files'] as $id => $filecursor) { - print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; + $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0); + if ($tmppreview) { + print $tmppreview; + } + $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']); + print ''; + if (empty($tmppreview)) { + print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright'); + } + print $filename; + print '
'; } } print "\n"; // Paid - print ''.$data['paid'].''; + print ''.($data['paid'] ? yn($data['paid']) : '').''; // Total ET - print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; // Total IT - print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; // Total VAT - print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; print ''.dol_escape_htmltag($data['thirdparty_name'])."\n"; @@ -757,6 +767,7 @@ if (!empty($date_start) && !empty($date_stop)) { print ''.$data['country_code']."\n"; + // VAT number print ''.dol_escape_htmltag($data['vatnum'])."\n"; if ($data['sens']) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6c4ff6e30f1..b955fa4a51d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -2144,7 +2144,7 @@ class FormFile * @param array $file Array with data of file. Example: array('name'=>...) * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs - * @param integer $ruleforpicto Rule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file) + * @param integer $ruleforpicto Rule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file). Use a negative value to show a generic picto even if preview not available. * @param string $param More param on http links * @return string $out Output string with HTML */ @@ -2160,11 +2160,15 @@ class FormFile //$out.= ''; if (empty($ruleforpicto)) { //$out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail'); - $out .= ''; + $out .= ''; } else { - $out .= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); + $out .= img_mime($relativepath, $langs->trans('Preview').' '.$file['name'], 'pictofixedwidth'); } $out .= ''; + } else { + if ($ruleforpicto < 0) { + $out .= img_picto('', 'generic', '', false, 0, 0, '', 'paddingright pictofixedwidth'); + } } } return $out; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ba260737678..11dea235094 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2280,7 +2280,7 @@ span.widthpictotitle.pictotitle { vertical-align: middle; margin-top: -3px } -.pictowarning, .pictoerror, .pictopreview, .picto.error { +.pictowarning, .pictoerror, .pictopreview, .pictonopreview, .picto.error { padding-: 3px; } .pictowarning { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 764b21bba77..83d656196e2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2294,7 +2294,7 @@ td.nobordernopadding.widthpictotitle.col-picto { vertical-align: middle; margin-top: -3px } -.pictowarning, .pictoerror, .pictopreview { +.pictowarning, .pictoerror, .pictopreview, .pictonopreview { padding-: 3px; } .pictowarning { From 9be7bae765778020680d9ca96a9ce9051bdf482b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2022 11:24:58 +0200 Subject: [PATCH 255/752] Fix menu entry invalid --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c03b8aebfe1..b44f082d650 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1687,8 +1687,8 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef if ($objp->nature == 5 && !empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { $nature = "expensereports"; } - if ($objp->nature == 1) { - $nature = "various"; + if ($objp->nature == 1 && !empty($conf->asset->enabled)) { + $nature = "various"; // Warning: The page /accountancy/journal/variousjournal.php is bugged. It read tables that does not exists. } if ($objp->nature == 8) { $nature = "inventory"; From a9faf5fb54791c14e995c30e98cc9c826210db59 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 1 Apr 2022 11:29:38 +0200 Subject: [PATCH 256/752] feat: Add rank column into contract line --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_contratdet.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index e62ee2fa8aa..353eb71eac4 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -300,3 +300,5 @@ UPDATE llx_c_availability SET type_duration = 'w', qty = 3 WHERE code = 'AV_3W'; UPDATE llx_c_availability SET type_duration = 'w', qty = 4 WHERE code = 'AV_4W'; ALTER TABLE llx_boxes_def ADD COLUMN fk_user integer DEFAULT 0 NOT NULL; + +ALTER TABLE llx_contratdet ADD COLUMN rang integer DEFAULT 0 AFTER info_bits; diff --git a/htdocs/install/mysql/tables/llx_contratdet.sql b/htdocs/install/mysql/tables/llx_contratdet.sql index 075de80270d..6d52cfc3462 100644 --- a/htdocs/install/mysql/tables/llx_contratdet.sql +++ b/htdocs/install/mysql/tables/llx_contratdet.sql @@ -56,6 +56,7 @@ create table llx_contratdet product_type integer DEFAULT 1, -- Type of line (1=service by default) info_bits integer DEFAULT 0, -- TVA NPR ou non + rang integer DEFAULT 0, buy_price_ht double(24,8) DEFAULT NULL, -- buying price fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added was created (may be used to update buy_price_ht when future invoice will be created) From cbf89df591050b0fa90fec73d5840818dfe402c4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 1 Apr 2022 11:54:16 +0200 Subject: [PATCH 257/752] new: add hidden option on contract PDF line --- htdocs/core/modules/contract/doc/pdf_strato.modules.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 67dca0ecf1b..085f7bee190 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -355,7 +355,12 @@ class pdf_strato extends ModelePDFContract $desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines) $txt = ''; - $txt .= $outputlangs->transnoentities("Quantity").' : '.$objectligne->qty.' - '.$outputlangs->transnoentities("UnitPrice").' : '.price($objectligne->subprice).''; // Desc (not empty for free lines) + if (empty($conf->global->CONTRACT_HIDE_QTY_ON_PDF)) { + $txt .= $outputlangs->transnoentities("Quantity") . ' : ' . $objectligne->qty . ''; + } + if (empty($conf->global->CONTRACT_HIDE_PRICE_ON_PDF)) { + $txt .= ' - ' . $outputlangs->transnoentities("UnitPrice") . ' : ' . price($objectligne->subprice) . ''; + } if (empty($conf->global->CONTRACT_HIDE_PLANNED_DATE_ON_PDF)) { $txt .= '
'; $txt .= $outputlangs->transnoentities("DateStartPlannedShort")." : ".$datei." - ".$outputlangs->transnoentities("DateEndPlanned")." : ".$datee.''; From a3dbcd0c27f0844283a8940ccb45d60fc6311890 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2022 13:09:11 +0200 Subject: [PATCH 258/752] Clean language files --- htdocs/comm/propal/list.php | 4 ++-- htdocs/commande/list.php | 2 +- htdocs/core/modules/modVariants.class.php | 6 +++--- htdocs/langs/en_US/admin.lang | 6 +++--- htdocs/langs/en_US/orders.lang | 1 - htdocs/langs/en_US/projects.lang | 1 + htdocs/langs/en_US/propal.lang | 3 --- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 6eb9ba5014c..73b4c479b2e 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -361,7 +361,7 @@ if ($action == 'validate' && $permissiontovalidate) { if ($tmpproposal->valid($user) > 0) { setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs'); } else { - setEventMessage($langs->trans('CantBeValidated'), 'errors'); + setEventMessage($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } else { @@ -398,7 +398,7 @@ if ($action == "sign" && $permissiontoclose) { $error++; } } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); + setEventMessage($langs->trans('MustBeValidatedToBeSigned', $tmpproposal->ref), 'errors'); $error++; } } else { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index c819bd1dc55..fcbd00fe945 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -318,7 +318,7 @@ if ($action == 'validate' && $permissiontoadd) { if ($objecttmp->valid($user, $idwarehouse)) { setEventMessage($langs->trans('hasBeenValidated', $objecttmp->ref), 'mesgs'); } else { - setEventMessage($langs->trans('CantBeValidated'), 'errors'); + setEventMessage($objecttmp->error, $objecttmp->errors, 'errors'); $error++; } } else { diff --git a/htdocs/core/modules/modVariants.class.php b/htdocs/core/modules/modVariants.class.php index ad71d2ca300..e1364fd845e 100644 --- a/htdocs/core/modules/modVariants.class.php +++ b/htdocs/core/modules/modVariants.class.php @@ -112,15 +112,15 @@ class modVariants extends DolibarrModules $r = 0; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read objects of ProductAttribute'; // Permission label + $this->rights[$r][1] = 'Read attributes of variants'; // Permission label $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update objects of ProductAttribute'; // Permission label + $this->rights[$r][1] = 'Create/Update attributes of variants'; // Permission label $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete objects of ProductAttribute'; // Permission label + $this->rights[$r][1] = 'Delete attributes of variants'; // Permission label $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) $r++; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 794893e2133..d4073f80b7c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -883,9 +883,9 @@ Permission564=Record Debits/Rejections of credit transfer Permission601=Read stickers Permission602=Create/modify stickers Permission609=Delete stickers -Permission611=Read objects of ProductAttribute -Permission612=Create/Update objects of ProductAttribute -Permission613=Delete objects of ProductAttribute +Permission611=Read attributes of variants +Permission612=Create/Update attributes of variants +Permission613=Delete attributes of variants Permission650=Read Bills of Materials Permission651=Create/Update Bills of Materials Permission652=Delete Bills of Materials diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index fb30758aba9..a4261f8e62c 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -106,7 +106,6 @@ GenerateBill=Generate invoice ClassifyShipped=Classify delivered PassedInShippedStatus=classified delivered YouCantShipThis=I can't classify this. Please check user permissions -MustBeValidatedBefore=must be Validated or In process in order to be classified as shipped DraftOrders=Draft orders DraftSuppliersOrders=Draft purchase orders OnProcessOrders=In process orders diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index cc63f8e7c68..1e0ed42d3e3 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -190,6 +190,7 @@ PlannedWorkload=Planned workload PlannedWorkloadShort=Workload ProjectReferers=Related items ProjectMustBeValidatedFirst=Project must be validated first +MustBeValidatedToBeSigned=%s must be validated first to be set to Signed. FirstAddRessourceToAllocateTime=Assign a user resource as contact of project to allocate time InputPerDay=Input per day InputPerWeek=Input per week diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 4c95b3b1851..ed25b5501dc 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -93,11 +93,8 @@ ConfirmMassNoSignature=Bulk Not signed confirmation ConfirmMassNoSignatureQuestion=Are you sure you want to set not signed the selected records ? IsNotADraft=is not a draft PassedInOpenStatus=has been validated -CantBeSign=cannot be signed Sign=Sign Signed=signed -CantBeSign=cannot be signed -CantBeValidated=cannot be validated ConfirmMassValidation=Bulk Validate confirmation ConfirmMassSignature=Bulk Signature confirmation ConfirmMassValidationQuestion=Are you sure you want to validate the selected records ? From 106e3072dcbbe1415c9f4a34822b2843f305e451 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2022 13:20:40 +0200 Subject: [PATCH 259/752] Update card.php --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index adfd3f34429..a5a898ef7f2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -659,7 +659,7 @@ if (empty($reshook) && $action == 'update') { $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $object->loadReminders($remindertype,0,false); + $object->loadReminders($remindertype, 0, false); if (!empty($object->reminders) && $object->datep > dol_now()) { foreach ($object->reminders as $reminder) { $reminder->delete($user); From 4c150d85c9ad25f533dcf049e725365d2810a07f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2022 13:23:45 +0200 Subject: [PATCH 260/752] Doc --- htdocs/conf/conf.php.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 6bf2873b50c..44f0d63d69f 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -204,7 +204,7 @@ $dolibarr_main_authentication='dolibarr'; // $dolibarr_main_auth_ldap_servertype='openldap'; // openldap, activedirectory or egroupware // $dolibarr_main_auth_ldap_login_attribute='loginfield'; // Ex: uid or samaccountname for active directory // $dolibarr_main_auth_ldap_dn='ou=users,dc=my-domain,dc=com'; // Ex: ou=users,dc=my-domain,dc=com -// $dolibarr_main_auth_ldap_filter = ''; // If defined, two previous parameters are not used to find a user into LDAP. Ex: (uid=%1%) or &(uid=%1%)(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com). +// $dolibarr_main_auth_ldap_filter = ''; // If defined, the two previous parameters (dolibarr_main_auth_ldap_login_attribute and dolibarr_main_auth_ldap_dn) are not used to find a user into LDAP. Instead we use this search string. Ex: (uid=%1%) or &(uid=%1%)(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com). // $dolibarr_main_auth_ldap_admin_login=''; // Required only if anonymous bind disabled. Ex: cn=admin,dc=example,dc=com // $dolibarr_main_auth_ldap_admin_pass=''; // Required only if anonymous bind disabled. Ex: secret // $dolibarr_main_auth_ldap_debug='false'; From f2480b6443d1450f5924541ce9d7759ad52bad84 Mon Sep 17 00:00:00 2001 From: jpb Date: Fri, 1 Apr 2022 13:56:10 +0200 Subject: [PATCH 261/752] fix : remove tds add by mistake --- htdocs/expensereport/card.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 5ffef81e4c0..7696e8c9807 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2493,8 +2493,6 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; - print ''; print ''; print ''; From 1cdf55fea0bd48a7f49e354940a8925f73707305 Mon Sep 17 00:00:00 2001 From: jpb Date: Fri, 1 Apr 2022 14:21:13 +0200 Subject: [PATCH 262/752] remove empty line --- htdocs/expensereport/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 7696e8c9807..a39a14dbab4 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2494,7 +2494,6 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; // Line number From 88e6c67c10ab8459833dd158939f213ffb2d336e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2022 14:29:11 +0200 Subject: [PATCH 263/752] Look and feel v16 of media manager --- .../browser/default/browser.css | 6 ++-- .../browser/default/browser.php | 29 ++++++++++++---- .../browser/default/frmactualfolder.php | 19 +++++++++++ .../browser/default/frmcreatefolder.php | 31 +++++++++++++----- .../browser/default/frmfolders.php | 21 +++++++++++- .../browser/default/frmresourceslist.php | 19 +++++++++++ .../browser/default/frmupload.php | 30 ++++++++++++++--- .../filemanagerdol/browser/default/spacer.gif | Bin 43 -> 0 bytes 8 files changed, 131 insertions(+), 24 deletions(-) delete mode 100644 htdocs/core/filemanagerdol/browser/default/spacer.gif diff --git a/htdocs/core/filemanagerdol/browser/default/browser.css b/htdocs/core/filemanagerdol/browser/default/browser.css index 0df72be1a35..d6ec1e212aa 100644 --- a/htdocs/core/filemanagerdol/browser/default/browser.css +++ b/htdocs/core/filemanagerdol/browser/default/browser.css @@ -42,8 +42,8 @@ body.FileArea body, td, input, select { - font-size: 11px; - font-family: 'Microsoft Sans Serif', Arial, Helvetica, Verdana, sans-serif; + /* font-size: 11px; */ + /* font-family: 'Microsoft Sans Serif', Arial, Helvetica, Verdana, sans-serif; */ } .ActualFolder @@ -78,4 +78,6 @@ body, td, input, select .fullHeight { height: 100%; + padding-left: 10px; + padding-right: 10px; } diff --git a/htdocs/core/filemanagerdol/browser/default/browser.php b/htdocs/core/filemanagerdol/browser/default/browser.php index 50bd538078b..b5bce100d39 100644 --- a/htdocs/core/filemanagerdol/browser/default/browser.php +++ b/htdocs/core/filemanagerdol/browser/default/browser.php @@ -25,15 +25,30 @@ require '../../connectors/php/config.php'; // This include the define('NOTOKENRE global $Config; - - ?> - + <?php echo $langs->trans("MediaBrowser").' - '.$Config['UserFilesAbsolutePathRelative']; ?> +'."\n"; +// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php' +$themepath = dol_buildpath($conf->css, 1); +$themesubdir = ''; +if (!empty($conf->modules_parts['theme'])) { // This slow down + foreach ($conf->modules_parts['theme'] as $reldir) { + if (file_exists(dol_buildpath($reldir.$conf->css, 0))) { + $themepath = dol_buildpath($reldir.$conf->css, 1); + $themesubdir = $reldir; + break; + } + } +} + +//print 'themepath='.$themepath.' themeparam='.$themeparam;exit; +print ''."\n"; +?> - + - + - + diff --git a/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php b/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php index d2d7a0966ce..c66187ee433 100644 --- a/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php +++ b/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php @@ -22,6 +22,7 @@ define('NOTOKENRENEWAL', 1); // Disables token renewal require '../../../../main.inc.php'; + ?> '."\n"; +// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php' +$themepath = dol_buildpath($conf->css, 1); +$themesubdir = ''; +if (!empty($conf->modules_parts['theme'])) { // This slow down + foreach ($conf->modules_parts['theme'] as $reldir) { + if (file_exists(dol_buildpath($reldir.$conf->css, 0))) { + $themepath = dol_buildpath($reldir.$conf->css, 1); + $themesubdir = $reldir; + break; + } + } +} + +//print 'themepath='.$themepath.' themeparam='.$themeparam;exit; +print ''."\n"; +?> '."\n"; + print ''."\n"; } // jQuery jeditable for Edit In Place features diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 9c20aa562d7..7266e029985 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -243,7 +243,7 @@ if ($user->rights->projet->all->creer || $user->rights->projet->creer) { } } -$linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam); +$linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam); $linktotasks = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id, '', 1, array('morecss'=>'reposition')); $linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition marginleftonly btnTitleSelected')); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 11dea235094..0715723bf55 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3646,9 +3646,11 @@ table.liste tr:last-of-type td, table.noborder:not(#tablelines) tr:last-of-type border-bottom-color: var(--colortopbordertitle1); border-bottom-style: solid; } +/* div.tabBar div.fichehalfright table.noborder:not(.margintable):not(.paymenttable):not(.lastrecordtable):last-of-type { border-bottom: 1px solid var(--colortopbordertitle1); } +*/ div.tabBar table.border>tbody>tr:last-of-type>td { border-bottom-width: 1px; border-bottom-color: var(--colortopbordertitle1); From 395758f213699a126e2e36ce22a329a7c1279e01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Apr 2022 12:24:03 +0200 Subject: [PATCH 288/752] Doxygen --- .../emailcollector/lib/emailcollector.lib.php | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/htdocs/emailcollector/lib/emailcollector.lib.php b/htdocs/emailcollector/lib/emailcollector.lib.php index 9b63bbea66a..60611c35841 100644 --- a/htdocs/emailcollector/lib/emailcollector.lib.php +++ b/htdocs/emailcollector/lib/emailcollector.lib.php @@ -87,9 +87,10 @@ function emailcollectorPrepareHead($object) } /** - * Récupère les parties d'un message - * @param object $structure structure du message - * @return object|boolean parties du message|false en cas d'erreur + * Get parts of a message + * + * @param object $structure Structure of message + * @return object|boolean Parties du message|false en cas d'erreur */ function getParts($structure) { @@ -97,9 +98,10 @@ function getParts($structure) } /** - * Tableau définissant la pièce jointe - * @param object $part partie du message - * @return object|boolean définition du message|false en cas d'erreur + * Array with joined files + * + * @param object $part Part of message + * @return object|boolean Definition of message|false en cas d'erreur */ function getDParameters($part) { @@ -107,10 +109,11 @@ function getDParameters($part) } /** - * Récupère les pièces d'un mail donné - * @param integer $jk numéro du mail - * @param object $mbox object connection imaap - * @return array type, filename, pos + * Get attachments of a given mail + * + * @param integer $jk Number of email + * @param object $mbox object connection imaap + * @return array type, filename, pos */ function getAttachments($jk, $mbox) { @@ -140,7 +143,8 @@ function getAttachments($jk, $mbox) } /** - * Récupère la contenu de la pièce jointe par rapport a sa position dans un mail donné + * Get content of a joined file from its position into a given email + * * @param integer $jk numéro du mail * @param integer $fpos position de la pièce jointe * @param integer $type type de la pièce jointe @@ -156,11 +160,12 @@ function getFileData($jk, $fpos, $type, $mbox) } /** - * Sauvegarde de la pièce jointe dans le dossier défini avec un nom unique - * @param string $path chemin de sauvegarde dui fichier - * @param string $filename nom du fichier - * @param mixed $data contenu à sauvegarder - * @return string emplacement du fichier + * Save joined file into a directory with a given name + * + * @param string $path Path to file + * @param string $filename Name of file + * @param mixed $data contenu à sauvegarder + * @return string emplacement du fichier **/ function saveAttachment($path, $filename, $data) { @@ -186,10 +191,11 @@ function saveAttachment($path, $filename, $data) } /** - * Décode le contenu du message - * @param string $message message - * @param integer $coding type de contenu - * @return message décodé + * Decode content of a message + * + * @param string $message Message + * @param integer $coding Type of content + * @return string Decoded message **/ function getDecodeValue($message, $coding) { From d514d72ac5671ab342bb5e5b2336b387d9f58190 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Apr 2022 12:25:43 +0200 Subject: [PATCH 289/752] Doxygen --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/images.lib.php | 1 + .../class/fournisseur.facture-rec.class.php | 44 +++++++++---------- htdocs/hrm/class/skill.class.php | 2 +- htdocs/hrm/class/skilldet.class.php | 21 --------- htdocs/hrm/class/skillrank.class.php | 2 + .../template/class/api_mymodule.class.php | 2 +- .../class/api_recruitment.class.php | 9 +++- 8 files changed, 35 insertions(+), 48 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2c094ea56c7..f07b82a4c74 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7187,7 +7187,7 @@ class Form * @param int $limit Limit on number of returned lines * @param int $status Ticket status * @param string $selected_input_value Value of preselected input text (for use with ajax) - * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) + * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon before and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter * @param int $socid Thirdparty Id (to get also price dedicated to this customer) * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 6b973d89887..b8202b8e361 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -590,6 +590,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', break; } + // Before PHP8, img was a resource, With PHP8, it is a GdImage if (!is_resource($img) && !($img instanceof \GdImage)) { dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); return 0; diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 3d6c0868f01..f77dd5638f7 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -1031,29 +1031,29 @@ class FactureFournisseurRec extends CommonInvoice } /** - * Update a line to supplier invoice template + * Update a line to supplier invoice template * - * @param $rowid ID - * @param int $fk_product Product/Service ID predefined - * @param $ref Ref - * @param string $label Label of the line - * @param string $desc Description de la ligne - * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) - * @param double $qty Quantity - * @param int $remise_percent Percentage discount of the line - * @param double $txtva Taux de tva force, sinon -1 - * @param int $txlocaltax1 Local tax 1 rate (deprecated) - * @param int $txlocaltax2 Local tax 2 rate (deprecated) - * @param string $price_base_type HT or TTC - * @param int $type Type of line (0=product, 1=service) - * @param int $date_start Date start - * @param int $date_end Date end - * @param int $info_bits Bits of type of lines - * @param int $special_code Special code - * @param int $rang Position of line - * @param string $fk_unit Unit - * @param int $pu_ht_devise Unit price in currency - * @return int <0 if KO, Id of line if OK + * @param int $rowid ID + * @param int $fk_product Product/Service ID predefined + * @param string $ref Ref + * @param string $label Label of the line + * @param string $desc Description de la ligne + * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) + * @param double $qty Quantity + * @param int $remise_percent Percentage discount of the line + * @param double $txtva Taux de tva force, sinon -1 + * @param int $txlocaltax1 Local tax 1 rate (deprecated) + * @param int $txlocaltax2 Local tax 2 rate (deprecated) + * @param string $price_base_type HT or TTC + * @param int $type Type of line (0=product, 1=service) + * @param int $date_start Date start + * @param int $date_end Date end + * @param int $info_bits Bits of type of lines + * @param int $special_code Special code + * @param int $rang Position of line + * @param string $fk_unit Unit + * @param int $pu_ht_devise Unit price in currency + * @return int <0 if KO, Id of line if OK * @throws Exception */ public function updateline($rowid, $fk_product, $ref, $label, $desc, $pu_ht, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $type = 0, $date_start = 0, $date_end = 0, $info_bits = 0, $special_code = 0, $rang = -1, $fk_unit = null, $pu_ht_devise = 0) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 724c14b93c0..ececc70b4f1 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -977,7 +977,7 @@ class Skill extends CommonObject { $this->lines = array(); - $objectline = new SkillLine($this->db); + $objectline = new Skilldet($this->db); $result = $objectline->fetchAll('ASC', 'rankorder', 0, 0, array('customsql'=>'fk_skill = '.$this->id)); if (is_numeric($result)) { diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 5e2da1ba7aa..ac91e2ef21a 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -882,27 +882,6 @@ class Skilldet extends CommonObject $this->initAsSpecimenCommon(); } - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - $objectline = new SkilldetLine($this->db); - $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_skilldet = '.$this->id)); - - if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; - return $result; - } else { - $this->lines = $result; - return $this->lines; - } - } /** * Returns the reference to the following non used object depending on the active numbering module. diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index eb93208040b..aa1d70b430f 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -930,6 +930,7 @@ class SkillRank extends CommonObject { $this->lines = array(); + /* $objectline = new SkillRankLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_skillrank = '.((int) $this->id))); @@ -941,6 +942,7 @@ class SkillRank extends CommonObject $this->lines = $result; return $this->lines; } + */ } /** diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 4cb50c8de2f..04bf641930d 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -49,7 +49,7 @@ class MyModuleApi extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; $this->db = $db; $this->myobject = new MyObject($this->db); } diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php index e0c2cb5da11..ff6f3c3d65a 100644 --- a/htdocs/recruitment/class/api_recruitment.class.php +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -37,11 +37,15 @@ dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); class Recruitment extends DolibarrApi { /** - * @var jobposition $jobposition {@type jobposition} + * @var RecruitmentJobPosition $jobposition {@type RecruitmentJobPosition} */ public $jobposition; + /** + * @var RecruitmentCandidature $candidature {@type RecruitmentCandidature} + */ public $candidature; + /** * Constructor * @@ -50,12 +54,13 @@ class Recruitment extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; $this->db = $db; $this->jobposition = new RecruitmentJobPosition($this->db); $this->candidature = new RecruitmentCandidature($this->db); } + /** * Get properties of a jobposition object * From 564382ec6c24a1cfd0531500a6a63739ada15a08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Apr 2022 12:56:07 +0200 Subject: [PATCH 290/752] Upgrade ACE Editor from 1.4.7 to 1.4.14 --- COPYRIGHT | 2 +- htdocs/admin/dolistore/ajax/image.php | 5 +- htdocs/admin/dolistore/css/dolistore.css | 3 - htdocs/includes/ace/.npmignore | 3 + htdocs/includes/ace/ChangeLog.txt | 23 + htdocs/includes/ace/ace-modules.d.ts | 34 +- htdocs/includes/ace/ace.d.ts | 28 +- htdocs/includes/ace/kitchen-sink.html | 10 +- htdocs/includes/ace/package.json | 2 +- htdocs/includes/ace/src/ace.js | 1618 +-- htdocs/includes/ace/src/ext-beautify.js | 42 +- htdocs/includes/ace/src/ext-code_lens.js | 24 +- htdocs/includes/ace/src/ext-emmet.js | 35 +- htdocs/includes/ace/src/ext-hardwrap.js | 125 + .../includes/ace/src/ext-keybinding_menu.js | 2 +- htdocs/includes/ace/src/ext-language_tools.js | 128 +- htdocs/includes/ace/src/ext-modelist.js | 31 +- htdocs/includes/ace/src/ext-options.js | 74 +- htdocs/includes/ace/src/ext-prompt.js | 138 +- htdocs/includes/ace/src/ext-searchbox.js | 2 +- htdocs/includes/ace/src/ext-settings_menu.js | 74 +- htdocs/includes/ace/src/ext-textarea.js | 135 +- htdocs/includes/ace/src/ext-themelist.js | 4 +- htdocs/includes/ace/src/keybinding-emacs.js | 47 +- htdocs/includes/ace/src/keybinding-vim.js | 827 +- htdocs/includes/ace/src/keybinding-vscode.js | 6 +- htdocs/includes/ace/src/mode-abc.js | 3 + htdocs/includes/ace/src/mode-actionscript.js | 1 + htdocs/includes/ace/src/mode-alda.js | 311 + htdocs/includes/ace/src/mode-asl.js | 33 +- htdocs/includes/ace/src/mode-bro.js | 334 - htdocs/includes/ace/src/mode-c_cpp.js | 3 +- htdocs/includes/ace/src/mode-clojure.js | 1 + htdocs/includes/ace/src/mode-coffee.js | 1 + htdocs/includes/ace/src/mode-coldfusion.js | 3 + .../includes/ace/src/mode-csound_document.js | 126 +- .../includes/ace/src/mode-csound_orchestra.js | 123 +- htdocs/includes/ace/src/mode-csound_score.js | 3 +- htdocs/includes/ace/src/mode-css.js | 1 + htdocs/includes/ace/src/mode-curly.js | 3 + htdocs/includes/ace/src/mode-d.js | 2 +- htdocs/includes/ace/src/mode-dart.js | 4 +- htdocs/includes/ace/src/mode-diff.js | 1 + htdocs/includes/ace/src/mode-django.js | 4 + htdocs/includes/ace/src/mode-dockerfile.js | 1 + htdocs/includes/ace/src/mode-drools.js | 3 +- htdocs/includes/ace/src/mode-edifact.js | 1 + htdocs/includes/ace/src/mode-ejs.js | 860 +- htdocs/includes/ace/src/mode-erlang.js | 1 + htdocs/includes/ace/src/mode-fsl.js | 1 + htdocs/includes/ace/src/mode-glsl.js | 3 +- htdocs/includes/ace/src/mode-gobstones.js | 2 + htdocs/includes/ace/src/mode-graphqlschema.js | 1 + htdocs/includes/ace/src/mode-groovy.js | 1 + htdocs/includes/ace/src/mode-haml.js | 525 +- htdocs/includes/ace/src/mode-handlebars.js | 3 + htdocs/includes/ace/src/mode-haskell.js | 1 + htdocs/includes/ace/src/mode-html.js | 3 + htdocs/includes/ace/src/mode-html_elixir.js | 3 + htdocs/includes/ace/src/mode-html_ruby.js | 860 +- htdocs/includes/ace/src/mode-io.js | 1 + htdocs/includes/ace/src/mode-java.js | 4 +- htdocs/includes/ace/src/mode-javascript.js | 1 + htdocs/includes/ace/src/mode-json.js | 3 + htdocs/includes/ace/src/mode-jsoniq.js | 1 + htdocs/includes/ace/src/mode-jsp.js | 3 +- htdocs/includes/ace/src/mode-kotlin.js | 2 + htdocs/includes/ace/src/mode-latte.js | 2708 ++++ htdocs/includes/ace/src/mode-liquid.js | 4 + htdocs/includes/ace/src/mode-lsl.js | 1 + htdocs/includes/ace/src/mode-lua.js | 1 + htdocs/includes/ace/src/mode-luapage.js | 4 + htdocs/includes/ace/src/mode-makefile.js | 1 + htdocs/includes/ace/src/mode-markdown.js | 5 + htdocs/includes/ace/src/mode-maze.js | 1 + htdocs/includes/ace/src/mode-mediawiki.js | 592 + htdocs/includes/ace/src/mode-mips.js | 264 + htdocs/includes/ace/src/mode-nix.js | 3 +- htdocs/includes/ace/src/mode-nsis.js | 2 +- htdocs/includes/ace/src/mode-nunjucks.js | 3 + htdocs/includes/ace/src/mode-objectivec.js | 2 +- htdocs/includes/ace/src/mode-perl.js | 1 + htdocs/includes/ace/src/mode-pgsql.js | 4 +- htdocs/includes/ace/src/mode-php.js | 773 +- .../ace/src/mode-php_laravel_blade.js | 773 +- htdocs/includes/ace/src/mode-prisma.js | 489 + htdocs/includes/ace/src/mode-protobuf.js | 3 +- htdocs/includes/ace/src/mode-puppet.js | 11 +- htdocs/includes/ace/src/mode-python.js | 5 +- htdocs/includes/ace/src/mode-qml.js | 381 + htdocs/includes/ace/src/mode-r.js | 1 + .../ace/src/{mode-perl6.js => mode-raku.js} | 22 +- htdocs/includes/ace/src/mode-razor.js | 4 + htdocs/includes/ace/src/mode-rhtml.js | 3 + htdocs/includes/ace/src/mode-rst.js | 1 + htdocs/includes/ace/src/mode-ruby.js | 857 +- htdocs/includes/ace/src/mode-rust.js | 9 +- htdocs/includes/ace/src/mode-scala.js | 1 + htdocs/includes/ace/src/mode-scrypt.js | 364 + htdocs/includes/ace/src/mode-sh.js | 1 + htdocs/includes/ace/src/mode-sjs.js | 1 + htdocs/includes/ace/src/mode-slim.js | 820 +- htdocs/includes/ace/src/mode-smarty.js | 3 + htdocs/includes/ace/src/mode-smithy.js | 507 + htdocs/includes/ace/src/mode-snippets.js | 1 + htdocs/includes/ace/src/mode-soy_template.js | 3 + htdocs/includes/ace/src/mode-sql.js | 163 +- htdocs/includes/ace/src/mode-sqlserver.js | 3 +- htdocs/includes/ace/src/mode-svg.js | 1 + htdocs/includes/ace/src/mode-swift.js | 6 + htdocs/includes/ace/src/mode-tcl.js | 1 + htdocs/includes/ace/src/mode-terraform.js | 17 +- htdocs/includes/ace/src/mode-tex.js | 1 + htdocs/includes/ace/src/mode-textile.js | 1 + htdocs/includes/ace/src/mode-tsx.js | 1 + htdocs/includes/ace/src/mode-twig.js | 3 + htdocs/includes/ace/src/mode-typescript.js | 1 + htdocs/includes/ace/src/mode-vala.js | 1 + htdocs/includes/ace/src/mode-vbscript.js | 459 +- htdocs/includes/ace/src/mode-velocity.js | 4 + htdocs/includes/ace/src/mode-vhdl.js | 21 +- htdocs/includes/ace/src/mode-visualforce.js | 3 + htdocs/includes/ace/src/mode-wollok.js | 2 + htdocs/includes/ace/src/mode-xquery.js | 1 + htdocs/includes/ace/src/snippets/abap.js | 7 +- htdocs/includes/ace/src/snippets/ada.js | 7 +- htdocs/includes/ace/src/snippets/alda.js | 9 + .../includes/ace/src/snippets/apache_conf.js | 7 +- htdocs/includes/ace/src/snippets/apex.js | 7 +- .../includes/ace/src/snippets/applescript.js | 7 +- htdocs/includes/ace/src/snippets/aql.js | 7 +- htdocs/includes/ace/src/snippets/asciidoc.js | 7 +- htdocs/includes/ace/src/snippets/asl.js | 6 +- .../includes/ace/src/snippets/assembly_x86.js | 7 +- .../includes/ace/src/snippets/autohotkey.js | 7 +- htdocs/includes/ace/src/snippets/batchfile.js | 7 +- htdocs/includes/ace/src/snippets/bro.js | 14 - htdocs/includes/ace/src/snippets/c9search.js | 7 +- htdocs/includes/ace/src/snippets/cirru.js | 7 +- htdocs/includes/ace/src/snippets/cobol.js | 7 +- .../includes/ace/src/snippets/coldfusion.js | 7 +- htdocs/includes/ace/src/snippets/crystal.js | 7 +- htdocs/includes/ace/src/snippets/csharp.js | 7 +- .../includes/ace/src/snippets/csound_score.js | 7 +- htdocs/includes/ace/src/snippets/csp.js | 7 +- htdocs/includes/ace/src/snippets/curly.js | 7 +- htdocs/includes/ace/src/snippets/d.js | 7 +- .../includes/ace/src/snippets/dockerfile.js | 7 +- htdocs/includes/ace/src/snippets/dot.js | 7 +- htdocs/includes/ace/src/snippets/eiffel.js | 7 +- htdocs/includes/ace/src/snippets/ejs.js | 7 +- htdocs/includes/ace/src/snippets/elixir.js | 7 +- htdocs/includes/ace/src/snippets/elm.js | 7 +- htdocs/includes/ace/src/snippets/forth.js | 7 +- htdocs/includes/ace/src/snippets/fortran.js | 7 +- htdocs/includes/ace/src/snippets/fsharp.js | 7 +- htdocs/includes/ace/src/snippets/ftl.js | 7 +- htdocs/includes/ace/src/snippets/gcode.js | 7 +- htdocs/includes/ace/src/snippets/gherkin.js | 7 +- htdocs/includes/ace/src/snippets/gitignore.js | 7 +- htdocs/includes/ace/src/snippets/glsl.js | 7 +- htdocs/includes/ace/src/snippets/golang.js | 7 +- htdocs/includes/ace/src/snippets/groovy.js | 7 +- .../includes/ace/src/snippets/handlebars.js | 7 +- .../ace/src/snippets/haskell_cabal.js | 7 +- htdocs/includes/ace/src/snippets/haxe.js | 7 +- htdocs/includes/ace/src/snippets/hjson.js | 7 +- htdocs/includes/ace/src/snippets/html.js | 6 +- .../includes/ace/src/snippets/html_elixir.js | 7 +- htdocs/includes/ace/src/snippets/html_ruby.js | 7 +- htdocs/includes/ace/src/snippets/ini.js | 7 +- htdocs/includes/ace/src/snippets/jack.js | 7 +- htdocs/includes/ace/src/snippets/jade.js | 7 +- htdocs/includes/ace/src/snippets/json.js | 7 +- htdocs/includes/ace/src/snippets/json5.js | 7 +- htdocs/includes/ace/src/snippets/jssm.js | 7 +- htdocs/includes/ace/src/snippets/jsx.js | 7 +- htdocs/includes/ace/src/snippets/julia.js | 7 +- htdocs/includes/ace/src/snippets/kotlin.js | 7 +- htdocs/includes/ace/src/snippets/latex.js | 7 +- htdocs/includes/ace/src/snippets/latte.js | 9 + htdocs/includes/ace/src/snippets/less.js | 7 +- htdocs/includes/ace/src/snippets/lisp.js | 7 +- .../includes/ace/src/snippets/livescript.js | 7 +- htdocs/includes/ace/src/snippets/logiql.js | 7 +- htdocs/includes/ace/src/snippets/logtalk.js | 7 +- htdocs/includes/ace/src/snippets/luapage.js | 7 +- htdocs/includes/ace/src/snippets/lucene.js | 7 +- htdocs/includes/ace/src/snippets/mask.js | 7 +- htdocs/includes/ace/src/snippets/matlab.js | 7 +- htdocs/includes/ace/src/snippets/mediawiki.js | 9 + htdocs/includes/ace/src/snippets/mel.js | 7 +- htdocs/includes/ace/src/snippets/mips.js | 9 + htdocs/includes/ace/src/snippets/mixal.js | 7 +- htdocs/includes/ace/src/snippets/mushcode.js | 7 +- htdocs/includes/ace/src/snippets/mysql.js | 7 +- htdocs/includes/ace/src/snippets/nginx.js | 7 +- htdocs/includes/ace/src/snippets/nim.js | 7 +- htdocs/includes/ace/src/snippets/nix.js | 7 +- htdocs/includes/ace/src/snippets/nsis.js | 7 +- htdocs/includes/ace/src/snippets/nunjucks.js | 7 +- .../includes/ace/src/snippets/objectivec.js | 7 +- htdocs/includes/ace/src/snippets/ocaml.js | 7 +- htdocs/includes/ace/src/snippets/pascal.js | 7 +- htdocs/includes/ace/src/snippets/perl6.js | 14 - htdocs/includes/ace/src/snippets/pgsql.js | 7 +- .../ace/src/snippets/php_laravel_blade.js | 7 +- htdocs/includes/ace/src/snippets/pig.js | 7 +- .../includes/ace/src/snippets/plain_text.js | 7 +- .../includes/ace/src/snippets/powershell.js | 7 +- htdocs/includes/ace/src/snippets/praat.js | 7 +- htdocs/includes/ace/src/snippets/prisma.js | 9 + htdocs/includes/ace/src/snippets/prolog.js | 7 +- .../includes/ace/src/snippets/properties.js | 7 +- htdocs/includes/ace/src/snippets/protobuf.js | 7 +- htdocs/includes/ace/src/snippets/puppet.js | 7 +- htdocs/includes/ace/src/snippets/qml.js | 9 + htdocs/includes/ace/src/snippets/raku.js | 9 + htdocs/includes/ace/src/snippets/rdoc.js | 7 +- htdocs/includes/ace/src/snippets/red.js | 7 +- htdocs/includes/ace/src/snippets/redshift.js | 7 +- htdocs/includes/ace/src/snippets/rhtml.js | 7 +- htdocs/includes/ace/src/snippets/rust.js | 7 +- htdocs/includes/ace/src/snippets/sass.js | 7 +- htdocs/includes/ace/src/snippets/scad.js | 7 +- htdocs/includes/ace/src/snippets/scala.js | 7 +- htdocs/includes/ace/src/snippets/scheme.js | 7 +- htdocs/includes/ace/src/snippets/scrypt.js | 9 + htdocs/includes/ace/src/snippets/scss.js | 7 +- htdocs/includes/ace/src/snippets/sjs.js | 7 +- htdocs/includes/ace/src/snippets/slim.js | 7 +- htdocs/includes/ace/src/snippets/smarty.js | 7 +- htdocs/includes/ace/src/snippets/smithy.js | 9 + .../includes/ace/src/snippets/soy_template.js | 7 +- htdocs/includes/ace/src/snippets/space.js | 7 +- htdocs/includes/ace/src/snippets/sparql.js | 7 +- htdocs/includes/ace/src/snippets/stylus.js | 7 +- htdocs/includes/ace/src/snippets/svg.js | 7 +- htdocs/includes/ace/src/snippets/swift.js | 7 +- htdocs/includes/ace/src/snippets/terraform.js | 7 +- htdocs/includes/ace/src/snippets/text.js | 7 +- htdocs/includes/ace/src/snippets/toml.js | 7 +- htdocs/includes/ace/src/snippets/tsx.js | 7 +- htdocs/includes/ace/src/snippets/turtle.js | 7 +- htdocs/includes/ace/src/snippets/twig.js | 7 +- .../includes/ace/src/snippets/typescript.js | 7 +- htdocs/includes/ace/src/snippets/vbscript.js | 7 +- htdocs/includes/ace/src/snippets/verilog.js | 7 +- htdocs/includes/ace/src/snippets/vhdl.js | 7 +- .../includes/ace/src/snippets/visualforce.js | 7 +- htdocs/includes/ace/src/snippets/xml.js | 7 +- htdocs/includes/ace/src/snippets/yaml.js | 7 +- htdocs/includes/ace/src/snippets/zeek.js | 7 +- htdocs/includes/ace/src/theme-ambiance.js | 7 +- htdocs/includes/ace/src/theme-chaos.js | 4 +- htdocs/includes/ace/src/theme-chrome.js | 2 +- htdocs/includes/ace/src/theme-clouds.js | 2 +- .../includes/ace/src/theme-clouds_midnight.js | 2 +- htdocs/includes/ace/src/theme-cobalt.js | 2 +- .../includes/ace/src/theme-crimson_editor.js | 2 +- htdocs/includes/ace/src/theme-dawn.js | 2 +- htdocs/includes/ace/src/theme-dracula.js | 2 +- htdocs/includes/ace/src/theme-dreamweaver.js | 2 +- htdocs/includes/ace/src/theme-eclipse.js | 2 +- htdocs/includes/ace/src/theme-github.js | 2 +- htdocs/includes/ace/src/theme-gob.js | 2 +- htdocs/includes/ace/src/theme-gruvbox.js | 2 +- htdocs/includes/ace/src/theme-idle_fingers.js | 2 +- htdocs/includes/ace/src/theme-iplastic.js | 2 +- htdocs/includes/ace/src/theme-katzenmilch.js | 2 +- htdocs/includes/ace/src/theme-kr_theme.js | 2 +- htdocs/includes/ace/src/theme-kuroir.js | 2 +- htdocs/includes/ace/src/theme-merbivore.js | 2 +- .../includes/ace/src/theme-merbivore_soft.js | 2 +- .../includes/ace/src/theme-mono_industrial.js | 2 +- htdocs/includes/ace/src/theme-monokai.js | 2 +- htdocs/includes/ace/src/theme-nord_dark.js | 102 + htdocs/includes/ace/src/theme-one_dark.js | 139 + .../includes/ace/src/theme-pastel_on_dark.js | 2 +- .../includes/ace/src/theme-solarized_dark.js | 2 +- .../includes/ace/src/theme-solarized_light.js | 2 +- htdocs/includes/ace/src/theme-sqlserver.js | 2 +- htdocs/includes/ace/src/theme-terminal.js | 2 +- htdocs/includes/ace/src/theme-textmate.js | 2 +- htdocs/includes/ace/src/theme-tomorrow.js | 2 +- .../includes/ace/src/theme-tomorrow_night.js | 2 +- .../ace/src/theme-tomorrow_night_blue.js | 2 +- .../ace/src/theme-tomorrow_night_bright.js | 2 +- .../ace/src/theme-tomorrow_night_eighties.js | 2 +- htdocs/includes/ace/src/theme-twilight.js | 8 +- htdocs/includes/ace/src/theme-vibrant_ink.js | 2 +- htdocs/includes/ace/src/theme-xcode.js | 2 +- htdocs/includes/ace/src/worker-base.js | 1421 ++ htdocs/includes/ace/src/worker-coffee.js | 720 +- htdocs/includes/ace/src/worker-css.js | 6965 +++++----- htdocs/includes/ace/src/worker-html.js | 720 +- htdocs/includes/ace/src/worker-javascript.js | 10814 ++++++++++------ htdocs/includes/ace/src/worker-json.js | 720 +- htdocs/includes/ace/src/worker-lua.js | 1986 ++- htdocs/includes/ace/src/worker-php.js | 2332 ++-- htdocs/includes/ace/src/worker-xml.js | 720 +- htdocs/includes/ace/src/worker-xquery.js | 720 +- htdocs/includes/ace/webpack-resolver.js | 32 +- 303 files changed, 26642 insertions(+), 17750 deletions(-) create mode 100644 htdocs/includes/ace/.npmignore create mode 100644 htdocs/includes/ace/src/ext-hardwrap.js create mode 100644 htdocs/includes/ace/src/mode-alda.js delete mode 100644 htdocs/includes/ace/src/mode-bro.js create mode 100644 htdocs/includes/ace/src/mode-latte.js create mode 100644 htdocs/includes/ace/src/mode-mediawiki.js create mode 100644 htdocs/includes/ace/src/mode-mips.js create mode 100644 htdocs/includes/ace/src/mode-prisma.js create mode 100644 htdocs/includes/ace/src/mode-qml.js rename htdocs/includes/ace/src/{mode-perl6.js => mode-raku.js} (96%) create mode 100644 htdocs/includes/ace/src/mode-scrypt.js create mode 100644 htdocs/includes/ace/src/mode-smithy.js create mode 100644 htdocs/includes/ace/src/snippets/alda.js delete mode 100644 htdocs/includes/ace/src/snippets/bro.js create mode 100644 htdocs/includes/ace/src/snippets/latte.js create mode 100644 htdocs/includes/ace/src/snippets/mediawiki.js create mode 100644 htdocs/includes/ace/src/snippets/mips.js delete mode 100644 htdocs/includes/ace/src/snippets/perl6.js create mode 100644 htdocs/includes/ace/src/snippets/prisma.js create mode 100644 htdocs/includes/ace/src/snippets/qml.js create mode 100644 htdocs/includes/ace/src/snippets/raku.js create mode 100644 htdocs/includes/ace/src/snippets/scrypt.js create mode 100644 htdocs/includes/ace/src/snippets/smithy.js create mode 100644 htdocs/includes/ace/src/theme-nord_dark.js create mode 100644 htdocs/includes/ace/src/theme-one_dark.js create mode 100644 htdocs/includes/ace/src/worker-base.js diff --git a/COPYRIGHT b/COPYRIGHT index eaa3e2e963e..a5e1f4a4005 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -48,7 +48,7 @@ TCPDF 6.3.2 LGPL-3+ Yes TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement JS libraries: -Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea. +Ace 1.4.14 BSD Yes JS library to get code syntaxique coloration in a textarea. ChartJS 3.7.1 MIT License Yes JS library for graph jQuery 3.5.1 MIT License Yes JS library jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI diff --git a/htdocs/admin/dolistore/ajax/image.php b/htdocs/admin/dolistore/ajax/image.php index af844edaa68..e601da43e06 100644 --- a/htdocs/admin/dolistore/ajax/image.php +++ b/htdocs/admin/dolistore/ajax/image.php @@ -1,7 +1,7 @@ . * Copyright (C) 2008-2011 Laurent Destailleur - * Copyright (C) 2020 Frédéric France + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); * it under the terms of the GNU General Public License as published bypliance with the License. @@ -17,9 +17,6 @@ * or see https://www.gnu.org/ */ -if (!defined('REQUIRE_JQUERY_BLOCKUI')) { - define('REQUIRE_JQUERY_BLOCKUI', 1); -} if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', 1); } diff --git a/htdocs/admin/dolistore/css/dolistore.css b/htdocs/admin/dolistore/css/dolistore.css index 3d8f163caf2..c3a8b6ca7ce 100644 --- a/htdocs/admin/dolistore/css/dolistore.css +++ b/htdocs/admin/dolistore/css/dolistore.css @@ -67,9 +67,6 @@ div.divsearchfield { .tree li:last-child:after{ display: none } -.blockUI { - cursor: auto!important; -} .newAppParent{ position: relative; overflow: hidden; diff --git a/htdocs/includes/ace/.npmignore b/htdocs/includes/ace/.npmignore new file mode 100644 index 00000000000..b7e6c1b552d --- /dev/null +++ b/htdocs/includes/ace/.npmignore @@ -0,0 +1,3 @@ +demo/ +kitchen-sink.html +* * \ No newline at end of file diff --git a/htdocs/includes/ace/ChangeLog.txt b/htdocs/includes/ace/ChangeLog.txt index 824f8750e12..2819a6014d0 100644 --- a/htdocs/includes/ace/ChangeLog.txt +++ b/htdocs/includes/ace/ChangeLog.txt @@ -1,3 +1,26 @@ +2022.01.26 Version 1.4.14 +* update vim mode +* remove slow regex in beautify extension + +2021.09.30 Version 1.4.13 +* added useStrictCSP global option to use in environments where dynamic style creation is disabled + see demo/csp.html for an example of a page which loads external css files instead of generating styles with javascript +* updated vim mode, added support for gqq command + +2020.07.06 Version 1.4.12 +* removed unused es5-shim +* imporved ruby and vbscript highlighting and folding +* workaround for double space being converted to dot on mobile keyboards + +2020.04.15 Version 1.4.10 +* added workaround for chrome bug causing memory leak after calling editor.destroy +* added code folding support for vbscript mode + +2020.04.01 Version 1.4.9 +* added option to disable autoindent +* added new language modes +* fixed backspace not working with some mobile keyboards + 2020.01.14 Version 1.4.8 * highlight both matched braces, and highlight unmatched brace in red * improve snippet manager diff --git a/htdocs/includes/ace/ace-modules.d.ts b/htdocs/includes/ace/ace-modules.d.ts index a25e20c9c84..0f0bac5fbfd 100644 --- a/htdocs/includes/ace/ace-modules.d.ts +++ b/htdocs/includes/ace/ace-modules.d.ts @@ -1,7 +1,11 @@ +declare module 'ace-builds/webpack-resolver'; +declare module 'ace-builds/src-noconflict/ace'; declare module 'ace-builds/src-noconflict/ext-beautify'; +declare module 'ace-builds/src-noconflict/ext-code_lens'; declare module 'ace-builds/src-noconflict/ext-elastic_tabstops_lite'; declare module 'ace-builds/src-noconflict/ext-emmet'; declare module 'ace-builds/src-noconflict/ext-error_marker'; +declare module 'ace-builds/src-noconflict/ext-hardwrap'; declare module 'ace-builds/src-noconflict/ext-keybinding_menu'; declare module 'ace-builds/src-noconflict/ext-language_tools'; declare module 'ace-builds/src-noconflict/ext-linking'; @@ -21,10 +25,12 @@ declare module 'ace-builds/src-noconflict/ext-whitespace'; declare module 'ace-builds/src-noconflict/keybinding-emacs'; declare module 'ace-builds/src-noconflict/keybinding-sublime'; declare module 'ace-builds/src-noconflict/keybinding-vim'; +declare module 'ace-builds/src-noconflict/keybinding-vscode'; declare module 'ace-builds/src-noconflict/mode-abap'; declare module 'ace-builds/src-noconflict/mode-abc'; declare module 'ace-builds/src-noconflict/mode-actionscript'; declare module 'ace-builds/src-noconflict/mode-ada'; +declare module 'ace-builds/src-noconflict/mode-alda'; declare module 'ace-builds/src-noconflict/mode-apache_conf'; declare module 'ace-builds/src-noconflict/mode-apex'; declare module 'ace-builds/src-noconflict/mode-applescript'; @@ -34,7 +40,6 @@ declare module 'ace-builds/src-noconflict/mode-asl'; declare module 'ace-builds/src-noconflict/mode-assembly_x86'; declare module 'ace-builds/src-noconflict/mode-autohotkey'; declare module 'ace-builds/src-noconflict/mode-batchfile'; -declare module 'ace-builds/src-noconflict/mode-bro'; declare module 'ace-builds/src-noconflict/mode-c9search'; declare module 'ace-builds/src-noconflict/mode-cirru'; declare module 'ace-builds/src-noconflict/mode-clojure'; @@ -92,6 +97,7 @@ declare module 'ace-builds/src-noconflict/mode-jade'; declare module 'ace-builds/src-noconflict/mode-java'; declare module 'ace-builds/src-noconflict/mode-javascript'; declare module 'ace-builds/src-noconflict/mode-json'; +declare module 'ace-builds/src-noconflict/mode-json5'; declare module 'ace-builds/src-noconflict/mode-jsoniq'; declare module 'ace-builds/src-noconflict/mode-jsp'; declare module 'ace-builds/src-noconflict/mode-jssm'; @@ -99,6 +105,7 @@ declare module 'ace-builds/src-noconflict/mode-jsx'; declare module 'ace-builds/src-noconflict/mode-julia'; declare module 'ace-builds/src-noconflict/mode-kotlin'; declare module 'ace-builds/src-noconflict/mode-latex'; +declare module 'ace-builds/src-noconflict/mode-latte'; declare module 'ace-builds/src-noconflict/mode-less'; declare module 'ace-builds/src-noconflict/mode-liquid'; declare module 'ace-builds/src-noconflict/mode-lisp'; @@ -114,7 +121,9 @@ declare module 'ace-builds/src-noconflict/mode-markdown'; declare module 'ace-builds/src-noconflict/mode-mask'; declare module 'ace-builds/src-noconflict/mode-matlab'; declare module 'ace-builds/src-noconflict/mode-maze'; +declare module 'ace-builds/src-noconflict/mode-mediawiki'; declare module 'ace-builds/src-noconflict/mode-mel'; +declare module 'ace-builds/src-noconflict/mode-mips'; declare module 'ace-builds/src-noconflict/mode-mixal'; declare module 'ace-builds/src-noconflict/mode-mushcode'; declare module 'ace-builds/src-noconflict/mode-mysql'; @@ -122,11 +131,11 @@ declare module 'ace-builds/src-noconflict/mode-nginx'; declare module 'ace-builds/src-noconflict/mode-nim'; declare module 'ace-builds/src-noconflict/mode-nix'; declare module 'ace-builds/src-noconflict/mode-nsis'; +declare module 'ace-builds/src-noconflict/mode-nunjucks'; declare module 'ace-builds/src-noconflict/mode-objectivec'; declare module 'ace-builds/src-noconflict/mode-ocaml'; declare module 'ace-builds/src-noconflict/mode-pascal'; declare module 'ace-builds/src-noconflict/mode-perl'; -declare module 'ace-builds/src-noconflict/mode-perl6'; declare module 'ace-builds/src-noconflict/mode-pgsql'; declare module 'ace-builds/src-noconflict/mode-php'; declare module 'ace-builds/src-noconflict/mode-php_laravel_blade'; @@ -134,12 +143,15 @@ declare module 'ace-builds/src-noconflict/mode-pig'; declare module 'ace-builds/src-noconflict/mode-plain_text'; declare module 'ace-builds/src-noconflict/mode-powershell'; declare module 'ace-builds/src-noconflict/mode-praat'; +declare module 'ace-builds/src-noconflict/mode-prisma'; declare module 'ace-builds/src-noconflict/mode-prolog'; declare module 'ace-builds/src-noconflict/mode-properties'; declare module 'ace-builds/src-noconflict/mode-protobuf'; declare module 'ace-builds/src-noconflict/mode-puppet'; declare module 'ace-builds/src-noconflict/mode-python'; +declare module 'ace-builds/src-noconflict/mode-qml'; declare module 'ace-builds/src-noconflict/mode-r'; +declare module 'ace-builds/src-noconflict/mode-raku'; declare module 'ace-builds/src-noconflict/mode-razor'; declare module 'ace-builds/src-noconflict/mode-rdoc'; declare module 'ace-builds/src-noconflict/mode-red'; @@ -152,11 +164,13 @@ declare module 'ace-builds/src-noconflict/mode-sass'; declare module 'ace-builds/src-noconflict/mode-scad'; declare module 'ace-builds/src-noconflict/mode-scala'; declare module 'ace-builds/src-noconflict/mode-scheme'; +declare module 'ace-builds/src-noconflict/mode-scrypt'; declare module 'ace-builds/src-noconflict/mode-scss'; declare module 'ace-builds/src-noconflict/mode-sh'; declare module 'ace-builds/src-noconflict/mode-sjs'; declare module 'ace-builds/src-noconflict/mode-slim'; declare module 'ace-builds/src-noconflict/mode-smarty'; +declare module 'ace-builds/src-noconflict/mode-smithy'; declare module 'ace-builds/src-noconflict/mode-snippets'; declare module 'ace-builds/src-noconflict/mode-soy_template'; declare module 'ace-builds/src-noconflict/mode-space'; @@ -210,6 +224,8 @@ declare module 'ace-builds/src-noconflict/theme-merbivore'; declare module 'ace-builds/src-noconflict/theme-merbivore_soft'; declare module 'ace-builds/src-noconflict/theme-monokai'; declare module 'ace-builds/src-noconflict/theme-mono_industrial'; +declare module 'ace-builds/src-noconflict/theme-nord_dark'; +declare module 'ace-builds/src-noconflict/theme-one_dark'; declare module 'ace-builds/src-noconflict/theme-pastel_on_dark'; declare module 'ace-builds/src-noconflict/theme-solarized_dark'; declare module 'ace-builds/src-noconflict/theme-solarized_light'; @@ -228,6 +244,7 @@ declare module 'ace-builds/src-noconflict/snippets/abap'; declare module 'ace-builds/src-noconflict/snippets/abc'; declare module 'ace-builds/src-noconflict/snippets/actionscript'; declare module 'ace-builds/src-noconflict/snippets/ada'; +declare module 'ace-builds/src-noconflict/snippets/alda'; declare module 'ace-builds/src-noconflict/snippets/apache_conf'; declare module 'ace-builds/src-noconflict/snippets/apex'; declare module 'ace-builds/src-noconflict/snippets/applescript'; @@ -237,7 +254,6 @@ declare module 'ace-builds/src-noconflict/snippets/asl'; declare module 'ace-builds/src-noconflict/snippets/assembly_x86'; declare module 'ace-builds/src-noconflict/snippets/autohotkey'; declare module 'ace-builds/src-noconflict/snippets/batchfile'; -declare module 'ace-builds/src-noconflict/snippets/bro'; declare module 'ace-builds/src-noconflict/snippets/c9search'; declare module 'ace-builds/src-noconflict/snippets/cirru'; declare module 'ace-builds/src-noconflict/snippets/clojure'; @@ -295,6 +311,7 @@ declare module 'ace-builds/src-noconflict/snippets/jade'; declare module 'ace-builds/src-noconflict/snippets/java'; declare module 'ace-builds/src-noconflict/snippets/javascript'; declare module 'ace-builds/src-noconflict/snippets/json'; +declare module 'ace-builds/src-noconflict/snippets/json5'; declare module 'ace-builds/src-noconflict/snippets/jsoniq'; declare module 'ace-builds/src-noconflict/snippets/jsp'; declare module 'ace-builds/src-noconflict/snippets/jssm'; @@ -302,6 +319,7 @@ declare module 'ace-builds/src-noconflict/snippets/jsx'; declare module 'ace-builds/src-noconflict/snippets/julia'; declare module 'ace-builds/src-noconflict/snippets/kotlin'; declare module 'ace-builds/src-noconflict/snippets/latex'; +declare module 'ace-builds/src-noconflict/snippets/latte'; declare module 'ace-builds/src-noconflict/snippets/less'; declare module 'ace-builds/src-noconflict/snippets/liquid'; declare module 'ace-builds/src-noconflict/snippets/lisp'; @@ -317,7 +335,9 @@ declare module 'ace-builds/src-noconflict/snippets/markdown'; declare module 'ace-builds/src-noconflict/snippets/mask'; declare module 'ace-builds/src-noconflict/snippets/matlab'; declare module 'ace-builds/src-noconflict/snippets/maze'; +declare module 'ace-builds/src-noconflict/snippets/mediawiki'; declare module 'ace-builds/src-noconflict/snippets/mel'; +declare module 'ace-builds/src-noconflict/snippets/mips'; declare module 'ace-builds/src-noconflict/snippets/mixal'; declare module 'ace-builds/src-noconflict/snippets/mushcode'; declare module 'ace-builds/src-noconflict/snippets/mysql'; @@ -325,11 +345,11 @@ declare module 'ace-builds/src-noconflict/snippets/nginx'; declare module 'ace-builds/src-noconflict/snippets/nim'; declare module 'ace-builds/src-noconflict/snippets/nix'; declare module 'ace-builds/src-noconflict/snippets/nsis'; +declare module 'ace-builds/src-noconflict/snippets/nunjucks'; declare module 'ace-builds/src-noconflict/snippets/objectivec'; declare module 'ace-builds/src-noconflict/snippets/ocaml'; declare module 'ace-builds/src-noconflict/snippets/pascal'; declare module 'ace-builds/src-noconflict/snippets/perl'; -declare module 'ace-builds/src-noconflict/snippets/perl6'; declare module 'ace-builds/src-noconflict/snippets/pgsql'; declare module 'ace-builds/src-noconflict/snippets/php'; declare module 'ace-builds/src-noconflict/snippets/php_laravel_blade'; @@ -337,12 +357,15 @@ declare module 'ace-builds/src-noconflict/snippets/pig'; declare module 'ace-builds/src-noconflict/snippets/plain_text'; declare module 'ace-builds/src-noconflict/snippets/powershell'; declare module 'ace-builds/src-noconflict/snippets/praat'; +declare module 'ace-builds/src-noconflict/snippets/prisma'; declare module 'ace-builds/src-noconflict/snippets/prolog'; declare module 'ace-builds/src-noconflict/snippets/properties'; declare module 'ace-builds/src-noconflict/snippets/protobuf'; declare module 'ace-builds/src-noconflict/snippets/puppet'; declare module 'ace-builds/src-noconflict/snippets/python'; +declare module 'ace-builds/src-noconflict/snippets/qml'; declare module 'ace-builds/src-noconflict/snippets/r'; +declare module 'ace-builds/src-noconflict/snippets/raku'; declare module 'ace-builds/src-noconflict/snippets/razor'; declare module 'ace-builds/src-noconflict/snippets/rdoc'; declare module 'ace-builds/src-noconflict/snippets/red'; @@ -355,11 +378,13 @@ declare module 'ace-builds/src-noconflict/snippets/sass'; declare module 'ace-builds/src-noconflict/snippets/scad'; declare module 'ace-builds/src-noconflict/snippets/scala'; declare module 'ace-builds/src-noconflict/snippets/scheme'; +declare module 'ace-builds/src-noconflict/snippets/scrypt'; declare module 'ace-builds/src-noconflict/snippets/scss'; declare module 'ace-builds/src-noconflict/snippets/sh'; declare module 'ace-builds/src-noconflict/snippets/sjs'; declare module 'ace-builds/src-noconflict/snippets/slim'; declare module 'ace-builds/src-noconflict/snippets/smarty'; +declare module 'ace-builds/src-noconflict/snippets/smithy'; declare module 'ace-builds/src-noconflict/snippets/snippets'; declare module 'ace-builds/src-noconflict/snippets/soy_template'; declare module 'ace-builds/src-noconflict/snippets/space'; @@ -390,4 +415,3 @@ declare module 'ace-builds/src-noconflict/snippets/xml'; declare module 'ace-builds/src-noconflict/snippets/xquery'; declare module 'ace-builds/src-noconflict/snippets/yaml'; declare module 'ace-builds/src-noconflict/snippets/zeek'; -declare module 'ace-builds/webpack-resolver'; diff --git a/htdocs/includes/ace/ace.d.ts b/htdocs/includes/ace/ace.d.ts index dd1a2952a06..bdf62ffd3a4 100644 --- a/htdocs/includes/ace/ace.d.ts +++ b/htdocs/includes/ace/ace.d.ts @@ -21,10 +21,12 @@ export namespace Ace { getLine(row: number): string; getLines(firstRow: number, lastRow: number): string[]; getAllLines(): string[]; + getLength(): number; getTextRange(range: Range): string; getLinesForRange(range: Range): string[]; insert(position: Point, text: string): Point; insertInLine(position: Point, text: string): Point; + insertNewLine(position: Point): Point; clippedPos(row: number, column: number): Point; clonePos(pos: Point): Point; pos(row: number, column: number): Point; @@ -153,7 +155,7 @@ export namespace Ace { } export interface EditSessionOptions { - wrap: string | number; + wrap: "off" | "free" | "printmargin" | boolean | number; wrapMethod: 'code' | 'text' | 'auto'; indentedSoftWrap: boolean; firstLineNumber: number; @@ -212,6 +214,7 @@ export namespace Ace { mergeUndoDeltas: true | false | 'always'; behavioursEnabled: boolean; wrapBehavioursEnabled: boolean; + enableAutoIndent: boolean; autoScrollEditorIntoView: boolean; keyboardHandler: string; placeholder: string; @@ -228,7 +231,7 @@ export namespace Ace { range: Range; preserveCase: boolean; regExp: RegExp; - wholeWord: string; + wholeWord: boolean; caseSensitive: boolean; wrap: boolean; } @@ -362,7 +365,7 @@ export namespace Ace { moduleUrl(name: string, component?: string): string; setModuleUrl(name: string, subst: string): string; loadModule(moduleName: string | [string, string], - onLoad: (module: any) => void): void; + onLoad?: (module: any) => void): void; init(packaged: any): any; defineOptions(obj: any, path: string, options: { [key: string]: any }): Config; resetOptions(obj: any): void; @@ -398,6 +401,8 @@ export namespace Ace { export interface EditSession extends EventEmitter, OptionsProvider, Folding { selection: Selection; + // TODO: define BackgroundTokenizer + on(name: 'changeFold', callback: (obj: { data: Fold, action: string }) => void): Function; on(name: 'changeScrollLeft', callback: (scrollLeft: number) => void): Function; @@ -519,6 +524,8 @@ export namespace Ace { removeKeyboardHandler(handler: KeyboardHandler): boolean; getKeyboardHandler(): KeyboardHandler; getStatusText(): string; + onCommandKey(e: any, hashId: number, keyCode: number): boolean; + onTextInput(text: string): boolean; } interface CommandMap { @@ -549,10 +556,17 @@ export namespace Ace { toggleRecording(editor: Editor): void; replay(editor: Editor): void; addCommand(command: Command): void; - removeCommand(command: Command, keepCommand?: boolean): void; + addCommands(command: Command[]): void; + removeCommand(command: Command | string, keepCommand?: boolean): void; + removeCommands(command: Command[]): void; bindKey(key: string | { mac?: string, win?: string }, command: CommandLike, position?: number): void; + bindKeys(keys: {[s: string]: Function}): void; + parseKeys(keyPart: string): {key: string, hashId: number}; + findKeyCommand(hashId: number, keyString: string): string | undefined; + handleKeyboard(data: {}, hashId: number, keyString: string, keyCode: string | number): void | {command: string}; + getStatusText(editor: Editor, data: {}): string; } export interface VirtualRenderer extends OptionsProvider, EventEmitter { @@ -746,7 +760,7 @@ export namespace Ace { setFontSize(size: string): void; focus(): void; isFocused(): boolean; - flur(): void; + blur(): void; getSelectedText(): string; getCopyText(): string; execCommand(command: string | string[], args?: any): boolean; @@ -844,9 +858,10 @@ export namespace Ace { replace(replacement: string, options?: Partial): number; replaceAll(replacement: string, options?: Partial): number; getLastSearchOptions(): Partial; - find(needle: string, options?: Partial, animate?: boolean): void; + find(needle: string | RegExp, options?: Partial, animate?: boolean): Ace.Range | undefined; findNext(options?: Partial, animate?: boolean): void; findPrevious(options?: Partial, animate?: boolean): void; + findAll(needle: string | RegExp, options?: Partial, additive?: boolean): number; undo(): void; redo(): void; destroy(): void; @@ -857,6 +872,7 @@ export namespace Ace { type CompleterCallback = (error: any, completions: Completion[]) => void; interface Completer { + identifierRegexps?: Array, getCompletions(editor: Editor, session: EditSession, position: Point, diff --git a/htdocs/includes/ace/kitchen-sink.html b/htdocs/includes/ace/kitchen-sink.html index 27014fa6004..026b357ca4a 100644 --- a/htdocs/includes/ace/kitchen-sink.html +++ b/htdocs/includes/ace/kitchen-sink.html @@ -8,7 +8,7 @@ @@ -21,18 +21,18 @@
-
+
- - + +
diff --git a/htdocs/includes/ace/package.json b/htdocs/includes/ace/package.json index a00dddeb40a..5deb5e6d478 100644 --- a/htdocs/includes/ace/package.json +++ b/htdocs/includes/ace/package.json @@ -2,7 +2,7 @@ "name": "ace-builds", "main": "./src-noconflict/ace.js", "typings": "ace.d.ts", - "version": "1.4.8", + "version": "1.4.14", "description": "Ace (Ajax.org Cloud9 Editor)", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/htdocs/includes/ace/src/ace.js b/htdocs/includes/ace/src/ace.js index 43d9931a3c4..74913993af1 100644 --- a/htdocs/includes/ace/src/ace.js +++ b/htdocs/includes/ace/src/ace.js @@ -173,781 +173,8 @@ exportAce(ACE_NAMESPACE); })(); -define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) { +define("ace/lib/fixoldbrowsers",["require","exports","module"], function(require, exports, module) { "use strict"; - - var real = { - exec: RegExp.prototype.exec, - test: RegExp.prototype.test, - match: String.prototype.match, - replace: String.prototype.replace, - split: String.prototype.split - }, - compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups - compliantLastIndexIncrement = function () { - var x = /^/g; - real.test.call(x, ""); - return !x.lastIndex; - }(); - - if (compliantLastIndexIncrement && compliantExecNpcg) - return; - RegExp.prototype.exec = function (str) { - var match = real.exec.apply(this, arguments), - name, r2; - if ( typeof(str) == 'string' && match) { - if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) { - r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", "")); - real.replace.call(str.slice(match.index), r2, function () { - for (var i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) - match[i] = undefined; - } - }); - } - if (this._xregexp && this._xregexp.captureNames) { - for (var i = 1; i < match.length; i++) { - name = this._xregexp.captureNames[i - 1]; - if (name) - match[name] = match[i]; - } - } - if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index)) - this.lastIndex--; - } - return match; - }; - if (!compliantLastIndexIncrement) { - RegExp.prototype.test = function (str) { - var match = real.exec.call(this, str); - if (match && this.global && !match[0].length && (this.lastIndex > match.index)) - this.lastIndex--; - return !!match; - }; - } - - function getNativeFlags (regex) { - return (regex.global ? "g" : "") + - (regex.ignoreCase ? "i" : "") + - (regex.multiline ? "m" : "") + - (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3 - (regex.sticky ? "y" : ""); - } - - function indexOf (array, item, from) { - if (Array.prototype.indexOf) // Use the native array method if available - return array.indexOf(item, from); - for (var i = from || 0; i < array.length; i++) { - if (array[i] === item) - return i; - } - return -1; - } - -}); - -define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) { - -function Empty() {} - -if (!Function.prototype.bind) { - Function.prototype.bind = function bind(that) { // .length is 1 - var target = this; - if (typeof target != "function") { - throw new TypeError("Function.prototype.bind called on incompatible " + target); - } - var args = slice.call(arguments, 1); // for normal call - var bound = function () { - - if (this instanceof bound) { - - var result = target.apply( - this, - args.concat(slice.call(arguments)) - ); - if (Object(result) === result) { - return result; - } - return this; - - } else { - return target.apply( - that, - args.concat(slice.call(arguments)) - ); - - } - - }; - if(target.prototype) { - Empty.prototype = target.prototype; - bound.prototype = new Empty(); - Empty.prototype = null; - } - return bound; - }; -} -var call = Function.prototype.call; -var prototypeOfArray = Array.prototype; -var prototypeOfObject = Object.prototype; -var slice = prototypeOfArray.slice; -var _toString = call.bind(prototypeOfObject.toString); -var owns = call.bind(prototypeOfObject.hasOwnProperty); -var defineGetter; -var defineSetter; -var lookupGetter; -var lookupSetter; -var supportsAccessors; -if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { - defineGetter = call.bind(prototypeOfObject.__defineGetter__); - defineSetter = call.bind(prototypeOfObject.__defineSetter__); - lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); - lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); -} -if ([1,2].splice(0).length != 2) { - if(function() { // test IE < 9 to splice bug - see issue #138 - function makeArray(l) { - var a = new Array(l+2); - a[0] = a[1] = 0; - return a; - } - var array = [], lengthBefore; - - array.splice.apply(array, makeArray(20)); - array.splice.apply(array, makeArray(26)); - - lengthBefore = array.length; //46 - array.splice(5, 0, "XXX"); // add one element - - lengthBefore + 1 == array.length - - if (lengthBefore + 1 == array.length) { - return true;// has right splice implementation without bugs - } - }()) {//IE 6/7 - var array_splice = Array.prototype.splice; - Array.prototype.splice = function(start, deleteCount) { - if (!arguments.length) { - return []; - } else { - return array_splice.apply(this, [ - start === void 0 ? 0 : start, - deleteCount === void 0 ? (this.length - start) : deleteCount - ].concat(slice.call(arguments, 2))) - } - }; - } else {//IE8 - Array.prototype.splice = function(pos, removeCount){ - var length = this.length; - if (pos > 0) { - if (pos > length) - pos = length; - } else if (pos == void 0) { - pos = 0; - } else if (pos < 0) { - pos = Math.max(length + pos, 0); - } - - if (!(pos+removeCount < length)) - removeCount = length - pos; - - var removed = this.slice(pos, pos+removeCount); - var insert = slice.call(arguments, 2); - var add = insert.length; - if (pos === length) { - if (add) { - this.push.apply(this, insert); - } - } else { - var remove = Math.min(removeCount, length - pos); - var tailOldPos = pos + remove; - var tailNewPos = tailOldPos + add - remove; - var tailCount = length - tailOldPos; - var lengthAfterRemove = length - remove; - - if (tailNewPos < tailOldPos) { // case A - for (var i = 0; i < tailCount; ++i) { - this[tailNewPos+i] = this[tailOldPos+i]; - } - } else if (tailNewPos > tailOldPos) { // case B - for (i = tailCount; i--; ) { - this[tailNewPos+i] = this[tailOldPos+i]; - } - } // else, add == remove (nothing to do) - - if (add && pos === lengthAfterRemove) { - this.length = lengthAfterRemove; // truncate array - this.push.apply(this, insert); - } else { - this.length = lengthAfterRemove + add; // reserves space - for (i = 0; i < add; ++i) { - this[pos+i] = insert[i]; - } - } - } - return removed; - }; - } -} -if (!Array.isArray) { - Array.isArray = function isArray(obj) { - return _toString(obj) == "[object Array]"; - }; -} -var boxedString = Object("a"), - splitString = boxedString[0] != "a" || !(0 in boxedString); - -if (!Array.prototype.forEach) { - Array.prototype.forEach = function forEach(fun /*, thisp*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - thisp = arguments[1], - i = -1, - length = self.length >>> 0; - if (_toString(fun) != "[object Function]") { - throw new TypeError(); // TODO message - } - - while (++i < length) { - if (i in self) { - fun.call(thisp, self[i], i, object); - } - } - }; -} -if (!Array.prototype.map) { - Array.prototype.map = function map(fun /*, thisp*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - result = Array(length), - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self) - result[i] = fun.call(thisp, self[i], i, object); - } - return result; - }; -} -if (!Array.prototype.filter) { - Array.prototype.filter = function filter(fun /*, thisp */) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - result = [], - value, - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self) { - value = self[i]; - if (fun.call(thisp, value, i, object)) { - result.push(value); - } - } - } - return result; - }; -} -if (!Array.prototype.every) { - Array.prototype.every = function every(fun /*, thisp */) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self && !fun.call(thisp, self[i], i, object)) { - return false; - } - } - return true; - }; -} -if (!Array.prototype.some) { - Array.prototype.some = function some(fun /*, thisp */) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self && fun.call(thisp, self[i], i, object)) { - return true; - } - } - return false; - }; -} -if (!Array.prototype.reduce) { - Array.prototype.reduce = function reduce(fun /*, initial*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - if (!length && arguments.length == 1) { - throw new TypeError("reduce of empty array with no initial value"); - } - - var i = 0; - var result; - if (arguments.length >= 2) { - result = arguments[1]; - } else { - do { - if (i in self) { - result = self[i++]; - break; - } - if (++i >= length) { - throw new TypeError("reduce of empty array with no initial value"); - } - } while (true); - } - - for (; i < length; i++) { - if (i in self) { - result = fun.call(void 0, result, self[i], i, object); - } - } - - return result; - }; -} -if (!Array.prototype.reduceRight) { - Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - if (!length && arguments.length == 1) { - throw new TypeError("reduceRight of empty array with no initial value"); - } - - var result, i = length - 1; - if (arguments.length >= 2) { - result = arguments[1]; - } else { - do { - if (i in self) { - result = self[i--]; - break; - } - if (--i < 0) { - throw new TypeError("reduceRight of empty array with no initial value"); - } - } while (true); - } - - do { - if (i in this) { - result = fun.call(void 0, result, self[i], i, object); - } - } while (i--); - - return result; - }; -} -if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) { - Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { - var self = splitString && _toString(this) == "[object String]" ? - this.split("") : - toObject(this), - length = self.length >>> 0; - - if (!length) { - return -1; - } - - var i = 0; - if (arguments.length > 1) { - i = toInteger(arguments[1]); - } - i = i >= 0 ? i : Math.max(0, length + i); - for (; i < length; i++) { - if (i in self && self[i] === sought) { - return i; - } - } - return -1; - }; -} -if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) { - Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { - var self = splitString && _toString(this) == "[object String]" ? - this.split("") : - toObject(this), - length = self.length >>> 0; - - if (!length) { - return -1; - } - var i = length - 1; - if (arguments.length > 1) { - i = Math.min(i, toInteger(arguments[1])); - } - i = i >= 0 ? i : length - Math.abs(i); - for (; i >= 0; i--) { - if (i in self && sought === self[i]) { - return i; - } - } - return -1; - }; -} -if (!Object.getPrototypeOf) { - Object.getPrototypeOf = function getPrototypeOf(object) { - return object.__proto__ || ( - object.constructor ? - object.constructor.prototype : - prototypeOfObject - ); - }; -} -if (!Object.getOwnPropertyDescriptor) { - var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + - "non-object: "; - Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { - if ((typeof object != "object" && typeof object != "function") || object === null) - throw new TypeError(ERR_NON_OBJECT + object); - if (!owns(object, property)) - return; - - var descriptor, getter, setter; - descriptor = { enumerable: true, configurable: true }; - if (supportsAccessors) { - var prototype = object.__proto__; - object.__proto__ = prototypeOfObject; - - var getter = lookupGetter(object, property); - var setter = lookupSetter(object, property); - object.__proto__ = prototype; - - if (getter || setter) { - if (getter) descriptor.get = getter; - if (setter) descriptor.set = setter; - return descriptor; - } - } - descriptor.value = object[property]; - return descriptor; - }; -} -if (!Object.getOwnPropertyNames) { - Object.getOwnPropertyNames = function getOwnPropertyNames(object) { - return Object.keys(object); - }; -} -if (!Object.create) { - var createEmpty; - if (Object.prototype.__proto__ === null) { - createEmpty = function () { - return { "__proto__": null }; - }; - } else { - createEmpty = function () { - var empty = {}; - for (var i in empty) - empty[i] = null; - empty.constructor = - empty.hasOwnProperty = - empty.propertyIsEnumerable = - empty.isPrototypeOf = - empty.toLocaleString = - empty.toString = - empty.valueOf = - empty.__proto__ = null; - return empty; - } - } - - Object.create = function create(prototype, properties) { - var object; - if (prototype === null) { - object = createEmpty(); - } else { - if (typeof prototype != "object") - throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); - var Type = function () {}; - Type.prototype = prototype; - object = new Type(); - object.__proto__ = prototype; - } - if (properties !== void 0) - Object.defineProperties(object, properties); - return object; - }; -} - -function doesDefinePropertyWork(object) { - try { - Object.defineProperty(object, "sentinel", {}); - return "sentinel" in object; - } catch (exception) { - } -} -if (Object.defineProperty) { - var definePropertyWorksOnObject = doesDefinePropertyWork({}); - var definePropertyWorksOnDom = typeof document == "undefined" || - doesDefinePropertyWork(document.createElement("div")); - if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { - var definePropertyFallback = Object.defineProperty; - } -} - -if (!Object.defineProperty || definePropertyFallback) { - var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; - var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " - var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + - "on this javascript engine"; - - Object.defineProperty = function defineProperty(object, property, descriptor) { - if ((typeof object != "object" && typeof object != "function") || object === null) - throw new TypeError(ERR_NON_OBJECT_TARGET + object); - if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) - throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); - if (definePropertyFallback) { - try { - return definePropertyFallback.call(Object, object, property, descriptor); - } catch (exception) { - } - } - if (owns(descriptor, "value")) { - - if (supportsAccessors && (lookupGetter(object, property) || - lookupSetter(object, property))) - { - var prototype = object.__proto__; - object.__proto__ = prototypeOfObject; - delete object[property]; - object[property] = descriptor.value; - object.__proto__ = prototype; - } else { - object[property] = descriptor.value; - } - } else { - if (!supportsAccessors) - throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); - if (owns(descriptor, "get")) - defineGetter(object, property, descriptor.get); - if (owns(descriptor, "set")) - defineSetter(object, property, descriptor.set); - } - - return object; - }; -} -if (!Object.defineProperties) { - Object.defineProperties = function defineProperties(object, properties) { - for (var property in properties) { - if (owns(properties, property)) - Object.defineProperty(object, property, properties[property]); - } - return object; - }; -} -if (!Object.seal) { - Object.seal = function seal(object) { - return object; - }; -} -if (!Object.freeze) { - Object.freeze = function freeze(object) { - return object; - }; -} -try { - Object.freeze(function () {}); -} catch (exception) { - Object.freeze = (function freeze(freezeObject) { - return function freeze(object) { - if (typeof object == "function") { - return object; - } else { - return freezeObject(object); - } - }; - })(Object.freeze); -} -if (!Object.preventExtensions) { - Object.preventExtensions = function preventExtensions(object) { - return object; - }; -} -if (!Object.isSealed) { - Object.isSealed = function isSealed(object) { - return false; - }; -} -if (!Object.isFrozen) { - Object.isFrozen = function isFrozen(object) { - return false; - }; -} -if (!Object.isExtensible) { - Object.isExtensible = function isExtensible(object) { - if (Object(object) === object) { - throw new TypeError(); // TODO message - } - var name = ''; - while (owns(object, name)) { - name += '?'; - } - object[name] = true; - var returnValue = owns(object, name); - delete object[name]; - return returnValue; - }; -} -if (!Object.keys) { - var hasDontEnumBug = true, - dontEnums = [ - "toString", - "toLocaleString", - "valueOf", - "hasOwnProperty", - "isPrototypeOf", - "propertyIsEnumerable", - "constructor" - ], - dontEnumsLength = dontEnums.length; - - for (var key in {"toString": null}) { - hasDontEnumBug = false; - } - - Object.keys = function keys(object) { - - if ( - (typeof object != "object" && typeof object != "function") || - object === null - ) { - throw new TypeError("Object.keys called on a non-object"); - } - - var keys = []; - for (var name in object) { - if (owns(object, name)) { - keys.push(name); - } - } - - if (hasDontEnumBug) { - for (var i = 0, ii = dontEnumsLength; i < ii; i++) { - var dontEnum = dontEnums[i]; - if (owns(object, dontEnum)) { - keys.push(dontEnum); - } - } - } - return keys; - }; - -} -if (!Date.now) { - Date.now = function now() { - return new Date().getTime(); - }; -} -var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003" + - "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + - "\u2029\uFEFF"; -if (!String.prototype.trim) { - ws = "[" + ws + "]"; - var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), - trimEndRegexp = new RegExp(ws + ws + "*$"); - String.prototype.trim = function trim() { - return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); - }; -} - -function toInteger(n) { - n = +n; - if (n !== n) { // isNaN - n = 0; - } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) { - n = (n > 0 || -1) * Math.floor(Math.abs(n)); - } - return n; -} - -function isPrimitive(input) { - var type = typeof input; - return ( - input === null || - type === "undefined" || - type === "boolean" || - type === "number" || - type === "string" - ); -} - -function toPrimitive(input) { - var val, valueOf, toString; - if (isPrimitive(input)) { - return input; - } - valueOf = input.valueOf; - if (typeof valueOf === "function") { - val = valueOf.call(input); - if (isPrimitive(val)) { - return val; - } - } - toString = input.toString; - if (typeof toString === "function") { - val = toString.call(input); - if (isPrimitive(val)) { - return val; - } - } - throw new TypeError(); -} -var toObject = function (o) { - if (o == null) { // this matches both null and undefined - throw new TypeError("can't convert "+o+" to object"); - } - return Object(o); -}; - -}); - -define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) { -"use strict"; - -require("./regexp"); -require("./es5-shim"); if (typeof Element != "undefined" && !Element.prototype.remove) { Object.defineProperty(Element.prototype, "remove", { enumerable: false, @@ -1026,8 +253,11 @@ exports.buildDom = function buildDom(arr, parent, refs) { return txt; } - if (!Array.isArray(arr)) + if (!Array.isArray(arr)) { + if (arr && arr.appendChild && parent) + parent.appendChild(arr); return arr; + } if (typeof arr[0] != "string" || !arr[0]) { var els = []; for (var i = 0; i < arr.length; i++) { @@ -1049,10 +279,12 @@ exports.buildDom = function buildDom(arr, parent, refs) { var val = options[n]; if (n === "class") { el.className = Array.isArray(val) ? val.join(" ") : val; - } else if (typeof val == "function" || n == "value") { + } else if (typeof val == "function" || n == "value" || n[0] == "$") { el[n] = val; } else if (n === "ref") { if (refs) refs[val] = el; + } else if (n === "style") { + if (typeof val == "string") el.style.cssText = val; } else if (val != null) { el.setAttribute(n, val); } @@ -1144,7 +376,34 @@ exports.hasCssString = function(id, doc) { } }; -exports.importCssString = function importCssString(cssText, id, target) { +var strictCSP; +var cssCache = []; +exports.useStrictCSP = function(value) { + strictCSP = value; + if (value == false) insertPendingStyles(); + else if (!cssCache) cssCache = []; +}; + +function insertPendingStyles() { + var cache = cssCache; + cssCache = null; + cache && cache.forEach(function(item) { + importCssString(item[0], item[1]); + }); +} + +function importCssString(cssText, id, target) { + if (typeof document == "undefined") + return; + if (cssCache) { + if (target) { + insertPendingStyles(); + } else if (target === false) { + return cssCache.push([cssText, id]); + } + } + if (strictCSP) return; + var container = target; if (!target || !target.getRootNode) { container = document; @@ -1169,7 +428,8 @@ exports.importCssString = function importCssString(cssText, id, target) { if (container == doc) container = exports.getDocumentHead(doc); container.insertBefore(style, container.firstChild); -}; +} +exports.importCssString = importCssString; exports.importCssStylsheet = function(uri, doc) { exports.buildDom(["link", {rel: "stylesheet", href: uri}], exports.getDocumentHead(doc)); @@ -1211,10 +471,6 @@ exports.scrollbarWidth = function(document) { return noScrollbar-withScrollbar; }; -if (typeof document == "undefined") { - exports.importCssString = function() {}; -} - exports.computedStyle = function(element, style) { return window.getComputedStyle(element, "") || {}; }; @@ -1231,6 +487,8 @@ exports.HI_DPI = useragent.isWin ? typeof window !== "undefined" && window.devicePixelRatio >= 1.5 : true; +if (useragent.isChromeOS) exports.HI_DPI = false; + if (typeof document !== "undefined") { var div = document.createElement("div"); if (exports.HI_DPI && div.style.transform !== undefined) @@ -1294,7 +552,8 @@ var Keys = (function() { KEY_MODS: { "ctrl": 1, "alt": 2, "option" : 2, "shift": 4, - "super": 8, "meta": 8, "command": 8, "cmd": 8 + "super": 8, "meta": 8, "command": 8, "cmd": 8, + "control": 1 }, FUNCTION_KEYS : { @@ -1422,12 +681,24 @@ function getListenerOptions() { return activeListenerOptions; } -exports.addListener = function(elem, type, callback) { - return elem.addEventListener(type, callback, getListenerOptions()); +function EventListener(elem, type, callback) { + this.elem = elem; + this.type = type; + this.callback = callback; +} +EventListener.prototype.destroy = function() { + removeListener(this.elem, this.type, this.callback); + this.elem = this.type = this.callback = undefined; }; -exports.removeListener = function(elem, type, callback) { - return elem.removeEventListener(type, callback, getListenerOptions()); +var addListener = exports.addListener = function(elem, type, callback, destroyer) { + elem.addEventListener(type, callback, getListenerOptions()); + if (destroyer) + destroyer.$toDestroy.push(new EventListener(elem, type, callback)); +}; + +var removeListener = exports.removeListener = function(elem, type, callback) { + elem.removeEventListener(type, callback, getListenerOptions()); }; exports.stopEvent = function(e) { exports.stopPropagation(e); @@ -1453,25 +724,26 @@ exports.getButton = function(e) { }; exports.capture = function(el, eventHandler, releaseCaptureHandler) { + var ownerDocument = el && el.ownerDocument || document; function onMouseUp(e) { eventHandler && eventHandler(e); releaseCaptureHandler && releaseCaptureHandler(e); - exports.removeListener(document, "mousemove", eventHandler, true); - exports.removeListener(document, "mouseup", onMouseUp, true); - exports.removeListener(document, "dragstart", onMouseUp, true); + removeListener(ownerDocument, "mousemove", eventHandler); + removeListener(ownerDocument, "mouseup", onMouseUp); + removeListener(ownerDocument, "dragstart", onMouseUp); } - exports.addListener(document, "mousemove", eventHandler, true); - exports.addListener(document, "mouseup", onMouseUp, true); - exports.addListener(document, "dragstart", onMouseUp, true); + addListener(ownerDocument, "mousemove", eventHandler); + addListener(ownerDocument, "mouseup", onMouseUp); + addListener(ownerDocument, "dragstart", onMouseUp); return onMouseUp; }; -exports.addMouseWheelListener = function(el, callback) { +exports.addMouseWheelListener = function(el, callback, destroyer) { if ("onmousewheel" in el) { - exports.addListener(el, "mousewheel", function(e) { + addListener(el, "mousewheel", function(e) { var factor = 8; if (e.wheelDeltaX !== undefined) { e.wheelX = -e.wheelDeltaX / factor; @@ -1481,9 +753,9 @@ exports.addMouseWheelListener = function(el, callback) { e.wheelY = -e.wheelDelta / factor; } callback(e); - }); + }, destroyer); } else if ("onwheel" in el) { - exports.addListener(el, "wheel", function(e) { + addListener(el, "wheel", function(e) { var factor = 0.35; switch (e.deltaMode) { case e.DOM_DELTA_PIXEL: @@ -1498,9 +770,9 @@ exports.addMouseWheelListener = function(el, callback) { } callback(e); - }); + }, destroyer); } else { - exports.addListener(el, "DOMMouseScroll", function(e) { + addListener(el, "DOMMouseScroll", function(e) { if (e.axis && e.axis == e.HORIZONTAL_AXIS) { e.wheelX = (e.detail || 0) * 5; e.wheelY = 0; @@ -1509,11 +781,11 @@ exports.addMouseWheelListener = function(el, callback) { e.wheelY = (e.detail || 0) * 5; } callback(e); - }); + }, destroyer); } }; -exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName) { +exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName, destroyer) { var clicks = 0; var startX, startY, timer; var eventNames = { @@ -1558,7 +830,7 @@ exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, c if (!Array.isArray(elements)) elements = [elements]; elements.forEach(function(el) { - exports.addListener(el, "mousedown", onMousedown); + addListener(el, "mousedown", onMousedown, destroyer); }); }; @@ -1623,16 +895,15 @@ function normalizeCommandKeys(callback, e, keyCode) { } -exports.addCommandKeyListener = function(el, callback) { - var addListener = exports.addListener; +exports.addCommandKeyListener = function(el, callback, destroyer) { if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) { var lastKeyDownKeyCode = null; addListener(el, "keydown", function(e) { lastKeyDownKeyCode = e.keyCode; - }); + }, destroyer); addListener(el, "keypress", function(e) { return normalizeCommandKeys(callback, e, lastKeyDownKeyCode); - }); + }, destroyer); } else { var lastDefaultPrevented = null; @@ -1641,18 +912,18 @@ exports.addCommandKeyListener = function(el, callback) { var result = normalizeCommandKeys(callback, e, e.keyCode); lastDefaultPrevented = e.defaultPrevented; return result; - }); + }, destroyer); addListener(el, "keypress", function(e) { if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) { exports.stopEvent(e); lastDefaultPrevented = null; } - }); + }, destroyer); addListener(el, "keyup", function(e) { pressedKeys[e.keyCode] = null; - }); + }, destroyer); if (!pressedKeys) { resetPressedKeys(); @@ -1673,12 +944,12 @@ if (typeof window == "object" && window.postMessage && !useragent.isOldIE) { var listener = function(e) { if (e.data == messageName) { exports.stopPropagation(e); - exports.removeListener(win, "message", listener); + removeListener(win, "message", listener); callback(); } }; - exports.addListener(win, "message", listener); + addListener(win, "message", listener); win.postMessage(messageName, "*"); }; } @@ -2181,6 +1452,7 @@ var KEYS = require("../lib/keys"); var MODS = KEYS.KEY_MODS; var isIOS = useragent.isIOS; var valueResetRegex = isIOS ? /\s/ : /\n/; +var isMobile = useragent.isMobile; var TextInput = function(parentNode, host) { var text = dom.createElement("textarea"); @@ -2200,7 +1472,7 @@ var TextInput = function(parentNode, host) { var sendingText = false; var tempStyle = ''; - if (!useragent.isMobile) + if (!isMobile) text.style.fontSize = "1px"; var commandMode = false; @@ -2216,7 +1488,7 @@ var TextInput = function(parentNode, host) { if (ignoreFocusEvents) return; host.onBlur(e); isFocused = false; - }); + }, host); event.addListener(text, "focus", function(e) { if (ignoreFocusEvents) return; isFocused = true; @@ -2231,7 +1503,7 @@ var TextInput = function(parentNode, host) { setTimeout(resetSelection); else resetSelection(); - }); + }, host); this.$focusScroll = false; this.focus = function() { if (tempStyle || HAS_FOCUS_ARGS || this.$focusScroll == "browser") @@ -2277,9 +1549,12 @@ var TextInput = function(parentNode, host) { }; host.on("beforeEndOperation", function() { - if (host.curOp && host.curOp.command.name == "insertstring") + var curOp = host.curOp; + var commandName = curOp && curOp.command && curOp.command.name; + if (commandName == "insertstring") return; - if (inComposition) { + var isUserAction = commandName && (curOp.docChanged || curOp.selectionChanged); + if (inComposition && isUserAction) { lastValue = text.value = ""; onCompositionEnd(); } @@ -2311,33 +1586,49 @@ var TextInput = function(parentNode, host) { return; inComposition = true; - var selection = host.selection; - var range = selection.getRange(); - var row = selection.cursor.row; - var selectionStart = range.start.column; - var selectionEnd = range.end.column; - var line = host.session.getLine(row); + var selectionStart = 0; + var selectionEnd = 0; + var line = ""; - if (range.start.row != row) { - var prevLine = host.session.getLine(row - 1); - selectionStart = range.start.row < row - 1 ? 0 : selectionStart; - selectionEnd += prevLine.length + 1; - line = prevLine + "\n" + line; - } - else if (range.end.row != row) { - var nextLine = host.session.getLine(row + 1); - selectionEnd = range.end.row > row + 1 ? nextLine.length : selectionEnd; - selectionEnd += line.length + 1; - line = line + "\n" + nextLine; - } + if (host.session) { + var selection = host.selection; + var range = selection.getRange(); + var row = selection.cursor.row; + selectionStart = range.start.column; + selectionEnd = range.end.column; + line = host.session.getLine(row); - if (line.length > MAX_LINE_LENGTH) { - if (selectionStart < MAX_LINE_LENGTH && selectionEnd < MAX_LINE_LENGTH) { - line = line.slice(0, MAX_LINE_LENGTH); - } else { - line = "\n"; - selectionStart = 0; - selectionEnd = 1; + if (range.start.row != row) { + var prevLine = host.session.getLine(row - 1); + selectionStart = range.start.row < row - 1 ? 0 : selectionStart; + selectionEnd += prevLine.length + 1; + line = prevLine + "\n" + line; + } + else if (range.end.row != row) { + var nextLine = host.session.getLine(row + 1); + selectionEnd = range.end.row > row + 1 ? nextLine.length : selectionEnd; + selectionEnd += line.length + 1; + line = line + "\n" + nextLine; + } + else if (isMobile && row > 0) { + line = "\n" + line; + selectionEnd += 1; + selectionStart += 1; + } + + if (line.length > MAX_LINE_LENGTH) { + if (selectionStart < MAX_LINE_LENGTH && selectionEnd < MAX_LINE_LENGTH) { + line = line.slice(0, MAX_LINE_LENGTH); + } else { + line = "\n"; + if (selectionStart == selectionEnd) { + selectionStart = selectionEnd = 0; + } + else { + selectionStart = 0; + selectionEnd = 1; + } + } } } @@ -2363,6 +1654,7 @@ var TextInput = function(parentNode, host) { } inComposition = false; }; + this.resetSelection = resetSelection; if (isFocused) host.onFocus(); @@ -2382,6 +1674,8 @@ var TextInput = function(parentNode, host) { } else if (isAllSelected(text)) { host.selectAll(); resetSelection(); + } else if (isMobile && text.selectionStart != lastSelectionStart) { + resetSelection(); } }; @@ -2432,6 +1726,12 @@ var TextInput = function(parentNode, host) { if (!fromInput && !inserted && !restoreStart && !extendLeft && !extendRight && !restoreEnd) return ""; sendingText = true; + var shouldReset = false; + if (useragent.isAndroid && inserted == ". ") { + inserted = " "; + shouldReset = true; + } + if (inserted && !extendLeft && !extendRight && !restoreStart && !restoreEnd || commandMode) { host.onTextInput(inserted); } else { @@ -2448,7 +1748,7 @@ var TextInput = function(parentNode, host) { lastSelectionStart = selectionStart; lastSelectionEnd = selectionEnd; lastRestoreEnd = restoreEnd; - return inserted; + return shouldReset ? "\n" : inserted; } }; var onInput = function(e) { @@ -2460,8 +1760,13 @@ var TextInput = function(parentNode, host) { } var data = text.value; var inserted = sendText(data, true); - if (data.length > MAX_LINE_LENGTH + 100 || valueResetRegex.test(inserted)) + if ( + data.length > MAX_LINE_LENGTH + 100 + || valueResetRegex.test(inserted) + || isMobile && lastSelectionStart < 1 && lastSelectionStart == lastSelectionEnd + ) { resetSelection(); + } }; var handleClipboardData = function(e, data, forceIEMime) { @@ -2533,14 +1838,14 @@ var TextInput = function(parentNode, host) { } }; - event.addCommandKeyListener(text, host.onCommandKey.bind(host)); + event.addCommandKeyListener(text, host.onCommandKey.bind(host), host); - event.addListener(text, "select", onSelect); - event.addListener(text, "input", onInput); + event.addListener(text, "select", onSelect, host); + event.addListener(text, "input", onInput, host); - event.addListener(text, "cut", onCut); - event.addListener(text, "copy", onCopy); - event.addListener(text, "paste", onPaste); + event.addListener(text, "cut", onCut, host); + event.addListener(text, "copy", onCopy, host); + event.addListener(text, "paste", onPaste, host); if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)) { event.addListener(parentNode, "keydown", function(e) { if ((useragent.isMac && !e.metaKey) || !e.ctrlKey) @@ -2557,7 +1862,7 @@ var TextInput = function(parentNode, host) { onCut(e); break; } - }); + }, host); } var onCompositionStart = function(e) { if (inComposition || !host.onCompositionStart || host.$readOnly) @@ -2568,7 +1873,11 @@ var TextInput = function(parentNode, host) { if (commandMode) return; + if (e.data) + inComposition.useTextareaForIME = false; + setTimeout(onCompositionUpdate, 0); + host._signal("compositionStart"); host.on("mousedown", cancelComposition); var range = host.getSelectionRange(); @@ -2579,8 +1888,7 @@ var TextInput = function(parentNode, host) { host.onCompositionStart(inComposition); if (inComposition.useTextareaForIME) { - text.value = ""; - lastValue = ""; + lastValue = text.value = ""; lastSelectionStart = 0; lastSelectionEnd = 0; } @@ -2643,11 +1951,11 @@ var TextInput = function(parentNode, host) { syncComposition(); } - event.addListener(text, "compositionstart", onCompositionStart); - event.addListener(text, "compositionupdate", onCompositionUpdate); - event.addListener(text, "keyup", onKeyup); - event.addListener(text, "keydown", syncComposition); - event.addListener(text, "compositionend", onCompositionEnd); + event.addListener(text, "compositionstart", onCompositionStart, host); + event.addListener(text, "compositionupdate", onCompositionUpdate, host); + event.addListener(text, "keyup", onKeyup, host); + event.addListener(text, "keydown", syncComposition, host); + event.addListener(text, "compositionend", onCompositionEnd, host); this.getElement = function() { return text; @@ -2718,13 +2026,13 @@ var TextInput = function(parentNode, host) { host.textInput.onContextMenu(e); onContextMenuClose(); }; - event.addListener(text, "mouseup", onContextMenu); + event.addListener(text, "mouseup", onContextMenu, host); event.addListener(text, "mousedown", function(e) { e.preventDefault(); onContextMenuClose(); - }); - event.addListener(host.renderer.scroller, "contextmenu", onContextMenu); - event.addListener(text, "contextmenu", onContextMenu); + }, host); + event.addListener(host.renderer.scroller, "contextmenu", onContextMenu, host); + event.addListener(text, "contextmenu", onContextMenu, host); if (isIOS) addIosSelectionHandler(parentNode, host, text); @@ -2810,10 +2118,13 @@ var TextInput = function(parentNode, host) { document.removeEventListener("selectionchange", detectArrowKeys); }); } - }; exports.TextInput = TextInput; +exports.$setUserAgentForTests = function(_isMobile, _isIOS) { + isMobile = _isMobile; + isIOS = _isIOS; +}; }); define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"], function(require, exports, module) { @@ -3243,7 +2554,7 @@ function GutterHandler(mouseHandler) { tooltip.hide(); tooltipAnnotation = null; editor._signal("hideGutterTooltip", tooltip); - editor.removeEventListener("mousewheel", hideTooltip); + editor.off("mousewheel", hideTooltip); } } @@ -3280,7 +2591,7 @@ function GutterHandler(mouseHandler) { tooltipTimeout = null; hideTooltip(); }, 50); - }); + }, editor); editor.on("changeSession", hideTooltip); } @@ -3405,18 +2716,16 @@ function DragdropHandler(mouseHandler) { var editor = mouseHandler.editor; - var blankImage = dom.createElement("img"); - blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; - if (useragent.isOpera) - blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;"; + var dragImage = dom.createElement("div"); + dragImage.style.cssText = "top:-100px;position:absolute;z-index:2147483647;opacity:0.5"; + dragImage.textContent = "\xa0"; var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"]; - exports.forEach(function(x) { - mouseHandler[x] = this[x]; + exports.forEach(function(x) { + mouseHandler[x] = this[x]; }, this); - editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler)); - + editor.on("mousedown", this.onMouseDown.bind(mouseHandler)); var mouseTarget = editor.container; var dragSelectionMarker, x, y; @@ -3441,14 +2750,12 @@ function DragdropHandler(mouseHandler) { var dataTransfer = e.dataTransfer; dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove"; - if (useragent.isOpera) { - editor.container.appendChild(blankImage); - blankImage.scrollTop = 0; - } - dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0); - if (useragent.isOpera) { - editor.container.removeChild(blankImage); - } + editor.container.appendChild(dragImage); + + dataTransfer.setDragImage && dataTransfer.setDragImage(dragImage, 0, 0); + setTimeout(function() { + editor.container.removeChild(dragImage); + }); dataTransfer.clearData(); dataTransfer.setData("Text", editor.session.getTextRange()); @@ -3540,12 +2847,12 @@ function DragdropHandler(mouseHandler) { return event.preventDefault(e); }; - event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler)); - event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler)); - event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler)); - event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler)); - event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler)); - event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler)); + event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler), editor); + event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler), editor); + event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler), editor); + event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler), editor); + event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler), editor); + event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler), editor); function scrollCursorIntoView(cursor, prevCursor) { var now = Date.now(); @@ -3860,9 +3167,17 @@ exports.addTouchListeners = function(el, editor) { if (!contextMenu) createContextMenu(); var cursor = editor.selection.cursor; var pagePos = editor.renderer.textToScreenCoordinates(cursor.row, cursor.column); + var leftOffset = editor.renderer.textToScreenCoordinates(0, 0).pageX; + var scrollLeft = editor.renderer.scrollLeft; var rect = editor.container.getBoundingClientRect(); contextMenu.style.top = pagePos.pageY - rect.top - 3 + "px"; - contextMenu.style.right = "10px"; + if (pagePos.pageX - rect.left < rect.width - 70) { + contextMenu.style.left = ""; + contextMenu.style.right = "10px"; + } else { + contextMenu.style.right = ""; + contextMenu.style.left = leftOffset + scrollLeft - rect.left + "px"; + } contextMenu.style.display = ""; contextMenu.firstChild.style.display = "none"; editor.on("input", hideContextMenu); @@ -3903,7 +3218,7 @@ exports.addTouchListeners = function(el, editor) { if (!pressed) return; var textarea = editor.textInput.getElement(); textarea.focus(); - }); + }, editor); event.addListener(el, "touchstart", function (e) { var touches = e.touches; if (longTouchTimer || touches.length > 1) { @@ -3945,6 +3260,8 @@ exports.addTouchListeners = function(el, editor) { var cursorPos = editor.renderer.$cursorLayer.getPixelPosition(cursor, true); var anchorPos = editor.renderer.$cursorLayer.getPixelPosition(anchor, true); var rect = editor.renderer.scroller.getBoundingClientRect(); + var offsetTop = editor.renderer.layerConfig.offset; + var offsetLeft = editor.renderer.scrollLeft; var weightedDistance = function(x, y) { x = x / w; y = y / h - 0.75; @@ -3957,12 +3274,12 @@ exports.addTouchListeners = function(el, editor) { } var diff1 = weightedDistance( - e.clientX - rect.left - cursorPos.left, - e.clientY - rect.top - cursorPos.top + e.clientX - rect.left - cursorPos.left + offsetLeft, + e.clientY - rect.top - cursorPos.top + offsetTop ); var diff2 = weightedDistance( - e.clientX - rect.left - anchorPos.left, - e.clientY - rect.top - anchorPos.top + e.clientX - rect.left - anchorPos.left + offsetLeft, + e.clientY - rect.top - anchorPos.top + offsetTop ); if (diff1 < 3.5 && diff2 < 3.5) mode = diff1 > diff2 ? "cursor" : "anchor"; @@ -3976,7 +3293,7 @@ exports.addTouchListeners = function(el, editor) { longTouchTimer = setTimeout(handleLongTap, 450); } touchStartT = t; - }); + }, editor); event.addListener(el, "touchend", function (e) { pressed = editor.$mouseHandler.isMousePressed = false; @@ -3990,14 +3307,13 @@ exports.addTouchListeners = function(el, editor) { showContextMenu(); } else if (mode == "scroll") { animate(); - e.preventDefault(); hideContextMenu(); } else { showContextMenu(); } clearTimeout(longTouchTimer); longTouchTimer = null; - }); + }, editor); event.addListener(el, "touchmove", function (e) { if (longTouchTimer) { clearTimeout(longTouchTimer); @@ -4053,7 +3369,7 @@ exports.addTouchListeners = function(el, editor) { editor.renderer.scrollCursorIntoView(pos); e.preventDefault(); } - }); + }, editor); function animate() { animationSteps += 60; @@ -4164,8 +3480,8 @@ EventEmitter._signal = function(eventName, e) { EventEmitter.once = function(eventName, callback) { var _self = this; - this.addEventListener(eventName, function newCallback() { - _self.removeEventListener(eventName, newCallback); + this.on(eventName, function newCallback() { + _self.off(eventName, newCallback); callback.apply(null, arguments); }); if (!callback) { @@ -4237,7 +3553,9 @@ EventEmitter.removeEventListener = function(eventName, callback) { }; EventEmitter.removeAllListeners = function(eventName) { - if (this._eventRegistry) this._eventRegistry[eventName] = []; + if (!eventName) this._eventRegistry = this._defaultHandlers = undefined; + if (this._eventRegistry) this._eventRegistry[eventName] = undefined; + if (this._defaultHandlers) this._defaultHandlers[eventName] = undefined; }; exports.EventEmitter = EventEmitter; @@ -4376,12 +3694,13 @@ exports.AppConfig = AppConfig; }); -define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) { +define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/dom","ace/lib/app_config"], function(require, exports, module) { "no use strict"; var lang = require("./lib/lang"); var oop = require("./lib/oop"); var net = require("./lib/net"); +var dom = require("./lib/dom"); var AppConfig = require("./lib/app_config").AppConfig; module.exports = exports = new AppConfig(); @@ -4399,13 +3718,13 @@ var options = { suffix: ".js", $moduleUrls: {}, loadWorkerFromBlob: true, - sharedPopups: false + sharedPopups: false, + useStrictCSP: null }; exports.get = function(key) { if (!options.hasOwnProperty(key)) throw new Error("Unknown config key: " + key); - return options[key]; }; @@ -4414,6 +3733,8 @@ exports.set = function(key, value) { options[key] = value; else if (this.setDefaultValue("", key, value) == false) throw new Error("Unknown config key: " + key); + if (key == "useStrictCSP") + dom.useStrictCSP(value); }; exports.all = function() { @@ -4560,7 +3881,7 @@ function deHyphenate(str) { return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); }); } -exports.version = "1.4.8"; +exports.version = "1.4.14"; }); @@ -4593,28 +3914,28 @@ var MouseHandler = function(editor) { }; var mouseTarget = editor.renderer.getMouseEventTarget(); - event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click")); - event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove")); + event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"), editor); + event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"), editor); event.addMultiMouseDownListener([ mouseTarget, editor.renderer.scrollBarV && editor.renderer.scrollBarV.inner, editor.renderer.scrollBarH && editor.renderer.scrollBarH.inner, editor.textInput && editor.textInput.getElement() - ].filter(Boolean), [400, 300, 250], this, "onMouseEvent"); - event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel")); + ].filter(Boolean), [400, 300, 250], this, "onMouseEvent", editor); + event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"), editor); addTouchListeners(editor.container, editor); var gutterEl = editor.renderer.$gutter; - event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown")); - event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick")); - event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick")); - event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove")); + event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"), editor); + event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"), editor); + event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"), editor); + event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"), editor); - event.addListener(mouseTarget, "mousedown", focusEditor); - event.addListener(gutterEl, "mousedown", focusEditor); + event.addListener(mouseTarget, "mousedown", focusEditor, editor); + event.addListener(gutterEl, "mousedown", focusEditor, editor); if (useragent.isIE && editor.renderer.scrollBarV) { - event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor); - event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor); + event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor, editor); + event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor, editor); } editor.on("mousemove", function(e){ @@ -4630,11 +3951,12 @@ var MouseHandler = function(editor) { } else { renderer.setCursorStyle(""); } - }); + }, editor); }; (function() { this.onMouseEvent = function(name, e) { + if (!this.editor.session) return; this.editor._emit(name, new MouseEvent(e, this.editor)); }; @@ -4684,7 +4006,7 @@ var MouseHandler = function(editor) { var onCaptureEnd = function(e) { editor.off("beforeEndOperation", onOperationEnd); clearInterval(timerId); - onCaptureInterval(); + if (editor.session) onCaptureInterval(); self[self.state + "End"] && self[self.state + "End"](e); self.state = ""; self.isMousePressed = renderer.$isMousePressed = false; @@ -4732,6 +4054,9 @@ var MouseHandler = function(editor) { setTimeout(stop, 10); this.editor.on("nativecontextmenu", stop); }; + this.destroy = function() { + if (this.releaseMouse) this.releaseMouse(); + }; }).call(MouseHandler.prototype); config.defineOptions(MouseHandler.prototype, "mouseHandler", { @@ -6102,7 +5427,6 @@ var Selection = function(session) { this.detach = function() { this.lead.detach(); this.anchor.detach(); - this.session = this.doc = null; }; this.fromOrientedRange = function(range) { @@ -6318,7 +5642,7 @@ var Tokenizer = function(rules) { this.removeCapturingGroups = function(src) { var r = src.replace( - /\\.|\[(?:\\.|[^\\\]])*|\(\?[:=!]|(\()/g, + /\\.|\[(?:\\.|[^\\\]])*|\(\?[:=!<]|(\()/g, function(x, y) {return y ? "(?:" : x;} ); return r; @@ -6677,18 +6001,18 @@ var TextHighlightRules = function() { this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) { var keywords = Object.create(null); + this.$keywordList = []; Object.keys(map).forEach(function(className) { var a = map[className]; - if (ignoreCase) - a = a.toLowerCase(); var list = a.split(splitChar || "|"); - for (var i = list.length; i--; ) - keywords[list[i]] = className; - }); - if (Object.getPrototypeOf(keywords)) { - keywords.__proto__ = null; - } - this.$keywordList = Object.keys(keywords); + for (var i = list.length; i--; ) { + var word = list[i]; + this.$keywordList.push(word); + if (ignoreCase) + word = word.toLowerCase(); + keywords[word] = className; + } + }, this); map = null; return ignoreCase ? function(value) {return keywords[value.toLowerCase()] || defaultToken; } @@ -7751,7 +7075,7 @@ var Anchor = exports.Anchor = function(doc, row, column) { }); }; this.detach = function() { - this.document.removeEventListener("change", this.$onChange); + this.document.off("change", this.$onChange); }; this.attach = function(doc) { this.document = doc || this.document; @@ -8083,6 +7407,16 @@ var Document = function(textOrLines) { } }; + this.$safeApplyDelta = function(delta) { + var docLength = this.$lines.length; + if ( + delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength + || delta.action == "insert" && delta.start.row <= docLength + ) { + this.applyDelta(delta); + } + }; + this.$splitAndapplyLargeDelta = function(delta, MAX) { var lines = delta.lines; var l = lines.length - MAX + 1; @@ -8105,7 +7439,7 @@ var Document = function(textOrLines) { this.applyDelta(delta, true); }; this.revertDelta = function(delta) { - this.applyDelta({ + this.$safeApplyDelta({ start: this.clonePos(delta.start), end: this.clonePos(delta.end), action: (delta.action == "insert" ? "remove" : "insert"), @@ -9142,9 +8476,11 @@ function Folding() { var folds = this.getFoldsInRange(fold.range); if (folds.length > 0) { this.removeFolds(folds); - folds.forEach(function(subFold) { - fold.addSubFold(subFold); - }); + if (!fold.collapseChildren) { + folds.forEach(function(subFold) { + fold.addSubFold(subFold); + }); + } } for (var i = 0; i < foldData.length; i++) { @@ -9263,26 +8599,39 @@ function Folding() { var range, folds; if (location == null) { range = new Range(0, 0, this.getLength(), 0); - expandInner = true; - } else if (typeof location == "number") + if (expandInner == null) expandInner = true; + } else if (typeof location == "number") { range = new Range(location, 0, location, this.getLine(location).length); - else if ("row" in location) + } else if ("row" in location) { range = Range.fromPoints(location, location); - else + } else if (Array.isArray(location)) { + folds = []; + location.forEach(function(range) { + folds = folds.concat(this.unfold(range)); + }, this); + return folds; + } else { range = location; + } folds = this.getFoldsInRangeList(range); - if (expandInner) { + var outermostFolds = folds; + while ( + folds.length == 1 + && Range.comparePoints(folds[0].start, range.start) < 0 + && Range.comparePoints(folds[0].end, range.end) > 0 + ) { + this.expandFolds(folds); + folds = this.getFoldsInRangeList(range); + } + + if (expandInner != false) { this.removeFolds(folds); } else { - var subFolds = folds; - while (subFolds.length) { - this.expandFolds(subFolds); - subFolds = this.getFoldsInRangeList(range); - } + this.expandFolds(folds); } - if (folds.length) - return folds; + if (outermostFolds.length) + return outermostFolds; }; this.isRowFolded = function(docRow, startFoldRow) { return !!this.getFoldLine(docRow, startFoldRow); @@ -9416,7 +8765,7 @@ function Folding() { this.getCommentFoldRange = function(row, column, dir) { var iterator = new TokenIterator(this, row, column); var token = iterator.getCurrentToken(); - var type = token.type; + var type = token && token.type; if (token && /^comment|string/.test(type)) { type = type.match(/comment|string/)[0]; if (type == "comment") @@ -9457,7 +8806,7 @@ function Folding() { } }; - this.foldAll = function(startRow, endRow, depth) { + this.foldAll = function(startRow, endRow, depth, test) { if (depth == undefined) depth = 100000; // JSON.stringify doesn't hanle Infinity var foldWidgets = this.foldWidgets; @@ -9470,6 +8819,8 @@ function Folding() { foldWidgets[row] = this.getFoldWidget(row); if (foldWidgets[row] != "start") continue; + + if (test && !test(row)) continue; var range = this.getFoldWidgetRange(row); if (range && range.isMultiLine() @@ -9477,14 +8828,32 @@ function Folding() { && range.start.row >= startRow ) { row = range.end.row; - try { - var fold = this.addFold("...", range); - if (fold) - fold.collapseChildren = depth; - } catch(e) {} + range.collapseChildren = depth; + this.addFold("...", range); } } }; + + this.foldToLevel = function(level) { + this.foldAll(); + while (level-- > 0) + this.unfold(null, false); + }; + + this.foldAllComments = function() { + var session = this; + this.foldAll(null, null, null, function(row) { + var tokens = session.getTokens(row); + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (token.type == "text" && /^\s+$/.test(token.value)) + continue; + if (/comment/.test(token.type)) + return true; + return false; + } + }); + }; this.$foldStyles = { "manual": 1, "markbegin": 1, @@ -9929,7 +9298,7 @@ EditSession.$uid = 0; oop.implement(this, EventEmitter); this.setDocument = function(doc) { if (this.doc) - this.doc.removeListener("change", this.$onChange); + this.doc.off("change", this.$onChange); this.doc = doc; doc.on("change", this.$onChange); @@ -10356,7 +9725,8 @@ EditSession.$uid = 0; this.$modeId = mode.$id; if (this.$mode === mode) return; - + + var oldMode = this.$mode; this.$mode = mode; this.$stopWorker(); @@ -10366,15 +9736,15 @@ EditSession.$uid = 0; var tokenizer = mode.getTokenizer(); - if(tokenizer.addEventListener !== undefined) { + if(tokenizer.on !== undefined) { var onReloadTokenizer = this.onReloadTokenizer.bind(this); - tokenizer.addEventListener("update", onReloadTokenizer); + tokenizer.on("update", onReloadTokenizer); } if (!this.bgTokenizer) { this.bgTokenizer = new BackgroundTokenizer(tokenizer); var _self = this; - this.bgTokenizer.addEventListener("update", function(e) { + this.bgTokenizer.on("update", function(e) { _self._signal("tokenizerUpdate", e); }); } else { @@ -10393,7 +9763,7 @@ EditSession.$uid = 0; this.$options.wrapMethod.set.call(this, this.$wrapMethod); this.$setFolding(mode.foldingRules); this.bgTokenizer.start(0); - this._emit("changeMode"); + this._emit("changeMode", {oldMode: oldMode, mode: mode}); } }; @@ -10539,7 +9909,7 @@ EditSession.$uid = 0; for (var i = 0; i < deltas.length; i++) { var delta = deltas[i]; if (delta.action == "insert" || delta.action == "remove") { - this.doc.applyDelta(delta); + this.doc.$safeApplyDelta(delta); } } @@ -10561,7 +9931,6 @@ EditSession.$uid = 0; } var range, point; - var lastDeltaIsInsert; for (var i = 0; i < deltas.length; i++) { var delta = deltas[i]; @@ -10569,10 +9938,8 @@ EditSession.$uid = 0; if (!range) { if (isInsert(delta)) { range = Range.fromPoints(delta.start, delta.end); - lastDeltaIsInsert = true; } else { range = Range.fromPoints(delta.start, delta.start); - lastDeltaIsInsert = false; } continue; } @@ -10586,13 +9953,11 @@ EditSession.$uid = 0; if (range.compare(point.row, point.column) == 1) { range.setEnd(point); } - lastDeltaIsInsert = true; } else { point = delta.start; if (range.compare(point.row, point.column) == -1) { range = Range.fromPoints(delta.start, delta.start); } - lastDeltaIsInsert = false; } } return range; @@ -11458,6 +10823,11 @@ EditSession.$uid = 0; this.bgTokenizer = null; } this.$stopWorker(); + this.removeAllListeners(); + if (this.doc) { + this.doc.off("change", this.$onChange); + } + this.selection.detach(); }; this.isFullWidth = isFullWidth; @@ -11848,7 +11218,7 @@ var Search = function() { var len = re.length; var forEachInLine = function(row, offset, callback) { var startRow = backwards ? row - len + 1 : row; - if (startRow < 0) return; + if (startRow < 0 || startRow + len > session.getLength()) return; var line = session.getLine(startRow); var startIndex = line.search(re[0]); if (!backwards && startIndex < offset || startIndex === -1) return; @@ -12199,7 +11569,7 @@ oop.inherits(CommandManager, MultiHashHandler); editor && editor._emit("changeStatus"); if (this.recording) { this.macro.pop(); - this.removeEventListener("exec", this.$addCommandToMacro); + this.off("exec", this.$addCommandToMacro); if (!this.macro.length) this.macro = this.oldMacro; @@ -12266,6 +11636,7 @@ function bindKey(win, mac) { } exports.commands = [{ name: "showSettingsMenu", + description: "Show settings menu", bindKey: bindKey("Ctrl-,", "Command-,"), exec: function(editor) { config.loadModule("ace/ext/settings_menu", function(module) { @@ -12276,6 +11647,7 @@ exports.commands = [{ readOnly: true }, { name: "goToNextError", + description: "Go to next error", bindKey: bindKey("Alt-E", "F4"), exec: function(editor) { config.loadModule("./ext/error_marker", function(module) { @@ -12286,6 +11658,7 @@ exports.commands = [{ readOnly: true }, { name: "goToPreviousError", + description: "Go to previous error", bindKey: bindKey("Alt-Shift-E", "Shift-F4"), exec: function(editor) { config.loadModule("./ext/error_marker", function(module) { @@ -12332,6 +11705,7 @@ exports.commands = [{ readOnly: true }, { name: "toggleFoldWidget", + description: "Toggle fold widget", bindKey: bindKey("F2", "F2"), exec: function(editor) { editor.session.toggleFoldWidget(); }, multiSelectAction: "forEach", @@ -12339,6 +11713,7 @@ exports.commands = [{ readOnly: true }, { name: "toggleParentFoldWidget", + description: "Toggle parent fold widget", bindKey: bindKey("Alt-F2", "Alt-F2"), exec: function(editor) { editor.session.toggleFoldWidget(true); }, multiSelectAction: "forEach", @@ -12351,6 +11726,13 @@ exports.commands = [{ exec: function(editor) { editor.session.foldAll(); }, scrollIntoView: "center", readOnly: true +}, { + name: "foldAllComments", + description: "Fold all comments", + bindKey: bindKey(null, "Ctrl-Command-Option-0"), + exec: function(editor) { editor.session.foldAllComments(); }, + scrollIntoView: "center", + readOnly: true }, { name: "foldOther", description: "Fold other", @@ -12959,6 +12341,13 @@ exports.commands = [{ exec: function(editor) { editor.toLowerCase(); }, multiSelectAction: "forEach", scrollIntoView: "cursor" +}, { + name: "autoindent", + description: "Auto Indent", + bindKey: bindKey(null, null), + exec: function(editor) { editor.autoIndent(); }, + multiSelectAction: "forEachLine", + scrollIntoView: "animate" }, { name: "expandtoline", description: "Expand to line", @@ -13051,6 +12440,7 @@ exports.commands = [{ scrollIntoView: "none" }, { name: "addLineAfter", + description: "Add new line after the current line", exec: function(editor) { editor.selection.clearSelection(); editor.navigateLineEnd(); @@ -13060,6 +12450,7 @@ exports.commands = [{ scrollIntoView: "cursor" }, { name: "addLineBefore", + description: "Add new line before the current line", exec: function(editor) { editor.selection.clearSelection(); var cursor = editor.getCursorPosition(); @@ -13087,6 +12478,17 @@ exports.commands = [{ readOnly: true }]; +for (var i = 1; i < 9; i++) { + exports.commands.push({ + name: "foldToLevel" + i, + description: "Fold To Level " + i, + level: i, + exec: function(editor) { editor.session.foldToLevel(this.level); }, + scrollIntoView: "center", + readOnly: true + }); +} + }); define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator","ace/clipboard"], function(require, exports, module) { @@ -13113,6 +12515,7 @@ var TokenIterator = require("./token_iterator").TokenIterator; var clipboard = require("./clipboard"); var Editor = function(renderer, session, options) { + this.$toDestroy = []; var container = renderer.getContainerElement(); this.container = container; this.renderer = renderer; @@ -13205,8 +12608,8 @@ Editor.$uid = 0; }; this.endOperation = function(e) { - if (this.curOp) { - if (e && e.returnValue === false) + if (this.curOp && this.session) { + if (e && e.returnValue === false || !this.session) return (this.curOp = null); if (e == true && this.curOp.command && this.curOp.command.name == "mouse") return; @@ -13517,25 +12920,33 @@ Editor.$uid = 0; return; } - if (token.type.indexOf("tag-open") != -1) { + if (token.type.indexOf("tag-open") !== -1) { token = iterator.stepForward(); if (!token) return; } var tag = token.value; + var currentTag = token.value; var depth = 0; var prevToken = iterator.stepBackward(); - if (prevToken.value == '<'){ + if (prevToken.value === '<'){ do { prevToken = token; token = iterator.stepForward(); - - if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { - if (prevToken.value === '<'){ - depth++; - } else if (prevToken.value === '') { // self closing tag depth--; } } @@ -13545,12 +12956,32 @@ Editor.$uid = 0; do { token = prevToken; prevToken = iterator.stepBackward(); - - if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { - if (prevToken.value === '<') { - depth++; - } else if (prevToken.value === '') { // self closing tag + var stepCount = 0; + var tmpToken = prevToken; + while (tmpToken) { + if (tmpToken.type.indexOf('tag-name') !== -1 && tmpToken.value === tag) { + depth--; + break; + } else if (tmpToken.value === '<') { + break; + } + tmpToken = iterator.stepBackward(); + stepCount++; + } + for (var i = 0; i < stepCount; i++) { + iterator.stepForward(); + } } } } while (prevToken && depth <= 0); @@ -13609,6 +13040,9 @@ Editor.$uid = 0; this.$cursorChange = function() { this.renderer.updateCursor(); + this.$highlightBrackets(); + this.$highlightTags(); + this.$updateHighlightActiveLine(); }; this.onDocumentChange = function(delta) { var wrap = this.session.$useWrapMode; @@ -13617,7 +13051,6 @@ Editor.$uid = 0; this._signal("change", delta); this.$cursorChange(); - this.$updateHighlightActiveLine(); }; this.onTokenizerUpdate = function(e) { @@ -13635,10 +13068,6 @@ Editor.$uid = 0; }; this.onCursorChange = function() { this.$cursorChange(); - - this.$highlightBrackets(); - this.$highlightTags(); - this.$updateHighlightActiveLine(); this._signal("changeSelection"); }; @@ -13777,7 +13206,7 @@ Editor.$uid = 0; } var e = {text: text}; this._signal("copy", e); - clipboard.lineMode = copyLine ? e.text : ""; + clipboard.lineMode = copyLine ? e.text : false; return e.text; }; this.onCopy = function() { @@ -13797,7 +13226,7 @@ Editor.$uid = 0; this._signal("paste", e); var text = e.text; - var lineMode = text == clipboard.lineMode; + var lineMode = text === clipboard.lineMode; var session = this.session; if (!this.inMultiSelectMode || this.inVirtualSelectionMode) { if (lineMode) @@ -13889,16 +13318,62 @@ Editor.$uid = 0; transform.selection[3])); } } + if (this.$enableAutoIndent) { + if (session.getDocument().isNewLine(text)) { + var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString()); - if (session.getDocument().isNewLine(text)) { - var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString()); - - session.insert({row: cursor.row+1, column: 0}, lineIndent); + session.insert({row: cursor.row+1, column: 0}, lineIndent); + } + if (shouldOutdent) + mode.autoOutdent(lineState, session, cursor.row); } - if (shouldOutdent) - mode.autoOutdent(lineState, session, cursor.row); }; + this.autoIndent = function () { + var session = this.session; + var mode = session.getMode(); + + var startRow, endRow; + if (this.selection.isEmpty()) { + startRow = 0; + endRow = session.doc.getLength() - 1; + } else { + var selectedRange = this.getSelectionRange(); + + startRow = selectedRange.start.row; + endRow = selectedRange.end.row; + } + + var prevLineState = ""; + var prevLine = ""; + var lineIndent = ""; + var line, currIndent, range; + var tab = session.getTabString(); + + for (var row = startRow; row <= endRow; row++) { + if (row > 0) { + prevLineState = session.getState(row - 1); + prevLine = session.getLine(row - 1); + lineIndent = mode.getNextLineIndent(prevLineState, prevLine, tab); + } + + line = session.getLine(row); + currIndent = mode.$getIndent(line); + if (lineIndent !== currIndent) { + if (currIndent.length > 0) { + range = new Range(row, 0, row, currIndent.length); + session.remove(range); + } + if (lineIndent.length > 0) { + session.insert({row: row, column: 0}, lineIndent); + } + } + + mode.autoOutdent(prevLineState, session, row); + } + }; + + this.onTextInput = function(text, composition) { if (!composition) return this.keyBinding.onTextInput(text); @@ -13917,6 +13392,10 @@ Editor.$uid = 0; var r = this.selection.getRange(); r.start.column -= composition.extendLeft; r.end.column += composition.extendRight; + if (r.start.column < 0) { + r.start.row--; + r.start.column += this.session.getLine(r.start.row).length + 1; + } this.selection.setRange(r); if (!text && !r.isEmpty()) this.remove(); @@ -14922,13 +14401,21 @@ Editor.$uid = 0; this.renderer.scrollCursorIntoView(null, 0.5); }; this.destroy = function() { + if (this.$toDestroy) { + this.$toDestroy.forEach(function(el) { + el.destroy(); + }); + this.$toDestroy = null; + } + if (this.$mouseHandler) + this.$mouseHandler.destroy(); this.renderer.destroy(); this._signal("destroy", this); if (this.session) this.session.destroy(); if (this._$emitInputEvent) this._$emitInputEvent.cancel(); - this.session = null; + this.removeAllListeners(); }; this.setAutoScrollEditorIntoView = function(enable) { if (!enable) @@ -15044,6 +14531,7 @@ config.defineOptions(Editor.prototype, "editor", { }, behavioursEnabled: {initialValue: true}, wrapBehavioursEnabled: {initialValue: true}, + enableAutoIndent: {initialValue: true}, autoScrollEditorIntoView: { set: function(val) {this.setAutoScrollEditorIntoView(val);} }, @@ -15088,7 +14576,7 @@ config.defineOptions(Editor.prototype, "editor", { set: function(message) { if (!this.$updatePlaceholder) { this.$updatePlaceholder = function() { - var value = this.renderer.$composition || this.getValue(); + var value = this.session && (this.renderer.$composition || this.getValue()); if (value && this.renderer.placeholderNode) { this.renderer.off("afterRender", this.$updatePlaceholder); dom.removeCssClass(this.container, "ace_hasPlaceholder"); @@ -15102,6 +14590,8 @@ config.defineOptions(Editor.prototype, "editor", { el.textContent = this.$placeholder || ""; this.renderer.placeholderNode = el; this.renderer.content.appendChild(this.renderer.placeholderNode); + } else if (!value && this.renderer.placeholderNode) { + this.renderer.placeholderNode.textContent = this.$placeholder || ""; } }.bind(this); this.on("input", this.$updatePlaceholder); @@ -15276,25 +14766,6 @@ var UndoManager = function() { if (to == null) to = this.$rev + 1; }; - - this.validateDeltaBoundaries = function(deltaSet, docLength, invertAction) { - if (!deltaSet) { - return false; - } - return deltaSet.every(function(delta) { - var action = delta.action; - if (invertAction && delta.action === "insert") action = "remove"; - if (invertAction && delta.action === "remove") action = "insert"; - switch(action) { - case "insert": - return delta.start.row <= docLength; - case "remove": - return delta.start.row < docLength && delta.end.row < docLength; - default: - return true; - } - }); - }; this.undo = function(session, dontSelect) { this.lastDeltas = null; var stack = this.$undoStack; @@ -15312,7 +14783,7 @@ var UndoManager = function() { var deltaSet = stack.pop(); var undoSelectionRange = null; - if (this.validateDeltaBoundaries(deltaSet, session.getLength(), true)) { + if (deltaSet) { undoSelectionRange = session.undoChanges(deltaSet, dontSelect); this.$redoStack.push(deltaSet); this.$syncRev(); @@ -15340,7 +14811,7 @@ var UndoManager = function() { var deltaSet = this.$redoStack.pop(); var redoSelectionRange = null; - if (this.validateDeltaBoundaries(deltaSet, session.getLength(), false)) { + if (deltaSet) { redoSelectionRange = session.redoChanges(deltaSet, dontSelect); this.$undoStack.push(deltaSet); this.$syncRev(); @@ -15840,7 +15311,7 @@ var Gutter = function(parentEl) { this.setSession = function(session) { if (this.session) - this.session.removeEventListener("change", this.$updateAnnotations); + this.session.off("change", this.$updateAnnotations); this.session = session; if (session) session.on("change", this.$updateAnnotations); @@ -16529,11 +16000,21 @@ var Text = function(parentEl) { }; this.showInvisibles = false; + this.showSpaces = false; + this.showTabs = false; + this.showEOL = false; this.setShowInvisibles = function(showInvisibles) { if (this.showInvisibles == showInvisibles) return false; this.showInvisibles = showInvisibles; + if (typeof showInvisibles == "string") { + this.showSpaces = /tab/i.test(showInvisibles); + this.showTabs = /space/i.test(showInvisibles); + this.showEOL = /eol/i.test(showInvisibles); + } else { + this.showSpaces = this.showTabs = this.showEOL = showInvisibles; + } this.$computeTabString(); return true; }; @@ -16555,7 +16036,7 @@ var Text = function(parentEl) { this.tabSize = tabSize; var tabStr = this.$tabStrings = [0]; for (var i = 1; i < tabSize + 1; i++) { - if (this.showInvisibles) { + if (this.showTabs) { var span = this.dom.createElement("span"); span.className = "ace_invisible ace_invisible_tab"; span.textContent = lang.stringRepeat(this.TAB_CHAR, i); @@ -16567,18 +16048,15 @@ var Text = function(parentEl) { if (this.displayIndentGuides) { this.$indentGuideRe = /\s\S| \t|\t |\s$/; var className = "ace_indent-guide"; - var spaceClass = ""; - var tabClass = ""; - if (this.showInvisibles) { - className += " ace_invisible"; - spaceClass = " ace_invisible_space"; - tabClass = " ace_invisible_tab"; - var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); - var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); - } else { - var spaceContent = lang.stringRepeat(" ", this.tabSize); - var tabContent = spaceContent; - } + var spaceClass = this.showSpaces ? " ace_invisible ace_invisible_space" : ""; + var spaceContent = this.showSpaces + ? lang.stringRepeat(this.SPACE_CHAR, this.tabSize) + : lang.stringRepeat(" ", this.tabSize); + + var tabClass = this.showTabs ? " ace_invisible ace_invisible_tab" : ""; + var tabContent = this.showTabs + ? lang.stringRepeat(this.TAB_CHAR, this.tabSize) + : spaceContent; var span = this.dom.createElement("span"); span.className = className + spaceClass; @@ -16771,7 +16249,7 @@ var Text = function(parentEl) { var cjkSpace = m[4]; var cjk = m[5]; - if (!self.showInvisibles && simpleSpace) + if (!self.showSpaces && simpleSpace) continue; var before = i != m.index ? value.slice(i, m.index) : ""; @@ -16787,7 +16265,7 @@ var Text = function(parentEl) { valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); screenColumn += tabSize - 1; } else if (simpleSpace) { - if (self.showInvisibles) { + if (self.showSpaces) { var span = this.dom.createElement("span"); span.className = "ace_invisible ace_invisible_space"; span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); @@ -16805,8 +16283,8 @@ var Text = function(parentEl) { var span = this.dom.createElement("span"); span.style.width = (self.config.characterWidth * 2) + "px"; - span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; - span.textContent = self.showInvisibles ? self.SPACE_CHAR : cjkSpace; + span.className = self.showSpaces ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + span.textContent = self.showSpaces ? self.SPACE_CHAR : cjkSpace; valueFragment.appendChild(span); } else if (cjk) { screenColumn += 1; @@ -16975,7 +16453,7 @@ var Text = function(parentEl) { parent.appendChild(lastLineEl); } - if (this.showInvisibles && lastLineEl) { + if (this.showEOL && lastLineEl) { if (foldLine) row = foldLine.end.row; @@ -17092,12 +16570,16 @@ var Cursor = function(parentEl) { for (var i = cursors.length; i--; ) cursors[i].style.animationDuration = this.blinkInterval + "ms"; + this.$isAnimating = true; setTimeout(function() { - dom.addCssClass(this.element, "ace_animate-blinking"); + if (this.$isAnimating) { + dom.addCssClass(this.element, "ace_animate-blinking"); + } }.bind(this)); }; this.$stopCssAnimation = function() { + this.$isAnimating = false; dom.removeCssClass(this.element, "ace_animate-blinking"); }; @@ -17168,6 +16650,7 @@ var Cursor = function(parentEl) { this.$stopCssAnimation(); if (this.smoothBlinking) { + this.$isSmoothBlinking = false; dom.removeCssClass(this.element, "ace_smooth-blinking"); } @@ -17179,8 +16662,11 @@ var Cursor = function(parentEl) { } if (this.smoothBlinking) { - setTimeout(function(){ - dom.addCssClass(this.element, "ace_smooth-blinking"); + this.$isSmoothBlinking = true; + setTimeout(function() { + if (this.$isSmoothBlinking) { + dom.addCssClass(this.element, "ace_smooth-blinking"); + } }.bind(this)); } @@ -17506,7 +16992,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { this.el.appendChild(this.$measureNode); parentEl.appendChild(this.el); - this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT); + this.$measureNode.textContent = lang.stringRepeat("X", CHAR_COUNT); this.$characterSize = {width: 0, height: 0}; @@ -17555,11 +17041,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { this.$addObserver = function() { var self = this; this.$observer = new window.ResizeObserver(function(e) { - var rect = e[0].contentRect; - self.checkForSizeChanges({ - height: rect.height, - width: rect.width / CHAR_COUNT - }); + self.checkForSizeChanges(); }); this.$observer.observe(this.$measureNode); }; @@ -17595,7 +17077,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { }; this.$measureCharWidth = function(ch) { - this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT); + this.$main.textContent = lang.stringRepeat(ch, CHAR_COUNT); var rect = this.$main.getBoundingClientRect(); return rect.width / CHAR_COUNT; }; @@ -17618,7 +17100,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { this.$getZoom = function getZoom(element) { - if (!element) return 1; + if (!element || !element.parentElement) return 1; return (window.getComputedStyle(element).zoom || 1) * getZoom(element.parentElement); }; this.$initTransformMeasureNodes = function() { @@ -17712,6 +17194,7 @@ var editorCss = "\ .ace_editor {\ position: relative;\ overflow: hidden;\ +padding: 0;\ font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\ direction: ltr;\ text-align: left;\ @@ -18184,7 +17667,7 @@ margin: 0 10px;\ var useragent = require("./lib/useragent"); var HIDE_TEXTAREA = useragent.isIE; -dom.importCssString(editorCss, "ace_editor.css"); +dom.importCssString(editorCss, "ace_editor.css", false); var VirtualRenderer = function(container, theme) { var _self = this; @@ -18195,6 +17678,8 @@ var VirtualRenderer = function(container, theme) { if (dom.HI_DPI) dom.addCssClass(this.container, "ace_hidpi"); this.setTheme(theme); + if (config.get("useStrictCSP") == null) + config.set("useStrictCSP", false); this.$gutter = dom.createElement("div"); this.$gutter.className = "ace_gutter"; @@ -18227,11 +17712,11 @@ var VirtualRenderer = function(container, theme) { this.scrollBar = this.scrollBarV = new VScrollBar(this.container, this); this.scrollBarH = new HScrollBar(this.container, this); - this.scrollBarV.addEventListener("scroll", function(e) { + this.scrollBarV.on("scroll", function(e) { if (!_self.$scrollAnimation) _self.session.setScrollTop(e.data - _self.scrollMargin.top); }); - this.scrollBarH.addEventListener("scroll", function(e) { + this.scrollBarH.on("scroll", function(e) { if (!_self.$scrollAnimation) _self.session.setScrollLeft(e.data - _self.scrollMargin.left); }); @@ -18246,7 +17731,7 @@ var VirtualRenderer = function(container, theme) { this.$fontMetrics = new FontMetrics(this.container); this.$textLayer.$setFontMetrics(this.$fontMetrics); - this.$textLayer.addEventListener("changeCharacterSize", function(e) { + this.$textLayer.on("changeCharacterSize", function(e) { _self.updateCharacterSize(); _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height); _self._signal("changeCharacterSize", e); @@ -18446,7 +17931,7 @@ var VirtualRenderer = function(container, theme) { if (this.resizing) this.resizing = 0; - this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null; + this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; }; this.$updateCachedSize = function(force, gutterWidth, width, height) { @@ -19183,6 +18668,8 @@ var VirtualRenderer = function(container, theme) { _self.session.setScrollTop(steps.shift()); _self.session.$scrollTop = toValue; this.$timer = setInterval(function() { + if (!_self.session) + return clearInterval(_self.$timer); if (steps.length) { _self.session.setScrollTop(steps.shift()); _self.session.$scrollTop = toValue; @@ -19210,7 +18697,7 @@ var VirtualRenderer = function(container, theme) { }; this.scrollTo = function(x, y) { this.session.setScrollTop(y); - this.session.setScrollLeft(y); + this.session.setScrollLeft(x); }; this.scrollBy = function(deltaX, deltaY) { deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY); @@ -19293,7 +18780,8 @@ var VirtualRenderer = function(container, theme) { if (!composition.cssText) { composition.cssText = this.textarea.style.cssText; } - composition.useTextareaForIME = this.$useTextareaForIME; + if (composition.useTextareaForIME == undefined) + composition.useTextareaForIME = this.$useTextareaForIME; if (this.$useTextareaForIME) { dom.addCssClass(this.textarea, "ace_composition"); @@ -19319,6 +18807,8 @@ var VirtualRenderer = function(container, theme) { dom.removeCssClass(this.textarea, "ace_composition"); this.textarea.style.cssText = this.$composition.cssText; + var cursor = this.session.selection.cursor; + this.removeExtraToken(cursor.row, cursor.column); this.$composition = null; this.$cursorLayer.element.style.display = ""; }; @@ -19347,6 +18837,10 @@ var VirtualRenderer = function(container, theme) { } this.updateLines(row, row); }; + + this.removeExtraToken = function(row, column) { + this.updateLines(row, row); + }; this.setTheme = function(theme, cb) { var _self = this; this.$themeId = theme; @@ -19417,6 +18911,8 @@ var VirtualRenderer = function(container, theme) { this.freeze(); this.$fontMetrics.destroy(); this.$cursorLayer.destroy(); + this.removeAllListeners(); + this.container.textContent = ""; }; }).call(VirtualRenderer.prototype); @@ -19943,8 +19439,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) this.detach = function() { this.session.removeMarker(this.pos && this.pos.markerId); this.hideOtherMarkers(); - this.doc.removeEventListener("change", this.$onUpdate); - this.session.selection.removeEventListener("changeCursor", this.$onCursorChange); + this.doc.off("change", this.$onUpdate); + this.session.selection.off("changeCursor", this.$onCursorChange); this.session.setUndoSelect(true); this.session = null; }; @@ -20998,10 +20494,10 @@ function addAltCursorListeners(editor){ } else if (altCursor) { reset(); } - }); + }, editor); - event.addListener(el, "keyup", reset); - event.addListener(el, "blur", reset); + event.addListener(el, "keyup", reset, editor); + event.addListener(el, "blur", reset, editor); function reset(e) { if (altCursor) { editor.renderer.setMouseCursor(""); @@ -21259,7 +20755,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ exports.$id = "ace/theme/textmate"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); define("ace/line_widgets",["require","exports","module","ace/lib/dom"], function(require, exports, module) { @@ -21806,7 +21302,7 @@ dom.importCssString("\ border-left-color: transparent!important;\ top: -5px;\ }\ -", ""); +", "error_marker.css", false); }); diff --git a/htdocs/includes/ace/src/ext-beautify.js b/htdocs/includes/ace/src/ext-beautify.js index a39074326a2..674cf671131 100644 --- a/htdocs/includes/ace/src/ext-beautify.js +++ b/htdocs/includes/ace/src/ext-beautify.js @@ -40,16 +40,28 @@ exports.beautify = function(session) { var inBlock = false; var levels = {0: 0}; var parents = []; + var caseBody = false; var trimNext = function() { if (nextToken && nextToken.value && nextToken.type !== 'string.regexp') - nextToken.value = nextToken.value.trim(); + nextToken.value = nextToken.value.replace(/^\s*/, ""); }; - + var trimLine = function() { - code = code.replace(/ +$/, ""); - }; + var end = code.length - 1; + while (true) { + if (end == 0) + break; + if (code[end] !== " ") + break; + + end = end - 1; + } + + code = code.slice(0, end + 1); + }; + var trimCode = function() { code = code.trimRight(); breakBefore = false; @@ -201,8 +213,11 @@ exports.beautify = function(session) { trimLine(); if(value === "/>") spaceBefore = true; + } else if (token.type === "keyword" && value.match(/^(case|default)$/)) { + if (caseBody) + unindent = 1; } - if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['"]$/))) { + if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['"@]$/))) { indent = lastIndent; @@ -229,16 +244,16 @@ exports.beautify = function(session) { code += tabString; } - if (token.type === "keyword" && value.match(/^(case|default)$/)) { - parents[depth] = value; - depth++; - } - - - if (token.type === "keyword" && value.match(/^(break)$/)) { + if (caseBody === false) { + parents[depth] = value; + depth++; + caseBody = true; + } + } else if (token.type === "keyword" && value.match(/^(break)$/)) { if(parents[depth-1] && parents[depth-1].match(/^(case|default)$/)) { depth--; + caseBody = false; } } if (token.type === "paren.lparen") { @@ -264,6 +279,9 @@ exports.beautify = function(session) { } } } + + if (token.type == "text") + value = value.replace(/\s+$/, " "); if (spaceBefore && !breakBefore) { trimLine(); if (code.substr(-1) !== "\n") diff --git a/htdocs/includes/ace/src/ext-code_lens.js b/htdocs/includes/ace/src/ext-code_lens.js index 4b7e4340f22..ee4653d8595 100644 --- a/htdocs/includes/ace/src/ext-code_lens.js +++ b/htdocs/includes/ace/src/ext-code_lens.js @@ -1,6 +1,7 @@ -define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"], function(require, exports, module) { +define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"], function(require, exports, module) { "use strict"; var LineWidgets = require("../line_widgets").LineWidgets; +var event = require("../lib/event"); var lang = require("../lib/lang"); var dom = require("../lib/dom"); @@ -120,12 +121,14 @@ exports.setLenses = function(session, lenses) { function attachToEditor(editor) { editor.codeLensProviders = []; editor.renderer.on("afterRender", renderWidgets); - editor.$codeLensClickHandler = function(e) { - var command = e.target.lensCommand; - if (command) - editor.execCommand(command.id, command.arguments); - }; - editor.container.addEventListener("click", editor.$codeLensClickHandler); + if (!editor.$codeLensClickHandler) { + editor.$codeLensClickHandler = function(e) { + var command = e.target.lensCommand; + if (command) + editor.execCommand(command.id, command.arguments); + }; + event.addListener(editor.container, "click", editor.$codeLensClickHandler, editor); + } editor.$updateLenses = function() { var session = editor.session; if (!session) return; @@ -138,8 +141,9 @@ function attachToEditor(editor) { var providersToWaitNum = editor.codeLensProviders.length; var lenses = []; editor.codeLensProviders.forEach(function(provider) { - provider.provideCodeLenses(session, function(currentLenses) { - currentLenses.forEach(function(lens) { + provider.provideCodeLenses(session, function(err, payload) { + if (err) return; + payload.forEach(function(lens) { lenses.push(lens); }); providersToWaitNum--; @@ -222,7 +226,7 @@ dom.importCssString("\ .ace_dark > .ace_codeLens > a:hover {\ color: #4e94ce;\ }\ -", ""); +", "codelense.css", false); }); (function() { window.require(["ace/ext/code_lens"], function(m) { diff --git a/htdocs/includes/ace/src/ext-emmet.js b/htdocs/includes/ace/src/ext-emmet.js index 3cb3818d1b5..68fc0ff1367 100644 --- a/htdocs/includes/ace/src/ext-emmet.js +++ b/htdocs/includes/ace/src/ext-emmet.js @@ -1,5 +1,6 @@ -define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/lib/dom","ace/editor"], function(require, exports, module) { +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module) { "use strict"; +var dom = require("./lib/dom"); var oop = require("./lib/oop"); var EventEmitter = require("./lib/event_emitter").EventEmitter; var lang = require("./lib/lang"); @@ -144,7 +145,9 @@ var SnippetManager = function() { {regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) { var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function(operator) { return operator.length == 2 ? operator[1] : "\x00"; - }).split("\x00"); + }).split("\x00").map(function(value){ + return {value: value}; + }); stack[0].choices = choices; return [choices[0]]; }, next: "start"}, @@ -615,6 +618,12 @@ var SnippetManager = function() { } snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { if (!s.guard && /^\w/.test(s.tabTrigger)) s.guard = "\\b"; @@ -631,10 +640,13 @@ var SnippetManager = function() { s.endTriggerRe = new RegExp(s.endTrigger); } - if (snippets && snippets.content) - addSnippet(snippets); - else if (Array.isArray(snippets)) + if (Array.isArray(snippets)) { snippets.forEach(addSnippet); + } else { + Object.keys(snippets).forEach(function(key) { + addSnippet(snippets[key]); + }); + } this._signal("registerSnippets", {scope: scope}); }; @@ -684,7 +696,7 @@ var SnippetManager = function() { snippet.tabTrigger = val.match(/^\S*/)[0]; if (!snippet.name) snippet.name = val; - } else { + } else if (key) { snippet[key] = val; } } @@ -833,18 +845,17 @@ var TabstopManager = function(editor) { this.selectedTabstop = ts; var range = ts.firstNonLinked || ts; + if (ts.choices) range.cursor = range.start; if (!this.editor.inVirtualSelectionMode) { var sel = this.editor.multiSelect; - sel.toSingleRange(range.clone()); + sel.toSingleRange(range); for (var i = 0; i < ts.length; i++) { if (ts.hasLinkedRanges && ts[i].linked) continue; sel.addRange(ts[i].clone(), true); } - if (sel.ranges[0]) - sel.addRange(sel.ranges[0].clone()); } else { - this.editor.selection.setRange(range); + this.editor.selection.fromOrientedRange(range); } this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); @@ -971,14 +982,14 @@ var moveRelative = function(point, start) { }; -require("./lib/dom").importCssString("\ +dom.importCssString("\ .ace_snippet-marker {\ -moz-box-sizing: border-box;\ box-sizing: border-box;\ background: rgba(194, 193, 208, 0.09);\ border: 1px dotted rgba(211, 208, 235, 0.62);\ position: absolute;\ -}"); +}", "snippets.css", false); exports.snippetManager = new SnippetManager(); diff --git a/htdocs/includes/ace/src/ext-hardwrap.js b/htdocs/includes/ace/src/ext-hardwrap.js new file mode 100644 index 00000000000..a2037b9113e --- /dev/null +++ b/htdocs/includes/ace/src/ext-hardwrap.js @@ -0,0 +1,125 @@ +define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"], function(require, exports, module) { +"use strict"; + +var Range = require("../range").Range; + +function hardWrap(editor, options) { + var max = options.column || editor.getOption("printMarginColumn"); + var allowMerge = options.allowMerge != false; + + var row = Math.min(options.startRow, options.endRow); + var endRow = Math.max(options.startRow, options.endRow); + + var session = editor.session; + + while (row <= endRow) { + var line = session.getLine(row); + if (line.length > max) { + var space = findSpace(line, max, 5); + if (space) { + var indentation = /^\s*/.exec(line)[0]; + session.replace(new Range(row,space.start,row,space.end), "\n" + indentation); + } + endRow++; + } else if (allowMerge && /\S/.test(line) && row != endRow) { + var nextLine = session.getLine(row + 1); + if (nextLine && /\S/.test(nextLine)) { + var trimmedLine = line.replace(/\s+$/, ""); + var trimmedNextLine = nextLine.replace(/^\s+/, ""); + var mergedLine = trimmedLine + " " + trimmedNextLine; + + var space = findSpace(mergedLine, max, 5); + if (space && space.start > trimmedLine.length || mergedLine.length < max) { + var replaceRange = new Range(row,trimmedLine.length,row + 1,nextLine.length - trimmedNextLine.length); + session.replace(replaceRange, " "); + row--; + endRow--; + } else if (trimmedLine.length < line.length) { + session.remove(new Range(row, trimmedLine.length, row, line.length)); + } + } + } + row++; + } + + function findSpace(line, max, min) { + if (line.length < max) + return; + var before = line.slice(0, max); + var after = line.slice(max); + var spaceAfter = /^(?:(\s+)|(\S+)(\s+))/.exec(after); + var spaceBefore = /(?:(\s+)|(\s+)(\S+))$/.exec(before); + var start = 0; + var end = 0; + if (spaceBefore && !spaceBefore[2]) { + start = max - spaceBefore[1].length; + end = max; + } + if (spaceAfter && !spaceAfter[2]) { + if (!start) + start = max; + end = max + spaceAfter[1].length; + } + if (start) { + return { + start: start, + end: end + }; + } + if (spaceBefore && spaceBefore[2] && spaceBefore.index > min) { + return { + start: spaceBefore.index, + end: spaceBefore.index + spaceBefore[2].length + }; + } + if (spaceAfter && spaceAfter[2]) { + start = max + spaceAfter[2].length; + return { + start: start, + end: start + spaceAfter[3].length + }; + } + } + +} + +function wrapAfterInput(e) { + if (e.command.name == "insertstring" && /\S/.test(e.args)) { + var editor = e.editor; + var cursor = editor.selection.cursor; + if (cursor.column <= editor.renderer.$printMarginColumn) return; + var lastDelta = editor.session.$undoManager.$lastDelta; + + hardWrap(editor, { + startRow: cursor.row, endRow: cursor.row, + allowMerge: false + }); + if (lastDelta != editor.session.$undoManager.$lastDelta) + editor.session.markUndoGroup(); + } +} + +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + hardWrap: { + set: function(val) { + if (val) { + this.commands.on("afterExec", wrapAfterInput); + } else { + this.commands.off("afterExec", wrapAfterInput); + } + }, + value: false + } +}); + +exports.hardWrap = hardWrap; + +}); (function() { + window.require(["ace/ext/hardwrap"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/ext-keybinding_menu.js b/htdocs/includes/ace/src/ext-keybinding_menu.js index 4f980686e68..b9ad46ee724 100644 --- a/htdocs/includes/ace/src/ext-keybinding_menu.js +++ b/htdocs/includes/ace/src/ext-keybinding_menu.js @@ -61,7 +61,7 @@ margin: 0px;\ .ace_optionsMenuEntry button:hover{\ background: #f0f0f0;\ }"; -dom.importCssString(cssText); +dom.importCssString(cssText, "settings_menu.css", false); module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { var closer = document.createElement('div'); diff --git a/htdocs/includes/ace/src/ext-language_tools.js b/htdocs/includes/ace/src/ext-language_tools.js index 7e6967e0d7a..b561c3bc87d 100644 --- a/htdocs/includes/ace/src/ext-language_tools.js +++ b/htdocs/includes/ace/src/ext-language_tools.js @@ -1,5 +1,6 @@ -define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/lib/dom","ace/editor"], function(require, exports, module) { +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module) { "use strict"; +var dom = require("./lib/dom"); var oop = require("./lib/oop"); var EventEmitter = require("./lib/event_emitter").EventEmitter; var lang = require("./lib/lang"); @@ -144,7 +145,9 @@ var SnippetManager = function() { {regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) { var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function(operator) { return operator.length == 2 ? operator[1] : "\x00"; - }).split("\x00"); + }).split("\x00").map(function(value){ + return {value: value}; + }); stack[0].choices = choices; return [choices[0]]; }, next: "start"}, @@ -615,6 +618,12 @@ var SnippetManager = function() { } snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { if (!s.guard && /^\w/.test(s.tabTrigger)) s.guard = "\\b"; @@ -631,10 +640,13 @@ var SnippetManager = function() { s.endTriggerRe = new RegExp(s.endTrigger); } - if (snippets && snippets.content) - addSnippet(snippets); - else if (Array.isArray(snippets)) + if (Array.isArray(snippets)) { snippets.forEach(addSnippet); + } else { + Object.keys(snippets).forEach(function(key) { + addSnippet(snippets[key]); + }); + } this._signal("registerSnippets", {scope: scope}); }; @@ -684,7 +696,7 @@ var SnippetManager = function() { snippet.tabTrigger = val.match(/^\S*/)[0]; if (!snippet.name) snippet.name = val; - } else { + } else if (key) { snippet[key] = val; } } @@ -833,18 +845,17 @@ var TabstopManager = function(editor) { this.selectedTabstop = ts; var range = ts.firstNonLinked || ts; + if (ts.choices) range.cursor = range.start; if (!this.editor.inVirtualSelectionMode) { var sel = this.editor.multiSelect; - sel.toSingleRange(range.clone()); + sel.toSingleRange(range); for (var i = 0; i < ts.length; i++) { if (ts.hasLinkedRanges && ts[i].linked) continue; sel.addRange(ts[i].clone(), true); } - if (sel.ranges[0]) - sel.addRange(sel.ranges[0].clone()); } else { - this.editor.selection.setRange(range); + this.editor.selection.fromOrientedRange(range); } this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); @@ -971,14 +982,14 @@ var moveRelative = function(point, start) { }; -require("./lib/dom").importCssString("\ +dom.importCssString("\ .ace_snippet-marker {\ -moz-box-sizing: border-box;\ box-sizing: border-box;\ background: rgba(194, 193, 208, 0.09);\ border: 1px dotted rgba(211, 208, 235, 0.62);\ position: absolute;\ -}"); +}", "snippets.css", false); exports.snippetManager = new SnippetManager(); @@ -1330,7 +1341,7 @@ dom.importCssString("\ line-height: 1.4;\ background: #25282c;\ color: #c1c1c1;\ -}", "autocompletion.css"); +}", "autocompletion.css", false); exports.AcePopup = AcePopup; exports.$singleLineEditor = $singleLineEditor; @@ -1476,6 +1487,7 @@ var Autocomplete = function() { } else if (keepPopupPosition && !prefix) { this.detach(); } + this.changeTimer.cancel(); }; this.detach = function() { @@ -1538,13 +1550,15 @@ var Autocomplete = function() { if (!data) return false; + var completions = this.completions; + this.editor.startOperation({command: {name: "insertMatch"}}); if (data.completer && data.completer.insertMatch) { data.completer.insertMatch(this.editor, data); } else { - if (this.completions.filterText) { + if (completions.filterText) { var ranges = this.editor.selection.getAllRanges(); for (var i = 0, range; range = ranges[i]; i++) { - range.start.column -= this.completions.filterText.length; + range.start.column -= completions.filterText.length; this.editor.session.remove(range); } } @@ -1553,7 +1567,9 @@ var Autocomplete = function() { else this.editor.execCommand("insertstring", data.value || data); } - this.detach(); + if (this.completions == completions) + this.detach(); + this.editor.endOperation(); }; @@ -1649,19 +1665,14 @@ var Autocomplete = function() { return this.openPopup(this.editor, "", keepPopupPosition); } var _id = this.gatherCompletionsId; - this.gatherCompletions(this.editor, function(err, results) { - var detachIfFinished = function() { - if (!results.finished) return; - return this.detach(); - }.bind(this); + var detachIfFinished = function(results) { + if (!results.finished) return; + return this.detach(); + }.bind(this); + var processResults = function(results) { var prefix = results.prefix; - var matches = results && results.matches; - - if (!matches || !matches.length) - return detachIfFinished(); - if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) - return; + var matches = results.matches; this.completions = new FilteredList(matches); @@ -1671,14 +1682,39 @@ var Autocomplete = function() { this.completions.setFilter(prefix); var filtered = this.completions.filtered; if (!filtered.length) - return detachIfFinished(); + return detachIfFinished(results); if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) - return detachIfFinished(); + return detachIfFinished(results); if (this.autoInsert && filtered.length == 1 && results.finished) return this.insertMatch(filtered[0]); this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this); + + var isImmediate = true; + var immediateResults = null; + this.gatherCompletions(this.editor, function(err, results) { + var prefix = results.prefix; + var matches = results && results.matches; + + if (!matches || !matches.length) + return detachIfFinished(results); + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + if (isImmediate) { + immediateResults = results; + return; + } + + processResults(results); }.bind(this)); + + isImmediate = false; + if (immediateResults) { + var results = immediateResults; + immediateResults = null; + processResults(results); + } }; this.cancelContextMenu = function() { @@ -2032,31 +2068,33 @@ var onChangeMode = function(e, editor) { }; var loadSnippetsForMode = function(mode) { - var id = mode.$id; + if (typeof mode == "string") + mode = config.$modes[mode]; + if (!mode) + return; if (!snippetManager.files) snippetManager.files = {}; - loadSnippetFile(id); + + loadSnippetFile(mode.$id, mode.snippetFileId); if (mode.modes) mode.modes.forEach(loadSnippetsForMode); }; -var loadSnippetFile = function(id) { - if (!id || snippetManager.files[id]) +var loadSnippetFile = function(id, snippetFilePath) { + if (!snippetFilePath || !id || snippetManager.files[id]) return; - var snippetFilePath = id.replace("mode", "snippets"); snippetManager.files[id] = {}; config.loadModule(snippetFilePath, function(m) { - if (m) { - snippetManager.files[id] = m; - if (!m.snippets && m.snippetText) - m.snippets = snippetManager.parseSnippetFile(m.snippetText); - snippetManager.register(m.snippets || [], m.scope); - if (m.includeScopes) { - snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes; - m.includeScopes.forEach(function(x) { - loadSnippetFile("ace/mode/" + x); - }); - } + if (!m) return; + snippetManager.files[id] = m; + if (!m.snippets && m.snippetText) + m.snippets = snippetManager.parseSnippetFile(m.snippetText); + snippetManager.register(m.snippets || [], m.scope); + if (m.includeScopes) { + snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes; + m.includeScopes.forEach(function(x) { + loadSnippetsForMode("ace/mode/" + x); + }); } }); }; diff --git a/htdocs/includes/ace/src/ext-modelist.js b/htdocs/includes/ace/src/ext-modelist.js index 8b771ffeb99..064e398db75 100644 --- a/htdocs/includes/ace/src/ext-modelist.js +++ b/htdocs/includes/ace/src/ext-modelist.js @@ -39,22 +39,23 @@ var supportedModes = { ABC: ["abc"], ActionScript:["as"], ADA: ["ada|adb"], + Alda: ["alda"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], - AsciiDoc: ["asciidoc|adoc"], - ASL: ["dsl|asl"], - Assembly_x86:["asm|a"], - AutoHotKey: ["ahk"], Apex: ["apex|cls|trigger|tgr"], AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86:["asm|a"], + AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], C9Search: ["c9search_results"], - Crystal: ["cr"], Cirru: ["cirru|cr"], Clojure: ["clj|cljs"], Cobol: ["CBL|COB"], coffee: ["coffee|cf|cson|^Cakefile"], ColdFusion: ["cfm"], + Crystal: ["cr"], CSharp: ["cs"], Csound_Document: ["csd"], Csound_Orchestra: ["orc"], @@ -101,8 +102,8 @@ var supportedModes = { Jade: ["jade|pug"], Java: ["java"], JavaScript: ["js|jsm|jsx"], - JSON5: ["json5"], JSON: ["json"], + JSON5: ["json5"], JSONiq: ["jq"], JSP: ["jsp"], JSSM: ["jssm|jssm_state"], @@ -110,6 +111,7 @@ var supportedModes = { Julia: ["jl"], Kotlin: ["kt|kts"], LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], LESS: ["less"], Liquid: ["liquid"], Lisp: ["lisp"], @@ -124,32 +126,36 @@ var supportedModes = { Mask: ["mask"], MATLAB: ["matlab"], Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], MEL: ["mel"], + MIPS: ["s|asm"], MIXAL: ["mixal"], MUSHCode: ["mc|mush"], MySQL: ["mysql"], Nginx: ["nginx|conf"], - Nix: ["nix"], Nim: ["nim"], + Nix: ["nix"], NSIS: ["nsi|nsh"], Nunjucks: ["nunjucks|nunjs|nj|njk"], ObjectiveC: ["m|mm"], OCaml: ["ml|mli"], Pascal: ["pas|p"], Perl: ["pl|pm"], - Perl6: ["p6|pl6|pm6"], pgSQL: ["pgsql"], - PHP_Laravel_blade: ["blade.php"], PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], - Puppet: ["epp|pp"], + PHP_Laravel_blade: ["blade.php"], Pig: ["pig"], Powershell: ["ps1"], Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], Prolog: ["plg|prolog"], Properties: ["properties"], Protobuf: ["proto"], + Puppet: ["epp|pp"], Python: ["py"], + QML: ["qml"], R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], Razor: ["cshtml|asp"], RDoc: ["Rd"], Red: ["red|reds"], @@ -161,11 +167,13 @@ var supportedModes = { SCAD: ["scad"], Scala: ["scala|sbt"], Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], SCSS: ["scss"], SH: ["sh|bash|^.bashrc"], SJS: ["sjs"], Slim: ["slim|skim"], Smarty: ["smarty|tpl"], + Smithy: ["smithy"], snippets: ["snippets"], Soy_Template:["soy"], Space: ["space"], @@ -181,7 +189,7 @@ var supportedModes = { Textile: ["textile"], Toml: ["toml"], TSX: ["tsx"], - Twig: ["latte|twig|swig"], + Twig: ["twig|swig"], Typescript: ["ts|typescript|str"], Vala: ["vala"], VBScript: ["vbs|vb"], @@ -213,6 +221,7 @@ var nameOverrides = { Perl6: "Perl 6", AutoHotKey: "AutoHotkey / AutoIt" }; + var modesByName = {}; for (var name in supportedModes) { var data = supportedModes[name]; diff --git a/htdocs/includes/ace/src/ext-options.js b/htdocs/includes/ace/src/ext-options.js index d1d01cefa05..d200e821a3e 100644 --- a/htdocs/includes/ace/src/ext-options.js +++ b/htdocs/includes/ace/src/ext-options.js @@ -61,7 +61,7 @@ margin: 0px;\ .ace_optionsMenuEntry button:hover{\ background: #f0f0f0;\ }"; -dom.importCssString(cssText); +dom.importCssString(cssText, "settings_menu.css", false); module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { var closer = document.createElement('div'); @@ -160,22 +160,23 @@ var supportedModes = { ABC: ["abc"], ActionScript:["as"], ADA: ["ada|adb"], + Alda: ["alda"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], - AsciiDoc: ["asciidoc|adoc"], - ASL: ["dsl|asl"], - Assembly_x86:["asm|a"], - AutoHotKey: ["ahk"], Apex: ["apex|cls|trigger|tgr"], AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86:["asm|a"], + AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], C9Search: ["c9search_results"], - Crystal: ["cr"], Cirru: ["cirru|cr"], Clojure: ["clj|cljs"], Cobol: ["CBL|COB"], coffee: ["coffee|cf|cson|^Cakefile"], ColdFusion: ["cfm"], + Crystal: ["cr"], CSharp: ["cs"], Csound_Document: ["csd"], Csound_Orchestra: ["orc"], @@ -222,8 +223,8 @@ var supportedModes = { Jade: ["jade|pug"], Java: ["java"], JavaScript: ["js|jsm|jsx"], - JSON5: ["json5"], JSON: ["json"], + JSON5: ["json5"], JSONiq: ["jq"], JSP: ["jsp"], JSSM: ["jssm|jssm_state"], @@ -231,6 +232,7 @@ var supportedModes = { Julia: ["jl"], Kotlin: ["kt|kts"], LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], LESS: ["less"], Liquid: ["liquid"], Lisp: ["lisp"], @@ -245,32 +247,36 @@ var supportedModes = { Mask: ["mask"], MATLAB: ["matlab"], Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], MEL: ["mel"], + MIPS: ["s|asm"], MIXAL: ["mixal"], MUSHCode: ["mc|mush"], MySQL: ["mysql"], Nginx: ["nginx|conf"], - Nix: ["nix"], Nim: ["nim"], + Nix: ["nix"], NSIS: ["nsi|nsh"], Nunjucks: ["nunjucks|nunjs|nj|njk"], ObjectiveC: ["m|mm"], OCaml: ["ml|mli"], Pascal: ["pas|p"], Perl: ["pl|pm"], - Perl6: ["p6|pl6|pm6"], pgSQL: ["pgsql"], - PHP_Laravel_blade: ["blade.php"], PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], - Puppet: ["epp|pp"], + PHP_Laravel_blade: ["blade.php"], Pig: ["pig"], Powershell: ["ps1"], Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], Prolog: ["plg|prolog"], Properties: ["properties"], Protobuf: ["proto"], + Puppet: ["epp|pp"], Python: ["py"], + QML: ["qml"], R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], Razor: ["cshtml|asp"], RDoc: ["Rd"], Red: ["red|reds"], @@ -282,11 +288,13 @@ var supportedModes = { SCAD: ["scad"], Scala: ["scala|sbt"], Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], SCSS: ["scss"], SH: ["sh|bash|^.bashrc"], SJS: ["sjs"], Slim: ["slim|skim"], Smarty: ["smarty|tpl"], + Smithy: ["smithy"], snippets: ["snippets"], Soy_Template:["soy"], Space: ["space"], @@ -302,7 +310,7 @@ var supportedModes = { Textile: ["textile"], Toml: ["toml"], TSX: ["tsx"], - Twig: ["latte|twig|swig"], + Twig: ["twig|swig"], Typescript: ["ts|typescript|str"], Vala: ["vala"], VBScript: ["vbs|vb"], @@ -334,6 +342,7 @@ var nameOverrides = { Perl6: "Perl 6", AutoHotKey: "AutoHotkey / AutoIt" }; + var modesByName = {}; for (var name in supportedModes) { var data = supportedModes[name]; @@ -367,7 +376,7 @@ var themeData = [ ["Solarized Light"], ["TextMate" ], ["Tomorrow" ], - ["XCode" ], + ["Xcode" ], ["Kuroir"], ["KatzenMilch"], ["SQL Server" ,"sqlserver" , "light"], @@ -384,6 +393,8 @@ var themeData = [ ["Merbivore Soft" ,"merbivore_soft" , "dark"], ["Mono Industrial" ,"mono_industrial" , "dark"], ["Monokai" ,"monokai" , "dark"], + ["Nord Dark" ,"nord_dark" , "dark"], + ["One Dark" ,"one_dark" , "dark"], ["Pastel on dark" ,"pastel_on_dark" , "dark"], ["Solarized Dark" ,"solarized_dark" , "dark"], ["Terminal" ,"terminal" , "dark"], @@ -498,6 +509,7 @@ var optionGroups = { "Soft Tabs": [{ path: "useSoftTabs" }, { + ariaLabel: "Tab Size", path: "tabSize", type: "number", values: [2, 3, 4, 8, 16] @@ -519,6 +531,12 @@ var optionGroups = { "Enable Behaviours": { path: "behavioursEnabled" }, + "Wrap with quotes": { + path: "wrapBehavioursEnabled" + }, + "Enable Auto Indent": { + path: "enableAutoIndent" + }, "Full Line Selection": { type: "checkbox", values: "text|line", @@ -533,11 +551,12 @@ var optionGroups = { "Show Indent Guides": { path: "displayIndentGuides" }, - "Persistent Scrollbar": [{ + "Persistent HScrollbar": { path: "hScrollBarAlwaysVisible" - }, { + }, + "Persistent VScrollbar": { path: "vScrollBarAlwaysVisible" - }], + }, "Animate scrolling": { path: "animatedScroll" }, @@ -556,6 +575,7 @@ var optionGroups = { "Show Print Margin": [{ path: "showPrintMargin" }, { + ariaLabel: "Print Margin", type: "number", path: "printMarginColumn" }], @@ -618,10 +638,10 @@ var OptionPanel = function(editor, element) { this.render = function() { this.container.innerHTML = ""; - buildDom(["table", {id: "controls"}, + buildDom(["table", {role: "presentation", id: "controls"}, this.renderOptionGroup(optionGroups.Main), ["tr", null, ["td", {colspan: 2}, - ["table", {id: "more-controls"}, + ["table", {role: "presentation", id: "more-controls"}, this.renderOptionGroup(optionGroups.More) ] ]], @@ -664,17 +684,20 @@ var OptionPanel = function(editor, element) { } if (option.type == "buttonBar") { - control = ["div", option.items.map(function(item) { + control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) { return ["button", { value: item.value, ace_selected_button: value == item.value, + 'aria-pressed': value == item.value, onclick: function() { self.setOption(option, item.value); var nodes = this.parentNode.querySelectorAll("[ace_selected_button]"); for (var i = 0; i < nodes.length; i++) { nodes[i].removeAttribute("ace_selected_button"); + nodes[i].setAttribute("aria-pressed", false); } this.setAttribute("ace_selected_button", true); + this.setAttribute("aria-pressed", true); } }, item.desc || item.caption || item.name]; })]; @@ -682,6 +705,11 @@ var OptionPanel = function(editor, element) { control = ["input", {type: "number", value: value || option.defaultValue, style:"width:3em", oninput: function() { self.setOption(option, parseInt(this.value)); }}]; + if (option.ariaLabel) { + control[1]["aria-label"] = option.ariaLabel; + } else { + control[1].id = key; + } if (option.defaults) { control = [control, option.defaults.map(function(item) { return ["button", {onclick: function() { @@ -725,11 +753,13 @@ var OptionPanel = function(editor, element) { this.renderOption = function(key, option) { if (option.path && !option.onchange && !this.editor.$options[option.path]) return; - this.options[option.path] = option; - var safeKey = "-" + option.path; + var path = Array.isArray(option) ? option[0].path : option.path; + this.options[path] = option; + var safeKey = "-" + path; + var safeId = path + "-label"; var control = this.renderOptionControl(safeKey, option); return ["tr", {class: "ace_optionsMenuEntry"}, ["td", - ["label", {for: safeKey}, key] + ["label", {for: safeKey, id: safeId}, key] ], ["td", control]]; }; diff --git a/htdocs/includes/ace/src/ext-prompt.js b/htdocs/includes/ace/src/ext-prompt.js index bcc99f70806..34d7e36d513 100644 --- a/htdocs/includes/ace/src/ext-prompt.js +++ b/htdocs/includes/ace/src/ext-prompt.js @@ -364,7 +364,7 @@ dom.importCssString("\ line-height: 1.4;\ background: #25282c;\ color: #c1c1c1;\ -}", "autocompletion.css"); +}", "autocompletion.css", false); exports.AcePopup = AcePopup; exports.$singleLineEditor = $singleLineEditor; @@ -430,8 +430,9 @@ exports.getCompletionPrefix = function (editor) { }); -define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/lib/dom","ace/editor"], function(require, exports, module) { +define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module) { "use strict"; +var dom = require("./lib/dom"); var oop = require("./lib/oop"); var EventEmitter = require("./lib/event_emitter").EventEmitter; var lang = require("./lib/lang"); @@ -576,7 +577,9 @@ var SnippetManager = function() { {regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) { var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function(operator) { return operator.length == 2 ? operator[1] : "\x00"; - }).split("\x00"); + }).split("\x00").map(function(value){ + return {value: value}; + }); stack[0].choices = choices; return [choices[0]]; }, next: "start"}, @@ -1047,6 +1050,12 @@ var SnippetManager = function() { } snippetMap[scope].push(s); + if (s.prefix) + s.tabTrigger = s.prefix; + + if (!s.content && s.body) + s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body; + if (s.tabTrigger && !s.trigger) { if (!s.guard && /^\w/.test(s.tabTrigger)) s.guard = "\\b"; @@ -1063,10 +1072,13 @@ var SnippetManager = function() { s.endTriggerRe = new RegExp(s.endTrigger); } - if (snippets && snippets.content) - addSnippet(snippets); - else if (Array.isArray(snippets)) + if (Array.isArray(snippets)) { snippets.forEach(addSnippet); + } else { + Object.keys(snippets).forEach(function(key) { + addSnippet(snippets[key]); + }); + } this._signal("registerSnippets", {scope: scope}); }; @@ -1116,7 +1128,7 @@ var SnippetManager = function() { snippet.tabTrigger = val.match(/^\S*/)[0]; if (!snippet.name) snippet.name = val; - } else { + } else if (key) { snippet[key] = val; } } @@ -1265,18 +1277,17 @@ var TabstopManager = function(editor) { this.selectedTabstop = ts; var range = ts.firstNonLinked || ts; + if (ts.choices) range.cursor = range.start; if (!this.editor.inVirtualSelectionMode) { var sel = this.editor.multiSelect; - sel.toSingleRange(range.clone()); + sel.toSingleRange(range); for (var i = 0; i < ts.length; i++) { if (ts.hasLinkedRanges && ts[i].linked) continue; sel.addRange(ts[i].clone(), true); } - if (sel.ranges[0]) - sel.addRange(sel.ranges[0].clone()); } else { - this.editor.selection.setRange(range); + this.editor.selection.fromOrientedRange(range); } this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); @@ -1403,14 +1414,14 @@ var moveRelative = function(point, start) { }; -require("./lib/dom").importCssString("\ +dom.importCssString("\ .ace_snippet-marker {\ -moz-box-sizing: border-box;\ box-sizing: border-box;\ background: rgba(194, 193, 208, 0.09);\ border: 1px dotted rgba(211, 208, 235, 0.62);\ position: absolute;\ -}"); +}", "snippets.css", false); exports.snippetManager = new SnippetManager(); @@ -1507,6 +1518,7 @@ var Autocomplete = function() { } else if (keepPopupPosition && !prefix) { this.detach(); } + this.changeTimer.cancel(); }; this.detach = function() { @@ -1569,13 +1581,15 @@ var Autocomplete = function() { if (!data) return false; + var completions = this.completions; + this.editor.startOperation({command: {name: "insertMatch"}}); if (data.completer && data.completer.insertMatch) { data.completer.insertMatch(this.editor, data); } else { - if (this.completions.filterText) { + if (completions.filterText) { var ranges = this.editor.selection.getAllRanges(); for (var i = 0, range; range = ranges[i]; i++) { - range.start.column -= this.completions.filterText.length; + range.start.column -= completions.filterText.length; this.editor.session.remove(range); } } @@ -1584,7 +1598,9 @@ var Autocomplete = function() { else this.editor.execCommand("insertstring", data.value || data); } - this.detach(); + if (this.completions == completions) + this.detach(); + this.editor.endOperation(); }; @@ -1680,19 +1696,14 @@ var Autocomplete = function() { return this.openPopup(this.editor, "", keepPopupPosition); } var _id = this.gatherCompletionsId; - this.gatherCompletions(this.editor, function(err, results) { - var detachIfFinished = function() { - if (!results.finished) return; - return this.detach(); - }.bind(this); + var detachIfFinished = function(results) { + if (!results.finished) return; + return this.detach(); + }.bind(this); + var processResults = function(results) { var prefix = results.prefix; - var matches = results && results.matches; - - if (!matches || !matches.length) - return detachIfFinished(); - if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) - return; + var matches = results.matches; this.completions = new FilteredList(matches); @@ -1702,14 +1713,39 @@ var Autocomplete = function() { this.completions.setFilter(prefix); var filtered = this.completions.filtered; if (!filtered.length) - return detachIfFinished(); + return detachIfFinished(results); if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) - return detachIfFinished(); + return detachIfFinished(results); if (this.autoInsert && filtered.length == 1 && results.finished) return this.insertMatch(filtered[0]); this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this); + + var isImmediate = true; + var immediateResults = null; + this.gatherCompletions(this.editor, function(err, results) { + var prefix = results.prefix; + var matches = results && results.matches; + + if (!matches || !matches.length) + return detachIfFinished(results); + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + if (isImmediate) { + immediateResults = results; + return; + } + + processResults(results); }.bind(this)); + + isImmediate = false; + if (immediateResults) { + var results = immediateResults; + immediateResults = null; + processResults(results); + } }; this.cancelContextMenu = function() { @@ -1998,7 +2034,7 @@ margin: 0px;\ .ace_optionsMenuEntry button:hover{\ background: #f0f0f0;\ }"; -dom.importCssString(cssText); +dom.importCssString(cssText, "settings_menu.css", false); module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { var closer = document.createElement('div'); @@ -2097,22 +2133,23 @@ var supportedModes = { ABC: ["abc"], ActionScript:["as"], ADA: ["ada|adb"], + Alda: ["alda"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], - AsciiDoc: ["asciidoc|adoc"], - ASL: ["dsl|asl"], - Assembly_x86:["asm|a"], - AutoHotKey: ["ahk"], Apex: ["apex|cls|trigger|tgr"], AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86:["asm|a"], + AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], C9Search: ["c9search_results"], - Crystal: ["cr"], Cirru: ["cirru|cr"], Clojure: ["clj|cljs"], Cobol: ["CBL|COB"], coffee: ["coffee|cf|cson|^Cakefile"], ColdFusion: ["cfm"], + Crystal: ["cr"], CSharp: ["cs"], Csound_Document: ["csd"], Csound_Orchestra: ["orc"], @@ -2159,8 +2196,8 @@ var supportedModes = { Jade: ["jade|pug"], Java: ["java"], JavaScript: ["js|jsm|jsx"], - JSON5: ["json5"], JSON: ["json"], + JSON5: ["json5"], JSONiq: ["jq"], JSP: ["jsp"], JSSM: ["jssm|jssm_state"], @@ -2168,6 +2205,7 @@ var supportedModes = { Julia: ["jl"], Kotlin: ["kt|kts"], LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], LESS: ["less"], Liquid: ["liquid"], Lisp: ["lisp"], @@ -2182,32 +2220,36 @@ var supportedModes = { Mask: ["mask"], MATLAB: ["matlab"], Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], MEL: ["mel"], + MIPS: ["s|asm"], MIXAL: ["mixal"], MUSHCode: ["mc|mush"], MySQL: ["mysql"], Nginx: ["nginx|conf"], - Nix: ["nix"], Nim: ["nim"], + Nix: ["nix"], NSIS: ["nsi|nsh"], Nunjucks: ["nunjucks|nunjs|nj|njk"], ObjectiveC: ["m|mm"], OCaml: ["ml|mli"], Pascal: ["pas|p"], Perl: ["pl|pm"], - Perl6: ["p6|pl6|pm6"], pgSQL: ["pgsql"], - PHP_Laravel_blade: ["blade.php"], PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], - Puppet: ["epp|pp"], + PHP_Laravel_blade: ["blade.php"], Pig: ["pig"], Powershell: ["ps1"], Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], Prolog: ["plg|prolog"], Properties: ["properties"], Protobuf: ["proto"], + Puppet: ["epp|pp"], Python: ["py"], + QML: ["qml"], R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], Razor: ["cshtml|asp"], RDoc: ["Rd"], Red: ["red|reds"], @@ -2219,11 +2261,13 @@ var supportedModes = { SCAD: ["scad"], Scala: ["scala|sbt"], Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], SCSS: ["scss"], SH: ["sh|bash|^.bashrc"], SJS: ["sjs"], Slim: ["slim|skim"], Smarty: ["smarty|tpl"], + Smithy: ["smithy"], snippets: ["snippets"], Soy_Template:["soy"], Space: ["space"], @@ -2239,7 +2283,7 @@ var supportedModes = { Textile: ["textile"], Toml: ["toml"], TSX: ["tsx"], - Twig: ["latte|twig|swig"], + Twig: ["twig|swig"], Typescript: ["ts|typescript|str"], Vala: ["vala"], VBScript: ["vbs|vb"], @@ -2271,6 +2315,7 @@ var nameOverrides = { Perl6: "Perl 6", AutoHotKey: "AutoHotkey / AutoIt" }; + var modesByName = {}; for (var name in supportedModes) { var data = supportedModes[name]; @@ -2586,13 +2631,10 @@ prompt.commands = function(editor, callback) { var platform = handler.platform; var cbn = handler.byName; for (var i in cbn) { - var key; - if (cbn[i].bindKey && cbn[i].bindKey[platform] !== null) { - key = cbn[i].bindKey["win"]; - } else { - key = ""; + var key = cbn[i].bindKey; + if (typeof key !== "string") { + key = key && key[platform] || ""; } - var commands = cbn[i]; var description = commands.description || normalizeName(commands.name); if (!Array.isArray(commands)) @@ -2749,7 +2791,7 @@ dom.importCssString(".ace_prompt_container {\ background: white;\ border-radius: 2px;\ box-shadow: 0px 2px 3px 0px #555;\ -}"); +}", "promtp.css", false); exports.prompt = prompt; diff --git a/htdocs/includes/ace/src/ext-searchbox.js b/htdocs/includes/ace/src/ext-searchbox.js index 4fbe7933506..8be7e8c12e7 100644 --- a/htdocs/includes/ace/src/ext-searchbox.js +++ b/htdocs/includes/ace/src/ext-searchbox.js @@ -160,7 +160,7 @@ var keyUtil = require("../lib/keys"); var MAX_COUNT = 999; -dom.importCssString(searchboxCss, "ace_searchbox"); +dom.importCssString(searchboxCss, "ace_searchbox", false); var SearchBox = function(editor, range, showReplaceForm) { var div = dom.createElement("div"); diff --git a/htdocs/includes/ace/src/ext-settings_menu.js b/htdocs/includes/ace/src/ext-settings_menu.js index ebfa4108519..1d88965b63b 100644 --- a/htdocs/includes/ace/src/ext-settings_menu.js +++ b/htdocs/includes/ace/src/ext-settings_menu.js @@ -61,7 +61,7 @@ margin: 0px;\ .ace_optionsMenuEntry button:hover{\ background: #f0f0f0;\ }"; -dom.importCssString(cssText); +dom.importCssString(cssText, "settings_menu.css", false); module.exports.overlayPage = function overlayPage(editor, contentElement, callback) { var closer = document.createElement('div'); @@ -160,22 +160,23 @@ var supportedModes = { ABC: ["abc"], ActionScript:["as"], ADA: ["ada|adb"], + Alda: ["alda"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], - AsciiDoc: ["asciidoc|adoc"], - ASL: ["dsl|asl"], - Assembly_x86:["asm|a"], - AutoHotKey: ["ahk"], Apex: ["apex|cls|trigger|tgr"], AQL: ["aql"], + AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl|asl.json"], + Assembly_x86:["asm|a"], + AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], C9Search: ["c9search_results"], - Crystal: ["cr"], Cirru: ["cirru|cr"], Clojure: ["clj|cljs"], Cobol: ["CBL|COB"], coffee: ["coffee|cf|cson|^Cakefile"], ColdFusion: ["cfm"], + Crystal: ["cr"], CSharp: ["cs"], Csound_Document: ["csd"], Csound_Orchestra: ["orc"], @@ -222,8 +223,8 @@ var supportedModes = { Jade: ["jade|pug"], Java: ["java"], JavaScript: ["js|jsm|jsx"], - JSON5: ["json5"], JSON: ["json"], + JSON5: ["json5"], JSONiq: ["jq"], JSP: ["jsp"], JSSM: ["jssm|jssm_state"], @@ -231,6 +232,7 @@ var supportedModes = { Julia: ["jl"], Kotlin: ["kt|kts"], LaTeX: ["tex|latex|ltx|bib"], + Latte: ["latte"], LESS: ["less"], Liquid: ["liquid"], Lisp: ["lisp"], @@ -245,32 +247,36 @@ var supportedModes = { Mask: ["mask"], MATLAB: ["matlab"], Maze: ["mz"], + MediaWiki: ["wiki|mediawiki"], MEL: ["mel"], + MIPS: ["s|asm"], MIXAL: ["mixal"], MUSHCode: ["mc|mush"], MySQL: ["mysql"], Nginx: ["nginx|conf"], - Nix: ["nix"], Nim: ["nim"], + Nix: ["nix"], NSIS: ["nsi|nsh"], Nunjucks: ["nunjucks|nunjs|nj|njk"], ObjectiveC: ["m|mm"], OCaml: ["ml|mli"], Pascal: ["pas|p"], Perl: ["pl|pm"], - Perl6: ["p6|pl6|pm6"], pgSQL: ["pgsql"], - PHP_Laravel_blade: ["blade.php"], PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], - Puppet: ["epp|pp"], + PHP_Laravel_blade: ["blade.php"], Pig: ["pig"], Powershell: ["ps1"], Praat: ["praat|praatscript|psc|proc"], + Prisma: ["prisma"], Prolog: ["plg|prolog"], Properties: ["properties"], Protobuf: ["proto"], + Puppet: ["epp|pp"], Python: ["py"], + QML: ["qml"], R: ["r"], + Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"], Razor: ["cshtml|asp"], RDoc: ["Rd"], Red: ["red|reds"], @@ -282,11 +288,13 @@ var supportedModes = { SCAD: ["scad"], Scala: ["scala|sbt"], Scheme: ["scm|sm|rkt|oak|scheme"], + Scrypt: ["scrypt"], SCSS: ["scss"], SH: ["sh|bash|^.bashrc"], SJS: ["sjs"], Slim: ["slim|skim"], Smarty: ["smarty|tpl"], + Smithy: ["smithy"], snippets: ["snippets"], Soy_Template:["soy"], Space: ["space"], @@ -302,7 +310,7 @@ var supportedModes = { Textile: ["textile"], Toml: ["toml"], TSX: ["tsx"], - Twig: ["latte|twig|swig"], + Twig: ["twig|swig"], Typescript: ["ts|typescript|str"], Vala: ["vala"], VBScript: ["vbs|vb"], @@ -334,6 +342,7 @@ var nameOverrides = { Perl6: "Perl 6", AutoHotKey: "AutoHotkey / AutoIt" }; + var modesByName = {}; for (var name in supportedModes) { var data = supportedModes[name]; @@ -367,7 +376,7 @@ var themeData = [ ["Solarized Light"], ["TextMate" ], ["Tomorrow" ], - ["XCode" ], + ["Xcode" ], ["Kuroir"], ["KatzenMilch"], ["SQL Server" ,"sqlserver" , "light"], @@ -384,6 +393,8 @@ var themeData = [ ["Merbivore Soft" ,"merbivore_soft" , "dark"], ["Mono Industrial" ,"mono_industrial" , "dark"], ["Monokai" ,"monokai" , "dark"], + ["Nord Dark" ,"nord_dark" , "dark"], + ["One Dark" ,"one_dark" , "dark"], ["Pastel on dark" ,"pastel_on_dark" , "dark"], ["Solarized Dark" ,"solarized_dark" , "dark"], ["Terminal" ,"terminal" , "dark"], @@ -498,6 +509,7 @@ var optionGroups = { "Soft Tabs": [{ path: "useSoftTabs" }, { + ariaLabel: "Tab Size", path: "tabSize", type: "number", values: [2, 3, 4, 8, 16] @@ -519,6 +531,12 @@ var optionGroups = { "Enable Behaviours": { path: "behavioursEnabled" }, + "Wrap with quotes": { + path: "wrapBehavioursEnabled" + }, + "Enable Auto Indent": { + path: "enableAutoIndent" + }, "Full Line Selection": { type: "checkbox", values: "text|line", @@ -533,11 +551,12 @@ var optionGroups = { "Show Indent Guides": { path: "displayIndentGuides" }, - "Persistent Scrollbar": [{ + "Persistent HScrollbar": { path: "hScrollBarAlwaysVisible" - }, { + }, + "Persistent VScrollbar": { path: "vScrollBarAlwaysVisible" - }], + }, "Animate scrolling": { path: "animatedScroll" }, @@ -556,6 +575,7 @@ var optionGroups = { "Show Print Margin": [{ path: "showPrintMargin" }, { + ariaLabel: "Print Margin", type: "number", path: "printMarginColumn" }], @@ -618,10 +638,10 @@ var OptionPanel = function(editor, element) { this.render = function() { this.container.innerHTML = ""; - buildDom(["table", {id: "controls"}, + buildDom(["table", {role: "presentation", id: "controls"}, this.renderOptionGroup(optionGroups.Main), ["tr", null, ["td", {colspan: 2}, - ["table", {id: "more-controls"}, + ["table", {role: "presentation", id: "more-controls"}, this.renderOptionGroup(optionGroups.More) ] ]], @@ -664,17 +684,20 @@ var OptionPanel = function(editor, element) { } if (option.type == "buttonBar") { - control = ["div", option.items.map(function(item) { + control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) { return ["button", { value: item.value, ace_selected_button: value == item.value, + 'aria-pressed': value == item.value, onclick: function() { self.setOption(option, item.value); var nodes = this.parentNode.querySelectorAll("[ace_selected_button]"); for (var i = 0; i < nodes.length; i++) { nodes[i].removeAttribute("ace_selected_button"); + nodes[i].setAttribute("aria-pressed", false); } this.setAttribute("ace_selected_button", true); + this.setAttribute("aria-pressed", true); } }, item.desc || item.caption || item.name]; })]; @@ -682,6 +705,11 @@ var OptionPanel = function(editor, element) { control = ["input", {type: "number", value: value || option.defaultValue, style:"width:3em", oninput: function() { self.setOption(option, parseInt(this.value)); }}]; + if (option.ariaLabel) { + control[1]["aria-label"] = option.ariaLabel; + } else { + control[1].id = key; + } if (option.defaults) { control = [control, option.defaults.map(function(item) { return ["button", {onclick: function() { @@ -725,11 +753,13 @@ var OptionPanel = function(editor, element) { this.renderOption = function(key, option) { if (option.path && !option.onchange && !this.editor.$options[option.path]) return; - this.options[option.path] = option; - var safeKey = "-" + option.path; + var path = Array.isArray(option) ? option[0].path : option.path; + this.options[path] = option; + var safeKey = "-" + path; + var safeId = path + "-label"; var control = this.renderOptionControl(safeKey, option); return ["tr", {class: "ace_optionsMenuEntry"}, ["td", - ["label", {for: safeKey}, key] + ["label", {for: safeKey, id: safeId}, key] ], ["td", control]]; }; diff --git a/htdocs/includes/ace/src/ext-textarea.js b/htdocs/includes/ace/src/ext-textarea.js index b876bd3854e..c4bc96bdd1a 100644 --- a/htdocs/includes/ace/src/ext-textarea.js +++ b/htdocs/includes/ace/src/ext-textarea.js @@ -1,135 +1,4 @@ -define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) { -"use strict"; - -exports.isDark = false; -exports.cssClass = "ace-tm"; -exports.cssText = ".ace-tm .ace_gutter {\ -background: #f0f0f0;\ -color: #333;\ -}\ -.ace-tm .ace_print-margin {\ -width: 1px;\ -background: #e8e8e8;\ -}\ -.ace-tm .ace_fold {\ -background-color: #6B72E6;\ -}\ -.ace-tm {\ -background-color: #FFFFFF;\ -color: black;\ -}\ -.ace-tm .ace_cursor {\ -color: black;\ -}\ -.ace-tm .ace_invisible {\ -color: rgb(191, 191, 191);\ -}\ -.ace-tm .ace_storage,\ -.ace-tm .ace_keyword {\ -color: blue;\ -}\ -.ace-tm .ace_constant {\ -color: rgb(197, 6, 11);\ -}\ -.ace-tm .ace_constant.ace_buildin {\ -color: rgb(88, 72, 246);\ -}\ -.ace-tm .ace_constant.ace_language {\ -color: rgb(88, 92, 246);\ -}\ -.ace-tm .ace_constant.ace_library {\ -color: rgb(6, 150, 14);\ -}\ -.ace-tm .ace_invalid {\ -background-color: rgba(255, 0, 0, 0.1);\ -color: red;\ -}\ -.ace-tm .ace_support.ace_function {\ -color: rgb(60, 76, 114);\ -}\ -.ace-tm .ace_support.ace_constant {\ -color: rgb(6, 150, 14);\ -}\ -.ace-tm .ace_support.ace_type,\ -.ace-tm .ace_support.ace_class {\ -color: rgb(109, 121, 222);\ -}\ -.ace-tm .ace_keyword.ace_operator {\ -color: rgb(104, 118, 135);\ -}\ -.ace-tm .ace_string {\ -color: rgb(3, 106, 7);\ -}\ -.ace-tm .ace_comment {\ -color: rgb(76, 136, 107);\ -}\ -.ace-tm .ace_comment.ace_doc {\ -color: rgb(0, 102, 255);\ -}\ -.ace-tm .ace_comment.ace_doc.ace_tag {\ -color: rgb(128, 159, 191);\ -}\ -.ace-tm .ace_constant.ace_numeric {\ -color: rgb(0, 0, 205);\ -}\ -.ace-tm .ace_variable {\ -color: rgb(49, 132, 149);\ -}\ -.ace-tm .ace_xml-pe {\ -color: rgb(104, 104, 91);\ -}\ -.ace-tm .ace_entity.ace_name.ace_function {\ -color: #0000A2;\ -}\ -.ace-tm .ace_heading {\ -color: rgb(12, 7, 255);\ -}\ -.ace-tm .ace_list {\ -color:rgb(185, 6, 144);\ -}\ -.ace-tm .ace_meta.ace_tag {\ -color:rgb(0, 22, 142);\ -}\ -.ace-tm .ace_string.ace_regex {\ -color: rgb(255, 0, 0)\ -}\ -.ace-tm .ace_marker-layer .ace_selection {\ -background: rgb(181, 213, 255);\ -}\ -.ace-tm.ace_multiselect .ace_selection.ace_start {\ -box-shadow: 0 0 3px 0px white;\ -}\ -.ace-tm .ace_marker-layer .ace_step {\ -background: rgb(252, 255, 0);\ -}\ -.ace-tm .ace_marker-layer .ace_stack {\ -background: rgb(164, 229, 101);\ -}\ -.ace-tm .ace_marker-layer .ace_bracket {\ -margin: -1px 0 0 -1px;\ -border: 1px solid rgb(192, 192, 192);\ -}\ -.ace-tm .ace_marker-layer .ace_active-line {\ -background: rgba(0, 0, 0, 0.07);\ -}\ -.ace-tm .ace_gutter-active-line {\ -background-color : #dcdcdc;\ -}\ -.ace-tm .ace_marker-layer .ace_selected-word {\ -background: rgb(250, 250, 255);\ -border: 1px solid rgb(200, 200, 250);\ -}\ -.ace-tm .ace_indent-guide {\ -background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ -}\ -"; -exports.$id = "ace/theme/textmate"; - -var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); -}); - -define("ace/ext/textarea",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/net","ace/ace","ace/theme/textmate"], function(require, exports, module) { +define("ace/ext/textarea",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/net","ace/ace"], function(require, exports, module) { "use strict"; var event = require("../lib/event"); @@ -137,8 +6,6 @@ var UA = require("../lib/useragent"); var net = require("../lib/net"); var ace = require("../ace"); -require("../theme/textmate"); - module.exports = exports = ace; var getCSSProperty = function(element, container, property) { var ret = element.style[property]; diff --git a/htdocs/includes/ace/src/ext-themelist.js b/htdocs/includes/ace/src/ext-themelist.js index 712700a64bd..e8a8ea8974a 100644 --- a/htdocs/includes/ace/src/ext-themelist.js +++ b/htdocs/includes/ace/src/ext-themelist.js @@ -13,7 +13,7 @@ var themeData = [ ["Solarized Light"], ["TextMate" ], ["Tomorrow" ], - ["XCode" ], + ["Xcode" ], ["Kuroir"], ["KatzenMilch"], ["SQL Server" ,"sqlserver" , "light"], @@ -30,6 +30,8 @@ var themeData = [ ["Merbivore Soft" ,"merbivore_soft" , "dark"], ["Mono Industrial" ,"mono_industrial" , "dark"], ["Monokai" ,"monokai" , "dark"], + ["Nord Dark" ,"nord_dark" , "dark"], + ["One Dark" ,"one_dark" , "dark"], ["Pastel on dark" ,"pastel_on_dark" , "dark"], ["Solarized Dark" ,"solarized_dark" , "dark"], ["Terminal" ,"terminal" , "dark"], diff --git a/htdocs/includes/ace/src/keybinding-emacs.js b/htdocs/includes/ace/src/keybinding-emacs.js index 58e79cd44fc..07ffa85cd9d 100644 --- a/htdocs/includes/ace/src/keybinding-emacs.js +++ b/htdocs/includes/ace/src/keybinding-emacs.js @@ -98,7 +98,7 @@ dom.importCssString(".ace_occur-highlight {\n\ .ace_dark .ace_occur-highlight {\n\ background-color: rgb(80, 140, 85);\n\ box-shadow: 0 0 4px rgb(60, 120, 70);\n\ -}\n", "incremental-occur-highlighting"); +}\n", "incremental-occur-highlighting", false); exports.Occur = Occur; @@ -325,7 +325,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); this.attach = function(editor) { var iSearch = this.$iSearch; HashHandler.call(this, exports.iSearchCommands, editor.commands.platform); - this.$commandExecHandler = editor.commands.addEventListener('exec', function(e) { + this.$commandExecHandler = editor.commands.on('exec', function(e) { if (!e.command.isIncrementalSearchCommand) return iSearch.deactivate(); e.stopPropagation(); @@ -340,7 +340,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); this.detach = function(editor) { if (!this.$commandExecHandler) return; - editor.commands.removeEventListener('exec', this.$commandExecHandler); + editor.commands.off('exec', this.$commandExecHandler); delete this.$commandExecHandler; }; @@ -349,7 +349,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); if (((hashId === 1/*ctrl*/ || hashId === 8/*command*/) && key === 'v') || (hashId === 1/*ctrl*/ && key === 'y')) return null; var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode); - if (cmd.command) { return cmd; } + if (cmd && cmd.command) { return cmd; } if (hashId == -1) { var extendCmd = this.commands.extendSearchTerm; if (extendCmd) { return {command: extendCmd, args: key}; } @@ -406,27 +406,28 @@ function objectToRegExp(obj) { (function() { - this.activate = function(ed, backwards) { - this.$editor = ed; - this.$startPos = this.$currentPos = ed.getCursorPosition(); + this.activate = function(editor, backwards) { + this.$editor = editor; + this.$startPos = this.$currentPos = editor.getCursorPosition(); this.$options.needle = ''; this.$options.backwards = backwards; - ed.keyBinding.addKeyboardHandler(this.$keyboardHandler); - this.$originalEditorOnPaste = ed.onPaste; ed.onPaste = this.onPaste.bind(this); - this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this)); - this.selectionFix(ed); + editor.keyBinding.addKeyboardHandler(this.$keyboardHandler); + this.$originalEditorOnPaste = editor.onPaste; + editor.onPaste = this.onPaste.bind(this); + this.$mousedownHandler = editor.on('mousedown', this.onMouseDown.bind(this)); + this.selectionFix(editor); this.statusMessage(true); }; this.deactivate = function(reset) { this.cancelSearch(reset); - var ed = this.$editor; - ed.keyBinding.removeKeyboardHandler(this.$keyboardHandler); + var editor = this.$editor; + editor.keyBinding.removeKeyboardHandler(this.$keyboardHandler); if (this.$mousedownHandler) { - ed.removeEventListener('mousedown', this.$mousedownHandler); + editor.off('mousedown', this.$mousedownHandler); delete this.$mousedownHandler; } - ed.onPaste = this.$originalEditorOnPaste; + editor.onPaste = this.$originalEditorOnPaste; this.message(''); }; @@ -557,7 +558,7 @@ function objectToRegExp(obj) { exports.IncrementalSearch = IncrementalSearch; var dom = require('./lib/dom'); -dom.importCssString && dom.importCssString("\ +dom.importCssString("\ .ace_marker-layer .ace_isearch-result {\ position: absolute;\ z-index: 6;\ @@ -571,7 +572,7 @@ div.ace_isearch-result {\ .ace_dark div.ace_isearch-result {\ background-color: rgb(100, 110, 160);\ box-shadow: 0 0 4px rgb(80, 90, 140);\ -}", "incremental-search-highlighting"); +}", "incremental-search-highlighting", false); var commands = require("./commands/command_manager"); (function() { this.setupIncrementalSearch = function(editor, val) { @@ -700,20 +701,20 @@ exports.handler.attach = function(editor) { editor.commands.addCommands(commands); exports.handler.platform = editor.commands.platform; editor.$emacsModeHandler = this; - editor.addEventListener('copy', this.onCopy); - editor.addEventListener('paste', this.onPaste); + editor.on('copy', this.onCopy); + editor.on('paste', this.onPaste); }; exports.handler.detach = function(editor) { editor.renderer.$blockCursor = false; editor.session.$selectLongWords = $formerLongWords; editor.session.$useEmacsStyleLineStart = $formerLineStart; - editor.removeEventListener("click", $resetMarkMode); - editor.removeEventListener("changeSession", $kbSessionChange); + editor.off("click", $resetMarkMode); + editor.off("changeSession", $kbSessionChange); editor.unsetStyle("emacs-mode"); editor.commands.removeCommands(commands); - editor.removeEventListener('copy', this.onCopy); - editor.removeEventListener('paste', this.onPaste); + editor.off('copy', this.onCopy); + editor.off('paste', this.onPaste); editor.$emacsModeHandler = null; }; diff --git a/htdocs/includes/ace/src/keybinding-vim.js b/htdocs/includes/ace/src/keybinding-vim.js index 79761280e93..bfb7e0bafe5 100644 --- a/htdocs/includes/ace/src/keybinding-vim.js +++ b/htdocs/includes/ace/src/keybinding-vim.js @@ -1,4 +1,123 @@ -define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/dom","ace/lib/oop","ace/lib/keys","ace/lib/event","ace/search","ace/lib/useragent","ace/search_highlight","ace/commands/multi_select_commands","ace/mode/text","ace/multi_select"], function(require, exports, module) { +define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"], function(require, exports, module) { +"use strict"; + +var Range = require("../range").Range; + +function hardWrap(editor, options) { + var max = options.column || editor.getOption("printMarginColumn"); + var allowMerge = options.allowMerge != false; + + var row = Math.min(options.startRow, options.endRow); + var endRow = Math.max(options.startRow, options.endRow); + + var session = editor.session; + + while (row <= endRow) { + var line = session.getLine(row); + if (line.length > max) { + var space = findSpace(line, max, 5); + if (space) { + var indentation = /^\s*/.exec(line)[0]; + session.replace(new Range(row,space.start,row,space.end), "\n" + indentation); + } + endRow++; + } else if (allowMerge && /\S/.test(line) && row != endRow) { + var nextLine = session.getLine(row + 1); + if (nextLine && /\S/.test(nextLine)) { + var trimmedLine = line.replace(/\s+$/, ""); + var trimmedNextLine = nextLine.replace(/^\s+/, ""); + var mergedLine = trimmedLine + " " + trimmedNextLine; + + var space = findSpace(mergedLine, max, 5); + if (space && space.start > trimmedLine.length || mergedLine.length < max) { + var replaceRange = new Range(row,trimmedLine.length,row + 1,nextLine.length - trimmedNextLine.length); + session.replace(replaceRange, " "); + row--; + endRow--; + } else if (trimmedLine.length < line.length) { + session.remove(new Range(row, trimmedLine.length, row, line.length)); + } + } + } + row++; + } + + function findSpace(line, max, min) { + if (line.length < max) + return; + var before = line.slice(0, max); + var after = line.slice(max); + var spaceAfter = /^(?:(\s+)|(\S+)(\s+))/.exec(after); + var spaceBefore = /(?:(\s+)|(\s+)(\S+))$/.exec(before); + var start = 0; + var end = 0; + if (spaceBefore && !spaceBefore[2]) { + start = max - spaceBefore[1].length; + end = max; + } + if (spaceAfter && !spaceAfter[2]) { + if (!start) + start = max; + end = max + spaceAfter[1].length; + } + if (start) { + return { + start: start, + end: end + }; + } + if (spaceBefore && spaceBefore[2] && spaceBefore.index > min) { + return { + start: spaceBefore.index, + end: spaceBefore.index + spaceBefore[2].length + }; + } + if (spaceAfter && spaceAfter[2]) { + start = max + spaceAfter[2].length; + return { + start: start, + end: start + spaceAfter[3].length + }; + } + } + +} + +function wrapAfterInput(e) { + if (e.command.name == "insertstring" && /\S/.test(e.args)) { + var editor = e.editor; + var cursor = editor.selection.cursor; + if (cursor.column <= editor.renderer.$printMarginColumn) return; + var lastDelta = editor.session.$undoManager.$lastDelta; + + hardWrap(editor, { + startRow: cursor.row, endRow: cursor.row, + allowMerge: false + }); + if (lastDelta != editor.session.$undoManager.$lastDelta) + editor.session.markUndoGroup(); + } +} + +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + hardWrap: { + set: function(val) { + if (val) { + this.commands.on("afterExec", wrapAfterInput); + } else { + this.commands.off("afterExec", wrapAfterInput); + } + }, + value: false + } +}); + +exports.hardWrap = hardWrap; + +}); + +define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/dom","ace/lib/oop","ace/lib/keys","ace/lib/event","ace/search","ace/lib/useragent","ace/search_highlight","ace/commands/multi_select_commands","ace/mode/text","ace/ext/hardwrap","ace/multi_select"], function(require, exports, module) { 'use strict'; function log() { @@ -36,12 +155,14 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve var SearchHighlight = require("../search_highlight").SearchHighlight; var multiSelectCommands = require("../commands/multi_select_commands"); var TextModeTokenRe = require("../mode/text").Mode.prototype.tokenRe; + var hardWrap = require("../ext/hardwrap").hardWrap; require("../multi_select"); var CodeMirror = function(ace) { this.ace = ace; this.state = {}; this.marks = {}; + this.options = {}; this.$uid = 0; this.onChange = this.onChange.bind(this); this.onSelectionChange = this.onSelectionChange.bind(this); @@ -58,7 +179,9 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve CodeMirror.commands = { redo: function(cm) { cm.ace.redo(); }, undo: function(cm) { cm.ace.undo(); }, - newlineAndIndent: function(cm) { cm.ace.insert("\n"); } + newlineAndIndent: function(cm) { cm.ace.insert("\n"); }, + goLineLeft: function(cm) { cm.ace.selection.moveCursorLineStart(); }, + goLineRight: function(cm) { cm.ace.selection.moveCursorLineEnd(); } }; CodeMirror.keyMap = {}; CodeMirror.addClass = CodeMirror.rmClass = function() {}; @@ -96,6 +219,11 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve } }; + + CodeMirror.findMatchingTag = function(cm, head) { + + }; + CodeMirror.signal = function(o, name, e) { return o._signal(name, e) }; CodeMirror.on = event.addListener; CodeMirror.off = event.removeListener; @@ -104,10 +232,10 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve TextModeTokenRe.lastIndex = 0; return TextModeTokenRe.test(ch); }; - + (function() { oop.implement(CodeMirror.prototype, EventEmitter); - + this.destroy = function() { this.ace.off('change', this.onChange); this.ace.off('changeSelection', this.onSelectionChange); @@ -194,10 +322,15 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve ch = line.ch; line = line.line; } + var shouldScroll = !this.curOp && !this.ace.inVirtualSelectionMode; if (!this.ace.inVirtualSelectionMode) this.ace.exitMultiSelectMode(); this.ace.session.unfold({row: line, column: ch}); this.ace.selection.moveTo(line, ch); + if (shouldScroll) { + this.ace.renderer.scrollCursorIntoView(); + this.ace.endOperation(); + } }; this.getCursor = function(p) { var sel = this.ace.selection; @@ -227,7 +360,7 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve r.cursor = Range.comparePoints(r.start, head) ? r.end : r.start; return r; }); - + if (this.ace.inVirtualSelectionMode) { this.ace.selection.fromOrientedRange(ranges[0]); return; @@ -259,6 +392,9 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve var pos = this.ace.session.$clipPositionToDocument(p.line, p.ch); return toCmPos(pos); }; + this.foldCode = function(pos) { + this.ace.session.$toggleFoldWidget(pos.line, {}); + }; this.markText = function(cursor) { return {clear: function() {}, find: function() {}}; }; @@ -269,7 +405,7 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve var rowShift = (end.row - start.row) * (isInsert ? 1 : -1); var colShift = (end.column - start.column) * (isInsert ? 1 : -1); if (isInsert) end = start; - + for (var i in this.marks) { var point = this.marks[i]; var cmp = Range.comparePoints(point, start); @@ -374,6 +510,7 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve query = query.source; isRegexp = true; } + if (query == "\\n") { query = "\n"; isRegexp = false; } var search = new Search(); if (pos.ch == undefined) pos.ch = Number.MAX_VALUE; var acePos = {row: pos.line, column: pos.ch}; @@ -392,14 +529,8 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve start: last || acePos }); var range = search.find(cm.ace.session); - if (range && range.isEmpty()) { - if (cm.getLine(range.start.row).length == range.start.column) { - search.$options.start = range; - range = search.find(cm.ace.session); - } - } last = range; - return last; + return last && [!last.isEmpty()]; }, from: function() { return last && toCmPos(last.start) }, to: function() { return last && toCmPos(last.end) }, @@ -433,9 +564,11 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve }; this.replaceRange = function(text, s, e) { if (!e) e = s; - return this.ace.session.replace(new Range(s.line, s.ch, e.line, e.ch), text); + var range = new Range(s.line, s.ch, e.line, e.ch); + this.ace.session.$clipRangeToDocument(range); + return this.ace.session.replace(range, text); }; - this.replaceSelection = + this.replaceSelection = this.replaceSelections = function(p) { var sel = this.ace.selection; if (this.ace.inVirtualSelectionMode) { @@ -487,7 +620,8 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve if (name) this.ace.setOption(name, val); }; - this.getOption = function(name, val) { + this.getOption = function(name) { + var val; var aceOpt = optMap[name]; if (aceOpt) val = this.ace.getOption(aceOpt); @@ -496,7 +630,7 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve name = optMap[name]; return !val; case 'keyMap': - return this.state.$keyMap; + return this.state.$keyMap || 'vim'; } return aceOpt ? val : this.state[name]; }; @@ -597,9 +731,17 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve this.getMode = function() { return { name : this.getOption("mode") }; }; - this.execCommand = function() { - + this.execCommand = function(name) { + if (CodeMirror.commands.hasOwnProperty(name)) return CodeMirror.commands[name](this); + if (name == "indentAuto") return this.ace.execCommand("autoindent"); + console.log(name + " is not implemented"); }; + this.getLineNumber = function(handle) { + return handle.row; + } + this.getLineHandle = function(row) { + return {text: this.ace.session.getLine(row), row: row}; + } }).call(CodeMirror.prototype); function toAcePos(cmPos) { return {row: cmPos.line, column: cmPos.ch}; @@ -710,7 +852,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ width: 20em;\ color: inherit;\ font-family: monospace;\ -}", "vimMode"); +}", "vimMode", false); (function() { function dialogDiv(cm, template, bottom) { var wrap = cm.ace.container; @@ -749,18 +891,26 @@ dom.importCssString(".normal-mode .ace_cursor{\ inp.value = newVal; } else { if (closed) return; - + if (newVal && newVal.type == "blur") { if (document.activeElement === inp) return; } - - me.state.dialog = null; + + if (me.state.dialog == dialog) { + me.state.dialog = null; + me.focus(); + } closed = true; - dialog.parentNode.removeChild(dialog); - me.focus(); + dialog.remove(); if (options.onClose) options.onClose(dialog); + var cm = me; + if (cm.state.vim) { + cm.state.vim.status = null; + cm.ace._signal("changeStatus"); + cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); + } } } @@ -780,7 +930,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } if (e.keyCode == 13) callback(inp.value); if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { - inp.blur(); CodeMirror.e_stop(e); close(); } @@ -813,7 +962,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (closed) return; closed = true; clearTimeout(doneTimer); - dialog.parentNode.removeChild(dialog); + dialog.remove(); } CodeMirror.on(dialog, 'click', function(e) { @@ -828,12 +977,35 @@ dom.importCssString(".normal-mode .ace_cursor{\ }); })(); - + + var Pos = CodeMirror.Pos; + + function transformCursor(cm, range) { + var vim = cm.state.vim; + if (!vim || vim.insertMode) return range.head; + var head = vim.sel.head; + if (!head) return range.head; + + if (vim.visualBlock) { + if (range.head.line != head.line) { + return; + } + } + if (range.from() == range.anchor && !range.empty()) { + if (range.head.line == head.line && range.head.ch != head.ch) + return new Pos(range.head.line, range.head.ch - 1); + } + + return range.head; + } + var defaultKeymap = [ { keys: '', type: 'keyToKey', toKeys: 'h' }, { keys: '', type: 'keyToKey', toKeys: 'l' }, { keys: '', type: 'keyToKey', toKeys: 'k' }, { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: 'g', type: 'keyToKey', toKeys: 'gk' }, + { keys: 'g', type: 'keyToKey', toKeys: 'gj' }, { keys: '', type: 'keyToKey', toKeys: 'l' }, { keys: '', type: 'keyToKey', toKeys: 'h', context: 'normal'}, { keys: '', type: 'keyToKey', toKeys: 'x', context: 'normal'}, @@ -858,6 +1030,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ { keys: '', type: 'keyToKey', toKeys: '' }, { keys: '', type: 'keyToKey', toKeys: '' }, { keys: '', type: 'keyToKey', toKeys: 'j^', context: 'normal' }, + { keys: '', type: 'keyToKey', toKeys: 'i', context: 'normal'}, { keys: '', type: 'action', action: 'toggleOverwrite', context: 'insert' }, { keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }}, { keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }}, @@ -886,6 +1059,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: false, explicitRepeat: true }}, { keys: 'gg', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }}, { keys: 'G', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }}, + {keys: "g$", type: "motion", motion: "moveToEndOfDisplayLine"}, + {keys: "g^", type: "motion", motion: "moveToStartOfDisplayLine"}, + {keys: "g0", type: "motion", motion: "moveToStartOfDisplayLine"}, { keys: '0', type: 'motion', motion: 'moveToStartOfLine' }, { keys: '^', type: 'motion', motion: 'moveToFirstNonWhiteSpaceCharacter' }, { keys: '+', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true }}, @@ -923,6 +1099,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ { keys: 'gU', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, isEdit: true }, { keys: 'n', type: 'motion', motion: 'findNext', motionArgs: { forward: true, toJumplist: true }}, { keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true }}, + { keys: 'gn', type: 'motion', motion: 'findAndSelectNextInclusive', motionArgs: { forward: true }}, + { keys: 'gN', type: 'motion', motion: 'findAndSelectNextInclusive', motionArgs: { forward: false }}, { keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false }}, { keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true }}, { keys: 'D', type: 'operatorMotion', operator: 'delete', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'}, @@ -1002,7 +1180,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ { name: 'undo', shortName: 'u' }, { name: 'redo', shortName: 'red' }, { name: 'set', shortName: 'se' }, - { name: 'set', shortName: 'se' }, { name: 'setlocal', shortName: 'setl' }, { name: 'setglobal', shortName: 'setg' }, { name: 'sort', shortName: 'sor' }, @@ -1011,11 +1188,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ { name: 'yank', shortName: 'y' }, { name: 'delmarks', shortName: 'delm' }, { name: 'registers', shortName: 'reg', excludeFromCommandHistory: true }, + { name: 'vglobal', shortName: 'v' }, { name: 'global', shortName: 'g' } ]; - var Pos = CodeMirror.Pos; - var Vim = function() { return vimApi; } //{ function enterVimMode(cm) { cm.setOption('disableInput', true); @@ -1032,16 +1208,22 @@ dom.importCssString(".normal-mode .ace_cursor{\ CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm)); cm.state.vim = null; } + function detachVimMap(cm, next) { - if (this == CodeMirror.keyMap.vim) + if (this == CodeMirror.keyMap.vim) { + cm.options.$customCursor = null; CodeMirror.rmClass(cm.getWrapperElement(), "cm-fat-cursor"); + } if (!next || next.attach != attachVimMap) leaveVimMode(cm); } function attachVimMap(cm, prev) { - if (this == CodeMirror.keyMap.vim) + if (this == CodeMirror.keyMap.vim) { + if (cm.curOp) cm.curOp.selectionChanged = true; + cm.options.$customCursor = transformCursor; CodeMirror.addClass(cm.getWrapperElement(), "cm-fat-cursor"); + } if (!prev || prev.attach != attachVimMap) enterVimMode(cm); @@ -1060,14 +1242,14 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (!vimKey) { return false; } - var cmd = CodeMirror.Vim.findKey(cm, vimKey); + var cmd = vimApi.findKey(cm, vimKey); if (typeof cmd == 'function') { CodeMirror.signal(cm, 'vim-keypress', vimKey); } return cmd; } - var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'}; + var modifiers = {Shift:'S',Ctrl:'C',Alt:'A',Cmd:'D',Mod:'A',CapsLock:''}; var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del',Insert:'Ins'}; function cmKeyToVimKey(key) { if (key.charAt(0) == '\'') { @@ -1126,7 +1308,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ var lowerCaseAlphabet = makeKeyRange(97, 26); var numbers = makeKeyRange(48, 10); var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']); - var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '/']); + var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '_', '/']); + var upperCaseChars; + try { upperCaseChars = new RegExp("^[\\p{Lu}]$", "u"); } + catch (_) { upperCaseChars = /^[A-Z]$/; } function isLine(cm, line) { return line >= cm.firstLine() && line <= cm.lastLine(); @@ -1141,7 +1326,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ return numberRegex.test(k); } function isUpperCase(k) { - return (/^[A-Z]$/).test(k); + return upperCaseChars.test(k); } function isWhiteSpaceString(k) { return (/^\s*$/).test(k); @@ -1352,7 +1537,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ this.latestRegister = registerName; if (cm.openDialog) { this.onRecordingDone = cm.openDialog( - '(recording)['+registerName+']', null, {bottom:true}); + document.createTextNode('(recording)['+registerName+']'), null, {bottom:true}); } this.isRecording = true; } @@ -1369,7 +1554,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ lastHSPos: -1, lastMotion: null, marks: {}, - fakeCursor: null, insertMode: false, insertModeRepeat: undefined, visualMode: false, @@ -1422,7 +1606,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ exCommandDispatcher.map(lhs, rhs, ctx); }, unmap: function(lhs, ctx) { - exCommandDispatcher.unmap(lhs, ctx); + return exCommandDispatcher.unmap(lhs, ctx); }, noremap: function(lhs, rhs, ctx) { function toCtxArray(ctx) { @@ -1530,7 +1714,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ match = (/<\w+-.+?>|<\w+>|./).exec(keys); key = match[0]; keys = keys.substring(match.index + key.length); - CodeMirror.Vim.handleKey(cm, key, 'mapping'); + vimApi.handleKey(cm, key, 'mapping'); } } @@ -1576,9 +1760,14 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (!keysMatcher) { clearInputState(cm); return false; } var context = vim.visualMode ? 'visual' : 'normal'; - var match = commandDispatcher.matchCommand(keysMatcher[2] || keysMatcher[1], defaultKeymap, vim.inputState, context); + var mainKey = keysMatcher[2] || keysMatcher[1]; + if (vim.inputState.operatorShortcut && vim.inputState.operatorShortcut.slice(-1) == mainKey) { + mainKey = vim.inputState.operatorShortcut; + } + var match = commandDispatcher.matchCommand(mainKey, defaultKeymap, vim.inputState, context); if (match.type == 'none') { clearInputState(cm); return false; } else if (match.type == 'partial') { return true; } + else if (match.type == 'clear') { clearInputState(cm); return true; } // ace_patch vim.inputState.keyBuffer = ''; var keysMatcher = /^(\d*)(.*)$/.exec(keys); @@ -1610,7 +1799,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ } catch (e) { cm.state.vim = undefined; maybeInitVimState(cm); - if (!CodeMirror.Vim.suppressErrorLogging) { + if (!vimApi.suppressErrorLogging) { console['log'](e); } throw e; @@ -1727,6 +1916,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ } RegisterController.prototype = { pushText: function(registerName, operator, text, linewise, blockwise) { + if (registerName === '_') return; if (linewise && text.charAt(text.length - 1) !== '\n'){ text += '\n'; } @@ -1830,7 +2020,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ } if (bestMatch.keys.slice(-11) == '') { var character = lastChar(keys); - if (//.test(character) || !character) return {type: 'none'}; //ace_patch + if (!character || character.length > 1) return {type: 'clear'}; //ace_patch inputState.selectedCharacter = character; } return {type: 'full', command: bestMatch}; @@ -1880,6 +2070,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ } inputState.operator = command.operator; inputState.operatorArgs = copyArgs(command.operatorArgs); + if (command.keys.length > 1) { + inputState.operatorShortcut = command.keys; + } if (command.exitVisualBlock) { vim.visualBlock = false; updateCmSelection(cm); @@ -1955,7 +2148,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ }); } function onPromptClose(query) { - cm.scrollTo(originalScrollPos.left, originalScrollPos.top); handleQuery(query, true /** ignoreCase */, true /** smartCase */); var macroModeState = vimGlobalState.macroModeState; if (macroModeState.isRecording) { @@ -2017,7 +2209,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ showPrompt(cm, { onClose: onPromptClose, prefix: promptPrefix, - desc: searchPromptDesc, + desc: '(JavaScript regexp)', onKeyUp: onPromptKeyUp, onKeyDown: onPromptKeyDown }); @@ -2131,7 +2323,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ motionArgs.repeat = repeat; clearInputState(cm); if (motion) { - var motionResult = motions[motion](cm, origHead, motionArgs, vim); + var motionResult = motions[motion](cm, origHead, motionArgs, vim, inputState); vim.lastMotion = motions[motion]; if (!motionResult) { return; @@ -2159,10 +2351,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ } if (vim.visualMode) { if (!(vim.visualBlock && newHead.ch === Infinity)) { - newHead = clipCursorToContent(cm, newHead, vim.visualBlock); + newHead = clipCursorToContent(cm, newHead); } if (newAnchor) { - newAnchor = clipCursorToContent(cm, newAnchor, true); + newAnchor = clipCursorToContent(cm, newAnchor); } newAnchor = newAnchor || oldAnchor; sel.anchor = newAnchor; @@ -2186,13 +2378,13 @@ dom.importCssString(".normal-mode .ace_cursor{\ var lineOffset = Math.abs(lastSel.head.line - lastSel.anchor.line); var chOffset = Math.abs(lastSel.head.ch - lastSel.anchor.ch); if (lastSel.visualLine) { - newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch); + newHead = new Pos(oldAnchor.line + lineOffset, oldAnchor.ch); } else if (lastSel.visualBlock) { - newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch + chOffset); + newHead = new Pos(oldAnchor.line + lineOffset, oldAnchor.ch + chOffset); } else if (lastSel.head.line == lastSel.anchor.line) { - newHead = Pos(oldAnchor.line, oldAnchor.ch + chOffset); + newHead = new Pos(oldAnchor.line, oldAnchor.ch + chOffset); } else { - newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch); + newHead = new Pos(oldAnchor.line + lineOffset, oldAnchor.ch); } vim.visualMode = true; vim.visualLine = lastSel.visualLine; @@ -2230,7 +2422,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ ranges[i].head.ch = lineLength(cm, ranges[i].head.line); } } else if (mode == 'line') { - ranges[0].head = Pos(ranges[0].head.line + 1, 0); + ranges[0].head = new Pos(ranges[0].head.line + 1, 0); } } } else { @@ -2282,20 +2474,20 @@ dom.importCssString(".normal-mode .ace_cursor{\ var motions = { moveToTopLine: function(cm, _head, motionArgs) { var line = getUserVisibleLines(cm).top + motionArgs.repeat -1; - return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + return new Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); }, moveToMiddleLine: function(cm) { var range = getUserVisibleLines(cm); var line = Math.floor((range.top + range.bottom) * 0.5); - return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + return new Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); }, moveToBottomLine: function(cm, _head, motionArgs) { var line = getUserVisibleLines(cm).bottom - motionArgs.repeat +1; - return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + return new Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); }, expandToLine: function(_cm, head, motionArgs) { var cur = head; - return Pos(cur.line + motionArgs.repeat - 1, Infinity); + return new Pos(cur.line + motionArgs.repeat - 1, Infinity); }, findNext: function(cm, _head, motionArgs) { var state = getSearchState(cm); @@ -2308,6 +2500,58 @@ dom.importCssString(".normal-mode .ace_cursor{\ highlightSearchMatches(cm, query); return findNext(cm, prev/** prev */, query, motionArgs.repeat); }, + findAndSelectNextInclusive: function(cm, _head, motionArgs, vim, prevInputState) { + var state = getSearchState(cm); + var query = state.getQuery(); + + if (!query) { + return; + } + + var prev = !motionArgs.forward; + prev = (state.isReversed()) ? !prev : prev; + var next = findNextFromAndToInclusive(cm, prev, query, motionArgs.repeat, vim); + if (!next) { + return; + } + if (prevInputState.operator) { + return next; + } + + var from = next[0]; + var to = new Pos(next[1].line, next[1].ch - 1); + + if (vim.visualMode) { + if (vim.visualLine || vim.visualBlock) { + vim.visualLine = false; + vim.visualBlock = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: ""}); + } + var anchor = vim.sel.anchor; + if (anchor) { + if (state.isReversed()) { + if (motionArgs.forward) { + return [anchor, from]; + } + + return [anchor, to]; + } else { + if (motionArgs.forward) { + return [anchor, to]; + } + + return [anchor, from]; + } + } + } else { + vim.visualMode = true; + vim.visualLine = false; + vim.visualBlock = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: ""}); + } + + return prev ? [to, from] : [from, to]; + }, goToMark: function(cm, _head, motionArgs, vim) { var pos = getMarkPos(cm, vim, motionArgs.selectedCharacter); if (pos) { @@ -2319,8 +2563,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (vim.visualBlock && motionArgs.sameLine) { var sel = vim.sel; return [ - clipCursorToContent(cm, Pos(sel.anchor.line, sel.head.ch)), - clipCursorToContent(cm, Pos(sel.head.line, sel.anchor.ch)) + clipCursorToContent(cm, new Pos(sel.anchor.line, sel.head.ch)), + clipCursorToContent(cm, new Pos(sel.head.line, sel.anchor.ch)) ]; } else { return ([vim.sel.head, vim.sel.anchor]); @@ -2357,7 +2601,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ } if (motionArgs.linewise) { - best = Pos(best.line, findFirstNonWhiteSpaceCharacter(cm.getLine(best.line))); + best = new Pos(best.line, findFirstNonWhiteSpaceCharacter(cm.getLine(best.line))); } return best; }, @@ -2365,7 +2609,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var cur = head; var repeat = motionArgs.repeat; var ch = motionArgs.forward ? cur.ch + repeat : cur.ch - repeat; - return Pos(cur.line, ch); + return new Pos(cur.line, ch); }, moveByLines: function(cm, head, motionArgs, vim) { var cur = head; @@ -2387,8 +2631,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ var last = cm.lastLine(); if (line < first && cur.line == first){ return this.moveToStartOfLine(cm, head, motionArgs, vim); - }else if (line > last && cur.line == last){ - return this.moveToEol(cm, head, motionArgs, vim, true); + } else if (line > last && cur.line == last){ + return moveToEol(cm, head, motionArgs, vim, true); } var fold = cm.ace.session.getFoldLine(line); if (fold) { @@ -2403,8 +2647,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line)); vim.lastHPos = endCh; } - vim.lastHSPos = cm.charCoords(Pos(line, endCh),'div').left; - return Pos(line, endCh); + vim.lastHSPos = cm.charCoords(new Pos(line, endCh),'div').left; + return new Pos(line, endCh); }, moveByDisplayLines: function(cm, head, motionArgs, vim) { var cur = head; @@ -2426,7 +2670,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var goalCoords = { top: lastCharCoords.top + 8, left: vim.lastHSPos }; var res = cm.coordsChar(goalCoords, 'div'); } else { - var resCoords = cm.charCoords(Pos(cm.firstLine(), 0), 'div'); + var resCoords = cm.charCoords(new Pos(cm.firstLine(), 0), 'div'); resCoords.left = vim.lastHSPos; res = cm.coordsChar(resCoords, 'div'); } @@ -2495,20 +2739,12 @@ dom.importCssString(".normal-mode .ace_cursor{\ vim.lastHSPos = cm.charCoords(head,'div').left; return moveToColumn(cm, repeat); }, - moveToEol: function(cm, head, motionArgs, vim, keepHPos) { - var cur = head; - var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity); - var end=cm.clipPos(retval); - end.ch--; - if (!keepHPos) { - vim.lastHPos = Infinity; - vim.lastHSPos = cm.charCoords(end,'div').left; - } - return retval; + moveToEol: function(cm, head, motionArgs, vim) { + return moveToEol(cm, head, motionArgs, vim, false); }, moveToFirstNonWhiteSpaceCharacter: function(cm, head) { var cursor = head; - return Pos(cursor.line, + return new Pos(cursor.line, findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line))); }, moveToMatchedSymbol: function(cm, head) { @@ -2520,7 +2756,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ for (; ch < lineText.length; ch++) { symbol = lineText.charAt(ch); if (symbol && isMatchableSymbol(symbol)) { - var style = cm.getTokenTypeAt(Pos(line, ch + 1)); + var style = cm.getTokenTypeAt(new Pos(line, ch + 1)); if (style !== "string" && style !== "comment") { break; } @@ -2528,23 +2764,33 @@ dom.importCssString(".normal-mode .ace_cursor{\ } if (ch < lineText.length) { var re = /[<>]/.test(lineText[ch]) ? /[(){}[\]<>]/ : /[(){}[\]]/; //ace_patch? - var matched = cm.findMatchingBracket(Pos(line, ch+1), {bracketRegex: re}); + var matched = cm.findMatchingBracket(new Pos(line, ch+1), {bracketRegex: re}); return matched.to; } else { return cursor; } }, moveToStartOfLine: function(_cm, head) { - return Pos(head.line, 0); + return new Pos(head.line, 0); }, moveToLineOrEdgeOfDocument: function(cm, _head, motionArgs) { var lineNum = motionArgs.forward ? cm.lastLine() : cm.firstLine(); if (motionArgs.repeatIsExplicit) { lineNum = motionArgs.repeat - cm.getOption('firstLineNumber'); } - return Pos(lineNum, + return new Pos(lineNum, findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum))); }, + moveToStartOfDisplayLine: function(cm) { + cm.execCommand("goLineLeft"); + return cm.getCursor(); + }, + moveToEndOfDisplayLine: function(cm) { + cm.execCommand("goLineRight"); + var head = cm.getCursor(); + if (head.sticky == "before") head.ch--; + return head; + }, textObjectManipulation: function(cm, head, motionArgs, vim) { var mirroredPairs = {'(': ')', ')': '(', '{': '}', '}': '{', @@ -2581,6 +2827,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (operatorArgs) { operatorArgs.linewise = true; } tmp.end.line--; } + } else if (character === 't') { + tmp = expandTagUnderCursor(cm, head, inclusive); } else { return null; } @@ -2682,7 +2930,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (anchor.line == cm.firstLine()) { anchor.ch = 0; } else { - anchor = Pos(anchor.line - 1, lineLength(cm, anchor.line - 1)); + anchor = new Pos(anchor.line - 1, lineLength(cm, anchor.line - 1)); } } text = cm.getRange(anchor, head); @@ -2695,13 +2943,12 @@ dom.importCssString(".normal-mode .ace_cursor{\ text = cm.getSelection(); var replacement = fillArray('', ranges.length); cm.replaceSelections(replacement); - finalHead = ranges[0].anchor; + finalHead = cursorMin(ranges[0].head, ranges[0].anchor); } vimGlobalState.registerController.pushText( args.registerName, 'delete', text, args.linewise, vim.visualBlock); - var includeLineBreak = vim.insertMode - return clipCursorToContent(cm, finalHead, includeLineBreak); + return clipCursorToContent(cm, finalHead); }, indent: function(cm, args, ranges) { var vim = cm.state.vim; @@ -2721,6 +2968,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor); }, indentAuto: function(cm, _args, ranges) { + if (ranges.length > 1) { // ace_patch + cm.setSelection(ranges[0].anchor, ranges[ranges.length - 1].head); + } cm.execCommand("indentAuto"); return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor); }, @@ -2824,7 +3074,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ }, scrollToCursor: function(cm, actionArgs) { var lineNum = cm.getCursor().line; - var charCoords = cm.charCoords(Pos(lineNum, 0), 'local'); + var charCoords = cm.charCoords(new Pos(lineNum, 0), 'local'); var height = cm.getScrollInfo().clientHeight; var y = charCoords.top; var lineHeight = charCoords.bottom - y; @@ -2876,9 +3126,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ var head = actionArgs.head || cm.getCursor('head'); var height = cm.listSelections().length; if (insertAt == 'eol') { - head = Pos(head.line, lineLength(cm, head.line)); + head = new Pos(head.line, lineLength(cm, head.line)); } else if (insertAt == 'bol') { - head = Pos(head.line, 0); + head = new Pos(head.line, 0); } else if (insertAt == 'charAfter') { head = offsetCursor(head, 0, 1); } else if (insertAt == 'firstNonBlank') { @@ -2890,10 +3140,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (sel.head.line < sel.anchor.line) { head = sel.head; } else { - head = Pos(sel.anchor.line, 0); + head = new Pos(sel.anchor.line, 0); } } else { - head = Pos( + head = new Pos( Math.min(sel.head.line, sel.anchor.line), Math.min(sel.head.ch, sel.anchor.ch)); height = Math.abs(sel.head.line - sel.anchor.line) + 1; @@ -2905,12 +3155,12 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (sel.head.line >= sel.anchor.line) { head = offsetCursor(sel.head, 0, 1); } else { - head = Pos(sel.anchor.line, 0); + head = new Pos(sel.anchor.line, 0); } } else { - head = Pos( + head = new Pos( Math.min(sel.head.line, sel.anchor.line), - Math.max(sel.head.ch + 1, sel.anchor.ch)); + Math.max(sel.head.ch, sel.anchor.ch) + 1); height = Math.abs(sel.head.line - sel.anchor.line) + 1; } } else if (insertAt == 'inplace') { @@ -2948,8 +3198,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ vim.visualLine = !!actionArgs.linewise; vim.visualBlock = !!actionArgs.blockwise; head = clipCursorToContent( - cm, Pos(anchor.line, anchor.ch + repeat - 1), - true /** includeLineBreak */); + cm, new Pos(anchor.line, anchor.ch + repeat - 1)); vim.sel = { anchor: anchor, head: head @@ -3009,13 +3258,13 @@ dom.importCssString(".normal-mode .ace_cursor{\ } else { var repeat = Math.max(actionArgs.repeat, 2); curStart = cm.getCursor(); - curEnd = clipCursorToContent(cm, Pos(curStart.line + repeat - 1, + curEnd = clipCursorToContent(cm, new Pos(curStart.line + repeat - 1, Infinity)); } var finalCh = 0; for (var i = curStart.line; i < curEnd.line; i++) { finalCh = lineLength(cm, curStart.line); - var tmp = Pos(curStart.line + 1, + var tmp = new Pos(curStart.line + 1, lineLength(cm, curStart.line + 1)); var text = cm.getRange(curStart, tmp); text = actionArgs.keepSpaces @@ -3023,7 +3272,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ : text.replace(/\n\s*/g, ' '); cm.replaceRange(text, curStart, tmp); } - var curFinalPos = Pos(curStart.line, finalCh); + var curFinalPos = new Pos(curStart.line, finalCh); if (vim.visualMode) { exitVisualMode(cm, false); } @@ -3033,7 +3282,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ vim.insertMode = true; var insertAt = copyCursor(cm.getCursor()); if (insertAt.line === cm.firstLine() && !actionArgs.after) { - cm.replaceRange('\n', Pos(cm.firstLine(), 0)); + cm.replaceRange('\n', new Pos(cm.firstLine(), 0)); cm.setCursor(cm.firstLine(), 0); } else { insertAt.line = (actionArgs.after) ? insertAt.line : @@ -3125,7 +3374,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ vimGlobalState.registerController.unnamedRegister.setText(selectedText); if (blockwise) { cm.replaceSelections(emptyStrings); - selectionEnd = Pos(selectionStart.line + text.length-1, selectionStart.ch); + selectionEnd = new Pos(selectionStart.line + text.length-1, selectionStart.ch); cm.setCursor(selectionStart); selectBlock(cm, selectionEnd); cm.replaceSelections(text); @@ -3151,7 +3400,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ for (var i = 0; i < text.length; i++) { var line = cur.line+i; if (line > cm.lastLine()) { - cm.replaceRange('\n', Pos(line, 0)); + cm.replaceRange('\n', new Pos(line, 0)); } var lastCh = lineLength(cm, line); if (lastCh < cur.ch) { @@ -3159,17 +3408,17 @@ dom.importCssString(".normal-mode .ace_cursor{\ } } cm.setCursor(cur); - selectBlock(cm, Pos(cur.line + text.length-1, cur.ch)); + selectBlock(cm, new Pos(cur.line + text.length-1, cur.ch)); cm.replaceSelections(text); curPosFinal = cur; } else { cm.replaceRange(text, cur); if (linewise && actionArgs.after) { - curPosFinal = Pos( + curPosFinal = new Pos( cur.line + 1, findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1))); } else if (linewise && !actionArgs.after) { - curPosFinal = Pos( + curPosFinal = new Pos( cur.line, findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line))); } else if (!linewise && actionArgs.after) { @@ -3217,7 +3466,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (replaceTo > line.length) { replaceTo=line.length; } - curEnd = Pos(curStart.line, replaceTo); + curEnd = new Pos(curStart.line, replaceTo); } if (replaceWith=='\n') { if (!vim.visualMode) cm.replaceRange('', curStart, curEnd); @@ -3270,13 +3519,13 @@ dom.importCssString(".normal-mode .ace_cursor{\ } else { numberStr = baseStr + zeroPadding + numberStr; } - var from = Pos(cur.line, start); - var to = Pos(cur.line, end); + var from = new Pos(cur.line, start); + var to = new Pos(cur.line, end); cm.replaceRange(numberStr, from, to); } else { return; } - cm.setCursor(Pos(cur.line, start + numberStr.length - 1)); + cm.setCursor(new Pos(cur.line, start + numberStr.length - 1)); }, repeatLastEdit: function(cm, actionArgs, vim) { var lastEditInputState = vim.lastEditInputState; @@ -3298,12 +3547,13 @@ dom.importCssString(".normal-mode .ace_cursor{\ function defineAction(name, fn) { actions[name] = fn; } - function clipCursorToContent(cm, cur, includeLineBreak) { + function clipCursorToContent(cm, cur) { + var vim = cm.state.vim; + var includeLineBreak = vim.insertMode || vim.visualMode; var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() ); - var maxCh = lineLength(cm, line) - 1; - maxCh = (includeLineBreak) ? maxCh + 1 : maxCh; + var maxCh = lineLength(cm, line) - 1 + !!includeLineBreak; var ch = Math.min(Math.max(0, cur.ch), maxCh); - return Pos(line, ch); + return new Pos(line, ch); } function copyArgs(args) { var ret = {}; @@ -3319,7 +3569,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ offsetCh = offsetLine.ch; offsetLine = offsetLine.line; } - return Pos(cur.line + offsetLine, cur.ch + offsetCh); + return new Pos(cur.line + offsetLine, cur.ch + offsetCh); } function commandMatches(keys, keyMap, context, inputState) { var match, partial = [], full = []; @@ -3375,7 +3625,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ }; } function copyCursor(cur) { - return Pos(cur.line, cur.ch); + return new Pos(cur.line, cur.ch); } function cursorEqual(cur1, cur2) { return cur1.ch == cur2.ch && cur1.line == cur2.line; @@ -3421,7 +3671,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ function extendLineToColumn(cm, lineNum, column) { var endCh = lineLength(cm, lineNum); var spaces = new Array(column-endCh+1).join(' '); - cm.setCursor(Pos(lineNum, endCh)); + cm.setCursor(new Pos(lineNum, endCh)); cm.replaceRange(spaces, cm.getCursor()); } function selectBlock(cm, selectionEnd) { @@ -3495,11 +3745,11 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (block) { var width = block.width; var height = block.height; - selectionEnd = Pos(selectionStart.line + height, selectionStart.ch + width); + selectionEnd = new Pos(selectionStart.line + height, selectionStart.ch + width); var selections = []; for (var i = selectionStart.line; i < selectionEnd.line; i++) { - var anchor = Pos(i, selectionStart.ch); - var head = Pos(i, selectionEnd.ch); + var anchor = new Pos(i, selectionStart.ch); + var head = new Pos(i, selectionEnd.ch); var range = {anchor: anchor, head: head}; selections.push(range); } @@ -3511,8 +3761,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ var ch = end.ch - start.ch; selectionEnd = {line: selectionEnd.line + line, ch: line ? selectionEnd.ch : ch + selectionEnd.ch}; if (lastSelection.visualLine) { - selectionStart = Pos(selectionStart.line, 0); - selectionEnd = Pos(selectionEnd.line, lineLength(cm, selectionEnd.line)); + selectionStart = new Pos(selectionStart.line, 0); + selectionEnd = new Pos(selectionEnd.line, lineLength(cm, selectionEnd.line)); } cm.setSelection(selectionStart, selectionEnd); } @@ -3557,7 +3807,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ head = cursorMax(head, end); head = offsetCursor(head, 0, -1); if (head.ch == -1 && head.line != cm.firstLine()) { - head = Pos(head.line - 1, lineLength(cm, head.line - 1)); + head = new Pos(head.line - 1, lineLength(cm, head.line - 1)); } } return [anchor, head]; @@ -3569,7 +3819,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ vim.visualLine ? 'line' : vim.visualBlock ? 'block' : 'char'; var cmSel = makeCmSelection(cm, sel, mode); cm.setSelections(cmSel.ranges, cmSel.primary); - updateFakeCursor(cm); } function makeCmSelection(cm, sel, mode, exclusive) { var head = copyCursor(sel.head); @@ -3602,16 +3851,18 @@ dom.importCssString(".normal-mode .ace_cursor{\ }; } else if (mode == 'block') { var top = Math.min(anchor.line, head.line), - left = Math.min(anchor.ch, head.ch), + fromCh = anchor.ch, bottom = Math.max(anchor.line, head.line), - right = Math.max(anchor.ch, head.ch) + 1; + toCh = head.ch; + if (fromCh < toCh) { toCh += 1 } + else { fromCh += 1 }; var height = bottom - top + 1; var primary = head.line == top ? 0 : height - 1; var ranges = []; for (var i = 0; i < height; i++) { ranges.push({ - anchor: Pos(top + i, left), - head: Pos(top + i, right) + anchor: new Pos(top + i, fromCh), + head: new Pos(top + i, toCh) }); } return { @@ -3636,10 +3887,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ vim.visualMode = false; vim.visualLine = false; vim.visualBlock = false; - CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); - if (vim.fakeCursor) { - vim.fakeCursor.clear(); - } + if (!vim.insertMode) CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); } function clipToLine(cm, curStart, curEnd) { var selection = cm.getRange(curStart, curEnd); @@ -3706,7 +3954,23 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (!start) { start = wordStart; } } } - return { start: Pos(cur.line, start), end: Pos(cur.line, end) }; + return { start: new Pos(cur.line, start), end: new Pos(cur.line, end) }; + } + function expandTagUnderCursor(cm, head, inclusive) { + var cur = head; + if (!CodeMirror.findMatchingTag || !CodeMirror.findEnclosingTag) { + return { start: cur, end: cur }; + } + + var tags = CodeMirror.findMatchingTag(cm, head) || CodeMirror.findEnclosingTag(cm, head); + if (!tags || !tags.open || !tags.close) { + return { start: cur, end: cur }; + } + + if (inclusive) { + return { start: tags.open.from, end: tags.close.to }; + } + return { start: tags.open.to, end: tags.close.from }; } function recordJumpPosition(cm, oldCur, newCur) { @@ -3772,7 +4036,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ }, isComplete: function(state) { if (state.nextCh === '#') { - var token = state.lineText.match(/#(\w+)/)[1]; + var token = state.lineText.match(/^#(\w+)/)[1]; if (token === 'endif') { if (state.forward && state.depth === 0) { return true; @@ -3834,7 +4098,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ } } if (state.nextCh || state.curMoveThrough) { - return Pos(line, state.index); + return new Pos(line, state.index); } return cur; } @@ -3910,7 +4174,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ break; } words.push(word); - cur = Pos(word.line, forward ? (word.to - 1) : word.from); + cur = new Pos(word.line, forward ? (word.to - 1) : word.from); } var shortCircuit = words.length != repeat; var firstWord = words[0]; @@ -3919,19 +4183,31 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (!shortCircuit && (firstWord.from != curStart.ch || firstWord.line != curStart.line)) { lastWord = words.pop(); } - return Pos(lastWord.line, lastWord.from); + return new Pos(lastWord.line, lastWord.from); } else if (forward && wordEnd) { - return Pos(lastWord.line, lastWord.to - 1); + return new Pos(lastWord.line, lastWord.to - 1); } else if (!forward && wordEnd) { if (!shortCircuit && (firstWord.to != curStart.ch || firstWord.line != curStart.line)) { lastWord = words.pop(); } - return Pos(lastWord.line, lastWord.to); + return new Pos(lastWord.line, lastWord.to); } else { - return Pos(lastWord.line, lastWord.from); + return new Pos(lastWord.line, lastWord.from); } } + function moveToEol(cm, head, motionArgs, vim, keepHPos) { + var cur = head; + var retval= new Pos(cur.line + motionArgs.repeat - 1, Infinity); + var end=cm.clipPos(retval); + end.ch--; + if (!keepHPos) { + vim.lastHPos = Infinity; + vim.lastHSPos = cm.charCoords(end,'div').left; + } + return retval; + } + function moveToCharacter(cm, repeat, forward, character) { var cur = cm.getCursor(); var start = cur.ch; @@ -3944,12 +4220,12 @@ dom.importCssString(".normal-mode .ace_cursor{\ } start = idx; } - return Pos(cm.getCursor().line, idx); + return new Pos(cm.getCursor().line, idx); } function moveToColumn(cm, repeat) { var line = cm.getCursor().line; - return clipCursorToContent(cm, Pos(line, repeat - 1)); + return clipCursorToContent(cm, new Pos(line, repeat - 1)); } function updateMark(cm, vim, markName, pos) { @@ -4167,7 +4443,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ repeat--; } - return Pos(curr_index.ln, curr_index.pos); + return new Pos(curr_index.ln, curr_index.pos); } function selectCompanionObject(cm, head, symb, inclusive) { var cur = head, start, end; @@ -4185,8 +4461,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ var curChar = cm.getLine(cur.line).charAt(cur.ch); var offset = curChar === openSym ? 1 : 0; - start = cm.scanForBracket(Pos(cur.line, cur.ch + offset), -1, undefined, {'bracketRegex': bracketRegexp}); - end = cm.scanForBracket(Pos(cur.line, cur.ch + offset), 1, undefined, {'bracketRegex': bracketRegexp}); + start = cm.scanForBracket(new Pos(cur.line, cur.ch + offset), -1, undefined, {'bracketRegex': bracketRegexp}); + end = cm.scanForBracket(new Pos(cur.line, cur.ch + offset), 1, undefined, {'bracketRegex': bracketRegexp}); if (!start || !end) { return { start: cur, end: cur }; @@ -4247,8 +4523,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ } return { - start: Pos(cur.line, start), - end: Pos(cur.line, end) + start: new Pos(cur.line, start), + end: new Pos(cur.line, end) }; } defineOption('pcre', true, 'boolean'); @@ -4283,21 +4559,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ var vim = cm.state.vim; return vim.searchState_ || (vim.searchState_ = new SearchState()); } - function dialog(cm, template, shortText, onClose, options) { - if (cm.openDialog) { - cm.openDialog(template, onClose, { bottom: true, value: options.value, - onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp, - selectValueOnOpen: false, onClose: function() { - if (cm.state.vim) { - cm.state.vim.status = ""; - cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); - } - }}); - } - else { - onClose(prompt(shortText, '')); - } - } function splitBySlash(argString) { return splitBySeparator(argString, '/'); } @@ -4400,7 +4661,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ } return out.join(''); } - var unescapes = {'\\/': '/', '\\\\': '\\', '\\n': '\n', '\\r': '\r', '\\t': '\t'}; + var unescapes = {'\\/': '/', '\\\\': '\\', '\\n': '\n', '\\r': '\r', '\\t': '\t', '\\&':'&'}; function unescapeRegexReplace(str) { var stream = new CodeMirror.StringStream(str); var output = []; @@ -4446,30 +4707,58 @@ dom.importCssString(".normal-mode .ace_cursor{\ ignoreCase = (/^[^A-Z]*$/).test(regexPart); } var regexp = new RegExp(regexPart, - (ignoreCase || forceIgnoreCase) ? 'i' : undefined); + (ignoreCase || forceIgnoreCase) ? 'im' : 'm'); return regexp; } - function showConfirm(cm, text) { + function hdom(n) { + if (typeof n === 'string') n = document.createElement(n); + for (var a, i = 1; i < arguments.length; i++) { + if (!(a = arguments[i])) continue; + if (typeof a !== 'object') a = document.createTextNode(a); + if (a.nodeType) n.appendChild(a); + else for (var key in a) { + if (!Object.prototype.hasOwnProperty.call(a, key)) continue; + if (key[0] === '$') n.style[key.slice(1)] = a[key]; + else n.setAttribute(key, a[key]); + } + } + return n; + } + + function showConfirm(cm, template) { + var pre = hdom('span', {$color: 'red', $whiteSpace: 'pre', class: 'cm-vim-message'}, template); //ace_patch span instead of pre if (cm.openNotification) { - cm.openNotification('' + text + '', - {bottom: true, duration: 5000}); + cm.openNotification(pre, {bottom: true, duration: 5000}); } else { - alert(text); + alert(pre.innerText); } } + function makePrompt(prefix, desc) { - var raw = '' + - (prefix || "") + ''; - if (desc) - raw += ' ' + desc + ''; - return raw; + return hdom(document.createDocumentFragment(), + hdom('span', {$fontFamily: 'monospace', $whiteSpace: 'pre'}, + prefix, + hdom('input', {type: 'text', autocorrect: 'off', + autocapitalize: 'off', spellcheck: 'false'})), + desc && hdom('span', {$color: '#888'}, desc)); } - var searchPromptDesc = '(Javascript regexp)'; + function showPrompt(cm, options) { - var shortText = (options.prefix || '') + ' ' + (options.desc || ''); - var prompt = makePrompt(options.prefix, options.desc); - dialog(cm, prompt, shortText, options.onClose, options); + var template = makePrompt(options.prefix, options.desc); + if (cm.openDialog) { + cm.openDialog(template, options.onClose, { + onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp, + bottom: true, selectValueOnOpen: false, value: options.value + }); + } + else { + var shortText = ''; + if (typeof options.prefix != "string" && options.prefix) shortText += options.prefix.textContent; + if (options.desc) shortText += " " + options.desc; + options.onClose(prompt(shortText, '')); + } } + function regexEqual(r1, r2) { if (r1 instanceof RegExp && r2 instanceof RegExp) { var props = ['global', 'multiline', 'ignoreCase', 'source']; @@ -4558,10 +4847,17 @@ dom.importCssString(".normal-mode .ace_cursor{\ var cursor = cm.getSearchCursor(query, pos); for (var i = 0; i < repeat; i++) { var found = cursor.find(prev); - if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); } + if (i == 0 && found && cursorEqual(cursor.from(), pos)) { + var lastEndPos = prev ? cursor.from() : cursor.to(); + found = cursor.find(prev); + if (found && !found[0] && cursorEqual(cursor.from(), lastEndPos)) { + if (cm.getLine(lastEndPos.line).length == lastEndPos.ch) + found = cursor.find(prev); + } + } if (!found) { cursor = cm.getSearchCursor(query, - (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) ); + (prev) ? new Pos(cm.lastLine()) : new Pos(cm.firstLine(), 0) ); if (!cursor.find(prev)) { return; } @@ -4570,6 +4866,29 @@ dom.importCssString(".normal-mode .ace_cursor{\ return cursor.from(); }); } + function findNextFromAndToInclusive(cm, prev, query, repeat, vim) { + if (repeat === undefined) { repeat = 1; } + return cm.operation(function() { + var pos = cm.getCursor(); + var cursor = cm.getSearchCursor(query, pos); + var found = cursor.find(!prev); + if (!vim.visualMode && found && cursorEqual(cursor.from(), pos)) { + cursor.find(!prev); + } + + for (var i = 0; i < repeat; i++) { + found = cursor.find(prev); + if (!found) { + cursor = cm.getSearchCursor(query, + (prev) ? new Pos(cm.lastLine()) : new Pos(cm.firstLine(), 0) ); + if (!cursor.find(prev)) { + return; + } + } + } + return [cursor.from(), cursor.to()]; + }); + } function clearSearchHighlight(cm) { var state = getSearchState(cm); cm.removeOverlay(getSearchState(cm).getOverlay()); @@ -4586,7 +4905,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (start instanceof Array) { return inArray(pos, start); } else { - if (end) { + if (typeof end == 'number') { return (pos >= start && pos <= end); } else { return pos == start; @@ -4603,7 +4922,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ function getMarkPos(cm, vim, markName) { if (markName == '\'' || markName == '`') { - return vimGlobalState.jumpList.find(cm, -1) || Pos(0, 0); + return vimGlobalState.jumpList.find(cm, -1) || new Pos(0, 0); } else if (markName == '.') { return getLastEditPos(cm); } @@ -4643,7 +4962,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ try { this.parseInput_(cm, inputStream, params); } catch(e) { - showConfirm(cm, e); + showConfirm(cm, e.toString()); throw e; } var command; @@ -4662,7 +4981,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ this.parseCommandArgs_(inputStream, params, command); if (command.type == 'exToKey') { for (var i = 0; i < command.toKeys.length; i++) { - CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping'); + vimApi.handleKey(cm, command.toKeys[i], 'mapping'); } return; } else if (command.type == 'exToEx') { @@ -4681,7 +5000,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ params.callback(); } } catch(e) { - showConfirm(cm, e); + showConfirm(cm, e.toString()); throw e; } }, @@ -4696,7 +5015,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ result.lineEnd = this.parseLineSpec_(cm, inputStream); } } - var commandMatch = inputStream.match(/^(\w+)/); + var commandMatch = inputStream.match(/^(\w+|!!|@@|[!#&*<=>@~])/); if (commandMatch) { result.commandName = commandMatch[1]; } else { @@ -4817,7 +5136,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var commandName = lhs.substring(1); if (this.commandMap_[commandName] && this.commandMap_[commandName].user) { delete this.commandMap_[commandName]; - return; + return true; } } else { var keys = lhs; @@ -4825,7 +5144,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (keys == defaultKeymap[i].keys && defaultKeymap[i].context === ctx) { defaultKeymap.splice(i, 1); - return; + return true; } } } @@ -4855,13 +5174,11 @@ dom.importCssString(".normal-mode .ace_cursor{\ vmap: function(cm, params) { this.map(cm, params, 'visual'); }, unmap: function(cm, params, ctx) { var mapArgs = params.args; - if (!mapArgs || mapArgs.length < 1) { + if (!mapArgs || mapArgs.length < 1 || !exCommandDispatcher.unmap(mapArgs[0], ctx)) { if (cm) { showConfirm(cm, 'No such mapping: ' + params.input); } - return; } - exCommandDispatcher.unmap(mapArgs[0], ctx); }, move: function(cm, params) { commandDispatcher.processCommand(cm, cm.state.vim, { @@ -4926,12 +5243,12 @@ dom.importCssString(".normal-mode .ace_cursor{\ registers: function(cm, params) { var regArgs = params.args; var registers = vimGlobalState.registerController.registers; - var regInfo = '----------Registers----------

'; + var regInfo = '----------Registers----------\n\n'; if (!regArgs) { for (var registerName in registers) { var text = registers[registerName].toString(); if (text.length) { - regInfo += '"' + registerName + ' ' + text + '
'; + regInfo += '"' + registerName + ' ' + text + '\n' } } } else { @@ -4943,7 +5260,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ continue; } var register = registers[registerName] || new Register(); - regInfo += '"' + registerName + ' ' + register.toString() + '
'; + regInfo += '"' + registerName + ' ' + register.toString() + '\n' } } showConfirm(cm, regInfo); @@ -4980,8 +5297,8 @@ dom.importCssString(".normal-mode .ace_cursor{\ var lineStart = params.line || cm.firstLine(); var lineEnd = params.lineEnd || params.line || cm.lastLine(); if (lineStart == lineEnd) { return; } - var curStart = Pos(lineStart, 0); - var curEnd = Pos(lineEnd, lineLength(cm, lineEnd)); + var curStart = new Pos(lineStart, 0); + var curEnd = new Pos(lineEnd, lineLength(cm, lineEnd)); var text = cm.getRange(curStart, curEnd).split('\n'); var numberRegex = pattern ? pattern : (number == 'decimal') ? /(-?)([\d]+)/ : @@ -5038,12 +5355,16 @@ dom.importCssString(".normal-mode .ace_cursor{\ } cm.replaceRange(text.join('\n'), curStart, curEnd); }, + vglobal: function(cm, params) { + this.global(cm, params); + }, global: function(cm, params) { var argString = params.argString; if (!argString) { showConfirm(cm, 'Regular Expression missing from global'); return; } + var inverted = params.commandName[0] === 'v'; var lineStart = (params.line !== undefined) ? params.line : cm.firstLine(); var lineEnd = params.lineEnd || params.line || cm.lastLine(); var tokens = splitBySlash(argString); @@ -5062,27 +5383,32 @@ dom.importCssString(".normal-mode .ace_cursor{\ } } var query = getSearchState(cm).getQuery(); - var matchedLines = [], content = ''; + var matchedLines = []; for (var i = lineStart; i <= lineEnd; i++) { - var matched = query.test(cm.getLine(i)); - if (matched) { - matchedLines.push(i+1); - content+= cm.getLine(i) + '
'; + var line = cm.getLineHandle(i); + var matched = query.test(line.text); + if (matched !== inverted) { + matchedLines.push(cmd ? line : line.text); } } if (!cmd) { - showConfirm(cm, content); + showConfirm(cm, matchedLines.join('\n')); return; } var index = 0; var nextCommand = function() { if (index < matchedLines.length) { - var command = matchedLines[index] + cmd; + var line = matchedLines[index++]; + var lineNum = cm.getLineNumber(line); + if (lineNum == null) { + nextCommand(); + return; + } + var command = (lineNum + 1) + cmd; exCommandDispatcher.processCommand(cm, command, { callback: nextCommand }); } - index++; }; nextCommand(); }, @@ -5102,10 +5428,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ regexPart = new RegExp(regexPart).source; //normalize not escaped characters } replacePart = tokens[1]; - if (regexPart && regexPart[regexPart.length - 1] === '$') { - regexPart = regexPart.slice(0, regexPart.length - 1) + '\\n'; - replacePart = replacePart ? replacePart + '\n' : '\n'; - } if (replacePart !== undefined) { if (getOption('pcre')) { replacePart = unescapeRegexReplace(replacePart.replace(/([^\\])&/g,"$1$$&")); @@ -5128,11 +5450,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (flagsPart) { if (flagsPart.indexOf('c') != -1) { confirm = true; - flagsPart.replace('c', ''); } if (flagsPart.indexOf('g') != -1) { global = true; - flagsPart.replace('g', ''); } if (getOption('pcre')) { regexPart = regexPart + '/' + flagsPart; @@ -5166,7 +5486,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ lineStart = lineEnd; lineEnd = lineStart + count - 1; } - var startPos = clipCursorToContent(cm, Pos(lineStart, 0)); + var startPos = clipCursorToContent(cm, new Pos(lineStart, 0)); var cursor = cm.getSearchCursor(query, startPos); doReplace(cm, confirm, global, lineStart, lineEnd, cursor, query, replacePart, params.callback); }, @@ -5243,7 +5563,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ replaceWith, callback) { cm.state.vim.exMode = true; var done = false; - var lastPos = searchCursor.from(); + var lastPos, modifiedLineNumber, joined; function replaceAll() { cm.operation(function() { while (!done) { @@ -5256,12 +5576,24 @@ dom.importCssString(".normal-mode .ace_cursor{\ function replace() { var text = cm.getRange(searchCursor.from(), searchCursor.to()); var newText = text.replace(query, replaceWith); + var unmodifiedLineNumber = searchCursor.to().line; searchCursor.replace(newText); + modifiedLineNumber = searchCursor.to().line; + lineEnd += modifiedLineNumber - unmodifiedLineNumber; + joined = modifiedLineNumber < unmodifiedLineNumber; + } + function findNextValidMatch() { + var lastMatchTo = lastPos && copyCursor(searchCursor.to()); + var match = searchCursor.findNext(); + if (match && !match[0] && lastMatchTo && cursorEqual(searchCursor.from(), lastMatchTo)) { + match = searchCursor.findNext(); + } + return match; } function next() { - while(searchCursor.findNext() && + while(findNextValidMatch() && isInRange(searchCursor.from(), lineStart, lineEnd)) { - if (!global && lastPos && searchCursor.from().line == lastPos.line) { + if (!global && searchCursor.from().line == modifiedLineNumber && !joined) { continue; } cm.scrollIntoView(searchCursor.from(), 30); @@ -5320,7 +5652,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ return; } showPrompt(cm, { - prefix: 'replace with ' + replaceWith + ' (y/n/a/q/l)', + prefix: hdom('span', 'replace with ', hdom('strong', replaceWith), ' (y/n/a/q/l)'), onKeyDown: onPromptKeyDown }); } @@ -5408,7 +5740,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ match = (/<\w+-.+?>|<\w+>|./).exec(text); key = match[0]; text = text.substring(match.index + key.length); - CodeMirror.Vim.handleKey(cm, key, 'macro'); + vimApi.handleKey(cm, key, 'macro'); if (vim.insertMode) { var changes = register.insertModeChanges[imc++].changes; vimGlobalState.macroModeState.lastInsertModeChanges.changes = @@ -5491,18 +5823,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ } else if (!cm.curOp.isVimOp) { handleExternalSelection(cm, vim); } - if (vim.visualMode) { - updateFakeCursor(cm); - } - } - function updateFakeCursor(cm) { - var vim = cm.state.vim; - var from = clipCursorToContent(cm, copyCursor(vim.sel.head)); - var to = offsetCursor(from, 0, 1); - if (vim.fakeCursor) { - vim.fakeCursor.clear(); - } - vim.fakeCursor = cm.markText(from, to, {className: 'cm-animate-fat-cursor'}); } function handleExternalSelection(cm, vim, keepHPos) { var anchor = cm.getCursor('anchor'); @@ -5612,12 +5932,12 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (change instanceof InsertModeKey) { CodeMirror.lookupKey(change.keyName, 'vim-insert', keyHandler); } else if (typeof change == "string") { - var cur = cm.getCursor(); - cm.replaceRange(change, cur, cur); + cm.replaceSelection(change); } else { var start = cm.getCursor(); var end = offsetCursor(start, 0, change[0].length); cm.replaceRange(change[0], start, end); + cm.setCursor(end); } } } @@ -5632,7 +5952,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ Vim = CodeMirror.Vim; var specialKey = {'return':'CR',backspace:'BS','delete':'Del',esc:'Esc', - left:'Left',right:'Right',up:'Up',down:'Down',space: 'Space', + left:'Left',right:'Right',up:'Up',down:'Down',space: 'Space',insert: 'Ins', home:'Home',end:'End',pageup:'PageUp',pagedown:'PageDown', enter: 'CR' }; function lookupKey(hashId, key, e) { @@ -5684,7 +6004,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ } else if (wasMultiselect && vim.visualBlock) { vim.wasInVisualBlock = true; } - + if (key == '' && !vim.insertMode && !vim.visualMode && wasMultiselect) { cm.ace.exitMultiSelectMode(); } else if (visualBlock || !wasMultiselect || cm.ace.inVirtualSelectionMode) { @@ -5703,7 +6023,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ anchor = offsetCursor(anchor, 0, anchorOffset); cm.state.vim.sel.head = head; cm.state.vim.sel.anchor = anchor; - + isHandled = handleKey(cm, key, origin); sel.$desiredColumn = cm.state.vim.lastHPos == -1 ? null : cm.state.vim.lastHPos; if (cm.virtualSelectionMode()) { @@ -5730,12 +6050,12 @@ dom.importCssString(".normal-mode .ace_cursor{\ var top = pixelPos.top; var left = pixelPos.left; if (!vim.insertMode) { - var isbackwards = !sel.cursor + var isbackwards = !sel.cursor ? session.selection.isBackwards() || session.selection.isEmpty() : Range.comparePoints(sel.cursor, sel.start) <= 0; if (!isbackwards && left > w) left -= w; - } + } if (!vim.insertMode && vim.status) { h = h / 2; top += h; @@ -5775,21 +6095,26 @@ dom.importCssString(".normal-mode .ace_cursor{\ data.inputChar = data.inputKey = null; } } + + if (cm.state.overwrite && vim.insertMode && key == "backspace" && hashId == 0) { + return {command: "gotoleft"} + } if (key == "c" && hashId == 1) { // key == "ctrl-c" if (!useragent.isMac && editor.getCopyText()) { editor.once("copy", function() { - editor.selection.clearSelection(); + if (vim.insertMode) editor.selection.clearSelection(); + else cm.operation(function() { exitVisualMode(cm); }); }); return {command: "null", passEvent: true}; } } - + if (key == "esc" && !vim.insertMode && !vim.visualMode && !cm.ace.inMultiSelectMode) { var searchState = getSearchState(cm); var overlay = searchState.getOverlay(); if (overlay) cm.removeOverlay(overlay); } - + if (hashId == -1 || hashId & 1 || hashId === 0 && key.length > 1) { var insertMode = vim.insertMode; var name = lookupKey(hashId, key, e || {}); @@ -5887,7 +6212,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ { keys: 'zA', type: 'action', action: 'fold', actionArgs: { toggle: true, all: true } }, { keys: 'zf', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, { keys: 'zd', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, - + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorAbove" } }, { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorBelow" } }, { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorAboveSkipCurrent" } }, @@ -5897,6 +6222,34 @@ dom.importCssString(".normal-mode .ace_cursor{\ { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectNextBefore" } }, { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectNextAfter" } } ); + + defaultKeymap.push({ + keys: 'gq', + type: 'operator', + operator: 'hardWrap' + }); + Vim.defineOperator("hardWrap", function(cm, operatorArgs, ranges, oldAnchor, newHead) { + var anchor = ranges[0].anchor.line; + var head = ranges[0].head.line; + if (operatorArgs.linewise) head--; + hardWrap(cm.ace, {startRow: anchor, endRow: head}); + return Pos(head, 0); + }); + defineOption('textwidth', undefined, 'number', ['tw'], function(width, cm) { + if (cm === undefined) { + return; + } + if (width === undefined) { + var value = cm.ace.getOption('printMarginColumn'); + return value; + } else { + var column = Math.round(width); + if (column > 1) { + cm.ace.setOption('printMarginColumn', column); + } + } + }); + actions.aceCommand = function(cm, actionArgs, vim) { cm.vimCmd = actionArgs; if (cm.ace.inVirtualSelectionMode) diff --git a/htdocs/includes/ace/src/keybinding-vscode.js b/htdocs/includes/ace/src/keybinding-vscode.js index 45ac5cf03ff..5ab34483c33 100644 --- a/htdocs/includes/ace/src/keybinding-vscode.js +++ b/htdocs/includes/ace/src/keybinding-vscode.js @@ -116,7 +116,7 @@ exports.handler.addCommands([{ [{ - bindKey: {mac: "Control-G", win: "Ctrl-G"}, + bindKey: {mac: "Ctrl-G", win: "Ctrl-G"}, name: "gotoline" }, { bindKey: {mac: "Command-Shift-L|Command-F2", win: "Ctrl-Shift-L|Ctrl-F2"}, @@ -158,10 +158,10 @@ exports.handler.addCommands([{ bindKey: {mac: "Command-[", win: "Ctrl-["}, name: "blockoutdent" }, { - bindKey: {mac: "Control-PageDown", win: "Alt-PageDown"}, + bindKey: {mac: "Ctrl-PageDown", win: "Alt-PageDown"}, name: "pagedown" }, { - bindKey: {mac: "Control-PageUp", win: "Alt-PageUp"}, + bindKey: {mac: "Ctrl-PageUp", win: "Alt-PageUp"}, name: "pageup" }, { bindKey: {mac: "Shift-Option-A", win: "Shift-Alt-A"}, diff --git a/htdocs/includes/ace/src/mode-abc.js b/htdocs/includes/ace/src/mode-abc.js index 94cb1605ec2..a1dd531b807 100644 --- a/htdocs/includes/ace/src/mode-abc.js +++ b/htdocs/includes/ace/src/mode-abc.js @@ -254,7 +254,10 @@ define("ace/mode/abc",["require","exports","module","ace/lib/oop","ace/mode/text oop.inherits(Mode, TextMode); (function () { + this.lineCommentStart = "%"; + this.$id = "ace/mode/abc"; + this.snippetFileId = "ace/snippets/abc"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-actionscript.js b/htdocs/includes/ace/src/mode-actionscript.js index f23c9d3ceb4..d9e6634b0d7 100644 --- a/htdocs/includes/ace/src/mode-actionscript.js +++ b/htdocs/includes/ace/src/mode-actionscript.js @@ -261,6 +261,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "//"; this.blockComment = {start: "/*", end: "*/"}; this.$id = "ace/mode/actionscript"; + this.snippetFileId = "ace/snippets/actionscript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-alda.js b/htdocs/includes/ace/src/mode-alda.js new file mode 100644 index 00000000000..72470be79d0 --- /dev/null +++ b/htdocs/includes/ace/src/mode-alda.js @@ -0,0 +1,311 @@ +define("ace/mode/alda_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + var AldaHighlightRules = function() { + + this.$rules = { + pitch: [{ + token: "variable.parameter.operator.pitch.alda", + regex: /(?:[+\-]+|\=)/ + }, { + token: "", + regex: "", + next: "timing" + }], + timing: [{ + token: "string.quoted.operator.timing.alda", + regex: /\d+(?:s|ms)?/ + }, { + token: "", + regex: "", + next: "start" + }], + start: [{ + token: [ + "constant.language.instrument.alda", + "constant.language.instrument.alda", + "meta.part.call.alda", + "storage.type.nickname.alda", + "meta.part.call.alda" + ], + regex: /^([a-zA-Z]{2}[\w\-+\'()]*)((?:\s*\/\s*[a-zA-Z]{2}[\w\-+\'()]*)*)(?:(\s*)(\"[a-zA-Z]{2}[\w\-+\'()]*\"))?(\s*:)/ + }, { + token: [ + "text", + "entity.other.inherited-class.voice.alda", + "text" + ], + regex: /^(\s*)(V\d+)(:)/ + }, { + token: "comment.line.number-sign.alda", + regex: /#.*$/ + }, { + token: "entity.name.function.pipe.measure.alda", + regex: /\|/ + }, { + token: "comment.block.inline.alda", + regex: /\(comment\b/, + push: [{ + token: "comment.block.inline.alda", + regex: /\)/, + next: "pop" + }, { + defaultToken: "comment.block.inline.alda" + }] + }, { + token: "entity.name.function.marker.alda", + regex: /%[a-zA-Z]{2}[\w\-+\'()]*/ + }, { + token: "entity.name.function.at-marker.alda", + regex: /@[a-zA-Z]{2}[\w\-+\'()]*/ + }, { + token: "keyword.operator.octave-change.alda", + regex: /\bo\d+\b/ + }, { + token: "keyword.operator.octave-shift.alda", + regex: /[><]/ + }, { + token: "keyword.operator.repeat.alda", + regex: /\*\s*\d+/ + }, { + token: "string.quoted.operator.timing.alda", + regex: /[.]|r\d*(?:s|ms)?/ + },{ + token: "text", + regex: /([cdefgab])/, + next: "pitch" + }, { + token: "string.quoted.operator.timing.alda", + regex: /~/, + next: "timing" + }, { + token: "punctuation.section.embedded.cram.alda", + regex: /\}/, + next: "timing" + }, { + token: "constant.numeric.subchord.alda", + regex: /\// + }, { + todo: { + token: "punctuation.section.embedded.cram.alda", + regex: /\{/, + push: [{ + token: "punctuation.section.embedded.cram.alda", + regex: /\}/, + next: "pop" + }, { + include: "$self" + }] + } + }, { + todo: { + token: "keyword.control.sequence.alda", + regex: /\[/, + push: [{ + token: "keyword.control.sequence.alda", + regex: /\]/, + next: "pop" + }, { + include: "$self" + }] + } + }, { + token: "meta.inline.clojure.alda", + regex: /\(/, + push: [{ + token: "meta.inline.clojure.alda", + regex: /\)/, + next: "pop" + }, { + include: "source.clojure" + }, { + defaultToken: "meta.inline.clojure.alda" + }] + }] + }; + + this.normalizeRules(); + }; + + AldaHighlightRules.metaData = { + scopeName: "source.alda", + fileTypes: ["alda"], + name: "Alda" + }; + + + oop.inherits(AldaHighlightRules, TextHighlightRules); + + exports.AldaHighlightRules = AldaHighlightRules; + }); + +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/alda",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/alda_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var AldaHighlightRules = require("./alda_highlight_rules").AldaHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = AldaHighlightRules; + this.foldingRules = new FoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.$id = "ace/mode/alda"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); (function() { + window.require(["ace/mode/alda"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-asl.js b/htdocs/includes/ace/src/mode-asl.js index 58c82631449..955838a94b4 100644 --- a/htdocs/includes/ace/src/mode-asl.js +++ b/htdocs/includes/ace/src/mode-asl.js @@ -58,16 +58,7 @@ define("ace/mode/asl_highlight_rules",["require","exports","module","ace/lib/oop var ASLHighlightRules = function() { var keywords = ( "Default|DefinitionBlock|Device|Method|Else|ElseIf|For|Function|If|Include|Method|Return|" + - "Scope|Switch|Case|While|Break|BreakPoint|Continue|NoOp|Wait" - ); - - var keywordOperators = ( - "Add|And|Decrement|Divide|Increment|Index|LAnd|LEqual|LGreater|LGreaterEqual|" + - "LLess|LLessEqual|LNot|LNotEqual|LOr|Mod|Multiply|NAnd|NOr|Not|Or|RefOf|Revision|" + - "ShiftLeft|ShiftRight|Subtract|XOr|DerefOf" - ); - - var buildinFunctions = ( + "Scope|Switch|Case|While|Break|BreakPoint|Continue|NoOp|Wait|True|False|" + "AccessAs|Acquire|Alias|BankField|Buffer|Concatenate|ConcatenateResTemplate|" + "CondRefOf|Connection|CopyObject|CreateBitField|CreateByteField|CreateDWordField|" + "CreateField|CreateQWordField|CreateWordField|DataTableRegion|Debug|" + @@ -83,6 +74,12 @@ define("ace/mode/asl_highlight_rules",["require","exports","module","ace/lib/oop "WordSpace" ); + var keywordOperators = ( + "Add|And|Decrement|Divide|Increment|Index|LAnd|LEqual|LGreater|LGreaterEqual|" + + "LLess|LLessEqual|LNot|LNotEqual|LOr|Mod|Multiply|NAnd|NOr|Not|Or|RefOf|Revision|" + + "ShiftLeft|ShiftRight|Subtract|XOr|DerefOf" + ); + var flags = ( "AttribQuick|AttribSendReceive|AttribByte|AttribBytes|AttribRawBytes|" + "AttribRawProcessBytes|AttribWord|AttribBlock|AttribProcessCall|AttribBlockProcessCall|" + @@ -121,21 +118,25 @@ define("ace/mode/asl_highlight_rules",["require","exports","module","ace/lib/oop "ThermalZoneObj|BuffFieldObj|DDBHandleObj" ); - var buildinConstants = ( + var builtinConstants = ( "__FILE__|__PATH__|__LINE__|__DATE__|__IASL__" ); + var strNumbers = ( + "One|Ones|Zero" + ); + var deprecated = ( "Memory24|Processor" ); var keywordMapper = this.createKeywordMapper({ "keyword": keywords, + "constant.numeric": strNumbers, "keyword.operator": keywordOperators, - "function.buildin": buildinFunctions, - "constant.language": buildinConstants, + "constant.language": builtinConstants, "storage.type": storageTypes, - "constant.character": flags, + "constant.library": flags, "invalid.deprecated": deprecated }, "identifier"); @@ -174,13 +175,13 @@ define("ace/mode/asl_highlight_rules",["require","exports","module","ace/lib/oop regex : /0[xX][0-9a-fA-F]+\b/ }, { token : "constant.numeric", - regex : /(One(s)?|Zero|True|False|[0-9]+)\b/ + regex : /[0-9]+\b/ }, { token : keywordMapper, regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { token : "keyword.operator", - regex : "/|!|\\$|%|&|\\||\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|\\^|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\|=" + regex : /[!\~\*\/%+-<>\^|=&]/ }, { token : "lparen", regex : "[[({]" diff --git a/htdocs/includes/ace/src/mode-bro.js b/htdocs/includes/ace/src/mode-bro.js deleted file mode 100644 index 86521764689..00000000000 --- a/htdocs/includes/ace/src/mode-bro.js +++ /dev/null @@ -1,334 +0,0 @@ -define("ace/mode/bro_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { -"use strict"; - -var oop = require("../lib/oop"); -var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; - -var BroHighlightRules = function() { - - this.$rules = { - start: [{ - token: "punctuation.definition.comment.bro", - regex: /#/, - push: [{ - token: "comment.line.number-sign.bro", - regex: /$/, - next: "pop" - }, { - defaultToken: "comment.line.number-sign.bro" - }] - }, { - token: "keyword.control.bro", - regex: /\b(?:break|case|continue|else|for|if|return|switch|next|when|timeout|schedule)\b/ - }, { - token: [ - "meta.function.bro", - "meta.function.bro", - "storage.type.bro", - "meta.function.bro", - "entity.name.function.bro", - "meta.function.bro" - ], - regex: /^(\s*)(?:function|hook|event)(\s*)(.*)(\s*\()(.*)(\).*$)/ - }, { - token: "storage.type.bro", - regex: /\b(?:bool|enum|double|int|count|port|addr|subnet|any|file|interval|time|string|table|vector|set|record|pattern|hook)\b/ - }, { - token: "storage.modifier.bro", - regex: /\b(?:global|const|redef|local|&(?:optional|rotate_interval|rotate_size|add_func|del_func|expire_func|expire_create|expire_read|expire_write|persistent|synchronized|encrypt|mergeable|priority|group|type_column|log|error_handler))\b/ - }, { - token: "keyword.operator.bro", - regex: /\s*(?:\||&&|(?:>|<|!)=?|==)\s*|\b!?in\b/ - }, { - token: "constant.language.bro", - regex: /\b(?:T|F)\b/ - }, { - token: "constant.numeric.bro", - regex: /\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:(?:e|E)(?:\+|-)?[0-9]+)?)(?:\/(?:tcp|udp|icmp)|\s*(?:u?sec|min|hr|day)s?)?\b/ - }, { - token: "punctuation.definition.string.begin.bro", - regex: /"/, - push: [{ - token: "punctuation.definition.string.end.bro", - regex: /"/, - next: "pop" - }, { - include: "#string_escaped_char" - }, { - include: "#string_placeholder" - }, { - defaultToken: "string.quoted.double.bro" - }] - }, { - token: "punctuation.definition.string.begin.bro", - regex: /\//, - push: [{ - token: "punctuation.definition.string.end.bro", - regex: /\//, - next: "pop" - }, { - include: "#string_escaped_char" - }, { - include: "#string_placeholder" - }, { - defaultToken: "string.quoted.regex.bro" - }] - }, { - token: [ - "meta.preprocessor.bro.load", - "keyword.other.special-method.bro" - ], - regex: /^(\s*)(\@load(?:-sigs)?)\b/, - push: [{ - token: [], - regex: /(?=\#)|$/, - next: "pop" - }, { - defaultToken: "meta.preprocessor.bro.load" - }] - }, { - token: [ - "meta.preprocessor.bro.if", - "keyword.other.special-method.bro", - "meta.preprocessor.bro.if" - ], - regex: /^(\s*)(\@endif|\@if(?:n?def)?)(.*$)/, - push: [{ - token: [], - regex: /$/, - next: "pop" - }, { - defaultToken: "meta.preprocessor.bro.if" - }] - }], - "#disabled": [{ - token: "text", - regex: /^\s*\@if(?:n?def)?\b.*$/, - push: [{ - token: "text", - regex: /^\s*\@endif\b.*$/, - next: "pop" - }, { - include: "#disabled" - }, { - include: "#pragma-mark" - }], - comment: "eat nested preprocessor ifdefs" - }], - "#preprocessor-rule-other": [{ - token: [ - "text", - "meta.preprocessor.bro", - "meta.preprocessor.bro", - "text" - ], - regex: /^(\s*)(@if)((?:n?def)?)\b(.*?)(?:(?=)|$)/, - push: [{ - token: ["text", "meta.preprocessor.bro", "text"], - regex: /^(\s*)(@endif)\b(.*$)/, - next: "pop" - }, { - include: "$base" - }] - }], - "#string_escaped_char": [{ - token: "constant.character.escape.bro", - regex: /\\(?:\\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2})/ - }, { - token: "invalid.illegal.unknown-escape.bro", - regex: /\\./ - }], - "#string_placeholder": [{ - token: "constant.other.placeholder.bro", - regex: /%(?:\d+\$)?[#0\- +']*[,;:_]?(?:-?\d+|\*(?:-?\d+\$)?)?(?:\.(?:-?\d+|\*(?:-?\d+\$)?)?)?(?:hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?[diouxXDOUeEfFgGaACcSspn%]/ - }, { - token: "invalid.illegal.placeholder.bro", - regex: /%/ - }] - }; - - this.normalizeRules(); -}; - -BroHighlightRules.metaData = { - fileTypes: ["bro"], - foldingStartMarker: "^(\\@if(n?def)?)", - foldingStopMarker: "^\\@endif", - keyEquivalent: "@B", - name: "Bro", - scopeName: "source.bro" -}; - - -oop.inherits(BroHighlightRules, TextHighlightRules); - -exports.BroHighlightRules = BroHighlightRules; -}); - -define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { -"use strict"; - -var oop = require("../../lib/oop"); -var Range = require("../../range").Range; -var BaseFoldMode = require("./fold_mode").FoldMode; - -var FoldMode = exports.FoldMode = function(commentRegex) { - if (commentRegex) { - this.foldingStartMarker = new RegExp( - this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) - ); - this.foldingStopMarker = new RegExp( - this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) - ); - } -}; -oop.inherits(FoldMode, BaseFoldMode); - -(function() { - - this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; - this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; - this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; - this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; - this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; - this._getFoldWidgetBase = this.getFoldWidget; - this.getFoldWidget = function(session, foldStyle, row) { - var line = session.getLine(row); - - if (this.singleLineBlockCommentRe.test(line)) { - if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) - return ""; - } - - var fw = this._getFoldWidgetBase(session, foldStyle, row); - - if (!fw && this.startRegionRe.test(line)) - return "start"; // lineCommentRegionStart - - return fw; - }; - - this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { - var line = session.getLine(row); - - if (this.startRegionRe.test(line)) - return this.getCommentRegionBlock(session, line, row); - - var match = line.match(this.foldingStartMarker); - if (match) { - var i = match.index; - - if (match[1]) - return this.openingBracketBlock(session, match[1], row, i); - - var range = session.getCommentFoldRange(row, i + match[0].length, 1); - - if (range && !range.isMultiLine()) { - if (forceMultiline) { - range = this.getSectionRange(session, row); - } else if (foldStyle != "all") - range = null; - } - - return range; - } - - if (foldStyle === "markbegin") - return; - - var match = line.match(this.foldingStopMarker); - if (match) { - var i = match.index + match[0].length; - - if (match[1]) - return this.closingBracketBlock(session, match[1], row, i); - - return session.getCommentFoldRange(row, i, -1); - } - }; - - this.getSectionRange = function(session, row) { - var line = session.getLine(row); - var startIndent = line.search(/\S/); - var startRow = row; - var startColumn = line.length; - row = row + 1; - var endRow = row; - var maxRow = session.getLength(); - while (++row < maxRow) { - line = session.getLine(row); - var indent = line.search(/\S/); - if (indent === -1) - continue; - if (startIndent > indent) - break; - var subRange = this.getFoldWidgetRange(session, "all", row); - - if (subRange) { - if (subRange.start.row <= startRow) { - break; - } else if (subRange.isMultiLine()) { - row = subRange.end.row; - } else if (startIndent == indent) { - break; - } - } - endRow = row; - } - - return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); - }; - this.getCommentRegionBlock = function(session, line, row) { - var startColumn = line.search(/\s*$/); - var maxRow = session.getLength(); - var startRow = row; - - var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; - var depth = 1; - while (++row < maxRow) { - line = session.getLine(row); - var m = re.exec(line); - if (!m) continue; - if (m[1]) depth--; - else depth++; - - if (!depth) break; - } - - var endRow = row; - if (endRow > startRow) { - return new Range(startRow, startColumn, endRow, line.length); - } - }; - -}).call(FoldMode.prototype); - -}); - -define("ace/mode/bro",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/bro_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) { -"use strict"; - -var oop = require("../lib/oop"); -var TextMode = require("./text").Mode; -var BroHighlightRules = require("./bro_highlight_rules").BroHighlightRules; -var FoldMode = require("./folding/cstyle").FoldMode; - -var Mode = function() { - this.HighlightRules = BroHighlightRules; - this.foldingRules = new FoldMode(); -}; -oop.inherits(Mode, TextMode); - -(function() { - this.$id = "ace/mode/bro"; -}).call(Mode.prototype); - -exports.Mode = Mode; -}); (function() { - window.require(["ace/mode/bro"], function(m) { - if (typeof module == "object" && typeof exports == "object" && module) { - module.exports = m; - } - }); - })(); - \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-c_cpp.js b/htdocs/includes/ace/src/mode-c_cpp.js index 4e653ebe028..da730717d6c 100644 --- a/htdocs/includes/ace/src/mode-c_cpp.js +++ b/htdocs/includes/ace/src/mode-c_cpp.js @@ -65,7 +65,7 @@ var c_cppHighlightRules = function() { var storageType = ( "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + - "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" + + "_Imaginary|int|int8_t|int16_t|int32_t|int64_t|long|short|signed|size_t|struct|typedef|uint8_t|uint16_t|uint32_t|uint64_t|union|unsigned|void|" + "class|wchar_t|template|char16_t|char32_t" ); @@ -489,6 +489,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/c_cpp"; + this.snippetFileId = "ace/snippets/c_cpp"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-clojure.js b/htdocs/includes/ace/src/mode-clojure.js index 1f7f41841a7..dd10ec76dd2 100644 --- a/htdocs/includes/ace/src/mode-clojure.js +++ b/htdocs/includes/ace/src/mode-clojure.js @@ -301,6 +301,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/clojure"; + this.snippetFileId = "ace/snippets/clojure"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-coffee.js b/htdocs/includes/ace/src/mode-coffee.js index 75d19d4d3ff..063883c9f58 100644 --- a/htdocs/includes/ace/src/mode-coffee.js +++ b/htdocs/includes/ace/src/mode-coffee.js @@ -385,6 +385,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/coffee"; + this.snippetFileId = "ace/snippets/coffee"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-coldfusion.js b/htdocs/includes/ace/src/mode-coldfusion.js index 8b85c12e940..fcb742db282 100644 --- a/htdocs/includes/ace/src/mode-coldfusion.js +++ b/htdocs/includes/ace/src/mode-coldfusion.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-csound_document.js b/htdocs/includes/ace/src/mode-csound_document.js index ae92fce17e1..de242e5c184 100644 --- a/htdocs/includes/ace/src/mode-csound_document.js +++ b/htdocs/includes/ace/src/mode-csound_document.js @@ -300,7 +300,7 @@ var CsoundScoreHighlightRules = function(embeddedRulePrefix) { start.push( { token : "keyword.control.csound-score", - regex : /[abCdefiqstvxy]/ + regex : /[aBbCdefiqstvxy]/ }, { token : "invalid.illegal.csound-score", regex : /w/ @@ -935,10 +935,10 @@ var PythonHighlightRules = function() { regex: "\\s+" }, { token: "string", - regex: "'(.)*'" + regex: "'[^']*'" }, { token: "string", - regex: '"(.)*"' + regex: '"[^"]*"' }, { token: "function.support", regex: "(!s|!r|!a)" @@ -1141,6 +1141,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "adsynt", "adsynt2", "aftouch", + "allpole", "alpass", "alwayson", "ampdb", @@ -1148,11 +1149,17 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ampmidi", "ampmidicurve", "ampmidid", + "apoleparams", + "arduinoRead", + "arduinoReadF", + "arduinoStart", + "arduinoStop", "areson", "aresonk", "atone", "atonek", "atonex", + "autocorr", "babo", "balance", "balance2", @@ -1160,8 +1167,6 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "barmodel", "bbcutm", "bbcuts", - "beadsynt", - "beosc", "betarand", "bexprnd", "bformdec1", @@ -1170,6 +1175,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "biquad", "biquada", "birnd", + "bob", "bpf", "bpfcos", "bqrez", @@ -1195,6 +1201,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ceps", "cepsinv", "chanctrl", + "changed", "changed2", "chani", "chano", @@ -1206,11 +1213,19 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "chnclear", "chnexport", "chnget", + "chngeta", + "chngeti", + "chngetk", "chngetks", + "chngets", "chnmix", "chnparams", "chnset", + "chnseta", + "chnseti", + "chnsetk", "chnsetks", + "chnsets", "chuap", "clear", "clfilt", @@ -1219,6 +1234,13 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "clockon", "cmp", "cmplxprod", + "cntCreate", + "cntCycles", + "cntDelete", + "cntDelete_i", + "cntRead", + "cntReset", + "cntState", "comb", "combinv", "compilecsd", @@ -1238,6 +1260,8 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "cosseg", "cossegb", "cossegr", + "count", + "count_i", "cps2pch", "cpsmidi", "cpsmidib", @@ -1263,6 +1287,11 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ctrl21", "ctrl7", "ctrlinit", + "ctrlpreset", + "ctrlprint", + "ctrlprintpresets", + "ctrlsave", + "ctrlselect", "cuserrnd", "dam", "date", @@ -1408,6 +1437,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ftchnls", "ftconv", "ftcps", + "ftexists", "ftfree", "ftgen", "ftgenonce", @@ -1424,7 +1454,9 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ftsamplebank", "ftsave", "ftsavek", + "ftset", "ftslice", + "ftslicei", "ftsr", "gain", "gainslider", @@ -1441,7 +1473,6 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "getcol", "getftargs", "getrow", - "getrowlin", "getseed", "gogobel", "grain", @@ -1689,8 +1720,12 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "la_k_upper_solve_mr", "la_k_vc_set", "la_k_vr_set", + "lag", + "lagud", + "lastcycle", "lenarray", "lfo", + "lfsr", "limit", "limit1", "lincos", @@ -1734,6 +1769,8 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "lowpass2", "lowres", "lowresx", + "lpcanal", + "lpcfilter", "lpf18", "lpform", "lpfreson", @@ -1749,14 +1786,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "lpshold", "lpsholdp", "lpslot", - "lua_exec", - "lua_iaopcall", - "lua_iaopcall_off", - "lua_ikopcall", - "lua_ikopcall_off", - "lua_iopcall", - "lua_iopcall_off", - "lua_opdef", + "lufs", "mac", "maca", "madsr", @@ -1779,6 +1809,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "median", "mediank", "metro", + "metro2", "mfb", "midglobal", "midiarp", @@ -1831,6 +1862,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "mp3sr", "mpulse", "mrtmsg", + "ms2st", "mtof", "mton", "multitap", @@ -1840,6 +1872,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "mvclpf2", "mvclpf3", "mvclpf4", + "mvmfilter", "mxadsr", "nchnls_hw", "nestedap", @@ -1883,6 +1916,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "oscilx", "out", "out32", + "outall", "outc", "outch", "outh", @@ -1983,12 +2017,11 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "printk2", "printks", "printks2", + "println", "prints", + "printsk", "product", "pset", - "ptable", - "ptable3", - "ptablei", "ptablew", "ptrack", "puts", @@ -2005,6 +2038,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "pvsarp", "pvsbandp", "pvsbandr", + "pvsbandwidth", "pvsbin", "pvsblur", "pvsbuffer", @@ -2013,6 +2047,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "pvscale", "pvscent", "pvsceps", + "pvscfs", "pvscross", "pvsdemix", "pvsdiskin", @@ -2032,6 +2067,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "pvsinfo", "pvsinit", "pvslock", + "pvslpc", "pvsmaska", "pvsmix", "pvsmooth", @@ -2133,6 +2169,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "qnan", "r2c", "rand", + "randc", "randh", "randi", "random", @@ -2156,6 +2193,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "repluck", "reshapearray", "reson", + "resonbnk", "resonk", "resonr", "resonx", @@ -2173,6 +2211,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "rms", "rnd", "rnd31", + "rndseed", "round", "rspline", "rtclock", @@ -2185,14 +2224,17 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "sc_phasor", "sc_trig", "scale", + "scale2", "scalearray", "scanhammer", "scans", "scantable", "scanu", + "scanu2", "schedkwhen", "schedkwhennamed", "schedule", + "schedulek", "schedwhen", "scoreline", "scoreline_i", @@ -2238,6 +2280,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "sinh", "sininv", "sinsyn", + "skf", "sleighbells", "slicearray", "slicearray_i", @@ -2273,13 +2316,16 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "spat3di", "spat3dt", "spdist", + "spf", "splitrig", "sprintf", "sprintfk", "spsend", "sqrt", "squinewave", + "st2ms", "statevar", + "sterrain", "stix", "strcat", "strcatk", @@ -2303,6 +2349,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "strrindex", "strrindexk", "strset", + "strstrip", "strsub", "strsubk", "strtod", @@ -2317,6 +2364,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "sum", "sumarray", "svfilter", + "svn", "syncgrain", "syncloop", "syncphasor", @@ -2357,7 +2405,6 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "tabmorphi", "tabplay", "tabrec", - "tabrowlin", "tabsum", "tabw", "tabw_i", @@ -2389,7 +2436,11 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "trcross", "trfilter", "trhighest", + "trigExpseg", + "trigLinseg", "trigger", + "trighold", + "trigphasor", "trigseq", "trim", "trim_i", @@ -2401,6 +2452,8 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "trsplit", "turnoff", "turnoff2", + "turnoff2_i", + "turnoff3", "turnon", "tvconv", "unirand", @@ -2424,6 +2477,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "vbapz", "vbapzmove", "vcella", + "vclpf", "vco", "vco2", "vco2ft", @@ -2472,6 +2526,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "vpow_i", "vpowv", "vpowv_i", + "vps", "vpvoc", "vrandh", "vrandi", @@ -2511,6 +2566,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "wrap", "writescratch", "wterrain", + "wterrain2", "xadsr", "xin", "xout", @@ -2543,24 +2599,47 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "zkwm" ]; var deprecatedOpcodes = [ + "OSCsendA", "array", + "beadsynt", + "beosc", "bformdec", "bformenc", - "changed", + "buchla", "copy2ftab", "copy2ttab", + "getrowlin", "hrtfer", "ktableseg", "lentab", + "lua_exec", + "lua_iaopcall", + "lua_iaopcall_off", + "lua_ikopcall", + "lua_ikopcall_off", + "lua_iopcall", + "lua_iopcall_off", + "lua_opdef", "maxtab", "mintab", + "mp3scal_check", + "mp3scal_load", + "mp3scal_load2", + "mp3scal_play", + "mp3scal_play2", "pop", "pop_f", + "ptable", + "ptable3", + "ptablei", "ptableiw", "push", "push_f", + "pvsgendy", "scalet", + "signalflowgraph", "sndload", + "socksend_k", "soundout", "soundouts", "specaddm", @@ -2573,11 +2652,14 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "specsum", "spectrum", "stack", + "sumTableFilter", "sumtab", + "systime", "tabgen", "tableiw", "tabmap", "tabmap_i", + "tabrowlin", "tabslice", "tb0", "tb0_init", @@ -2612,6 +2694,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "tb9", "tb9_init", "vbap16", + "vbap1move", "vbap4", "vbap4move", "vbap8", @@ -4006,6 +4089,11 @@ var Mode = function() { }; oop.inherits(Mode, TextMode); +(function() { + this.$id = "ace/mode/csound_document"; + this.snippetFileId = "ace/snippets/csound_document"; +}).call(Mode.prototype); + exports.Mode = Mode; }); (function() { window.require(["ace/mode/csound_document"], function(m) { diff --git a/htdocs/includes/ace/src/mode-csound_orchestra.js b/htdocs/includes/ace/src/mode-csound_orchestra.js index 7cb3917c9f4..58f932eceee 100644 --- a/htdocs/includes/ace/src/mode-csound_orchestra.js +++ b/htdocs/includes/ace/src/mode-csound_orchestra.js @@ -300,7 +300,7 @@ var CsoundScoreHighlightRules = function(embeddedRulePrefix) { start.push( { token : "keyword.control.csound-score", - regex : /[abCdefiqstvxy]/ + regex : /[aBbCdefiqstvxy]/ }, { token : "invalid.illegal.csound-score", regex : /w/ @@ -935,10 +935,10 @@ var PythonHighlightRules = function() { regex: "\\s+" }, { token: "string", - regex: "'(.)*'" + regex: "'[^']*'" }, { token: "string", - regex: '"(.)*"' + regex: '"[^"]*"' }, { token: "function.support", regex: "(!s|!r|!a)" @@ -1141,6 +1141,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "adsynt", "adsynt2", "aftouch", + "allpole", "alpass", "alwayson", "ampdb", @@ -1148,11 +1149,17 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ampmidi", "ampmidicurve", "ampmidid", + "apoleparams", + "arduinoRead", + "arduinoReadF", + "arduinoStart", + "arduinoStop", "areson", "aresonk", "atone", "atonek", "atonex", + "autocorr", "babo", "balance", "balance2", @@ -1160,8 +1167,6 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "barmodel", "bbcutm", "bbcuts", - "beadsynt", - "beosc", "betarand", "bexprnd", "bformdec1", @@ -1170,6 +1175,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "biquad", "biquada", "birnd", + "bob", "bpf", "bpfcos", "bqrez", @@ -1195,6 +1201,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ceps", "cepsinv", "chanctrl", + "changed", "changed2", "chani", "chano", @@ -1206,11 +1213,19 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "chnclear", "chnexport", "chnget", + "chngeta", + "chngeti", + "chngetk", "chngetks", + "chngets", "chnmix", "chnparams", "chnset", + "chnseta", + "chnseti", + "chnsetk", "chnsetks", + "chnsets", "chuap", "clear", "clfilt", @@ -1219,6 +1234,13 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "clockon", "cmp", "cmplxprod", + "cntCreate", + "cntCycles", + "cntDelete", + "cntDelete_i", + "cntRead", + "cntReset", + "cntState", "comb", "combinv", "compilecsd", @@ -1238,6 +1260,8 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "cosseg", "cossegb", "cossegr", + "count", + "count_i", "cps2pch", "cpsmidi", "cpsmidib", @@ -1263,6 +1287,11 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ctrl21", "ctrl7", "ctrlinit", + "ctrlpreset", + "ctrlprint", + "ctrlprintpresets", + "ctrlsave", + "ctrlselect", "cuserrnd", "dam", "date", @@ -1408,6 +1437,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ftchnls", "ftconv", "ftcps", + "ftexists", "ftfree", "ftgen", "ftgenonce", @@ -1424,7 +1454,9 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "ftsamplebank", "ftsave", "ftsavek", + "ftset", "ftslice", + "ftslicei", "ftsr", "gain", "gainslider", @@ -1441,7 +1473,6 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "getcol", "getftargs", "getrow", - "getrowlin", "getseed", "gogobel", "grain", @@ -1689,8 +1720,12 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "la_k_upper_solve_mr", "la_k_vc_set", "la_k_vr_set", + "lag", + "lagud", + "lastcycle", "lenarray", "lfo", + "lfsr", "limit", "limit1", "lincos", @@ -1734,6 +1769,8 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "lowpass2", "lowres", "lowresx", + "lpcanal", + "lpcfilter", "lpf18", "lpform", "lpfreson", @@ -1749,14 +1786,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "lpshold", "lpsholdp", "lpslot", - "lua_exec", - "lua_iaopcall", - "lua_iaopcall_off", - "lua_ikopcall", - "lua_ikopcall_off", - "lua_iopcall", - "lua_iopcall_off", - "lua_opdef", + "lufs", "mac", "maca", "madsr", @@ -1779,6 +1809,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "median", "mediank", "metro", + "metro2", "mfb", "midglobal", "midiarp", @@ -1831,6 +1862,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "mp3sr", "mpulse", "mrtmsg", + "ms2st", "mtof", "mton", "multitap", @@ -1840,6 +1872,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "mvclpf2", "mvclpf3", "mvclpf4", + "mvmfilter", "mxadsr", "nchnls_hw", "nestedap", @@ -1883,6 +1916,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "oscilx", "out", "out32", + "outall", "outc", "outch", "outh", @@ -1983,12 +2017,11 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "printk2", "printks", "printks2", + "println", "prints", + "printsk", "product", "pset", - "ptable", - "ptable3", - "ptablei", "ptablew", "ptrack", "puts", @@ -2005,6 +2038,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "pvsarp", "pvsbandp", "pvsbandr", + "pvsbandwidth", "pvsbin", "pvsblur", "pvsbuffer", @@ -2013,6 +2047,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "pvscale", "pvscent", "pvsceps", + "pvscfs", "pvscross", "pvsdemix", "pvsdiskin", @@ -2032,6 +2067,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "pvsinfo", "pvsinit", "pvslock", + "pvslpc", "pvsmaska", "pvsmix", "pvsmooth", @@ -2133,6 +2169,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "qnan", "r2c", "rand", + "randc", "randh", "randi", "random", @@ -2156,6 +2193,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "repluck", "reshapearray", "reson", + "resonbnk", "resonk", "resonr", "resonx", @@ -2173,6 +2211,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "rms", "rnd", "rnd31", + "rndseed", "round", "rspline", "rtclock", @@ -2185,14 +2224,17 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "sc_phasor", "sc_trig", "scale", + "scale2", "scalearray", "scanhammer", "scans", "scantable", "scanu", + "scanu2", "schedkwhen", "schedkwhennamed", "schedule", + "schedulek", "schedwhen", "scoreline", "scoreline_i", @@ -2238,6 +2280,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "sinh", "sininv", "sinsyn", + "skf", "sleighbells", "slicearray", "slicearray_i", @@ -2273,13 +2316,16 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "spat3di", "spat3dt", "spdist", + "spf", "splitrig", "sprintf", "sprintfk", "spsend", "sqrt", "squinewave", + "st2ms", "statevar", + "sterrain", "stix", "strcat", "strcatk", @@ -2303,6 +2349,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "strrindex", "strrindexk", "strset", + "strstrip", "strsub", "strsubk", "strtod", @@ -2317,6 +2364,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "sum", "sumarray", "svfilter", + "svn", "syncgrain", "syncloop", "syncphasor", @@ -2357,7 +2405,6 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "tabmorphi", "tabplay", "tabrec", - "tabrowlin", "tabsum", "tabw", "tabw_i", @@ -2389,7 +2436,11 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "trcross", "trfilter", "trhighest", + "trigExpseg", + "trigLinseg", "trigger", + "trighold", + "trigphasor", "trigseq", "trim", "trim_i", @@ -2401,6 +2452,8 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "trsplit", "turnoff", "turnoff2", + "turnoff2_i", + "turnoff3", "turnon", "tvconv", "unirand", @@ -2424,6 +2477,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "vbapz", "vbapzmove", "vcella", + "vclpf", "vco", "vco2", "vco2ft", @@ -2472,6 +2526,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "vpow_i", "vpowv", "vpowv_i", + "vps", "vpvoc", "vrandh", "vrandi", @@ -2511,6 +2566,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "wrap", "writescratch", "wterrain", + "wterrain2", "xadsr", "xin", "xout", @@ -2543,24 +2599,47 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "zkwm" ]; var deprecatedOpcodes = [ + "OSCsendA", "array", + "beadsynt", + "beosc", "bformdec", "bformenc", - "changed", + "buchla", "copy2ftab", "copy2ttab", + "getrowlin", "hrtfer", "ktableseg", "lentab", + "lua_exec", + "lua_iaopcall", + "lua_iaopcall_off", + "lua_ikopcall", + "lua_ikopcall_off", + "lua_iopcall", + "lua_iopcall_off", + "lua_opdef", "maxtab", "mintab", + "mp3scal_check", + "mp3scal_load", + "mp3scal_load2", + "mp3scal_play", + "mp3scal_play2", "pop", "pop_f", + "ptable", + "ptable3", + "ptablei", "ptableiw", "push", "push_f", + "pvsgendy", "scalet", + "signalflowgraph", "sndload", + "socksend_k", "soundout", "soundouts", "specaddm", @@ -2573,11 +2652,14 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "specsum", "spectrum", "stack", + "sumTableFilter", "sumtab", + "systime", "tabgen", "tableiw", "tabmap", "tabmap_i", + "tabrowlin", "tabslice", "tb0", "tb0_init", @@ -2612,6 +2694,7 @@ var CsoundOrchestraHighlightRules = function(embeddedRulePrefix) { "tb9", "tb9_init", "vbap16", + "vbap1move", "vbap4", "vbap4move", "vbap8", @@ -2937,6 +3020,8 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = ";"; this.blockComment = {start: "/*", end: "*/"}; + this.$id = "ace/mode/csound_orchestra"; + this.snippetFileId = "ace/snippets/csound_orchestra"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-csound_score.js b/htdocs/includes/ace/src/mode-csound_score.js index e7168662e1a..3155ca1ab67 100644 --- a/htdocs/includes/ace/src/mode-csound_score.js +++ b/htdocs/includes/ace/src/mode-csound_score.js @@ -300,7 +300,7 @@ var CsoundScoreHighlightRules = function(embeddedRulePrefix) { start.push( { token : "keyword.control.csound-score", - regex : /[abCdefiqstvxy]/ + regex : /[aBbCdefiqstvxy]/ }, { token : "invalid.illegal.csound-score", regex : /w/ @@ -448,6 +448,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = ";"; this.blockComment = {start: "/*", end: "*/"}; + this.$id = "ace/mode/csound_score"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-css.js b/htdocs/includes/ace/src/mode-css.js index 5ccc1ae304c..04560163b76 100644 --- a/htdocs/includes/ace/src/mode-css.js +++ b/htdocs/includes/ace/src/mode-css.js @@ -705,6 +705,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-curly.js b/htdocs/includes/ace/src/mode-curly.js index c408fed95ed..a3a7e712980 100644 --- a/htdocs/includes/ace/src/mode-curly.js +++ b/htdocs/includes/ace/src/mode-curly.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-d.js b/htdocs/includes/ace/src/mode-d.js index 8615c468b48..15379fb9992 100644 --- a/htdocs/includes/ace/src/mode-d.js +++ b/htdocs/includes/ace/src/mode-d.js @@ -308,7 +308,7 @@ var DHighlightRules = function() { regex: '[a-zA-Z]+' }, { token: 'string', - regex: '".*"' + regex: '"[^"]*"' }, { token: 'comment', regex: '//.*$' diff --git a/htdocs/includes/ace/src/mode-dart.js b/htdocs/includes/ace/src/mode-dart.js index 4a228361e6e..9abd9ecc054 100644 --- a/htdocs/includes/ace/src/mode-dart.js +++ b/htdocs/includes/ace/src/mode-dart.js @@ -65,7 +65,7 @@ var c_cppHighlightRules = function() { var storageType = ( "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + - "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" + + "_Imaginary|int|int8_t|int16_t|int32_t|int64_t|long|short|signed|size_t|struct|typedef|uint8_t|uint16_t|uint32_t|uint64_t|union|unsigned|void|" + "class|wchar_t|template|char16_t|char32_t" ); @@ -489,6 +489,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/c_cpp"; + this.snippetFileId = "ace/snippets/c_cpp"; }).call(Mode.prototype); exports.Mode = Mode; @@ -700,6 +701,7 @@ oop.inherits(Mode, CMode); this.lineCommentStart = "//"; this.blockComment = {start: "/*", end: "*/"}; this.$id = "ace/mode/dart"; + this.snippetFileId = "ace/snippets/dart"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-diff.js b/htdocs/includes/ace/src/mode-diff.js index b8237149bef..8a0ec7e722a 100644 --- a/htdocs/includes/ace/src/mode-diff.js +++ b/htdocs/includes/ace/src/mode-diff.js @@ -132,6 +132,7 @@ oop.inherits(Mode, TextMode); (function() { this.$id = "ace/mode/diff"; + this.snippetFileId = "ace/snippets/diff"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-django.js b/htdocs/includes/ace/src/mode-django.js index 81ce28dc73f..3a5d519bda7 100644 --- a/htdocs/includes/ace/src/mode-django.js +++ b/htdocs/includes/ace/src/mode-django.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2578,6 +2581,7 @@ oop.inherits(Mode, HtmlMode); (function() { this.$id = "ace/mode/django"; + this.snippetFileId = "ace/snippets/django"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-dockerfile.js b/htdocs/includes/ace/src/mode-dockerfile.js index 6b4e85c871b..26d64de860b 100644 --- a/htdocs/includes/ace/src/mode-dockerfile.js +++ b/htdocs/includes/ace/src/mode-dockerfile.js @@ -435,6 +435,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/sh"; + this.snippetFileId = "ace/snippets/sh"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-drools.js b/htdocs/includes/ace/src/mode-drools.js index d208011c997..adcc08f45f7 100644 --- a/htdocs/includes/ace/src/mode-drools.js +++ b/htdocs/includes/ace/src/mode-drools.js @@ -168,7 +168,7 @@ var JavaHighlightRules = function() { regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + regex : "!|\\$|%|&|\\||\\^|\\*|\\/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\*=|\\/=|%=|\\+=|\\-=|&=|\\|=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" }, { token : "lparen", regex : "[[({]" @@ -483,6 +483,7 @@ oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "//"; this.$id = "ace/mode/drools"; + this.snippetFileId = "ace/snippets/drools"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-edifact.js b/htdocs/includes/ace/src/mode-edifact.js index cffe68e2532..3fc865aee9a 100644 --- a/htdocs/includes/ace/src/mode-edifact.js +++ b/htdocs/includes/ace/src/mode-edifact.js @@ -152,6 +152,7 @@ oop.inherits(Mode, TextMode); (function() { this.$id = "ace/mode/edifact"; + this.snippetFileId = "ace/snippets/edifact"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-ejs.js b/htdocs/includes/ace/src/mode-ejs.js index 95323019651..5825e8385ca 100644 --- a/htdocs/includes/ace/src/mode-ejs.js +++ b/htdocs/includes/ace/src/mode-ejs.js @@ -1264,6 +1264,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1601,6 +1602,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2508,17 +2511,17 @@ var constantOtherSymbol = exports.constantOtherSymbol = { regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?" }; -var qString = exports.qString = { +exports.qString = { token : "string", // single line regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }; -var qqString = exports.qqString = { +exports.qqString = { token : "string", // single line regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }; -var tString = exports.tString = { +exports.tString = { token : "string", // backtick string regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]" }; @@ -2528,9 +2531,34 @@ var constantNumericHex = exports.constantNumericHex = { regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b" }; +var constantNumericBinary = exports.constantNumericBinary = { + token: "constant.numeric", + regex: /\b(0[bB][01](?:[01]|_(?=[01]))*)\b/ +}; + +var constantNumericDecimal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[dD](?:[1-9](?:[\d]|_(?=[\d]))*|0))\b/ +}; + +var constantNumericOctal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[oO]?(?:[1-7](?:[0-7]|_(?=[0-7]))*|0))\b/ +}; + +var constantNumericRational = exports.constantNumericRational = { + token: "constant.numeric", //rational + complex + regex: /\b([\d]+(?:[./][\d]+)?ri?)\b/ +}; + +var constantNumericComplex = exports.constantNumericComplex = { + token: "constant.numeric", //simple complex numbers + regex: /\b([\d]i)\b/ +}; + var constantNumericFloat = exports.constantNumericFloat = { - token : "constant.numeric", // float - regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b" + token : "constant.numeric", // float + complex + regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?i?\\b" }; var instanceVariable = exports.instanceVariable = { @@ -2570,18 +2598,19 @@ var RubyHighlightRules = function() { "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" + "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" + "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" + - "has_many|has_one|belongs_to|has_and_belongs_to_many" + "has_many|has_one|belongs_to|has_and_belongs_to_many|p|warn|refine|using|module_function|extend|alias_method|" + + "private_class_method|remove_method|undef_method" ); var keywords = ( "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" + "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" + - "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield" + "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield|__ENCODING__|prepend" ); var buildinConstants = ( "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" + - "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING" + "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING|RUBY_PATCHLEVEL|RUBY_REVISION|RUBY_COPYRIGHT|RUBY_ENGINE|RUBY_ENGINE_VERSION|RUBY_DESCRIPTION" ); var builtinVariables = ( @@ -2597,126 +2626,191 @@ var RubyHighlightRules = function() { "invalid.deprecated": "debugger" // TODO is this a remnant from js mode? }, "identifier"); + var escapedChars = "\\\\(?:n(?:[1-7][0-7]{0,2}|0)|[nsrtvfbae'\"\\\\]|c(?:\\\\M-)?.|M-(?:\\\\C-|\\\\c)?.|C-(?:\\\\M-)?.|[0-7]{3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|u{[\\da-fA-F]{1,6}(?:\\s[\\da-fA-F]{1,6})*})"; + + var closeParen = { + "(": ")", + "[": "]", + "{": "}", + "<": ">", + "^": "^", + "|": "|", + "%": "%" + }; + this.$rules = { - "start" : [ + "start": [ { - token : "comment", - regex : "#.*$" + token: "comment", + regex: "#.*$" }, { - token : "comment", // multi line comment - regex : "^=begin(?:$|\\s.*$)", - next : "comment" + token: "comment.multiline", // multi line comment + regex: "^=begin(?=$|\\s.*$)", + next: "comment" }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + token: "string.regexp", + regex: /[/](?=.*\/)/, + next: "regex" }, [{ - regex: "[{}]", onMatch: function(val, state, stack) { - this.next = val == "{" ? this.nextState : ""; - if (val == "{" && stack.length) { - stack.unshift("start", state); - return "paren.lparen"; - } - if (val == "}" && stack.length) { - stack.shift(); - this.next = stack.shift(); - if (this.next.indexOf("string") != -1) - return "paren.end"; - } - return val == "{" ? "paren.lparen" : "paren.rparen"; - }, - nextState: "start" - }, { - token : "string.start", - regex : /"/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(")/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /"/, - next : "pop" + token: "string.end", + regex: /"/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /`/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: "string.start", + regex: /`/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /`/, - next : "pop" + token: "string.end", + regex: /`/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /'/, - push : [{ - token : "constant.language.escape", - regex : /\\['\\]/ - }, { - token : "string.end", - regex : /'/, - next : "pop" + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(')/, + push: [{ + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "string.end", + regex: /'/, + next: "pop" }, { defaultToken: "string" }] + }, { + token: "string.start",//doesn't see any differences between strings and array of strings in highlighting + regex: /%[qwx]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithoutInterpolation"; + return this.token; + } + }, { + token: "string.start", //doesn't see any differences between strings and array of strings in highlighting + regex: /%[QWX]?([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[si]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithoutInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[SI]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithInterpolation"; + return this.token; + } + }, { + token: "string.regexp", + regex: /%[r]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "rState"; + return this.token; + } }], { - token : "text", // namespaces aren't symbols - regex : "::" + token: "punctuation", // namespaces aren't symbols + regex: "::" + }, + instanceVariable, + { + token: "variable.global", // global variable + regex: "[$][a-zA-Z_\\d]+" }, { - token : "variable.instance", // instance variable - regex : "@{1,2}[a-zA-Z_\\d]+" + token: "support.class", // class name + regex: "[A-Z][a-zA-Z_\\d]*" }, { - token : "support.class", // class name - regex : "[A-Z][a-zA-Z_\\d]+" + token: ["punctuation.operator", "support.function"], + regex: /(\.)([a-zA-Z_\d]+)(?=\()/ + }, { + token: ["punctuation.operator", "identifier"], + regex: /(\.)([a-zA-Z_][a-zA-Z_\d]*)/ + }, { + token: "string.character", + regex: "\\B\\?(?:" + escapedChars + "|\\S)" + }, { + token: "punctuation.operator", + regex: /\?(?=.+:)/ }, + constantNumericRational, + constantNumericComplex, constantOtherSymbol, constantNumericHex, constantNumericFloat, - + constantNumericBinary, + constantNumericDecimal, + constantNumericOctal, { - token : "constant.language.boolean", - regex : "(?:true|false)\\b" + token: "constant.language.boolean", + regex: "(?:true|false)\\b" }, { - token : keywordMapper, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + token: keywordMapper, + regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { - token : "punctuation.separator.key-value", - regex : "=>" + token: "punctuation.separator.key-value", + regex: "=>" }, { stateName: "heredoc", - onMatch : function(value, currentState, stack) { - var next = value[2] == '-' ? "indentedHeredoc" : "heredoc"; + onMatch: function (value, currentState, stack) { + var next = (value[2] == '-' || value[2] == '~') ? "indentedHeredoc" : "heredoc"; var tokens = value.split(this.splitRegex); stack.push(next, tokens[3]); return [ - {type:"constant", value: tokens[1]}, - {type:"string", value: tokens[2]}, - {type:"support.class", value: tokens[3]}, - {type:"string", value: tokens[4]} + {type: "constant", value: tokens[1]}, + {type: "string", value: tokens[2]}, + {type: "support.class", value: tokens[3]}, + {type: "string", value: tokens[4]} ]; }, - regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)", + regex: "(<<[-~]?)(['\"`]?)([\\w]+)(['\"`]?)", rules: { heredoc: [{ - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -2733,7 +2827,7 @@ var RubyHighlightRules = function() { token: "string", regex: "^ +" }, { - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -2748,38 +2842,261 @@ var RubyHighlightRules = function() { }] } }, { - regex : "$", - token : "empty", - next : function(currentState, stack) { + regex: "$", + token: "empty", + next: function(currentState, stack) { if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc") return stack[0]; return currentState; } + }, { + token: "keyword.operator", + regex: "!|\\$|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\||\\b(?:in|instanceof|new|delete|typeof|void)" }, { - token : "string.character", - regex : "\\B\\?." + token: "paren.lparen", + regex: "[[({]" }, { - token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + token: "paren.rparen", + regex: "[\\])}]", + onMatch: function(value, currentState, stack) { + this.next = ''; + if (value == "}" && stack.length > 1 && stack[1] != "start") { + stack.shift(); + this.next = stack.shift(); + } + return this.token; + } }, { - token : "paren.lparen", - regex : "[[({]" + token: "text", + regex: "\\s+" }, { - token : "paren.rparen", - regex : "[\\])}]" - }, { - token : "text", - regex : "\\s+" + token: "punctuation.operator", + regex: /[?:,;.]/ } ], - "comment" : [ + "comment": [ { - token : "comment", // closing comment - regex : "^=end(?:$|\\s.*$)", - next : "start" + token: "comment.multiline", // closing comment + regex: "^=end(?=$|\\s.*$)", + next: "start" }, { - token : "comment", // comment spanning whole line - regex : ".+" + token: "comment", // comment spanning whole line + regex: ".+" + } + ], + "qStateWithInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "qStateWithoutInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "sStateWithoutInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "sStateWithInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "rState": [{ + token: "string.regexp",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.language.escape"; + } + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.regexp", + regex: /\// + }, { + token: "string.regexp", + regex: /[)\]>}^|%][imxouesn]*/, onMatch: function (val, state, stack) { + if (stack.length && val[0] === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.language.escape"; + } + }, + {include: "regex"}, + { + defaultToken: "string.regexp" + }], + "regex": [ + {// character classes + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "constant.language.escape", + regex: /\\[AGbBzZ]/ + }, { + token: "constant.language.escape", + regex: /\\g<[a-zA-Z0-9]*>/ + }, { + token: ["constant.language.escape", "regexp.keyword", "constant.language.escape"], + regex: /(\\p{\^?)(Alnum|Alpha|Blank|Cntrl|Digit|Graph|Lower|Print|Punct|Space|Upper|XDigit|Word|ASCII|Any|Assigned|Arabic|Armenian|Balinese|Bengali|Bopomofo|Braille|Buginese|Buhid|Canadian_Aboriginal|Carian|Cham|Cherokee|Common|Coptic|Cuneiform|Cypriot|Cyrillic|Deseret|Devanagari|Ethiopic|Georgian|Glagolitic|Gothic|Greek|Gujarati|Gurmukhi|Han|Hangul|Hanunoo|Hebrew|Hiragana|Inherited|Kannada|Katakana|Kayah_Li|Kharoshthi|Khmer|Lao|Latin|Lepcha|Limbu|Linear_B|Lycian|Lydian|Malayalam|Mongolian|Myanmar|New_Tai_Lue|Nko|Ogham|Ol_Chiki|Old_Italic|Old_Persian|Oriya|Osmanya|Phags_Pa|Phoenician|Rejang|Runic|Saurashtra|Shavian|Sinhala|Sundanese|Syloti_Nagri|Syriac|Tagalog|Tagbanwa|Tai_Le|Tamil|Telugu|Thaana|Thai|Tibetan|Tifinagh|Ugaritic|Vai|Yi|Ll|Lm|Lt|Lu|Lo|Mn|Mc|Me|Nd|Nl|Pc|Pd|Ps|Pe|Pi|Pf|Po|No|Sm|Sc|Sk|So|Zs|Zl|Zp|Cc|Cf|Cn|Co|Cs|N|L|M|P|S|Z|C)(})/ + }, { + token: ["constant.language.escape", "invalid", "constant.language.escape"], + regex: /(\\p{\^?)([^/]*)(})/ + }, {// escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, {// flag + token: "string.regexp", + regex: /[/][imxouesn]*/, + next: "start" + }, {// invalid operators + token: "invalid", + regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ + }, {// operators + token: "constant.language.escape", + regex: /\(\?(?:[:=!>]|<'?[a-zA-Z]*'?>|<[=!])|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ + }, { + token: "constant.language.delimiter", + regex: /\|/ + }, { + token: "regexp.keyword", + regex: /\[\[:(?:alnum|alpha|blank|cntrl|digit|graph|lower|print|punct|space|upper|xdigit|word|ascii):\]\]/ + }, { + token: "constant.language.escape", + regex: /\[\^?/, + push: "regex_character_class" + }, { + defaultToken: "string.regexp" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "regexp.charclass.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: /&?&?\[\^?/, + push: "regex_character_class" + }, { + token: "constant.language.escape", + regex: "]", + next: "pop" + }, { + token: "constant.language.escape", + regex: "-" + }, { + defaultToken: "string.regexp.characterclass" } ] }; @@ -2792,94 +3109,271 @@ oop.inherits(RubyHighlightRules, TextHighlightRules); exports.RubyHighlightRules = RubyHighlightRules; }); -define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) { +define("ace/mode/folding/ruby",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function (require, exports, module) { "use strict"; var oop = require("../../lib/oop"); var BaseFoldMode = require("./fold_mode").FoldMode; var Range = require("../../range").Range; +var TokenIterator = require("../../token_iterator").TokenIterator; + + +var FoldMode = exports.FoldMode = function () { +}; -var FoldMode = exports.FoldMode = function() {}; oop.inherits(FoldMode, BaseFoldMode); -(function() { - - this.getFoldWidgetRange = function(session, foldStyle, row) { - var range = this.indentationBlock(session, row); - if (range) - return range; - - var re = /\S/; - var line = session.getLine(row); - var startLevel = line.search(re); - if (startLevel == -1 || line[startLevel] != "#") - return; - - var startColumn = line.length; - var maxRow = session.getLength(); - var startRow = row; - var endRow = row; - - while (++row < maxRow) { - line = session.getLine(row); - var level = line.search(re); - - if (level == -1) - continue; - - if (line[level] != "#") - break; - - endRow = row; - } - - if (endRow > startRow) { - var endColumn = session.getLine(endRow).length; - return new Range(startRow, startColumn, endRow, endColumn); - } +(function () { + this.indentKeywords = { + "class": 1, + "def": 1, + "module": 1, + "do": 1, + "unless": 1, + "if": 1, + "while": 1, + "for": 1, + "until": 1, + "begin": 1, + "else": 0, + "elsif": 0, + "rescue": 0, + "ensure": 0, + "when": 0, + "end": -1, + "case": 1, + "=begin": 1, + "=end": -1 }; - this.getFoldWidget = function(session, foldStyle, row) { - var line = session.getLine(row); - var indent = line.search(/\S/); - var next = session.getLine(row + 1); - var prev = session.getLine(row - 1); - var prevIndent = prev.search(/\S/); - var nextIndent = next.search(/\S/); - if (indent == -1) { - session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : ""; - return ""; - } - if (prevIndent == -1) { - if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") { - session.foldWidgets[row - 1] = ""; - session.foldWidgets[row + 1] = ""; + this.foldingStartMarker = /(?:\s|^)(def|do|while|class|unless|module|if|for|until|begin|else|elsif|case|rescue|ensure|when)\b|({\s*$)|(=begin)/; + this.foldingStopMarker = /(=end(?=$|\s.*$))|(^\s*})|\b(end)\b/; + + this.getFoldWidget = function (session, foldStyle, row) { + var line = session.getLine(row); + var isStart = this.foldingStartMarker.test(line); + var isEnd = this.foldingStopMarker.test(line); + + if (isStart && !isEnd) { + var match = line.match(this.foldingStartMarker); + if (match[1]) { + if (match[1] == "if" || match[1] == "else" || match[1] == "while" || match[1] == "until" || match[1] == "unless") { + if (match[1] == "else" && /^\s*else\s*$/.test(line) === false) { + return; + } + if (/^\s*(?:if|else|while|until|unless)\s*/.test(line) === false) { + return; + } + } + + if (match[1] == "when") { + if (/\sthen\s/.test(line) === true) { + return; + } + } + if (session.getTokenAt(row, match.index + 2).type === "keyword") + return "start"; + } else if (match[3]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "start"; + } else { return "start"; } - } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") { - if (session.getLine(row - 2).search(/\S/) == -1) { - session.foldWidgets[row - 1] = "start"; - session.foldWidgets[row + 1] = ""; - return ""; + } + if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd) + return ""; + + var match = line.match(this.foldingStopMarker); + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return "end"; + } else if (match[1]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "end"; + } else + return "end"; + }; + + this.getFoldWidgetRange = function (session, foldStyle, row) { + var line = session.doc.getLine(row); + var match = this.foldingStartMarker.exec(line); + if (match) { + if (match[1] || match[3]) + return this.rubyBlock(session, row, match.index + 2); + + return this.openingBracketBlock(session, "{", row, match.index); + } + + var match = this.foldingStopMarker.exec(line); + if (match) { + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return this.rubyBlock(session, row, match.index + 1); + } + + if (match[1] === "=end") { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return this.rubyBlock(session, row, match.index + 1); + } + + return this.closingBracketBlock(session, "}", row, match.index + match[0].length); + } + }; + + this.rubyBlock = function (session, row, column, tokenRange) { + var stream = new TokenIterator(session, row, column); + + var token = stream.getCurrentToken(); + if (!token || (token.type != "keyword" && token.type != "comment.multiline")) + return; + + var val = token.value; + var line = session.getLine(row); + switch (token.value) { + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + return; + } + var dir = this.indentKeywords[val]; + break; + case "when": + if (/\sthen\s/.test(line)) { + return; + } + case "elsif": + case "rescue": + case "ensure": + var dir = 1; + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line)) { + return; + } + var dir = 1; + break; + default: + var dir = this.indentKeywords[val]; + break; + } + + var stack = [val]; + if (!dir) + return; + + var startColumn = dir === -1 ? session.getLine(row - 1).length : session.getLine(row).length; + var startRow = row; + var ranges = []; + ranges.push(stream.getCurrentTokenRange()); + + stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; + if (token.type == "comment.multiline") { + while (token = stream.step()) { + if (token.type !== "comment.multiline") + continue; + if (dir == 1) { + startColumn = 6; + if (token.value == "=end") { + break; + } + } else { + if (token.value == "=begin") { + break; + } + } + } + } else { + while (token = stream.step()) { + var ignore = false; + if (token.type !== "keyword") + continue; + var level = dir * this.indentKeywords[token.value]; + line = session.getLine(stream.getCurrentTokenRow()); + switch (token.value) { + case "do": + for (var i = stream.$tokenIndex - 1; i >= 0; i--) { + var prevToken = stream.$rowTokens[i]; + if (prevToken && (prevToken.value == "while" || prevToken.value == "until" || prevToken.value == "for")) { + level = 0; + break; + } + } + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + level = 0; + ignore = true; + } + break; + case "when": + if (/\sthen\s/.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + } + + if (level > 0) { + stack.unshift(token.value); + } else if (level <= 0 && ignore === false) { + stack.shift(); + if (!stack.length) { + if ((val == "while" || val == "until" || val == "for") && token.value != "do") { + break; + } + if (token.value == "do" && dir == -1 && level != 0) + break; + if (token.value != "do") + break; + } + + if (level === 0) { + stack.unshift(token.value); + } + } } } - if (prevIndent!= -1 && prevIndent < indent) - session.foldWidgets[row - 1] = "start"; - else - session.foldWidgets[row - 1] = ""; + if (!token) + return null; - if (indent < nextIndent) - return "start"; - else - return ""; + if (tokenRange) { + ranges.push(stream.getCurrentTokenRange()); + return ranges; + } + + var row = stream.getCurrentTokenRow(); + if (dir === -1) { + if (token.type === "comment.multiline") { + var endColumn = 6; + } else { + var endColumn = session.getLine(row).length; + } + return new Range(row, endColumn, startRow - 1, startColumn); + } else + return new Range(startRow, startColumn, row - 1, session.getLine(row - 1).length); }; }).call(FoldMode.prototype); }); -define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module) { +define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/ruby"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); @@ -2888,13 +3382,14 @@ var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; -var FoldMode = require("./folding/coffee").FoldMode; +var FoldMode = require("./folding/ruby").FoldMode; var Mode = function() { this.HighlightRules = RubyHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new FoldMode(); + this.indentKeywords = this.foldingRules.indentKeywords; }; oop.inherits(Mode, TextMode); @@ -2909,7 +3404,7 @@ oop.inherits(Mode, TextMode); var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokens = tokenizedLine.tokens; - if (tokens.length && tokens[tokens.length-1].type == "comment") { + if (tokens.length && tokens[tokens.length - 1].type == "comment") { return indent; } @@ -2917,7 +3412,7 @@ oop.inherits(Mode, TextMode); var match = line.match(/^.*[\{\(\[]\s*$/); var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/); var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/); - var startingConditional = line.match(/^\s*(if|else|when)\s*/); + var startingConditional = line.match(/^\s*(if|else|when|elsif|unless|while|for|begin|rescue|ensure)\s*/); if (match || startingClassOrMethod || startingDoBlock || startingConditional) { indent += tab; } @@ -2927,7 +3422,7 @@ oop.inherits(Mode, TextMode); }; this.checkOutdent = function(state, line, input) { - return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input); + return /^\s+(end|else|rescue|ensure)$/.test(line + input) || this.$outdent.checkOutdent(line, input); }; this.autoOutdent = function(state, session, row) { @@ -2940,11 +3435,24 @@ oop.inherits(Mode, TextMode); var tab = session.getTabString(); if (prevIndent.length <= indent.length) { if (indent.slice(-tab.length) == tab) - session.remove(new Range(row, indent.length-tab.length, row, indent.length)); + session.remove(new Range(row, indent.length - tab.length, row, indent.length)); } }; + this.getMatching = function(session, row, column) { + if (row == undefined) { + var pos = session.selection.lead; + column = pos.column; + row = pos.row; + } + + var startToken = session.getTokenAt(row, column); + if (startToken && startToken.value in this.indentKeywords) + return this.foldingRules.rubyBlock(session, row, column, true); + }; + this.$id = "ace/mode/ruby"; + this.snippetFileId = "ace/snippets/ruby"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-erlang.js b/htdocs/includes/ace/src/mode-erlang.js index 3f91c0098c8..fd1143d9e87 100644 --- a/htdocs/includes/ace/src/mode-erlang.js +++ b/htdocs/includes/ace/src/mode-erlang.js @@ -996,6 +996,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "%"; this.blockComment = null; this.$id = "ace/mode/erlang"; + this.snippetFileId = "ace/snippets/erlang"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-fsl.js b/htdocs/includes/ace/src/mode-fsl.js index 9bfde7ebaba..9bd21d96c15 100644 --- a/htdocs/includes/ace/src/mode-fsl.js +++ b/htdocs/includes/ace/src/mode-fsl.js @@ -245,6 +245,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "//"; this.blockComment = {start: "/*", end: "*/"}; this.$id = "ace/mode/fsl"; + this.snippetFileId = "ace/snippets/fsl"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-glsl.js b/htdocs/includes/ace/src/mode-glsl.js index b5bc6e699e1..f5d0c815c94 100644 --- a/htdocs/includes/ace/src/mode-glsl.js +++ b/htdocs/includes/ace/src/mode-glsl.js @@ -65,7 +65,7 @@ var c_cppHighlightRules = function() { var storageType = ( "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + - "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" + + "_Imaginary|int|int8_t|int16_t|int32_t|int64_t|long|short|signed|size_t|struct|typedef|uint8_t|uint16_t|uint32_t|uint64_t|union|unsigned|void|" + "class|wchar_t|template|char16_t|char32_t" ); @@ -489,6 +489,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/c_cpp"; + this.snippetFileId = "ace/snippets/c_cpp"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-gobstones.js b/htdocs/includes/ace/src/mode-gobstones.js index 1ab66a8b898..cd2fc3aaf82 100644 --- a/htdocs/includes/ace/src/mode-gobstones.js +++ b/htdocs/includes/ace/src/mode-gobstones.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1075,6 +1076,7 @@ oop.inherits(Mode, JavaScriptMode); }; this.$id = "ace/mode/gobstones"; + this.snippetFileId = "ace/snippets/gobstones"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-graphqlschema.js b/htdocs/includes/ace/src/mode-graphqlschema.js index e252b70c78c..cf0931e3c8a 100644 --- a/htdocs/includes/ace/src/mode-graphqlschema.js +++ b/htdocs/includes/ace/src/mode-graphqlschema.js @@ -200,6 +200,7 @@ oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "#"; this.$id = "ace/mode/graphqlschema"; + this.snippetFileId = "ace/snippets/graphqlschema"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-groovy.js b/htdocs/includes/ace/src/mode-groovy.js index 4c48df1f925..8395de92087 100644 --- a/htdocs/includes/ace/src/mode-groovy.js +++ b/htdocs/includes/ace/src/mode-groovy.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-haml.js b/htdocs/includes/ace/src/mode-haml.js index e6821c8a45e..db8e69343ca 100644 --- a/htdocs/includes/ace/src/mode-haml.js +++ b/htdocs/includes/ace/src/mode-haml.js @@ -1012,17 +1012,17 @@ var constantOtherSymbol = exports.constantOtherSymbol = { regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?" }; -var qString = exports.qString = { +exports.qString = { token : "string", // single line regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }; -var qqString = exports.qqString = { +exports.qqString = { token : "string", // single line regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }; -var tString = exports.tString = { +exports.tString = { token : "string", // backtick string regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]" }; @@ -1032,9 +1032,34 @@ var constantNumericHex = exports.constantNumericHex = { regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b" }; +var constantNumericBinary = exports.constantNumericBinary = { + token: "constant.numeric", + regex: /\b(0[bB][01](?:[01]|_(?=[01]))*)\b/ +}; + +var constantNumericDecimal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[dD](?:[1-9](?:[\d]|_(?=[\d]))*|0))\b/ +}; + +var constantNumericOctal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[oO]?(?:[1-7](?:[0-7]|_(?=[0-7]))*|0))\b/ +}; + +var constantNumericRational = exports.constantNumericRational = { + token: "constant.numeric", //rational + complex + regex: /\b([\d]+(?:[./][\d]+)?ri?)\b/ +}; + +var constantNumericComplex = exports.constantNumericComplex = { + token: "constant.numeric", //simple complex numbers + regex: /\b([\d]i)\b/ +}; + var constantNumericFloat = exports.constantNumericFloat = { - token : "constant.numeric", // float - regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b" + token : "constant.numeric", // float + complex + regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?i?\\b" }; var instanceVariable = exports.instanceVariable = { @@ -1074,18 +1099,19 @@ var RubyHighlightRules = function() { "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" + "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" + "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" + - "has_many|has_one|belongs_to|has_and_belongs_to_many" + "has_many|has_one|belongs_to|has_and_belongs_to_many|p|warn|refine|using|module_function|extend|alias_method|" + + "private_class_method|remove_method|undef_method" ); var keywords = ( "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" + "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" + - "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield" + "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield|__ENCODING__|prepend" ); var buildinConstants = ( "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" + - "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING" + "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING|RUBY_PATCHLEVEL|RUBY_REVISION|RUBY_COPYRIGHT|RUBY_ENGINE|RUBY_ENGINE_VERSION|RUBY_DESCRIPTION" ); var builtinVariables = ( @@ -1101,126 +1127,191 @@ var RubyHighlightRules = function() { "invalid.deprecated": "debugger" // TODO is this a remnant from js mode? }, "identifier"); + var escapedChars = "\\\\(?:n(?:[1-7][0-7]{0,2}|0)|[nsrtvfbae'\"\\\\]|c(?:\\\\M-)?.|M-(?:\\\\C-|\\\\c)?.|C-(?:\\\\M-)?.|[0-7]{3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|u{[\\da-fA-F]{1,6}(?:\\s[\\da-fA-F]{1,6})*})"; + + var closeParen = { + "(": ")", + "[": "]", + "{": "}", + "<": ">", + "^": "^", + "|": "|", + "%": "%" + }; + this.$rules = { - "start" : [ + "start": [ { - token : "comment", - regex : "#.*$" + token: "comment", + regex: "#.*$" }, { - token : "comment", // multi line comment - regex : "^=begin(?:$|\\s.*$)", - next : "comment" + token: "comment.multiline", // multi line comment + regex: "^=begin(?=$|\\s.*$)", + next: "comment" }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + token: "string.regexp", + regex: /[/](?=.*\/)/, + next: "regex" }, [{ - regex: "[{}]", onMatch: function(val, state, stack) { - this.next = val == "{" ? this.nextState : ""; - if (val == "{" && stack.length) { - stack.unshift("start", state); - return "paren.lparen"; - } - if (val == "}" && stack.length) { - stack.shift(); - this.next = stack.shift(); - if (this.next.indexOf("string") != -1) - return "paren.end"; - } - return val == "{" ? "paren.lparen" : "paren.rparen"; - }, - nextState: "start" - }, { - token : "string.start", - regex : /"/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(")/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /"/, - next : "pop" + token: "string.end", + regex: /"/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /`/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: "string.start", + regex: /`/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /`/, - next : "pop" + token: "string.end", + regex: /`/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /'/, - push : [{ - token : "constant.language.escape", - regex : /\\['\\]/ - }, { - token : "string.end", - regex : /'/, - next : "pop" + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(')/, + push: [{ + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "string.end", + regex: /'/, + next: "pop" }, { defaultToken: "string" }] + }, { + token: "string.start",//doesn't see any differences between strings and array of strings in highlighting + regex: /%[qwx]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithoutInterpolation"; + return this.token; + } + }, { + token: "string.start", //doesn't see any differences between strings and array of strings in highlighting + regex: /%[QWX]?([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[si]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithoutInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[SI]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithInterpolation"; + return this.token; + } + }, { + token: "string.regexp", + regex: /%[r]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "rState"; + return this.token; + } }], { - token : "text", // namespaces aren't symbols - regex : "::" + token: "punctuation", // namespaces aren't symbols + regex: "::" + }, + instanceVariable, + { + token: "variable.global", // global variable + regex: "[$][a-zA-Z_\\d]+" }, { - token : "variable.instance", // instance variable - regex : "@{1,2}[a-zA-Z_\\d]+" + token: "support.class", // class name + regex: "[A-Z][a-zA-Z_\\d]*" }, { - token : "support.class", // class name - regex : "[A-Z][a-zA-Z_\\d]+" + token: ["punctuation.operator", "support.function"], + regex: /(\.)([a-zA-Z_\d]+)(?=\()/ + }, { + token: ["punctuation.operator", "identifier"], + regex: /(\.)([a-zA-Z_][a-zA-Z_\d]*)/ + }, { + token: "string.character", + regex: "\\B\\?(?:" + escapedChars + "|\\S)" + }, { + token: "punctuation.operator", + regex: /\?(?=.+:)/ }, + constantNumericRational, + constantNumericComplex, constantOtherSymbol, constantNumericHex, constantNumericFloat, - + constantNumericBinary, + constantNumericDecimal, + constantNumericOctal, { - token : "constant.language.boolean", - regex : "(?:true|false)\\b" + token: "constant.language.boolean", + regex: "(?:true|false)\\b" }, { - token : keywordMapper, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + token: keywordMapper, + regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { - token : "punctuation.separator.key-value", - regex : "=>" + token: "punctuation.separator.key-value", + regex: "=>" }, { stateName: "heredoc", - onMatch : function(value, currentState, stack) { - var next = value[2] == '-' ? "indentedHeredoc" : "heredoc"; + onMatch: function (value, currentState, stack) { + var next = (value[2] == '-' || value[2] == '~') ? "indentedHeredoc" : "heredoc"; var tokens = value.split(this.splitRegex); stack.push(next, tokens[3]); return [ - {type:"constant", value: tokens[1]}, - {type:"string", value: tokens[2]}, - {type:"support.class", value: tokens[3]}, - {type:"string", value: tokens[4]} + {type: "constant", value: tokens[1]}, + {type: "string", value: tokens[2]}, + {type: "support.class", value: tokens[3]}, + {type: "string", value: tokens[4]} ]; }, - regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)", + regex: "(<<[-~]?)(['\"`]?)([\\w]+)(['\"`]?)", rules: { heredoc: [{ - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -1237,7 +1328,7 @@ var RubyHighlightRules = function() { token: "string", regex: "^ +" }, { - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -1252,38 +1343,261 @@ var RubyHighlightRules = function() { }] } }, { - regex : "$", - token : "empty", - next : function(currentState, stack) { + regex: "$", + token: "empty", + next: function(currentState, stack) { if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc") return stack[0]; return currentState; } + }, { + token: "keyword.operator", + regex: "!|\\$|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\||\\b(?:in|instanceof|new|delete|typeof|void)" }, { - token : "string.character", - regex : "\\B\\?." + token: "paren.lparen", + regex: "[[({]" }, { - token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + token: "paren.rparen", + regex: "[\\])}]", + onMatch: function(value, currentState, stack) { + this.next = ''; + if (value == "}" && stack.length > 1 && stack[1] != "start") { + stack.shift(); + this.next = stack.shift(); + } + return this.token; + } }, { - token : "paren.lparen", - regex : "[[({]" + token: "text", + regex: "\\s+" }, { - token : "paren.rparen", - regex : "[\\])}]" - }, { - token : "text", - regex : "\\s+" + token: "punctuation.operator", + regex: /[?:,;.]/ } ], - "comment" : [ + "comment": [ { - token : "comment", // closing comment - regex : "^=end(?:$|\\s.*$)", - next : "start" + token: "comment.multiline", // closing comment + regex: "^=end(?=$|\\s.*$)", + next: "start" }, { - token : "comment", // comment spanning whole line - regex : ".+" + token: "comment", // comment spanning whole line + regex: ".+" + } + ], + "qStateWithInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "qStateWithoutInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "sStateWithoutInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "sStateWithInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "rState": [{ + token: "string.regexp",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.language.escape"; + } + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.regexp", + regex: /\// + }, { + token: "string.regexp", + regex: /[)\]>}^|%][imxouesn]*/, onMatch: function (val, state, stack) { + if (stack.length && val[0] === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.language.escape"; + } + }, + {include: "regex"}, + { + defaultToken: "string.regexp" + }], + "regex": [ + {// character classes + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "constant.language.escape", + regex: /\\[AGbBzZ]/ + }, { + token: "constant.language.escape", + regex: /\\g<[a-zA-Z0-9]*>/ + }, { + token: ["constant.language.escape", "regexp.keyword", "constant.language.escape"], + regex: /(\\p{\^?)(Alnum|Alpha|Blank|Cntrl|Digit|Graph|Lower|Print|Punct|Space|Upper|XDigit|Word|ASCII|Any|Assigned|Arabic|Armenian|Balinese|Bengali|Bopomofo|Braille|Buginese|Buhid|Canadian_Aboriginal|Carian|Cham|Cherokee|Common|Coptic|Cuneiform|Cypriot|Cyrillic|Deseret|Devanagari|Ethiopic|Georgian|Glagolitic|Gothic|Greek|Gujarati|Gurmukhi|Han|Hangul|Hanunoo|Hebrew|Hiragana|Inherited|Kannada|Katakana|Kayah_Li|Kharoshthi|Khmer|Lao|Latin|Lepcha|Limbu|Linear_B|Lycian|Lydian|Malayalam|Mongolian|Myanmar|New_Tai_Lue|Nko|Ogham|Ol_Chiki|Old_Italic|Old_Persian|Oriya|Osmanya|Phags_Pa|Phoenician|Rejang|Runic|Saurashtra|Shavian|Sinhala|Sundanese|Syloti_Nagri|Syriac|Tagalog|Tagbanwa|Tai_Le|Tamil|Telugu|Thaana|Thai|Tibetan|Tifinagh|Ugaritic|Vai|Yi|Ll|Lm|Lt|Lu|Lo|Mn|Mc|Me|Nd|Nl|Pc|Pd|Ps|Pe|Pi|Pf|Po|No|Sm|Sc|Sk|So|Zs|Zl|Zp|Cc|Cf|Cn|Co|Cs|N|L|M|P|S|Z|C)(})/ + }, { + token: ["constant.language.escape", "invalid", "constant.language.escape"], + regex: /(\\p{\^?)([^/]*)(})/ + }, {// escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, {// flag + token: "string.regexp", + regex: /[/][imxouesn]*/, + next: "start" + }, {// invalid operators + token: "invalid", + regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ + }, {// operators + token: "constant.language.escape", + regex: /\(\?(?:[:=!>]|<'?[a-zA-Z]*'?>|<[=!])|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ + }, { + token: "constant.language.delimiter", + regex: /\|/ + }, { + token: "regexp.keyword", + regex: /\[\[:(?:alnum|alpha|blank|cntrl|digit|graph|lower|print|punct|space|upper|xdigit|word|ascii):\]\]/ + }, { + token: "constant.language.escape", + regex: /\[\^?/, + push: "regex_character_class" + }, { + defaultToken: "string.regexp" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "regexp.charclass.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: /&?&?\[\^?/, + push: "regex_character_class" + }, { + token: "constant.language.escape", + regex: "]", + next: "pop" + }, { + token: "constant.language.escape", + regex: "-" + }, { + defaultToken: "string.regexp.characterclass" } ] }; @@ -1545,6 +1859,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "//"; this.$id = "ace/mode/haml"; + this.snippetFileId = "ace/snippets/haml"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-handlebars.js b/htdocs/includes/ace/src/mode-handlebars.js index 620074baff2..ba8f7e015fc 100644 --- a/htdocs/includes/ace/src/mode-handlebars.js +++ b/htdocs/includes/ace/src/mode-handlebars.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-haskell.js b/htdocs/includes/ace/src/mode-haskell.js index af5eff5693a..bf5f1d6edb3 100644 --- a/htdocs/includes/ace/src/mode-haskell.js +++ b/htdocs/includes/ace/src/mode-haskell.js @@ -366,6 +366,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "--"; this.blockComment = null; this.$id = "ace/mode/haskell"; + this.snippetFileId = "ace/snippets/haskell"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-html.js b/htdocs/includes/ace/src/mode-html.js index 2d7ddabbdaa..f8466c2ddb7 100644 --- a/htdocs/includes/ace/src/mode-html.js +++ b/htdocs/includes/ace/src/mode-html.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-html_elixir.js b/htdocs/includes/ace/src/mode-html_elixir.js index 5d80fcbbcef..53fa828bdde 100644 --- a/htdocs/includes/ace/src/mode-html_elixir.js +++ b/htdocs/includes/ace/src/mode-html_elixir.js @@ -1704,6 +1704,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2041,6 +2042,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2933,6 +2935,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-html_ruby.js b/htdocs/includes/ace/src/mode-html_ruby.js index ec77543f358..e3eb0f7761a 100644 --- a/htdocs/includes/ace/src/mode-html_ruby.js +++ b/htdocs/includes/ace/src/mode-html_ruby.js @@ -1012,17 +1012,17 @@ var constantOtherSymbol = exports.constantOtherSymbol = { regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?" }; -var qString = exports.qString = { +exports.qString = { token : "string", // single line regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }; -var qqString = exports.qqString = { +exports.qqString = { token : "string", // single line regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }; -var tString = exports.tString = { +exports.tString = { token : "string", // backtick string regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]" }; @@ -1032,9 +1032,34 @@ var constantNumericHex = exports.constantNumericHex = { regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b" }; +var constantNumericBinary = exports.constantNumericBinary = { + token: "constant.numeric", + regex: /\b(0[bB][01](?:[01]|_(?=[01]))*)\b/ +}; + +var constantNumericDecimal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[dD](?:[1-9](?:[\d]|_(?=[\d]))*|0))\b/ +}; + +var constantNumericOctal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[oO]?(?:[1-7](?:[0-7]|_(?=[0-7]))*|0))\b/ +}; + +var constantNumericRational = exports.constantNumericRational = { + token: "constant.numeric", //rational + complex + regex: /\b([\d]+(?:[./][\d]+)?ri?)\b/ +}; + +var constantNumericComplex = exports.constantNumericComplex = { + token: "constant.numeric", //simple complex numbers + regex: /\b([\d]i)\b/ +}; + var constantNumericFloat = exports.constantNumericFloat = { - token : "constant.numeric", // float - regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b" + token : "constant.numeric", // float + complex + regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?i?\\b" }; var instanceVariable = exports.instanceVariable = { @@ -1074,18 +1099,19 @@ var RubyHighlightRules = function() { "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" + "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" + "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" + - "has_many|has_one|belongs_to|has_and_belongs_to_many" + "has_many|has_one|belongs_to|has_and_belongs_to_many|p|warn|refine|using|module_function|extend|alias_method|" + + "private_class_method|remove_method|undef_method" ); var keywords = ( "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" + "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" + - "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield" + "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield|__ENCODING__|prepend" ); var buildinConstants = ( "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" + - "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING" + "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING|RUBY_PATCHLEVEL|RUBY_REVISION|RUBY_COPYRIGHT|RUBY_ENGINE|RUBY_ENGINE_VERSION|RUBY_DESCRIPTION" ); var builtinVariables = ( @@ -1101,126 +1127,191 @@ var RubyHighlightRules = function() { "invalid.deprecated": "debugger" // TODO is this a remnant from js mode? }, "identifier"); + var escapedChars = "\\\\(?:n(?:[1-7][0-7]{0,2}|0)|[nsrtvfbae'\"\\\\]|c(?:\\\\M-)?.|M-(?:\\\\C-|\\\\c)?.|C-(?:\\\\M-)?.|[0-7]{3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|u{[\\da-fA-F]{1,6}(?:\\s[\\da-fA-F]{1,6})*})"; + + var closeParen = { + "(": ")", + "[": "]", + "{": "}", + "<": ">", + "^": "^", + "|": "|", + "%": "%" + }; + this.$rules = { - "start" : [ + "start": [ { - token : "comment", - regex : "#.*$" + token: "comment", + regex: "#.*$" }, { - token : "comment", // multi line comment - regex : "^=begin(?:$|\\s.*$)", - next : "comment" + token: "comment.multiline", // multi line comment + regex: "^=begin(?=$|\\s.*$)", + next: "comment" }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + token: "string.regexp", + regex: /[/](?=.*\/)/, + next: "regex" }, [{ - regex: "[{}]", onMatch: function(val, state, stack) { - this.next = val == "{" ? this.nextState : ""; - if (val == "{" && stack.length) { - stack.unshift("start", state); - return "paren.lparen"; - } - if (val == "}" && stack.length) { - stack.shift(); - this.next = stack.shift(); - if (this.next.indexOf("string") != -1) - return "paren.end"; - } - return val == "{" ? "paren.lparen" : "paren.rparen"; - }, - nextState: "start" - }, { - token : "string.start", - regex : /"/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(")/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /"/, - next : "pop" + token: "string.end", + regex: /"/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /`/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: "string.start", + regex: /`/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /`/, - next : "pop" + token: "string.end", + regex: /`/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /'/, - push : [{ - token : "constant.language.escape", - regex : /\\['\\]/ - }, { - token : "string.end", - regex : /'/, - next : "pop" + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(')/, + push: [{ + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "string.end", + regex: /'/, + next: "pop" }, { defaultToken: "string" }] + }, { + token: "string.start",//doesn't see any differences between strings and array of strings in highlighting + regex: /%[qwx]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithoutInterpolation"; + return this.token; + } + }, { + token: "string.start", //doesn't see any differences between strings and array of strings in highlighting + regex: /%[QWX]?([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[si]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithoutInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[SI]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithInterpolation"; + return this.token; + } + }, { + token: "string.regexp", + regex: /%[r]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "rState"; + return this.token; + } }], { - token : "text", // namespaces aren't symbols - regex : "::" + token: "punctuation", // namespaces aren't symbols + regex: "::" + }, + instanceVariable, + { + token: "variable.global", // global variable + regex: "[$][a-zA-Z_\\d]+" }, { - token : "variable.instance", // instance variable - regex : "@{1,2}[a-zA-Z_\\d]+" + token: "support.class", // class name + regex: "[A-Z][a-zA-Z_\\d]*" }, { - token : "support.class", // class name - regex : "[A-Z][a-zA-Z_\\d]+" + token: ["punctuation.operator", "support.function"], + regex: /(\.)([a-zA-Z_\d]+)(?=\()/ + }, { + token: ["punctuation.operator", "identifier"], + regex: /(\.)([a-zA-Z_][a-zA-Z_\d]*)/ + }, { + token: "string.character", + regex: "\\B\\?(?:" + escapedChars + "|\\S)" + }, { + token: "punctuation.operator", + regex: /\?(?=.+:)/ }, + constantNumericRational, + constantNumericComplex, constantOtherSymbol, constantNumericHex, constantNumericFloat, - + constantNumericBinary, + constantNumericDecimal, + constantNumericOctal, { - token : "constant.language.boolean", - regex : "(?:true|false)\\b" + token: "constant.language.boolean", + regex: "(?:true|false)\\b" }, { - token : keywordMapper, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + token: keywordMapper, + regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { - token : "punctuation.separator.key-value", - regex : "=>" + token: "punctuation.separator.key-value", + regex: "=>" }, { stateName: "heredoc", - onMatch : function(value, currentState, stack) { - var next = value[2] == '-' ? "indentedHeredoc" : "heredoc"; + onMatch: function (value, currentState, stack) { + var next = (value[2] == '-' || value[2] == '~') ? "indentedHeredoc" : "heredoc"; var tokens = value.split(this.splitRegex); stack.push(next, tokens[3]); return [ - {type:"constant", value: tokens[1]}, - {type:"string", value: tokens[2]}, - {type:"support.class", value: tokens[3]}, - {type:"string", value: tokens[4]} + {type: "constant", value: tokens[1]}, + {type: "string", value: tokens[2]}, + {type: "support.class", value: tokens[3]}, + {type: "string", value: tokens[4]} ]; }, - regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)", + regex: "(<<[-~]?)(['\"`]?)([\\w]+)(['\"`]?)", rules: { heredoc: [{ - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -1237,7 +1328,7 @@ var RubyHighlightRules = function() { token: "string", regex: "^ +" }, { - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -1252,38 +1343,261 @@ var RubyHighlightRules = function() { }] } }, { - regex : "$", - token : "empty", - next : function(currentState, stack) { + regex: "$", + token: "empty", + next: function(currentState, stack) { if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc") return stack[0]; return currentState; } + }, { + token: "keyword.operator", + regex: "!|\\$|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\||\\b(?:in|instanceof|new|delete|typeof|void)" }, { - token : "string.character", - regex : "\\B\\?." + token: "paren.lparen", + regex: "[[({]" }, { - token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + token: "paren.rparen", + regex: "[\\])}]", + onMatch: function(value, currentState, stack) { + this.next = ''; + if (value == "}" && stack.length > 1 && stack[1] != "start") { + stack.shift(); + this.next = stack.shift(); + } + return this.token; + } }, { - token : "paren.lparen", - regex : "[[({]" + token: "text", + regex: "\\s+" }, { - token : "paren.rparen", - regex : "[\\])}]" - }, { - token : "text", - regex : "\\s+" + token: "punctuation.operator", + regex: /[?:,;.]/ } ], - "comment" : [ + "comment": [ { - token : "comment", // closing comment - regex : "^=end(?:$|\\s.*$)", - next : "start" + token: "comment.multiline", // closing comment + regex: "^=end(?=$|\\s.*$)", + next: "start" }, { - token : "comment", // comment spanning whole line - regex : ".+" + token: "comment", // comment spanning whole line + regex: ".+" + } + ], + "qStateWithInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "qStateWithoutInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "sStateWithoutInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "sStateWithInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "rState": [{ + token: "string.regexp",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.language.escape"; + } + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.regexp", + regex: /\// + }, { + token: "string.regexp", + regex: /[)\]>}^|%][imxouesn]*/, onMatch: function (val, state, stack) { + if (stack.length && val[0] === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.language.escape"; + } + }, + {include: "regex"}, + { + defaultToken: "string.regexp" + }], + "regex": [ + {// character classes + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "constant.language.escape", + regex: /\\[AGbBzZ]/ + }, { + token: "constant.language.escape", + regex: /\\g<[a-zA-Z0-9]*>/ + }, { + token: ["constant.language.escape", "regexp.keyword", "constant.language.escape"], + regex: /(\\p{\^?)(Alnum|Alpha|Blank|Cntrl|Digit|Graph|Lower|Print|Punct|Space|Upper|XDigit|Word|ASCII|Any|Assigned|Arabic|Armenian|Balinese|Bengali|Bopomofo|Braille|Buginese|Buhid|Canadian_Aboriginal|Carian|Cham|Cherokee|Common|Coptic|Cuneiform|Cypriot|Cyrillic|Deseret|Devanagari|Ethiopic|Georgian|Glagolitic|Gothic|Greek|Gujarati|Gurmukhi|Han|Hangul|Hanunoo|Hebrew|Hiragana|Inherited|Kannada|Katakana|Kayah_Li|Kharoshthi|Khmer|Lao|Latin|Lepcha|Limbu|Linear_B|Lycian|Lydian|Malayalam|Mongolian|Myanmar|New_Tai_Lue|Nko|Ogham|Ol_Chiki|Old_Italic|Old_Persian|Oriya|Osmanya|Phags_Pa|Phoenician|Rejang|Runic|Saurashtra|Shavian|Sinhala|Sundanese|Syloti_Nagri|Syriac|Tagalog|Tagbanwa|Tai_Le|Tamil|Telugu|Thaana|Thai|Tibetan|Tifinagh|Ugaritic|Vai|Yi|Ll|Lm|Lt|Lu|Lo|Mn|Mc|Me|Nd|Nl|Pc|Pd|Ps|Pe|Pi|Pf|Po|No|Sm|Sc|Sk|So|Zs|Zl|Zp|Cc|Cf|Cn|Co|Cs|N|L|M|P|S|Z|C)(})/ + }, { + token: ["constant.language.escape", "invalid", "constant.language.escape"], + regex: /(\\p{\^?)([^/]*)(})/ + }, {// escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, {// flag + token: "string.regexp", + regex: /[/][imxouesn]*/, + next: "start" + }, {// invalid operators + token: "invalid", + regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ + }, {// operators + token: "constant.language.escape", + regex: /\(\?(?:[:=!>]|<'?[a-zA-Z]*'?>|<[=!])|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ + }, { + token: "constant.language.delimiter", + regex: /\|/ + }, { + token: "regexp.keyword", + regex: /\[\[:(?:alnum|alpha|blank|cntrl|digit|graph|lower|print|punct|space|upper|xdigit|word|ascii):\]\]/ + }, { + token: "constant.language.escape", + regex: /\[\^?/, + push: "regex_character_class" + }, { + defaultToken: "string.regexp" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "regexp.charclass.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: /&?&?\[\^?/, + push: "regex_character_class" + }, { + token: "constant.language.escape", + regex: "]", + next: "pop" + }, { + token: "constant.language.escape", + regex: "-" + }, { + defaultToken: "string.regexp.characterclass" } ] }; @@ -1613,6 +1927,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1950,6 +2265,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2842,99 +3158,277 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; }); -define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) { +define("ace/mode/folding/ruby",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function (require, exports, module) { "use strict"; var oop = require("../../lib/oop"); var BaseFoldMode = require("./fold_mode").FoldMode; var Range = require("../../range").Range; +var TokenIterator = require("../../token_iterator").TokenIterator; + + +var FoldMode = exports.FoldMode = function () { +}; -var FoldMode = exports.FoldMode = function() {}; oop.inherits(FoldMode, BaseFoldMode); -(function() { - - this.getFoldWidgetRange = function(session, foldStyle, row) { - var range = this.indentationBlock(session, row); - if (range) - return range; - - var re = /\S/; - var line = session.getLine(row); - var startLevel = line.search(re); - if (startLevel == -1 || line[startLevel] != "#") - return; - - var startColumn = line.length; - var maxRow = session.getLength(); - var startRow = row; - var endRow = row; - - while (++row < maxRow) { - line = session.getLine(row); - var level = line.search(re); - - if (level == -1) - continue; - - if (line[level] != "#") - break; - - endRow = row; - } - - if (endRow > startRow) { - var endColumn = session.getLine(endRow).length; - return new Range(startRow, startColumn, endRow, endColumn); - } +(function () { + this.indentKeywords = { + "class": 1, + "def": 1, + "module": 1, + "do": 1, + "unless": 1, + "if": 1, + "while": 1, + "for": 1, + "until": 1, + "begin": 1, + "else": 0, + "elsif": 0, + "rescue": 0, + "ensure": 0, + "when": 0, + "end": -1, + "case": 1, + "=begin": 1, + "=end": -1 }; - this.getFoldWidget = function(session, foldStyle, row) { - var line = session.getLine(row); - var indent = line.search(/\S/); - var next = session.getLine(row + 1); - var prev = session.getLine(row - 1); - var prevIndent = prev.search(/\S/); - var nextIndent = next.search(/\S/); - if (indent == -1) { - session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : ""; - return ""; - } - if (prevIndent == -1) { - if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") { - session.foldWidgets[row - 1] = ""; - session.foldWidgets[row + 1] = ""; + this.foldingStartMarker = /(?:\s|^)(def|do|while|class|unless|module|if|for|until|begin|else|elsif|case|rescue|ensure|when)\b|({\s*$)|(=begin)/; + this.foldingStopMarker = /(=end(?=$|\s.*$))|(^\s*})|\b(end)\b/; + + this.getFoldWidget = function (session, foldStyle, row) { + var line = session.getLine(row); + var isStart = this.foldingStartMarker.test(line); + var isEnd = this.foldingStopMarker.test(line); + + if (isStart && !isEnd) { + var match = line.match(this.foldingStartMarker); + if (match[1]) { + if (match[1] == "if" || match[1] == "else" || match[1] == "while" || match[1] == "until" || match[1] == "unless") { + if (match[1] == "else" && /^\s*else\s*$/.test(line) === false) { + return; + } + if (/^\s*(?:if|else|while|until|unless)\s*/.test(line) === false) { + return; + } + } + + if (match[1] == "when") { + if (/\sthen\s/.test(line) === true) { + return; + } + } + if (session.getTokenAt(row, match.index + 2).type === "keyword") + return "start"; + } else if (match[3]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "start"; + } else { return "start"; } - } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") { - if (session.getLine(row - 2).search(/\S/) == -1) { - session.foldWidgets[row - 1] = "start"; - session.foldWidgets[row + 1] = ""; - return ""; + } + if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd) + return ""; + + var match = line.match(this.foldingStopMarker); + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return "end"; + } else if (match[1]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "end"; + } else + return "end"; + }; + + this.getFoldWidgetRange = function (session, foldStyle, row) { + var line = session.doc.getLine(row); + var match = this.foldingStartMarker.exec(line); + if (match) { + if (match[1] || match[3]) + return this.rubyBlock(session, row, match.index + 2); + + return this.openingBracketBlock(session, "{", row, match.index); + } + + var match = this.foldingStopMarker.exec(line); + if (match) { + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return this.rubyBlock(session, row, match.index + 1); + } + + if (match[1] === "=end") { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return this.rubyBlock(session, row, match.index + 1); + } + + return this.closingBracketBlock(session, "}", row, match.index + match[0].length); + } + }; + + this.rubyBlock = function (session, row, column, tokenRange) { + var stream = new TokenIterator(session, row, column); + + var token = stream.getCurrentToken(); + if (!token || (token.type != "keyword" && token.type != "comment.multiline")) + return; + + var val = token.value; + var line = session.getLine(row); + switch (token.value) { + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + return; + } + var dir = this.indentKeywords[val]; + break; + case "when": + if (/\sthen\s/.test(line)) { + return; + } + case "elsif": + case "rescue": + case "ensure": + var dir = 1; + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line)) { + return; + } + var dir = 1; + break; + default: + var dir = this.indentKeywords[val]; + break; + } + + var stack = [val]; + if (!dir) + return; + + var startColumn = dir === -1 ? session.getLine(row - 1).length : session.getLine(row).length; + var startRow = row; + var ranges = []; + ranges.push(stream.getCurrentTokenRange()); + + stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; + if (token.type == "comment.multiline") { + while (token = stream.step()) { + if (token.type !== "comment.multiline") + continue; + if (dir == 1) { + startColumn = 6; + if (token.value == "=end") { + break; + } + } else { + if (token.value == "=begin") { + break; + } + } + } + } else { + while (token = stream.step()) { + var ignore = false; + if (token.type !== "keyword") + continue; + var level = dir * this.indentKeywords[token.value]; + line = session.getLine(stream.getCurrentTokenRow()); + switch (token.value) { + case "do": + for (var i = stream.$tokenIndex - 1; i >= 0; i--) { + var prevToken = stream.$rowTokens[i]; + if (prevToken && (prevToken.value == "while" || prevToken.value == "until" || prevToken.value == "for")) { + level = 0; + break; + } + } + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + level = 0; + ignore = true; + } + break; + case "when": + if (/\sthen\s/.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + } + + if (level > 0) { + stack.unshift(token.value); + } else if (level <= 0 && ignore === false) { + stack.shift(); + if (!stack.length) { + if ((val == "while" || val == "until" || val == "for") && token.value != "do") { + break; + } + if (token.value == "do" && dir == -1 && level != 0) + break; + if (token.value != "do") + break; + } + + if (level === 0) { + stack.unshift(token.value); + } + } } } - if (prevIndent!= -1 && prevIndent < indent) - session.foldWidgets[row - 1] = "start"; - else - session.foldWidgets[row - 1] = ""; + if (!token) + return null; - if (indent < nextIndent) - return "start"; - else - return ""; + if (tokenRange) { + ranges.push(stream.getCurrentTokenRange()); + return ranges; + } + + var row = stream.getCurrentTokenRow(); + if (dir === -1) { + if (token.type === "comment.multiline") { + var endColumn = 6; + } else { + var endColumn = session.getLine(row).length; + } + return new Range(row, endColumn, startRow - 1, startColumn); + } else + return new Range(startRow, startColumn, row - 1, session.getLine(row - 1).length); }; }).call(FoldMode.prototype); }); -define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module) { +define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/ruby"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); @@ -2943,13 +3437,14 @@ var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; -var FoldMode = require("./folding/coffee").FoldMode; +var FoldMode = require("./folding/ruby").FoldMode; var Mode = function() { this.HighlightRules = RubyHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new FoldMode(); + this.indentKeywords = this.foldingRules.indentKeywords; }; oop.inherits(Mode, TextMode); @@ -2964,7 +3459,7 @@ oop.inherits(Mode, TextMode); var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokens = tokenizedLine.tokens; - if (tokens.length && tokens[tokens.length-1].type == "comment") { + if (tokens.length && tokens[tokens.length - 1].type == "comment") { return indent; } @@ -2972,7 +3467,7 @@ oop.inherits(Mode, TextMode); var match = line.match(/^.*[\{\(\[]\s*$/); var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/); var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/); - var startingConditional = line.match(/^\s*(if|else|when)\s*/); + var startingConditional = line.match(/^\s*(if|else|when|elsif|unless|while|for|begin|rescue|ensure)\s*/); if (match || startingClassOrMethod || startingDoBlock || startingConditional) { indent += tab; } @@ -2982,7 +3477,7 @@ oop.inherits(Mode, TextMode); }; this.checkOutdent = function(state, line, input) { - return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input); + return /^\s+(end|else|rescue|ensure)$/.test(line + input) || this.$outdent.checkOutdent(line, input); }; this.autoOutdent = function(state, session, row) { @@ -2995,11 +3490,24 @@ oop.inherits(Mode, TextMode); var tab = session.getTabString(); if (prevIndent.length <= indent.length) { if (indent.slice(-tab.length) == tab) - session.remove(new Range(row, indent.length-tab.length, row, indent.length)); + session.remove(new Range(row, indent.length - tab.length, row, indent.length)); } }; + this.getMatching = function(session, row, column) { + if (row == undefined) { + var pos = session.selection.lead; + column = pos.column; + row = pos.row; + } + + var startToken = session.getTokenAt(row, column); + if (startToken && startToken.value in this.indentKeywords) + return this.foldingRules.rubyBlock(session, row, column, true); + }; + this.$id = "ace/mode/ruby"; + this.snippetFileId = "ace/snippets/ruby"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-io.js b/htdocs/includes/ace/src/mode-io.js index aba935b2011..452a803f8d7 100644 --- a/htdocs/includes/ace/src/mode-io.js +++ b/htdocs/includes/ace/src/mode-io.js @@ -234,6 +234,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "//"; this.blockComment = {start: "/*", end: "*/"}; this.$id = "ace/mode/io"; + this.snippetFileId = "ace/snippets/io"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-java.js b/htdocs/includes/ace/src/mode-java.js index ed9cbe351ba..b61e2a90a78 100644 --- a/htdocs/includes/ace/src/mode-java.js +++ b/htdocs/includes/ace/src/mode-java.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -909,7 +910,7 @@ var JavaHighlightRules = function() { regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + regex : "!|\\$|%|&|\\||\\^|\\*|\\/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\*=|\\/=|%=|\\+=|\\-=|&=|\\|=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" }, { token : "lparen", regex : "[[({]" @@ -1023,6 +1024,7 @@ oop.inherits(Mode, JavaScriptMode); }; this.$id = "ace/mode/java"; + this.snippetFileId = "ace/snippets/java"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-javascript.js b/htdocs/includes/ace/src/mode-javascript.js index f9640e85d95..be3d822c23d 100644 --- a/htdocs/includes/ace/src/mode-javascript.js +++ b/htdocs/includes/ace/src/mode-javascript.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-json.js b/htdocs/includes/ace/src/mode-json.js index 5ade1857f98..2446e39c6a1 100644 --- a/htdocs/includes/ace/src/mode-json.js +++ b/htdocs/includes/ace/src/mode-json.js @@ -275,6 +275,9 @@ oop.inherits(Mode, TextMode); (function() { + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; + this.getNextLineIndent = function(state, line, tab) { var indent = this.$getIndent(line); diff --git a/htdocs/includes/ace/src/mode-jsoniq.js b/htdocs/includes/ace/src/mode-jsoniq.js index 2d717609bd9..323317aa4ae 100644 --- a/htdocs/includes/ace/src/mode-jsoniq.js +++ b/htdocs/includes/ace/src/mode-jsoniq.js @@ -2618,6 +2618,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/jsoniq"; + this.snippetFileId = "ace/snippets/jsoniq"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-jsp.js b/htdocs/includes/ace/src/mode-jsp.js index 42cc5f54321..b6c4233441a 100644 --- a/htdocs/includes/ace/src/mode-jsp.js +++ b/htdocs/includes/ace/src/mode-jsp.js @@ -1122,7 +1122,7 @@ var JavaHighlightRules = function() { regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + regex : "!|\\$|%|&|\\||\\^|\\*|\\/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\*=|\\/=|%=|\\+=|\\-=|&=|\\|=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" }, { token : "lparen", regex : "[[({]" @@ -1419,6 +1419,7 @@ oop.inherits(Mode, TextMode); (function() { this.$id = "ace/mode/jsp"; + this.snippetFileId = "ace/snippets/jsp"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-kotlin.js b/htdocs/includes/ace/src/mode-kotlin.js index 11021b5890a..394271de33c 100644 --- a/htdocs/includes/ace/src/mode-kotlin.js +++ b/htdocs/includes/ace/src/mode-kotlin.js @@ -781,6 +781,8 @@ var Mode = function() { oop.inherits(Mode, TextMode); (function() { + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; this.$id = "ace/mode/kotlin"; }).call(Mode.prototype); diff --git a/htdocs/includes/ace/src/mode-latte.js b/htdocs/includes/ace/src/mode-latte.js new file mode 100644 index 00000000000..0377c843865 --- /dev/null +++ b/htdocs/includes/ace/src/mode-latte.js @@ -0,0 +1,2708 @@ +define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, + DocCommentHighlightRules.getTagRule(), + { + defaultToken : "comment.doc", + caseInsensitive: true + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getTagRule = function(start) { + return { + token : "comment.doc.tag.storage.type", + regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b" + }; +}; + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*"; + +var JavaScriptHighlightRules = function(options) { + var keywordMapper = this.createKeywordMapper({ + "variable.language": + "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors + "Namespace|QName|XML|XMLList|" + // E4X + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors + "SyntaxError|TypeError|URIError|" + + "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions + "isNaN|parseFloat|parseInt|" + + "JSON|Math|" + // Other + "this|arguments|prototype|window|document" , // Pseudo + "keyword": + "const|yield|import|get|set|async|await|" + + "break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" + + "__parent__|__count__|escape|unescape|with|__proto__|" + + "class|enum|extends|super|export|implements|private|public|interface|package|protected|static", + "storage.type": + "const|let|var|function", + "constant.language": + "null|Infinity|NaN|undefined", + "support.function": + "alert", + "constant.language.boolean": "true|false" + }, "identifier"); + var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void"; + + var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex + "u[0-9a-fA-F]{4}|" + // unicode + "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode + "[0-2][0-7]{0,2}|" + // oct + "3[0-7][0-7]?|" + // oct + "[4-7][0-7]?|" + //oct + ".)"; + + this.$rules = { + "no_regex" : [ + DocCommentHighlightRules.getStartRule("doc-start"), + comments("no_regex"), + { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hexadecimal, octal and binary + regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/ + }, { + token : "constant.numeric", // decimal integers and floats + regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/ + }, { + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "keyword", + regex : "from(?=\\s*('|\"))" + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "start" + }, { + token : ["support.constant"], + regex : /that\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "punctuation.operator", + regex : /[.](?![.])/, + next : "property" + }, { + token : "storage.type", + regex : /=>/, + next : "start" + }, { + token : "keyword.operator", + regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/, + next : "start" + }, { + token : "punctuation.operator", + regex : /[?:,;.]/, + next : "start" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "start" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token: "comment", + regex: /^#!.*$/ + } + ], + property: [{ + token : "text", + regex : "\\s+" + }, { + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()", + next: "function_arguments" + }, { + token : "punctuation.operator", + regex : /[.](?![.])/ + }, { + token : "support.function", + regex : /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : "support.function.dom", + regex : /(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : "support.constant", + regex : /(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : "identifier", + regex : identifierRe + }, { + regex: "", + token: "empty", + next: "no_regex" + } + ], + "start": [ + DocCommentHighlightRules.getStartRule("doc-start"), + comments("start"), + { + token: "string.regexp", + regex: "\\/", + next: "regex" + }, { + token : "text", + regex : "\\s+|^$", + next : "start" + }, { + token: "empty", + regex: "", + next: "no_regex" + } + ], + "regex": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "string.regexp", + regex: "/[sxngimy]*", + next: "no_regex" + }, { + token : "invalid", + regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ + }, { + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ + }, { + token : "constant.language.delimiter", + regex: /\|/ + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class" + }, { + token: "empty", + regex: "$", + next: "no_regex" + }, { + defaultToken: "string.regexp" + } + ], + "regex_character_class": [ + { + token: "regexp.charclass.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex" + }, { + token: "constant.language.escape", + regex: "-" + }, { + token: "empty", + regex: "$", + next: "no_regex" + }, { + defaultToken: "string.regexp.charachterclass" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+" + }, { + token: "punctuation.operator", + regex: "$" + }, { + token: "empty", + regex: "", + next: "no_regex" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "\\\\$", + consumeLineEnd : true + }, { + token : "string", + regex : '"|$', + next : "no_regex" + }, { + defaultToken: "string" + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "\\\\$", + consumeLineEnd : true + }, { + token : "string", + regex : "'|$", + next : "no_regex" + }, { + defaultToken: "string" + } + ] + }; + + + if (!options || !options.noES6) { + this.$rules.no_regex.unshift({ + regex: "[{}]", onMatch: function(val, state, stack) { + this.next = val == "{" ? this.nextState : ""; + if (val == "{" && stack.length) { + stack.unshift("start", state); + } + else if (val == "}" && stack.length) { + stack.shift(); + this.next = stack.shift(); + if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1) + return "paren.quasi.end"; + } + return val == "{" ? "paren.lparen" : "paren.rparen"; + }, + nextState: "start" + }, { + token : "string.quasi.start", + regex : /`/, + push : [{ + token : "constant.language.escape", + regex : escapedRe + }, { + token : "paren.quasi.start", + regex : /\${/, + push : "start" + }, { + token : "string.quasi.end", + regex : /`/, + next : "pop" + }, { + defaultToken: "string.quasi" + }] + }); + + if (!options || options.jsx != false) + JSX.call(this); + } + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("no_regex") ]); + + this.normalizeRules(); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +function JSX() { + var tagRegex = identifierRe.replace("\\d", "\\d\\-"); + var jsxTag = { + onMatch : function(val, state, stack) { + var offset = val.charAt(1) == "/" ? 2 : 1; + if (offset == 1) { + if (state != this.nextState) + stack.unshift(this.next, this.nextState, 0); + else + stack.unshift(this.next); + stack[2]++; + } else if (offset == 2) { + if (state == this.nextState) { + stack[1]--; + if (!stack[1] || stack[1] < 0) { + stack.shift(); + stack.shift(); + } + } + } + return [{ + type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml", + value: val.slice(0, offset) + }, { + type: "meta.tag.tag-name.xml", + value: val.substr(offset) + }]; + }, + regex : "", + onMatch : function(value, currentState, stack) { + if (currentState == stack[0]) + stack.shift(); + if (value.length == 2) { + if (stack[0] == this.nextState) + stack[1]--; + if (!stack[1] || stack[1] < 0) { + stack.splice(0, 2); + } + } + this.next = stack[0] || "start"; + return [{type: this.token, value: value}]; + }, + nextState: "jsx" + }, + jsxJsRule, + comments("jsxAttributes"), + { + token : "entity.other.attribute-name.xml", + regex : tagRegex + }, { + token : "keyword.operator.attribute-equals.xml", + regex : "=" + }, { + token : "text.tag-whitespace.xml", + regex : "\\s+" + }, { + token : "string.attribute-value.xml", + regex : "'", + stateName : "jsx_attr_q", + push : [ + {token : "string.attribute-value.xml", regex: "'", next: "pop"}, + {include : "reference"}, + {defaultToken : "string.attribute-value.xml"} + ] + }, { + token : "string.attribute-value.xml", + regex : '"', + stateName : "jsx_attr_qq", + push : [ + {token : "string.attribute-value.xml", regex: '"', next: "pop"}, + {include : "reference"}, + {defaultToken : "string.attribute-value.xml"} + ] + }, + jsxTag + ]; + this.$rules.reference = [{ + token : "constant.language.escape.reference.xml", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }]; +} + +function comments(next) { + return [ + { + token : "comment", // multi line comment + regex : /\/\*/, + next: [ + DocCommentHighlightRules.getTagRule(), + {token : "comment", regex : "\\*\\/", next : next || "pop"}, + {defaultToken : "comment", caseInsensitive: true} + ] + }, { + token : "comment", + regex : "\\/\\/", + next: [ + DocCommentHighlightRules.getTagRule(), + {token : "comment", regex : "$|^", next : next || "pop"}, + {defaultToken : "comment", caseInsensitive: true} + ] + } + ]; +} +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) { +"use strict"; + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + return line.match(/^\s*/)[0]; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = JavaScriptHighlightRules; + + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; + this.$quotes = {'"': '"', "'": "'", "`": "`"}; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.getTokenizer().getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "no_regex") { + var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || endState == "no_regex") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("annotate", function(results) { + session.setAnnotations(results.data); + }); + + worker.on("terminate", function() { + session.clearAnnotations(); + }); + + return worker; + }; + + this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +define("ace/mode/css_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var supportType = exports.supportType = "align-content|align-items|align-self|all|animation|animation-delay|animation-direction|animation-duration|animation-fill-mode|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|backface-visibility|background|background-attachment|background-blend-mode|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|border|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|bottom|box-shadow|box-sizing|caption-side|clear|clip|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|cursor|direction|display|empty-cells|filter|flex|flex-basis|flex-direction|flex-flow|flex-grow|flex-shrink|flex-wrap|float|font|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|hanging-punctuation|height|justify-content|left|letter-spacing|line-height|list-style|list-style-image|list-style-position|list-style-type|margin|margin-bottom|margin-left|margin-right|margin-top|max-height|max-width|max-zoom|min-height|min-width|min-zoom|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|order|outline|outline-color|outline-offset|outline-style|outline-width|overflow|overflow-x|overflow-y|padding|padding-bottom|padding-left|padding-right|padding-top|page-break-after|page-break-before|page-break-inside|perspective|perspective-origin|position|quotes|resize|right|tab-size|table-layout|text-align|text-align-last|text-decoration|text-decoration-color|text-decoration-line|text-decoration-style|text-indent|text-justify|text-overflow|text-shadow|text-transform|top|transform|transform-origin|transform-style|transition|transition-delay|transition-duration|transition-property|transition-timing-function|unicode-bidi|user-select|user-zoom|vertical-align|visibility|white-space|width|word-break|word-spacing|word-wrap|z-index"; +var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters"; +var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero|zoom"; +var supportConstantColor = exports.supportConstantColor = "aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen"; +var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace"; + +var numRe = exports.numRe = "\\-?(?:(?:[0-9]+(?:\\.[0-9]+)?)|(?:\\.[0-9]+))"; +var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; +var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + +var CssHighlightRules = function() { + + var keywordMapper = this.createKeywordMapper({ + "support.function": supportFunction, + "support.constant": supportConstant, + "support.type": supportType, + "support.constant.color": supportConstantColor, + "support.constant.fonts": supportConstantFonts + }, "text", true); + + this.$rules = { + "start" : [{ + include : ["strings", "url", "comments"] + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "paren.rparen", + regex: "\\}" + }, { + token: "string", + regex: "@(?!viewport)", + next: "media" + }, { + token: "keyword", + regex: "#[a-z0-9-_]+" + }, { + token: "keyword", + regex: "%" + }, { + token: "variable", + regex: "\\.[a-z0-9-_]+" + }, { + token: "string", + regex: ":[a-z0-9-_]+" + }, { + token : "constant.numeric", + regex : numRe + }, { + token: "constant", + regex: "[a-z0-9-_]+" + }, { + caseInsensitive: true + }], + + "media": [{ + include : ["strings", "url", "comments"] + }, { + token: "paren.lparen", + regex: "\\{", + next: "start" + }, { + token: "paren.rparen", + regex: "\\}", + next: "start" + }, { + token: "string", + regex: ";", + next: "start" + }, { + token: "keyword", + regex: "(?:media|supports|document|charset|import|namespace|media|supports|document" + + "|page|font|keyframes|viewport|counter-style|font-feature-values" + + "|swash|ornaments|annotation|stylistic|styleset|character-variant)" + }], + + "comments" : [{ + token: "comment", // multi line comment + regex: "\\/\\*", + push: [{ + token : "comment", + regex : "\\*\\/", + next : "pop" + }, { + defaultToken : "comment" + }] + }], + + "ruleset" : [{ + regex : "-(webkit|ms|moz|o)-", + token : "text" + }, { + token : "punctuation.operator", + regex : "[:;]" + }, { + token : "paren.rparen", + regex : "\\}", + next : "start" + }, { + include : ["strings", "url", "comments"] + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vmax|vmin|vm|vw|%)" + }, { + token : "constant.numeric", + regex : numRe + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + include: "url" + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + }, { + caseInsensitive: true + }], + + url: [{ + token : "support.function", + regex : "(?:url(:?-prefix)?|domain|regexp)\\(", + push: [{ + token : "support.function", + regex : "\\)", + next : "pop" + }, { + defaultToken: "string" + }] + }], + + strings: [{ + token : "string.start", + regex : "'", + push : [{ + token : "string.end", + regex : "'|$", + next: "pop" + }, { + include : "escapes" + }, { + token : "constant.language.escape", + regex : /\\$/, + consumeLineEnd: true + }, { + defaultToken: "string" + }] + }, { + token : "string.start", + regex : '"', + push : [{ + token : "string.end", + regex : '"|$', + next: "pop" + }, { + include : "escapes" + }, { + token : "constant.language.escape", + regex : /\\$/, + consumeLineEnd: true + }, { + defaultToken: "string" + }] + }], + escapes: [{ + token : "constant.language.escape", + regex : /\\([a-fA-F\d]{1,6}|[^a-fA-F\d])/ + }] + + }; + + this.normalizeRules(); +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +define("ace/mode/css_completions",["require","exports","module"], function(require, exports, module) { +"use strict"; + +var propertyMap = { + "background": {"#$0": 1}, + "background-color": {"#$0": 1, "transparent": 1, "fixed": 1}, + "background-image": {"url('/$0')": 1}, + "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1}, + "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2}, + "background-attachment": {"scroll": 1, "fixed": 1}, + "background-size": {"cover": 1, "contain": 1}, + "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1}, + "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1}, + "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1}, + "border-color": {"#$0": 1}, + "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2}, + "border-collapse": {"collapse": 1, "separate": 1}, + "bottom": {"px": 1, "em": 1, "%": 1}, + "clear": {"left": 1, "right": 1, "both": 1, "none": 1}, + "color": {"#$0": 1, "rgb(#$00,0,0)": 1}, + "cursor": {"default": 1, "pointer": 1, "move": 1, "text": 1, "wait": 1, "help": 1, "progress": 1, "n-resize": 1, "ne-resize": 1, "e-resize": 1, "se-resize": 1, "s-resize": 1, "sw-resize": 1, "w-resize": 1, "nw-resize": 1}, + "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1}, + "empty-cells": {"show": 1, "hide": 1}, + "float": {"left": 1, "right": 1, "none": 1}, + "font-family": {"Arial":2,"Comic Sans MS":2,"Consolas":2,"Courier New":2,"Courier":2,"Georgia":2,"Monospace":2,"Sans-Serif":2, "Segoe UI":2,"Tahoma":2,"Times New Roman":2,"Trebuchet MS":2,"Verdana": 1}, + "font-size": {"px": 1, "em": 1, "%": 1}, + "font-weight": {"bold": 1, "normal": 1}, + "font-style": {"italic": 1, "normal": 1}, + "font-variant": {"normal": 1, "small-caps": 1}, + "height": {"px": 1, "em": 1, "%": 1}, + "left": {"px": 1, "em": 1, "%": 1}, + "letter-spacing": {"normal": 1}, + "line-height": {"normal": 1}, + "list-style-type": {"none": 1, "disc": 1, "circle": 1, "square": 1, "decimal": 1, "decimal-leading-zero": 1, "lower-roman": 1, "upper-roman": 1, "lower-greek": 1, "lower-latin": 1, "upper-latin": 1, "georgian": 1, "lower-alpha": 1, "upper-alpha": 1}, + "margin": {"px": 1, "em": 1, "%": 1}, + "margin-right": {"px": 1, "em": 1, "%": 1}, + "margin-left": {"px": 1, "em": 1, "%": 1}, + "margin-top": {"px": 1, "em": 1, "%": 1}, + "margin-bottom": {"px": 1, "em": 1, "%": 1}, + "max-height": {"px": 1, "em": 1, "%": 1}, + "max-width": {"px": 1, "em": 1, "%": 1}, + "min-height": {"px": 1, "em": 1, "%": 1}, + "min-width": {"px": 1, "em": 1, "%": 1}, + "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1}, + "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1}, + "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1}, + "padding": {"px": 1, "em": 1, "%": 1}, + "padding-top": {"px": 1, "em": 1, "%": 1}, + "padding-right": {"px": 1, "em": 1, "%": 1}, + "padding-bottom": {"px": 1, "em": 1, "%": 1}, + "padding-left": {"px": 1, "em": 1, "%": 1}, + "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1}, + "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1}, + "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1}, + "right": {"px": 1, "em": 1, "%": 1}, + "table-layout": {"fixed": 1, "auto": 1}, + "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1}, + "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1}, + "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1}, + "top": {"px": 1, "em": 1, "%": 1}, + "vertical-align": {"top": 1, "bottom": 1}, + "visibility": {"hidden": 1, "visible": 1}, + "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1}, + "width": {"px": 1, "em": 1, "%": 1}, + "word-spacing": {"normal": 1}, + "filter": {"alpha(opacity=$0100)": 1}, + + "text-shadow": {"$02px 2px 2px #777": 1}, + "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1}, + "-moz-border-radius": 1, + "-moz-border-radius-topright": 1, + "-moz-border-radius-bottomright": 1, + "-moz-border-radius-topleft": 1, + "-moz-border-radius-bottomleft": 1, + "-webkit-border-radius": 1, + "-webkit-border-top-right-radius": 1, + "-webkit-border-top-left-radius": 1, + "-webkit-border-bottom-right-radius": 1, + "-webkit-border-bottom-left-radius": 1, + "-moz-box-shadow": 1, + "-webkit-box-shadow": 1, + "transform": {"rotate($00deg)": 1, "skew($00deg)": 1}, + "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1}, + "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 } +}; + +var CssCompletions = function() { + +}; + +(function() { + + this.completionsDefined = false; + + this.defineCompletions = function() { + if (document) { + var style = document.createElement('c').style; + + for (var i in style) { + if (typeof style[i] !== 'string') + continue; + + var name = i.replace(/[A-Z]/g, function(x) { + return '-' + x.toLowerCase(); + }); + + if (!propertyMap.hasOwnProperty(name)) + propertyMap[name] = 1; + } + } + + this.completionsDefined = true; + }; + + this.getCompletions = function(state, session, pos, prefix) { + if (!this.completionsDefined) { + this.defineCompletions(); + } + + if (state==='ruleset' || session.$mode.$id == "ace/mode/scss") { + var line = session.getLine(pos.row).substr(0, pos.column); + if (/:[^;]+$/.test(line)) { + /([\w\-]+):[^:]*$/.test(line); + + return this.getPropertyValueCompletions(state, session, pos, prefix); + } else { + return this.getPropertyCompletions(state, session, pos, prefix); + } + } + + return []; + }; + + this.getPropertyCompletions = function(state, session, pos, prefix) { + var properties = Object.keys(propertyMap); + return properties.map(function(property){ + return { + caption: property, + snippet: property + ': $0;', + meta: "property", + score: 1000000 + }; + }); + }; + + this.getPropertyValueCompletions = function(state, session, pos, prefix) { + var line = session.getLine(pos.row).substr(0, pos.column); + var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1]; + + if (!property) + return []; + var values = []; + if (property in propertyMap && typeof propertyMap[property] === "object") { + values = Object.keys(propertyMap[property]); + } + return values.map(function(value){ + return { + caption: value, + snippet: value, + meta: "property value", + score: 1000000 + }; + }); + }; + +}).call(CssCompletions.prototype); + +exports.CssCompletions = CssCompletions; +}); + +define("ace/mode/behaviour/css",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +var CssBehaviour = function () { + + this.inherit(CstyleBehaviour); + + this.add("colon", "insertion", function (state, action, editor, session, text) { + if (text === ':' && editor.selection.isEmpty()) { + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + if (token && token.value.match(/\s+/)) { + token = iterator.stepBackward(); + } + if (token && token.type === 'support.type') { + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar === ':') { + return { + text: '', + selection: [1, 1] + }; + } + if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) { + return { + text: ':;', + selection: [1, 1] + }; + } + } + } + }); + + this.add("colon", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected === ':') { + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + if (token && token.value.match(/\s+/)) { + token = iterator.stepBackward(); + } + if (token && token.type === 'support.type') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar === ';') { + range.end.column ++; + return range; + } + } + } + }); + + this.add("semicolon", "insertion", function (state, action, editor, session, text) { + if (text === ';' && editor.selection.isEmpty()) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar === ';') { + return { + text: '', + selection: [1, 1] + }; + } + } + }); + + this.add("!important", "insertion", function (state, action, editor, session, text) { + if (text === '!' && editor.selection.isEmpty()) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + + if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) { + return { + text: '!important', + selection: [10, 10] + }; + } + } + }); + +}; +oop.inherits(CssBehaviour, CstyleBehaviour); + +exports.CssBehaviour = CssBehaviour; +}); + +define("ace/mode/css",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/css_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/css_completions","ace/mode/behaviour/css","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CssCompletions = require("./css_completions").CssCompletions; +var CssBehaviour = require("./behaviour/css").CssBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = CssHighlightRules; + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CssBehaviour(); + this.$completer = new CssCompletions(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + this.blockComment = {start: "/*", end: "*/"}; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var tokens = this.getTokenizer().getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.getCompletions = function(state, session, pos, prefix) { + return this.$completer.getCompletions(state, session, pos, prefix); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("annotate", function(e) { + session.setAnnotations(e.data); + }); + + worker.on("terminate", function() { + session.clearAnnotations(); + }); + + return worker; + }; + + this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var XmlHighlightRules = function(normalize) { + var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*"; + + this.$rules = { + start : [ + {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"}, + { + token : ["punctuation.instruction.xml", "keyword.instruction.xml"], + regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction" + }, + {token : "comment.start.xml", regex : "<\\!--", next : "comment"}, + { + token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"], + regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true + }, + {include : "tag"}, + {token : "text.end-tag-open.xml", regex: "", + next : "start" + }], + + doctype : [ + {include : "whitespace"}, + {include : "string"}, + {token : "xml-pe.doctype.xml", regex : ">", next : "start"}, + {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"}, + {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"} + ], + + int_subset : [{ + token : "text.xml", + regex : "\\s+" + }, { + token: "punctuation.int-subset.xml", + regex: "]", + next: "pop" + }, { + token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"], + regex : "(<\\!)(" + tagRegex + ")", + push : [{ + token : "text", + regex : "\\s+" + }, + { + token : "punctuation.markup-decl.xml", + regex : ">", + next : "pop" + }, + {include : "string"}] + }], + + cdata : [ + {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"}, + {token : "text.xml", regex : "\\s+"}, + {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"} + ], + + comment : [ + {token : "comment.end.xml", regex : "-->", next : "start"}, + {defaultToken : "comment.xml"} + ], + + reference : [{ + token : "constant.language.escape.reference.xml", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }], + + attr_reference : [{ + token : "constant.language.escape.reference.attribute-value.xml", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }], + + tag : [{ + token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"], + regex : "(?:(<)|(", next : "start"} + ] + }], + + tag_whitespace : [ + {token : "text.tag-whitespace.xml", regex : "\\s+"} + ], + whitespace : [ + {token : "text.whitespace.xml", regex : "\\s+"} + ], + string: [{ + token : "string.xml", + regex : "'", + push : [ + {token : "string.xml", regex: "'", next: "pop"}, + {defaultToken : "string.xml"} + ] + }, { + token : "string.xml", + regex : '"', + push : [ + {token : "string.xml", regex: '"', next: "pop"}, + {defaultToken : "string.xml"} + ] + }], + + attributes: [{ + token : "entity.other.attribute-name.xml", + regex : tagRegex + }, { + token : "keyword.operator.attribute-equals.xml", + regex : "=" + }, { + include: "tag_whitespace" + }, { + include: "attribute_value" + }], + + attribute_value: [{ + token : "string.attribute-value.xml", + regex : "'", + push : [ + {token : "string.attribute-value.xml", regex: "'", next: "pop"}, + {include : "attr_reference"}, + {defaultToken : "string.attribute-value.xml"} + ] + }, { + token : "string.attribute-value.xml", + regex : '"', + push : [ + {token : "string.attribute-value.xml", regex: '"', next: "pop"}, + {include : "attr_reference"}, + {defaultToken : "string.attribute-value.xml"} + ] + }] + }; + + if (this.constructor === XmlHighlightRules) + this.normalizeRules(); +}; + + +(function() { + + this.embedTagRules = function(HighlightRules, prefix, tag){ + this.$rules.tag.unshift({ + token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"], + regex : "(<)(" + tag + "(?=\\s|>|$))", + next: [ + {include : "attributes"}, + {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"} + ] + }); + + this.$rules[tag + "-end"] = [ + {include : "attributes"}, + {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start", + onMatch : function(value, currentState, stack) { + stack.splice(0); + return this.token; + }} + ]; + + this.embedRules(HighlightRules, prefix, [{ + token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"], + regex : "(|$))", + next: tag + "-end" + }, { + token: "string.cdata.xml", + regex : "<\\!\\[CDATA\\[" + }, { + token: "string.cdata.xml", + regex : "\\]\\]>" + }]); + }; + +}).call(TextHighlightRules.prototype); + +oop.inherits(XmlHighlightRules, TextHighlightRules); + +exports.XmlHighlightRules = XmlHighlightRules; +}); + +define("ace/mode/html_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/css_highlight_rules","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; + +var tagMap = lang.createMap({ + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + option : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}); + +var HtmlHighlightRules = function() { + XmlHighlightRules.call(this); + + this.addRules({ + attributes: [{ + include : "tag_whitespace" + }, { + token : "entity.other.attribute-name.xml", + regex : "[-_a-zA-Z0-9:.]+" + }, { + token : "keyword.operator.attribute-equals.xml", + regex : "=", + push : [{ + include: "tag_whitespace" + }, { + token : "string.unquoted.attribute-value.html", + regex : "[^<>='\"`\\s]+", + next : "pop" + }, { + token : "empty", + regex : "", + next : "pop" + }] + }, { + include : "attribute_value" + }], + tag: [{ + token : function(start, tag) { + var group = tagMap[tag]; + return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml", + "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"]; + }, + regex : "(", next : "start"} + ] + }); + + this.embedTagRules(CssHighlightRules, "css-", "style"); + this.embedTagRules(new JavaScriptHighlightRules({jsx: false}).getRules(), "js-", "script"); + + if (this.constructor === HtmlHighlightRules) + this.normalizeRules(); +}; + +oop.inherits(HtmlHighlightRules, XmlHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; +var lang = require("../../lib/lang"); + +function is(token, type) { + return token && token.type.lastIndexOf(type + ".xml") > -1; +} + +var XmlBehaviour = function () { + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selected = session.doc.getTextRange(editor.getSelectionRange()); + if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { + return { + text: quote + selected + quote, + selection: false + }; + } + + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + + if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) { + return { + text: "", + selection: [1, 1] + }; + } + + if (!token) + token = iterator.stepBackward(); + + if (!token) + return; + + while (is(token, "tag-whitespace") || is(token, "whitespace")) { + token = iterator.stepBackward(); + } + var rightSpace = !rightChar || rightChar.match(/\s/); + if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) { + return { + text: quote + quote, + selection: [1, 1] + }; + } + } + }); + + this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == selected) { + range.end.column++; + return range; + } + } + }); + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getSelectionRange().start; + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken() || iterator.stepBackward(); + if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value"))) + return; + if (is(token, "reference.attribute-value")) + return; + if (is(token, "attribute-value")) { + var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length; + if (position.column < tokenEndColumn) + return; + if (position.column == tokenEndColumn) { + var nextToken = iterator.stepForward(); + if (nextToken && is(nextToken, "attribute-value")) + return; + iterator.stepBackward(); + } + } + + if (/^\s*>/.test(session.getLine(position.row).slice(position.column))) + return; + while (!is(token, "tag-name")) { + token = iterator.stepBackward(); + if (token.value == "<") { + token = iterator.stepForward(); + break; + } + } + + var tokenRow = iterator.getCurrentTokenRow(); + var tokenColumn = iterator.getCurrentTokenColumn(); + if (is(iterator.stepBackward(), "end-tag-open")) + return; + + var element = token.value; + if (tokenRow == position.row) + element = element.substring(0, position.column - tokenColumn); + + if (this.voidElements.hasOwnProperty(element.toLowerCase())) + return; + + return { + text: ">" + "", + selection: [1, 1] + }; + } + }); + + this.add("autoindent", "insertion", function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.getLine(cursor.row); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + + if (token && token.type.indexOf("tag-close") !== -1) { + if (token.value == "/>") + return; + while (token && token.type.indexOf("tag-name") === -1) { + token = iterator.stepBackward(); + } + + if (!token) { + return; + } + + var tag = token.value; + var row = iterator.getCurrentTokenRow(); + token = iterator.stepBackward(); + if (!token || token.type.indexOf("end-tag") !== -1) { + return; + } + + if (this.voidElements && !this.voidElements[tag]) { + var nextToken = session.getTokenAt(cursor.row, cursor.column+1); + var line = session.getLine(row); + var nextIndent = this.$getIndent(line); + var indent = nextIndent + session.getTabString(); + + if (nextToken && nextToken.value === " -1; +} + +(function() { + + this.getFoldWidget = function(session, foldStyle, row) { + var tag = this._getFirstTagInLine(session, row); + + if (!tag) + return this.getCommentFoldWidget(session, row); + + if (tag.closing || (!tag.tagName && tag.selfClosing)) + return foldStyle == "markbeginend" ? "end" : ""; + + if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase())) + return ""; + + if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column)) + return ""; + + return "start"; + }; + + this.getCommentFoldWidget = function(session, row) { + if (/comment/.test(session.getState(row)) && /'; + break; + } + } + return tag; + } else if (is(token, "tag-close")) { + tag.selfClosing = token.value == '/>'; + return tag; + } + tag.start.column += token.value.length; + } + + return null; + }; + + this._findEndTagInLine = function(session, row, tagName, startColumn) { + var tokens = session.getTokens(row); + var column = 0; + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + column += token.value.length; + if (column < startColumn) + continue; + if (is(token, "end-tag-open")) { + token = tokens[i + 1]; + if (token && token.value == tagName) + return true; + } + } + return false; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var tag = new Tag(); + do { + if (is(token, "tag-open")) { + tag.closing = is(token, "end-tag-open"); + tag.start.row = iterator.getCurrentTokenRow(); + tag.start.column = iterator.getCurrentTokenColumn(); + } else if (is(token, "tag-name")) { + tag.tagName = token.value; + } else if (is(token, "tag-close")) { + tag.selfClosing = token.value == "/>"; + tag.end.row = iterator.getCurrentTokenRow(); + tag.end.column = iterator.getCurrentTokenColumn() + token.value.length; + iterator.stepForward(); + return tag; + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var tag = new Tag(); + do { + if (is(token, "tag-open")) { + tag.closing = is(token, "end-tag-open"); + tag.start.row = iterator.getCurrentTokenRow(); + tag.start.column = iterator.getCurrentTokenColumn(); + iterator.stepBackward(); + return tag; + } else if (is(token, "tag-name")) { + tag.tagName = token.value; + } else if (is(token, "tag-close")) { + tag.selfClosing = token.value == "/>"; + tag.end.row = iterator.getCurrentTokenRow(); + tag.end.column = iterator.getCurrentTokenColumn() + token.value.length; + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.optionalEndTags.hasOwnProperty(top.tagName)) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag) { + return this.getCommentFoldWidget(session, row) + && session.getCommentFoldRange(row, session.getLine(row).length); + } + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.start.column); + var start = { + row: row, + column: firstTag.start.column + firstTag.tagName.length + 2 + }; + if (firstTag.start.row == firstTag.end.row) + start.column = firstTag.end.column; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag); + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.end.column); + var end = { + row: row, + column: firstTag.start.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + if (tag.start.row == tag.end.row && tag.start.column < tag.end.column) + tag.start.column = tag.end.column; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag); + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/folding/html",["require","exports","module","ace/lib/oop","ace/mode/folding/mixed","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var MixedFoldMode = require("./mixed").FoldMode; +var XmlFoldMode = require("./xml").FoldMode; +var CStyleFoldMode = require("./cstyle").FoldMode; + +var FoldMode = exports.FoldMode = function(voidElements, optionalTags) { + MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), { + "js-": new CStyleFoldMode(), + "css-": new CStyleFoldMode() + }); +}; + +oop.inherits(FoldMode, MixedFoldMode); + +}); + +define("ace/mode/html_completions",["require","exports","module","ace/token_iterator"], function(require, exports, module) { +"use strict"; + +var TokenIterator = require("../token_iterator").TokenIterator; + +var commonAttributes = [ + "accesskey", + "class", + "contenteditable", + "contextmenu", + "dir", + "draggable", + "dropzone", + "hidden", + "id", + "inert", + "itemid", + "itemprop", + "itemref", + "itemscope", + "itemtype", + "lang", + "spellcheck", + "style", + "tabindex", + "title", + "translate" +]; + +var eventAttributes = [ + "onabort", + "onblur", + "oncancel", + "oncanplay", + "oncanplaythrough", + "onchange", + "onclick", + "onclose", + "oncontextmenu", + "oncuechange", + "ondblclick", + "ondrag", + "ondragend", + "ondragenter", + "ondragleave", + "ondragover", + "ondragstart", + "ondrop", + "ondurationchange", + "onemptied", + "onended", + "onerror", + "onfocus", + "oninput", + "oninvalid", + "onkeydown", + "onkeypress", + "onkeyup", + "onload", + "onloadeddata", + "onloadedmetadata", + "onloadstart", + "onmousedown", + "onmousemove", + "onmouseout", + "onmouseover", + "onmouseup", + "onmousewheel", + "onpause", + "onplay", + "onplaying", + "onprogress", + "onratechange", + "onreset", + "onscroll", + "onseeked", + "onseeking", + "onselect", + "onshow", + "onstalled", + "onsubmit", + "onsuspend", + "ontimeupdate", + "onvolumechange", + "onwaiting" +]; + +var globalAttributes = commonAttributes.concat(eventAttributes); + +var attributeMap = { + "a": {"href": 1, "target": {"_blank": 1, "top": 1}, "ping": 1, "rel": {"nofollow": 1, "alternate": 1, "author": 1, "bookmark": 1, "help": 1, "license": 1, "next": 1, "noreferrer": 1, "prefetch": 1, "prev": 1, "search": 1, "tag": 1}, "media": 1, "hreflang": 1, "type": 1}, + "abbr": {}, + "address": {}, + "area": {"shape": 1, "coords": 1, "href": 1, "hreflang": 1, "alt": 1, "target": 1, "media": 1, "rel": 1, "ping": 1, "type": 1}, + "article": {"pubdate": 1}, + "aside": {}, + "audio": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1 }}, + "b": {}, + "base": {"href": 1, "target": 1}, + "bdi": {}, + "bdo": {}, + "blockquote": {"cite": 1}, + "body": {"onafterprint": 1, "onbeforeprint": 1, "onbeforeunload": 1, "onhashchange": 1, "onmessage": 1, "onoffline": 1, "onpopstate": 1, "onredo": 1, "onresize": 1, "onstorage": 1, "onundo": 1, "onunload": 1}, + "br": {}, + "button": {"autofocus": 1, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": 1, "formmethod": 1, "formnovalidate": 1, "formtarget": 1, "name": 1, "value": 1, "type": {"button": 1, "submit": 1}}, + "canvas": {"width": 1, "height": 1}, + "caption": {}, + "cite": {}, + "code": {}, + "col": {"span": 1}, + "colgroup": {"span": 1}, + "command": {"type": 1, "label": 1, "icon": 1, "disabled": 1, "checked": 1, "radiogroup": 1, "command": 1}, + "data": {}, + "datalist": {}, + "dd": {}, + "del": {"cite": 1, "datetime": 1}, + "details": {"open": 1}, + "dfn": {}, + "dialog": {"open": 1}, + "div": {}, + "dl": {}, + "dt": {}, + "em": {}, + "embed": {"src": 1, "height": 1, "width": 1, "type": 1}, + "fieldset": {"disabled": 1, "form": 1, "name": 1}, + "figcaption": {}, + "figure": {}, + "footer": {}, + "form": {"accept-charset": 1, "action": 1, "autocomplete": 1, "enctype": {"multipart/form-data": 1, "application/x-www-form-urlencoded": 1}, "method": {"get": 1, "post": 1}, "name": 1, "novalidate": 1, "target": {"_blank": 1, "top": 1}}, + "h1": {}, + "h2": {}, + "h3": {}, + "h4": {}, + "h5": {}, + "h6": {}, + "head": {}, + "header": {}, + "hr": {}, + "html": {"manifest": 1}, + "i": {}, + "iframe": {"name": 1, "src": 1, "height": 1, "width": 1, "sandbox": {"allow-same-origin": 1, "allow-top-navigation": 1, "allow-forms": 1, "allow-scripts": 1}, "seamless": {"seamless": 1}}, + "img": {"alt": 1, "src": 1, "height": 1, "width": 1, "usemap": 1, "ismap": 1}, + "input": { + "type": {"text": 1, "password": 1, "hidden": 1, "checkbox": 1, "submit": 1, "radio": 1, "file": 1, "button": 1, "reset": 1, "image": 31, "color": 1, "date": 1, "datetime": 1, "datetime-local": 1, "email": 1, "month": 1, "number": 1, "range": 1, "search": 1, "tel": 1, "time": 1, "url": 1, "week": 1}, + "accept": 1, "alt": 1, "autocomplete": {"on": 1, "off": 1}, "autofocus": {"autofocus": 1}, "checked": {"checked": 1}, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": {"application/x-www-form-urlencoded": 1, "multipart/form-data": 1, "text/plain": 1}, "formmethod": {"get": 1, "post": 1}, "formnovalidate": {"formnovalidate": 1}, "formtarget": {"_blank": 1, "_self": 1, "_parent": 1, "_top": 1}, "height": 1, "list": 1, "max": 1, "maxlength": 1, "min": 1, "multiple": {"multiple": 1}, "name": 1, "pattern": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "size": 1, "src": 1, "step": 1, "width": 1, "files": 1, "value": 1}, + "ins": {"cite": 1, "datetime": 1}, + "kbd": {}, + "keygen": {"autofocus": 1, "challenge": {"challenge": 1}, "disabled": {"disabled": 1}, "form": 1, "keytype": {"rsa": 1, "dsa": 1, "ec": 1}, "name": 1}, + "label": {"form": 1, "for": 1}, + "legend": {}, + "li": {"value": 1}, + "link": {"href": 1, "hreflang": 1, "rel": {"stylesheet": 1, "icon": 1}, "media": {"all": 1, "screen": 1, "print": 1}, "type": {"text/css": 1, "image/png": 1, "image/jpeg": 1, "image/gif": 1}, "sizes": 1}, + "main": {}, + "map": {"name": 1}, + "mark": {}, + "math": {}, + "menu": {"type": 1, "label": 1}, + "meta": {"http-equiv": {"content-type": 1}, "name": {"description": 1, "keywords": 1}, "content": {"text/html; charset=UTF-8": 1}, "charset": 1}, + "meter": {"value": 1, "min": 1, "max": 1, "low": 1, "high": 1, "optimum": 1}, + "nav": {}, + "noscript": {"href": 1}, + "object": {"param": 1, "data": 1, "type": 1, "height" : 1, "width": 1, "usemap": 1, "name": 1, "form": 1, "classid": 1}, + "ol": {"start": 1, "reversed": 1}, + "optgroup": {"disabled": 1, "label": 1}, + "option": {"disabled": 1, "selected": 1, "label": 1, "value": 1}, + "output": {"for": 1, "form": 1, "name": 1}, + "p": {}, + "param": {"name": 1, "value": 1}, + "pre": {}, + "progress": {"value": 1, "max": 1}, + "q": {"cite": 1}, + "rp": {}, + "rt": {}, + "ruby": {}, + "s": {}, + "samp": {}, + "script": {"charset": 1, "type": {"text/javascript": 1}, "src": 1, "defer": 1, "async": 1}, + "select": {"autofocus": 1, "disabled": 1, "form": 1, "multiple": {"multiple": 1}, "name": 1, "size": 1, "readonly":{"readonly": 1}}, + "small": {}, + "source": {"src": 1, "type": 1, "media": 1}, + "span": {}, + "strong": {}, + "style": {"type": 1, "media": {"all": 1, "screen": 1, "print": 1}, "scoped": 1}, + "sub": {}, + "sup": {}, + "svg": {}, + "table": {"summary": 1}, + "tbody": {}, + "td": {"headers": 1, "rowspan": 1, "colspan": 1}, + "textarea": {"autofocus": {"autofocus": 1}, "disabled": {"disabled": 1}, "form": 1, "maxlength": 1, "name": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "rows": 1, "cols": 1, "wrap": {"on": 1, "off": 1, "hard": 1, "soft": 1}}, + "tfoot": {}, + "th": {"headers": 1, "rowspan": 1, "colspan": 1, "scope": 1}, + "thead": {}, + "time": {"datetime": 1}, + "title": {}, + "tr": {}, + "track": {"kind": 1, "src": 1, "srclang": 1, "label": 1, "default": 1}, + "section": {}, + "summary": {}, + "u": {}, + "ul": {}, + "var": {}, + "video": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "width": 1, "height": 1, "poster": 1, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1}}, + "wbr": {} +}; + +var elements = Object.keys(attributeMap); + +function is(token, type) { + return token.type.lastIndexOf(type + ".xml") > -1; +} + +function findTagName(session, pos) { + var iterator = new TokenIterator(session, pos.row, pos.column); + var token = iterator.getCurrentToken(); + while (token && !is(token, "tag-name")){ + token = iterator.stepBackward(); + } + if (token) + return token.value; +} + +function findAttributeName(session, pos) { + var iterator = new TokenIterator(session, pos.row, pos.column); + var token = iterator.getCurrentToken(); + while (token && !is(token, "attribute-name")){ + token = iterator.stepBackward(); + } + if (token) + return token.value; +} + +var HtmlCompletions = function() { + +}; + +(function() { + + this.getCompletions = function(state, session, pos, prefix) { + var token = session.getTokenAt(pos.row, pos.column); + + if (!token) + return []; + if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open")) + return this.getTagCompletions(state, session, pos, prefix); + if (is(token, "tag-whitespace") || is(token, "attribute-name")) + return this.getAttributeCompletions(state, session, pos, prefix); + if (is(token, "attribute-value")) + return this.getAttributeValueCompletions(state, session, pos, prefix); + var line = session.getLine(pos.row).substr(0, pos.column); + if (/&[a-z]*$/i.test(line)) + return this.getHTMLEntityCompletions(state, session, pos, prefix); + + return []; + }; + + this.getTagCompletions = function(state, session, pos, prefix) { + return elements.map(function(element){ + return { + value: element, + meta: "tag", + score: 1000000 + }; + }); + }; + + this.getAttributeCompletions = function(state, session, pos, prefix) { + var tagName = findTagName(session, pos); + if (!tagName) + return []; + var attributes = globalAttributes; + if (tagName in attributeMap) { + attributes = attributes.concat(Object.keys(attributeMap[tagName])); + } + return attributes.map(function(attribute){ + return { + caption: attribute, + snippet: attribute + '="$0"', + meta: "attribute", + score: 1000000 + }; + }); + }; + + this.getAttributeValueCompletions = function(state, session, pos, prefix) { + var tagName = findTagName(session, pos); + var attributeName = findAttributeName(session, pos); + + if (!tagName) + return []; + var values = []; + if (tagName in attributeMap && attributeName in attributeMap[tagName] && typeof attributeMap[tagName][attributeName] === "object") { + values = Object.keys(attributeMap[tagName][attributeName]); + } + return values.map(function(value){ + return { + caption: value, + snippet: value, + meta: "attribute value", + score: 1000000 + }; + }); + }; + + this.getHTMLEntityCompletions = function(state, session, pos, prefix) { + var values = ['Aacute;', 'aacute;', 'Acirc;', 'acirc;', 'acute;', 'AElig;', 'aelig;', 'Agrave;', 'agrave;', 'alefsym;', 'Alpha;', 'alpha;', 'amp;', 'and;', 'ang;', 'Aring;', 'aring;', 'asymp;', 'Atilde;', 'atilde;', 'Auml;', 'auml;', 'bdquo;', 'Beta;', 'beta;', 'brvbar;', 'bull;', 'cap;', 'Ccedil;', 'ccedil;', 'cedil;', 'cent;', 'Chi;', 'chi;', 'circ;', 'clubs;', 'cong;', 'copy;', 'crarr;', 'cup;', 'curren;', 'Dagger;', 'dagger;', 'dArr;', 'darr;', 'deg;', 'Delta;', 'delta;', 'diams;', 'divide;', 'Eacute;', 'eacute;', 'Ecirc;', 'ecirc;', 'Egrave;', 'egrave;', 'empty;', 'emsp;', 'ensp;', 'Epsilon;', 'epsilon;', 'equiv;', 'Eta;', 'eta;', 'ETH;', 'eth;', 'Euml;', 'euml;', 'euro;', 'exist;', 'fnof;', 'forall;', 'frac12;', 'frac14;', 'frac34;', 'frasl;', 'Gamma;', 'gamma;', 'ge;', 'gt;', 'hArr;', 'harr;', 'hearts;', 'hellip;', 'Iacute;', 'iacute;', 'Icirc;', 'icirc;', 'iexcl;', 'Igrave;', 'igrave;', 'image;', 'infin;', 'int;', 'Iota;', 'iota;', 'iquest;', 'isin;', 'Iuml;', 'iuml;', 'Kappa;', 'kappa;', 'Lambda;', 'lambda;', 'lang;', 'laquo;', 'lArr;', 'larr;', 'lceil;', 'ldquo;', 'le;', 'lfloor;', 'lowast;', 'loz;', 'lrm;', 'lsaquo;', 'lsquo;', 'lt;', 'macr;', 'mdash;', 'micro;', 'middot;', 'minus;', 'Mu;', 'mu;', 'nabla;', 'nbsp;', 'ndash;', 'ne;', 'ni;', 'not;', 'notin;', 'nsub;', 'Ntilde;', 'ntilde;', 'Nu;', 'nu;', 'Oacute;', 'oacute;', 'Ocirc;', 'ocirc;', 'OElig;', 'oelig;', 'Ograve;', 'ograve;', 'oline;', 'Omega;', 'omega;', 'Omicron;', 'omicron;', 'oplus;', 'or;', 'ordf;', 'ordm;', 'Oslash;', 'oslash;', 'Otilde;', 'otilde;', 'otimes;', 'Ouml;', 'ouml;', 'para;', 'part;', 'permil;', 'perp;', 'Phi;', 'phi;', 'Pi;', 'pi;', 'piv;', 'plusmn;', 'pound;', 'Prime;', 'prime;', 'prod;', 'prop;', 'Psi;', 'psi;', 'quot;', 'radic;', 'rang;', 'raquo;', 'rArr;', 'rarr;', 'rceil;', 'rdquo;', 'real;', 'reg;', 'rfloor;', 'Rho;', 'rho;', 'rlm;', 'rsaquo;', 'rsquo;', 'sbquo;', 'Scaron;', 'scaron;', 'sdot;', 'sect;', 'shy;', 'Sigma;', 'sigma;', 'sigmaf;', 'sim;', 'spades;', 'sub;', 'sube;', 'sum;', 'sup;', 'sup1;', 'sup2;', 'sup3;', 'supe;', 'szlig;', 'Tau;', 'tau;', 'there4;', 'Theta;', 'theta;', 'thetasym;', 'thinsp;', 'THORN;', 'thorn;', 'tilde;', 'times;', 'trade;', 'Uacute;', 'uacute;', 'uArr;', 'uarr;', 'Ucirc;', 'ucirc;', 'Ugrave;', 'ugrave;', 'uml;', 'upsih;', 'Upsilon;', 'upsilon;', 'Uuml;', 'uuml;', 'weierp;', 'Xi;', 'xi;', 'Yacute;', 'yacute;', 'yen;', 'Yuml;', 'yuml;', 'Zeta;', 'zeta;', 'zwj;', 'zwnj;']; + + return values.map(function(value){ + return { + caption: value, + snippet: value, + meta: "html entity", + score: 1000000 + }; + }); + }; + +}).call(HtmlCompletions.prototype); + +exports.HtmlCompletions = HtmlCompletions; +}); + +define("ace/mode/html",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/javascript","ace/mode/css","ace/mode/html_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/html","ace/mode/html_completions","ace/worker/worker_client"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextMode = require("./text").Mode; +var JavaScriptMode = require("./javascript").Mode; +var CssMode = require("./css").Mode; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; +var HtmlFoldMode = require("./folding/html").FoldMode; +var HtmlCompletions = require("./html_completions").HtmlCompletions; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"]; +var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"]; + +var Mode = function(options) { + this.fragmentContext = options && options.fragmentContext; + this.HighlightRules = HtmlHighlightRules; + this.$behaviour = new XmlBehaviour(); + this.$completer = new HtmlCompletions(); + + this.createModeDelegates({ + "js-": JavaScriptMode, + "css-": CssMode + }); + + this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags)); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.blockComment = {start: ""}; + + this.voidElements = lang.arrayToMap(voidElements); + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + + this.checkOutdent = function(state, line, input) { + return false; + }; + + this.getCompletions = function(state, session, pos, prefix) { + return this.$completer.getCompletions(state, session, pos, prefix); + }; + + this.createWorker = function(session) { + if (this.constructor != Mode) + return; + var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + if (this.fragmentContext) + worker.call("setOptions", [{context: this.fragmentContext}]); + + worker.on("error", function(e) { + session.setAnnotations(e.data); + }); + + worker.on("terminate", function() { + session.clearAnnotations(); + }); + + return worker; + }; + + this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +define("ace/mode/latte_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/html_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LatteHighlightRules = function() { + HtmlHighlightRules.call(this); + for (var rule in this.$rules) { + this.$rules[rule].unshift( + { + token : "comment.start.latte", + regex : "\\{\\*", + push : [{ + token : "comment.end.latte", + regex : ".*\\*\\}", + next : "pop" + }, { + defaultToken : "comment" + }] + }, { + token : "meta.tag.punctuation.tag-open.latte", + regex : "\\{(?![\\s'\"{}]|$)/?", + push : [{ + token : "meta.tag.latte", + regex : "(?:_|=|[a-z]\\w*(?:[.:-]\\w+)*)?", + next: [{ + token : "meta.tag.punctuation.tag-close.latte", + regex : "\\}", + next : "pop" + }, { + include: "latte-content" + }] + }] + }); + } + this.$rules['tag_stuff'].unshift({ + token : "meta.attribute.latte", + regex : "n:[\\w-]+", + next : [{ + include: "tag_whitespace" + }, { + token : "keyword.operator.attribute-equals.xml", + regex : "=", + next : [{ + token : "string.attribute-value.xml", + regex : "'", + next : [ + {token : "string.attribute-value.xml", regex: "'", next: "tag_stuff"}, + {include : "latte-content"} + ] + }, { + token : "string.attribute-value.xml", + regex : '"', + next : [ + {token : "string.attribute-value.xml", regex: '"', next: "tag_stuff"}, + {include : "latte-content"} + ] + }, { + token : "text.tag-whitespace.xml", + regex : "\\s", + next: "tag_stuff" + }, { + token : "meta.tag.punctuation.tag-close.xml", + regex : "/?>", + next: "tag_stuff" + }, { + include : "latte-content" + }] + }, { + token : "empty", + regex : "", + next : "tag_stuff" + }] + }); + this.$rules["latte-content"] = [ + { + token : "comment.start.latte", // multi line comment + regex : "\\/\\*", + push : [ + { + token : "comment.end.latte", + regex : "\\*\\/", + next : "pop" + }, { + defaultToken : "comment" + } + ] + }, { + token : "string.start", // " string start + regex : '"', + push : [ + { + token : "constant.language.escape", + regex : '\\\\(?:[nrtvef\\\\"$]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})' + }, { + token : "variable", + regex : /\$[\w]+(?:\[[\w\]+]|[=\-]>\w+)?/ + }, { + token : "variable", + regex : /\$\{[^"\}]+\}?/ // this is wrong but ok for now + }, + {token : "string.end", regex : '"', next : "pop"}, + {defaultToken : "string"} + ] + }, { + token : "string.start", // ' string start + regex : "'", + push : [ + {token : "constant.language.escape", regex : /\\['\\]/}, + {token : "string.end", regex : "'", next : "pop"}, + {defaultToken : "string"} + ] + }, { + token : "keyword.control", + regex : "\\b(?:INF|NAN|and|or|xor|AND|OR|XOR|clone|new|instanceof|return|continue|break|as)\\b" + }, { + token : "constant.language", + regex : "\\b(?:true|false|null|TRUE|FALSE|NULL)\\b" + }, { + token : "variable", + regex : /\$\w+/ + }, { + token : "constant.numeric", + regex : "[+-]?[0-9]+(?:\\.[0-9]+)?(?:e[0-9]+)?" + }, { + token : ["support.class", "keyword.operator"], + regex : "\\b(\\w+)(::)" + }, { + token : "constant.language", // constants + regex : "\\b(?:[A-Z0-9_]+)\\b" + }, { + token : "string.unquoted", + regex : "\\w+(?:-+\\w+)*" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "keyword.operator", + regex : "::|=>|->|\\?->|\\?\\?->|\\+\\+|--|<<|>>|<=>|<=|>=|===|!==|==|!=|<>|&&|\\|\\||\\?\\?|\\?>|\\*\\*|\\.\\.\\.|[^'\"]" // =>, any char except quotes + } + ]; + + this.normalizeRules(); +}; + +oop.inherits(LatteHighlightRules, TextHighlightRules); + +exports.LatteHighlightRules = LatteHighlightRules; +}); + +define("ace/mode/latte",["require","exports","module","ace/lib/oop","ace/mode/html","ace/mode/latte_highlight_rules","ace/mode/matching_brace_outdent"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var HtmlMode = require("./html").Mode; +var LatteHighlightRules = require("./latte_highlight_rules").LatteHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; + +var Mode = function() { + HtmlMode.call(this); + this.HighlightRules = LatteHighlightRules; + this.$outdent = new MatchingBraceOutdent(); +}; +oop.inherits(Mode, HtmlMode); + +(function() { + this.blockComment = {start: "{*", end: "*}"}; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + if (state == "start") { + var match = line.match(/^.*\{(?:if|else|elseif|ifset|elseifset|ifchanged|switch|case|foreach|iterateWhile|for|while|first|last|sep|try|capture|spaceless|snippet|block|define|embed|snippetArea)\b[^{]*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return /^\s+\{\/$/.test(line + input); + }; + + this.autoOutdent = function(state, doc, row) { + }; + + this.$id = "ace/mode/latte"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); (function() { + window.require(["ace/mode/latte"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-liquid.js b/htdocs/includes/ace/src/mode-liquid.js index 6bbf7d1e9d6..f22cfa98a4a 100644 --- a/htdocs/includes/ace/src/mode-liquid.js +++ b/htdocs/includes/ace/src/mode-liquid.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2725,6 +2728,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/liquid"; + this.snippetFileId = "ace/snippets/liquid"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-lsl.js b/htdocs/includes/ace/src/mode-lsl.js index f6d7a7497f5..a08ff25f31b 100644 --- a/htdocs/includes/ace/src/mode-lsl.js +++ b/htdocs/includes/ace/src/mode-lsl.js @@ -329,6 +329,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/lsl"; + this.snippetFileId = "ace/snippets/lsl"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-lua.js b/htdocs/includes/ace/src/mode-lua.js index e96b6c37a9b..a87f127a893 100644 --- a/htdocs/includes/ace/src/mode-lua.js +++ b/htdocs/includes/ace/src/mode-lua.js @@ -438,6 +438,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/lua"; + this.snippetFileId = "ace/snippets/lua"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-luapage.js b/htdocs/includes/ace/src/mode-luapage.js index 5f5ecce9079..49bbde3f148 100644 --- a/htdocs/includes/ace/src/mode-luapage.js +++ b/htdocs/includes/ace/src/mode-luapage.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2938,6 +2941,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/lua"; + this.snippetFileId = "ace/snippets/lua"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-makefile.js b/htdocs/includes/ace/src/mode-makefile.js index 0314c6a216b..f8d853bd52c 100644 --- a/htdocs/includes/ace/src/mode-makefile.js +++ b/htdocs/includes/ace/src/mode-makefile.js @@ -398,6 +398,7 @@ oop.inherits(Mode, TextMode); this.$indentWithTabs = true; this.$id = "ace/mode/makefile"; + this.snippetFileId = "ace/snippets/makefile"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-markdown.js b/htdocs/includes/ace/src/mode-markdown.js index ac4072175ec..42fa514fdf5 100644 --- a/htdocs/includes/ace/src/mode-markdown.js +++ b/htdocs/includes/ace/src/mode-markdown.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1986,6 +1987,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2539,6 +2541,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -3124,6 +3127,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/sh"; + this.snippetFileId = "ace/snippets/sh"; }).call(Mode.prototype); exports.Mode = Mode; @@ -3176,6 +3180,7 @@ oop.inherits(Mode, TextMode); } }; this.$id = "ace/mode/markdown"; + this.snippetFileId = "ace/snippets/markdown"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-maze.js b/htdocs/includes/ace/src/mode-maze.js index faa82968572..75e1da782da 100644 --- a/htdocs/includes/ace/src/mode-maze.js +++ b/htdocs/includes/ace/src/mode-maze.js @@ -278,6 +278,7 @@ oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "//"; this.$id = "ace/mode/maze"; + this.snippetFileId = "ace/snippets/maze"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-mediawiki.js b/htdocs/includes/ace/src/mode-mediawiki.js new file mode 100644 index 00000000000..199e90b9101 --- /dev/null +++ b/htdocs/includes/ace/src/mode-mediawiki.js @@ -0,0 +1,592 @@ +define("ace/mode/mediawiki_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var MediaWikiHighlightRules = function() { + this.$rules = { + start: [{ + include: "#switch" + }, { + include: "#redirect" + }, { + include: "#variable" + }, { + include: "#comment" + }, { + include: "#entity" + }, { + include: "#emphasis" + }, { + include: "#tag" + }, { + include: "#table" + }, { + include: "#hr" + }, { + include: "#heading" + }, { + include: "#link" + }, { + include: "#list" + }, { + include: "#template" + }], + "#hr": [{ + token: "markup.bold", + regex: /^[-]{4,}/ + }], + "#switch": [{ + token: "constant.language", + regex: /(__NOTOC__|__FORCETOC__|__TOC__|__NOEDITSECTION__|__NEWSECTIONLINK__|__NONEWSECTIONLINK__|__NOWYSIWYG__|__NOGALLERY__|__HIDDENCAT__|__EXPECTUNUSEDCATEGORY__|__NOCONTENTCONVERT__|__NOCC__|__NOTITLECONVERT__|__NOTC__|__START__|__END__|__INDEX__|__NOINDEX__|__STATICREDIRECT__|__NOGLOBAL__|__DISAMBIG__)/ + }], + "#redirect": [{ + token: [ + "keyword.control.redirect", + "meta.keyword.control" + ], + regex: /(^#REDIRECT|^#redirect|^#Redirect)(\s+)/ + }], + "#variable": [{ + token: "storage.type.variable", + regex: /{{{/, + push: [{ + token: "storage.type.variable", + regex: /}}}/, + next: "pop" + }, { + token: [ + "text", + "variable.other", + "text", + "keyword.operator" + ], + regex: /(\s*)(\w+)(\s*)((?:\|)?)/ + }, { + defaultToken: "storage.type.variable" + }] + }], + "#entity": [{ + token: "constant.character.entity", + regex: /&\w+;/ + }], + "#list": [{ + token: "markup.bold", + regex: /^[#*;:]+/, + push: [{ + token: "markup.list", + regex: /$/, + next: "pop" + }, { + include: "$self" + }, { + defaultToken: "markup.list" + }] + }], + "#template": [{ + token: [ + "storage.type.function", + "meta.template", + "entity.name.function", + "meta.template" + ], + regex: /({{)(\s*)([#\w: ]+)(\s*)/, + push: [{ + token: "storage.type.function", + regex: /}}/, + next: "pop" + }, { + token: [ + "storage", + "meta.structure.dictionary", + "support.type.property-name", + "meta.structure.dictionary", + "punctuation.separator.dictionary.key-value", + "meta.structure.dictionary", + "meta.structure.dictionary.value" + ], + regex: /(\|)(\s*)([a-zA-Z-]*)(\s*)(=)(\s*)([^|}]*)/, + push: [{ + token: "meta.structure.dictionary", + regex: /(?=}}|[|])/, + next: "pop" + }, { + defaultToken: "meta.structure.dictionary" + }] + }, { + token: ["storage", "meta.template.value"], + regex: /(\|)(.*?)/, + push: [{ + token: [], + regex: /(?=}}|[|])/, + next: "pop" + }, { + include: "$self" + }, { + defaultToken: "meta.template.value" + }] + }, { + defaultToken: "meta.template" + }] + }], + "#link": [{ + token: [ + "punctuation.definition.tag.begin", + "meta.tag.link.internal", + "entity.name.tag", + "meta.tag.link.internal", + "string.other.link.title", + "meta.tag.link.internal", + "punctuation.definition.tag" + ], + regex: /(\[\[)(\s*)((?:Category|Wikipedia)?)(:?)([^\]\]\|]+)(\s*)((?:\|)*)/, + push: [{ + token: "punctuation.definition.tag.end", + regex: /\]\]/, + next: "pop" + }, { + include: "$self" + }, { + defaultToken: "meta.tag.link.internal" + }] + }, { + token: [ + "punctuation.definition.tag.begin", + "meta.tag.link.external", + "meta.tag.link.external", + "string.unquoted", + "punctuation.definition.tag.end" + ], + regex: /(\[)(.*?)([\s]+)(.*?)(\])/ + }], + "#comment": [{ + token: "punctuation.definition.comment.html", + regex: //, + next: "pop" + }, { + defaultToken: "comment.block.html" + }] + }], + "#emphasis": [{ + token: [ + "punctuation.definition.tag.begin", + "markup.italic.bold", + "punctuation.definition.tag.end" + ], + regex: /(''''')(?!')(.*?)('''''|$)/ + }, { + token: [ + "punctuation.definition.tag.begin", + "markup.bold", + "punctuation.definition.tag.end" + ], + regex: /(''')(?!')(.*?)('''|$)/ + }, { + token: [ + "punctuation.definition.tag.begin", + "markup.italic", + "punctuation.definition.tag.end" + ], + regex: /('')(?!')(.*?)(''|$)/ + }], + "#heading": [{ + token: [ + "punctuation.definition.heading", + "entity.name.section", + "punctuation.definition.heading" + ], + regex: /(={1,6})(.+?)(\1)(?!=)/ + }], + "#tag": [{ + token: [ + "punctuation.definition.tag.begin", + "entity.name.tag", + "meta.tag.block.ref", + "punctuation.definition.tag.end" + ], + regex: /(<)(ref)((?:\s+.*?)?)(>)/, + caseInsensitive: true, + push: [{ + token: [ + "punctuation.definition.tag.begin", + "entity.name.tag", + "meta.tag.block.ref", + "punctuation.definition.tag.end" + ], + regex: /(<\/)(ref)(\s*)(>)/, + caseInsensitive: true, + next: "pop" + }, { + include: "$self" + }, { + defaultToken: "meta.tag.block.ref" + }] + }, + { + token: [ + "punctuation.definition.tag.begin", + "entity.name.tag", + "meta.tag.block.nowiki", + "punctuation.definition.tag.end" + ], + regex: /(<)(nowiki)((?:\s+.*?)?)(>)/, + caseInsensitive: true, + push: [{ + token: [ + "punctuation.definition.tag.begin", + "entity.name.tag", + "meta.tag.block.nowiki", + "punctuation.definition.tag.end" + ], + regex: /(<\/)(nowiki)(\s*)(>)/, + caseInsensitive: true, + next: "pop" + }, { + defaultToken: "meta.tag.block.nowiki" + }] + }, { + token: [ + "punctuation.definition.tag.begin", + "entity.name.tag" + ], + regex: /(<\/?)(noinclude|includeonly|onlyinclude)(?=\W)/, + caseInsensitive: true, + push: [{ + token: [ + "invalid.illegal", + "punctuation.definition.tag.end" + ], + regex: /((?:\/)?)(>)/, + next: "pop" + }, { + include: "#attribute" + }, { + defaultToken: "meta.tag.block.any" + }] + }, { + token: [ + "punctuation.definition.tag.begin", + "entity.name.tag" + ], + regex: /(<)(br|wbr|hr|meta|link)(?=\W)/, + caseInsensitive: true, + push: [{ + token: "punctuation.definition.tag.end", + regex: /\/?>/, + next: "pop" + }, { + include: "#attribute" + }, { + defaultToken: "meta.tag.other" + }] + }, { + token: [ + "punctuation.definition.tag.begin", + "entity.name.tag" + ], + regex: /(<\/?)(div|center|span|h1|h2|h3|h4|h5|h6|bdo|em|strong|cite|dfn|code|samp|kbd|var|abbr|blockquote|q|sub|sup|p|pre|ins|del|ul|ol|li|dl|dd|dt|table|caption|thead|tfoot|tbody|colgroup|col|tr|td|th|a|img|video|source|track|tt|b|i|big|small|strike|s|u|font|ruby|rb|rp|rt|rtc|math|figure|figcaption|bdi|data|time|mark|html)(?=\W)/, + caseInsensitive: true, + push: [{ + token: [ + "invalid.illegal", + "punctuation.definition.tag.end" + ], + regex: /((?:\/)?)(>)/, + next: "pop" + }, { + include: "#attribute" + }, { + defaultToken: "meta.tag.block" + }] + }, { + token: [ + "punctuation.definition.tag.begin", + "invalid.illegal" + ], + regex: /(<\/)(br|wbr|hr|meta|link)(?=\W)/, + caseInsensitive: true, + push: [{ + token: "punctuation.definition.tag.end", + regex: /\/?>/, + next: "pop" + }, { + include: "#attribute" + }, { + defaultToken: "meta.tag.other" + }] + }], + "#caption": [{ + token: [ + "meta.tag.block.table-caption", + "punctuation.definition.tag.begin" + ], + regex: /^(\s*)(\|\+)/, + push: [{ + token: "meta.tag.block.table-caption", + regex: /$/, + next: "pop" + }, { + defaultToken: "meta.tag.block.table-caption" + }] + }], + "#tr": [{ + token: [ + "meta.tag.block.tr", + "punctuation.definition.tag.begin", + "meta.tag.block.tr", + "invalid.illegal" + ], + regex: /^(\s*)(\|\-)([\s]*)(.*)/ + }], + "#th": [{ + token: [ + "meta.tag.block.th.heading", + "punctuation.definition.tag.begin", + "meta.tag.block.th.heading", + "punctuation.definition.tag", + "markup.bold" + ], + regex: /^(\s*)(!)(?:(.*?)(\|))?(.*?)(?=!!|$)/, + push: [{ + token: "meta.tag.block.th.heading", + regex: /$/, + next: "pop" + }, { + token: [ + "punctuation.definition.tag.begin", + "meta.tag.block.th.inline", + "punctuation.definition.tag", + "markup.bold" + ], + regex: /(!!)(?:(.*?)(\|))?(.*?)(?=!!|$)/ + }, { + include: "$self" + }, { + defaultToken: "meta.tag.block.th.heading" + }] + }], + "#td": [{ + token: [ + "meta.tag.block.td", + "punctuation.definition.tag.begin" + ], + regex: /^(\s*)(\|)/, + push: [{ + token: "meta.tag.block.td", + regex: /$/, + next: "pop" + }, { + include: "$self" + }, { + defaultToken: "meta.tag.block.td" + }] + }], + "#table": [{ + patterns: [{ + name: "meta.tag.block.table", + begin: "^\\s*({\\|)(.*?)$", + end: "^\\s*\\|}", + beginCaptures: { + 1: { + name: "punctuation.definition.tag.begin" + }, + 2: { + patterns: [{ + include: "#attribute" + }] + }, + 3: { + name: "invalid.illegal" + } + }, + endCaptures: { + 0: { + name: "punctuation.definition.tag.end" + } + }, + patterns: [{ + include: "#comment" + }, { + include: "#template" + }, { + include: "#caption" + }, { + include: "#tr" + }, { + include: "#th" + }, { + include: "#td" + }] + }], + repository: { + caption: { + name: "meta.tag.block.table-caption", + begin: "^\\s*(\\|\\+)", + end: "$", + beginCaptures: { + 1: { + name: "punctuation.definition.tag.begin" + } + } + }, + tr: { + name: "meta.tag.block.tr", + match: "^\\s*(\\|\\-)[\\s]*(.*)", + captures: { + 1: { + name: "punctuation.definition.tag.begin" + }, + 2: { + name: "invalid.illegal" + } + } + }, + th: { + name: "meta.tag.block.th.heading", + begin: "^\\s*(!)((.*?)(\\|))?(.*?)(?=(!!)|$)", + end: "$", + beginCaptures: { + 1: { + name: "punctuation.definition.tag.begin" + }, + 3: { + patterns: [{ + include: "#attribute" + }] + }, + 4: { + name: "punctuation.definition.tag" + }, + 5: { + name: "markup.bold" + } + }, + patterns: [{ + name: "meta.tag.block.th.inline", + match: "(!!)((.*?)(\\|))?(.*?)(?=(!!)|$)", + captures: { + 1: { + name: "punctuation.definition.tag.begin" + }, + 3: { + patterns: [{ + include: "#attribute" + }] + }, + 4: { + name: "punctuation.definition.tag" + }, + 5: { + name: "markup.bold" + } + } + }, { + include: "$self" + }] + }, + td: { + name: "meta.tag.block.td", + begin: "^\\s*(\\|)", + end: "$", + beginCaptures: { + 1: { + name: "punctuation.definition.tag.begin" + }, + 2: { + patterns: [{ + include: "#attribute" + }] + }, + 3: { + name: "punctuation.definition.tag" + } + }, + patterns: [{ + include: "$self" + }] + } + } + }], + "#attribute": [{ + include: "#string" + }, { + token: "entity.other.attribute-name", + regex: /\w+/ + }], + "#string": [{ + token: "string.quoted.double", + regex: /\"/, + push: [{ + token: "string.quoted.double", + regex: /\"/, + next: "pop" + }, { + defaultToken: "string.quoted.double" + }] + }, { + token: "string.quoted.single", + regex: /\'/, + push: [{ + token: "string.quoted.single", + regex: /\'/, + next: "pop" + }, { + defaultToken: "string.quoted.single" + }] + }], + "#url": [{ + token: "markup.underline.link", + regex: /(?:http(?:s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:\/?#\[\]@!\$&'\(\)\*\+,;=.]+/ + }, { + token: "invalid.illegal", + regex: /.*/ + }] + }; + + + this.normalizeRules(); +}; + +MediaWikiHighlightRules.metaData = { + name: "MediaWiki", + scopeName: "text.html.mediawiki", + fileTypes: ["mediawiki", "wiki"] +}; + + +oop.inherits(MediaWikiHighlightRules, TextHighlightRules); + +exports.MediaWikiHighlightRules = MediaWikiHighlightRules; +}); + +define("ace/mode/mediawiki",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/mediawiki_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var MediaWikiHighlightRules = require("./mediawiki_highlight_rules").MediaWikiHighlightRules; + +var Mode = function() { + this.HighlightRules = MediaWikiHighlightRules; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.type = "text"; + this.blockComment = {start: ""}; + this.$id = "ace/mode/mediawiki"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); (function() { + window.require(["ace/mode/mediawiki"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-mips.js b/htdocs/includes/ace/src/mode-mips.js new file mode 100644 index 00000000000..4d28b88d676 --- /dev/null +++ b/htdocs/includes/ace/src/mode-mips.js @@ -0,0 +1,264 @@ +define("ace/mode/mips_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var MIPSHighlightRules = function() { + + var escapeRe = /\\(?:['"?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}U[a-fA-F\d]{8}|.)/.source; + + this.$rules = { + start: [{ + token: "storage.modifier.mips", + regex: /\.\b(?:align|ascii|asciiz|byte|double|extern|float|globl|space|word)\b/, + comment: "Assembler directives for data storage" + }, { + token: "entity.name.section.mips", + regex: /\.\b(?:data|text|kdata|ktext|)\b/, + comment: "Segements: .data .text" + }, { + token: "variable.parameter.mips", + regex: /\$(?:(?:3[01]|[12]?[0-9]|[0-9])|zero|at|v[01]|a[0-3]|s[0-7]|t[0-9]|k[01]|gp|sp|fp|ra)/, + comment: "Registers by id $1, $2, ..." + }, { + token: "variable.parameter.mips", + regex: /\$f(?:[0-9]|[1-2][0-9]|3[0-1])/, + comment: "Floating point registers" + }, { + token: "support.function.source.mips", + regex: /\b(?:(?:add|sub|div|l|mov|mult|neg|s|c\.eq|c\.le|c\.lt)\.[ds]|cvt\.s\.[dw]|cvt\.d\.[sw]|cvt\.w\.[ds]|bc1[tf])\b/, + comment: "The MIPS floating-point instruction set" + }, { + token: "support.function.source.mips", + regex: /\b(?:add|addu|addi|addiu|sub|subu|and|andi|or|not|ori|nor|xor|xori|slt|sltu|slti|sltiu|sll|sllv|rol|srl|sra|srlv|ror|j|jr|jal|beq|bne|lw|sw|lb|sb|lui|move|mfhi|mflo|mthi|mtlo)\b/, + comment: "Just the hardcoded instructions provided by the MIPS assembly language" + }, { + token: "support.function.other.mips", + regex: /\b(?:abs|b|beqz|bge|bgt|bgtu|ble|bleu|blt|bltu|bnez|div|divu|la|li|move|mul|neg|not|rem|remu|seq|sge|sgt|sle|sne)\b/, + comment: "Pseudo instructions" + }, { + token: "entity.name.function.mips", + regex: /\bsyscall\b/, + comment: "Other" + }, { + token : "string", // character + regex : "(?:'\")(?:" + escapeRe + "|.)?(?:'\")" + }, { + token : "string.start", + regex : '\'', + stateName: "qstring", + next: [ + { token: "string", regex: /\\\s*$/, next: "qqstring" }, + { token: "constant.language.escape", regex: escapeRe }, + { token: "string.end", regex: '\'|$', next: "start" }, + { defaultToken: "string"} + ] + }, { + token : "string.start", + regex : '"', + stateName: "qqstring", + next: [ + { token: "string", regex: /\\\s*$/, next: "qqstring" }, + { token: "constant.language.escape", regex: escapeRe }, + { token: "string.end", regex: '"|$', next: "start" }, + { defaultToken: "string"} + ] + }, { + token: "constant.numeric.mips", + regex: /\b(?:\d+|0(?:x|X)[a-fA-F0-9]+)\b/, + comment: "Numbers like +12, -3, 55, 0x3F" + }, { + token: "entity.name.tag.mips", + regex: /\b[\w]+\b:/, + comment: "Labels at line start: begin_repeat: add ..." + }, { + token: "comment.assembly", + regex: /#.*$/, + comment: "Single line comments" + }] + }; + + this.normalizeRules(); +}; + +MIPSHighlightRules.metaData = { + fileTypes: ["s", "asm"], + name: "MIPS", + scopeName: "source.mips" +}; + + +oop.inherits(MIPSHighlightRules, TextHighlightRules); + +exports.MIPSHighlightRules = MIPSHighlightRules; +}); + +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/mips",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/mips_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var MIPSHighlightRules = require("./mips_highlight_rules").MIPSHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = MIPSHighlightRules; + this.foldingRules = new FoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = ["#"]; + this.$id = "ace/mode/mips"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); (function() { + window.require(["ace/mode/mips"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-nix.js b/htdocs/includes/ace/src/mode-nix.js index b1a426fb9b3..d5698eb141b 100644 --- a/htdocs/includes/ace/src/mode-nix.js +++ b/htdocs/includes/ace/src/mode-nix.js @@ -65,7 +65,7 @@ var c_cppHighlightRules = function() { var storageType = ( "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + - "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" + + "_Imaginary|int|int8_t|int16_t|int32_t|int64_t|long|short|signed|size_t|struct|typedef|uint8_t|uint16_t|uint32_t|uint64_t|union|unsigned|void|" + "class|wchar_t|template|char16_t|char32_t" ); @@ -489,6 +489,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/c_cpp"; + this.snippetFileId = "ace/snippets/c_cpp"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-nsis.js b/htdocs/includes/ace/src/mode-nsis.js index 67c2abec063..10816422adf 100644 --- a/htdocs/includes/ace/src/mode-nsis.js +++ b/htdocs/includes/ace/src/mode-nsis.js @@ -13,7 +13,7 @@ var NSISHighlightRules = function() { caseInsensitive: true }, { token: "keyword.command.nsis", - regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|Int64Cmp|Int64CmpU|Int64Fmt|IntCmp|IntCmpU|IntFmt|IntOp|IntPtrCmp|IntPtrCmpU|IntPtrOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadAndSetImage|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestLongPathAware|ManifestMaxVersionTested|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEAddResource|PEDllCharacteristics|PERemoveResource|PESubsysVer|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, + regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetKnownFolderPath|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfRtlLanguage|IfShellVarContextAll|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|Int64Cmp|Int64CmpU|Int64Fmt|IntCmp|IntCmpU|IntFmt|IntOp|IntPtrCmp|IntPtrCmpU|IntPtrOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadAndSetImage|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestLongPathAware|ManifestMaxVersionTested|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEAddResource|PEDllCharacteristics|PERemoveResource|PESubsysVer|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, caseInsensitive: true }, { token: "keyword.control.nsis", diff --git a/htdocs/includes/ace/src/mode-nunjucks.js b/htdocs/includes/ace/src/mode-nunjucks.js index 57f1e9f32bb..c59a814e67d 100644 --- a/htdocs/includes/ace/src/mode-nunjucks.js +++ b/htdocs/includes/ace/src/mode-nunjucks.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-objectivec.js b/htdocs/includes/ace/src/mode-objectivec.js index 28a56917f03..0a2dbd08fba 100644 --- a/htdocs/includes/ace/src/mode-objectivec.js +++ b/htdocs/includes/ace/src/mode-objectivec.js @@ -65,7 +65,7 @@ var c_cppHighlightRules = function() { var storageType = ( "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + - "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" + + "_Imaginary|int|int8_t|int16_t|int32_t|int64_t|long|short|signed|size_t|struct|typedef|uint8_t|uint16_t|uint32_t|uint64_t|union|unsigned|void|" + "class|wchar_t|template|char16_t|char32_t" ); diff --git a/htdocs/includes/ace/src/mode-perl.js b/htdocs/includes/ace/src/mode-perl.js index 978979b1e47..bc8d178c968 100644 --- a/htdocs/includes/ace/src/mode-perl.js +++ b/htdocs/includes/ace/src/mode-perl.js @@ -367,6 +367,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/perl"; + this.snippetFileId = "ace/snippets/perl"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-pgsql.js b/htdocs/includes/ace/src/mode-pgsql.js index 952319ef862..069b750eab6 100644 --- a/htdocs/includes/ace/src/mode-pgsql.js +++ b/htdocs/includes/ace/src/mode-pgsql.js @@ -526,10 +526,10 @@ var PythonHighlightRules = function() { regex: "\\s+" }, { token: "string", - regex: "'(.)*'" + regex: "'[^']*'" }, { token: "string", - regex: '"(.)*"' + regex: '"[^"]*"' }, { token: "function.support", regex: "(!s|!r|!a)" diff --git a/htdocs/includes/ace/src/mode-php.js b/htdocs/includes/ace/src/mode-php.js index b9acd2c8073..7db8bf2c7bd 100644 --- a/htdocs/includes/ace/src/mode-php.js +++ b/htdocs/includes/ace/src/mode-php.js @@ -2138,15 +2138,15 @@ var functionMap = { "Escapes single quote, double quotes and backslash characters in a string with backslashes" ], "apache_child_terminate": [ - "bool apache_child_terminate(void)", + "bool apache_child_terminate()", "Terminate apache process after this request" ], "apache_get_modules": [ - "array apache_get_modules(void)", + "array apache_get_modules()", "Get a list of loaded Apache modules" ], "apache_get_version": [ - "string apache_get_version(void)", + "string apache_get_version()", "Fetch Apache version" ], "apache_getenv": [ @@ -2178,7 +2178,7 @@ var functionMap = { "* fetch all headers that go out in case of an error or a subrequest" ], "apache_request_headers": [ - "array apache_request_headers(void)", + "array apache_request_headers()", "Fetch all HTTP request headers" ], "apache_request_headers_in": [ @@ -2194,7 +2194,7 @@ var functionMap = { "" ], "apache_request_log_error": [ - "boolean apache_request_log_error(string message, [long facility])", + "bool apache_request_log_error(string message, [long facility])", "" ], "apache_request_meets_conditions": [ @@ -2246,11 +2246,11 @@ var functionMap = { "" ], "apache_reset_timeout": [ - "bool apache_reset_timeout(void)", + "bool apache_reset_timeout()", "Reset the Apache write timer" ], "apache_response_headers": [ - "array apache_response_headers(void)", + "array apache_response_headers()", "Fetch all HTTP response headers" ], "apache_setenv": [ @@ -2337,6 +2337,14 @@ var functionMap = { "array array_keys(array input [, mixed search_value[, bool strict]])", "Return just the keys from the input array, optionally only for the specified search_value" ], + "array_key_first": [ + "mixed array_key_first(array arr)", + "Returns the first key of arr if the array is not empty; NULL otherwise" + ], + "array_key_last": [ + "mixed array_key_last(array arr)", + "Returns the last key of arr if the array is not empty; NULL otherwise" + ], "array_map": [ "array array_map(mixed callback, array input1 [, array input2 ,...])", "Applies the callback to the elements in given arrays." @@ -2694,7 +2702,7 @@ var functionMap = { "Change file mode" ], "chown": [ - "bool chown (string filename, mixed user)", + "bool chown(string filename, mixed user)", "Change file owner" ], "chr": [ @@ -2722,7 +2730,7 @@ var functionMap = { "Return all classes and interfaces implemented by SPL" ], "class_parents": [ - "array class_parents(object instance [, boolean autoload = true])", + "array class_parents(object instance [, bool autoload = true])", "Return an array containing the names of all parent classes" ], "clearstatcache": [ @@ -2734,7 +2742,7 @@ var functionMap = { "Close directory connection identified by the dir_handle" ], "closelog": [ - "bool closelog(void)", + "bool closelog()", "Close connection to system logger" ], "collator_asort": [ @@ -2826,11 +2834,11 @@ var functionMap = { "Return a string to confirm that the module is compiled in" ], "connection_aborted": [ - "int connection_aborted(void)", + "int connection_aborted()", "Returns true if client disconnected" ], "connection_status": [ - "int connection_status(void)", + "int connection_status()", "Returns the connection status bitfield" ], "constant": [ @@ -2875,7 +2883,7 @@ var functionMap = { ], "create_function": [ "string create_function(string args, string code)", - "Creates an anonymous function, and returns its name (funny, eh?)" + "Creates an anonymous function, and returns its name" ], "crypt": [ "string crypt(string str [, string salt])", @@ -2974,7 +2982,7 @@ var functionMap = { "Get information about the current transfers" ], "curl_multi_init": [ - "resource curl_multi_init(void)", + "resource curl_multi_init()", "Returns a new cURL multi handle" ], "curl_multi_remove_handle": [ @@ -3170,7 +3178,7 @@ var functionMap = { "* Set formatter pattern." ], "datefmt_set_timezone_id": [ - "boolean datefmt_set_timezone_id( IntlDateFormatter $mf,$timezone_id)", + "bool datefmt_set_timezone_id( IntlDateFormatter $mf,$timezone_id)", "* Set formatter timezone_id." ], "dba_close": [ @@ -3238,7 +3246,7 @@ var functionMap = { "Return the translation of msgid for domain_name and category, or msgid unaltered if a translation does not exist" ], "dcngettext": [ - "string dcngettext (string domain, string msgid1, string msgid2, int n, int category)", + "string dcngettext(string domain, string msgid1, string msgid2, int n, int category)", "Plural version of dcgettext()" ], "debug_backtrace": [ @@ -3246,44 +3254,231 @@ var functionMap = { "Return backtrace as array" ], "debug_print_backtrace": [ - "void debug_print_backtrace(void) */", - "ZEND_FUNCTION(debug_print_backtrace) { zend_execute_data *ptr, *skip; int lineno; char *function_name; char *filename; char *class_name = NULL; char *call_type; char *include_filename = NULL; zval *arg_array = NULL; int indent = 0; if (zend_parse_parameters_none() == FAILURE) { return; } ptr = EG(current_execute_data);", + "void debug_print_backtrace()", + "Prints a PHP backtrace" + ], + "debug_zval_dump": [ + "void debug_zval_dump(mixed var)", + "Dumps a string representation of an internal Zend value to output" + ], + "decbin": [ + "string decbin(int decimal_number)", + "Returns a string containing a binary representation of the number" + ], + "dechex": [ + "string dechex(int decimal_number)", + "Returns a string containing a hexadecimal representation of the given number" + ], + "decoct": [ + "string decoct(int decimal_number)", + "Returns a string containing an octal representation of the given number" + ], + "define": [ + "bool define(string constant_name, mixed value, bool case_insensitive=false)", + "Define a new constant" + ], + "define_syslog_variables": [ + "void define_syslog_variables()", + "Initializes all syslog-related variables" + ], + "defined": [ + "bool defined(string constant_name)", + "Check whether a constant exists" + ], + "deg2rad": [ + "float deg2rad(float number)", + "Converts the number in degrees to the radian equivalent" + ], + "dgettext": [ + "string dgettext(string domain_name, string msgid)", + "Return the translation of msgid for domain_name, or msgid unaltered if a translation does not exist" + ], + "die": [ + "void die([mixed status])", + "Output a message and terminate the current script" + ], + "dir": [ + "object dir(string directory[, resource context])", + "Directory class with properties, handle and class and methods read, rewind and close" + ], + "dirname": [ + "string dirname(string path)", + "Returns the directory name component of the path" + ], + "disk_free_space": [ + "float disk_free_space(string path)", + "Get free disk space for filesystem that path is on" + ], + "disk_total_space": [ + "float disk_total_space(string path)", + "Get total disk space for filesystem that path is on" + ], + "display_disabled_function": [ + "void display_disabled_function()", + "Dummy function which displays an error when a disabled function is called." + ], + "dl": [ + "int dl(string extension_filename)", + "Load a PHP extension at runtime" + ], + "dngettext": [ + "string dngettext(string domain, string msgid1, string msgid2, int count)", + "Plural version of dgettext()" + ], + "dns_check_record": [ + "bool dns_check_record(string host [, string type])", + "Check DNS records corresponding to a given Internet host name or IP address" + ], + "dns_get_mx": [ + "bool dns_get_mx(string hostname, array mxhosts [, array weight])", + "Get MX records corresponding to a given Internet host name" + ], + "dns_get_record": [ + "array|false dns_get_record(string hostname [, int type[, array authns, array addtl]])", + "Get any Resource Record corresponding to a given Internet host name" + ], + "dom_attr_is_id": [ + "bool dom_attr_is_id()", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-isId Since: DOM Level 3" + ], + "dom_characterdata_append_data": [ + "void dom_characterdata_append_data(string arg)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-32791A2F Since:" + ], + "dom_characterdata_delete_data": [ + "void dom_characterdata_delete_data(int offset, int count)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-7C603781 Since:" + ], + "dom_characterdata_insert_data": [ + "void dom_characterdata_insert_data(int offset, string arg)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-3EDB695F Since:" + ], + "dom_characterdata_replace_data": [ + "void dom_characterdata_replace_data(int offset, int count, string arg)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-E5CBA7FB Since:" + ], + "dom_characterdata_substring_data": [ + "string dom_characterdata_substring_data(int offset, int count)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6531BCCF Since:" + ], + "dom_document_adopt_node": [ + "DOMNode dom_document_adopt_node(DOMNode source)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-adoptNode Since: DOM Level 3" + ], + "dom_document_create_attribute": [ + "DOMAttr dom_document_create_attribute(string name)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1084891198 Since:" + ], + "dom_document_create_attribute_ns": [ + "DOMAttr dom_document_create_attribute_ns(string namespaceURI, string qualifiedName)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrAttrNS Since: DOM Level 2" + ], + "dom_document_create_cdatasection": [ + "DOMCdataSection dom_document_create_cdatasection(string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D26C0AF8 Since:" + ], + "dom_document_create_comment": [ + "DOMComment dom_document_create_comment(string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1334481328 Since:" + ], + "dom_document_create_document_fragment": [ + "DOMDocumentFragment dom_document_create_document_fragment()", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-35CB04B5 Since:" + ], + "dom_document_create_element": [ + "DOMElement dom_document_create_element(string tagName [, string value])", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-2141741547 Since:" + ], + "dom_document_create_element_ns": [ + "DOMElement dom_document_create_element_ns(string namespaceURI, string qualifiedName [,string value])", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrElNS Since: DOM Level 2" + ], + "dom_document_create_entity_reference": [ + "DOMEntityReference dom_document_create_entity_reference(string name)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-392B75AE Since:" + ], + "dom_document_create_processing_instruction": [ + "DOMProcessingInstruction dom_document_create_processing_instruction(string target, string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-135944439 Since:" + ], + "dom_document_create_text_node": [ + "DOMText dom_document_create_text_node(string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1975348127 Since:" + ], + "dom_document_get_element_by_id": [ + "DOMElement dom_document_get_element_by_id(string elementId)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBId Since: DOM Level 2" + ], + "dom_document_get_elements_by_tag_name": [ + "DOMNodeList dom_document_get_elements_by_tag_name(string tagname)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C9094 Since:" + ], + "dom_document_get_elements_by_tag_name_ns": [ + "DOMNodeList dom_document_get_elements_by_tag_name_ns(string namespaceURI, string localName)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBTNNS Since: DOM Level 2" + ], + "dom_document_import_node": [ + "DOMNode dom_document_import_node(DOMNode importedNode, bool deep)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Core-Document-importNode Since: DOM Level 2" + ], + "dom_document_load": [ + "DOMNode dom_document_load(string source [, int options])", + "URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-load Since: DOM Level 3" + ], + "dom_document_load_html": [ + "DOMNode dom_document_load_html(string source)", + "Since: DOM extended" + ], + "dom_document_load_html_file": [ + "DOMNode dom_document_load_html_file(string source)", + "Since: DOM extended" + ], + "dom_document_loadxml": [ + "DOMNode dom_document_loadxml(string source [, int options])", + "URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-loadXML Since: DOM Level 3" + ], + "dom_document_normalize_document": [ + "void dom_document_normalize_document()", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-normalizeDocument Since: DOM Level 3" + ], + "dom_document_relaxNG_validate_file": [ + "bool dom_document_relaxNG_validate_file(string filename); */", "PHP_FUNCTION(dom_document_relaxNG_validate_file) { _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } /* }}} end dom_document_relaxNG_validate_file" ], "dom_document_relaxNG_validate_xml": [ - "boolean dom_document_relaxNG_validate_xml(string source); */", + "bool dom_document_relaxNG_validate_xml(string source); */", "PHP_FUNCTION(dom_document_relaxNG_validate_xml) { _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } /* }}} end dom_document_relaxNG_validate_xml" ], "dom_document_rename_node": [ - "DOMNode dom_document_rename_node(node n, string namespaceURI, string qualifiedName);", + "DOMNode dom_document_rename_node(node n, string namespaceURI, string qualifiedName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-renameNode Since: DOM Level 3" ], "dom_document_save": [ - "int dom_document_save(string file);", + "int dom_document_save(string file)", "Convenience method to save to file" ], "dom_document_save_html": [ - "string dom_document_save_html();", + "string dom_document_save_html()", "Convenience method to output as html" ], "dom_document_save_html_file": [ - "int dom_document_save_html_file(string file);", + "int dom_document_save_html_file(string file)", "Convenience method to save to file as html" ], "dom_document_savexml": [ - "string dom_document_savexml([node n]);", + "string dom_document_savexml([node n])", "URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-saveXML Since: DOM Level 3" ], "dom_document_schema_validate": [ - "boolean dom_document_schema_validate(string source); */", + "bool dom_document_schema_validate(string source); */", "PHP_FUNCTION(dom_document_schema_validate_xml) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } /* }}} end dom_document_schema_validate" ], "dom_document_schema_validate_file": [ - "boolean dom_document_schema_validate_file(string filename); */", + "bool dom_document_schema_validate_file(string filename); */", "PHP_FUNCTION(dom_document_schema_validate_file) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } /* }}} end dom_document_schema_validate_file" ], "dom_document_validate": [ - "boolean dom_document_validate();", + "bool dom_document_validate()", "Since: DOM extended" ], "dom_document_xinclude": [ @@ -3291,123 +3486,123 @@ var functionMap = { "Substitutues xincludes in a DomDocument" ], "dom_domconfiguration_can_set_parameter": [ - "boolean dom_domconfiguration_can_set_parameter(string name, domuserdata value);", + "bool dom_domconfiguration_can_set_parameter(string name, domuserdata value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-canSetParameter Since:" ], "dom_domconfiguration_get_parameter": [ - "domdomuserdata dom_domconfiguration_get_parameter(string name);", + "domdomuserdata dom_domconfiguration_get_parameter(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-getParameter Since:" ], "dom_domconfiguration_set_parameter": [ - "dom_void dom_domconfiguration_set_parameter(string name, domuserdata value);", + "dom_void dom_domconfiguration_set_parameter(string name, domuserdata value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-property Since:" ], "dom_domerrorhandler_handle_error": [ - "dom_boolean dom_domerrorhandler_handle_error(domerror error);", + "dom_bool dom_domerrorhandler_handle_error(domerror error)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-ERRORS-DOMErrorHandler-handleError Since:" ], "dom_domimplementation_create_document": [ - "DOMDocument dom_domimplementation_create_document(string namespaceURI, string qualifiedName, DOMDocumentType doctype);", + "DOMDocument dom_domimplementation_create_document(string namespaceURI, string qualifiedName, DOMDocumentType doctype)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocument Since: DOM Level 2" ], "dom_domimplementation_create_document_type": [ - "DOMDocumentType dom_domimplementation_create_document_type(string qualifiedName, string publicId, string systemId);", + "DOMDocumentType dom_domimplementation_create_document_type(string qualifiedName, string publicId, string systemId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocType Since: DOM Level 2" ], "dom_domimplementation_get_feature": [ - "DOMNode dom_domimplementation_get_feature(string feature, string version);", + "DOMNode dom_domimplementation_get_feature(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementation3-getFeature Since: DOM Level 3" ], "dom_domimplementation_has_feature": [ - "boolean dom_domimplementation_has_feature(string feature, string version);", + "bool dom_domimplementation_has_feature(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-5CED94D7 Since:" ], "dom_domimplementationlist_item": [ - "domdomimplementation dom_domimplementationlist_item(int index);", + "domdomimplementation dom_domimplementationlist_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementationList-item Since:" ], "dom_domimplementationsource_get_domimplementation": [ - "domdomimplementation dom_domimplementationsource_get_domimplementation(string features);", + "domdomimplementation dom_domimplementationsource_get_domimplementation(string features)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-getDOMImpl Since:" ], "dom_domimplementationsource_get_domimplementations": [ - "domimplementationlist dom_domimplementationsource_get_domimplementations(string features);", + "domimplementationlist dom_domimplementationsource_get_domimplementations(string features)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-getDOMImpls Since:" ], "dom_domstringlist_item": [ - "domstring dom_domstringlist_item(int index);", + "domstring dom_domstringlist_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMStringList-item Since:" ], "dom_element_get_attribute": [ - "string dom_element_get_attribute(string name);", + "string dom_element_get_attribute(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-666EE0F9 Since:" ], "dom_element_get_attribute_node": [ - "DOMAttr dom_element_get_attribute_node(string name);", + "DOMAttr dom_element_get_attribute_node(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-217A91B8 Since:" ], "dom_element_get_attribute_node_ns": [ - "DOMAttr dom_element_get_attribute_node_ns(string namespaceURI, string localName);", + "DOMAttr dom_element_get_attribute_node_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElGetAtNodeNS Since: DOM Level 2" ], "dom_element_get_attribute_ns": [ - "string dom_element_get_attribute_ns(string namespaceURI, string localName);", + "string dom_element_get_attribute_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElGetAttrNS Since: DOM Level 2" ], "dom_element_get_elements_by_tag_name": [ - "DOMNodeList dom_element_get_elements_by_tag_name(string name);", + "DOMNodeList dom_element_get_elements_by_tag_name(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1938918D Since:" ], "dom_element_get_elements_by_tag_name_ns": [ - "DOMNodeList dom_element_get_elements_by_tag_name_ns(string namespaceURI, string localName);", + "DOMNodeList dom_element_get_elements_by_tag_name_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C90942 Since: DOM Level 2" ], "dom_element_has_attribute": [ - "boolean dom_element_has_attribute(string name);", + "bool dom_element_has_attribute(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElHasAttr Since: DOM Level 2" ], "dom_element_has_attribute_ns": [ - "boolean dom_element_has_attribute_ns(string namespaceURI, string localName);", + "bool dom_element_has_attribute_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElHasAttrNS Since: DOM Level 2" ], "dom_element_remove_attribute": [ - "void dom_element_remove_attribute(string name);", + "void dom_element_remove_attribute(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6D6AC0F9 Since:" ], "dom_element_remove_attribute_node": [ - "DOMAttr dom_element_remove_attribute_node(DOMAttr oldAttr);", + "DOMAttr dom_element_remove_attribute_node(DOMAttr oldAttr)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D589198 Since:" ], "dom_element_remove_attribute_ns": [ - "void dom_element_remove_attribute_ns(string namespaceURI, string localName);", + "void dom_element_remove_attribute_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElRemAtNS Since: DOM Level 2" ], "dom_element_set_attribute": [ - "void dom_element_set_attribute(string name, string value);", + "void dom_element_set_attribute(string name, string value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68F082 Since:" ], "dom_element_set_attribute_node": [ - "DOMAttr dom_element_set_attribute_node(DOMAttr newAttr);", + "DOMAttr dom_element_set_attribute_node(DOMAttr newAttr)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-887236154 Since:" ], "dom_element_set_attribute_node_ns": [ - "DOMAttr dom_element_set_attribute_node_ns(DOMAttr newAttr);", + "DOMAttr dom_element_set_attribute_node_ns(DOMAttr newAttr)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetAtNodeNS Since: DOM Level 2" ], "dom_element_set_attribute_ns": [ - "void dom_element_set_attribute_ns(string namespaceURI, string qualifiedName, string value);", + "void dom_element_set_attribute_ns(string namespaceURI, string qualifiedName, string value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetAttrNS Since: DOM Level 2" ], "dom_element_set_id_attribute": [ - "void dom_element_set_id_attribute(string name, boolean isId);", + "void dom_element_set_id_attribute(string name, bool isId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttr Since: DOM Level 3" ], "dom_element_set_id_attribute_node": [ - "void dom_element_set_id_attribute_node(attr idAttr, boolean isId);", + "void dom_element_set_id_attribute_node(attr idAttr, bool isId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttrNode Since: DOM Level 3" ], "dom_element_set_id_attribute_ns": [ - "void dom_element_set_id_attribute_ns(string namespaceURI, string localName, boolean isId);", + "void dom_element_set_id_attribute_ns(string namespaceURI, string localName, bool isId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttrNS Since: DOM Level 3" ], "dom_import_simplexml": [ @@ -3415,156 +3610,156 @@ var functionMap = { "Get a simplexml_element object from dom to allow for processing" ], "dom_namednodemap_get_named_item": [ - "DOMNode dom_namednodemap_get_named_item(string name);", + "DOMNode dom_namednodemap_get_named_item(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1074577549 Since:" ], "dom_namednodemap_get_named_item_ns": [ - "DOMNode dom_namednodemap_get_named_item_ns(string namespaceURI, string localName);", + "DOMNode dom_namednodemap_get_named_item_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getNamedItemNS Since: DOM Level 2" ], "dom_namednodemap_item": [ - "DOMNode dom_namednodemap_item(int index);", + "DOMNode dom_namednodemap_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-349467F9 Since:" ], "dom_namednodemap_remove_named_item": [ - "DOMNode dom_namednodemap_remove_named_item(string name);", + "DOMNode dom_namednodemap_remove_named_item(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D58B193 Since:" ], "dom_namednodemap_remove_named_item_ns": [ - "DOMNode dom_namednodemap_remove_named_item_ns(string namespaceURI, string localName);", + "DOMNode dom_namednodemap_remove_named_item_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-removeNamedItemNS Since: DOM Level 2" ], "dom_namednodemap_set_named_item": [ - "DOMNode dom_namednodemap_set_named_item(DOMNode arg);", + "DOMNode dom_namednodemap_set_named_item(DOMNode arg)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1025163788 Since:" ], "dom_namednodemap_set_named_item_ns": [ - "DOMNode dom_namednodemap_set_named_item_ns(DOMNode arg);", + "DOMNode dom_namednodemap_set_named_item_ns(DOMNode arg)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-setNamedItemNS Since: DOM Level 2" ], "dom_namelist_get_name": [ - "string dom_namelist_get_name(int index);", + "string dom_namelist_get_name(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList-getName Since:" ], "dom_namelist_get_namespace_uri": [ - "string dom_namelist_get_namespace_uri(int index);", + "string dom_namelist_get_namespace_uri(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList-getNamespaceURI Since:" ], "dom_node_append_child": [ - "DomNode dom_node_append_child(DomNode newChild);", + "DomNode dom_node_append_child(DomNode newChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-184E7107 Since:" ], "dom_node_clone_node": [ - "DomNode dom_node_clone_node(boolean deep);", + "DomNode dom_node_clone_node(bool deep)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-3A0ED0A4 Since:" ], "dom_node_compare_document_position": [ - "short dom_node_compare_document_position(DomNode other);", + "short dom_node_compare_document_position(DomNode other)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-compareDocumentPosition Since: DOM Level 3" ], "dom_node_get_feature": [ - "DomNode dom_node_get_feature(string feature, string version);", + "DomNode dom_node_get_feature(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-getFeature Since: DOM Level 3" ], "dom_node_get_user_data": [ - "mixed dom_node_get_user_data(string key);", + "mixed dom_node_get_user_data(string key)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-getUserData Since: DOM Level 3" ], "dom_node_has_attributes": [ - "boolean dom_node_has_attributes();", + "bool dom_node_has_attributes()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-NodeHasAttrs Since: DOM Level 2" ], "dom_node_has_child_nodes": [ - "boolean dom_node_has_child_nodes();", + "bool dom_node_has_child_nodes()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-810594187 Since:" ], "dom_node_insert_before": [ - "domnode dom_node_insert_before(DomNode newChild, DomNode refChild);", + "domnode dom_node_insert_before(DomNode newChild, DomNode refChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-952280727 Since:" ], "dom_node_is_default_namespace": [ - "boolean dom_node_is_default_namespace(string namespaceURI);", + "bool dom_node_is_default_namespace(string namespaceURI)", "URL: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace Since: DOM Level 3" ], "dom_node_is_equal_node": [ - "boolean dom_node_is_equal_node(DomNode arg);", + "bool dom_node_is_equal_node(DomNode arg)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-isEqualNode Since: DOM Level 3" ], "dom_node_is_same_node": [ - "boolean dom_node_is_same_node(DomNode other);", + "bool dom_node_is_same_node(DomNode other)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-isSameNode Since: DOM Level 3" ], "dom_node_is_supported": [ - "boolean dom_node_is_supported(string feature, string version);", + "bool dom_node_is_supported(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Level-2-Core-Node-supports Since: DOM Level 2" ], "dom_node_lookup_namespace_uri": [ - "string dom_node_lookup_namespace_uri(string prefix);", + "string dom_node_lookup_namespace_uri(string prefix)", "URL: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI Since: DOM Level 3" ], "dom_node_lookup_prefix": [ - "string dom_node_lookup_prefix(string namespaceURI);", + "string dom_node_lookup_prefix(string namespaceURI)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-lookupNamespacePrefix Since: DOM Level 3" ], "dom_node_normalize": [ - "void dom_node_normalize();", + "void dom_node_normalize()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-normalize Since:" ], "dom_node_remove_child": [ - "DomNode dom_node_remove_child(DomNode oldChild);", + "DomNode dom_node_remove_child(DomNode oldChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1734834066 Since:" ], "dom_node_replace_child": [ - "DomNode dom_node_replace_child(DomNode newChild, DomNode oldChild);", + "DomNode dom_node_replace_child(DomNode newChild, DomNode oldChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-785887307 Since:" ], "dom_node_set_user_data": [ - "mixed dom_node_set_user_data(string key, mixed data, userdatahandler handler);", + "mixed dom_node_set_user_data(string key, mixed data, userdatahandler handler)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-setUserData Since: DOM Level 3" ], "dom_nodelist_item": [ - "DOMNode dom_nodelist_item(int index);", + "DOMNode dom_nodelist_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-844377136 Since:" ], "dom_string_extend_find_offset16": [ - "int dom_string_extend_find_offset16(int offset32);", + "int dom_string_extend_find_offset16(int offset32)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#i18n-methods-StringExtend-findOffset16 Since:" ], "dom_string_extend_find_offset32": [ - "int dom_string_extend_find_offset32(int offset16);", + "int dom_string_extend_find_offset32(int offset16)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#i18n-methods-StringExtend-findOffset32 Since:" ], "dom_text_is_whitespace_in_element_content": [ - "boolean dom_text_is_whitespace_in_element_content();", + "bool dom_text_is_whitespace_in_element_content()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Text3-isWhitespaceInElementContent Since: DOM Level 3" ], "dom_text_replace_whole_text": [ - "DOMText dom_text_replace_whole_text(string content);", + "DOMText dom_text_replace_whole_text(string content)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Text3-replaceWholeText Since: DOM Level 3" ], "dom_text_split_text": [ - "DOMText dom_text_split_text(int offset);", + "DOMText dom_text_split_text(int offset)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-38853C1D Since:" ], "dom_userdatahandler_handle": [ - "dom_void dom_userdatahandler_handle(short operation, string key, domobject data, node src, node dst);", + "dom_void dom_userdatahandler_handle(short operation, string key, domobject data, node src, node dst)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-handleUserDataEvent Since:" ], "dom_xpath_evaluate": [ - "mixed dom_xpath_evaluate(string expr [,DOMNode context]); */", - "PHP_FUNCTION(dom_xpath_evaluate) { php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_EVALUATE); } /* }}} end dom_xpath_evaluate" + "mixed dom_xpath_evaluate(string expr [,DOMNode context])", + "" ], "dom_xpath_query": [ - "DOMNodeList dom_xpath_query(string expr [,DOMNode context]); */", - "PHP_FUNCTION(dom_xpath_query) { php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_QUERY); } /* }}} end dom_xpath_query" + "DOMNodeList dom_xpath_query(string expr [,DOMNode context])", + "" ], "dom_xpath_register_ns": [ - "boolean dom_xpath_register_ns(string prefix, string uri); */", - "PHP_FUNCTION(dom_xpath_register_ns) { zval *id; xmlXPathContextPtr ctxp; int prefix_len, ns_uri_len; dom_xpath_object *intern; unsigned char *prefix, *ns_uri; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"Oss\", &id, dom_xpath_class_entry, &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) { return; } intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); ctxp = (xmlXPathContextPtr) intern->ptr; if (ctxp == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid XPath Context\"); RETURN_FALSE; } if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) { RETURN_FALSE } RETURN_TRUE; } /* }}}" + "bool dom_xpath_register_ns(string prefix, string uri)", + "" ], "dom_xpath_register_php_functions": [ - "void dom_xpath_register_php_functions() */", - "PHP_FUNCTION(dom_xpath_register_php_functions) { zval *id; dom_xpath_object *intern; zval *array_value, **entry, *new_string; int name_len = 0; char *name; DOM_GET_THIS(id); if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"a\", &array_value) == SUCCESS) { intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value)); while (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) { SEPARATE_ZVAL(entry); convert_to_string_ex(entry); MAKE_STD_ZVAL(new_string); ZVAL_LONG(new_string,1); zend_hash_update(intern->registered_phpfunctions, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, &new_string, sizeof(zval*), NULL); zend_hash_move_forward(Z_ARRVAL_P(array_value)); } intern->registerPhpFunctions = 2; RETURN_TRUE; } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &name, &name_len) == SUCCESS) { intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); MAKE_STD_ZVAL(new_string); ZVAL_LONG(new_string,1); zend_hash_update(intern->registered_phpfunctions, name, name_len + 1, &new_string, sizeof(zval*), NULL); intern->registerPhpFunctions = 2; } else { intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); intern->registerPhpFunctions = 1; } } /* }}} end dom_xpath_register_php_functions" + "void dom_xpath_register_php_functions()", + "" ], "each": [ "array each(array arr)", @@ -3583,7 +3778,7 @@ var functionMap = { "Output one or more strings" ], "empty": [ - "bool empty( mixed var )", + "bool empty(mixed var)", "Determine whether a variable is empty" ], "enchant_broker_describe": [ @@ -3595,7 +3790,7 @@ var functionMap = { "Whether a dictionary exists or not. Using non-empty tag" ], "enchant_broker_free": [ - "boolean enchant_broker_free(resource broker)", + "bool enchant_broker_free(resource broker)", "Destroys the broker object and its dictionnaries" ], "enchant_broker_free_dict": [ @@ -3891,7 +4086,7 @@ var functionMap = { "Returns the next lowest integer value from the number" ], "flush": [ - "void flush(void)", + "void flush()", "Flush the output buffer" ], "fmod": [ @@ -4099,7 +4294,7 @@ var functionMap = { "Get an array of the arguments that were passed to the function" ], "func_num_args": [ - "int func_num_args(void)", + "int func_num_args()", "Get the number of arguments that were passed to the function" ], "function ": ["", ""], @@ -4113,19 +4308,19 @@ var functionMap = { "Binary-safe file write" ], "gc_collect_cycles": [ - "int gc_collect_cycles(void)", + "int gc_collect_cycles()", "Forces collection of any existing garbage cycles. Returns number of freed zvals" ], "gc_disable": [ - "void gc_disable(void)", + "void gc_disable()", "Deactivates the circular reference collector" ], "gc_enable": [ - "void gc_enable(void)", + "void gc_enable()", "Activates the circular reference collector" ], "gc_enabled": [ - "void gc_enabled(void)", + "void gc_enabled()", "Returns status of the circular reference collector" ], "gd_info": [ @@ -4134,7 +4329,7 @@ var functionMap = { ], "getKeywords": [ "static array getKeywords(string $locale) {", - "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array (doh!) * }}}" + "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array * }}}" ], "get_browser": [ "mixed get_browser([string browser_name [, bool return_array]])", @@ -4161,7 +4356,7 @@ var functionMap = { "Returns an array of default properties of the class." ], "get_current_user": [ - "string get_current_user(void)", + "string get_current_user()", "Get the name of the owner of the current PHP script" ], "get_declared_classes": [ @@ -4177,11 +4372,11 @@ var functionMap = { "Return an array containing the names and values of all defined constants" ], "get_defined_functions": [ - "array get_defined_functions(void)", + "array get_defined_functions()", "Returns an array of all defined functions" ], "get_defined_vars": [ - "array get_defined_vars(void)", + "array get_defined_vars()", "Returns an associative array of names and values of all currently defined variable names (variables in the current scope)" ], "get_display_language": [ @@ -4217,7 +4412,7 @@ var functionMap = { "Get the current include_path configuration option" ], "get_included_files": [ - "array get_included_files(void)", + "array get_included_files()", "Returns an array with the file names that were include_once()'d" ], "get_loaded_extensions": [ @@ -4225,11 +4420,11 @@ var functionMap = { "Return an array containing names of loaded extensions" ], "get_magic_quotes_gpc": [ - "int get_magic_quotes_gpc(void)", + "int get_magic_quotes_gpc()", "Get the current active configuration setting of magic_quotes_gpc" ], "get_magic_quotes_runtime": [ - "int get_magic_quotes_runtime(void)", + "int get_magic_quotes_runtime()", "Get the current active configuration setting of magic_quotes_runtime" ], "get_meta_tags": [ @@ -4249,11 +4444,11 @@ var functionMap = { "Get the resource type name for a given resource" ], "getallheaders": [ - "array getallheaders(void)", + "array getallheaders()", "" ], "getcwd": [ - "mixed getcwd(void)", + "mixed getcwd()", "Gets the current directory" ], "getdate": [ @@ -4285,23 +4480,23 @@ var functionMap = { "Get the size of an image as 4-element array" ], "getlastmod": [ - "int getlastmod(void)", + "int getlastmod()", "Get time of last page modification" ], "getmygid": [ - "int getmygid(void)", + "int getmygid()", "Get PHP script owner's GID" ], "getmyinode": [ - "int getmyinode(void)", + "int getmyinode()", "Get the inode of the current script being parsed" ], "getmypid": [ - "int getmypid(void)", + "int getmypid()", "Get current process ID" ], "getmyuid": [ - "int getmyuid(void)", + "int getmyuid()", "Get PHP script owner's UID" ], "getopt": [ @@ -4317,7 +4512,7 @@ var functionMap = { "Returns protocol name associated with protocol number proto" ], "getrandmax": [ - "int getrandmax(void)", + "int getrandmax()", "Returns the maximum value a random number can have" ], "getrusage": [ @@ -4593,7 +4788,7 @@ var functionMap = { "Generate a hash of a given input string Returns lowercase hexits by default" ], "hash_algos": [ - "array hash_algos(void)", + "array hash_algos()", "Return a list of registered hashing algorithms" ], "hash_copy": [ @@ -4641,7 +4836,7 @@ var functionMap = { "Removes an HTTP header previously set using header()" ], "headers_list": [ - "array headers_list(void)", + "array headers_list()", "Return list of headers to be sent / already sent" ], "headers_sent": [ @@ -4769,11 +4964,11 @@ var functionMap = { "Drop an InterBase database" ], "ibase_errcode": [ - "int ibase_errcode(void)", + "int ibase_errcode()", "Return error code" ], "ibase_errmsg": [ - "string ibase_errmsg(void)", + "string ibase_errmsg()", "Return error message" ], "ibase_execute": [ @@ -5242,7 +5437,7 @@ var functionMap = { ], "imagepsextendfont": [ "bool imagepsextendfont(resource font_index, float extend)", - "Extend or or condense (if extend < 1) a font" + "Extend or or condense if (extend < 1) a font" ], "imagepsfreefont": [ "bool imagepsfreefont(resource font_index)", @@ -5321,7 +5516,7 @@ var functionMap = { "Write text to the image using a TrueType font" ], "imagetypes": [ - "int imagetypes(void)", + "int imagetypes()", "Return the types of images supported in a bitfield - 1=GIF, 2=JPEG, 4=PNG, 8=WBMP, 16=XPM" ], "imagewbmp": [ @@ -5337,7 +5532,7 @@ var functionMap = { "Convert an 8-bit string to a quoted-printable string" ], "imap_alerts": [ - "array imap_alerts(void)", + "array imap_alerts()", "Returns an array of all IMAP alerts that have been generated since the last page load or since the last imap_alerts() call, whichever came last. The alert stack is cleared after imap_alerts() is called." ], "imap_append": [ @@ -5385,7 +5580,7 @@ var functionMap = { "Delete a mailbox" ], "imap_errors": [ - "array imap_errors(void)", + "array imap_errors()", "Returns an array of all IMAP errors generated since the last page load, or since the last imap_errors() call, whichever came last. The error stack is cleared after imap_errors() is called." ], "imap_expunge": [ @@ -5441,7 +5636,7 @@ var functionMap = { "Returns headers for all messages in a mailbox" ], "imap_last_error": [ - "string imap_last_error(void)", + "string imap_last_error()", "Returns the last error that was generated by an IMAP function. The error stack is NOT cleared after this call." ], "imap_list": [ @@ -5692,6 +5887,10 @@ var functionMap = { "bool is_callable(mixed var [, bool syntax_only [, string callable_name]])", "Returns true if var is callable." ], + "is_countable": [ + "bool is_countable(mixed var)", + "Returns true if var is countable, false otherwise" + ], "is_dir": [ "bool is_dir(string filename)", "Returns true if file is directory" @@ -5773,15 +5972,15 @@ var functionMap = { "Determine whether a variable is set" ], "iterator_apply": [ - "int iterator_apply(Traversable it, mixed function [, mixed params])", + "int iterator_apply(Traversable iterator, callable function [, array args = null)", "Calls a function for every element in an iterator" ], "iterator_count": [ - "int iterator_count(Traversable it)", + "int iterator_count(Traversable iterator)", "Count the elements in an iterator" ], "iterator_to_array": [ - "array iterator_to_array(Traversable it [, bool use_keys = true])", + "array iterator_to_array(Traversable iterator [, bool use_keys = true])", "Copy the iterator into an array" ], "jddayofweek": [ @@ -5817,11 +6016,11 @@ var functionMap = { "Converts a jewish calendar date to a julian day count" ], "join": [ - "string join(array src, string glue)", - "An alias for implode" + "string join([string glue,] array pieces)", + "Returns a string containing a string representation of all the arrayelements in the same order, with the glue string between each element" ], "jpeg2wbmp": [ - "bool jpeg2wbmp (string f_org, string f_dest, int d_height, int d_width, int threshold)", + "bool jpeg2wbmp(string f_org, string f_dest, int d_height, int d_width, int threshold)", "Convert JPEG image to WBMP image" ], "json_decode": [ @@ -5989,7 +6188,7 @@ var functionMap = { "Read an entry" ], "ldap_rename": [ - "bool ldap_rename(resource link, string dn, string newrdn, string newparent, bool deleteoldrdn);", + "bool ldap_rename(resource link, string dn, string newrdn, string newparent, bool deleteoldrdn)", "Modify the name of an entry" ], "ldap_sasl_bind": [ @@ -6037,7 +6236,7 @@ var functionMap = { "Clear last error from libxml" ], "libxml_disable_entity_loader": [ - "bool libxml_disable_entity_loader([boolean disable])", + "bool libxml_disable_entity_loader([bool disable])", "Disable/Enable ability to load external entities" ], "libxml_get_errors": [ @@ -6053,7 +6252,7 @@ var functionMap = { "Set the streams context for the next libxml document load or write" ], "libxml_use_internal_errors": [ - "bool libxml_use_internal_errors([boolean use_errors])", + "bool libxml_use_internal_errors([bool use_errors])", "Disable libxml errors and allow user to fetch error information as needed" ], "link": [ @@ -6065,11 +6264,11 @@ var functionMap = { "Returns the st_dev field of the UNIX C stat structure describing the link" ], "litespeed_request_headers": [ - "array litespeed_request_headers(void)", + "array litespeed_request_headers()", "Fetch all HTTP request headers" ], "litespeed_response_headers": [ - "array litespeed_response_headers(void)", + "array litespeed_response_headers()", "Fetch all HTTP response headers" ], "locale_accept_from_http": [ @@ -6081,7 +6280,7 @@ var functionMap = { "* @param string $locale The locale string to canonicalize" ], "locale_filter_matches": [ - "boolean locale_filter_matches(string $langtag, string $locale[, bool $canonicalize])", + "bool locale_filter_matches(string $langtag, string $locale[, bool $canonicalize])", "* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm" ], "locale_get_all_variants": [ @@ -6094,7 +6293,7 @@ var functionMap = { ], "locale_get_keywords": [ "static array locale_get_keywords(string $locale) {", - "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array (doh!)" + "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array" ], "locale_get_primary_language": [ "static string locale_get_primary_language($locale)", @@ -6117,7 +6316,7 @@ var functionMap = { "Set default locale" ], "localeconv": [ - "array localeconv(void)", + "array localeconv()", "Returns numeric formatting information based on the current locale" ], "localtime": [ @@ -6221,11 +6420,11 @@ var functionMap = { "Regular expression search for multibyte string" ], "mb_ereg_search_getpos": [ - "int mb_ereg_search_getpos(void)", + "int mb_ereg_search_getpos()", "Get search start position" ], "mb_ereg_search_getregs": [ - "array mb_ereg_search_getregs(void)", + "array mb_ereg_search_getregs()", "Get matched substring of the last time" ], "mb_ereg_search_init": [ @@ -6545,7 +6744,7 @@ var functionMap = { "Hash data with hash" ], "mhash_count": [ - "int mhash_count(void)", + "int mhash_count()", "Gets the number of available hashes" ], "mhash_get_block_size": [ @@ -6721,7 +6920,7 @@ var functionMap = { "Free a MS-SQL statement index" ], "mssql_get_last_message": [ - "string mssql_get_last_message(void)", + "string mssql_get_last_message()", "Gets the last message from the MS-SQL server" ], "mssql_guid_string": [ @@ -6773,7 +6972,7 @@ var functionMap = { "Select a MS-SQL database" ], "mt_getrandmax": [ - "int mt_getrandmax(void)", + "int mt_getrandmax()", "Returns the maximum value a random number from Mersenne Twister can have" ], "mt_rand": [ @@ -6881,7 +7080,7 @@ var functionMap = { "Free result memory" ], "mysql_get_client_info": [ - "string mysql_get_client_info(void)", + "string mysql_get_client_info()", "Returns a string that represents the client library version" ], "mysql_get_host_info": [ @@ -6977,7 +7176,7 @@ var functionMap = { "Turn auto commit on or of" ], "mysqli_cache_stats": [ - "array mysqli_cache_stats(void)", + "array mysqli_cache_stats()", "Returns statistics about the zval cache" ], "mysqli_change_user": [ @@ -7001,11 +7200,11 @@ var functionMap = { "Open a connection to a mysql server" ], "mysqli_connect_errno": [ - "int mysqli_connect_errno(void)", + "int mysqli_connect_errno()", "Returns the numerical value of the error message from last connect command" ], "mysqli_connect_error": [ - "string mysqli_connect_error(void)", + "string mysqli_connect_error()", "Returns the text of the error message from previous MySQL operation" ], "mysqli_data_seek": [ @@ -7021,7 +7220,7 @@ var functionMap = { "" ], "mysqli_embedded_server_end": [ - "void mysqli_embedded_server_end(void)", + "void mysqli_embedded_server_end()", "" ], "mysqli_embedded_server_start": [ @@ -7037,39 +7236,39 @@ var functionMap = { "Returns the text of the error message from previous MySQL operation" ], "mysqli_fetch_all": [ - "mixed mysqli_fetch_all (object result [,int resulttype])", + "mixed mysqli_fetch_all(object result [,int resulttype])", "Fetches all result rows as an associative array, a numeric array, or both" ], "mysqli_fetch_array": [ - "mixed mysqli_fetch_array (object result [,int resulttype])", + "mixed mysqli_fetch_array(object result [,int resulttype])", "Fetch a result row as an associative array, a numeric array, or both" ], "mysqli_fetch_assoc": [ - "mixed mysqli_fetch_assoc (object result)", + "mixed mysqli_fetch_assoc(object result)", "Fetch a result row as an associative array" ], "mysqli_fetch_field": [ - "mixed mysqli_fetch_field (object result)", + "mixed mysqli_fetch_field(object result)", "Get column information from a result and return as an object" ], "mysqli_fetch_field_direct": [ - "mixed mysqli_fetch_field_direct (object result, int offset)", + "mixed mysqli_fetch_field_direct(object result, int offset)", "Fetch meta-data for a single field" ], "mysqli_fetch_fields": [ - "mixed mysqli_fetch_fields (object result)", + "mixed mysqli_fetch_fields(object result)", "Return array of objects containing field meta-data" ], "mysqli_fetch_lengths": [ - "mixed mysqli_fetch_lengths (object result)", + "mixed mysqli_fetch_lengths(object result)", "Get the length of each output in a result" ], "mysqli_fetch_object": [ - "mixed mysqli_fetch_object (object result [, string class_name [, NULL|array ctor_params]])", + "mixed mysqli_fetch_object(object result [, string class_name [, NULL|array ctor_params]])", "Fetch a result row as an object" ], "mysqli_fetch_row": [ - "array mysqli_fetch_row (object result)", + "array mysqli_fetch_row(object result)", "Get a result row as an enumerated array" ], "mysqli_field_count": [ @@ -7093,23 +7292,23 @@ var functionMap = { "returns a character set object" ], "mysqli_get_client_info": [ - "string mysqli_get_client_info(void)", + "string mysqli_get_client_info()", "Get MySQL client info" ], "mysqli_get_client_stats": [ - "array mysqli_get_client_stats(void)", + "array mysqli_get_client_stats()", "Returns statistics about the zval cache" ], "mysqli_get_client_version": [ - "int mysqli_get_client_version(void)", + "int mysqli_get_client_version()", "Get MySQL client info" ], "mysqli_get_connection_stats": [ - "array mysqli_get_connection_stats(void)", + "array mysqli_get_connection_stats()", "Returns statistics about the zval cache" ], "mysqli_get_host_info": [ - "string mysqli_get_host_info (object link)", + "string mysqli_get_host_info(object link)", "Get MySQL host info" ], "mysqli_get_proto_info": [ @@ -7125,15 +7324,15 @@ var functionMap = { "Return the MySQL version for the server referenced by the given link" ], "mysqli_get_warnings": [ - "object mysqli_get_warnings(object link) */", - "PHP_FUNCTION(mysqli_get_warnings) { MY_MYSQL *mysql; zval *mysql_link; MYSQLI_RESOURCE *mysqli_resource; MYSQLI_WARNING *w; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"O\", &mysql_link, mysqli_link_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, \"mysqli_link\", MYSQLI_STATUS_VALID); if (mysql_warning_count(mysql->mysql)) { w = php_get_warnings(mysql->mysql TSRMLS_CC); } else { RETURN_FALSE; } mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = mysqli_resource->info = (void *)w; mysqli_resource->status = MYSQLI_STATUS_VALID; MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); } /* }}}" + "object mysqli_get_warnings(object link)", + "" ], "mysqli_info": [ "string mysqli_info(object link)", "Get information about the most recent query" ], "mysqli_init": [ - "resource mysqli_init(void)", + "resource mysqli_init()", "Initialize mysqli and return a resource for use with mysql_real_connect" ], "mysqli_insert_id": [ @@ -7185,8 +7384,8 @@ var functionMap = { "Prepare a SQL statement for execution" ], "mysqli_query": [ - "mixed mysqli_query(object link, string query [,int resultmode]) */", - "PHP_FUNCTION(mysqli_query) { MY_MYSQL *mysql; zval *mysql_link; MYSQLI_RESOURCE *mysqli_resource; MYSQL_RES *result; char *query = NULL; unsigned int query_len; unsigned long resultmode = MYSQLI_STORE_RESULT; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"Os|l\", &mysql_link, mysqli_link_class_entry, &query, &query_len, &resultmode) == FAILURE) { return; } if (!query_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, \"Empty query\"); RETURN_FALSE; } if ((resultmode & ~MYSQLI_ASYNC) != MYSQLI_USE_RESULT && (resultmode & ~MYSQLI_ASYNC) != MYSQLI_STORE_RESULT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid value for resultmode\"); RETURN_FALSE; } MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, \"mysqli_link\", MYSQLI_STATUS_VALID); MYSQLI_DISABLE_MQ; #ifdef MYSQLI_USE_MYSQLND if (resultmode & MYSQLI_ASYNC) { if (mysqli_async_query(mysql->mysql, query, query_len)) { MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } mysql->async_result_fetch_type = resultmode & ~MYSQLI_ASYNC; RETURN_TRUE; } #endif if (mysql_real_query(mysql->mysql, query, query_len)) { MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } if (!mysql_field_count(mysql->mysql)) { /* no result set - not a SELECT" + "mixed mysqli_query(object link, string query [,int resultmode])", + "" ], "mysqli_real_connect": [ "bool mysqli_real_connect(object link [,string hostname [,string username [,string passwd [,string dbname [,int port [,string socket [,int flags]]]]]]])", @@ -7301,8 +7500,8 @@ var functionMap = { "Buffer result set on client" ], "mysqli_stmt_get_warnings": [ - "object mysqli_stmt_get_warnings(object link) */", - "PHP_FUNCTION(mysqli_stmt_get_warnings) { MY_STMT *stmt; zval *stmt_link; MYSQLI_RESOURCE *mysqli_resource; MYSQLI_WARNING *w; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"O\", &stmt_link, mysqli_stmt_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE(stmt, MY_STMT*, &stmt_link, \"mysqli_stmt\", MYSQLI_STATUS_VALID); if (mysqli_stmt_warning_count(stmt->stmt)) { w = php_get_warnings(mysqli_stmt_get_connection(stmt->stmt) TSRMLS_CC); } else { RETURN_FALSE; } mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = mysqli_resource->info = (void *)w; mysqli_resource->status = MYSQLI_STATUS_VALID; MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); } /* }}}" + "object mysqli_stmt_get_warnings(object link)", + "" ], "mysqli_stmt_init": [ "mixed mysqli_stmt_init(object link)", @@ -7357,7 +7556,7 @@ var functionMap = { "Return the current thread ID" ], "mysqli_thread_safe": [ - "bool mysqli_thread_safe(void)", + "bool mysqli_thread_safe()", "Return whether thread safety is given or not" ], "mysqli_use_result": [ @@ -7365,7 +7564,7 @@ var functionMap = { "Directly retrieve query results - do not buffer results on client side" ], "mysqli_warning_count": [ - "int mysqli_warning_count (object link)", + "int mysqli_warning_count(object link)", "Return number of warnings from the last query for the given link" ], "natcasesort": [ @@ -7401,11 +7600,11 @@ var functionMap = { "* Normalize a string." ], "nsapi_request_headers": [ - "array nsapi_request_headers(void)", + "array nsapi_request_headers()", "Get all headers from the request" ], "nsapi_response_headers": [ - "array nsapi_response_headers(void)", + "array nsapi_response_headers()", "Get all headers from the response" ], "nsapi_virtual": [ @@ -7485,39 +7684,39 @@ var functionMap = { "* Get formatter attribute value." ], "ob_clean": [ - "bool ob_clean(void)", + "bool ob_clean()", "Clean (delete) the current output buffer" ], "ob_end_clean": [ - "bool ob_end_clean(void)", + "bool ob_end_clean()", "Clean the output buffer, and delete current output buffer" ], "ob_end_flush": [ - "bool ob_end_flush(void)", + "bool ob_end_flush()", "Flush (send) the output buffer, and delete current output buffer" ], "ob_flush": [ - "bool ob_flush(void)", + "bool ob_flush()", "Flush (send) contents of the output buffer. The last buffer content is sent to next buffer" ], "ob_get_clean": [ - "bool ob_get_clean(void)", + "bool ob_get_clean()", "Get current buffer contents and delete current output buffer" ], "ob_get_contents": [ - "string ob_get_contents(void)", + "string ob_get_contents()", "Return the contents of the output buffer" ], "ob_get_flush": [ - "bool ob_get_flush(void)", + "bool ob_get_flush()", "Get current buffer contents, flush (send) the output buffer, and delete current output buffer" ], "ob_get_length": [ - "int ob_get_length(void)", + "int ob_get_length()", "Return the length of the output buffer" ], "ob_get_level": [ - "int ob_get_level(void)", + "int ob_get_level()", "Return the nesting level of the output buffer" ], "ob_get_status": [ @@ -7837,7 +8036,7 @@ var functionMap = { "Returns current state of buffering for a LOB" ], "ocisetbufferinglob": [ - "bool ocisetbufferinglob( boolean flag )", + "bool ocisetbufferinglob( bool flag )", "Enables/disables buffering for a LOB" ], "octdec": [ @@ -7857,7 +8056,7 @@ var functionMap = { "Close an ODBC connection" ], "odbc_close_all": [ - "void odbc_close_all(void)", + "void odbc_close_all()", "Close all ODBC connections" ], "odbc_columnprivileges": [ @@ -8065,7 +8264,7 @@ var functionMap = { "Encrypts given data with given method and key, returns raw or base64 encoded string" ], "openssl_error_string": [ - "mixed openssl_error_string(void)", + "mixed openssl_error_string()", "Returns a description of the last error, and alters the index of the error messages. Returns false when the are no more messages" ], "openssl_get_cipher_methods": [ @@ -8205,7 +8404,7 @@ var functionMap = { "Add URL rewriter values" ], "output_reset_rewrite_vars": [ - "bool output_reset_rewrite_vars(void)", + "bool output_reset_rewrite_vars()", "Reset(clear) URL rewriter values" ], "pack": [ @@ -8257,7 +8456,7 @@ var functionMap = { "Executes specified program in current process space as defined by exec(2)" ], "pcntl_fork": [ - "int pcntl_fork(void)", + "int pcntl_fork()", "Forks the currently running process following the same behavior as the UNIX fork() system call" ], "pcntl_getpriority": [ @@ -8374,7 +8573,7 @@ var functionMap = { ], "pg_delete": [ "mixed pg_delete(resource db, string table, array ids[, int options])", - "Delete records has ids (id=>value)" + "Delete records has ids (id => value)" ], "pg_end_copy": [ "bool pg_end_copy([resource connection])", @@ -8474,7 +8673,7 @@ var functionMap = { ], "pg_insert": [ "mixed pg_insert(resource db, string table, array values[, int options])", - "Insert values (filed=>value) to table" + "Insert values (filed => value) to table" ], "pg_last_error": [ "string pg_last_error([resource connection])", @@ -8598,7 +8797,7 @@ var functionMap = { ], "pg_select": [ "mixed pg_select(resource db, string table, array ids[, int options])", - "Select records that has ids (id=>value)" + "Select records that has ids (id => value)" ], "pg_send_execute": [ "bool pg_send_execute(resource connection, string stmtname, array params)", @@ -8646,34 +8845,34 @@ var functionMap = { ], "pg_update": [ "mixed pg_update(resource db, string table, array fields, array ids[, int options])", - "Update table using values (field=>value) and ids (id=>value)" + "Update table using values (field => value) and ids (id => value)" ], "pg_version": [ "array pg_version([resource connection])", "Returns an array with client, protocol and server version (when available)" ], "php_egg_logo_guid": [ - "string php_egg_logo_guid(void)", + "string php_egg_logo_guid()", "Return the special ID used to request the PHP logo in phpinfo screens" ], "php_ini_loaded_file": [ - "string php_ini_loaded_file(void)", + "string php_ini_loaded_file()", "Return the actual loaded ini filename" ], "php_ini_scanned_files": [ - "string php_ini_scanned_files(void)", + "string php_ini_scanned_files()", "Return comma-separated string of .ini files parsed from the additional ini dir" ], "php_logo_guid": [ - "string php_logo_guid(void)", + "string php_logo_guid()", "Return the special ID used to request the PHP logo in phpinfo screens" ], "php_real_logo_guid": [ - "string php_real_logo_guid(void)", + "string php_real_logo_guid()", "Return the special ID used to request the PHP logo in phpinfo screens" ], "php_sapi_name": [ - "string php_sapi_name(void)", + "string php_sapi_name()", "Return the current SAPI module name" ], "php_snmpv3": [ @@ -8685,7 +8884,7 @@ var functionMap = { "Return source with stripped comments and whitespace" ], "php_uname": [ - "string php_uname(void)", + "string php_uname()", "Return information about the system PHP was built on" ], "phpcredits": [ @@ -8701,11 +8900,11 @@ var functionMap = { "Return the current PHP version" ], "pi": [ - "float pi(void)", + "float pi()", "Returns an approximation of pi" ], "png2wbmp": [ - "bool png2wbmp (string f_org, string f_dest, int d_height, int d_width, int threshold)", + "bool png2wbmp(string f_org, string f_dest, int d_height, int d_width, int threshold)", "Convert PNG image to WBMP image" ], "popen": [ @@ -8717,27 +8916,27 @@ var functionMap = { "Determine accessibility of a file (POSIX.1 5.6.3)" ], "posix_ctermid": [ - "string posix_ctermid(void)", + "string posix_ctermid()", "Generate terminal path name (POSIX.1, 4.7.1)" ], "posix_get_last_error": [ - "int posix_get_last_error(void)", + "int posix_get_last_error()", "Retrieve the error number set by the last posix function which failed." ], "posix_getcwd": [ - "string posix_getcwd(void)", + "string posix_getcwd()", "Get working directory pathname (POSIX.1, 5.2.2)" ], "posix_getegid": [ - "int posix_getegid(void)", + "int posix_getegid()", "Get the current effective group id (POSIX.1, 4.2.1)" ], "posix_geteuid": [ - "int posix_geteuid(void)", + "int posix_geteuid()", "Get the current effective user id (POSIX.1, 4.2.1)" ], "posix_getgid": [ - "int posix_getgid(void)", + "int posix_getgid()", "Get the current group id (POSIX.1, 4.2.1)" ], "posix_getgrgid": [ @@ -8749,27 +8948,27 @@ var functionMap = { "Group database access (POSIX.1, 9.2.1)" ], "posix_getgroups": [ - "array posix_getgroups(void)", + "array posix_getgroups()", "Get supplementary group id's (POSIX.1, 4.2.3)" ], "posix_getlogin": [ - "string posix_getlogin(void)", + "string posix_getlogin()", "Get user name (POSIX.1, 4.2.4)" ], "posix_getpgid": [ - "int posix_getpgid(void)", + "int posix_getpgid()", "Get the process group id of the specified process (This is not a POSIX function, but a SVR4ism, so we compile conditionally)" ], "posix_getpgrp": [ - "int posix_getpgrp(void)", + "int posix_getpgrp()", "Get current process group id (POSIX.1, 4.3.1)" ], "posix_getpid": [ - "int posix_getpid(void)", + "int posix_getpid()", "Get the current process id (POSIX.1, 4.1.1)" ], "posix_getppid": [ - "int posix_getppid(void)", + "int posix_getppid()", "Get the parent process id (POSIX.1, 4.1.1)" ], "posix_getpwnam": [ @@ -8781,15 +8980,15 @@ var functionMap = { "User database access (POSIX.1, 9.2.2)" ], "posix_getrlimit": [ - "array posix_getrlimit(void)", + "array posix_getrlimit()", "Get system resource consumption limits (This is not a POSIX function, but a BSDism and a SVR4ism. We compile conditionally)" ], "posix_getsid": [ - "int posix_getsid(void)", + "int posix_getsid()", "Get process group id of session leader (This is not a POSIX function, but a SVR4ism, so be compile conditionally)" ], "posix_getuid": [ - "int posix_getuid(void)", + "int posix_getuid()", "Get the current user id (POSIX.1, 4.2.1)" ], "posix_initgroups": [ @@ -8829,7 +9028,7 @@ var functionMap = { "Set process group id for job control (POSIX.1, 4.3.3)" ], "posix_setsid": [ - "int posix_setsid(void)", + "int posix_setsid()", "Create session and set process group id (POSIX.1, 4.3.2)" ], "posix_setuid": [ @@ -8841,7 +9040,7 @@ var functionMap = { "Retrieve the system error message associated with the given errno." ], "posix_times": [ - "array posix_times(void)", + "array posix_times()", "Get process times (POSIX.1, 4.5.2)" ], "posix_ttyname": [ @@ -8849,7 +9048,7 @@ var functionMap = { "Determine terminal device name (POSIX.1, 4.7.2)" ], "posix_uname": [ - "array posix_uname(void)", + "array posix_uname()", "Get system name (POSIX.1, 4.4.1)" ], "pow": [ @@ -9017,8 +9216,8 @@ var functionMap = { "Convert a quoted-printable string to an 8 bit string" ], "quoted_printable_encode": [ - "string quoted_printable_encode(string str) */", - "PHP_FUNCTION(quoted_printable_encode) { char *str, *new_str; int str_len; size_t new_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &str, &str_len) != SUCCESS) { return; } if (!str_len) { RETURN_EMPTY_STRING(); } new_str = (char *)php_quot_print_encode((unsigned char *)str, (size_t)str_len, &new_str_len); RETURN_STRINGL(new_str, new_str_len, 0); } /* }}}" + "string quoted_printable_encode(string str)", + "" ], "quotemeta": [ "string quotemeta(string str)", @@ -9077,7 +9276,7 @@ var functionMap = { "Informs the readline callback interface that a character is ready for input" ], "readline_clear_history": [ - "bool readline_clear_history(void)", + "bool readline_clear_history()", "Clears the history" ], "readline_completion_function": [ @@ -9089,11 +9288,11 @@ var functionMap = { "Gets/sets various internal readline variables." ], "readline_list_history": [ - "array readline_list_history(void)", + "array readline_list_history()", "Lists the history" ], "readline_on_new_line": [ - "void readline_on_new_line(void)", + "void readline_on_new_line()", "Inform readline that the cursor has moved to a new line" ], "readline_read_history": [ @@ -9101,7 +9300,7 @@ var functionMap = { "Reads the history" ], "readline_redisplay": [ - "void readline_redisplay(void)", + "void readline_redisplay()", "Ask readline to redraw the display" ], "readline_write_history": [ @@ -9157,11 +9356,11 @@ var functionMap = { "Set array argument's internal pointer to the first element and return it" ], "restore_error_handler": [ - "void restore_error_handler(void)", + "void restore_error_handler()", "Restores the previously defined error handler function" ], "restore_exception_handler": [ - "void restore_exception_handler(void)", + "void restore_exception_handler()", "Restores the previously defined exception handler function" ], "restore_include_path": [ @@ -9229,15 +9428,15 @@ var functionMap = { "Deserializes data and reinitializes the variables" ], "session_destroy": [ - "bool session_destroy(void)", + "bool session_destroy()", "Destroy the current session and all data associated with it" ], "session_encode": [ - "string session_encode(void)", + "string session_encode()", "Serializes the current setup and returns the serialized representation" ], "session_get_cookie_params": [ - "array session_get_cookie_params(void)", + "array session_get_cookie_params()", "Return the session cookie parameters" ], "session_id": [ @@ -9277,7 +9476,7 @@ var functionMap = { "Sets user-level functions" ], "session_start": [ - "bool session_start(void)", + "bool session_start()", "Begin session - reinitializes freezed variables, registers browsers etc" ], "session_unregister": [ @@ -9285,11 +9484,11 @@ var functionMap = { "Removes varname from the list of variables which are freezed at the session end" ], "session_unset": [ - "void session_unset(void)", + "void session_unset()", "Unset all registered variables" ], "session_write_close": [ - "void session_write_close(void)", + "void session_write_close()", "Write session data and end session" ], "set_error_handler": [ @@ -9369,27 +9568,27 @@ var functionMap = { "Removes variable from shared memory" ], "shmop_close": [ - "void shmop_close (int shmid)", + "void shmop_close(int shmid)", "closes a shared memory segment" ], "shmop_delete": [ - "bool shmop_delete (int shmid)", + "bool shmop_delete(int shmid)", "mark segment for deletion" ], "shmop_open": [ - "int shmop_open (int key, string flags, int mode, int size)", + "int shmop_open(int key, string flags, int mode, int size)", "gets and attaches a shared memory segment" ], "shmop_read": [ - "string shmop_read (int shmid, int start, int count)", + "string shmop_read(int shmid, int start, int count)", "reads from a shm segment" ], "shmop_size": [ - "int shmop_size (int shmid)", + "int shmop_size(int shmid)", "returns the shm size" ], "shmop_write": [ - "int shmop_write (int shmid, string data, int offset)", + "int shmop_write(int shmid, string data, int offset)", "writes to a shared memory segment" ], "shuffle": [ @@ -9501,7 +9700,7 @@ var functionMap = { "Fetch the value of a SNMP object" ], "snmp_get_quick_print": [ - "bool snmp_get_quick_print(void)", + "bool snmp_get_quick_print()", "Return the current status of quick_print" ], "snmp_get_valueretrieval": [ @@ -9749,7 +9948,7 @@ var functionMap = { "Escapes a string for use as a query parameter." ], "sqlite_exec": [ - "boolean sqlite_exec(string query, resource db[, string &error_message])", + "bool sqlite_exec(string query, resource db[, string &error_message])", "Executes a result-less query against a given database" ], "sqlite_factory": [ @@ -10001,7 +10200,7 @@ var functionMap = { "Reads all remaining bytes (or up to maxlen bytes) from a stream and returns them as a string." ], "stream_get_filters": [ - "array stream_get_filters(void)", + "array stream_get_filters()", "Returns a list of registered filters" ], "stream_get_line": [ @@ -10265,7 +10464,7 @@ var functionMap = { "Free result memory" ], "sybase_get_last_message": [ - "string sybase_get_last_message(void)", + "string sybase_get_last_message()", "Returns the last message from server (over min_message_severity)" ], "sybase_min_client_severity": [ @@ -10349,7 +10548,7 @@ var functionMap = { "Returns the Number of Tidy accessibility warnings encountered for specified document." ], "tidy_clean_repair": [ - "boolean tidy_clean_repair()", + "bool tidy_clean_repair()", "Execute configured cleanup and repair operations on parsed markup" ], "tidy_config_count": [ @@ -10357,7 +10556,7 @@ var functionMap = { "Returns the Number of Tidy configuration errors encountered for specified document." ], "tidy_diagnose": [ - "boolean tidy_diagnose()", + "bool tidy_diagnose()", "Run configured diagnostics on parsed and repaired markup." ], "tidy_error_count": [ @@ -10373,7 +10572,7 @@ var functionMap = { "Get current Tidy configuarion" ], "tidy_get_error_buffer": [ - "string tidy_get_error_buffer([boolean detailed])", + "string tidy_get_error_buffer([bool detailed])", "Return warnings and errors which occured parsing the specified document" ], "tidy_get_head": [ @@ -10413,15 +10612,15 @@ var functionMap = { "Returns the value of the specified configuration option for the tidy document." ], "tidy_is_xhtml": [ - "boolean tidy_is_xhtml()", + "bool tidy_is_xhtml()", "Indicates if the document is a XHTML document." ], "tidy_is_xml": [ - "boolean tidy_is_xml()", + "bool tidy_is_xml()", "Indicates if the document is a generic (non HTML/XHTML) XML document." ], "tidy_parse_file": [ - "boolean tidy_parse_file(string file [, mixed config_options [, string encoding [, bool use_include_path]]])", + "bool tidy_parse_file(string file [, mixed config_options [, string encoding [, bool use_include_path]]])", "Parse markup in file or URI" ], "tidy_parse_string": [ @@ -10429,11 +10628,11 @@ var functionMap = { "Parse a document stored in a string" ], "tidy_repair_file": [ - "boolean tidy_repair_file(string filename [, mixed config_file [, string encoding [, bool use_include_path]]])", + "bool tidy_repair_file(string filename [, mixed config_file [, string encoding [, bool use_include_path]]])", "Repair a file using an optionally provided configuration file" ], "tidy_repair_string": [ - "boolean tidy_repair_string(string data [, mixed config_file [, string encoding]])", + "bool tidy_repair_string(string data [, mixed config_file [, string encoding]])", "Repair a string using an optionally provided configuration file" ], "tidy_warning_count": [ @@ -10441,7 +10640,7 @@ var functionMap = { "Returns the Number of Tidy warnings encountered for specified document." ], "time": [ - "int time(void)", + "int time()", "Return current UNIX timestamp" ], "time_nanosleep": [ @@ -10489,7 +10688,7 @@ var functionMap = { "Returns the Olson database version number." ], "tmpfile": [ - "resource tmpfile(void)", + "resource tmpfile()", "Create a temporary file that will be deleted automatically after use" ], "token_get_all": [ @@ -10557,7 +10756,7 @@ var functionMap = { "Takes a string representation of variable and recreates it" ], "unset": [ - "void unset (mixed var [, mixed var])", + "void unset(mixed var [, mixed var])", "Unset a given variable" ], "urldecode": [ @@ -10589,7 +10788,7 @@ var functionMap = { "Dumps a string representation of variable to output" ], "var_export": [ - "mixed var_export(mixed var [, bool return])", + "string var_export(mixed var [, bool return])", "Outputs or returns a string representation of a variable" ], "variant_abs": [ @@ -10717,7 +10916,7 @@ var functionMap = { "Return a formatted string" ], "wddx_add_vars": [ - "int wddx_add_vars(resource packet_id, mixed var_names [, mixed ...])", + "int wddx_add_vars(resource packet_id, mixed var_names [, mixed ...])", "Serializes given variables and adds them to packet given by packet_id" ], "wddx_deserialize": [ @@ -10741,7 +10940,7 @@ var functionMap = { "Creates a new packet and serializes given variables into a struct" ], "wordwrap": [ - "string wordwrap(string str [, int width [, string break [, boolean cut]]])", + "string wordwrap(string str [, int width [, string break [, bool cut]]])", "Wraps buffer to selected number of characters using string break char" ], "xml_error_string": [ @@ -10869,7 +11068,7 @@ var functionMap = { "Parses XML requests and call methods" ], "xmlrpc_server_create": [ - "resource xmlrpc_server_create(void)", + "resource xmlrpc_server_create()", "Creates an xmlrpc server" ], "xmlrpc_server_destroy": [ @@ -11057,51 +11256,51 @@ var functionMap = { "Write text - returns FALSE on error" ], "xsl_xsltprocessor_get_parameter": [ - "string xsl_xsltprocessor_get_parameter(string namespace, string name);", + "string xsl_xsltprocessor_get_parameter(string namespace, string name)", "" ], "xsl_xsltprocessor_has_exslt_support": [ - "bool xsl_xsltprocessor_has_exslt_support();", + "bool xsl_xsltprocessor_has_exslt_support()", "" ], "xsl_xsltprocessor_import_stylesheet": [ - "void xsl_xsltprocessor_import_stylesheet(domdocument doc);", - "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html# Since:" + "void xsl_xsltprocessor_import_stylesheet(domdocument doc)", + "" ], "xsl_xsltprocessor_register_php_functions": [ - "void xsl_xsltprocessor_register_php_functions([mixed $restrict]);", + "void xsl_xsltprocessor_register_php_functions([mixed $restrict])", "" ], "xsl_xsltprocessor_remove_parameter": [ - "bool xsl_xsltprocessor_remove_parameter(string namespace, string name);", + "bool xsl_xsltprocessor_remove_parameter(string namespace, string name)", "" ], "xsl_xsltprocessor_set_parameter": [ - "bool xsl_xsltprocessor_set_parameter(string namespace, mixed name [, string value]);", + "bool xsl_xsltprocessor_set_parameter(string namespace, mixed name [, string value])", "" ], "xsl_xsltprocessor_set_profiling": [ - "bool xsl_xsltprocessor_set_profiling(string filename) */", - "PHP_FUNCTION(xsl_xsltprocessor_set_profiling) { zval *id; xsl_object *intern; char *filename = NULL; int filename_len; DOM_GET_THIS(id); if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"s!\", &filename, &filename_len) == SUCCESS) { intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); if (intern->profiling) { efree(intern->profiling); } if (filename != NULL) { intern->profiling = estrndup(filename,filename_len); } else { intern->profiling = NULL; } RETURN_TRUE; } else { WRONG_PARAM_COUNT; } } /* }}} end xsl_xsltprocessor_set_profiling" + "bool xsl_xsltprocessor_set_profiling(string filename)", + "" ], "xsl_xsltprocessor_transform_to_doc": [ - "domdocument xsl_xsltprocessor_transform_to_doc(domnode doc);", - "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html# Since:" + "domdocument xsl_xsltprocessor_transform_to_doc(domnode doc)", + "" ], "xsl_xsltprocessor_transform_to_uri": [ - "int xsl_xsltprocessor_transform_to_uri(domdocument doc, string uri);", + "int xsl_xsltprocessor_transform_to_uri(domdocument doc, string uri)", "" ], "xsl_xsltprocessor_transform_to_xml": [ - "string xsl_xsltprocessor_transform_to_xml(domdocument doc);", + "string xsl_xsltprocessor_transform_to_xml(domdocument doc)", "" ], "zend_logo_guid": [ - "string zend_logo_guid(void)", + "string zend_logo_guid()", "Return the special ID used to request the Zend logo in phpinfo screens" ], "zend_version": [ - "string zend_version(void)", + "string zend_version()", "Get the version of the Zend Engine" ], "zip_close": [ @@ -11145,7 +11344,7 @@ var functionMap = { "Returns the next file in the archive" ], "zlib_get_coding_type": [ - "string zlib_get_coding_type(void)", + "string zlib_get_coding_type()", "Returns the coding type used for output compression" ] }; @@ -11196,7 +11395,9 @@ var variableMap = { "SERVER_PORT": 1, "SERVER_PROTOCOL": 1, "SERVER_SIGNATURE": 1, - "SERVER_SOFTWARE": 1 + "SERVER_SOFTWARE": 1, + "argv": 1, + "argc": 1 } }, "$_SESSION": { @@ -11204,6 +11405,12 @@ var variableMap = { }, "$GLOBALS": { type: "array" + }, + '$argv': { + type: "array" + }, + '$argc': { + type: "int" } }; @@ -11531,6 +11738,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -11868,6 +12076,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -12760,6 +12969,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -12886,6 +13096,7 @@ oop.inherits(Mode, HtmlMode); }; this.$id = "ace/mode/php"; + this.snippetFileId = "ace/snippets/php"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-php_laravel_blade.js b/htdocs/includes/ace/src/mode-php_laravel_blade.js index cd09a1f11fa..b9393a8a281 100644 --- a/htdocs/includes/ace/src/mode-php_laravel_blade.js +++ b/htdocs/includes/ace/src/mode-php_laravel_blade.js @@ -2309,15 +2309,15 @@ var functionMap = { "Escapes single quote, double quotes and backslash characters in a string with backslashes" ], "apache_child_terminate": [ - "bool apache_child_terminate(void)", + "bool apache_child_terminate()", "Terminate apache process after this request" ], "apache_get_modules": [ - "array apache_get_modules(void)", + "array apache_get_modules()", "Get a list of loaded Apache modules" ], "apache_get_version": [ - "string apache_get_version(void)", + "string apache_get_version()", "Fetch Apache version" ], "apache_getenv": [ @@ -2349,7 +2349,7 @@ var functionMap = { "* fetch all headers that go out in case of an error or a subrequest" ], "apache_request_headers": [ - "array apache_request_headers(void)", + "array apache_request_headers()", "Fetch all HTTP request headers" ], "apache_request_headers_in": [ @@ -2365,7 +2365,7 @@ var functionMap = { "" ], "apache_request_log_error": [ - "boolean apache_request_log_error(string message, [long facility])", + "bool apache_request_log_error(string message, [long facility])", "" ], "apache_request_meets_conditions": [ @@ -2417,11 +2417,11 @@ var functionMap = { "" ], "apache_reset_timeout": [ - "bool apache_reset_timeout(void)", + "bool apache_reset_timeout()", "Reset the Apache write timer" ], "apache_response_headers": [ - "array apache_response_headers(void)", + "array apache_response_headers()", "Fetch all HTTP response headers" ], "apache_setenv": [ @@ -2508,6 +2508,14 @@ var functionMap = { "array array_keys(array input [, mixed search_value[, bool strict]])", "Return just the keys from the input array, optionally only for the specified search_value" ], + "array_key_first": [ + "mixed array_key_first(array arr)", + "Returns the first key of arr if the array is not empty; NULL otherwise" + ], + "array_key_last": [ + "mixed array_key_last(array arr)", + "Returns the last key of arr if the array is not empty; NULL otherwise" + ], "array_map": [ "array array_map(mixed callback, array input1 [, array input2 ,...])", "Applies the callback to the elements in given arrays." @@ -2865,7 +2873,7 @@ var functionMap = { "Change file mode" ], "chown": [ - "bool chown (string filename, mixed user)", + "bool chown(string filename, mixed user)", "Change file owner" ], "chr": [ @@ -2893,7 +2901,7 @@ var functionMap = { "Return all classes and interfaces implemented by SPL" ], "class_parents": [ - "array class_parents(object instance [, boolean autoload = true])", + "array class_parents(object instance [, bool autoload = true])", "Return an array containing the names of all parent classes" ], "clearstatcache": [ @@ -2905,7 +2913,7 @@ var functionMap = { "Close directory connection identified by the dir_handle" ], "closelog": [ - "bool closelog(void)", + "bool closelog()", "Close connection to system logger" ], "collator_asort": [ @@ -2997,11 +3005,11 @@ var functionMap = { "Return a string to confirm that the module is compiled in" ], "connection_aborted": [ - "int connection_aborted(void)", + "int connection_aborted()", "Returns true if client disconnected" ], "connection_status": [ - "int connection_status(void)", + "int connection_status()", "Returns the connection status bitfield" ], "constant": [ @@ -3046,7 +3054,7 @@ var functionMap = { ], "create_function": [ "string create_function(string args, string code)", - "Creates an anonymous function, and returns its name (funny, eh?)" + "Creates an anonymous function, and returns its name" ], "crypt": [ "string crypt(string str [, string salt])", @@ -3145,7 +3153,7 @@ var functionMap = { "Get information about the current transfers" ], "curl_multi_init": [ - "resource curl_multi_init(void)", + "resource curl_multi_init()", "Returns a new cURL multi handle" ], "curl_multi_remove_handle": [ @@ -3341,7 +3349,7 @@ var functionMap = { "* Set formatter pattern." ], "datefmt_set_timezone_id": [ - "boolean datefmt_set_timezone_id( IntlDateFormatter $mf,$timezone_id)", + "bool datefmt_set_timezone_id( IntlDateFormatter $mf,$timezone_id)", "* Set formatter timezone_id." ], "dba_close": [ @@ -3409,7 +3417,7 @@ var functionMap = { "Return the translation of msgid for domain_name and category, or msgid unaltered if a translation does not exist" ], "dcngettext": [ - "string dcngettext (string domain, string msgid1, string msgid2, int n, int category)", + "string dcngettext(string domain, string msgid1, string msgid2, int n, int category)", "Plural version of dcgettext()" ], "debug_backtrace": [ @@ -3417,44 +3425,231 @@ var functionMap = { "Return backtrace as array" ], "debug_print_backtrace": [ - "void debug_print_backtrace(void) */", - "ZEND_FUNCTION(debug_print_backtrace) { zend_execute_data *ptr, *skip; int lineno; char *function_name; char *filename; char *class_name = NULL; char *call_type; char *include_filename = NULL; zval *arg_array = NULL; int indent = 0; if (zend_parse_parameters_none() == FAILURE) { return; } ptr = EG(current_execute_data);", + "void debug_print_backtrace()", + "Prints a PHP backtrace" + ], + "debug_zval_dump": [ + "void debug_zval_dump(mixed var)", + "Dumps a string representation of an internal Zend value to output" + ], + "decbin": [ + "string decbin(int decimal_number)", + "Returns a string containing a binary representation of the number" + ], + "dechex": [ + "string dechex(int decimal_number)", + "Returns a string containing a hexadecimal representation of the given number" + ], + "decoct": [ + "string decoct(int decimal_number)", + "Returns a string containing an octal representation of the given number" + ], + "define": [ + "bool define(string constant_name, mixed value, bool case_insensitive=false)", + "Define a new constant" + ], + "define_syslog_variables": [ + "void define_syslog_variables()", + "Initializes all syslog-related variables" + ], + "defined": [ + "bool defined(string constant_name)", + "Check whether a constant exists" + ], + "deg2rad": [ + "float deg2rad(float number)", + "Converts the number in degrees to the radian equivalent" + ], + "dgettext": [ + "string dgettext(string domain_name, string msgid)", + "Return the translation of msgid for domain_name, or msgid unaltered if a translation does not exist" + ], + "die": [ + "void die([mixed status])", + "Output a message and terminate the current script" + ], + "dir": [ + "object dir(string directory[, resource context])", + "Directory class with properties, handle and class and methods read, rewind and close" + ], + "dirname": [ + "string dirname(string path)", + "Returns the directory name component of the path" + ], + "disk_free_space": [ + "float disk_free_space(string path)", + "Get free disk space for filesystem that path is on" + ], + "disk_total_space": [ + "float disk_total_space(string path)", + "Get total disk space for filesystem that path is on" + ], + "display_disabled_function": [ + "void display_disabled_function()", + "Dummy function which displays an error when a disabled function is called." + ], + "dl": [ + "int dl(string extension_filename)", + "Load a PHP extension at runtime" + ], + "dngettext": [ + "string dngettext(string domain, string msgid1, string msgid2, int count)", + "Plural version of dgettext()" + ], + "dns_check_record": [ + "bool dns_check_record(string host [, string type])", + "Check DNS records corresponding to a given Internet host name or IP address" + ], + "dns_get_mx": [ + "bool dns_get_mx(string hostname, array mxhosts [, array weight])", + "Get MX records corresponding to a given Internet host name" + ], + "dns_get_record": [ + "array|false dns_get_record(string hostname [, int type[, array authns, array addtl]])", + "Get any Resource Record corresponding to a given Internet host name" + ], + "dom_attr_is_id": [ + "bool dom_attr_is_id()", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-isId Since: DOM Level 3" + ], + "dom_characterdata_append_data": [ + "void dom_characterdata_append_data(string arg)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-32791A2F Since:" + ], + "dom_characterdata_delete_data": [ + "void dom_characterdata_delete_data(int offset, int count)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-7C603781 Since:" + ], + "dom_characterdata_insert_data": [ + "void dom_characterdata_insert_data(int offset, string arg)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-3EDB695F Since:" + ], + "dom_characterdata_replace_data": [ + "void dom_characterdata_replace_data(int offset, int count, string arg)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-E5CBA7FB Since:" + ], + "dom_characterdata_substring_data": [ + "string dom_characterdata_substring_data(int offset, int count)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6531BCCF Since:" + ], + "dom_document_adopt_node": [ + "DOMNode dom_document_adopt_node(DOMNode source)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-adoptNode Since: DOM Level 3" + ], + "dom_document_create_attribute": [ + "DOMAttr dom_document_create_attribute(string name)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1084891198 Since:" + ], + "dom_document_create_attribute_ns": [ + "DOMAttr dom_document_create_attribute_ns(string namespaceURI, string qualifiedName)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrAttrNS Since: DOM Level 2" + ], + "dom_document_create_cdatasection": [ + "DOMCdataSection dom_document_create_cdatasection(string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D26C0AF8 Since:" + ], + "dom_document_create_comment": [ + "DOMComment dom_document_create_comment(string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1334481328 Since:" + ], + "dom_document_create_document_fragment": [ + "DOMDocumentFragment dom_document_create_document_fragment()", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-35CB04B5 Since:" + ], + "dom_document_create_element": [ + "DOMElement dom_document_create_element(string tagName [, string value])", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-2141741547 Since:" + ], + "dom_document_create_element_ns": [ + "DOMElement dom_document_create_element_ns(string namespaceURI, string qualifiedName [,string value])", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrElNS Since: DOM Level 2" + ], + "dom_document_create_entity_reference": [ + "DOMEntityReference dom_document_create_entity_reference(string name)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-392B75AE Since:" + ], + "dom_document_create_processing_instruction": [ + "DOMProcessingInstruction dom_document_create_processing_instruction(string target, string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-135944439 Since:" + ], + "dom_document_create_text_node": [ + "DOMText dom_document_create_text_node(string data)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1975348127 Since:" + ], + "dom_document_get_element_by_id": [ + "DOMElement dom_document_get_element_by_id(string elementId)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBId Since: DOM Level 2" + ], + "dom_document_get_elements_by_tag_name": [ + "DOMNodeList dom_document_get_elements_by_tag_name(string tagname)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C9094 Since:" + ], + "dom_document_get_elements_by_tag_name_ns": [ + "DOMNodeList dom_document_get_elements_by_tag_name_ns(string namespaceURI, string localName)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBTNNS Since: DOM Level 2" + ], + "dom_document_import_node": [ + "DOMNode dom_document_import_node(DOMNode importedNode, bool deep)", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Core-Document-importNode Since: DOM Level 2" + ], + "dom_document_load": [ + "DOMNode dom_document_load(string source [, int options])", + "URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-load Since: DOM Level 3" + ], + "dom_document_load_html": [ + "DOMNode dom_document_load_html(string source)", + "Since: DOM extended" + ], + "dom_document_load_html_file": [ + "DOMNode dom_document_load_html_file(string source)", + "Since: DOM extended" + ], + "dom_document_loadxml": [ + "DOMNode dom_document_loadxml(string source [, int options])", + "URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-loadXML Since: DOM Level 3" + ], + "dom_document_normalize_document": [ + "void dom_document_normalize_document()", + "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-normalizeDocument Since: DOM Level 3" + ], + "dom_document_relaxNG_validate_file": [ + "bool dom_document_relaxNG_validate_file(string filename); */", "PHP_FUNCTION(dom_document_relaxNG_validate_file) { _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } /* }}} end dom_document_relaxNG_validate_file" ], "dom_document_relaxNG_validate_xml": [ - "boolean dom_document_relaxNG_validate_xml(string source); */", + "bool dom_document_relaxNG_validate_xml(string source); */", "PHP_FUNCTION(dom_document_relaxNG_validate_xml) { _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } /* }}} end dom_document_relaxNG_validate_xml" ], "dom_document_rename_node": [ - "DOMNode dom_document_rename_node(node n, string namespaceURI, string qualifiedName);", + "DOMNode dom_document_rename_node(node n, string namespaceURI, string qualifiedName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-renameNode Since: DOM Level 3" ], "dom_document_save": [ - "int dom_document_save(string file);", + "int dom_document_save(string file)", "Convenience method to save to file" ], "dom_document_save_html": [ - "string dom_document_save_html();", + "string dom_document_save_html()", "Convenience method to output as html" ], "dom_document_save_html_file": [ - "int dom_document_save_html_file(string file);", + "int dom_document_save_html_file(string file)", "Convenience method to save to file as html" ], "dom_document_savexml": [ - "string dom_document_savexml([node n]);", + "string dom_document_savexml([node n])", "URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-saveXML Since: DOM Level 3" ], "dom_document_schema_validate": [ - "boolean dom_document_schema_validate(string source); */", + "bool dom_document_schema_validate(string source); */", "PHP_FUNCTION(dom_document_schema_validate_xml) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } /* }}} end dom_document_schema_validate" ], "dom_document_schema_validate_file": [ - "boolean dom_document_schema_validate_file(string filename); */", + "bool dom_document_schema_validate_file(string filename); */", "PHP_FUNCTION(dom_document_schema_validate_file) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } /* }}} end dom_document_schema_validate_file" ], "dom_document_validate": [ - "boolean dom_document_validate();", + "bool dom_document_validate()", "Since: DOM extended" ], "dom_document_xinclude": [ @@ -3462,123 +3657,123 @@ var functionMap = { "Substitutues xincludes in a DomDocument" ], "dom_domconfiguration_can_set_parameter": [ - "boolean dom_domconfiguration_can_set_parameter(string name, domuserdata value);", + "bool dom_domconfiguration_can_set_parameter(string name, domuserdata value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-canSetParameter Since:" ], "dom_domconfiguration_get_parameter": [ - "domdomuserdata dom_domconfiguration_get_parameter(string name);", + "domdomuserdata dom_domconfiguration_get_parameter(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-getParameter Since:" ], "dom_domconfiguration_set_parameter": [ - "dom_void dom_domconfiguration_set_parameter(string name, domuserdata value);", + "dom_void dom_domconfiguration_set_parameter(string name, domuserdata value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMConfiguration-property Since:" ], "dom_domerrorhandler_handle_error": [ - "dom_boolean dom_domerrorhandler_handle_error(domerror error);", + "dom_bool dom_domerrorhandler_handle_error(domerror error)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-ERRORS-DOMErrorHandler-handleError Since:" ], "dom_domimplementation_create_document": [ - "DOMDocument dom_domimplementation_create_document(string namespaceURI, string qualifiedName, DOMDocumentType doctype);", + "DOMDocument dom_domimplementation_create_document(string namespaceURI, string qualifiedName, DOMDocumentType doctype)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocument Since: DOM Level 2" ], "dom_domimplementation_create_document_type": [ - "DOMDocumentType dom_domimplementation_create_document_type(string qualifiedName, string publicId, string systemId);", + "DOMDocumentType dom_domimplementation_create_document_type(string qualifiedName, string publicId, string systemId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocType Since: DOM Level 2" ], "dom_domimplementation_get_feature": [ - "DOMNode dom_domimplementation_get_feature(string feature, string version);", + "DOMNode dom_domimplementation_get_feature(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementation3-getFeature Since: DOM Level 3" ], "dom_domimplementation_has_feature": [ - "boolean dom_domimplementation_has_feature(string feature, string version);", + "bool dom_domimplementation_has_feature(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-5CED94D7 Since:" ], "dom_domimplementationlist_item": [ - "domdomimplementation dom_domimplementationlist_item(int index);", + "domdomimplementation dom_domimplementationlist_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementationList-item Since:" ], "dom_domimplementationsource_get_domimplementation": [ - "domdomimplementation dom_domimplementationsource_get_domimplementation(string features);", + "domdomimplementation dom_domimplementationsource_get_domimplementation(string features)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-getDOMImpl Since:" ], "dom_domimplementationsource_get_domimplementations": [ - "domimplementationlist dom_domimplementationsource_get_domimplementations(string features);", + "domimplementationlist dom_domimplementationsource_get_domimplementations(string features)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-getDOMImpls Since:" ], "dom_domstringlist_item": [ - "domstring dom_domstringlist_item(int index);", + "domstring dom_domstringlist_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMStringList-item Since:" ], "dom_element_get_attribute": [ - "string dom_element_get_attribute(string name);", + "string dom_element_get_attribute(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-666EE0F9 Since:" ], "dom_element_get_attribute_node": [ - "DOMAttr dom_element_get_attribute_node(string name);", + "DOMAttr dom_element_get_attribute_node(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-217A91B8 Since:" ], "dom_element_get_attribute_node_ns": [ - "DOMAttr dom_element_get_attribute_node_ns(string namespaceURI, string localName);", + "DOMAttr dom_element_get_attribute_node_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElGetAtNodeNS Since: DOM Level 2" ], "dom_element_get_attribute_ns": [ - "string dom_element_get_attribute_ns(string namespaceURI, string localName);", + "string dom_element_get_attribute_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElGetAttrNS Since: DOM Level 2" ], "dom_element_get_elements_by_tag_name": [ - "DOMNodeList dom_element_get_elements_by_tag_name(string name);", + "DOMNodeList dom_element_get_elements_by_tag_name(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1938918D Since:" ], "dom_element_get_elements_by_tag_name_ns": [ - "DOMNodeList dom_element_get_elements_by_tag_name_ns(string namespaceURI, string localName);", + "DOMNodeList dom_element_get_elements_by_tag_name_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C90942 Since: DOM Level 2" ], "dom_element_has_attribute": [ - "boolean dom_element_has_attribute(string name);", + "bool dom_element_has_attribute(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElHasAttr Since: DOM Level 2" ], "dom_element_has_attribute_ns": [ - "boolean dom_element_has_attribute_ns(string namespaceURI, string localName);", + "bool dom_element_has_attribute_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElHasAttrNS Since: DOM Level 2" ], "dom_element_remove_attribute": [ - "void dom_element_remove_attribute(string name);", + "void dom_element_remove_attribute(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-6D6AC0F9 Since:" ], "dom_element_remove_attribute_node": [ - "DOMAttr dom_element_remove_attribute_node(DOMAttr oldAttr);", + "DOMAttr dom_element_remove_attribute_node(DOMAttr oldAttr)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D589198 Since:" ], "dom_element_remove_attribute_ns": [ - "void dom_element_remove_attribute_ns(string namespaceURI, string localName);", + "void dom_element_remove_attribute_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElRemAtNS Since: DOM Level 2" ], "dom_element_set_attribute": [ - "void dom_element_set_attribute(string name, string value);", + "void dom_element_set_attribute(string name, string value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68F082 Since:" ], "dom_element_set_attribute_node": [ - "DOMAttr dom_element_set_attribute_node(DOMAttr newAttr);", + "DOMAttr dom_element_set_attribute_node(DOMAttr newAttr)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-887236154 Since:" ], "dom_element_set_attribute_node_ns": [ - "DOMAttr dom_element_set_attribute_node_ns(DOMAttr newAttr);", + "DOMAttr dom_element_set_attribute_node_ns(DOMAttr newAttr)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetAtNodeNS Since: DOM Level 2" ], "dom_element_set_attribute_ns": [ - "void dom_element_set_attribute_ns(string namespaceURI, string qualifiedName, string value);", + "void dom_element_set_attribute_ns(string namespaceURI, string qualifiedName, string value)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetAttrNS Since: DOM Level 2" ], "dom_element_set_id_attribute": [ - "void dom_element_set_id_attribute(string name, boolean isId);", + "void dom_element_set_id_attribute(string name, bool isId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttr Since: DOM Level 3" ], "dom_element_set_id_attribute_node": [ - "void dom_element_set_id_attribute_node(attr idAttr, boolean isId);", + "void dom_element_set_id_attribute_node(attr idAttr, bool isId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttrNode Since: DOM Level 3" ], "dom_element_set_id_attribute_ns": [ - "void dom_element_set_id_attribute_ns(string namespaceURI, string localName, boolean isId);", + "void dom_element_set_id_attribute_ns(string namespaceURI, string localName, bool isId)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-ElSetIdAttrNS Since: DOM Level 3" ], "dom_import_simplexml": [ @@ -3586,156 +3781,156 @@ var functionMap = { "Get a simplexml_element object from dom to allow for processing" ], "dom_namednodemap_get_named_item": [ - "DOMNode dom_namednodemap_get_named_item(string name);", + "DOMNode dom_namednodemap_get_named_item(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1074577549 Since:" ], "dom_namednodemap_get_named_item_ns": [ - "DOMNode dom_namednodemap_get_named_item_ns(string namespaceURI, string localName);", + "DOMNode dom_namednodemap_get_named_item_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getNamedItemNS Since: DOM Level 2" ], "dom_namednodemap_item": [ - "DOMNode dom_namednodemap_item(int index);", + "DOMNode dom_namednodemap_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-349467F9 Since:" ], "dom_namednodemap_remove_named_item": [ - "DOMNode dom_namednodemap_remove_named_item(string name);", + "DOMNode dom_namednodemap_remove_named_item(string name)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D58B193 Since:" ], "dom_namednodemap_remove_named_item_ns": [ - "DOMNode dom_namednodemap_remove_named_item_ns(string namespaceURI, string localName);", + "DOMNode dom_namednodemap_remove_named_item_ns(string namespaceURI, string localName)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-removeNamedItemNS Since: DOM Level 2" ], "dom_namednodemap_set_named_item": [ - "DOMNode dom_namednodemap_set_named_item(DOMNode arg);", + "DOMNode dom_namednodemap_set_named_item(DOMNode arg)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1025163788 Since:" ], "dom_namednodemap_set_named_item_ns": [ - "DOMNode dom_namednodemap_set_named_item_ns(DOMNode arg);", + "DOMNode dom_namednodemap_set_named_item_ns(DOMNode arg)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-setNamedItemNS Since: DOM Level 2" ], "dom_namelist_get_name": [ - "string dom_namelist_get_name(int index);", + "string dom_namelist_get_name(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList-getName Since:" ], "dom_namelist_get_namespace_uri": [ - "string dom_namelist_get_namespace_uri(int index);", + "string dom_namelist_get_namespace_uri(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#NameList-getNamespaceURI Since:" ], "dom_node_append_child": [ - "DomNode dom_node_append_child(DomNode newChild);", + "DomNode dom_node_append_child(DomNode newChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-184E7107 Since:" ], "dom_node_clone_node": [ - "DomNode dom_node_clone_node(boolean deep);", + "DomNode dom_node_clone_node(bool deep)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-3A0ED0A4 Since:" ], "dom_node_compare_document_position": [ - "short dom_node_compare_document_position(DomNode other);", + "short dom_node_compare_document_position(DomNode other)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-compareDocumentPosition Since: DOM Level 3" ], "dom_node_get_feature": [ - "DomNode dom_node_get_feature(string feature, string version);", + "DomNode dom_node_get_feature(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-getFeature Since: DOM Level 3" ], "dom_node_get_user_data": [ - "mixed dom_node_get_user_data(string key);", + "mixed dom_node_get_user_data(string key)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-getUserData Since: DOM Level 3" ], "dom_node_has_attributes": [ - "boolean dom_node_has_attributes();", + "bool dom_node_has_attributes()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-NodeHasAttrs Since: DOM Level 2" ], "dom_node_has_child_nodes": [ - "boolean dom_node_has_child_nodes();", + "bool dom_node_has_child_nodes()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-810594187 Since:" ], "dom_node_insert_before": [ - "domnode dom_node_insert_before(DomNode newChild, DomNode refChild);", + "domnode dom_node_insert_before(DomNode newChild, DomNode refChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-952280727 Since:" ], "dom_node_is_default_namespace": [ - "boolean dom_node_is_default_namespace(string namespaceURI);", + "bool dom_node_is_default_namespace(string namespaceURI)", "URL: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace Since: DOM Level 3" ], "dom_node_is_equal_node": [ - "boolean dom_node_is_equal_node(DomNode arg);", + "bool dom_node_is_equal_node(DomNode arg)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-isEqualNode Since: DOM Level 3" ], "dom_node_is_same_node": [ - "boolean dom_node_is_same_node(DomNode other);", + "bool dom_node_is_same_node(DomNode other)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-isSameNode Since: DOM Level 3" ], "dom_node_is_supported": [ - "boolean dom_node_is_supported(string feature, string version);", + "bool dom_node_is_supported(string feature, string version)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Level-2-Core-Node-supports Since: DOM Level 2" ], "dom_node_lookup_namespace_uri": [ - "string dom_node_lookup_namespace_uri(string prefix);", + "string dom_node_lookup_namespace_uri(string prefix)", "URL: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI Since: DOM Level 3" ], "dom_node_lookup_prefix": [ - "string dom_node_lookup_prefix(string namespaceURI);", + "string dom_node_lookup_prefix(string namespaceURI)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-lookupNamespacePrefix Since: DOM Level 3" ], "dom_node_normalize": [ - "void dom_node_normalize();", + "void dom_node_normalize()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-normalize Since:" ], "dom_node_remove_child": [ - "DomNode dom_node_remove_child(DomNode oldChild);", + "DomNode dom_node_remove_child(DomNode oldChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1734834066 Since:" ], "dom_node_replace_child": [ - "DomNode dom_node_replace_child(DomNode newChild, DomNode oldChild);", + "DomNode dom_node_replace_child(DomNode newChild, DomNode oldChild)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-785887307 Since:" ], "dom_node_set_user_data": [ - "mixed dom_node_set_user_data(string key, mixed data, userdatahandler handler);", + "mixed dom_node_set_user_data(string key, mixed data, userdatahandler handler)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-setUserData Since: DOM Level 3" ], "dom_nodelist_item": [ - "DOMNode dom_nodelist_item(int index);", + "DOMNode dom_nodelist_item(int index)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-844377136 Since:" ], "dom_string_extend_find_offset16": [ - "int dom_string_extend_find_offset16(int offset32);", + "int dom_string_extend_find_offset16(int offset32)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#i18n-methods-StringExtend-findOffset16 Since:" ], "dom_string_extend_find_offset32": [ - "int dom_string_extend_find_offset32(int offset16);", + "int dom_string_extend_find_offset32(int offset16)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#i18n-methods-StringExtend-findOffset32 Since:" ], "dom_text_is_whitespace_in_element_content": [ - "boolean dom_text_is_whitespace_in_element_content();", + "bool dom_text_is_whitespace_in_element_content()", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Text3-isWhitespaceInElementContent Since: DOM Level 3" ], "dom_text_replace_whole_text": [ - "DOMText dom_text_replace_whole_text(string content);", + "DOMText dom_text_replace_whole_text(string content)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Text3-replaceWholeText Since: DOM Level 3" ], "dom_text_split_text": [ - "DOMText dom_text_split_text(int offset);", + "DOMText dom_text_split_text(int offset)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-38853C1D Since:" ], "dom_userdatahandler_handle": [ - "dom_void dom_userdatahandler_handle(short operation, string key, domobject data, node src, node dst);", + "dom_void dom_userdatahandler_handle(short operation, string key, domobject data, node src, node dst)", "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-handleUserDataEvent Since:" ], "dom_xpath_evaluate": [ - "mixed dom_xpath_evaluate(string expr [,DOMNode context]); */", - "PHP_FUNCTION(dom_xpath_evaluate) { php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_EVALUATE); } /* }}} end dom_xpath_evaluate" + "mixed dom_xpath_evaluate(string expr [,DOMNode context])", + "" ], "dom_xpath_query": [ - "DOMNodeList dom_xpath_query(string expr [,DOMNode context]); */", - "PHP_FUNCTION(dom_xpath_query) { php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_QUERY); } /* }}} end dom_xpath_query" + "DOMNodeList dom_xpath_query(string expr [,DOMNode context])", + "" ], "dom_xpath_register_ns": [ - "boolean dom_xpath_register_ns(string prefix, string uri); */", - "PHP_FUNCTION(dom_xpath_register_ns) { zval *id; xmlXPathContextPtr ctxp; int prefix_len, ns_uri_len; dom_xpath_object *intern; unsigned char *prefix, *ns_uri; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"Oss\", &id, dom_xpath_class_entry, &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) { return; } intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); ctxp = (xmlXPathContextPtr) intern->ptr; if (ctxp == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid XPath Context\"); RETURN_FALSE; } if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) { RETURN_FALSE } RETURN_TRUE; } /* }}}" + "bool dom_xpath_register_ns(string prefix, string uri)", + "" ], "dom_xpath_register_php_functions": [ - "void dom_xpath_register_php_functions() */", - "PHP_FUNCTION(dom_xpath_register_php_functions) { zval *id; dom_xpath_object *intern; zval *array_value, **entry, *new_string; int name_len = 0; char *name; DOM_GET_THIS(id); if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"a\", &array_value) == SUCCESS) { intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value)); while (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) { SEPARATE_ZVAL(entry); convert_to_string_ex(entry); MAKE_STD_ZVAL(new_string); ZVAL_LONG(new_string,1); zend_hash_update(intern->registered_phpfunctions, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, &new_string, sizeof(zval*), NULL); zend_hash_move_forward(Z_ARRVAL_P(array_value)); } intern->registerPhpFunctions = 2; RETURN_TRUE; } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &name, &name_len) == SUCCESS) { intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); MAKE_STD_ZVAL(new_string); ZVAL_LONG(new_string,1); zend_hash_update(intern->registered_phpfunctions, name, name_len + 1, &new_string, sizeof(zval*), NULL); intern->registerPhpFunctions = 2; } else { intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); intern->registerPhpFunctions = 1; } } /* }}} end dom_xpath_register_php_functions" + "void dom_xpath_register_php_functions()", + "" ], "each": [ "array each(array arr)", @@ -3754,7 +3949,7 @@ var functionMap = { "Output one or more strings" ], "empty": [ - "bool empty( mixed var )", + "bool empty(mixed var)", "Determine whether a variable is empty" ], "enchant_broker_describe": [ @@ -3766,7 +3961,7 @@ var functionMap = { "Whether a dictionary exists or not. Using non-empty tag" ], "enchant_broker_free": [ - "boolean enchant_broker_free(resource broker)", + "bool enchant_broker_free(resource broker)", "Destroys the broker object and its dictionnaries" ], "enchant_broker_free_dict": [ @@ -4062,7 +4257,7 @@ var functionMap = { "Returns the next lowest integer value from the number" ], "flush": [ - "void flush(void)", + "void flush()", "Flush the output buffer" ], "fmod": [ @@ -4270,7 +4465,7 @@ var functionMap = { "Get an array of the arguments that were passed to the function" ], "func_num_args": [ - "int func_num_args(void)", + "int func_num_args()", "Get the number of arguments that were passed to the function" ], "function ": ["", ""], @@ -4284,19 +4479,19 @@ var functionMap = { "Binary-safe file write" ], "gc_collect_cycles": [ - "int gc_collect_cycles(void)", + "int gc_collect_cycles()", "Forces collection of any existing garbage cycles. Returns number of freed zvals" ], "gc_disable": [ - "void gc_disable(void)", + "void gc_disable()", "Deactivates the circular reference collector" ], "gc_enable": [ - "void gc_enable(void)", + "void gc_enable()", "Activates the circular reference collector" ], "gc_enabled": [ - "void gc_enabled(void)", + "void gc_enabled()", "Returns status of the circular reference collector" ], "gd_info": [ @@ -4305,7 +4500,7 @@ var functionMap = { ], "getKeywords": [ "static array getKeywords(string $locale) {", - "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array (doh!) * }}}" + "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array * }}}" ], "get_browser": [ "mixed get_browser([string browser_name [, bool return_array]])", @@ -4332,7 +4527,7 @@ var functionMap = { "Returns an array of default properties of the class." ], "get_current_user": [ - "string get_current_user(void)", + "string get_current_user()", "Get the name of the owner of the current PHP script" ], "get_declared_classes": [ @@ -4348,11 +4543,11 @@ var functionMap = { "Return an array containing the names and values of all defined constants" ], "get_defined_functions": [ - "array get_defined_functions(void)", + "array get_defined_functions()", "Returns an array of all defined functions" ], "get_defined_vars": [ - "array get_defined_vars(void)", + "array get_defined_vars()", "Returns an associative array of names and values of all currently defined variable names (variables in the current scope)" ], "get_display_language": [ @@ -4388,7 +4583,7 @@ var functionMap = { "Get the current include_path configuration option" ], "get_included_files": [ - "array get_included_files(void)", + "array get_included_files()", "Returns an array with the file names that were include_once()'d" ], "get_loaded_extensions": [ @@ -4396,11 +4591,11 @@ var functionMap = { "Return an array containing names of loaded extensions" ], "get_magic_quotes_gpc": [ - "int get_magic_quotes_gpc(void)", + "int get_magic_quotes_gpc()", "Get the current active configuration setting of magic_quotes_gpc" ], "get_magic_quotes_runtime": [ - "int get_magic_quotes_runtime(void)", + "int get_magic_quotes_runtime()", "Get the current active configuration setting of magic_quotes_runtime" ], "get_meta_tags": [ @@ -4420,11 +4615,11 @@ var functionMap = { "Get the resource type name for a given resource" ], "getallheaders": [ - "array getallheaders(void)", + "array getallheaders()", "" ], "getcwd": [ - "mixed getcwd(void)", + "mixed getcwd()", "Gets the current directory" ], "getdate": [ @@ -4456,23 +4651,23 @@ var functionMap = { "Get the size of an image as 4-element array" ], "getlastmod": [ - "int getlastmod(void)", + "int getlastmod()", "Get time of last page modification" ], "getmygid": [ - "int getmygid(void)", + "int getmygid()", "Get PHP script owner's GID" ], "getmyinode": [ - "int getmyinode(void)", + "int getmyinode()", "Get the inode of the current script being parsed" ], "getmypid": [ - "int getmypid(void)", + "int getmypid()", "Get current process ID" ], "getmyuid": [ - "int getmyuid(void)", + "int getmyuid()", "Get PHP script owner's UID" ], "getopt": [ @@ -4488,7 +4683,7 @@ var functionMap = { "Returns protocol name associated with protocol number proto" ], "getrandmax": [ - "int getrandmax(void)", + "int getrandmax()", "Returns the maximum value a random number can have" ], "getrusage": [ @@ -4764,7 +4959,7 @@ var functionMap = { "Generate a hash of a given input string Returns lowercase hexits by default" ], "hash_algos": [ - "array hash_algos(void)", + "array hash_algos()", "Return a list of registered hashing algorithms" ], "hash_copy": [ @@ -4812,7 +5007,7 @@ var functionMap = { "Removes an HTTP header previously set using header()" ], "headers_list": [ - "array headers_list(void)", + "array headers_list()", "Return list of headers to be sent / already sent" ], "headers_sent": [ @@ -4940,11 +5135,11 @@ var functionMap = { "Drop an InterBase database" ], "ibase_errcode": [ - "int ibase_errcode(void)", + "int ibase_errcode()", "Return error code" ], "ibase_errmsg": [ - "string ibase_errmsg(void)", + "string ibase_errmsg()", "Return error message" ], "ibase_execute": [ @@ -5413,7 +5608,7 @@ var functionMap = { ], "imagepsextendfont": [ "bool imagepsextendfont(resource font_index, float extend)", - "Extend or or condense (if extend < 1) a font" + "Extend or or condense if (extend < 1) a font" ], "imagepsfreefont": [ "bool imagepsfreefont(resource font_index)", @@ -5492,7 +5687,7 @@ var functionMap = { "Write text to the image using a TrueType font" ], "imagetypes": [ - "int imagetypes(void)", + "int imagetypes()", "Return the types of images supported in a bitfield - 1=GIF, 2=JPEG, 4=PNG, 8=WBMP, 16=XPM" ], "imagewbmp": [ @@ -5508,7 +5703,7 @@ var functionMap = { "Convert an 8-bit string to a quoted-printable string" ], "imap_alerts": [ - "array imap_alerts(void)", + "array imap_alerts()", "Returns an array of all IMAP alerts that have been generated since the last page load or since the last imap_alerts() call, whichever came last. The alert stack is cleared after imap_alerts() is called." ], "imap_append": [ @@ -5556,7 +5751,7 @@ var functionMap = { "Delete a mailbox" ], "imap_errors": [ - "array imap_errors(void)", + "array imap_errors()", "Returns an array of all IMAP errors generated since the last page load, or since the last imap_errors() call, whichever came last. The error stack is cleared after imap_errors() is called." ], "imap_expunge": [ @@ -5612,7 +5807,7 @@ var functionMap = { "Returns headers for all messages in a mailbox" ], "imap_last_error": [ - "string imap_last_error(void)", + "string imap_last_error()", "Returns the last error that was generated by an IMAP function. The error stack is NOT cleared after this call." ], "imap_list": [ @@ -5863,6 +6058,10 @@ var functionMap = { "bool is_callable(mixed var [, bool syntax_only [, string callable_name]])", "Returns true if var is callable." ], + "is_countable": [ + "bool is_countable(mixed var)", + "Returns true if var is countable, false otherwise" + ], "is_dir": [ "bool is_dir(string filename)", "Returns true if file is directory" @@ -5944,15 +6143,15 @@ var functionMap = { "Determine whether a variable is set" ], "iterator_apply": [ - "int iterator_apply(Traversable it, mixed function [, mixed params])", + "int iterator_apply(Traversable iterator, callable function [, array args = null)", "Calls a function for every element in an iterator" ], "iterator_count": [ - "int iterator_count(Traversable it)", + "int iterator_count(Traversable iterator)", "Count the elements in an iterator" ], "iterator_to_array": [ - "array iterator_to_array(Traversable it [, bool use_keys = true])", + "array iterator_to_array(Traversable iterator [, bool use_keys = true])", "Copy the iterator into an array" ], "jddayofweek": [ @@ -5988,11 +6187,11 @@ var functionMap = { "Converts a jewish calendar date to a julian day count" ], "join": [ - "string join(array src, string glue)", - "An alias for implode" + "string join([string glue,] array pieces)", + "Returns a string containing a string representation of all the arrayelements in the same order, with the glue string between each element" ], "jpeg2wbmp": [ - "bool jpeg2wbmp (string f_org, string f_dest, int d_height, int d_width, int threshold)", + "bool jpeg2wbmp(string f_org, string f_dest, int d_height, int d_width, int threshold)", "Convert JPEG image to WBMP image" ], "json_decode": [ @@ -6160,7 +6359,7 @@ var functionMap = { "Read an entry" ], "ldap_rename": [ - "bool ldap_rename(resource link, string dn, string newrdn, string newparent, bool deleteoldrdn);", + "bool ldap_rename(resource link, string dn, string newrdn, string newparent, bool deleteoldrdn)", "Modify the name of an entry" ], "ldap_sasl_bind": [ @@ -6208,7 +6407,7 @@ var functionMap = { "Clear last error from libxml" ], "libxml_disable_entity_loader": [ - "bool libxml_disable_entity_loader([boolean disable])", + "bool libxml_disable_entity_loader([bool disable])", "Disable/Enable ability to load external entities" ], "libxml_get_errors": [ @@ -6224,7 +6423,7 @@ var functionMap = { "Set the streams context for the next libxml document load or write" ], "libxml_use_internal_errors": [ - "bool libxml_use_internal_errors([boolean use_errors])", + "bool libxml_use_internal_errors([bool use_errors])", "Disable libxml errors and allow user to fetch error information as needed" ], "link": [ @@ -6236,11 +6435,11 @@ var functionMap = { "Returns the st_dev field of the UNIX C stat structure describing the link" ], "litespeed_request_headers": [ - "array litespeed_request_headers(void)", + "array litespeed_request_headers()", "Fetch all HTTP request headers" ], "litespeed_response_headers": [ - "array litespeed_response_headers(void)", + "array litespeed_response_headers()", "Fetch all HTTP response headers" ], "locale_accept_from_http": [ @@ -6252,7 +6451,7 @@ var functionMap = { "* @param string $locale The locale string to canonicalize" ], "locale_filter_matches": [ - "boolean locale_filter_matches(string $langtag, string $locale[, bool $canonicalize])", + "bool locale_filter_matches(string $langtag, string $locale[, bool $canonicalize])", "* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm" ], "locale_get_all_variants": [ @@ -6265,7 +6464,7 @@ var functionMap = { ], "locale_get_keywords": [ "static array locale_get_keywords(string $locale) {", - "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array (doh!)" + "* return an associative array containing keyword-value * pairs for this locale. The keys are keys to the array" ], "locale_get_primary_language": [ "static string locale_get_primary_language($locale)", @@ -6288,7 +6487,7 @@ var functionMap = { "Set default locale" ], "localeconv": [ - "array localeconv(void)", + "array localeconv()", "Returns numeric formatting information based on the current locale" ], "localtime": [ @@ -6392,11 +6591,11 @@ var functionMap = { "Regular expression search for multibyte string" ], "mb_ereg_search_getpos": [ - "int mb_ereg_search_getpos(void)", + "int mb_ereg_search_getpos()", "Get search start position" ], "mb_ereg_search_getregs": [ - "array mb_ereg_search_getregs(void)", + "array mb_ereg_search_getregs()", "Get matched substring of the last time" ], "mb_ereg_search_init": [ @@ -6716,7 +6915,7 @@ var functionMap = { "Hash data with hash" ], "mhash_count": [ - "int mhash_count(void)", + "int mhash_count()", "Gets the number of available hashes" ], "mhash_get_block_size": [ @@ -6892,7 +7091,7 @@ var functionMap = { "Free a MS-SQL statement index" ], "mssql_get_last_message": [ - "string mssql_get_last_message(void)", + "string mssql_get_last_message()", "Gets the last message from the MS-SQL server" ], "mssql_guid_string": [ @@ -6944,7 +7143,7 @@ var functionMap = { "Select a MS-SQL database" ], "mt_getrandmax": [ - "int mt_getrandmax(void)", + "int mt_getrandmax()", "Returns the maximum value a random number from Mersenne Twister can have" ], "mt_rand": [ @@ -7052,7 +7251,7 @@ var functionMap = { "Free result memory" ], "mysql_get_client_info": [ - "string mysql_get_client_info(void)", + "string mysql_get_client_info()", "Returns a string that represents the client library version" ], "mysql_get_host_info": [ @@ -7148,7 +7347,7 @@ var functionMap = { "Turn auto commit on or of" ], "mysqli_cache_stats": [ - "array mysqli_cache_stats(void)", + "array mysqli_cache_stats()", "Returns statistics about the zval cache" ], "mysqli_change_user": [ @@ -7172,11 +7371,11 @@ var functionMap = { "Open a connection to a mysql server" ], "mysqli_connect_errno": [ - "int mysqli_connect_errno(void)", + "int mysqli_connect_errno()", "Returns the numerical value of the error message from last connect command" ], "mysqli_connect_error": [ - "string mysqli_connect_error(void)", + "string mysqli_connect_error()", "Returns the text of the error message from previous MySQL operation" ], "mysqli_data_seek": [ @@ -7192,7 +7391,7 @@ var functionMap = { "" ], "mysqli_embedded_server_end": [ - "void mysqli_embedded_server_end(void)", + "void mysqli_embedded_server_end()", "" ], "mysqli_embedded_server_start": [ @@ -7208,39 +7407,39 @@ var functionMap = { "Returns the text of the error message from previous MySQL operation" ], "mysqli_fetch_all": [ - "mixed mysqli_fetch_all (object result [,int resulttype])", + "mixed mysqli_fetch_all(object result [,int resulttype])", "Fetches all result rows as an associative array, a numeric array, or both" ], "mysqli_fetch_array": [ - "mixed mysqli_fetch_array (object result [,int resulttype])", + "mixed mysqli_fetch_array(object result [,int resulttype])", "Fetch a result row as an associative array, a numeric array, or both" ], "mysqli_fetch_assoc": [ - "mixed mysqli_fetch_assoc (object result)", + "mixed mysqli_fetch_assoc(object result)", "Fetch a result row as an associative array" ], "mysqli_fetch_field": [ - "mixed mysqli_fetch_field (object result)", + "mixed mysqli_fetch_field(object result)", "Get column information from a result and return as an object" ], "mysqli_fetch_field_direct": [ - "mixed mysqli_fetch_field_direct (object result, int offset)", + "mixed mysqli_fetch_field_direct(object result, int offset)", "Fetch meta-data for a single field" ], "mysqli_fetch_fields": [ - "mixed mysqli_fetch_fields (object result)", + "mixed mysqli_fetch_fields(object result)", "Return array of objects containing field meta-data" ], "mysqli_fetch_lengths": [ - "mixed mysqli_fetch_lengths (object result)", + "mixed mysqli_fetch_lengths(object result)", "Get the length of each output in a result" ], "mysqli_fetch_object": [ - "mixed mysqli_fetch_object (object result [, string class_name [, NULL|array ctor_params]])", + "mixed mysqli_fetch_object(object result [, string class_name [, NULL|array ctor_params]])", "Fetch a result row as an object" ], "mysqli_fetch_row": [ - "array mysqli_fetch_row (object result)", + "array mysqli_fetch_row(object result)", "Get a result row as an enumerated array" ], "mysqli_field_count": [ @@ -7264,23 +7463,23 @@ var functionMap = { "returns a character set object" ], "mysqli_get_client_info": [ - "string mysqli_get_client_info(void)", + "string mysqli_get_client_info()", "Get MySQL client info" ], "mysqli_get_client_stats": [ - "array mysqli_get_client_stats(void)", + "array mysqli_get_client_stats()", "Returns statistics about the zval cache" ], "mysqli_get_client_version": [ - "int mysqli_get_client_version(void)", + "int mysqli_get_client_version()", "Get MySQL client info" ], "mysqli_get_connection_stats": [ - "array mysqli_get_connection_stats(void)", + "array mysqli_get_connection_stats()", "Returns statistics about the zval cache" ], "mysqli_get_host_info": [ - "string mysqli_get_host_info (object link)", + "string mysqli_get_host_info(object link)", "Get MySQL host info" ], "mysqli_get_proto_info": [ @@ -7296,15 +7495,15 @@ var functionMap = { "Return the MySQL version for the server referenced by the given link" ], "mysqli_get_warnings": [ - "object mysqli_get_warnings(object link) */", - "PHP_FUNCTION(mysqli_get_warnings) { MY_MYSQL *mysql; zval *mysql_link; MYSQLI_RESOURCE *mysqli_resource; MYSQLI_WARNING *w; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"O\", &mysql_link, mysqli_link_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, \"mysqli_link\", MYSQLI_STATUS_VALID); if (mysql_warning_count(mysql->mysql)) { w = php_get_warnings(mysql->mysql TSRMLS_CC); } else { RETURN_FALSE; } mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = mysqli_resource->info = (void *)w; mysqli_resource->status = MYSQLI_STATUS_VALID; MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); } /* }}}" + "object mysqli_get_warnings(object link)", + "" ], "mysqli_info": [ "string mysqli_info(object link)", "Get information about the most recent query" ], "mysqli_init": [ - "resource mysqli_init(void)", + "resource mysqli_init()", "Initialize mysqli and return a resource for use with mysql_real_connect" ], "mysqli_insert_id": [ @@ -7356,8 +7555,8 @@ var functionMap = { "Prepare a SQL statement for execution" ], "mysqli_query": [ - "mixed mysqli_query(object link, string query [,int resultmode]) */", - "PHP_FUNCTION(mysqli_query) { MY_MYSQL *mysql; zval *mysql_link; MYSQLI_RESOURCE *mysqli_resource; MYSQL_RES *result; char *query = NULL; unsigned int query_len; unsigned long resultmode = MYSQLI_STORE_RESULT; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"Os|l\", &mysql_link, mysqli_link_class_entry, &query, &query_len, &resultmode) == FAILURE) { return; } if (!query_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, \"Empty query\"); RETURN_FALSE; } if ((resultmode & ~MYSQLI_ASYNC) != MYSQLI_USE_RESULT && (resultmode & ~MYSQLI_ASYNC) != MYSQLI_STORE_RESULT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid value for resultmode\"); RETURN_FALSE; } MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, \"mysqli_link\", MYSQLI_STATUS_VALID); MYSQLI_DISABLE_MQ; #ifdef MYSQLI_USE_MYSQLND if (resultmode & MYSQLI_ASYNC) { if (mysqli_async_query(mysql->mysql, query, query_len)) { MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } mysql->async_result_fetch_type = resultmode & ~MYSQLI_ASYNC; RETURN_TRUE; } #endif if (mysql_real_query(mysql->mysql, query, query_len)) { MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } if (!mysql_field_count(mysql->mysql)) { /* no result set - not a SELECT" + "mixed mysqli_query(object link, string query [,int resultmode])", + "" ], "mysqli_real_connect": [ "bool mysqli_real_connect(object link [,string hostname [,string username [,string passwd [,string dbname [,int port [,string socket [,int flags]]]]]]])", @@ -7472,8 +7671,8 @@ var functionMap = { "Buffer result set on client" ], "mysqli_stmt_get_warnings": [ - "object mysqli_stmt_get_warnings(object link) */", - "PHP_FUNCTION(mysqli_stmt_get_warnings) { MY_STMT *stmt; zval *stmt_link; MYSQLI_RESOURCE *mysqli_resource; MYSQLI_WARNING *w; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"O\", &stmt_link, mysqli_stmt_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE(stmt, MY_STMT*, &stmt_link, \"mysqli_stmt\", MYSQLI_STATUS_VALID); if (mysqli_stmt_warning_count(stmt->stmt)) { w = php_get_warnings(mysqli_stmt_get_connection(stmt->stmt) TSRMLS_CC); } else { RETURN_FALSE; } mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = mysqli_resource->info = (void *)w; mysqli_resource->status = MYSQLI_STATUS_VALID; MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); } /* }}}" + "object mysqli_stmt_get_warnings(object link)", + "" ], "mysqli_stmt_init": [ "mixed mysqli_stmt_init(object link)", @@ -7528,7 +7727,7 @@ var functionMap = { "Return the current thread ID" ], "mysqli_thread_safe": [ - "bool mysqli_thread_safe(void)", + "bool mysqli_thread_safe()", "Return whether thread safety is given or not" ], "mysqli_use_result": [ @@ -7536,7 +7735,7 @@ var functionMap = { "Directly retrieve query results - do not buffer results on client side" ], "mysqli_warning_count": [ - "int mysqli_warning_count (object link)", + "int mysqli_warning_count(object link)", "Return number of warnings from the last query for the given link" ], "natcasesort": [ @@ -7572,11 +7771,11 @@ var functionMap = { "* Normalize a string." ], "nsapi_request_headers": [ - "array nsapi_request_headers(void)", + "array nsapi_request_headers()", "Get all headers from the request" ], "nsapi_response_headers": [ - "array nsapi_response_headers(void)", + "array nsapi_response_headers()", "Get all headers from the response" ], "nsapi_virtual": [ @@ -7656,39 +7855,39 @@ var functionMap = { "* Get formatter attribute value." ], "ob_clean": [ - "bool ob_clean(void)", + "bool ob_clean()", "Clean (delete) the current output buffer" ], "ob_end_clean": [ - "bool ob_end_clean(void)", + "bool ob_end_clean()", "Clean the output buffer, and delete current output buffer" ], "ob_end_flush": [ - "bool ob_end_flush(void)", + "bool ob_end_flush()", "Flush (send) the output buffer, and delete current output buffer" ], "ob_flush": [ - "bool ob_flush(void)", + "bool ob_flush()", "Flush (send) contents of the output buffer. The last buffer content is sent to next buffer" ], "ob_get_clean": [ - "bool ob_get_clean(void)", + "bool ob_get_clean()", "Get current buffer contents and delete current output buffer" ], "ob_get_contents": [ - "string ob_get_contents(void)", + "string ob_get_contents()", "Return the contents of the output buffer" ], "ob_get_flush": [ - "bool ob_get_flush(void)", + "bool ob_get_flush()", "Get current buffer contents, flush (send) the output buffer, and delete current output buffer" ], "ob_get_length": [ - "int ob_get_length(void)", + "int ob_get_length()", "Return the length of the output buffer" ], "ob_get_level": [ - "int ob_get_level(void)", + "int ob_get_level()", "Return the nesting level of the output buffer" ], "ob_get_status": [ @@ -8008,7 +8207,7 @@ var functionMap = { "Returns current state of buffering for a LOB" ], "ocisetbufferinglob": [ - "bool ocisetbufferinglob( boolean flag )", + "bool ocisetbufferinglob( bool flag )", "Enables/disables buffering for a LOB" ], "octdec": [ @@ -8028,7 +8227,7 @@ var functionMap = { "Close an ODBC connection" ], "odbc_close_all": [ - "void odbc_close_all(void)", + "void odbc_close_all()", "Close all ODBC connections" ], "odbc_columnprivileges": [ @@ -8236,7 +8435,7 @@ var functionMap = { "Encrypts given data with given method and key, returns raw or base64 encoded string" ], "openssl_error_string": [ - "mixed openssl_error_string(void)", + "mixed openssl_error_string()", "Returns a description of the last error, and alters the index of the error messages. Returns false when the are no more messages" ], "openssl_get_cipher_methods": [ @@ -8376,7 +8575,7 @@ var functionMap = { "Add URL rewriter values" ], "output_reset_rewrite_vars": [ - "bool output_reset_rewrite_vars(void)", + "bool output_reset_rewrite_vars()", "Reset(clear) URL rewriter values" ], "pack": [ @@ -8428,7 +8627,7 @@ var functionMap = { "Executes specified program in current process space as defined by exec(2)" ], "pcntl_fork": [ - "int pcntl_fork(void)", + "int pcntl_fork()", "Forks the currently running process following the same behavior as the UNIX fork() system call" ], "pcntl_getpriority": [ @@ -8545,7 +8744,7 @@ var functionMap = { ], "pg_delete": [ "mixed pg_delete(resource db, string table, array ids[, int options])", - "Delete records has ids (id=>value)" + "Delete records has ids (id => value)" ], "pg_end_copy": [ "bool pg_end_copy([resource connection])", @@ -8645,7 +8844,7 @@ var functionMap = { ], "pg_insert": [ "mixed pg_insert(resource db, string table, array values[, int options])", - "Insert values (filed=>value) to table" + "Insert values (filed => value) to table" ], "pg_last_error": [ "string pg_last_error([resource connection])", @@ -8769,7 +8968,7 @@ var functionMap = { ], "pg_select": [ "mixed pg_select(resource db, string table, array ids[, int options])", - "Select records that has ids (id=>value)" + "Select records that has ids (id => value)" ], "pg_send_execute": [ "bool pg_send_execute(resource connection, string stmtname, array params)", @@ -8817,34 +9016,34 @@ var functionMap = { ], "pg_update": [ "mixed pg_update(resource db, string table, array fields, array ids[, int options])", - "Update table using values (field=>value) and ids (id=>value)" + "Update table using values (field => value) and ids (id => value)" ], "pg_version": [ "array pg_version([resource connection])", "Returns an array with client, protocol and server version (when available)" ], "php_egg_logo_guid": [ - "string php_egg_logo_guid(void)", + "string php_egg_logo_guid()", "Return the special ID used to request the PHP logo in phpinfo screens" ], "php_ini_loaded_file": [ - "string php_ini_loaded_file(void)", + "string php_ini_loaded_file()", "Return the actual loaded ini filename" ], "php_ini_scanned_files": [ - "string php_ini_scanned_files(void)", + "string php_ini_scanned_files()", "Return comma-separated string of .ini files parsed from the additional ini dir" ], "php_logo_guid": [ - "string php_logo_guid(void)", + "string php_logo_guid()", "Return the special ID used to request the PHP logo in phpinfo screens" ], "php_real_logo_guid": [ - "string php_real_logo_guid(void)", + "string php_real_logo_guid()", "Return the special ID used to request the PHP logo in phpinfo screens" ], "php_sapi_name": [ - "string php_sapi_name(void)", + "string php_sapi_name()", "Return the current SAPI module name" ], "php_snmpv3": [ @@ -8856,7 +9055,7 @@ var functionMap = { "Return source with stripped comments and whitespace" ], "php_uname": [ - "string php_uname(void)", + "string php_uname()", "Return information about the system PHP was built on" ], "phpcredits": [ @@ -8872,11 +9071,11 @@ var functionMap = { "Return the current PHP version" ], "pi": [ - "float pi(void)", + "float pi()", "Returns an approximation of pi" ], "png2wbmp": [ - "bool png2wbmp (string f_org, string f_dest, int d_height, int d_width, int threshold)", + "bool png2wbmp(string f_org, string f_dest, int d_height, int d_width, int threshold)", "Convert PNG image to WBMP image" ], "popen": [ @@ -8888,27 +9087,27 @@ var functionMap = { "Determine accessibility of a file (POSIX.1 5.6.3)" ], "posix_ctermid": [ - "string posix_ctermid(void)", + "string posix_ctermid()", "Generate terminal path name (POSIX.1, 4.7.1)" ], "posix_get_last_error": [ - "int posix_get_last_error(void)", + "int posix_get_last_error()", "Retrieve the error number set by the last posix function which failed." ], "posix_getcwd": [ - "string posix_getcwd(void)", + "string posix_getcwd()", "Get working directory pathname (POSIX.1, 5.2.2)" ], "posix_getegid": [ - "int posix_getegid(void)", + "int posix_getegid()", "Get the current effective group id (POSIX.1, 4.2.1)" ], "posix_geteuid": [ - "int posix_geteuid(void)", + "int posix_geteuid()", "Get the current effective user id (POSIX.1, 4.2.1)" ], "posix_getgid": [ - "int posix_getgid(void)", + "int posix_getgid()", "Get the current group id (POSIX.1, 4.2.1)" ], "posix_getgrgid": [ @@ -8920,27 +9119,27 @@ var functionMap = { "Group database access (POSIX.1, 9.2.1)" ], "posix_getgroups": [ - "array posix_getgroups(void)", + "array posix_getgroups()", "Get supplementary group id's (POSIX.1, 4.2.3)" ], "posix_getlogin": [ - "string posix_getlogin(void)", + "string posix_getlogin()", "Get user name (POSIX.1, 4.2.4)" ], "posix_getpgid": [ - "int posix_getpgid(void)", + "int posix_getpgid()", "Get the process group id of the specified process (This is not a POSIX function, but a SVR4ism, so we compile conditionally)" ], "posix_getpgrp": [ - "int posix_getpgrp(void)", + "int posix_getpgrp()", "Get current process group id (POSIX.1, 4.3.1)" ], "posix_getpid": [ - "int posix_getpid(void)", + "int posix_getpid()", "Get the current process id (POSIX.1, 4.1.1)" ], "posix_getppid": [ - "int posix_getppid(void)", + "int posix_getppid()", "Get the parent process id (POSIX.1, 4.1.1)" ], "posix_getpwnam": [ @@ -8952,15 +9151,15 @@ var functionMap = { "User database access (POSIX.1, 9.2.2)" ], "posix_getrlimit": [ - "array posix_getrlimit(void)", + "array posix_getrlimit()", "Get system resource consumption limits (This is not a POSIX function, but a BSDism and a SVR4ism. We compile conditionally)" ], "posix_getsid": [ - "int posix_getsid(void)", + "int posix_getsid()", "Get process group id of session leader (This is not a POSIX function, but a SVR4ism, so be compile conditionally)" ], "posix_getuid": [ - "int posix_getuid(void)", + "int posix_getuid()", "Get the current user id (POSIX.1, 4.2.1)" ], "posix_initgroups": [ @@ -9000,7 +9199,7 @@ var functionMap = { "Set process group id for job control (POSIX.1, 4.3.3)" ], "posix_setsid": [ - "int posix_setsid(void)", + "int posix_setsid()", "Create session and set process group id (POSIX.1, 4.3.2)" ], "posix_setuid": [ @@ -9012,7 +9211,7 @@ var functionMap = { "Retrieve the system error message associated with the given errno." ], "posix_times": [ - "array posix_times(void)", + "array posix_times()", "Get process times (POSIX.1, 4.5.2)" ], "posix_ttyname": [ @@ -9020,7 +9219,7 @@ var functionMap = { "Determine terminal device name (POSIX.1, 4.7.2)" ], "posix_uname": [ - "array posix_uname(void)", + "array posix_uname()", "Get system name (POSIX.1, 4.4.1)" ], "pow": [ @@ -9188,8 +9387,8 @@ var functionMap = { "Convert a quoted-printable string to an 8 bit string" ], "quoted_printable_encode": [ - "string quoted_printable_encode(string str) */", - "PHP_FUNCTION(quoted_printable_encode) { char *str, *new_str; int str_len; size_t new_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &str, &str_len) != SUCCESS) { return; } if (!str_len) { RETURN_EMPTY_STRING(); } new_str = (char *)php_quot_print_encode((unsigned char *)str, (size_t)str_len, &new_str_len); RETURN_STRINGL(new_str, new_str_len, 0); } /* }}}" + "string quoted_printable_encode(string str)", + "" ], "quotemeta": [ "string quotemeta(string str)", @@ -9248,7 +9447,7 @@ var functionMap = { "Informs the readline callback interface that a character is ready for input" ], "readline_clear_history": [ - "bool readline_clear_history(void)", + "bool readline_clear_history()", "Clears the history" ], "readline_completion_function": [ @@ -9260,11 +9459,11 @@ var functionMap = { "Gets/sets various internal readline variables." ], "readline_list_history": [ - "array readline_list_history(void)", + "array readline_list_history()", "Lists the history" ], "readline_on_new_line": [ - "void readline_on_new_line(void)", + "void readline_on_new_line()", "Inform readline that the cursor has moved to a new line" ], "readline_read_history": [ @@ -9272,7 +9471,7 @@ var functionMap = { "Reads the history" ], "readline_redisplay": [ - "void readline_redisplay(void)", + "void readline_redisplay()", "Ask readline to redraw the display" ], "readline_write_history": [ @@ -9328,11 +9527,11 @@ var functionMap = { "Set array argument's internal pointer to the first element and return it" ], "restore_error_handler": [ - "void restore_error_handler(void)", + "void restore_error_handler()", "Restores the previously defined error handler function" ], "restore_exception_handler": [ - "void restore_exception_handler(void)", + "void restore_exception_handler()", "Restores the previously defined exception handler function" ], "restore_include_path": [ @@ -9400,15 +9599,15 @@ var functionMap = { "Deserializes data and reinitializes the variables" ], "session_destroy": [ - "bool session_destroy(void)", + "bool session_destroy()", "Destroy the current session and all data associated with it" ], "session_encode": [ - "string session_encode(void)", + "string session_encode()", "Serializes the current setup and returns the serialized representation" ], "session_get_cookie_params": [ - "array session_get_cookie_params(void)", + "array session_get_cookie_params()", "Return the session cookie parameters" ], "session_id": [ @@ -9448,7 +9647,7 @@ var functionMap = { "Sets user-level functions" ], "session_start": [ - "bool session_start(void)", + "bool session_start()", "Begin session - reinitializes freezed variables, registers browsers etc" ], "session_unregister": [ @@ -9456,11 +9655,11 @@ var functionMap = { "Removes varname from the list of variables which are freezed at the session end" ], "session_unset": [ - "void session_unset(void)", + "void session_unset()", "Unset all registered variables" ], "session_write_close": [ - "void session_write_close(void)", + "void session_write_close()", "Write session data and end session" ], "set_error_handler": [ @@ -9540,27 +9739,27 @@ var functionMap = { "Removes variable from shared memory" ], "shmop_close": [ - "void shmop_close (int shmid)", + "void shmop_close(int shmid)", "closes a shared memory segment" ], "shmop_delete": [ - "bool shmop_delete (int shmid)", + "bool shmop_delete(int shmid)", "mark segment for deletion" ], "shmop_open": [ - "int shmop_open (int key, string flags, int mode, int size)", + "int shmop_open(int key, string flags, int mode, int size)", "gets and attaches a shared memory segment" ], "shmop_read": [ - "string shmop_read (int shmid, int start, int count)", + "string shmop_read(int shmid, int start, int count)", "reads from a shm segment" ], "shmop_size": [ - "int shmop_size (int shmid)", + "int shmop_size(int shmid)", "returns the shm size" ], "shmop_write": [ - "int shmop_write (int shmid, string data, int offset)", + "int shmop_write(int shmid, string data, int offset)", "writes to a shared memory segment" ], "shuffle": [ @@ -9672,7 +9871,7 @@ var functionMap = { "Fetch the value of a SNMP object" ], "snmp_get_quick_print": [ - "bool snmp_get_quick_print(void)", + "bool snmp_get_quick_print()", "Return the current status of quick_print" ], "snmp_get_valueretrieval": [ @@ -9920,7 +10119,7 @@ var functionMap = { "Escapes a string for use as a query parameter." ], "sqlite_exec": [ - "boolean sqlite_exec(string query, resource db[, string &error_message])", + "bool sqlite_exec(string query, resource db[, string &error_message])", "Executes a result-less query against a given database" ], "sqlite_factory": [ @@ -10172,7 +10371,7 @@ var functionMap = { "Reads all remaining bytes (or up to maxlen bytes) from a stream and returns them as a string." ], "stream_get_filters": [ - "array stream_get_filters(void)", + "array stream_get_filters()", "Returns a list of registered filters" ], "stream_get_line": [ @@ -10436,7 +10635,7 @@ var functionMap = { "Free result memory" ], "sybase_get_last_message": [ - "string sybase_get_last_message(void)", + "string sybase_get_last_message()", "Returns the last message from server (over min_message_severity)" ], "sybase_min_client_severity": [ @@ -10520,7 +10719,7 @@ var functionMap = { "Returns the Number of Tidy accessibility warnings encountered for specified document." ], "tidy_clean_repair": [ - "boolean tidy_clean_repair()", + "bool tidy_clean_repair()", "Execute configured cleanup and repair operations on parsed markup" ], "tidy_config_count": [ @@ -10528,7 +10727,7 @@ var functionMap = { "Returns the Number of Tidy configuration errors encountered for specified document." ], "tidy_diagnose": [ - "boolean tidy_diagnose()", + "bool tidy_diagnose()", "Run configured diagnostics on parsed and repaired markup." ], "tidy_error_count": [ @@ -10544,7 +10743,7 @@ var functionMap = { "Get current Tidy configuarion" ], "tidy_get_error_buffer": [ - "string tidy_get_error_buffer([boolean detailed])", + "string tidy_get_error_buffer([bool detailed])", "Return warnings and errors which occured parsing the specified document" ], "tidy_get_head": [ @@ -10584,15 +10783,15 @@ var functionMap = { "Returns the value of the specified configuration option for the tidy document." ], "tidy_is_xhtml": [ - "boolean tidy_is_xhtml()", + "bool tidy_is_xhtml()", "Indicates if the document is a XHTML document." ], "tidy_is_xml": [ - "boolean tidy_is_xml()", + "bool tidy_is_xml()", "Indicates if the document is a generic (non HTML/XHTML) XML document." ], "tidy_parse_file": [ - "boolean tidy_parse_file(string file [, mixed config_options [, string encoding [, bool use_include_path]]])", + "bool tidy_parse_file(string file [, mixed config_options [, string encoding [, bool use_include_path]]])", "Parse markup in file or URI" ], "tidy_parse_string": [ @@ -10600,11 +10799,11 @@ var functionMap = { "Parse a document stored in a string" ], "tidy_repair_file": [ - "boolean tidy_repair_file(string filename [, mixed config_file [, string encoding [, bool use_include_path]]])", + "bool tidy_repair_file(string filename [, mixed config_file [, string encoding [, bool use_include_path]]])", "Repair a file using an optionally provided configuration file" ], "tidy_repair_string": [ - "boolean tidy_repair_string(string data [, mixed config_file [, string encoding]])", + "bool tidy_repair_string(string data [, mixed config_file [, string encoding]])", "Repair a string using an optionally provided configuration file" ], "tidy_warning_count": [ @@ -10612,7 +10811,7 @@ var functionMap = { "Returns the Number of Tidy warnings encountered for specified document." ], "time": [ - "int time(void)", + "int time()", "Return current UNIX timestamp" ], "time_nanosleep": [ @@ -10660,7 +10859,7 @@ var functionMap = { "Returns the Olson database version number." ], "tmpfile": [ - "resource tmpfile(void)", + "resource tmpfile()", "Create a temporary file that will be deleted automatically after use" ], "token_get_all": [ @@ -10728,7 +10927,7 @@ var functionMap = { "Takes a string representation of variable and recreates it" ], "unset": [ - "void unset (mixed var [, mixed var])", + "void unset(mixed var [, mixed var])", "Unset a given variable" ], "urldecode": [ @@ -10760,7 +10959,7 @@ var functionMap = { "Dumps a string representation of variable to output" ], "var_export": [ - "mixed var_export(mixed var [, bool return])", + "string var_export(mixed var [, bool return])", "Outputs or returns a string representation of a variable" ], "variant_abs": [ @@ -10888,7 +11087,7 @@ var functionMap = { "Return a formatted string" ], "wddx_add_vars": [ - "int wddx_add_vars(resource packet_id, mixed var_names [, mixed ...])", + "int wddx_add_vars(resource packet_id, mixed var_names [, mixed ...])", "Serializes given variables and adds them to packet given by packet_id" ], "wddx_deserialize": [ @@ -10912,7 +11111,7 @@ var functionMap = { "Creates a new packet and serializes given variables into a struct" ], "wordwrap": [ - "string wordwrap(string str [, int width [, string break [, boolean cut]]])", + "string wordwrap(string str [, int width [, string break [, bool cut]]])", "Wraps buffer to selected number of characters using string break char" ], "xml_error_string": [ @@ -11040,7 +11239,7 @@ var functionMap = { "Parses XML requests and call methods" ], "xmlrpc_server_create": [ - "resource xmlrpc_server_create(void)", + "resource xmlrpc_server_create()", "Creates an xmlrpc server" ], "xmlrpc_server_destroy": [ @@ -11228,51 +11427,51 @@ var functionMap = { "Write text - returns FALSE on error" ], "xsl_xsltprocessor_get_parameter": [ - "string xsl_xsltprocessor_get_parameter(string namespace, string name);", + "string xsl_xsltprocessor_get_parameter(string namespace, string name)", "" ], "xsl_xsltprocessor_has_exslt_support": [ - "bool xsl_xsltprocessor_has_exslt_support();", + "bool xsl_xsltprocessor_has_exslt_support()", "" ], "xsl_xsltprocessor_import_stylesheet": [ - "void xsl_xsltprocessor_import_stylesheet(domdocument doc);", - "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html# Since:" + "void xsl_xsltprocessor_import_stylesheet(domdocument doc)", + "" ], "xsl_xsltprocessor_register_php_functions": [ - "void xsl_xsltprocessor_register_php_functions([mixed $restrict]);", + "void xsl_xsltprocessor_register_php_functions([mixed $restrict])", "" ], "xsl_xsltprocessor_remove_parameter": [ - "bool xsl_xsltprocessor_remove_parameter(string namespace, string name);", + "bool xsl_xsltprocessor_remove_parameter(string namespace, string name)", "" ], "xsl_xsltprocessor_set_parameter": [ - "bool xsl_xsltprocessor_set_parameter(string namespace, mixed name [, string value]);", + "bool xsl_xsltprocessor_set_parameter(string namespace, mixed name [, string value])", "" ], "xsl_xsltprocessor_set_profiling": [ - "bool xsl_xsltprocessor_set_profiling(string filename) */", - "PHP_FUNCTION(xsl_xsltprocessor_set_profiling) { zval *id; xsl_object *intern; char *filename = NULL; int filename_len; DOM_GET_THIS(id); if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"s!\", &filename, &filename_len) == SUCCESS) { intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); if (intern->profiling) { efree(intern->profiling); } if (filename != NULL) { intern->profiling = estrndup(filename,filename_len); } else { intern->profiling = NULL; } RETURN_TRUE; } else { WRONG_PARAM_COUNT; } } /* }}} end xsl_xsltprocessor_set_profiling" + "bool xsl_xsltprocessor_set_profiling(string filename)", + "" ], "xsl_xsltprocessor_transform_to_doc": [ - "domdocument xsl_xsltprocessor_transform_to_doc(domnode doc);", - "URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html# Since:" + "domdocument xsl_xsltprocessor_transform_to_doc(domnode doc)", + "" ], "xsl_xsltprocessor_transform_to_uri": [ - "int xsl_xsltprocessor_transform_to_uri(domdocument doc, string uri);", + "int xsl_xsltprocessor_transform_to_uri(domdocument doc, string uri)", "" ], "xsl_xsltprocessor_transform_to_xml": [ - "string xsl_xsltprocessor_transform_to_xml(domdocument doc);", + "string xsl_xsltprocessor_transform_to_xml(domdocument doc)", "" ], "zend_logo_guid": [ - "string zend_logo_guid(void)", + "string zend_logo_guid()", "Return the special ID used to request the Zend logo in phpinfo screens" ], "zend_version": [ - "string zend_version(void)", + "string zend_version()", "Get the version of the Zend Engine" ], "zip_close": [ @@ -11316,7 +11515,7 @@ var functionMap = { "Returns the next file in the archive" ], "zlib_get_coding_type": [ - "string zlib_get_coding_type(void)", + "string zlib_get_coding_type()", "Returns the coding type used for output compression" ] }; @@ -11367,7 +11566,9 @@ var variableMap = { "SERVER_PORT": 1, "SERVER_PROTOCOL": 1, "SERVER_SIGNATURE": 1, - "SERVER_SOFTWARE": 1 + "SERVER_SOFTWARE": 1, + "argv": 1, + "argc": 1 } }, "$_SESSION": { @@ -11375,6 +11576,12 @@ var variableMap = { }, "$GLOBALS": { type: "array" + }, + '$argv': { + type: "array" + }, + '$argc': { + type: "int" } }; @@ -11702,6 +11909,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -12039,6 +12247,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -12931,6 +13140,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -13057,6 +13267,7 @@ oop.inherits(Mode, HtmlMode); }; this.$id = "ace/mode/php"; + this.snippetFileId = "ace/snippets/php"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-prisma.js b/htdocs/includes/ace/src/mode-prisma.js new file mode 100644 index 00000000000..fc7048378e3 --- /dev/null +++ b/htdocs/includes/ace/src/mode-prisma.js @@ -0,0 +1,489 @@ +define("ace/mode/prisma_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PrismaHighlightRules = function() { + + this.$rules = { + start: [{ + include: "#triple_comment" + }, { + include: "#double_comment" + }, { + include: "#model_block_definition" + }, { + include: "#config_block_definition" + }, { + include: "#enum_block_definition" + }, { + include: "#type_definition" + }], + "#model_block_definition": [{ + token: [ + "source.prisma.embedded.source", + "storage.type.model.prisma", + "source.prisma.embedded.source", + "entity.name.type.model.prisma", + "source.prisma.embedded.source", + "punctuation.definition.tag.prisma" + ], + regex: /^(\s*)(model|type)(\s+)([A-Za-z][\w]*)(\s+)({)/, + push: [{ + token: "punctuation.definition.tag.prisma", + regex: /\s*\}/, + next: "pop" + }, { + include: "#triple_comment" + }, { + include: "#double_comment" + }, { + include: "#field_definition" + }, { + defaultToken: "source.prisma.embedded.source" + }] + }], + "#enum_block_definition": [{ + token: [ + "source.prisma.embedded.source", + "storage.type.enum.prisma", + "source.prisma.embedded.source", + "entity.name.type.enum.prisma", + "source.prisma.embedded.source", + "punctuation.definition.tag.prisma" + ], + regex: /^(\s*)(enum)(\s+)([A-Za-z][\w]*)(\s+)({)/, + push: [{ + token: "punctuation.definition.tag.prisma", + regex: /\s*\}/, + next: "pop" + }, { + include: "#triple_comment" + }, { + include: "#double_comment" + }, { + include: "#enum_value_definition" + }, { + defaultToken: "source.prisma.embedded.source" + }] + }], + "#config_block_definition": [{ + token: [ + "source.prisma.embedded.source", + "storage.type.config.prisma", + "source.prisma.embedded.source", + "entity.name.type.config.prisma", + "source.prisma.embedded.source", + "punctuation.definition.tag.prisma" + ], + regex: /^(\s*)(generator|datasource)(\s+)([A-Za-z][\w]*)(\s+)({)/, + push: [{ + token: "source.prisma.embedded.source", + regex: /\s*\}/, + next: "pop" + }, { + include: "#triple_comment" + }, { + include: "#double_comment" + }, { + include: "#assignment" + }, { + defaultToken: "source.prisma.embedded.source" + }] + }], + "#assignment": [{ + token: [ + "text", + "variable.other.assignment.prisma", + "text", + "keyword.operator.terraform", + "text" + ], + regex: /^(\s*)(\w+)(\s*)(=)(\s*)/, + push: [{ + token: "text", + regex: /$/, + next: "pop" + }, { + include: "#value" + }, { + include: "#double_comment_inline" + }] + }], + "#field_definition": [{ + token: [ + "text", + "variable.other.assignment.prisma", + "invalid.illegal.colon.prisma", + "text", + "support.type.primitive.prisma", + "keyword.operator.list_type.prisma", + "keyword.operator.optional_type.prisma", + "invalid.illegal.required_type.prisma" + ], + regex: /^(\s*)(\w+)((?:\s*:)?)(\s+)(\w+)((?:\[\])?)((?:\?)?)((?:\!)?)/ + }, { + include: "#attribute_with_arguments" + }, { + include: "#attribute" + }], + "#type_definition": [{ + token: [ + "text", + "storage.type.type.prisma", + "text", + "entity.name.type.type.prisma", + "text", + "support.type.primitive.prisma" + ], + regex: /^(\s*)(type)(\s+)(\w+)(\s*=\s*)(\w+)/ + }, { + include: "#attribute_with_arguments" + }, { + include: "#attribute" + }], + "#enum_value_definition": [{ + token: [ + "text", + "variable.other.assignment.prisma", + "text" + ], + regex: /^(\s*)(\w+)(\s*$)/ + }, { + include: "#attribute_with_arguments" + }, { + include: "#attribute" + }], + "#attribute_with_arguments": [{ + token: [ + "entity.name.function.attribute.prisma", + "punctuation.definition.tag.prisma" + ], + regex: /(@@?[\w\.]+)(\()/, + push: [{ + token: "punctuation.definition.tag.prisma", + regex: /\)/, + next: "pop" + }, { + include: "#named_argument" + }, { + include: "#value" + }, { + defaultToken: "source.prisma.attribute.with_arguments" + }] + }], + "#attribute": [{ + token: "entity.name.function.attribute.prisma", + regex: /@@?[\w\.]+/ + }], + "#array": [{ + token: "source.prisma.array", + regex: /\[/, + push: [{ + token: "source.prisma.array", + regex: /\]/, + next: "pop" + }, { + include: "#value" + }, { + defaultToken: "source.prisma.array" + }] + }], + "#value": [{ + include: "#array" + }, { + include: "#functional" + }, { + include: "#literal" + }], + "#functional": [{ + token: [ + "support.function.functional.prisma", + "punctuation.definition.tag.prisma" + ], + regex: /(\w+)(\()/, + push: [{ + token: "punctuation.definition.tag.prisma", + regex: /\)/, + next: "pop" + }, { + include: "#value" + }, { + defaultToken: "source.prisma.functional" + }] + }], + "#literal": [{ + include: "#boolean" + }, { + include: "#number" + }, { + include: "#double_quoted_string" + }, { + include: "#identifier" + }], + "#identifier": [{ + token: "support.constant.constant.prisma", + regex: /\b(?:\w)+\b/ + }], + "#map_key": [{ + token: [ + "variable.parameter.key.prisma", + "text", + "punctuation.definition.separator.key-value.prisma", + "text" + ], + regex: /(\w+)(\s*)(:)(\s*)/ + }], + "#named_argument": [{ + include: "#map_key" + }, { + include: "#value" + }], + "#triple_comment": [{ + token: "comment.prisma", + regex: /\/\/\//, + push: [{ + token: "comment.prisma", + regex: /$/, + next: "pop" + }, { + defaultToken: "comment.prisma" + }] + }], + "#double_comment": [{ + token: "comment.prisma", + regex: /\/\//, + push: [{ + token: "comment.prisma", + regex: /$/, + next: "pop" + }, { + defaultToken: "comment.prisma" + }] + }], + "#double_comment_inline": [{ + token: "comment.prisma", + regex: /\/\/[^$]*/ + }], + "#boolean": [{ + token: "constant.language.boolean.prisma", + regex: /\b(?:true|false)\b/ + }], + "#number": [{ + token: "constant.numeric.prisma", + regex: /(?:0(?:x|X)[0-9a-fA-F]*|(?:\+|-)?\b(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:(?:e|E)(?:\+|-)?[0-9]+)?)(?:[LlFfUuDdg]|UL|ul)?\b/ + }], + "#double_quoted_string": [{ + token: "string.quoted.double.start.prisma", + regex: /"/, + push: [{ + token: "string.quoted.double.end.prisma", + regex: /"/, + next: "pop" + }, { + include: "#string_interpolation" + }, { + token: "string.quoted.double.prisma", + regex: /[\w\-\/\._\\%@:\?=]+/ + }, { + defaultToken: "unnamed" + }] + }], + "#string_interpolation": [{ + token: "keyword.control.interpolation.start.prisma", + regex: /\$\{/, + push: [{ + token: "keyword.control.interpolation.end.prisma", + regex: /\s*\}/, + next: "pop" + }, { + include: "#value" + }, { + defaultToken: "source.tag.embedded.source.prisma" + }] + }] + }; + + this.normalizeRules(); +}; + +PrismaHighlightRules.metaData = { + name: "Prisma", + scopeName: "source.prisma" +}; + + +oop.inherits(PrismaHighlightRules, TextHighlightRules); + +exports.PrismaHighlightRules = PrismaHighlightRules; +}); + +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/prisma",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/prisma_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var PrismaHighlightRules = require("./prisma_highlight_rules").PrismaHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = PrismaHighlightRules; + this.foldingRules = new FoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "//"; + this.$id = "ace/mode/prisma"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); (function() { + window.require(["ace/mode/prisma"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-protobuf.js b/htdocs/includes/ace/src/mode-protobuf.js index 0d1a19a5cc4..a4463de826b 100644 --- a/htdocs/includes/ace/src/mode-protobuf.js +++ b/htdocs/includes/ace/src/mode-protobuf.js @@ -65,7 +65,7 @@ var c_cppHighlightRules = function() { var storageType = ( "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + - "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" + + "_Imaginary|int|int8_t|int16_t|int32_t|int64_t|long|short|signed|size_t|struct|typedef|uint8_t|uint16_t|uint32_t|uint64_t|union|unsigned|void|" + "class|wchar_t|template|char16_t|char32_t" ); @@ -489,6 +489,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/c_cpp"; + this.snippetFileId = "ace/snippets/c_cpp"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-puppet.js b/htdocs/includes/ace/src/mode-puppet.js index ea6b2356261..d647dea6f7e 100644 --- a/htdocs/includes/ace/src/mode-puppet.js +++ b/htdocs/includes/ace/src/mode-puppet.js @@ -44,7 +44,7 @@ var PuppetHighlightRules = function () { }, { token: "multiline.comment.begin.puppet", - regex: '^\\s*\\/\\*\\s*$', + regex: '^\\s*\\/\\*', push: "blockComment" }, { @@ -82,11 +82,7 @@ var PuppetHighlightRules = function () { } ], blockComment: [{ - regex: "^\\s*\\/\\*\\s*$", - token: "multiline.comment.begin.puppet", - push: "blockComment" - }, { - regex: "^\\s*\\*\\/\\s*$", + regex: "\\*\\/", token: "multiline.comment.end.puppet", next: "pop" }, { @@ -355,6 +351,9 @@ oop.inherits(Mode, TextMode); (function () { + this.lineCommentStart = "#"; + this.blockComment = {start: "/*", end: "*/"}; + this.$id = "ace/mode/puppet"; }).call(Mode.prototype); diff --git a/htdocs/includes/ace/src/mode-python.js b/htdocs/includes/ace/src/mode-python.js index e2045c8ac18..6c46043a46b 100644 --- a/htdocs/includes/ace/src/mode-python.js +++ b/htdocs/includes/ace/src/mode-python.js @@ -343,10 +343,10 @@ var PythonHighlightRules = function() { regex: "\\s+" }, { token: "string", - regex: "'(.)*'" + regex: "'[^']*'" }, { token: "string", - regex: '"(.)*"' + regex: '"[^"]*"' }, { token: "function.support", regex: "(!s|!r|!a)" @@ -494,6 +494,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/python"; + this.snippetFileId = "ace/snippets/python"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-qml.js b/htdocs/includes/ace/src/mode-qml.js new file mode 100644 index 00000000000..ba61ca66439 --- /dev/null +++ b/htdocs/includes/ace/src/mode-qml.js @@ -0,0 +1,381 @@ +define("ace/mode/qml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + var QmlHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "variable.language": + "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors + "Namespace|QName|XML|XMLList|" + // E4X + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors + "SyntaxError|TypeError|URIError|" + + "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions + "isNaN|parseFloat|parseInt|" + + "JSON|Math|" + // Other + "this|arguments|prototype|window|document" , // Pseudo + "keyword": + "const|yield|import|get|set|async|await|" + + "break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" + + "__parent__|__count__|escape|unescape|with|__proto__|" + + "class|enum|extends|super|export|implements|private|public|interface|package|protected|static|" + + "readonly|string|int|bool|date|color|url|real|double|var|variant|" + + "height|width|anchors|parent|" + + "Abstract3DSeries|AbstractActionInput|AbstractAnimation|AbstractAxis|AbstractAxis3D|AbstractAxisInput|" + + "AbstractBarSeries|AbstractButton|AbstractClipAnimator|AbstractClipBlendNode|AbstractDataProxy|AbstractGraph3D|" + + "AbstractInputHandler3D|AbstractPhysicalDevice|AbstractRayCaster|AbstractSeries|AbstractSkeleton|AbstractTextureImage|" + + "Accelerometer|AccelerometerReading|Accessible|Action|ActionGroup|ActionInput|" + + "AdditiveClipBlend|Address|Affector|Age|AlphaCoverage|AlphaTest|" + + "Altimeter|AltimeterReading|AmbientLightReading|AmbientLightSensor|AmbientTemperatureReading|AmbientTemperatureSensor|" + + "AnalogAxisInput|AnchorAnimation|AnchorChanges|AngleDirection|AnimatedImage|AnimatedSprite|" + + "Animation|AnimationController|AnimationGroup|Animator|ApplicationWindow|ApplicationWindowStyle|" + + "AreaSeries|Armature|AttenuationModelInverse|AttenuationModelLinear|Attractor|Attribute|" + + "Audio|AudioCategory|AudioEngine|AudioListener|AudioSample|AuthenticationDialogRequest|" + + "Axis|AxisAccumulator|AxisSetting|BackspaceKey|Bar3DSeries|BarCategoryAxis|" + + "BarDataProxy|BarSeries|BarSet|Bars3D|BaseKey|Behavior|" + + "Binding|Blend|BlendEquation|BlendEquationArguments|BlendedClipAnimator|BlitFramebuffer|" + + "BluetoothDiscoveryModel|BluetoothService|BluetoothSocket|BorderImage|BorderImageMesh|BoxPlotSeries|" + + "BoxSet|BrightnessContrast|Buffer|BusyIndicator|BusyIndicatorStyle|Button|" + + "ButtonAxisInput|ButtonGroup|ButtonStyle|Calendar|CalendarStyle|Camera|" + + "Camera3D|CameraCapabilities|CameraCapture|CameraExposure|CameraFlash|CameraFocus|" + + "CameraImageProcessing|CameraLens|CameraRecorder|CameraSelector|CandlestickSeries|CandlestickSet|" + + "Canvas|Canvas3D|Canvas3DAbstractObject|Canvas3DActiveInfo|Canvas3DBuffer|Canvas3DContextAttributes|" + + "Canvas3DFrameBuffer|Canvas3DProgram|Canvas3DRenderBuffer|Canvas3DShader|Canvas3DShaderPrecisionFormat|Canvas3DTexture|" + + "Canvas3DTextureProvider|Canvas3DUniformLocation|CanvasGradient|CanvasImageData|CanvasPixelArray|Category|" + + "CategoryAxis|CategoryAxis3D|CategoryModel|CategoryRange|ChangeLanguageKey|ChartView|" + + "CheckBox|CheckBoxStyle|CheckDelegate|CircularGauge|CircularGaugeStyle|ClearBuffers|" + + "ClipAnimator|ClipPlane|CloseEvent|ColorAnimation|ColorDialog|ColorDialogRequest|" + + "ColorGradient|ColorGradientStop|ColorMask|ColorOverlay|Colorize|Column|" + + "ColumnLayout|ComboBox|ComboBoxStyle|Compass|CompassReading|Component|Component3D|" + + "ComputeCommand|ConeGeometry|ConeMesh|ConicalGradient|Connections|ContactDetail|" + + "ContactDetails|Container|Context2D|Context3D|ContextMenuRequest|Control|" + + "CoordinateAnimation|CuboidGeometry|CuboidMesh|CullFace|CumulativeDirection|" + + "Custom3DItem|Custom3DLabel|Custom3DVolume|CustomParticle|CylinderGeometry|CylinderMesh|" + + "Date|DateTimeAxis|DelayButton|DelayButtonStyle|DelegateChoice|DelegateChooser|DelegateModel|" + + "DelegateModelGroup|DepthTest|Desaturate|Dial|DialStyle|Dialog|DialogButtonBox|DiffuseMapMaterial|" + + "DiffuseSpecularMapMaterial|DiffuseSpecularMaterial|Direction|DirectionalBlur|DirectionalLight|DispatchCompute|" + + "Displace|DistanceReading|DistanceSensor|Dithering|DoubleValidator|Drag|DragEvent|DragHandler|Drawer|DropArea|" + + "DropShadow|DwmFeatures|DynamicParameter|EditorialModel|Effect|EllipseShape|Emitter|EnterKey|EnterKeyAction|" + + "Entity|EntityLoader|EnvironmentLight|EventConnection|EventPoint|EventTouchPoint|ExclusiveGroup|ExtendedAttributes|" + + "ExtrudedTextGeometry|ExtrudedTextMesh|FastBlur|FileDialog|FileDialogRequest|FillerKey|FilterKey|FinalState|" + + "FirstPersonCameraController|Flickable|Flipable|Flow|FocusScope|FolderListModel|FontDialog|FontLoader|" + + "FontMetrics|FormValidationMessageRequest|ForwardRenderer|Frame|FrameAction|FrameGraphNode|Friction|" + + "FrontFace|FrustumCulling|FullScreenRequest|GLStateDumpExt|GammaAdjust|Gauge|GaugeStyle|GaussianBlur|" + + "GeocodeModel|Geometry|GeometryRenderer|GestureEvent|Glow|GoochMaterial|Gradient|GradientStop|GraphicsApiFilter|" + + "GraphicsInfo|Gravity|Grid|GridLayout|GridMesh|GridView|GroupBox|GroupGoal|Gyroscope|GyroscopeReading|HBarModelMapper|" + + "HBoxPlotModelMapper|HCandlestickModelMapper|HPieModelMapper|HXYModelMapper|HandlerPoint|HandwritingInputPanel|" + + "HandwritingModeKey|HeightMapSurfaceDataProxy|HideKeyboardKey|HistoryState|HolsterReading|HolsterSensor|HorizontalBarSeries|" + + "|HorizontalPercentBarSeries|HorizontalStackedBarSeries|HoverHandler|HueSaturation|HumidityReading|HumiditySensor|" + + "IRProximityReading|IRProximitySensor|Icon|Image|ImageModel|ImageParticle|InnerShadow|InputChord|InputContext|InputEngine|" + + "InputHandler3D|InputMethod|InputModeKey|InputPanel|InputSequence|InputSettings|Instantiator|IntValidator|InvokedServices|" + + "Item|ItemDelegate|ItemGrabResult|ItemModelBarDataProxy|ItemModelScatterDataProxy|ItemModelSurfaceDataProxy|ItemParticle|" + + "ItemSelectionModel|IviApplication|IviSurface|JavaScriptDialogRequest|Joint|JumpList|JumpListCategory|JumpListDestination|" + + "JumpListLink|JumpListSeparator|Key|KeyEvent|KeyIcon|KeyNavigation|KeyPanel|KeyboardColumn|KeyboardDevice|KeyboardHandler|" + + "KeyboardLayout|KeyboardLayoutLoader|KeyboardRow|KeyboardStyle|KeyframeAnimation|Keys|Label|Layer|LayerFilter|Layout|" + + "LayoutMirroring|Legend|LerpBlend|LevelAdjust|LevelOfDetail|LevelOfDetailBoundingSphere|LevelOfDetailLoader|" + + "LevelOfDetailSwitch|LidReading|LidSensor|Light|Light3D|LightReading|LightSensor|LineSeries|LineShape|LineWidth|" + + "LinearGradient|ListElement|ListModel|ListView|Loader|Locale|Location|LogValueAxis|LogValueAxis3DFormatter|LoggingCategory|" + + "LogicalDevice|Magnetometer|MagnetometerReading|Map|MapCircle|MapCircleObject|MapCopyrightNotice|MapGestureArea|MapIconObject|" + + "MapItemGroup|MapItemView|MapObjectView|MapParameter|MapPinchEvent|MapPolygon|MapPolygonObject|MapPolyline|MapPolylineObject|" + + "MapQuickItem|MapRectangle|MapRoute|MapRouteObject|MapType|Margins|MaskShape|MaskedBlur|Material|Matrix4x4|MediaPlayer|" + + "MemoryBarrier|Menu|MenuBar|MenuBarItem|MenuBarStyle|MenuItem|MenuSeparator|MenuStyle|Mesh|MessageDialog|ModeKey|MorphTarget|" + + "MorphingAnimation|MouseArea|MouseDevice|MouseEvent|MouseHandler|MultiPointHandler|MultiPointTouchArea|MultiSampleAntiAliasing|" + + "Navigator|NdefFilter|NdefMimeRecord|NdefRecord|NdefTextRecord|NdefUriRecord|NearField|NoDepthMask|NoDraw|Node|NodeInstantiator|" + + "NormalDiffuseMapAlphaMaterial|NormalDiffuseMapMaterial|NormalDiffuseSpecularMapMaterial|Number|NumberAnimation|NumberKey|Object3D|" + + "ObjectModel|ObjectPicker|OpacityAnimator|OpacityMask|OpenGLInfo|OrbitCameraController|OrientationReading|OrientationSensor|Overlay|" + + "Package|Page|PageIndicator|Pane|ParallelAnimation|Parameter|ParentAnimation|ParentChange|Particle|ParticleGroup|ParticlePainter|" + + "ParticleSystem|Path|PathAngleArc|PathAnimation|PathArc|PathAttribute|PathCubic|PathCurve|PathElement|PathInterpolator|PathLine|" + + "PathMove|PathPercent|PathQuad|PathSvg|PathView|PauseAnimation|PerVertexColorMaterial|PercentBarSeries|PhongAlphaMaterial|" + + "PhongMaterial|PickEvent|PickLineEvent|PickPointEvent|PickTriangleEvent|PickingSettings|Picture|PieMenu|PieMenuStyle|PieSeries|" + + "PieSlice|PinchArea|PinchEvent|PinchHandler|Place|PlaceAttribute|PlaceSearchModel|PlaceSearchSuggestionModel|PlaneGeometry|" + + "PlaneMesh|PlayVariation|Playlist|PlaylistItem|Plugin|PluginParameter|PointDirection|PointHandler|PointLight|PointSize|" + + "PointerDevice|PointerDeviceHandler|PointerEvent|PointerHandler|PolarChartView|PolygonOffset|Popup|Position|PositionSource|" + + "Positioner|PressureReading|PressureSensor|Product|ProgressBar|ProgressBarStyle|PropertyAction|PropertyAnimation|PropertyChanges|" + + "ProximityFilter|ProximityReading|ProximitySensor|QAbstractState|QAbstractTransition|QSignalTransition|" + + "QVirtualKeyboardSelectionListModel|Qt|QtMultimedia|QtObject|QtPositioning|QuaternionAnimation|QuotaRequest|RadialBlur|" + + "RadialGradient|Radio|RadioButton|RadioButtonStyle|RadioData|RadioDelegate|RangeSlider|Ratings|RayCaster|Rectangle|" + + "RectangleShape|RectangularGlow|RecursiveBlur|RegExpValidator|RegisterProtocolHandlerRequest|RenderCapture|" + + "RenderCaptureReply|RenderPass|RenderPassFilter|RenderSettings|RenderState|RenderStateSet|RenderSurfaceSelector|" + + "RenderTarget|RenderTargetOutput|RenderTargetSelector|Repeater|ReviewModel|Rotation|RotationAnimation|RotationAnimator|" + + "RotationReading|RotationSensor|RoundButton|Route|RouteLeg|RouteManeuver|RouteModel|RouteQuery|RouteSegment|Row|" + + "RowLayout|Scale|ScaleAnimator|Scatter3D|Scatter3DSeries|ScatterDataProxy|ScatterSeries|Scene2D|Scene3D|SceneLoader|" + + "ScissorTest|Screen|ScreenRayCaster|ScriptAction|ScrollBar|ScrollIndicator|ScrollView|ScrollViewStyle|ScxmlStateMachine|" + + "SeamlessCubemap|SelectionListItem|Sensor|SensorGesture|SensorGlobal|SensorReading|SequentialAnimation|Settings|" + + "SettingsStore|ShaderEffect|ShaderEffectSource|ShaderProgram|ShaderProgramBuilder|Shape|ShellSurface|ShellSurfaceItem|" + + "ShiftHandler|ShiftKey|Shortcut|SignalSpy|SignalTransition|SinglePointHandler|Skeleton|SkeletonLoader|Slider|SliderStyle|" + + "SmoothedAnimation|SortPolicy|Sound|SoundEffect|SoundInstance|SpaceKey|SphereGeometry|SphereMesh|SpinBox|SpinBoxStyle|" + + "SplineSeries|SplitView|SpotLight|SpringAnimation|Sprite|SpriteGoal|SpriteSequence|Stack|StackLayout|StackView|" + + "StackViewDelegate|StackedBarSeries|State|StateChangeScript|StateGroup|StateMachine|StateMachineLoader|StatusBar|" + + "StatusBarStyle|StatusIndicator|StatusIndicatorStyle|StencilMask|StencilOperation|StencilOperationArguments|StencilTest|" + + "StencilTestArguments|Store|String|Supplier|Surface3D|Surface3DSeries|SurfaceDataProxy|SwipeDelegate|SwipeView|Switch|" + + "SwitchDelegate|SwitchStyle|SymbolModeKey|SystemPalette|Tab|TabBar|TabButton|TabView|TabViewStyle|TableView|TableViewColumn|" + + "TableViewStyle|TapHandler|TapReading|TapSensor|TargetDirection|TaskbarButton|Technique|TechniqueFilter|TestCase|Text|TextArea|" + + "TextAreaStyle|TextEdit|TextField|TextFieldStyle|TextInput|TextMetrics|TextureImage|TextureImageFactory|Theme3D|ThemeColor|" + + "ThresholdMask|ThumbnailToolBar|ThumbnailToolButton|TiltReading|TiltSensor|TimeoutTransition|Timer|ToggleButton|" + + "ToggleButtonStyle|ToolBar|ToolBarStyle|ToolButton|ToolSeparator|ToolTip|Torch|TorusGeometry|TorusMesh|TouchEventSequence|" + + "TouchInputHandler3D|TouchPoint|Trace|TraceCanvas|TraceInputArea|TraceInputKey|TraceInputKeyPanel|TrailEmitter|Transaction|" + + "Transform|Transition|Translate|TreeView|TreeViewStyle|Tumbler|TumblerColumn|TumblerStyle|Turbulence|UniformAnimator|User|" + + "VBarModelMapper|VBoxPlotModelMapper|VCandlestickModelMapper|VPieModelMapper|VXYModelMapper|ValueAxis|ValueAxis3D|" + + "ValueAxis3DFormatter|Vector3dAnimation|VertexBlendAnimation|Video|VideoOutput|ViewTransition|Viewport|" + + "VirtualKeyboardSettings|Wander|WavefrontMesh|WaylandClient|WaylandCompositor|WaylandHardwareLayer|" + + "WaylandOutput|WaylandQuickItem|WaylandSeat|WaylandSurface|WaylandView|Waypoint|" + + "WebChannel|WebEngine|WebEngineAction|WebEngineCertificateError|WebEngineDownloadItem|WebEngineHistory|" + + "WebEngineHistoryListModel|WebEngineLoadRequest|WebEngineNavigationRequest|WebEngineNewViewRequest|WebEngineProfile|WebEngineScript|" + + "WebEngineSettings|WebEngineView|WebSocket|WebSocketServer|WebView|WebViewLoadRequest|" + + "WheelEvent|Window|WlShell|WlShellSurface|WorkerScript|XAnimator|" + + "XYPoint|XYSeries|XdgDecorationManagerV1|XdgPopup|XdgPopupV5|XdgPopupV6|" + + "XdgShell|XdgShellV5|XdgShellV6|XdgSurface|XdgSurfaceV5|XdgSurfaceV6|" + + "XdgToplevel|XdgToplevelV6|XmlListModel|XmlRole|YAnimator|ZoomBlur", + "storage.type": + "const|let|var|function|" + // js + "property|", // qml + "constant.language": + "null|Infinity|NaN|undefined", + "support.function": + "print|console\\.log", + "constant.language.boolean": "true|false" + }, "identifier"); + this.$rules = { + "start" : [ + { + token : "string", // single line + regex : '"', + next : "string" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : "text", + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token : "comment.start", + regex : "\\/\\*", + next : "comment" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + }, { + token : keywordMapper, + regex : "\\b\\w+\\b" + } + ], + "string" : [ + { + token : "constant.language.escape", + regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/ + }, { + token : "string", + regex : '"|$', + next : "start" + }, { + defaultToken : "string" + } + ], + "comment" : [ + { + token : "comment.end", + regex : "\\*\\/", + next : "start" + }, { + defaultToken: "comment" + } + ] + }; + + }; + + oop.inherits(QmlHighlightRules, TextHighlightRules); + + exports.QmlHighlightRules = QmlHighlightRules; + }); + +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/qml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/qml_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var TextMode = require("./text").Mode; + var QmlHighlightRules = require("./qml_highlight_rules").QmlHighlightRules; + var FoldMode = require("./folding/cstyle").FoldMode; + + var Mode = function() { + this.HighlightRules = QmlHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; + }; + oop.inherits(Mode, TextMode); + + (function() { + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; + this.$quotes = { '"': '"', "'": "'" }; + this.$id = "ace/mode/qml"; + }).call(Mode.prototype); + + exports.Mode = Mode; + }); (function() { + window.require(["ace/mode/qml"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-r.js b/htdocs/includes/ace/src/mode-r.js index 5a6ca976129..2fd49378749 100644 --- a/htdocs/includes/ace/src/mode-r.js +++ b/htdocs/includes/ace/src/mode-r.js @@ -299,6 +299,7 @@ define("ace/mode/r",["require","exports","module","ace/unicode","ace/range","ace this.nonTokenRe = new RegExp("^(?:[^" + unicode.wordChars + "._]|\s])+", "g"); this.$id = "ace/mode/r"; + this.snippetFileId = "ace/snippets/r"; }).call(Mode.prototype); exports.Mode = Mode; }); (function() { diff --git a/htdocs/includes/ace/src/mode-perl6.js b/htdocs/includes/ace/src/mode-raku.js similarity index 96% rename from htdocs/includes/ace/src/mode-perl6.js rename to htdocs/includes/ace/src/mode-raku.js index 4d25513c3ee..d2a829c08cc 100644 --- a/htdocs/includes/ace/src/mode-perl6.js +++ b/htdocs/includes/ace/src/mode-raku.js @@ -1,10 +1,10 @@ -define("ace/mode/perl6_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +define("ace/mode/raku_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; -var Perl6HighlightRules = function() { +var RakuHighlightRules = function() { var keywords = ( "my|our|class|role|grammar|is|does|sub|method|submethod|try|" + @@ -34,7 +34,7 @@ var Perl6HighlightRules = function() { "Pod::Block|Pod::Block::Code|Pod::Block::Comment|Pod::Block::Declarator|"+ "Pod::Block::Named|Pod::Block::Para|Pod::Block::Table|Pod::Heading|Pod::Item|"+ "Positional|PositionalBindFailover|Proc|Proc::Async|Promise|Proxy|PseudoStash|"+ - "QuantHash|Range|Rat|Rational|RatStr|Real|Regex|Routine|Scalar|Scheduler|"+ + "Raku|QuantHash|Range|Rat|Rational|RatStr|Real|Regex|Routine|Scalar|Scheduler|"+ "Semaphore|Seq|Set|SetHash|Setty|Signature|Slip|Stash|Str|StrDistance|Stringy|"+ "Sub|Submethod|Supplier|Supplier::Preserving|Supply|Systemic|Tap|Telemetry|"+ "Telemetry::Instrument::Thread|Telemetry::Instrument::Usage|Telemetry::Period|"+ @@ -120,7 +120,7 @@ var Perl6HighlightRules = function() { "positional|posix|postfix|postmatch|precomp-ext|precomp-target|pred|prefix|prematch|prepend|"+ "print|printf|print-nl|print-to|private|private_method_table|proc|produce|Promise|prompt|"+ "protect|pull-one|push|push-all|push-at-least|push-exactly|push-until-lazy|put|"+ - "qualifier-type|quit|r|race|radix|rand|range|raw|re|read|readchars|readonly|"+ + "qualifier-type|quit|r|race|radix|raku|rand|range|raw|re|read|readchars|readonly|"+ "ready|Real|reallocate|reals|reason|rebless|receive|recv|redispatcher|redo|reduce|"+ "rel2abs|relative|release|rename|repeated|replacement|report|reserved|resolve|"+ "restore|result|resume|rethrow|reverse|right|rindex|rmdir|roles_to_compose|"+ @@ -339,9 +339,9 @@ var Perl6HighlightRules = function() { }; }; -oop.inherits(Perl6HighlightRules, TextHighlightRules); +oop.inherits(RakuHighlightRules, TextHighlightRules); -exports.Perl6HighlightRules = Perl6HighlightRules; +exports.RakuHighlightRules = RakuHighlightRules; }); define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) { @@ -524,17 +524,17 @@ oop.inherits(FoldMode, BaseFoldMode); }); -define("ace/mode/perl6",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/perl6_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module) { +define("ace/mode/raku",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/raku_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Perl6HighlightRules = require("./perl6_highlight_rules").Perl6HighlightRules; +var RakuHighlightRules = require("./raku_highlight_rules").RakuHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - this.HighlightRules = Perl6HighlightRules; + this.HighlightRules = RakuHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new CStyleFoldMode({start: "^=(begin)\\b", end: "^=(end)\\b"}); @@ -579,12 +579,12 @@ oop.inherits(Mode, TextMode); this.$outdent.autoOutdent(doc, row); }; - this.$id = "ace/mode/perl6"; + this.$id = "ace/mode/raku"; }).call(Mode.prototype); exports.Mode = Mode; }); (function() { - window.require(["ace/mode/perl6"], function(m) { + window.require(["ace/mode/raku"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; } diff --git a/htdocs/includes/ace/src/mode-razor.js b/htdocs/includes/ace/src/mode-razor.js index 5733efd213e..49b7588eee5 100644 --- a/htdocs/includes/ace/src/mode-razor.js +++ b/htdocs/includes/ace/src/mode-razor.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2858,6 +2861,7 @@ oop.inherits(Mode, HtmlMode); }; this.$id = "ace/mode/razor"; + this.snippetFileId = "ace/snippets/razor"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-rhtml.js b/htdocs/includes/ace/src/mode-rhtml.js index f389e63d28e..de4788dfd88 100644 --- a/htdocs/includes/ace/src/mode-rhtml.js +++ b/htdocs/includes/ace/src/mode-rhtml.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-rst.js b/htdocs/includes/ace/src/mode-rst.js index 8a093c05701..23e17db0989 100644 --- a/htdocs/includes/ace/src/mode-rst.js +++ b/htdocs/includes/ace/src/mode-rst.js @@ -242,6 +242,7 @@ oop.inherits(Mode, TextMode); this.type = "text"; this.$id = "ace/mode/rst"; + this.snippetFileId = "ace/snippets/rst"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-ruby.js b/htdocs/includes/ace/src/mode-ruby.js index 6e8afa36877..12398cc9193 100644 --- a/htdocs/includes/ace/src/mode-ruby.js +++ b/htdocs/includes/ace/src/mode-ruby.js @@ -8,17 +8,17 @@ var constantOtherSymbol = exports.constantOtherSymbol = { regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?" }; -var qString = exports.qString = { +exports.qString = { token : "string", // single line regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }; -var qqString = exports.qqString = { +exports.qqString = { token : "string", // single line regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }; -var tString = exports.tString = { +exports.tString = { token : "string", // backtick string regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]" }; @@ -28,9 +28,34 @@ var constantNumericHex = exports.constantNumericHex = { regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b" }; +var constantNumericBinary = exports.constantNumericBinary = { + token: "constant.numeric", + regex: /\b(0[bB][01](?:[01]|_(?=[01]))*)\b/ +}; + +var constantNumericDecimal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[dD](?:[1-9](?:[\d]|_(?=[\d]))*|0))\b/ +}; + +var constantNumericOctal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[oO]?(?:[1-7](?:[0-7]|_(?=[0-7]))*|0))\b/ +}; + +var constantNumericRational = exports.constantNumericRational = { + token: "constant.numeric", //rational + complex + regex: /\b([\d]+(?:[./][\d]+)?ri?)\b/ +}; + +var constantNumericComplex = exports.constantNumericComplex = { + token: "constant.numeric", //simple complex numbers + regex: /\b([\d]i)\b/ +}; + var constantNumericFloat = exports.constantNumericFloat = { - token : "constant.numeric", // float - regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b" + token : "constant.numeric", // float + complex + regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?i?\\b" }; var instanceVariable = exports.instanceVariable = { @@ -70,18 +95,19 @@ var RubyHighlightRules = function() { "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" + "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" + "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" + - "has_many|has_one|belongs_to|has_and_belongs_to_many" + "has_many|has_one|belongs_to|has_and_belongs_to_many|p|warn|refine|using|module_function|extend|alias_method|" + + "private_class_method|remove_method|undef_method" ); var keywords = ( "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" + "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" + - "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield" + "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield|__ENCODING__|prepend" ); var buildinConstants = ( "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" + - "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING" + "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING|RUBY_PATCHLEVEL|RUBY_REVISION|RUBY_COPYRIGHT|RUBY_ENGINE|RUBY_ENGINE_VERSION|RUBY_DESCRIPTION" ); var builtinVariables = ( @@ -97,126 +123,191 @@ var RubyHighlightRules = function() { "invalid.deprecated": "debugger" // TODO is this a remnant from js mode? }, "identifier"); + var escapedChars = "\\\\(?:n(?:[1-7][0-7]{0,2}|0)|[nsrtvfbae'\"\\\\]|c(?:\\\\M-)?.|M-(?:\\\\C-|\\\\c)?.|C-(?:\\\\M-)?.|[0-7]{3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|u{[\\da-fA-F]{1,6}(?:\\s[\\da-fA-F]{1,6})*})"; + + var closeParen = { + "(": ")", + "[": "]", + "{": "}", + "<": ">", + "^": "^", + "|": "|", + "%": "%" + }; + this.$rules = { - "start" : [ + "start": [ { - token : "comment", - regex : "#.*$" + token: "comment", + regex: "#.*$" }, { - token : "comment", // multi line comment - regex : "^=begin(?:$|\\s.*$)", - next : "comment" + token: "comment.multiline", // multi line comment + regex: "^=begin(?=$|\\s.*$)", + next: "comment" }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + token: "string.regexp", + regex: /[/](?=.*\/)/, + next: "regex" }, [{ - regex: "[{}]", onMatch: function(val, state, stack) { - this.next = val == "{" ? this.nextState : ""; - if (val == "{" && stack.length) { - stack.unshift("start", state); - return "paren.lparen"; - } - if (val == "}" && stack.length) { - stack.shift(); - this.next = stack.shift(); - if (this.next.indexOf("string") != -1) - return "paren.end"; - } - return val == "{" ? "paren.lparen" : "paren.rparen"; - }, - nextState: "start" - }, { - token : "string.start", - regex : /"/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(")/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /"/, - next : "pop" + token: "string.end", + regex: /"/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /`/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: "string.start", + regex: /`/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /`/, - next : "pop" + token: "string.end", + regex: /`/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /'/, - push : [{ - token : "constant.language.escape", - regex : /\\['\\]/ - }, { - token : "string.end", - regex : /'/, - next : "pop" + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(')/, + push: [{ + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "string.end", + regex: /'/, + next: "pop" }, { defaultToken: "string" }] + }, { + token: "string.start",//doesn't see any differences between strings and array of strings in highlighting + regex: /%[qwx]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithoutInterpolation"; + return this.token; + } + }, { + token: "string.start", //doesn't see any differences between strings and array of strings in highlighting + regex: /%[QWX]?([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[si]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithoutInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[SI]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithInterpolation"; + return this.token; + } + }, { + token: "string.regexp", + regex: /%[r]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "rState"; + return this.token; + } }], { - token : "text", // namespaces aren't symbols - regex : "::" + token: "punctuation", // namespaces aren't symbols + regex: "::" + }, + instanceVariable, + { + token: "variable.global", // global variable + regex: "[$][a-zA-Z_\\d]+" }, { - token : "variable.instance", // instance variable - regex : "@{1,2}[a-zA-Z_\\d]+" + token: "support.class", // class name + regex: "[A-Z][a-zA-Z_\\d]*" }, { - token : "support.class", // class name - regex : "[A-Z][a-zA-Z_\\d]+" + token: ["punctuation.operator", "support.function"], + regex: /(\.)([a-zA-Z_\d]+)(?=\()/ + }, { + token: ["punctuation.operator", "identifier"], + regex: /(\.)([a-zA-Z_][a-zA-Z_\d]*)/ + }, { + token: "string.character", + regex: "\\B\\?(?:" + escapedChars + "|\\S)" + }, { + token: "punctuation.operator", + regex: /\?(?=.+:)/ }, + constantNumericRational, + constantNumericComplex, constantOtherSymbol, constantNumericHex, constantNumericFloat, - + constantNumericBinary, + constantNumericDecimal, + constantNumericOctal, { - token : "constant.language.boolean", - regex : "(?:true|false)\\b" + token: "constant.language.boolean", + regex: "(?:true|false)\\b" }, { - token : keywordMapper, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + token: keywordMapper, + regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { - token : "punctuation.separator.key-value", - regex : "=>" + token: "punctuation.separator.key-value", + regex: "=>" }, { stateName: "heredoc", - onMatch : function(value, currentState, stack) { - var next = value[2] == '-' ? "indentedHeredoc" : "heredoc"; + onMatch: function (value, currentState, stack) { + var next = (value[2] == '-' || value[2] == '~') ? "indentedHeredoc" : "heredoc"; var tokens = value.split(this.splitRegex); stack.push(next, tokens[3]); return [ - {type:"constant", value: tokens[1]}, - {type:"string", value: tokens[2]}, - {type:"support.class", value: tokens[3]}, - {type:"string", value: tokens[4]} + {type: "constant", value: tokens[1]}, + {type: "string", value: tokens[2]}, + {type: "support.class", value: tokens[3]}, + {type: "string", value: tokens[4]} ]; }, - regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)", + regex: "(<<[-~]?)(['\"`]?)([\\w]+)(['\"`]?)", rules: { heredoc: [{ - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -233,7 +324,7 @@ var RubyHighlightRules = function() { token: "string", regex: "^ +" }, { - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -248,38 +339,261 @@ var RubyHighlightRules = function() { }] } }, { - regex : "$", - token : "empty", - next : function(currentState, stack) { + regex: "$", + token: "empty", + next: function(currentState, stack) { if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc") return stack[0]; return currentState; } + }, { + token: "keyword.operator", + regex: "!|\\$|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\||\\b(?:in|instanceof|new|delete|typeof|void)" }, { - token : "string.character", - regex : "\\B\\?." + token: "paren.lparen", + regex: "[[({]" }, { - token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + token: "paren.rparen", + regex: "[\\])}]", + onMatch: function(value, currentState, stack) { + this.next = ''; + if (value == "}" && stack.length > 1 && stack[1] != "start") { + stack.shift(); + this.next = stack.shift(); + } + return this.token; + } }, { - token : "paren.lparen", - regex : "[[({]" + token: "text", + regex: "\\s+" }, { - token : "paren.rparen", - regex : "[\\])}]" - }, { - token : "text", - regex : "\\s+" + token: "punctuation.operator", + regex: /[?:,;.]/ } ], - "comment" : [ + "comment": [ { - token : "comment", // closing comment - regex : "^=end(?:$|\\s.*$)", - next : "start" + token: "comment.multiline", // closing comment + regex: "^=end(?=$|\\s.*$)", + next: "start" }, { - token : "comment", // comment spanning whole line - regex : ".+" + token: "comment", // comment spanning whole line + regex: ".+" + } + ], + "qStateWithInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "qStateWithoutInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "sStateWithoutInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "sStateWithInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "rState": [{ + token: "string.regexp",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.language.escape"; + } + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.regexp", + regex: /\// + }, { + token: "string.regexp", + regex: /[)\]>}^|%][imxouesn]*/, onMatch: function (val, state, stack) { + if (stack.length && val[0] === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.language.escape"; + } + }, + {include: "regex"}, + { + defaultToken: "string.regexp" + }], + "regex": [ + {// character classes + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "constant.language.escape", + regex: /\\[AGbBzZ]/ + }, { + token: "constant.language.escape", + regex: /\\g<[a-zA-Z0-9]*>/ + }, { + token: ["constant.language.escape", "regexp.keyword", "constant.language.escape"], + regex: /(\\p{\^?)(Alnum|Alpha|Blank|Cntrl|Digit|Graph|Lower|Print|Punct|Space|Upper|XDigit|Word|ASCII|Any|Assigned|Arabic|Armenian|Balinese|Bengali|Bopomofo|Braille|Buginese|Buhid|Canadian_Aboriginal|Carian|Cham|Cherokee|Common|Coptic|Cuneiform|Cypriot|Cyrillic|Deseret|Devanagari|Ethiopic|Georgian|Glagolitic|Gothic|Greek|Gujarati|Gurmukhi|Han|Hangul|Hanunoo|Hebrew|Hiragana|Inherited|Kannada|Katakana|Kayah_Li|Kharoshthi|Khmer|Lao|Latin|Lepcha|Limbu|Linear_B|Lycian|Lydian|Malayalam|Mongolian|Myanmar|New_Tai_Lue|Nko|Ogham|Ol_Chiki|Old_Italic|Old_Persian|Oriya|Osmanya|Phags_Pa|Phoenician|Rejang|Runic|Saurashtra|Shavian|Sinhala|Sundanese|Syloti_Nagri|Syriac|Tagalog|Tagbanwa|Tai_Le|Tamil|Telugu|Thaana|Thai|Tibetan|Tifinagh|Ugaritic|Vai|Yi|Ll|Lm|Lt|Lu|Lo|Mn|Mc|Me|Nd|Nl|Pc|Pd|Ps|Pe|Pi|Pf|Po|No|Sm|Sc|Sk|So|Zs|Zl|Zp|Cc|Cf|Cn|Co|Cs|N|L|M|P|S|Z|C)(})/ + }, { + token: ["constant.language.escape", "invalid", "constant.language.escape"], + regex: /(\\p{\^?)([^/]*)(})/ + }, {// escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, {// flag + token: "string.regexp", + regex: /[/][imxouesn]*/, + next: "start" + }, {// invalid operators + token: "invalid", + regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ + }, {// operators + token: "constant.language.escape", + regex: /\(\?(?:[:=!>]|<'?[a-zA-Z]*'?>|<[=!])|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ + }, { + token: "constant.language.delimiter", + regex: /\|/ + }, { + token: "regexp.keyword", + regex: /\[\[:(?:alnum|alpha|blank|cntrl|digit|graph|lower|print|punct|space|upper|xdigit|word|ascii):\]\]/ + }, { + token: "constant.language.escape", + regex: /\[\^?/, + push: "regex_character_class" + }, { + defaultToken: "string.regexp" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "regexp.charclass.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: /&?&?\[\^?/, + push: "regex_character_class" + }, { + token: "constant.language.escape", + regex: "]", + next: "pop" + }, { + token: "constant.language.escape", + regex: "-" + }, { + defaultToken: "string.regexp.characterclass" } ] }; @@ -332,94 +646,271 @@ var MatchingBraceOutdent = function() {}; exports.MatchingBraceOutdent = MatchingBraceOutdent; }); -define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) { +define("ace/mode/folding/ruby",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function (require, exports, module) { "use strict"; var oop = require("../../lib/oop"); var BaseFoldMode = require("./fold_mode").FoldMode; var Range = require("../../range").Range; +var TokenIterator = require("../../token_iterator").TokenIterator; + + +var FoldMode = exports.FoldMode = function () { +}; -var FoldMode = exports.FoldMode = function() {}; oop.inherits(FoldMode, BaseFoldMode); -(function() { - - this.getFoldWidgetRange = function(session, foldStyle, row) { - var range = this.indentationBlock(session, row); - if (range) - return range; - - var re = /\S/; - var line = session.getLine(row); - var startLevel = line.search(re); - if (startLevel == -1 || line[startLevel] != "#") - return; - - var startColumn = line.length; - var maxRow = session.getLength(); - var startRow = row; - var endRow = row; - - while (++row < maxRow) { - line = session.getLine(row); - var level = line.search(re); - - if (level == -1) - continue; - - if (line[level] != "#") - break; - - endRow = row; - } - - if (endRow > startRow) { - var endColumn = session.getLine(endRow).length; - return new Range(startRow, startColumn, endRow, endColumn); - } +(function () { + this.indentKeywords = { + "class": 1, + "def": 1, + "module": 1, + "do": 1, + "unless": 1, + "if": 1, + "while": 1, + "for": 1, + "until": 1, + "begin": 1, + "else": 0, + "elsif": 0, + "rescue": 0, + "ensure": 0, + "when": 0, + "end": -1, + "case": 1, + "=begin": 1, + "=end": -1 }; - this.getFoldWidget = function(session, foldStyle, row) { - var line = session.getLine(row); - var indent = line.search(/\S/); - var next = session.getLine(row + 1); - var prev = session.getLine(row - 1); - var prevIndent = prev.search(/\S/); - var nextIndent = next.search(/\S/); - if (indent == -1) { - session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : ""; - return ""; - } - if (prevIndent == -1) { - if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") { - session.foldWidgets[row - 1] = ""; - session.foldWidgets[row + 1] = ""; + this.foldingStartMarker = /(?:\s|^)(def|do|while|class|unless|module|if|for|until|begin|else|elsif|case|rescue|ensure|when)\b|({\s*$)|(=begin)/; + this.foldingStopMarker = /(=end(?=$|\s.*$))|(^\s*})|\b(end)\b/; + + this.getFoldWidget = function (session, foldStyle, row) { + var line = session.getLine(row); + var isStart = this.foldingStartMarker.test(line); + var isEnd = this.foldingStopMarker.test(line); + + if (isStart && !isEnd) { + var match = line.match(this.foldingStartMarker); + if (match[1]) { + if (match[1] == "if" || match[1] == "else" || match[1] == "while" || match[1] == "until" || match[1] == "unless") { + if (match[1] == "else" && /^\s*else\s*$/.test(line) === false) { + return; + } + if (/^\s*(?:if|else|while|until|unless)\s*/.test(line) === false) { + return; + } + } + + if (match[1] == "when") { + if (/\sthen\s/.test(line) === true) { + return; + } + } + if (session.getTokenAt(row, match.index + 2).type === "keyword") + return "start"; + } else if (match[3]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "start"; + } else { return "start"; } - } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") { - if (session.getLine(row - 2).search(/\S/) == -1) { - session.foldWidgets[row - 1] = "start"; - session.foldWidgets[row + 1] = ""; - return ""; + } + if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd) + return ""; + + var match = line.match(this.foldingStopMarker); + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return "end"; + } else if (match[1]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "end"; + } else + return "end"; + }; + + this.getFoldWidgetRange = function (session, foldStyle, row) { + var line = session.doc.getLine(row); + var match = this.foldingStartMarker.exec(line); + if (match) { + if (match[1] || match[3]) + return this.rubyBlock(session, row, match.index + 2); + + return this.openingBracketBlock(session, "{", row, match.index); + } + + var match = this.foldingStopMarker.exec(line); + if (match) { + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return this.rubyBlock(session, row, match.index + 1); + } + + if (match[1] === "=end") { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return this.rubyBlock(session, row, match.index + 1); + } + + return this.closingBracketBlock(session, "}", row, match.index + match[0].length); + } + }; + + this.rubyBlock = function (session, row, column, tokenRange) { + var stream = new TokenIterator(session, row, column); + + var token = stream.getCurrentToken(); + if (!token || (token.type != "keyword" && token.type != "comment.multiline")) + return; + + var val = token.value; + var line = session.getLine(row); + switch (token.value) { + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + return; + } + var dir = this.indentKeywords[val]; + break; + case "when": + if (/\sthen\s/.test(line)) { + return; + } + case "elsif": + case "rescue": + case "ensure": + var dir = 1; + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line)) { + return; + } + var dir = 1; + break; + default: + var dir = this.indentKeywords[val]; + break; + } + + var stack = [val]; + if (!dir) + return; + + var startColumn = dir === -1 ? session.getLine(row - 1).length : session.getLine(row).length; + var startRow = row; + var ranges = []; + ranges.push(stream.getCurrentTokenRange()); + + stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; + if (token.type == "comment.multiline") { + while (token = stream.step()) { + if (token.type !== "comment.multiline") + continue; + if (dir == 1) { + startColumn = 6; + if (token.value == "=end") { + break; + } + } else { + if (token.value == "=begin") { + break; + } + } + } + } else { + while (token = stream.step()) { + var ignore = false; + if (token.type !== "keyword") + continue; + var level = dir * this.indentKeywords[token.value]; + line = session.getLine(stream.getCurrentTokenRow()); + switch (token.value) { + case "do": + for (var i = stream.$tokenIndex - 1; i >= 0; i--) { + var prevToken = stream.$rowTokens[i]; + if (prevToken && (prevToken.value == "while" || prevToken.value == "until" || prevToken.value == "for")) { + level = 0; + break; + } + } + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + level = 0; + ignore = true; + } + break; + case "when": + if (/\sthen\s/.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + } + + if (level > 0) { + stack.unshift(token.value); + } else if (level <= 0 && ignore === false) { + stack.shift(); + if (!stack.length) { + if ((val == "while" || val == "until" || val == "for") && token.value != "do") { + break; + } + if (token.value == "do" && dir == -1 && level != 0) + break; + if (token.value != "do") + break; + } + + if (level === 0) { + stack.unshift(token.value); + } + } } } - if (prevIndent!= -1 && prevIndent < indent) - session.foldWidgets[row - 1] = "start"; - else - session.foldWidgets[row - 1] = ""; + if (!token) + return null; - if (indent < nextIndent) - return "start"; - else - return ""; + if (tokenRange) { + ranges.push(stream.getCurrentTokenRange()); + return ranges; + } + + var row = stream.getCurrentTokenRow(); + if (dir === -1) { + if (token.type === "comment.multiline") { + var endColumn = 6; + } else { + var endColumn = session.getLine(row).length; + } + return new Range(row, endColumn, startRow - 1, startColumn); + } else + return new Range(startRow, startColumn, row - 1, session.getLine(row - 1).length); }; }).call(FoldMode.prototype); }); -define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module) { +define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/ruby"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); @@ -428,13 +919,14 @@ var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; -var FoldMode = require("./folding/coffee").FoldMode; +var FoldMode = require("./folding/ruby").FoldMode; var Mode = function() { this.HighlightRules = RubyHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new FoldMode(); + this.indentKeywords = this.foldingRules.indentKeywords; }; oop.inherits(Mode, TextMode); @@ -449,7 +941,7 @@ oop.inherits(Mode, TextMode); var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokens = tokenizedLine.tokens; - if (tokens.length && tokens[tokens.length-1].type == "comment") { + if (tokens.length && tokens[tokens.length - 1].type == "comment") { return indent; } @@ -457,7 +949,7 @@ oop.inherits(Mode, TextMode); var match = line.match(/^.*[\{\(\[]\s*$/); var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/); var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/); - var startingConditional = line.match(/^\s*(if|else|when)\s*/); + var startingConditional = line.match(/^\s*(if|else|when|elsif|unless|while|for|begin|rescue|ensure)\s*/); if (match || startingClassOrMethod || startingDoBlock || startingConditional) { indent += tab; } @@ -467,7 +959,7 @@ oop.inherits(Mode, TextMode); }; this.checkOutdent = function(state, line, input) { - return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input); + return /^\s+(end|else|rescue|ensure)$/.test(line + input) || this.$outdent.checkOutdent(line, input); }; this.autoOutdent = function(state, session, row) { @@ -480,11 +972,24 @@ oop.inherits(Mode, TextMode); var tab = session.getTabString(); if (prevIndent.length <= indent.length) { if (indent.slice(-tab.length) == tab) - session.remove(new Range(row, indent.length-tab.length, row, indent.length)); + session.remove(new Range(row, indent.length - tab.length, row, indent.length)); } }; + this.getMatching = function(session, row, column) { + if (row == undefined) { + var pos = session.selection.lead; + column = pos.column; + row = pos.row; + } + + var startToken = session.getTokenAt(row, column); + if (startToken && startToken.value in this.indentKeywords) + return this.foldingRules.rubyBlock(session, row, column, true); + }; + this.$id = "ace/mode/ruby"; + this.snippetFileId = "ace/snippets/ruby"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-rust.js b/htdocs/includes/ace/src/mode-rust.js index e24ed47a680..19f6a989963 100644 --- a/htdocs/includes/ace/src/mode-rust.js +++ b/htdocs/includes/ace/src/mode-rust.js @@ -5,15 +5,16 @@ var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var stringEscape = /\\(?:[nrt0'"\\]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\})/.source; +var wordPattern = /[a-zA-Z_\xa1-\uffff][a-zA-Z0-9_\xa1-\uffff]*/.source; var RustHighlightRules = function() { this.$rules = { start: [ { token: 'variable.other.source.rust', - regex: '\'[a-zA-Z_][a-zA-Z0-9_]*(?![\\\'])' }, + regex: '\'' + wordPattern + '(?![\\\'])' }, { token: 'string.quoted.single.source.rust', regex: "'(?:[^'\\\\]|" + stringEscape + ")'" }, { token: 'identifier', - regex: /r#[a-zA-Z_][a-zA-Z0-9_]*\b/ }, + regex: "r#" + wordPattern + "\\b" }, { stateName: "bracketedComment", onMatch : function(value, currentState, stack){ @@ -53,8 +54,8 @@ var RustHighlightRules = function() { regex: stringEscape }, { defaultToken: 'string.quoted.double.source.rust' } ] }, { token: [ 'keyword.source.rust', 'text', 'entity.name.function.source.rust' ], - regex: '\\b(fn)(\\s+)((?:r#)?[a-zA-Z_][a-zA-Z0-9_]*)' }, - { token: 'support.constant', regex: '\\b[a-zA-Z_][\\w\\d]*::' }, + regex: '\\b(fn)(\\s+)((?:r#)?'+ wordPattern + ')' }, + { token: 'support.constant', regex: wordPattern + '::' }, { token: 'keyword.source.rust', regex: '\\b(?:abstract|alignof|as|async|await|become|box|break|catch|continue|const|crate|default|do|dyn|else|enum|extern|for|final|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\\b' }, { token: 'storage.type.source.rust', diff --git a/htdocs/includes/ace/src/mode-scala.js b/htdocs/includes/ace/src/mode-scala.js index b3cd18a601b..68a320ca8fd 100644 --- a/htdocs/includes/ace/src/mode-scala.js +++ b/htdocs/includes/ace/src/mode-scala.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-scrypt.js b/htdocs/includes/ace/src/mode-scrypt.js new file mode 100644 index 00000000000..80feb0ed02d --- /dev/null +++ b/htdocs/includes/ace/src/mode-scrypt.js @@ -0,0 +1,364 @@ +define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, + DocCommentHighlightRules.getTagRule(), + { + defaultToken : "comment.doc", + caseInsensitive: true + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getTagRule = function(start) { + return { + token : "comment.doc.tag.storage.type", + regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b" + }; +}; + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +define("ace/mode/scrypt_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function (require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + var scryptHighlightRules = function () { + + var keywords = ( + "contract|library|loop|new|private|" + + "public|if|else|struct|type|" + + "require|static|const|import|exit|return|asm" + ); + + var buildinConstants = ("true|false"); + + + var langClasses = ( + "function|auto|constructor|bytes|int|bool|SigHashPreimage|PrivKey|PubKey|Sig|Ripemd160|Sha1|Sha256|" + + "SigHashType|SigHashPreimage|OpCodeType" + ); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": langClasses + }, "identifier"); + + this.$rules = { + "start": [ + { + token: "comment", + regex: "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token: "comment", // multi line comment + regex: "\\/\\*", + next: "comment" + }, { + token: "string", // single line + regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token: "string", // single line + regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token: "constant.numeric", // hex + regex: /0(?:[xX][0-9a-fA-F][0-9a-fA-F_]*|[bB][01][01_]*)[LlSsDdFfYy]?\b/ + }, { + token: "constant.numeric", // float + regex: /[+-]?\d[\d_]*(?:(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?)?[LlSsDdFfYy]?\b/ + }, { + token: "constant.language.boolean", + regex: "(?:true|false)\\b" + }, + { + token: ["support.function.math.scrypt", "text", "text"], + regex: /\b(abs|min|max|within|ripemd160|sha1|sha256|hash160|hash256|checkSig|checkMultiSig|num2bin|pack|unpack|len|reverseBytes|repeat)(\s*)(\()/ + }, { + token: [ + "entity.name.type.scrypt", + "text", + "text", + "text", + "variable.object.property.scrypt" + ], + regex: /\b(SigHash)(\s*)(\.)(\s*)(ANYONECANPAY|ALL|FORKID|NONE|SINGLE)\b/ + }, + { + token: [ + "entity.name.type.scrypt", + "text", + "text", + "text", + "variable.object.property.scrypt" + ], + regex: /\b(OpCode)(\s*)(\.)(\s*)(OP_PUSHDATA1|OP_PUSHDATA2|OP_PUSHDATA4|OP_0|OP_FALSE|OP_1NEGATE|OP_1|OP_TRUE|OP_2|OP_3|OP_4|OP_5|OP_6|OP_7|OP_8|OP_9|OP_10|OP_11|OP_12|OP_13|OP_14|OP_15|OP_16|OP_1ADD|OP_1SUB|OP_NEGATE|OP_ABS|OP_NOT|OP_0NOTEQUAL|OP_ADD|OP_SUB|OP_MUL|OP_DIV|OP_MOD|OP_LSHIFT|OP_RSHIFT|OP_BOOLAND|OP_BOOLOR|OP_NUMEQUAL|OP_NUMEQUALVERIFY|OP_NUMNOTEQUAL|OP_LESSTHAN|OP_GREATERTHAN|OP_LESSTHANOREQUAL|OP_GREATERTHANOREQUAL|OP_MIN|OP_MAX|OP_WITHIN|OP_CAT|OP_SPLIT|OP_BIN2NUM|OP_NUM2BIN|OP_SIZE|OP_NOP|OP_IF|OP_NOTIF|OP_ELSE|OP_ENDIF|OP_VERIFY|OP_RETURN|OP_TOALTSTACK|OP_FROMALTSTACK|OP_IFDUP|OP_DEPTH|OP_DROP|OP_DUP|OP_NIP|OP_OVER|OP_PICK|OP_ROLL|OP_ROT|OP_SWAP|OP_TUCK|OP_2DROP|OP_2DUP|OP_3DUP|OP_2OVER|OP_2ROT|OP_2SWAP|OP_RIPEMD160|OP_SHA1|OP_SHA256|OP_HASH160|OP_HASH256|OP_CODESEPARATOR|OP_CHECKSIG|OP_CHECKSIGVERIFY|OP_CHECKMULTISIG|OP_CHECKMULTISIGVERIFY|OP_INVERT|OP_AND|OP_OR|OP_XOR|OP_EQUAL|OP_EQUALVERIFY)\b/ + }, { + token: "entity.name.type.scrypt", + regex: /\b(?:P2PKH|P2PK|Tx|HashPuzzleRipemd160|HashPuzzleSha1|HashPuzzleSha256|HashPuzzleHash160|OpCode|SigHash)\b/ + }, { + token: [ + "punctuation.separator.period.scrypt", + 'text', + "entity.name.function.scrypt", + "text", + "punctuation.definition.parameters.begin.bracket.round.scrypt" + ], + regex: /(\.)([^\S$\r]*)([\w][\w\d]*)(\s*)(\()/, + push: [{ + token: "punctuation.definition.parameters.end.bracket.round.scrypt", + regex: /\)/, + next: "pop" + }, { + defaultToken: "start" + }] + }, { + token: keywordMapper, + regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token: "keyword.operator", + regex: "!|\\$|%|&|\\||\\^|\\*|\\/|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<>|<|>|!|&&|\\|\\||\\?|\\:|\\*=|\\/=|%=|\\+=|\\-=|&=|\\|=|\\^=" + }, { + token: "lparen", + regex: "[[({]" + }, { + token: "rparen", + regex: "[\\])}]" + }, { + token: "text", + regex: "\\s+" + } + ], + "comment": [ + { + token: "comment", // closing comment + regex: "\\*\\/", + next: "start" + }, { + defaultToken: "comment" + } + ] + }; + + + this.embedRules(DocCommentHighlightRules, "doc-", + [DocCommentHighlightRules.getEndRule("start")]); + this.normalizeRules(); + }; + + oop.inherits(scryptHighlightRules, TextHighlightRules); + + exports.scryptHighlightRules = scryptHighlightRules; +}); + +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/scrypt",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/scrypt_highlight_rules","ace/mode/folding/cstyle"], function (require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var TextMode = require("./text").Mode; + var scryptHighlightRules = require("./scrypt_highlight_rules").scryptHighlightRules; + var FoldMode = require("./folding/cstyle").FoldMode; + + var Mode = function () { + this.HighlightRules = scryptHighlightRules; + this.foldingRules = new FoldMode(); + }; + oop.inherits(Mode, TextMode); + + (function () { + this.lineCommentStart = "//"; + this.blockComment = { start: "/*", end: "*/" }; + this.$quotes = { '"': '"', "'": "'" }; + + this.createWorker = function (session) { + + return null; + }; + + + this.$id = "ace/mode/scrypt"; + }).call(Mode.prototype); + + exports.Mode = Mode; +}); (function() { + window.require(["ace/mode/scrypt"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-sh.js b/htdocs/includes/ace/src/mode-sh.js index db130f99563..56df9c69694 100644 --- a/htdocs/includes/ace/src/mode-sh.js +++ b/htdocs/includes/ace/src/mode-sh.js @@ -435,6 +435,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/sh"; + this.snippetFileId = "ace/snippets/sh"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-sjs.js b/htdocs/includes/ace/src/mode-sjs.js index 218cab19b44..93855df3cee 100644 --- a/htdocs/includes/ace/src/mode-sjs.js +++ b/htdocs/includes/ace/src/mode-sjs.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-slim.js b/htdocs/includes/ace/src/mode-slim.js index 7f243bde705..85d09c8693d 100644 --- a/htdocs/includes/ace/src/mode-slim.js +++ b/htdocs/includes/ace/src/mode-slim.js @@ -990,6 +990,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2192,6 +2193,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2745,6 +2747,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -3330,6 +3333,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/sh"; + this.snippetFileId = "ace/snippets/sh"; }).call(Mode.prototype); exports.Mode = Mode; @@ -3382,6 +3386,7 @@ oop.inherits(Mode, TextMode); } }; this.$id = "ace/mode/markdown"; + this.snippetFileId = "ace/snippets/markdown"; }).call(Mode.prototype); exports.Mode = Mode; @@ -3734,6 +3739,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/coffee"; + this.snippetFileId = "ace/snippets/coffee"; }).call(Mode.prototype); exports.Mode = Mode; @@ -4247,17 +4253,17 @@ var constantOtherSymbol = exports.constantOtherSymbol = { regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?" }; -var qString = exports.qString = { +exports.qString = { token : "string", // single line regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }; -var qqString = exports.qqString = { +exports.qqString = { token : "string", // single line regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }; -var tString = exports.tString = { +exports.tString = { token : "string", // backtick string regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]" }; @@ -4267,9 +4273,34 @@ var constantNumericHex = exports.constantNumericHex = { regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b" }; +var constantNumericBinary = exports.constantNumericBinary = { + token: "constant.numeric", + regex: /\b(0[bB][01](?:[01]|_(?=[01]))*)\b/ +}; + +var constantNumericDecimal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[dD](?:[1-9](?:[\d]|_(?=[\d]))*|0))\b/ +}; + +var constantNumericOctal = exports.constantNumericDecimal = { + token: "constant.numeric", + regex: /\b(0[oO]?(?:[1-7](?:[0-7]|_(?=[0-7]))*|0))\b/ +}; + +var constantNumericRational = exports.constantNumericRational = { + token: "constant.numeric", //rational + complex + regex: /\b([\d]+(?:[./][\d]+)?ri?)\b/ +}; + +var constantNumericComplex = exports.constantNumericComplex = { + token: "constant.numeric", //simple complex numbers + regex: /\b([\d]i)\b/ +}; + var constantNumericFloat = exports.constantNumericFloat = { - token : "constant.numeric", // float - regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b" + token : "constant.numeric", // float + complex + regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?i?\\b" }; var instanceVariable = exports.instanceVariable = { @@ -4309,18 +4340,19 @@ var RubyHighlightRules = function() { "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" + "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" + "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" + - "has_many|has_one|belongs_to|has_and_belongs_to_many" + "has_many|has_one|belongs_to|has_and_belongs_to_many|p|warn|refine|using|module_function|extend|alias_method|" + + "private_class_method|remove_method|undef_method" ); var keywords = ( "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" + "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" + - "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield" + "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield|__ENCODING__|prepend" ); var buildinConstants = ( "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" + - "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING" + "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING|RUBY_PATCHLEVEL|RUBY_REVISION|RUBY_COPYRIGHT|RUBY_ENGINE|RUBY_ENGINE_VERSION|RUBY_DESCRIPTION" ); var builtinVariables = ( @@ -4336,126 +4368,191 @@ var RubyHighlightRules = function() { "invalid.deprecated": "debugger" // TODO is this a remnant from js mode? }, "identifier"); + var escapedChars = "\\\\(?:n(?:[1-7][0-7]{0,2}|0)|[nsrtvfbae'\"\\\\]|c(?:\\\\M-)?.|M-(?:\\\\C-|\\\\c)?.|C-(?:\\\\M-)?.|[0-7]{3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|u{[\\da-fA-F]{1,6}(?:\\s[\\da-fA-F]{1,6})*})"; + + var closeParen = { + "(": ")", + "[": "]", + "{": "}", + "<": ">", + "^": "^", + "|": "|", + "%": "%" + }; + this.$rules = { - "start" : [ + "start": [ { - token : "comment", - regex : "#.*$" + token: "comment", + regex: "#.*$" }, { - token : "comment", // multi line comment - regex : "^=begin(?:$|\\s.*$)", - next : "comment" + token: "comment.multiline", // multi line comment + regex: "^=begin(?=$|\\s.*$)", + next: "comment" }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + token: "string.regexp", + regex: /[/](?=.*\/)/, + next: "regex" }, [{ - regex: "[{}]", onMatch: function(val, state, stack) { - this.next = val == "{" ? this.nextState : ""; - if (val == "{" && stack.length) { - stack.unshift("start", state); - return "paren.lparen"; - } - if (val == "}" && stack.length) { - stack.shift(); - this.next = stack.shift(); - if (this.next.indexOf("string") != -1) - return "paren.end"; - } - return val == "{" ? "paren.lparen" : "paren.rparen"; - }, - nextState: "start" - }, { - token : "string.start", - regex : /"/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(")/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /"/, - next : "pop" + token: "string.end", + regex: /"/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /`/, - push : [{ - token : "constant.language.escape", - regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/ + token: "string.start", + regex: /`/, + push: [{ + token: "constant.language.escape", + regex: escapedChars }, { - token : "paren.start", - regex : /#{/, - push : "start" + token: "paren.start", + regex: /#{/, + push: "start" }, { - token : "string.end", - regex : /`/, - next : "pop" + token: "string.end", + regex: /`/, + next: "pop" }, { defaultToken: "string" }] }, { - token : "string.start", - regex : /'/, - push : [{ - token : "constant.language.escape", - regex : /\\['\\]/ - }, { - token : "string.end", - regex : /'/, - next : "pop" + token: ["constant.other.symbol.ruby", "string.start"], + regex: /(:)?(')/, + push: [{ + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "string.end", + regex: /'/, + next: "pop" }, { defaultToken: "string" }] + }, { + token: "string.start",//doesn't see any differences between strings and array of strings in highlighting + regex: /%[qwx]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithoutInterpolation"; + return this.token; + } + }, { + token: "string.start", //doesn't see any differences between strings and array of strings in highlighting + regex: /%[QWX]?([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "qStateWithInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[si]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithoutInterpolation"; + return this.token; + } + }, { + token: "constant.other.symbol.ruby", //doesn't see any differences between symbols and array of symbols in highlighting + regex: /%[SI]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "sStateWithInterpolation"; + return this.token; + } + }, { + token: "string.regexp", + regex: /%[r]([(\[<{^|%])/, onMatch: function (val, state, stack) { + if (stack.length) + stack = []; + var paren = val[val.length - 1]; + stack.unshift(paren, state); + this.next = "rState"; + return this.token; + } }], { - token : "text", // namespaces aren't symbols - regex : "::" + token: "punctuation", // namespaces aren't symbols + regex: "::" + }, + instanceVariable, + { + token: "variable.global", // global variable + regex: "[$][a-zA-Z_\\d]+" }, { - token : "variable.instance", // instance variable - regex : "@{1,2}[a-zA-Z_\\d]+" + token: "support.class", // class name + regex: "[A-Z][a-zA-Z_\\d]*" }, { - token : "support.class", // class name - regex : "[A-Z][a-zA-Z_\\d]+" + token: ["punctuation.operator", "support.function"], + regex: /(\.)([a-zA-Z_\d]+)(?=\()/ + }, { + token: ["punctuation.operator", "identifier"], + regex: /(\.)([a-zA-Z_][a-zA-Z_\d]*)/ + }, { + token: "string.character", + regex: "\\B\\?(?:" + escapedChars + "|\\S)" + }, { + token: "punctuation.operator", + regex: /\?(?=.+:)/ }, + constantNumericRational, + constantNumericComplex, constantOtherSymbol, constantNumericHex, constantNumericFloat, - + constantNumericBinary, + constantNumericDecimal, + constantNumericOctal, { - token : "constant.language.boolean", - regex : "(?:true|false)\\b" + token: "constant.language.boolean", + regex: "(?:true|false)\\b" }, { - token : keywordMapper, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + token: keywordMapper, + regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { - token : "punctuation.separator.key-value", - regex : "=>" + token: "punctuation.separator.key-value", + regex: "=>" }, { stateName: "heredoc", - onMatch : function(value, currentState, stack) { - var next = value[2] == '-' ? "indentedHeredoc" : "heredoc"; + onMatch: function (value, currentState, stack) { + var next = (value[2] == '-' || value[2] == '~') ? "indentedHeredoc" : "heredoc"; var tokens = value.split(this.splitRegex); stack.push(next, tokens[3]); return [ - {type:"constant", value: tokens[1]}, - {type:"string", value: tokens[2]}, - {type:"support.class", value: tokens[3]}, - {type:"string", value: tokens[4]} + {type: "constant", value: tokens[1]}, + {type: "string", value: tokens[2]}, + {type: "support.class", value: tokens[3]}, + {type: "string", value: tokens[4]} ]; }, - regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)", + regex: "(<<[-~]?)(['\"`]?)([\\w]+)(['\"`]?)", rules: { heredoc: [{ - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -4472,7 +4569,7 @@ var RubyHighlightRules = function() { token: "string", regex: "^ +" }, { - onMatch: function(value, currentState, stack) { + onMatch: function(value, currentState, stack) { if (value === stack[1]) { stack.shift(); stack.shift(); @@ -4487,38 +4584,261 @@ var RubyHighlightRules = function() { }] } }, { - regex : "$", - token : "empty", - next : function(currentState, stack) { + regex: "$", + token: "empty", + next: function(currentState, stack) { if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc") return stack[0]; return currentState; } + }, { + token: "keyword.operator", + regex: "!|\\$|%|&|\\*|/|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\||\\b(?:in|instanceof|new|delete|typeof|void)" }, { - token : "string.character", - regex : "\\B\\?." + token: "paren.lparen", + regex: "[[({]" }, { - token : "keyword.operator", - regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + token: "paren.rparen", + regex: "[\\])}]", + onMatch: function(value, currentState, stack) { + this.next = ''; + if (value == "}" && stack.length > 1 && stack[1] != "start") { + stack.shift(); + this.next = stack.shift(); + } + return this.token; + } }, { - token : "paren.lparen", - regex : "[[({]" + token: "text", + regex: "\\s+" }, { - token : "paren.rparen", - regex : "[\\])}]" - }, { - token : "text", - regex : "\\s+" + token: "punctuation.operator", + regex: /[?:,;.]/ } ], - "comment" : [ + "comment": [ { - token : "comment", // closing comment - regex : "^=end(?:$|\\s.*$)", - next : "start" + token: "comment.multiline", // closing comment + regex: "^=end(?=$|\\s.*$)", + next: "start" }, { - token : "comment", // comment spanning whole line - regex : ".+" + token: "comment", // comment spanning whole line + regex: ".+" + } + ], + "qStateWithInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "qStateWithoutInterpolation": [{ + token: "string.start",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "string"; + } + }, { + token: "constant.language.escape", + regex: /\\['\\]/ + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "string.end", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "string"; + } + }, { + defaultToken: "string" + }], + "sStateWithoutInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "sStateWithInterpolation": [{ + token: "constant.other.symbol.ruby",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.other.symbol.ruby"; + } + }, { + token: "constant.language.escape", + regex: escapedChars + }, { + token: "constant.language.escape", + regex: /\\./ + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "constant.other.symbol.ruby", + regex: /[)\]>}^|%]/, onMatch: function (val, state, stack) { + if (stack.length && val === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.other.symbol.ruby"; + } + }, { + defaultToken: "constant.other.symbol.ruby" + }], + "rState": [{ + token: "string.regexp",// excluded nested |^% due to difficulty in realization + regex: /[(\[<{]/, onMatch: function (val, state, stack) { + if (stack.length && val === stack[0]) { + stack.unshift(val, state); + return this.token; + } + return "constant.language.escape"; + } + }, { + token: "paren.start", + regex: /#{/, + push: "start" + }, { + token: "string.regexp", + regex: /\// + }, { + token: "string.regexp", + regex: /[)\]>}^|%][imxouesn]*/, onMatch: function (val, state, stack) { + if (stack.length && val[0] === closeParen[stack[0]]) { + stack.shift(); + this.next = stack.shift(); + return this.token; + } + this.next = ''; + return "constant.language.escape"; + } + }, + {include: "regex"}, + { + defaultToken: "string.regexp" + }], + "regex": [ + {// character classes + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "constant.language.escape", + regex: /\\[AGbBzZ]/ + }, { + token: "constant.language.escape", + regex: /\\g<[a-zA-Z0-9]*>/ + }, { + token: ["constant.language.escape", "regexp.keyword", "constant.language.escape"], + regex: /(\\p{\^?)(Alnum|Alpha|Blank|Cntrl|Digit|Graph|Lower|Print|Punct|Space|Upper|XDigit|Word|ASCII|Any|Assigned|Arabic|Armenian|Balinese|Bengali|Bopomofo|Braille|Buginese|Buhid|Canadian_Aboriginal|Carian|Cham|Cherokee|Common|Coptic|Cuneiform|Cypriot|Cyrillic|Deseret|Devanagari|Ethiopic|Georgian|Glagolitic|Gothic|Greek|Gujarati|Gurmukhi|Han|Hangul|Hanunoo|Hebrew|Hiragana|Inherited|Kannada|Katakana|Kayah_Li|Kharoshthi|Khmer|Lao|Latin|Lepcha|Limbu|Linear_B|Lycian|Lydian|Malayalam|Mongolian|Myanmar|New_Tai_Lue|Nko|Ogham|Ol_Chiki|Old_Italic|Old_Persian|Oriya|Osmanya|Phags_Pa|Phoenician|Rejang|Runic|Saurashtra|Shavian|Sinhala|Sundanese|Syloti_Nagri|Syriac|Tagalog|Tagbanwa|Tai_Le|Tamil|Telugu|Thaana|Thai|Tibetan|Tifinagh|Ugaritic|Vai|Yi|Ll|Lm|Lt|Lu|Lo|Mn|Mc|Me|Nd|Nl|Pc|Pd|Ps|Pe|Pi|Pf|Po|No|Sm|Sc|Sk|So|Zs|Zl|Zp|Cc|Cf|Cn|Co|Cs|N|L|M|P|S|Z|C)(})/ + }, { + token: ["constant.language.escape", "invalid", "constant.language.escape"], + regex: /(\\p{\^?)([^/]*)(})/ + }, {// escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, {// flag + token: "string.regexp", + regex: /[/][imxouesn]*/, + next: "start" + }, {// invalid operators + token: "invalid", + regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ + }, {// operators + token: "constant.language.escape", + regex: /\(\?(?:[:=!>]|<'?[a-zA-Z]*'?>|<[=!])|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ + }, { + token: "constant.language.delimiter", + regex: /\|/ + }, { + token: "regexp.keyword", + regex: /\[\[:(?:alnum|alpha|blank|cntrl|digit|graph|lower|print|punct|space|upper|xdigit|word|ascii):\]\]/ + }, { + token: "constant.language.escape", + regex: /\[\^?/, + push: "regex_character_class" + }, { + defaultToken: "string.regexp" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword", + regex: /\\[wWdDhHsS]/ + }, { + token: "regexp.charclass.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: /&?&?\[\^?/, + push: "regex_character_class" + }, { + token: "constant.language.escape", + regex: "]", + next: "pop" + }, { + token: "constant.language.escape", + regex: "-" + }, { + defaultToken: "string.regexp.characterclass" } ] }; @@ -4531,7 +4851,271 @@ oop.inherits(RubyHighlightRules, TextHighlightRules); exports.RubyHighlightRules = RubyHighlightRules; }); -define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module) { +define("ace/mode/folding/ruby",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function (require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; +var Range = require("../../range").Range; +var TokenIterator = require("../../token_iterator").TokenIterator; + + +var FoldMode = exports.FoldMode = function () { +}; + +oop.inherits(FoldMode, BaseFoldMode); + +(function () { + this.indentKeywords = { + "class": 1, + "def": 1, + "module": 1, + "do": 1, + "unless": 1, + "if": 1, + "while": 1, + "for": 1, + "until": 1, + "begin": 1, + "else": 0, + "elsif": 0, + "rescue": 0, + "ensure": 0, + "when": 0, + "end": -1, + "case": 1, + "=begin": 1, + "=end": -1 + }; + + this.foldingStartMarker = /(?:\s|^)(def|do|while|class|unless|module|if|for|until|begin|else|elsif|case|rescue|ensure|when)\b|({\s*$)|(=begin)/; + this.foldingStopMarker = /(=end(?=$|\s.*$))|(^\s*})|\b(end)\b/; + + this.getFoldWidget = function (session, foldStyle, row) { + var line = session.getLine(row); + var isStart = this.foldingStartMarker.test(line); + var isEnd = this.foldingStopMarker.test(line); + + if (isStart && !isEnd) { + var match = line.match(this.foldingStartMarker); + if (match[1]) { + if (match[1] == "if" || match[1] == "else" || match[1] == "while" || match[1] == "until" || match[1] == "unless") { + if (match[1] == "else" && /^\s*else\s*$/.test(line) === false) { + return; + } + if (/^\s*(?:if|else|while|until|unless)\s*/.test(line) === false) { + return; + } + } + + if (match[1] == "when") { + if (/\sthen\s/.test(line) === true) { + return; + } + } + if (session.getTokenAt(row, match.index + 2).type === "keyword") + return "start"; + } else if (match[3]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "start"; + } else { + return "start"; + } + } + if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd) + return ""; + + var match = line.match(this.foldingStopMarker); + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return "end"; + } else if (match[1]) { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return "end"; + } else + return "end"; + }; + + this.getFoldWidgetRange = function (session, foldStyle, row) { + var line = session.doc.getLine(row); + var match = this.foldingStartMarker.exec(line); + if (match) { + if (match[1] || match[3]) + return this.rubyBlock(session, row, match.index + 2); + + return this.openingBracketBlock(session, "{", row, match.index); + } + + var match = this.foldingStopMarker.exec(line); + if (match) { + if (match[3] === "end") { + if (session.getTokenAt(row, match.index + 1).type === "keyword") + return this.rubyBlock(session, row, match.index + 1); + } + + if (match[1] === "=end") { + if (session.getTokenAt(row, match.index + 1).type === "comment.multiline") + return this.rubyBlock(session, row, match.index + 1); + } + + return this.closingBracketBlock(session, "}", row, match.index + match[0].length); + } + }; + + this.rubyBlock = function (session, row, column, tokenRange) { + var stream = new TokenIterator(session, row, column); + + var token = stream.getCurrentToken(); + if (!token || (token.type != "keyword" && token.type != "comment.multiline")) + return; + + var val = token.value; + var line = session.getLine(row); + switch (token.value) { + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + return; + } + var dir = this.indentKeywords[val]; + break; + case "when": + if (/\sthen\s/.test(line)) { + return; + } + case "elsif": + case "rescue": + case "ensure": + var dir = 1; + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line)) { + return; + } + var dir = 1; + break; + default: + var dir = this.indentKeywords[val]; + break; + } + + var stack = [val]; + if (!dir) + return; + + var startColumn = dir === -1 ? session.getLine(row - 1).length : session.getLine(row).length; + var startRow = row; + var ranges = []; + ranges.push(stream.getCurrentTokenRange()); + + stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; + if (token.type == "comment.multiline") { + while (token = stream.step()) { + if (token.type !== "comment.multiline") + continue; + if (dir == 1) { + startColumn = 6; + if (token.value == "=end") { + break; + } + } else { + if (token.value == "=begin") { + break; + } + } + } + } else { + while (token = stream.step()) { + var ignore = false; + if (token.type !== "keyword") + continue; + var level = dir * this.indentKeywords[token.value]; + line = session.getLine(stream.getCurrentTokenRow()); + switch (token.value) { + case "do": + for (var i = stream.$tokenIndex - 1; i >= 0; i--) { + var prevToken = stream.$rowTokens[i]; + if (prevToken && (prevToken.value == "while" || prevToken.value == "until" || prevToken.value == "for")) { + level = 0; + break; + } + } + break; + case "else": + var checkToken = new RegExp("^\\s*" + token.value + "\\s*$"); + if (!checkToken.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + case "if": + case "unless": + case "while": + case "until": + var checkToken = new RegExp("^\\s*" + token.value); + if (!checkToken.test(line)) { + level = 0; + ignore = true; + } + break; + case "when": + if (/\sthen\s/.test(line) || val == "case") { + level = 0; + ignore = true; + } + break; + } + + if (level > 0) { + stack.unshift(token.value); + } else if (level <= 0 && ignore === false) { + stack.shift(); + if (!stack.length) { + if ((val == "while" || val == "until" || val == "for") && token.value != "do") { + break; + } + if (token.value == "do" && dir == -1 && level != 0) + break; + if (token.value != "do") + break; + } + + if (level === 0) { + stack.unshift(token.value); + } + } + } + } + + if (!token) + return null; + + if (tokenRange) { + ranges.push(stream.getCurrentTokenRange()); + return ranges; + } + + var row = stream.getCurrentTokenRow(); + if (dir === -1) { + if (token.type === "comment.multiline") { + var endColumn = 6; + } else { + var endColumn = session.getLine(row).length; + } + return new Range(row, endColumn, startRow - 1, startColumn); + } else + return new Range(startRow, startColumn, row - 1, session.getLine(row - 1).length); + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/ruby"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); @@ -4540,13 +5124,14 @@ var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; -var FoldMode = require("./folding/coffee").FoldMode; +var FoldMode = require("./folding/ruby").FoldMode; var Mode = function() { this.HighlightRules = RubyHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new FoldMode(); + this.indentKeywords = this.foldingRules.indentKeywords; }; oop.inherits(Mode, TextMode); @@ -4561,7 +5146,7 @@ oop.inherits(Mode, TextMode); var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokens = tokenizedLine.tokens; - if (tokens.length && tokens[tokens.length-1].type == "comment") { + if (tokens.length && tokens[tokens.length - 1].type == "comment") { return indent; } @@ -4569,7 +5154,7 @@ oop.inherits(Mode, TextMode); var match = line.match(/^.*[\{\(\[]\s*$/); var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/); var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/); - var startingConditional = line.match(/^\s*(if|else|when)\s*/); + var startingConditional = line.match(/^\s*(if|else|when|elsif|unless|while|for|begin|rescue|ensure)\s*/); if (match || startingClassOrMethod || startingDoBlock || startingConditional) { indent += tab; } @@ -4579,7 +5164,7 @@ oop.inherits(Mode, TextMode); }; this.checkOutdent = function(state, line, input) { - return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input); + return /^\s+(end|else|rescue|ensure)$/.test(line + input) || this.$outdent.checkOutdent(line, input); }; this.autoOutdent = function(state, session, row) { @@ -4592,11 +5177,24 @@ oop.inherits(Mode, TextMode); var tab = session.getTabString(); if (prevIndent.length <= indent.length) { if (indent.slice(-tab.length) == tab) - session.remove(new Range(row, indent.length-tab.length, row, indent.length)); + session.remove(new Range(row, indent.length - tab.length, row, indent.length)); } }; + this.getMatching = function(session, row, column) { + if (row == undefined) { + var pos = session.selection.lead; + column = pos.column; + row = pos.row; + } + + var startToken = session.getTokenAt(row, column); + if (startToken && startToken.value in this.indentKeywords) + return this.foldingRules.rubyBlock(session, row, column, true); + }; + this.$id = "ace/mode/ruby"; + this.snippetFileId = "ace/snippets/ruby"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-smarty.js b/htdocs/includes/ace/src/mode-smarty.js index 8c044c1698b..03a1654ffac 100644 --- a/htdocs/includes/ace/src/mode-smarty.js +++ b/htdocs/includes/ace/src/mode-smarty.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-smithy.js b/htdocs/includes/ace/src/mode-smithy.js new file mode 100644 index 00000000000..6dd0bcfaa81 --- /dev/null +++ b/htdocs/includes/ace/src/mode-smithy.js @@ -0,0 +1,507 @@ +define("ace/mode/smithy_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var SmithyHighlightRules = function() { + + this.$rules = { + start: [{ + include: "#comment" + }, { + token: [ + "meta.keyword.statement.smithy", + "variable.other.smithy", + "text", + "keyword.operator.smithy" + ], + regex: /^(\$)(\s+.+)(\s*)(=)/ + }, { + token: [ + "keyword.statement.smithy", + "text", + "entity.name.type.namespace.smithy" + ], + regex: /^(namespace)(\s+)([A-Z-a-z0-9_\.#$-]+)/ + }, { + token: [ + "keyword.statement.smithy", + "text", + "keyword.statement.smithy", + "text", + "entity.name.type.smithy" + ], + regex: /^(use)(\s+)(shape|trait)(\s+)([A-Z-a-z0-9_\.#$-]+)\b/ + }, { + token: [ + "keyword.statement.smithy", + "variable.other.smithy", + "text", + "keyword.operator.smithy" + ], + regex: /^(metadata)(\s+.+)(\s*)(=)/ + }, { + token: [ + "keyword.statement.smithy", + "text", + "entity.name.type.smithy" + ], + regex: /^(apply|byte|short|integer|long|float|double|bigInteger|bigDecimal|boolean|blob|string|timestamp|service|resource|trait|list|map|set|structure|union|document)(\s+)([A-Z-a-z0-9_\.#$-]+)\b/ + }, { + token: [ + "keyword.operator.smithy", + "text", + "entity.name.type.smithy", + "text", + "text", + "support.function.smithy", + "text", + "text", + "support.function.smithy" + ], + regex: /^(operation)(\s+)([A-Z-a-z0-9_\.#$-]+)(\(.*\))(?:(\s*)(->)(\s*[A-Z-a-z0-9_\.#$-]+))?(?:(\s+)(errors))?/ + }, { + include: "#trait" + }, { + token: [ + "support.type.property-name.smithy", + "punctuation.separator.dictionary.pair.smithy" + ], + regex: /([A-Z-a-z0-9_\.#$-]+)(:)/ + }, { + include: "#value" + }, { + token: "keyword.other.smithy", + regex: /\->/ + }], + "#comment": [{ + include: "#doc_comment" + }, { + include: "#line_comment" + }], + "#doc_comment": [{ + token: "comment.block.documentation.smithy", + regex: /\/\/\/.*/ + }], + "#line_comment": [{ + token: "comment.line.double-slash.smithy", + regex: /\/\/.*/ + }], + "#trait": [{ + token: [ + "punctuation.definition.annotation.smithy", + "storage.type.annotation.smithy" + ], + regex: /(@)([0-9a-zA-Z\.#-]+)/ + }, { + token: [ + "punctuation.definition.annotation.smithy", + "punctuation.definition.object.end.smithy", + "meta.structure.smithy" + ], + regex: /(@)([0-9a-zA-Z\.#-]+)(\()/, + push: [{ + token: "punctuation.definition.object.end.smithy", + regex: /\)/, + next: "pop" + }, { + include: "#value" + }, { + include: "#object_inner" + }, { + defaultToken: "meta.structure.smithy" + }] + }], + "#value": [{ + include: "#constant" + }, { + include: "#number" + }, { + include: "#string" + }, { + include: "#array" + }, { + include: "#object" + }], + "#array": [{ + token: "punctuation.definition.array.begin.smithy", + regex: /\[/, + push: [{ + token: "punctuation.definition.array.end.smithy", + regex: /\]/, + next: "pop" + }, { + include: "#comment" + }, { + include: "#value" + }, { + token: "punctuation.separator.array.smithy", + regex: /,/ + }, { + token: "invalid.illegal.expected-array-separator.smithy", + regex: /[^\s\]]/ + }, { + defaultToken: "meta.structure.array.smithy" + }] + }], + "#constant": [{ + token: "constant.language.smithy", + regex: /\b(?:true|false|null)\b/ + }], + "#number": [{ + token: "constant.numeric.smithy", + regex: /-?(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:[eE][+-]?\d+)?)?/ + }], + "#object": [{ + token: "punctuation.definition.dictionary.begin.smithy", + regex: /\{/, + push: [{ + token: "punctuation.definition.dictionary.end.smithy", + regex: /\}/, + next: "pop" + }, { + include: "#trait" + }, { + include: "#object_inner" + }, { + defaultToken: "meta.structure.dictionary.smithy" + }] + }], + "#object_inner": [{ + include: "#comment" + }, { + include: "#string_key" + }, { + token: "punctuation.separator.dictionary.key-value.smithy", + regex: /:/, + push: [{ + token: "punctuation.separator.dictionary.pair.smithy", + regex: /,|(?=\})/, + next: "pop" + }, { + include: "#value" + }, { + token: "invalid.illegal.expected-dictionary-separator.smithy", + regex: /[^\s,]/ + }, { + defaultToken: "meta.structure.dictionary.value.smithy" + }] + }, { + token: "invalid.illegal.expected-dictionary-separator.smithy", + regex: /[^\s\}]/ + }], + "#string_key": [{ + include: "#identifier_key" + }, { + include: "#dquote_key" + }, { + include: "#squote_key" + }], + "#identifier_key": [{ + token: "support.type.property-name.smithy", + regex: /[A-Z-a-z0-9_\.#$-]+/ + }], + "#dquote_key": [{ + include: "#dquote" + }], + "#squote_key": [{ + include: "#squote" + }], + "#string": [{ + include: "#textblock" + }, { + include: "#dquote" + }, { + include: "#squote" + }, { + include: "#identifier" + }], + "#textblock": [{ + token: "punctuation.definition.string.begin.smithy", + regex: /"""/, + push: [{ + token: "punctuation.definition.string.end.smithy", + regex: /"""/, + next: "pop" + }, { + token: "constant.character.escape.smithy", + regex: /\\./ + }, { + defaultToken: "string.quoted.double.smithy" + }] + }], + "#dquote": [{ + token: "punctuation.definition.string.begin.smithy", + regex: /"/, + push: [{ + token: "punctuation.definition.string.end.smithy", + regex: /"/, + next: "pop" + }, { + token: "constant.character.escape.smithy", + regex: /\\./ + }, { + defaultToken: "string.quoted.double.smithy" + }] + }], + "#squote": [{ + token: "punctuation.definition.string.begin.smithy", + regex: /'/, + push: [{ + token: "punctuation.definition.string.end.smithy", + regex: /'/, + next: "pop" + }, { + token: "constant.character.escape.smithy", + regex: /\\./ + }, { + defaultToken: "string.quoted.single.smithy" + }] + }], + "#identifier": [{ + token: "storage.type.smithy", + regex: /[A-Z-a-z_][A-Z-a-z0-9_\.#$-]*/ + }] + }; + + this.normalizeRules(); +}; + +SmithyHighlightRules.metaData = { + name: "Smithy", + fileTypes: ["smithy"], + scopeName: "source.smithy", + foldingStartMarker: "(\\{|\\[)\\s*", + foldingStopMarker: "\\s*(\\}|\\])" +}; + + +oop.inherits(SmithyHighlightRules, TextHighlightRules); + +exports.SmithyHighlightRules = SmithyHighlightRules; +}); + +define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) { +"use strict"; + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + return line.match(/^\s*/)[0]; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/smithy",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/smithy_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var SmithyHighlightRules = require("./smithy_highlight_rules").SmithyHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = SmithyHighlightRules; + + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "//"; + this.$quotes = {'"': '"'}; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.$id = "ace/mode/smithy"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); (function() { + window.require(["ace/mode/smithy"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/mode-snippets.js b/htdocs/includes/ace/src/mode-snippets.js index 600463bf3e5..32276191d16 100644 --- a/htdocs/includes/ace/src/mode-snippets.js +++ b/htdocs/includes/ace/src/mode-snippets.js @@ -192,6 +192,7 @@ oop.inherits(Mode, TextMode); this.$indentWithTabs = true; this.lineCommentStart = "#"; this.$id = "ace/mode/snippets"; + this.snippetFileId = "ace/snippets/snippets"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-soy_template.js b/htdocs/includes/ace/src/mode-soy_template.js index 83b35c0c673..a9674ac5730 100644 --- a/htdocs/includes/ace/src/mode-soy_template.js +++ b/htdocs/includes/ace/src/mode-soy_template.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-sql.js b/htdocs/includes/ace/src/mode-sql.js index 77ba37a8ed1..3bb9e83b7af 100644 --- a/htdocs/includes/ace/src/mode-sql.js +++ b/htdocs/includes/ace/src/mode-sql.js @@ -78,15 +78,174 @@ oop.inherits(SqlHighlightRules, TextHighlightRules); exports.SqlHighlightRules = SqlHighlightRules; }); -define("ace/mode/sql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sql_highlight_rules"], function(require, exports, module) { +define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(commentRegex) { + if (commentRegex) { + this.foldingStartMarker = new RegExp( + this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) + ); + this.foldingStopMarker = new RegExp( + this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) + ); + } +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; + this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; + this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; + this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; + this._getFoldWidgetBase = this.getFoldWidget; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + + if (this.singleLineBlockCommentRe.test(line)) { + if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) + return ""; + } + + var fw = this._getFoldWidgetBase(session, foldStyle, row); + + if (!fw && this.startRegionRe.test(line)) + return "start"; // lineCommentRegionStart + + return fw; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { + var line = session.getLine(row); + + if (this.startRegionRe.test(line)) + return this.getCommentRegionBlock(session, line, row); + + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length, 1); + + if (range && !range.isMultiLine()) { + if (forceMultiline) { + range = this.getSectionRange(session, row); + } else if (foldStyle != "all") + range = null; + } + + return range; + } + + if (foldStyle === "markbegin") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[1]) + return this.closingBracketBlock(session, match[1], row, i); + + return session.getCommentFoldRange(row, i, -1); + } + }; + + this.getSectionRange = function(session, row) { + var line = session.getLine(row); + var startIndent = line.search(/\S/); + var startRow = row; + var startColumn = line.length; + row = row + 1; + var endRow = row; + var maxRow = session.getLength(); + while (++row < maxRow) { + line = session.getLine(row); + var indent = line.search(/\S/); + if (indent === -1) + continue; + if (startIndent > indent) + break; + var subRange = this.getFoldWidgetRange(session, "all", row); + + if (subRange) { + if (subRange.start.row <= startRow) { + break; + } else if (subRange.isMultiLine()) { + row = subRange.end.row; + } else if (startIndent == indent) { + break; + } + } + endRow = row; + } + + return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); + }; + this.getCommentRegionBlock = function(session, line, row) { + var startColumn = line.search(/\s*$/); + var maxRow = session.getLength(); + var startRow = row; + + var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; + var depth = 1; + while (++row < maxRow) { + line = session.getLine(row); + var m = re.exec(line); + if (!m) continue; + if (m[1]) depth--; + else depth++; + + if (!depth) break; + } + + var endRow = row; + if (endRow > startRow) { + return new Range(startRow, startColumn, endRow, line.length); + } + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/folding/sql",["require","exports","module","ace/lib/oop","ace/mode/folding/cstyle"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./cstyle").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; + +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/sql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sql_highlight_rules","ace/mode/folding/sql"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SqlHighlightRules = require("./sql_highlight_rules").SqlHighlightRules; +var SqlFoldMode = require("./folding/sql").FoldMode; var Mode = function() { this.HighlightRules = SqlHighlightRules; + this.foldingRules = new SqlFoldMode(); this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); @@ -94,8 +253,10 @@ oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "--"; + this.blockComment = {start: "/*", end: "*/"}; this.$id = "ace/mode/sql"; + this.snippetFileId = "ace/snippets/sql"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-sqlserver.js b/htdocs/includes/ace/src/mode-sqlserver.js index 41f53c3e598..69aa4384ff1 100644 --- a/htdocs/includes/ace/src/mode-sqlserver.js +++ b/htdocs/includes/ace/src/mode-sqlserver.js @@ -429,7 +429,8 @@ oop.inherits(Mode, TextMode); return session.$mode.$highlightRules.completions; }; - this.$id = "ace/mode/sql"; + this.$id = "ace/mode/sqlserver"; + this.snippetFileId = "ace/snippets/sqlserver"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-svg.js b/htdocs/includes/ace/src/mode-svg.js index 6dc3c60c6dd..d8e0358d1b5 100644 --- a/htdocs/includes/ace/src/mode-svg.js +++ b/htdocs/includes/ace/src/mode-svg.js @@ -1454,6 +1454,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-swift.js b/htdocs/includes/ace/src/mode-swift.js index b207deb7652..06644d6fdda 100644 --- a/htdocs/includes/ace/src/mode-swift.js +++ b/htdocs/includes/ace/src/mode-swift.js @@ -165,6 +165,12 @@ var SwiftHighlightRules = function() { this.$rules = { start: [ + string('"""', { + escape: /\\(?:[0\\tnr"']|u{[a-fA-F1-9]{0,8}})/, + interpolation: {lead: "\\", open: "(", close: ")"}, + error: /\\./, + multiline: true + }), string('"', { escape: /\\(?:[0\\tnr"']|u{[a-fA-F1-9]{0,8}})/, interpolation: {lead: "\\", open: "(", close: ")"}, diff --git a/htdocs/includes/ace/src/mode-tcl.js b/htdocs/includes/ace/src/mode-tcl.js index b898da9c528..632f928adbc 100644 --- a/htdocs/includes/ace/src/mode-tcl.js +++ b/htdocs/includes/ace/src/mode-tcl.js @@ -373,6 +373,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/tcl"; + this.snippetFileId = "ace/snippets/tcl"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-terraform.js b/htdocs/includes/ace/src/mode-terraform.js index 76e2cf2db63..bd252bc32b5 100644 --- a/htdocs/includes/ace/src/mode-terraform.js +++ b/htdocs/includes/ace/src/mode-terraform.js @@ -40,11 +40,15 @@ var TerraformHighlightRules = function () { { token: "singleline.comment.terraform", - regex: '#(.)*$' + regex: '#.*$' + }, + { + token: "singleline.comment.terraform", + regex: '//.*$' }, { token: "multiline.comment.begin.terraform", - regex: '^\\s*\\/\\*', + regex: /\/\*/, push: "blockComment" }, { @@ -66,11 +70,7 @@ var TerraformHighlightRules = function () { {include: "variables"} ], blockComment: [{ - regex: "^\\s*\\/\\*", - token: "multiline.comment.begin.terraform", - push: "blockComment" - }, { - regex: "\\*\\/\\s*$", + regex: /\*\//, token: "multiline.comment.end.terraform", next: "pop" }, { @@ -383,6 +383,9 @@ oop.inherits(Mode, TextMode); (function () { + this.lineCommentStart = ["#", "//"]; + this.blockComment = {start: "/*", end: "*/"}; + this.$id = "ace/mode/terraform"; }).call(Mode.prototype); diff --git a/htdocs/includes/ace/src/mode-tex.js b/htdocs/includes/ace/src/mode-tex.js index 22673ec6222..9b3fb3b3722 100644 --- a/htdocs/includes/ace/src/mode-tex.js +++ b/htdocs/includes/ace/src/mode-tex.js @@ -146,6 +146,7 @@ oop.inherits(Mode, TextMode); return false; }; this.$id = "ace/mode/tex"; + this.snippetFileId = "ace/snippets/tex"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-textile.js b/htdocs/includes/ace/src/mode-textile.js index 203bbbeb31a..8ce8ad64dfd 100644 --- a/htdocs/includes/ace/src/mode-textile.js +++ b/htdocs/includes/ace/src/mode-textile.js @@ -135,6 +135,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/textile"; + this.snippetFileId = "ace/snippets/textile"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-tsx.js b/htdocs/includes/ace/src/mode-tsx.js index b4292219847..2b5d18d632c 100644 --- a/htdocs/includes/ace/src/mode-tsx.js +++ b/htdocs/includes/ace/src/mode-tsx.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-twig.js b/htdocs/includes/ace/src/mode-twig.js index a7c3c2b4bd2..b5eac5b2b68 100644 --- a/htdocs/includes/ace/src/mode-twig.js +++ b/htdocs/includes/ace/src/mode-twig.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-typescript.js b/htdocs/includes/ace/src/mode-typescript.js index d4e8cdb3876..3bebbdaba3d 100644 --- a/htdocs/includes/ace/src/mode-typescript.js +++ b/htdocs/includes/ace/src/mode-typescript.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-vala.js b/htdocs/includes/ace/src/mode-vala.js index 5e51a584107..2fe15bac55d 100644 --- a/htdocs/includes/ace/src/mode-vala.js +++ b/htdocs/includes/ace/src/mode-vala.js @@ -663,6 +663,7 @@ oop.inherits(Mode, TextMode); this.$outdent.autoOutdent(doc, row); }; this.$id = "ace/mode/vala"; + this.snippetFileId = "ace/snippets/vala"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-vbscript.js b/htdocs/includes/ace/src/mode-vbscript.js index 482c2f95c96..19a3a002781 100644 --- a/htdocs/includes/ace/src/mode-vbscript.js +++ b/htdocs/includes/ace/src/mode-vbscript.js @@ -8,11 +8,13 @@ var VBScriptHighlightRules = function() { var keywordMapper = this.createKeywordMapper({ "keyword.control.asp": "If|Then|Else|ElseIf|End|While|Wend|For|To|Each|Case|Select|Return" - + "|Continue|Do|Until|Loop|Next|With|Exit|Function|Property|Type|Enum|Sub|IIf", - "storage.type.asp": "Dim|Call|Class|Const|Dim|Redim|Set|Let|Get|New|Randomize|Option|Explicit", + + "|Continue|Do|Until|Loop|Next|With|Exit|Function|Property|Type|Enum|Sub|IIf|Class", + "storage.type.asp": "Dim|Call|Const|Redim|Set|Let|Get|New|Randomize|Option|Explicit|Preserve|Erase|Execute|ExecuteGlobal", "storage.modifier.asp": "Private|Public|Default", - "keyword.operator.asp": "Mod|And|Not|Or|Xor|as", + "keyword.operator.asp": "Mod|And|Not|Or|Xor|As|Eqv|Imp|Is", "constant.language.asp": "Empty|False|Nothing|Null|True", + "variable.language.vb.asp": "Me", + "support.class.vb.asp": "RegExp", "support.class.asp": "Application|ObjectContext|Request|Response|Server|Session", "support.class.collection.asp": "Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables", "support.constant.asp": "TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute" @@ -30,13 +32,17 @@ var VBScriptHighlightRules = function() { + "|Trim|Maths|Mid|Minute|Month|MonthName|MsgBox|Now|Oct|Remove|RemoveAll|Replace" + "|RGB|Right|Rnd|Round|ScriptEngine|ScriptEngineBuildVersion|ScriptEngineMajorVersion" + "|ScriptEngineMinorVersion|Second|SetLocale|Sgn|Sin|Space|Split|Sqr|StrComp|String|StrReverse" - + "|Tan|Time|Timer|TimeSerial|TimeValue|TypeName|UBound|UCase|Unescape|VarType|Weekday|WeekdayName|Year", - "support.type.vb.asp": "vbtrue|vbfalse|vbcr|vbcrlf|vbformfeed|vblf|vbnewline|vbnullchar|vbnullstring|" - + "int32|vbtab|vbverticaltab|vbbinarycompare|vbtextcomparevbsunday|vbmonday|vbtuesday|vbwednesday" - + "|vbthursday|vbfriday|vbsaturday|vbusesystemdayofweek|vbfirstjan1|vbfirstfourdays|vbfirstfullweek" - + "|vbgeneraldate|vblongdate|vbshortdate|vblongtime|vbshorttime|vbobjecterror|vbEmpty|vbNull|vbInteger" + + "|Tan|Time|Timer|TimeSerial|TimeValue|TypeName|UBound|UCase|Unescape|VarType|Weekday|WeekdayName|Year" + + "|AscB|AscW|ChrB|ChrW|InStrB|LeftB|LenB|MidB|RightB|Abs|GetUILanguage", + "support.type.vb.asp": "vbTrue|vbFalse|vbCr|vbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString" + + "|vbTab|vbVerticalTab|vbBinaryCompare|vbTextCompare|vbSunday|vbMonday|vbTuesday|vbWednesday" + + "|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek|vbFirstJan1|vbFirstFourDays|vbFirstFullWeek" + + "|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime|vbObjectError|vbEmpty|vbNull|vbInteger" + "|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant" - + "|vbDataObject|vbDecimal|vbByte|vbArray" + + "|vbDataObject|vbDecimal|vbByte|vbArray|vbOKOnly|vbOKCancel|vbAbortRetryIgnore|vbYesNoCancel|vbYesNo" + + "|vbRetryCancel|vbCritical|vbQuestion|vbExclamation|vbInformation|vbDefaultButton1|vbDefaultButton2" + + "|vbDefaultButton3|vbDefaultButton4|vbApplicationModal|vbSystemModal|vbOK|vbCancel|vbAbort|vbRetry|vbIgnore|vbYes|vbNo" + + "|vbUseDefault" }, "identifier", true); this.$rules = { @@ -78,7 +84,7 @@ var VBScriptHighlightRules = function() { }, { token: "storage.type.asp", - regex: "On Error Resume Next|On Error GoTo", + regex: "On\\s+Error\\s+(?:Resume\\s+Next|GoTo)\\b", caseInsensitive: true }, { @@ -106,7 +112,7 @@ var VBScriptHighlightRules = function() { }, { token: ["keyword.operator.asp"], - regex: "\\-|\\+|\\*\\/|\\>|\\<|\\=|\\&" + regex: "\\-|\\+|\\*|\\/|\\>|\\<|\\=|\\&|\\\\|\\^" } ], "state_3": [ @@ -145,7 +151,7 @@ var VBScriptHighlightRules = function() { "comment": [ { token: "comment.line.apostrophe.asp", - regex: "$|(?=(?:%>))", + regex: "$", next: "start" }, { @@ -175,23 +181,446 @@ oop.inherits(VBScriptHighlightRules, TextHighlightRules); exports.VBScriptHighlightRules = VBScriptHighlightRules; }); -define("ace/mode/vbscript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/vbscript_highlight_rules"], function(require, exports, module) { +define("ace/mode/folding/vbscript",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; +var Range = require("../../range").Range; +var TokenIterator = require("../../token_iterator").TokenIterator; + + +var FoldMode = exports.FoldMode = function() {}; + +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + this.indentKeywords = { + "class": 1, + "function": 1, + "sub": 1, + "if": 1, + "select": 1, + "do": 1, + "for": 1, + "while": 1, + "with": 1, + "property": 1, + "else": 1, + "elseif": 1, + "end": -1, + "loop": -1, + "next": -1, + "wend": -1 + }; + + this.foldingStartMarker = /(?:\s|^)(class|function|sub|if|select|do|for|while|with|property|else|elseif)\b/i; + this.foldingStopMarker = /\b(end|loop|next|wend)\b/i; + + this.getFoldWidgetRange = function (session, foldStyle, row) { + var line = session.getLine(row); + var isStart = this.foldingStartMarker.test(line); + var isEnd = this.foldingStopMarker.test(line); + if (isStart || isEnd) { + var match = (isEnd) ? this.foldingStopMarker.exec(line) : this.foldingStartMarker.exec(line); + var keyword = match && match[1].toLowerCase(); + if (keyword) { + var type = session.getTokenAt(row, match.index + 2).type; + if (type === "keyword.control.asp" || type === "storage.type.function.asp") + return this.vbsBlock(session, row, match.index + 2); + } + } + }; + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + var isStart = this.foldingStartMarker.test(line); + var isEnd = this.foldingStopMarker.test(line); + if (isStart && !isEnd) { + var match = this.foldingStartMarker.exec(line); + var keyword = match && match[1].toLowerCase(); + if (keyword) { + var type = session.getTokenAt(row, match.index + 2).type; + if (type == "keyword.control.asp" || type == "storage.type.function.asp") { + if (keyword == "if" && !/then\s*('|$)/i.test(line)) + return ""; + return "start"; + } + } + } + return ""; + }; + + this.vbsBlock = function(session, row, column, tokenRange) { + var stream = new TokenIterator(session, row, column); + + var endOpenings = { + "class": 1, + "function": 1, + "sub": 1, + "if": 1, + "select": 1, + "with": 1, + "property": 1, + "else": 1, + "elseif": 1 + }; + + var token = stream.getCurrentToken(); + if (!token || (token.type != "keyword.control.asp" && token.type != "storage.type.function.asp")) + return; + + var startTokenValue = token.value.toLowerCase(); + var val = token.value.toLowerCase(); + + var stack = [val]; + var dir = this.indentKeywords[val]; + + if (!dir) + return; + + var firstRange = stream.getCurrentTokenRange(); + switch (val) { + case "property": + case "sub": + case "function": + case "if": + case "select": + case "do": + case "for": + case "class": + case "while": + case "with": + var line = session.getLine(row); + var singleLineCondition = /^\s*If\s+.*\s+Then(?!')\s+(?!')\S/i.test(line); + if (singleLineCondition) + return; + var checkToken = new RegExp("(?:^|\\s)" + val, "i"); + var endTest = /^\s*End\s(If|Sub|Select|Function|Class|With|Property)\s*/i.test(line); + if (!checkToken.test(line) && !endTest) { + return; + } + if (endTest) { + var tokenRange = stream.getCurrentTokenRange(); + stream.step = stream.stepBackward; + stream.step(); + stream.step(); + token = stream.getCurrentToken(); + if (token) { + val = token.value.toLowerCase(); + if (val == "end") { + firstRange = stream.getCurrentTokenRange(); + firstRange = new Range(firstRange.start.row, firstRange.start.column, tokenRange.start.row, tokenRange.end.column); + } + } + dir = -1; + } + break; + case "end": + var tokenPos = stream.getCurrentTokenPosition(); + firstRange = stream.getCurrentTokenRange(); + stream.step = stream.stepForward; + stream.step(); + stream.step(); + token = stream.getCurrentToken(); + if (token) { + val = token.value.toLowerCase(); + if (val in endOpenings) { + startTokenValue = val; + var nextTokenPos = stream.getCurrentTokenPosition(); + var endColumn = nextTokenPos.column + val.length; + firstRange = new Range(tokenPos.row, tokenPos.column, nextTokenPos.row, endColumn); + } + } + stream.step = stream.stepBackward; + stream.step(); + stream.step(); + break; + } + var startColumn = dir === -1 ? session.getLine(row - 1).length : session.getLine(row).length; + var startRow = row; + var ranges = []; + ranges.push(firstRange); + + stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; + while(token = stream.step()) { + var outputRange = null; + var ignore = false; + if (token.type != "keyword.control.asp" && token.type != "storage.type.function.asp") + continue; + val = token.value.toLowerCase(); + var level = dir * this.indentKeywords[val]; + + switch (val) { + case "property": + case "sub": + case "function": + case "if": + case "select": + case "do": + case "for": + case "class": + case "while": + case "with": + var line = session.getLine(stream.getCurrentTokenRow()); + var singleLineCondition = /^\s*If\s+.*\s+Then(?!')\s+(?!')\S/i.test(line); + if (singleLineCondition) { + level = 0; + ignore = true; + } + var checkToken = new RegExp("^\\s* end\\s+" + val, "i"); + if (checkToken.test(line)) { + level = 0; + ignore = true; + } + break; + case "elseif": + case "else": + level = 0; + if (startTokenValue != "elseif") { + ignore = true; + } + break; + } + + if (level > 0) { + stack.unshift(val); + } else if (level <= 0 && ignore === false) { + stack.shift(); + if (!stack.length) { + switch (val) { + case "end": + var tokenPos = stream.getCurrentTokenPosition(); + outputRange = stream.getCurrentTokenRange(); + stream.step(); + stream.step(); + token = stream.getCurrentToken(); + if (token) { + val = token.value.toLowerCase(); + if (val in endOpenings) { + if ((startTokenValue == "else" || startTokenValue == "elseif")) { + if (val !== "if") { + ranges.shift(); + } + } else { + if (val != startTokenValue) + ranges.shift(); + } + var nextTokenPos = stream.getCurrentTokenPosition(); + var endColumn = nextTokenPos.column + val.length; + outputRange = new Range(tokenPos.row, tokenPos.column, nextTokenPos.row, endColumn); + } else { + ranges.shift(); + } + } else { + ranges.shift(); + } + stream.step = stream.stepBackward; + stream.step(); + stream.step(); + token = stream.getCurrentToken(); + val = token.value.toLowerCase(); + break; + case "select": + case "sub": + case "if": + case "function": + case "class": + case "with": + case "property": + if (val != startTokenValue) + ranges.shift(); + break; + case "do": + if (startTokenValue != "loop") + ranges.shift(); + break; + case "loop": + if (startTokenValue != "do") + ranges.shift(); + break; + case "for": + if (startTokenValue != "next") + ranges.shift(); + break; + case "next": + if (startTokenValue != "for") + ranges.shift(); + break; + case "while": + if (startTokenValue != "wend") + ranges.shift(); + break; + case "wend": + if (startTokenValue != "while") + ranges.shift(); + break; + } + break; + } + + if (level === 0){ + stack.unshift(val); + } + } + } + + if (!token) + return null; + + if (tokenRange) { + if (!outputRange) { + ranges.push(stream.getCurrentTokenRange()); + } else { + ranges.push(outputRange); + } + return ranges; + } + + var row = stream.getCurrentTokenRow(); + if (dir === -1) { + var endColumn = session.getLine(row).length; + return new Range(row, endColumn, startRow - 1, startColumn); + } else + return new Range(startRow, startColumn, row - 1, session.getLine(row - 1).length); + }; + +}).call(FoldMode.prototype); + +}); + +define("ace/mode/vbscript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/vbscript_highlight_rules","ace/mode/folding/vbscript","ace/range"], function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var VBScriptHighlightRules = require("./vbscript_highlight_rules").VBScriptHighlightRules; +var FoldMode = require("./folding/vbscript").FoldMode; +var Range = require("../range").Range; var Mode = function() { this.HighlightRules = VBScriptHighlightRules; + this.foldingRules = new FoldMode(); this.$behaviour = this.$defaultBehaviour; + this.indentKeywords = this.foldingRules.indentKeywords; }; oop.inherits(Mode, TextMode); (function() { - + this.lineCommentStart = ["'", "REM"]; - + + var outdentKeywords = [ + "else", + "elseif", + "end", + "loop", + "next", + "wend" + ]; + + function getNetIndentLevel(tokens, line, indentKeywords) { + var level = 0; + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (token.type == "keyword.control.asp" || token.type == "storage.type.function.asp") { + var val = token.value.toLowerCase(); + if (val in indentKeywords) { + switch (val) { + case "property": + case "sub": + case "function": + case "select": + case "do": + case "for": + case "class": + case "while": + case "with": + case "if": + var checkToken = new RegExp("^\\s* end\\s+" + val, "i"); + var singleLineCondition = /^\s*If\s+.*\s+Then(?!')\s+(?!')\S/i.test(line); + if (!singleLineCondition && !checkToken.test(line)) + level += indentKeywords[val]; + break; + default: + level += indentKeywords[val]; + break; + } + } + } + } + if (level < 0) { + return -1; + } else if (level > 0) { + return 1; + } else { + return 0; + } + } + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var level = 0; + + var tokenizedLine = this.getTokenizer().getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (state == "start") { + level = getNetIndentLevel(tokens, line, this.indentKeywords); + } + if (level > 0) { + return indent + tab; + } else if (level < 0 && indent.substr(indent.length - tab.length) == tab) { + if (!this.checkOutdent(state, line, "\n")) { + return indent.substr(0, indent.length - tab.length); + } + } + return indent; + }; + + this.checkOutdent = function(state, line, input) { + if (input != "\n" && input != "\r" && input != "\r\n") + return false; + + var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens; + + if (!tokens || !tokens.length) + return false; + var val = tokens[0].value.toLowerCase(); + return ((tokens[0].type == "keyword.control.asp" || tokens[0].type == "storage.type.function.asp") && outdentKeywords.indexOf(val) != -1); + }; + + this.getMatching = function(session, row, column, tokenRange) { + if (row == undefined) { + var pos = session.selection.lead; + column = pos.column; + row = pos.row; + } + if (tokenRange == undefined) + tokenRange = true; + + var startToken = session.getTokenAt(row, column); + if (startToken) { + var val = startToken.value.toLowerCase(); + if (val in this.indentKeywords) + return this.foldingRules.vbsBlock(session, row, column, tokenRange); + } + }; + + this.autoOutdent = function(state, session, row) { + var line = session.getLine(row); + var column = line.match(/^\s*/)[0].length; + if (!column || !row) return; + + var startRange = this.getMatching(session, row, column + 1, false); + if (!startRange || startRange.start.row == row) + return; + var indent = this.$getIndent(session.getLine(startRange.start.row)); + if (indent.length != column) { + session.replace(new Range(row, 0, row, column), indent); + session.outdentRows(new Range(row + 1, 0, row + 1, 0)); + } + }; + this.$id = "ace/mode/vbscript"; }).call(Mode.prototype); diff --git a/htdocs/includes/ace/src/mode-velocity.js b/htdocs/includes/ace/src/mode-velocity.js index ea94a8fd9ad..98458db2d49 100644 --- a/htdocs/includes/ace/src/mode-velocity.js +++ b/htdocs/includes/ace/src/mode-velocity.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2775,6 +2778,7 @@ oop.inherits(Mode, HtmlMode); this.lineCommentStart = "##"; this.blockComment = {start: "#*", end: "*#"}; this.$id = "ace/mode/velocity"; + this.snippetFileId = "ace/snippets/velocity"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-vhdl.js b/htdocs/includes/ace/src/mode-vhdl.js index 75f22a1f512..d3e4ba6fd59 100644 --- a/htdocs/includes/ace/src/mode-vhdl.js +++ b/htdocs/includes/ace/src/mode-vhdl.js @@ -8,18 +8,21 @@ var VHDLHighlightRules = function() { - var keywords = "access|after|ailas|all|architecture|assert|attribute|"+ - "begin|block|buffer|bus|case|component|configuration|"+ - "disconnect|downto|else|elsif|end|entity|file|for|function|"+ - "generate|generic|guarded|if|impure|in|inertial|inout|is|"+ - "label|linkage|literal|loop|mapnew|next|of|on|open|others|"+ - "out|port|process|pure|range|record|reject|report|return|"+ - "select|severity|shared|signal|subtype|then|to|transport|"+ - "type|unaffected|united|until|wait|when|while|with"; + var keywords = "access|after|alias|all|architecture|assert|attribute|"+ + "begin|block|body|buffer|bus|case|component|configuration|"+ + "context|disconnect|downto|else|elsif|end|entity|exit|"+ + "file|for|force|function|generate|generic|group|guarded|"+ + "if|impure|in|inertial|inout|is|label|library|linkage|"+ + "literal|loop|map|new|next|of|on|or|open|others|out|"+ + "package|parameter|port|postponed|procedure|process|"+ + "protected|pure|range|record|register|reject|release|"+ + "report|return|select|severity|shared|signal|subtype|then|"+ + "to|transport|type|unaffected|units|until|use|variable|"+ + "wait|when|while|with"; var storageType = "bit|bit_vector|boolean|character|integer|line|natural|"+ "positive|real|register|signed|std_logic|"+ - "std_logic_vector|string||text|time|unsigned|variable"; + "std_logic_vector|string||text|time|unsigned"; var storageModifiers = "array|constant"; diff --git a/htdocs/includes/ace/src/mode-visualforce.js b/htdocs/includes/ace/src/mode-visualforce.js index ad9ab780b74..30c2cd90d18 100644 --- a/htdocs/includes/ace/src/mode-visualforce.js +++ b/htdocs/includes/ace/src/mode-visualforce.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -1316,6 +1317,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/css"; + this.snippetFileId = "ace/snippets/css"; }).call(Mode.prototype); exports.Mode = Mode; @@ -2493,6 +2495,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/html"; + this.snippetFileId = "ace/snippets/html"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-wollok.js b/htdocs/includes/ace/src/mode-wollok.js index a4dba0f9ce4..e62e249a84d 100644 --- a/htdocs/includes/ace/src/mode-wollok.js +++ b/htdocs/includes/ace/src/mode-wollok.js @@ -784,6 +784,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/javascript"; + this.snippetFileId = "ace/snippets/javascript"; }).call(Mode.prototype); exports.Mode = Mode; @@ -899,6 +900,7 @@ oop.inherits(Mode, JavaScriptMode); }; this.$id = "ace/mode/wollok"; + this.snippetFileId = "ace/snippets/wollok"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/mode-xquery.js b/htdocs/includes/ace/src/mode-xquery.js index 0a87a75fa2b..4512ba9d91e 100644 --- a/htdocs/includes/ace/src/mode-xquery.js +++ b/htdocs/includes/ace/src/mode-xquery.js @@ -2630,6 +2630,7 @@ oop.inherits(Mode, TextMode); }; this.$id = "ace/mode/xquery"; + this.snippetFileId = "ace/snippets/xquery"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/htdocs/includes/ace/src/snippets/abap.js b/htdocs/includes/ace/src/snippets/abap.js index 39342f476a4..8a6b11f7d6f 100644 --- a/htdocs/includes/ace/src/snippets/abap.js +++ b/htdocs/includes/ace/src/snippets/abap.js @@ -1,10 +1,5 @@ -define("ace/snippets/abap",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "abap"; - -}); (function() { +; (function() { window.require(["ace/snippets/abap"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/ada.js b/htdocs/includes/ace/src/snippets/ada.js index 94be2e5962e..8eb30a101bd 100644 --- a/htdocs/includes/ace/src/snippets/ada.js +++ b/htdocs/includes/ace/src/snippets/ada.js @@ -1,10 +1,5 @@ -define("ace/snippets/ada",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "ada"; - -}); (function() { +; (function() { window.require(["ace/snippets/ada"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/alda.js b/htdocs/includes/ace/src/snippets/alda.js new file mode 100644 index 00000000000..a7827995831 --- /dev/null +++ b/htdocs/includes/ace/src/snippets/alda.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/alda"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/apache_conf.js b/htdocs/includes/ace/src/snippets/apache_conf.js index c4e29459270..21986504c25 100644 --- a/htdocs/includes/ace/src/snippets/apache_conf.js +++ b/htdocs/includes/ace/src/snippets/apache_conf.js @@ -1,10 +1,5 @@ -define("ace/snippets/apache_conf",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "apache_conf"; - -}); (function() { +; (function() { window.require(["ace/snippets/apache_conf"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/apex.js b/htdocs/includes/ace/src/snippets/apex.js index 0c1f767377d..2dbcd0fce11 100644 --- a/htdocs/includes/ace/src/snippets/apex.js +++ b/htdocs/includes/ace/src/snippets/apex.js @@ -1,10 +1,5 @@ -define("ace/snippets/apex",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "apex"; - -}); (function() { +; (function() { window.require(["ace/snippets/apex"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/applescript.js b/htdocs/includes/ace/src/snippets/applescript.js index 2412c72c9af..ea322dbde2b 100644 --- a/htdocs/includes/ace/src/snippets/applescript.js +++ b/htdocs/includes/ace/src/snippets/applescript.js @@ -1,10 +1,5 @@ -define("ace/snippets/applescript",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "applescript"; - -}); (function() { +; (function() { window.require(["ace/snippets/applescript"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/aql.js b/htdocs/includes/ace/src/snippets/aql.js index f9ef46d179d..5568f6a1084 100644 --- a/htdocs/includes/ace/src/snippets/aql.js +++ b/htdocs/includes/ace/src/snippets/aql.js @@ -1,10 +1,5 @@ -define("ace/snippets/aql",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "aql"; - -}); (function() { +; (function() { window.require(["ace/snippets/aql"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/asciidoc.js b/htdocs/includes/ace/src/snippets/asciidoc.js index 7c68e42e3f0..e5b47cfa570 100644 --- a/htdocs/includes/ace/src/snippets/asciidoc.js +++ b/htdocs/includes/ace/src/snippets/asciidoc.js @@ -1,10 +1,5 @@ -define("ace/snippets/asciidoc",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "asciidoc"; - -}); (function() { +; (function() { window.require(["ace/snippets/asciidoc"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/asl.js b/htdocs/includes/ace/src/snippets/asl.js index e077ac0e4ab..0166b95535e 100644 --- a/htdocs/includes/ace/src/snippets/asl.js +++ b/htdocs/includes/ace/src/snippets/asl.js @@ -1,9 +1,5 @@ -define("ace/snippets/asl",["require","exports","module"], function (require, exports, module) { - "use strict"; - exports.snippetText =undefined; - exports.scope = "asl"; -}); (function() { +; (function() { window.require(["ace/snippets/asl"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/assembly_x86.js b/htdocs/includes/ace/src/snippets/assembly_x86.js index 7b16369e1be..ffbf5971f61 100644 --- a/htdocs/includes/ace/src/snippets/assembly_x86.js +++ b/htdocs/includes/ace/src/snippets/assembly_x86.js @@ -1,10 +1,5 @@ -define("ace/snippets/assembly_x86",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "assembly_x86"; - -}); (function() { +; (function() { window.require(["ace/snippets/assembly_x86"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/autohotkey.js b/htdocs/includes/ace/src/snippets/autohotkey.js index 601d201ce16..e0674d4eac6 100644 --- a/htdocs/includes/ace/src/snippets/autohotkey.js +++ b/htdocs/includes/ace/src/snippets/autohotkey.js @@ -1,10 +1,5 @@ -define("ace/snippets/autohotkey",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "autohotkey"; - -}); (function() { +; (function() { window.require(["ace/snippets/autohotkey"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/batchfile.js b/htdocs/includes/ace/src/snippets/batchfile.js index dfae8ab00bc..0404a41ee28 100644 --- a/htdocs/includes/ace/src/snippets/batchfile.js +++ b/htdocs/includes/ace/src/snippets/batchfile.js @@ -1,10 +1,5 @@ -define("ace/snippets/batchfile",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "batchfile"; - -}); (function() { +; (function() { window.require(["ace/snippets/batchfile"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/bro.js b/htdocs/includes/ace/src/snippets/bro.js deleted file mode 100644 index 9412c6003e3..00000000000 --- a/htdocs/includes/ace/src/snippets/bro.js +++ /dev/null @@ -1,14 +0,0 @@ -define("ace/snippets/bro",["require","exports","module"], function(require, exports, module) { -"use strict"; - -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { - window.require(["ace/snippets/bro"], function(m) { - if (typeof module == "object" && typeof exports == "object" && module) { - module.exports = m; - } - }); - })(); - \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/c9search.js b/htdocs/includes/ace/src/snippets/c9search.js index b5c7058137b..d83a158fc79 100644 --- a/htdocs/includes/ace/src/snippets/c9search.js +++ b/htdocs/includes/ace/src/snippets/c9search.js @@ -1,10 +1,5 @@ -define("ace/snippets/c9search",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "c9search"; - -}); (function() { +; (function() { window.require(["ace/snippets/c9search"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/cirru.js b/htdocs/includes/ace/src/snippets/cirru.js index 882b0c9741f..8bd664ed3f9 100644 --- a/htdocs/includes/ace/src/snippets/cirru.js +++ b/htdocs/includes/ace/src/snippets/cirru.js @@ -1,10 +1,5 @@ -define("ace/snippets/cirru",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "cirru"; - -}); (function() { +; (function() { window.require(["ace/snippets/cirru"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/cobol.js b/htdocs/includes/ace/src/snippets/cobol.js index 303dea71778..1fece5b6445 100644 --- a/htdocs/includes/ace/src/snippets/cobol.js +++ b/htdocs/includes/ace/src/snippets/cobol.js @@ -1,10 +1,5 @@ -define("ace/snippets/cobol",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "cobol"; - -}); (function() { +; (function() { window.require(["ace/snippets/cobol"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/coldfusion.js b/htdocs/includes/ace/src/snippets/coldfusion.js index db72fad9320..0f1ff4d2b8a 100644 --- a/htdocs/includes/ace/src/snippets/coldfusion.js +++ b/htdocs/includes/ace/src/snippets/coldfusion.js @@ -1,10 +1,5 @@ -define("ace/snippets/coldfusion",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "coldfusion"; - -}); (function() { +; (function() { window.require(["ace/snippets/coldfusion"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/crystal.js b/htdocs/includes/ace/src/snippets/crystal.js index ef64a9fdce1..39614eb1fe5 100644 --- a/htdocs/includes/ace/src/snippets/crystal.js +++ b/htdocs/includes/ace/src/snippets/crystal.js @@ -1,10 +1,5 @@ -define("ace/snippets/crystal",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "crystal"; - -}); (function() { +; (function() { window.require(["ace/snippets/crystal"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/csharp.js b/htdocs/includes/ace/src/snippets/csharp.js index f36041cbcd7..22c8f86c0a7 100644 --- a/htdocs/includes/ace/src/snippets/csharp.js +++ b/htdocs/includes/ace/src/snippets/csharp.js @@ -1,10 +1,5 @@ -define("ace/snippets/csharp",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "csharp"; - -}); (function() { +; (function() { window.require(["ace/snippets/csharp"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/csound_score.js b/htdocs/includes/ace/src/snippets/csound_score.js index 82ee2c17d35..3d7ae0e6720 100644 --- a/htdocs/includes/ace/src/snippets/csound_score.js +++ b/htdocs/includes/ace/src/snippets/csound_score.js @@ -1,10 +1,5 @@ -define("ace/snippets/csound_score",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "csound_score"; - -}); (function() { +; (function() { window.require(["ace/snippets/csound_score"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/csp.js b/htdocs/includes/ace/src/snippets/csp.js index 8225367a49b..685814919fa 100644 --- a/htdocs/includes/ace/src/snippets/csp.js +++ b/htdocs/includes/ace/src/snippets/csp.js @@ -1,10 +1,5 @@ -define("ace/snippets/csp",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/csp"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/curly.js b/htdocs/includes/ace/src/snippets/curly.js index 1d7b8f7b290..d0c5487d9f0 100644 --- a/htdocs/includes/ace/src/snippets/curly.js +++ b/htdocs/includes/ace/src/snippets/curly.js @@ -1,10 +1,5 @@ -define("ace/snippets/curly",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "curly"; - -}); (function() { +; (function() { window.require(["ace/snippets/curly"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/d.js b/htdocs/includes/ace/src/snippets/d.js index 117da84d0eb..18257d4f6c6 100644 --- a/htdocs/includes/ace/src/snippets/d.js +++ b/htdocs/includes/ace/src/snippets/d.js @@ -1,10 +1,5 @@ -define("ace/snippets/d",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "d"; - -}); (function() { +; (function() { window.require(["ace/snippets/d"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/dockerfile.js b/htdocs/includes/ace/src/snippets/dockerfile.js index 6ebfb397359..cd5d4182f1a 100644 --- a/htdocs/includes/ace/src/snippets/dockerfile.js +++ b/htdocs/includes/ace/src/snippets/dockerfile.js @@ -1,10 +1,5 @@ -define("ace/snippets/dockerfile",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "dockerfile"; - -}); (function() { +; (function() { window.require(["ace/snippets/dockerfile"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/dot.js b/htdocs/includes/ace/src/snippets/dot.js index 0af0a491752..aec363b01d6 100644 --- a/htdocs/includes/ace/src/snippets/dot.js +++ b/htdocs/includes/ace/src/snippets/dot.js @@ -1,10 +1,5 @@ -define("ace/snippets/dot",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "dot"; - -}); (function() { +; (function() { window.require(["ace/snippets/dot"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/eiffel.js b/htdocs/includes/ace/src/snippets/eiffel.js index bc6a66a93b3..60a36440f0d 100644 --- a/htdocs/includes/ace/src/snippets/eiffel.js +++ b/htdocs/includes/ace/src/snippets/eiffel.js @@ -1,10 +1,5 @@ -define("ace/snippets/eiffel",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "eiffel"; - -}); (function() { +; (function() { window.require(["ace/snippets/eiffel"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/ejs.js b/htdocs/includes/ace/src/snippets/ejs.js index 83368d91ee0..3e0f355e747 100644 --- a/htdocs/includes/ace/src/snippets/ejs.js +++ b/htdocs/includes/ace/src/snippets/ejs.js @@ -1,10 +1,5 @@ -define("ace/snippets/ejs",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "ejs"; - -}); (function() { +; (function() { window.require(["ace/snippets/ejs"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/elixir.js b/htdocs/includes/ace/src/snippets/elixir.js index 8ddaf1c4495..f408337980b 100644 --- a/htdocs/includes/ace/src/snippets/elixir.js +++ b/htdocs/includes/ace/src/snippets/elixir.js @@ -1,10 +1,5 @@ -define("ace/snippets/elixir",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/elixir"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/elm.js b/htdocs/includes/ace/src/snippets/elm.js index 71d7a7e15b0..c1122649f1b 100644 --- a/htdocs/includes/ace/src/snippets/elm.js +++ b/htdocs/includes/ace/src/snippets/elm.js @@ -1,10 +1,5 @@ -define("ace/snippets/elm",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "elm"; - -}); (function() { +; (function() { window.require(["ace/snippets/elm"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/forth.js b/htdocs/includes/ace/src/snippets/forth.js index 0861c05f3e9..a7a0c053f63 100644 --- a/htdocs/includes/ace/src/snippets/forth.js +++ b/htdocs/includes/ace/src/snippets/forth.js @@ -1,10 +1,5 @@ -define("ace/snippets/forth",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "forth"; - -}); (function() { +; (function() { window.require(["ace/snippets/forth"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/fortran.js b/htdocs/includes/ace/src/snippets/fortran.js index 69bffe8f2aa..ec3ae4e6457 100644 --- a/htdocs/includes/ace/src/snippets/fortran.js +++ b/htdocs/includes/ace/src/snippets/fortran.js @@ -1,10 +1,5 @@ -define("ace/snippets/fortran",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "fortran"; - -}); (function() { +; (function() { window.require(["ace/snippets/fortran"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/fsharp.js b/htdocs/includes/ace/src/snippets/fsharp.js index bbc8eb65b5e..dfe6a1391e1 100644 --- a/htdocs/includes/ace/src/snippets/fsharp.js +++ b/htdocs/includes/ace/src/snippets/fsharp.js @@ -1,10 +1,5 @@ -define("ace/snippets/fsharp",["require","exports","module"], function(require, exports, module) { - "use strict"; - exports.snippetText =undefined; - exports.scope = "fsharp"; - -}); (function() { +; (function() { window.require(["ace/snippets/fsharp"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/ftl.js b/htdocs/includes/ace/src/snippets/ftl.js index 7b7cb67948e..aa9f0e0bbfc 100644 --- a/htdocs/includes/ace/src/snippets/ftl.js +++ b/htdocs/includes/ace/src/snippets/ftl.js @@ -1,10 +1,5 @@ -define("ace/snippets/ftl",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "ftl"; - -}); (function() { +; (function() { window.require(["ace/snippets/ftl"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/gcode.js b/htdocs/includes/ace/src/snippets/gcode.js index b44f1656ce3..d85b1b4838b 100644 --- a/htdocs/includes/ace/src/snippets/gcode.js +++ b/htdocs/includes/ace/src/snippets/gcode.js @@ -1,10 +1,5 @@ -define("ace/snippets/gcode",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "gcode"; - -}); (function() { +; (function() { window.require(["ace/snippets/gcode"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/gherkin.js b/htdocs/includes/ace/src/snippets/gherkin.js index 8986e377a7d..11c54661bdc 100644 --- a/htdocs/includes/ace/src/snippets/gherkin.js +++ b/htdocs/includes/ace/src/snippets/gherkin.js @@ -1,10 +1,5 @@ -define("ace/snippets/gherkin",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "gherkin"; - -}); (function() { +; (function() { window.require(["ace/snippets/gherkin"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/gitignore.js b/htdocs/includes/ace/src/snippets/gitignore.js index aea0fb0df9a..a6af8361d76 100644 --- a/htdocs/includes/ace/src/snippets/gitignore.js +++ b/htdocs/includes/ace/src/snippets/gitignore.js @@ -1,10 +1,5 @@ -define("ace/snippets/gitignore",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "gitignore"; - -}); (function() { +; (function() { window.require(["ace/snippets/gitignore"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/glsl.js b/htdocs/includes/ace/src/snippets/glsl.js index f638fbc6eac..bdea4bfaa64 100644 --- a/htdocs/includes/ace/src/snippets/glsl.js +++ b/htdocs/includes/ace/src/snippets/glsl.js @@ -1,10 +1,5 @@ -define("ace/snippets/glsl",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "glsl"; - -}); (function() { +; (function() { window.require(["ace/snippets/glsl"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/golang.js b/htdocs/includes/ace/src/snippets/golang.js index b16e805474f..18a9f97b64c 100644 --- a/htdocs/includes/ace/src/snippets/golang.js +++ b/htdocs/includes/ace/src/snippets/golang.js @@ -1,10 +1,5 @@ -define("ace/snippets/golang",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "golang"; - -}); (function() { +; (function() { window.require(["ace/snippets/golang"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/groovy.js b/htdocs/includes/ace/src/snippets/groovy.js index 56091acbccd..72f2f32ecb1 100644 --- a/htdocs/includes/ace/src/snippets/groovy.js +++ b/htdocs/includes/ace/src/snippets/groovy.js @@ -1,10 +1,5 @@ -define("ace/snippets/groovy",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "groovy"; - -}); (function() { +; (function() { window.require(["ace/snippets/groovy"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/handlebars.js b/htdocs/includes/ace/src/snippets/handlebars.js index ca8b6354867..2eaf61de444 100644 --- a/htdocs/includes/ace/src/snippets/handlebars.js +++ b/htdocs/includes/ace/src/snippets/handlebars.js @@ -1,10 +1,5 @@ -define("ace/snippets/handlebars",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "handlebars"; - -}); (function() { +; (function() { window.require(["ace/snippets/handlebars"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/haskell_cabal.js b/htdocs/includes/ace/src/snippets/haskell_cabal.js index 471feb12baa..1a90a9cbf97 100644 --- a/htdocs/includes/ace/src/snippets/haskell_cabal.js +++ b/htdocs/includes/ace/src/snippets/haskell_cabal.js @@ -1,10 +1,5 @@ -define("ace/snippets/haskell_cabal",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "haskell_cabal"; - -}); (function() { +; (function() { window.require(["ace/snippets/haskell_cabal"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/haxe.js b/htdocs/includes/ace/src/snippets/haxe.js index 8feed8d150c..b1f2dbe6c37 100644 --- a/htdocs/includes/ace/src/snippets/haxe.js +++ b/htdocs/includes/ace/src/snippets/haxe.js @@ -1,10 +1,5 @@ -define("ace/snippets/haxe",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "haxe"; - -}); (function() { +; (function() { window.require(["ace/snippets/haxe"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/hjson.js b/htdocs/includes/ace/src/snippets/hjson.js index 79be57d0cf3..96938d67d7a 100644 --- a/htdocs/includes/ace/src/snippets/hjson.js +++ b/htdocs/includes/ace/src/snippets/hjson.js @@ -1,10 +1,5 @@ -define("ace/snippets/hjson",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/hjson"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/html.js b/htdocs/includes/ace/src/snippets/html.js index 975496c1b49..885d2a2d64f 100644 --- a/htdocs/includes/ace/src/snippets/html.js +++ b/htdocs/includes/ace/src/snippets/html.js @@ -237,9 +237,7 @@ snippet button:s\n\ snippet button:r\n\ \n\ snippet canvas\n\ - \n\ - ${1}\n\ - \n\ + \n\ snippet caption\n\ ${1}\n\ snippet cite\n\ @@ -853,7 +851,7 @@ snippet ul+\n\ snippet var\n\ ${1}\n\ snippet video\n\ - ${8}\n\ + ${8}\n\ snippet wbr\n\ ${1}\n\ "; diff --git a/htdocs/includes/ace/src/snippets/html_elixir.js b/htdocs/includes/ace/src/snippets/html_elixir.js index c8521b55ca8..0db3e076f71 100644 --- a/htdocs/includes/ace/src/snippets/html_elixir.js +++ b/htdocs/includes/ace/src/snippets/html_elixir.js @@ -1,10 +1,5 @@ -define("ace/snippets/html_elixir",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "html_elixir"; - -}); (function() { +; (function() { window.require(["ace/snippets/html_elixir"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/html_ruby.js b/htdocs/includes/ace/src/snippets/html_ruby.js index ba20e65e72d..5d4499743c0 100644 --- a/htdocs/includes/ace/src/snippets/html_ruby.js +++ b/htdocs/includes/ace/src/snippets/html_ruby.js @@ -1,10 +1,5 @@ -define("ace/snippets/html_ruby",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "html_ruby"; - -}); (function() { +; (function() { window.require(["ace/snippets/html_ruby"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/ini.js b/htdocs/includes/ace/src/snippets/ini.js index 07200fda5b7..f31743c5b0d 100644 --- a/htdocs/includes/ace/src/snippets/ini.js +++ b/htdocs/includes/ace/src/snippets/ini.js @@ -1,10 +1,5 @@ -define("ace/snippets/ini",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "ini"; - -}); (function() { +; (function() { window.require(["ace/snippets/ini"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/jack.js b/htdocs/includes/ace/src/snippets/jack.js index 2688a3a1011..fc242d3c2a6 100644 --- a/htdocs/includes/ace/src/snippets/jack.js +++ b/htdocs/includes/ace/src/snippets/jack.js @@ -1,10 +1,5 @@ -define("ace/snippets/jack",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "jack"; - -}); (function() { +; (function() { window.require(["ace/snippets/jack"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/jade.js b/htdocs/includes/ace/src/snippets/jade.js index 6a4676b883d..1a1c1c25e37 100644 --- a/htdocs/includes/ace/src/snippets/jade.js +++ b/htdocs/includes/ace/src/snippets/jade.js @@ -1,10 +1,5 @@ -define("ace/snippets/jade",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "jade"; - -}); (function() { +; (function() { window.require(["ace/snippets/jade"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/json.js b/htdocs/includes/ace/src/snippets/json.js index 7c9c2eaf295..f1c015c4264 100644 --- a/htdocs/includes/ace/src/snippets/json.js +++ b/htdocs/includes/ace/src/snippets/json.js @@ -1,10 +1,5 @@ -define("ace/snippets/json",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "json"; - -}); (function() { +; (function() { window.require(["ace/snippets/json"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/json5.js b/htdocs/includes/ace/src/snippets/json5.js index 8afbead737d..4ae9f4b7b1f 100644 --- a/htdocs/includes/ace/src/snippets/json5.js +++ b/htdocs/includes/ace/src/snippets/json5.js @@ -1,10 +1,5 @@ -define("ace/snippets/json5",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "json5"; - -}); (function() { +; (function() { window.require(["ace/snippets/json5"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/jssm.js b/htdocs/includes/ace/src/snippets/jssm.js index fceb11ddfe9..2fcea71ccf0 100644 --- a/htdocs/includes/ace/src/snippets/jssm.js +++ b/htdocs/includes/ace/src/snippets/jssm.js @@ -1,10 +1,5 @@ -define("ace/snippets/jssm",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/jssm"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/jsx.js b/htdocs/includes/ace/src/snippets/jsx.js index 38f276f80a2..b26a3586bbb 100644 --- a/htdocs/includes/ace/src/snippets/jsx.js +++ b/htdocs/includes/ace/src/snippets/jsx.js @@ -1,10 +1,5 @@ -define("ace/snippets/jsx",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "jsx"; - -}); (function() { +; (function() { window.require(["ace/snippets/jsx"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/julia.js b/htdocs/includes/ace/src/snippets/julia.js index 360f7c3d200..30a74650766 100644 --- a/htdocs/includes/ace/src/snippets/julia.js +++ b/htdocs/includes/ace/src/snippets/julia.js @@ -1,10 +1,5 @@ -define("ace/snippets/julia",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "julia"; - -}); (function() { +; (function() { window.require(["ace/snippets/julia"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/kotlin.js b/htdocs/includes/ace/src/snippets/kotlin.js index b2e3d3cbb52..c9e543c7d58 100644 --- a/htdocs/includes/ace/src/snippets/kotlin.js +++ b/htdocs/includes/ace/src/snippets/kotlin.js @@ -1,10 +1,5 @@ -define("ace/snippets/kotlin",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/kotlin"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/latex.js b/htdocs/includes/ace/src/snippets/latex.js index 6afc3775b98..711a30b780f 100644 --- a/htdocs/includes/ace/src/snippets/latex.js +++ b/htdocs/includes/ace/src/snippets/latex.js @@ -1,10 +1,5 @@ -define("ace/snippets/latex",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "latex"; - -}); (function() { +; (function() { window.require(["ace/snippets/latex"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/latte.js b/htdocs/includes/ace/src/snippets/latte.js new file mode 100644 index 00000000000..d5c341ce881 --- /dev/null +++ b/htdocs/includes/ace/src/snippets/latte.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/latte"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/less.js b/htdocs/includes/ace/src/snippets/less.js index a87b47b185c..2b4c6b3b469 100644 --- a/htdocs/includes/ace/src/snippets/less.js +++ b/htdocs/includes/ace/src/snippets/less.js @@ -1,10 +1,5 @@ -define("ace/snippets/less",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "less"; - -}); (function() { +; (function() { window.require(["ace/snippets/less"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/lisp.js b/htdocs/includes/ace/src/snippets/lisp.js index f6c13860ec9..a971e2131e5 100644 --- a/htdocs/includes/ace/src/snippets/lisp.js +++ b/htdocs/includes/ace/src/snippets/lisp.js @@ -1,10 +1,5 @@ -define("ace/snippets/lisp",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "lisp"; - -}); (function() { +; (function() { window.require(["ace/snippets/lisp"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/livescript.js b/htdocs/includes/ace/src/snippets/livescript.js index 08b6cb107d6..ed4b397ac34 100644 --- a/htdocs/includes/ace/src/snippets/livescript.js +++ b/htdocs/includes/ace/src/snippets/livescript.js @@ -1,10 +1,5 @@ -define("ace/snippets/livescript",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "livescript"; - -}); (function() { +; (function() { window.require(["ace/snippets/livescript"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/logiql.js b/htdocs/includes/ace/src/snippets/logiql.js index 073da94b692..d0fea2bdae5 100644 --- a/htdocs/includes/ace/src/snippets/logiql.js +++ b/htdocs/includes/ace/src/snippets/logiql.js @@ -1,10 +1,5 @@ -define("ace/snippets/logiql",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "logiql"; - -}); (function() { +; (function() { window.require(["ace/snippets/logiql"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/logtalk.js b/htdocs/includes/ace/src/snippets/logtalk.js index 4ab4f1f9e8c..4ae82ed92b1 100644 --- a/htdocs/includes/ace/src/snippets/logtalk.js +++ b/htdocs/includes/ace/src/snippets/logtalk.js @@ -1,10 +1,5 @@ -define("ace/snippets/logtalk",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "logtalk"; - -}); (function() { +; (function() { window.require(["ace/snippets/logtalk"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/luapage.js b/htdocs/includes/ace/src/snippets/luapage.js index 8f52b58fc01..db7de782348 100644 --- a/htdocs/includes/ace/src/snippets/luapage.js +++ b/htdocs/includes/ace/src/snippets/luapage.js @@ -1,10 +1,5 @@ -define("ace/snippets/luapage",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "luapage"; - -}); (function() { +; (function() { window.require(["ace/snippets/luapage"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/lucene.js b/htdocs/includes/ace/src/snippets/lucene.js index c61509bea79..bb248e9c4b2 100644 --- a/htdocs/includes/ace/src/snippets/lucene.js +++ b/htdocs/includes/ace/src/snippets/lucene.js @@ -1,10 +1,5 @@ -define("ace/snippets/lucene",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "lucene"; - -}); (function() { +; (function() { window.require(["ace/snippets/lucene"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/mask.js b/htdocs/includes/ace/src/snippets/mask.js index 1b9c0c56dc2..f63c0a61b6d 100644 --- a/htdocs/includes/ace/src/snippets/mask.js +++ b/htdocs/includes/ace/src/snippets/mask.js @@ -1,10 +1,5 @@ -define("ace/snippets/mask",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "mask"; - -}); (function() { +; (function() { window.require(["ace/snippets/mask"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/matlab.js b/htdocs/includes/ace/src/snippets/matlab.js index d8fcd2bd071..cc5fb70e7a5 100644 --- a/htdocs/includes/ace/src/snippets/matlab.js +++ b/htdocs/includes/ace/src/snippets/matlab.js @@ -1,10 +1,5 @@ -define("ace/snippets/matlab",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "matlab"; - -}); (function() { +; (function() { window.require(["ace/snippets/matlab"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/mediawiki.js b/htdocs/includes/ace/src/snippets/mediawiki.js new file mode 100644 index 00000000000..bd73d00064b --- /dev/null +++ b/htdocs/includes/ace/src/snippets/mediawiki.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/mediawiki"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/mel.js b/htdocs/includes/ace/src/snippets/mel.js index 4e43ab1be3f..fa5ecbc8985 100644 --- a/htdocs/includes/ace/src/snippets/mel.js +++ b/htdocs/includes/ace/src/snippets/mel.js @@ -1,10 +1,5 @@ -define("ace/snippets/mel",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "mel"; - -}); (function() { +; (function() { window.require(["ace/snippets/mel"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/mips.js b/htdocs/includes/ace/src/snippets/mips.js new file mode 100644 index 00000000000..9badca8efcf --- /dev/null +++ b/htdocs/includes/ace/src/snippets/mips.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/mips"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/mixal.js b/htdocs/includes/ace/src/snippets/mixal.js index 60b08ea8f52..8246ef784c3 100644 --- a/htdocs/includes/ace/src/snippets/mixal.js +++ b/htdocs/includes/ace/src/snippets/mixal.js @@ -1,10 +1,5 @@ -define("ace/snippets/mixal",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "mixal"; - -}); (function() { +; (function() { window.require(["ace/snippets/mixal"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/mushcode.js b/htdocs/includes/ace/src/snippets/mushcode.js index 1ff99c4abae..8eddd370b3d 100644 --- a/htdocs/includes/ace/src/snippets/mushcode.js +++ b/htdocs/includes/ace/src/snippets/mushcode.js @@ -1,10 +1,5 @@ -define("ace/snippets/mushcode",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "mushcode"; - -}); (function() { +; (function() { window.require(["ace/snippets/mushcode"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/mysql.js b/htdocs/includes/ace/src/snippets/mysql.js index 2791c37f87a..d8544a1b7a8 100644 --- a/htdocs/includes/ace/src/snippets/mysql.js +++ b/htdocs/includes/ace/src/snippets/mysql.js @@ -1,10 +1,5 @@ -define("ace/snippets/mysql",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "mysql"; - -}); (function() { +; (function() { window.require(["ace/snippets/mysql"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/nginx.js b/htdocs/includes/ace/src/snippets/nginx.js index 4305b2cae3e..565e3b8a6ce 100644 --- a/htdocs/includes/ace/src/snippets/nginx.js +++ b/htdocs/includes/ace/src/snippets/nginx.js @@ -1,10 +1,5 @@ -define("ace/snippets/nginx",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "nginx"; - -}); (function() { +; (function() { window.require(["ace/snippets/nginx"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/nim.js b/htdocs/includes/ace/src/snippets/nim.js index f73018ce124..b3b4dfc0489 100644 --- a/htdocs/includes/ace/src/snippets/nim.js +++ b/htdocs/includes/ace/src/snippets/nim.js @@ -1,10 +1,5 @@ -define("ace/snippets/nim",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "nim"; - -}); (function() { +; (function() { window.require(["ace/snippets/nim"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/nix.js b/htdocs/includes/ace/src/snippets/nix.js index c7d9035a6d3..bc63bd3d5ce 100644 --- a/htdocs/includes/ace/src/snippets/nix.js +++ b/htdocs/includes/ace/src/snippets/nix.js @@ -1,10 +1,5 @@ -define("ace/snippets/nix",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "nix"; - -}); (function() { +; (function() { window.require(["ace/snippets/nix"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/nsis.js b/htdocs/includes/ace/src/snippets/nsis.js index 423a1a8b336..caf0839d1af 100644 --- a/htdocs/includes/ace/src/snippets/nsis.js +++ b/htdocs/includes/ace/src/snippets/nsis.js @@ -1,10 +1,5 @@ -define("ace/snippets/nsis",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/nsis"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/nunjucks.js b/htdocs/includes/ace/src/snippets/nunjucks.js index 961adec5778..748d2d9ffc4 100644 --- a/htdocs/includes/ace/src/snippets/nunjucks.js +++ b/htdocs/includes/ace/src/snippets/nunjucks.js @@ -1,10 +1,5 @@ -define("ace/snippets/nunjucks",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "nunjucks"; - -}); (function() { +; (function() { window.require(["ace/snippets/nunjucks"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/objectivec.js b/htdocs/includes/ace/src/snippets/objectivec.js index 32816f0b2a1..77bad68f2c2 100644 --- a/htdocs/includes/ace/src/snippets/objectivec.js +++ b/htdocs/includes/ace/src/snippets/objectivec.js @@ -1,10 +1,5 @@ -define("ace/snippets/objectivec",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "objectivec"; - -}); (function() { +; (function() { window.require(["ace/snippets/objectivec"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/ocaml.js b/htdocs/includes/ace/src/snippets/ocaml.js index 2d1f07a0043..23789d1ec6f 100644 --- a/htdocs/includes/ace/src/snippets/ocaml.js +++ b/htdocs/includes/ace/src/snippets/ocaml.js @@ -1,10 +1,5 @@ -define("ace/snippets/ocaml",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "ocaml"; - -}); (function() { +; (function() { window.require(["ace/snippets/ocaml"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/pascal.js b/htdocs/includes/ace/src/snippets/pascal.js index 296a7565525..f6d60d88ec4 100644 --- a/htdocs/includes/ace/src/snippets/pascal.js +++ b/htdocs/includes/ace/src/snippets/pascal.js @@ -1,10 +1,5 @@ -define("ace/snippets/pascal",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "pascal"; - -}); (function() { +; (function() { window.require(["ace/snippets/pascal"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/perl6.js b/htdocs/includes/ace/src/snippets/perl6.js deleted file mode 100644 index 90ecfbe0c82..00000000000 --- a/htdocs/includes/ace/src/snippets/perl6.js +++ /dev/null @@ -1,14 +0,0 @@ -define("ace/snippets/perl6",["require","exports","module"], function(require, exports, module) { -"use strict"; - -exports.snippetText =undefined; -exports.scope = "perl6"; - -}); (function() { - window.require(["ace/snippets/perl6"], function(m) { - if (typeof module == "object" && typeof exports == "object" && module) { - module.exports = m; - } - }); - })(); - \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/pgsql.js b/htdocs/includes/ace/src/snippets/pgsql.js index b8b45fb8acb..c15cb260ae6 100644 --- a/htdocs/includes/ace/src/snippets/pgsql.js +++ b/htdocs/includes/ace/src/snippets/pgsql.js @@ -1,10 +1,5 @@ -define("ace/snippets/pgsql",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "pgsql"; - -}); (function() { +; (function() { window.require(["ace/snippets/pgsql"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/php_laravel_blade.js b/htdocs/includes/ace/src/snippets/php_laravel_blade.js index 9a722c9b371..d4790ba2852 100644 --- a/htdocs/includes/ace/src/snippets/php_laravel_blade.js +++ b/htdocs/includes/ace/src/snippets/php_laravel_blade.js @@ -1,10 +1,5 @@ -define("ace/snippets/php_laravel_blade",["require","exports","module"], function(require, exports, module) { - "use strict"; - exports.snippetText =undefined; - exports.scope = "php"; - -}); (function() { +; (function() { window.require(["ace/snippets/php_laravel_blade"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/pig.js b/htdocs/includes/ace/src/snippets/pig.js index 94d46c7cc7f..157d1921126 100644 --- a/htdocs/includes/ace/src/snippets/pig.js +++ b/htdocs/includes/ace/src/snippets/pig.js @@ -1,10 +1,5 @@ -define("ace/snippets/pig",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "pig"; - -}); (function() { +; (function() { window.require(["ace/snippets/pig"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/plain_text.js b/htdocs/includes/ace/src/snippets/plain_text.js index 988880c9c97..92dfce5cd7b 100644 --- a/htdocs/includes/ace/src/snippets/plain_text.js +++ b/htdocs/includes/ace/src/snippets/plain_text.js @@ -1,10 +1,5 @@ -define("ace/snippets/plain_text",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "plain_text"; - -}); (function() { +; (function() { window.require(["ace/snippets/plain_text"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/powershell.js b/htdocs/includes/ace/src/snippets/powershell.js index 4d8388a81ea..0f36eededab 100644 --- a/htdocs/includes/ace/src/snippets/powershell.js +++ b/htdocs/includes/ace/src/snippets/powershell.js @@ -1,10 +1,5 @@ -define("ace/snippets/powershell",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "powershell"; - -}); (function() { +; (function() { window.require(["ace/snippets/powershell"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/praat.js b/htdocs/includes/ace/src/snippets/praat.js index 75fa2e423e5..e4e734fc77b 100644 --- a/htdocs/includes/ace/src/snippets/praat.js +++ b/htdocs/includes/ace/src/snippets/praat.js @@ -1,10 +1,5 @@ -define("ace/snippets/praat",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "praat"; - -}); (function() { +; (function() { window.require(["ace/snippets/praat"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/prisma.js b/htdocs/includes/ace/src/snippets/prisma.js new file mode 100644 index 00000000000..4a9e2b3e3e6 --- /dev/null +++ b/htdocs/includes/ace/src/snippets/prisma.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/prisma"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/prolog.js b/htdocs/includes/ace/src/snippets/prolog.js index 9147ec6dfaf..4c23dac3852 100644 --- a/htdocs/includes/ace/src/snippets/prolog.js +++ b/htdocs/includes/ace/src/snippets/prolog.js @@ -1,10 +1,5 @@ -define("ace/snippets/prolog",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "prolog"; - -}); (function() { +; (function() { window.require(["ace/snippets/prolog"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/properties.js b/htdocs/includes/ace/src/snippets/properties.js index 1ef5ff3e732..36c01dcb83e 100644 --- a/htdocs/includes/ace/src/snippets/properties.js +++ b/htdocs/includes/ace/src/snippets/properties.js @@ -1,10 +1,5 @@ -define("ace/snippets/properties",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "properties"; - -}); (function() { +; (function() { window.require(["ace/snippets/properties"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/protobuf.js b/htdocs/includes/ace/src/snippets/protobuf.js index 98f00415c7e..b169bbfc539 100644 --- a/htdocs/includes/ace/src/snippets/protobuf.js +++ b/htdocs/includes/ace/src/snippets/protobuf.js @@ -1,10 +1,5 @@ -define("ace/snippets/protobuf",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText = ""; -exports.scope = "protobuf"; - -}); (function() { +; (function() { window.require(["ace/snippets/protobuf"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/puppet.js b/htdocs/includes/ace/src/snippets/puppet.js index 5c7b31650a3..52021e3a5a5 100644 --- a/htdocs/includes/ace/src/snippets/puppet.js +++ b/htdocs/includes/ace/src/snippets/puppet.js @@ -1,10 +1,5 @@ -define("ace/snippets/puppet",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "puppet"; - -}); (function() { +; (function() { window.require(["ace/snippets/puppet"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/qml.js b/htdocs/includes/ace/src/snippets/qml.js new file mode 100644 index 00000000000..cb4f66ede73 --- /dev/null +++ b/htdocs/includes/ace/src/snippets/qml.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/qml"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/raku.js b/htdocs/includes/ace/src/snippets/raku.js new file mode 100644 index 00000000000..8beaf95dc05 --- /dev/null +++ b/htdocs/includes/ace/src/snippets/raku.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/raku"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/rdoc.js b/htdocs/includes/ace/src/snippets/rdoc.js index f4dc8927f84..e4845db4c67 100644 --- a/htdocs/includes/ace/src/snippets/rdoc.js +++ b/htdocs/includes/ace/src/snippets/rdoc.js @@ -1,10 +1,5 @@ -define("ace/snippets/rdoc",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "rdoc"; - -}); (function() { +; (function() { window.require(["ace/snippets/rdoc"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/red.js b/htdocs/includes/ace/src/snippets/red.js index 900634e691e..80cbd1b55af 100644 --- a/htdocs/includes/ace/src/snippets/red.js +++ b/htdocs/includes/ace/src/snippets/red.js @@ -1,10 +1,5 @@ -define("ace/snippets/red",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText = " "; -exports.scope = "red"; - -}); (function() { +; (function() { window.require(["ace/snippets/red"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/redshift.js b/htdocs/includes/ace/src/snippets/redshift.js index 088f0febf03..bedd1473317 100644 --- a/htdocs/includes/ace/src/snippets/redshift.js +++ b/htdocs/includes/ace/src/snippets/redshift.js @@ -1,10 +1,5 @@ -define("ace/snippets/redshift",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "redshift"; - -}); (function() { +; (function() { window.require(["ace/snippets/redshift"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/rhtml.js b/htdocs/includes/ace/src/snippets/rhtml.js index e31ed6f8e92..7eb8a5eba86 100644 --- a/htdocs/includes/ace/src/snippets/rhtml.js +++ b/htdocs/includes/ace/src/snippets/rhtml.js @@ -1,10 +1,5 @@ -define("ace/snippets/rhtml",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "rhtml"; - -}); (function() { +; (function() { window.require(["ace/snippets/rhtml"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/rust.js b/htdocs/includes/ace/src/snippets/rust.js index 9ee8633e254..63d42815a5d 100644 --- a/htdocs/includes/ace/src/snippets/rust.js +++ b/htdocs/includes/ace/src/snippets/rust.js @@ -1,10 +1,5 @@ -define("ace/snippets/rust",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "rust"; - -}); (function() { +; (function() { window.require(["ace/snippets/rust"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/sass.js b/htdocs/includes/ace/src/snippets/sass.js index 684485dd0ee..0a4de9b4442 100644 --- a/htdocs/includes/ace/src/snippets/sass.js +++ b/htdocs/includes/ace/src/snippets/sass.js @@ -1,10 +1,5 @@ -define("ace/snippets/sass",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "sass"; - -}); (function() { +; (function() { window.require(["ace/snippets/sass"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/scad.js b/htdocs/includes/ace/src/snippets/scad.js index 4d7eec20085..2fb0826416f 100644 --- a/htdocs/includes/ace/src/snippets/scad.js +++ b/htdocs/includes/ace/src/snippets/scad.js @@ -1,10 +1,5 @@ -define("ace/snippets/scad",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "scad"; - -}); (function() { +; (function() { window.require(["ace/snippets/scad"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/scala.js b/htdocs/includes/ace/src/snippets/scala.js index 03eb329e7a4..adc0abbd496 100644 --- a/htdocs/includes/ace/src/snippets/scala.js +++ b/htdocs/includes/ace/src/snippets/scala.js @@ -1,10 +1,5 @@ -define("ace/snippets/scala",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "scala"; - -}); (function() { +; (function() { window.require(["ace/snippets/scala"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/scheme.js b/htdocs/includes/ace/src/snippets/scheme.js index 0f0906f147f..29c3d357914 100644 --- a/htdocs/includes/ace/src/snippets/scheme.js +++ b/htdocs/includes/ace/src/snippets/scheme.js @@ -1,10 +1,5 @@ -define("ace/snippets/scheme",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "scheme"; - -}); (function() { +; (function() { window.require(["ace/snippets/scheme"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/scrypt.js b/htdocs/includes/ace/src/snippets/scrypt.js new file mode 100644 index 00000000000..2d0601a1046 --- /dev/null +++ b/htdocs/includes/ace/src/snippets/scrypt.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/scrypt"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/scss.js b/htdocs/includes/ace/src/snippets/scss.js index 8e636cea79c..6e808dea9f3 100644 --- a/htdocs/includes/ace/src/snippets/scss.js +++ b/htdocs/includes/ace/src/snippets/scss.js @@ -1,10 +1,5 @@ -define("ace/snippets/scss",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "scss"; - -}); (function() { +; (function() { window.require(["ace/snippets/scss"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/sjs.js b/htdocs/includes/ace/src/snippets/sjs.js index a0756ae154d..bc8c1872023 100644 --- a/htdocs/includes/ace/src/snippets/sjs.js +++ b/htdocs/includes/ace/src/snippets/sjs.js @@ -1,10 +1,5 @@ -define("ace/snippets/sjs",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "sjs"; - -}); (function() { +; (function() { window.require(["ace/snippets/sjs"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/slim.js b/htdocs/includes/ace/src/snippets/slim.js index 7b159a94d6a..2fcd039ac1c 100644 --- a/htdocs/includes/ace/src/snippets/slim.js +++ b/htdocs/includes/ace/src/snippets/slim.js @@ -1,10 +1,5 @@ -define("ace/snippets/slim",["require","exports","module"], function(require, exports, module) { - "use strict"; - exports.snippetText =undefined; - exports.scope = "slim"; - -}); (function() { +; (function() { window.require(["ace/snippets/slim"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/smarty.js b/htdocs/includes/ace/src/snippets/smarty.js index 84c3d8eee1c..3affd2eac6e 100644 --- a/htdocs/includes/ace/src/snippets/smarty.js +++ b/htdocs/includes/ace/src/snippets/smarty.js @@ -1,10 +1,5 @@ -define("ace/snippets/smarty",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "smarty"; - -}); (function() { +; (function() { window.require(["ace/snippets/smarty"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/smithy.js b/htdocs/includes/ace/src/snippets/smithy.js new file mode 100644 index 00000000000..4077f9eeeaa --- /dev/null +++ b/htdocs/includes/ace/src/snippets/smithy.js @@ -0,0 +1,9 @@ + +; (function() { + window.require(["ace/snippets/smithy"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/snippets/soy_template.js b/htdocs/includes/ace/src/snippets/soy_template.js index d087ef1d21a..c7409658633 100644 --- a/htdocs/includes/ace/src/snippets/soy_template.js +++ b/htdocs/includes/ace/src/snippets/soy_template.js @@ -1,10 +1,5 @@ -define("ace/snippets/soy_template",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "soy_template"; - -}); (function() { +; (function() { window.require(["ace/snippets/soy_template"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/space.js b/htdocs/includes/ace/src/snippets/space.js index ae87ec48d82..8f485977088 100644 --- a/htdocs/includes/ace/src/snippets/space.js +++ b/htdocs/includes/ace/src/snippets/space.js @@ -1,10 +1,5 @@ -define("ace/snippets/space",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "space"; - -}); (function() { +; (function() { window.require(["ace/snippets/space"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/sparql.js b/htdocs/includes/ace/src/snippets/sparql.js index e021a74fb94..fe60397edb4 100644 --- a/htdocs/includes/ace/src/snippets/sparql.js +++ b/htdocs/includes/ace/src/snippets/sparql.js @@ -1,10 +1,5 @@ -define("ace/snippets/sparql",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/sparql"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/stylus.js b/htdocs/includes/ace/src/snippets/stylus.js index 0172b391622..34f1d714119 100644 --- a/htdocs/includes/ace/src/snippets/stylus.js +++ b/htdocs/includes/ace/src/snippets/stylus.js @@ -1,10 +1,5 @@ -define("ace/snippets/stylus",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "stylus"; - -}); (function() { +; (function() { window.require(["ace/snippets/stylus"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/svg.js b/htdocs/includes/ace/src/snippets/svg.js index 9f63d38fa3b..1aa4a8502e7 100644 --- a/htdocs/includes/ace/src/snippets/svg.js +++ b/htdocs/includes/ace/src/snippets/svg.js @@ -1,10 +1,5 @@ -define("ace/snippets/svg",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "svg"; - -}); (function() { +; (function() { window.require(["ace/snippets/svg"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/swift.js b/htdocs/includes/ace/src/snippets/swift.js index 8b510938dd3..143e32b7acd 100644 --- a/htdocs/includes/ace/src/snippets/swift.js +++ b/htdocs/includes/ace/src/snippets/swift.js @@ -1,10 +1,5 @@ -define("ace/snippets/swift",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "swift"; - -}); (function() { +; (function() { window.require(["ace/snippets/swift"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/terraform.js b/htdocs/includes/ace/src/snippets/terraform.js index 7e0593733b5..c9d8d31d601 100644 --- a/htdocs/includes/ace/src/snippets/terraform.js +++ b/htdocs/includes/ace/src/snippets/terraform.js @@ -1,10 +1,5 @@ -define("ace/snippets/terraform",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "terraform"; - -}); (function() { +; (function() { window.require(["ace/snippets/terraform"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/text.js b/htdocs/includes/ace/src/snippets/text.js index 949bb2a72dd..85b4d10e5f7 100644 --- a/htdocs/includes/ace/src/snippets/text.js +++ b/htdocs/includes/ace/src/snippets/text.js @@ -1,10 +1,5 @@ -define("ace/snippets/text",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "text"; - -}); (function() { +; (function() { window.require(["ace/snippets/text"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/toml.js b/htdocs/includes/ace/src/snippets/toml.js index 4f0c1fa463f..e585672c285 100644 --- a/htdocs/includes/ace/src/snippets/toml.js +++ b/htdocs/includes/ace/src/snippets/toml.js @@ -1,10 +1,5 @@ -define("ace/snippets/toml",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "toml"; - -}); (function() { +; (function() { window.require(["ace/snippets/toml"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/tsx.js b/htdocs/includes/ace/src/snippets/tsx.js index fd1bba27203..f0456fdd9a1 100644 --- a/htdocs/includes/ace/src/snippets/tsx.js +++ b/htdocs/includes/ace/src/snippets/tsx.js @@ -1,10 +1,5 @@ -define("ace/snippets/tsx",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "tsx"; - -}); (function() { +; (function() { window.require(["ace/snippets/tsx"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/turtle.js b/htdocs/includes/ace/src/snippets/turtle.js index c6bc21bfa50..7e0a30cec5b 100644 --- a/htdocs/includes/ace/src/snippets/turtle.js +++ b/htdocs/includes/ace/src/snippets/turtle.js @@ -1,10 +1,5 @@ -define("ace/snippets/turtle",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/turtle"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/twig.js b/htdocs/includes/ace/src/snippets/twig.js index fe757895eb6..2cec7aaa7ff 100644 --- a/htdocs/includes/ace/src/snippets/twig.js +++ b/htdocs/includes/ace/src/snippets/twig.js @@ -1,10 +1,5 @@ -define("ace/snippets/twig",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "twig"; - -}); (function() { +; (function() { window.require(["ace/snippets/twig"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/typescript.js b/htdocs/includes/ace/src/snippets/typescript.js index 2da2fb807fa..27dc42bf129 100644 --- a/htdocs/includes/ace/src/snippets/typescript.js +++ b/htdocs/includes/ace/src/snippets/typescript.js @@ -1,10 +1,5 @@ -define("ace/snippets/typescript",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "typescript"; - -}); (function() { +; (function() { window.require(["ace/snippets/typescript"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/vbscript.js b/htdocs/includes/ace/src/snippets/vbscript.js index 0989a0810c9..637e51913ff 100644 --- a/htdocs/includes/ace/src/snippets/vbscript.js +++ b/htdocs/includes/ace/src/snippets/vbscript.js @@ -1,10 +1,5 @@ -define("ace/snippets/vbscript",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "vbscript"; - -}); (function() { +; (function() { window.require(["ace/snippets/vbscript"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/verilog.js b/htdocs/includes/ace/src/snippets/verilog.js index 2ed2eef0e45..d824e8463ef 100644 --- a/htdocs/includes/ace/src/snippets/verilog.js +++ b/htdocs/includes/ace/src/snippets/verilog.js @@ -1,10 +1,5 @@ -define("ace/snippets/verilog",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "verilog"; - -}); (function() { +; (function() { window.require(["ace/snippets/verilog"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/vhdl.js b/htdocs/includes/ace/src/snippets/vhdl.js index d9b716461be..015c2fbf371 100644 --- a/htdocs/includes/ace/src/snippets/vhdl.js +++ b/htdocs/includes/ace/src/snippets/vhdl.js @@ -1,10 +1,5 @@ -define("ace/snippets/vhdl",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "vhdl"; - -}); (function() { +; (function() { window.require(["ace/snippets/vhdl"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/visualforce.js b/htdocs/includes/ace/src/snippets/visualforce.js index 11c0781cef2..135cf6bdea8 100644 --- a/htdocs/includes/ace/src/snippets/visualforce.js +++ b/htdocs/includes/ace/src/snippets/visualforce.js @@ -1,10 +1,5 @@ -define("ace/snippets/visualforce",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "visualforce"; - -}); (function() { +; (function() { window.require(["ace/snippets/visualforce"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/xml.js b/htdocs/includes/ace/src/snippets/xml.js index 9bbe62ad7b6..927c6659786 100644 --- a/htdocs/includes/ace/src/snippets/xml.js +++ b/htdocs/includes/ace/src/snippets/xml.js @@ -1,10 +1,5 @@ -define("ace/snippets/xml",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "xml"; - -}); (function() { +; (function() { window.require(["ace/snippets/xml"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/yaml.js b/htdocs/includes/ace/src/snippets/yaml.js index bbfecbc21da..13a274dc84c 100644 --- a/htdocs/includes/ace/src/snippets/yaml.js +++ b/htdocs/includes/ace/src/snippets/yaml.js @@ -1,10 +1,5 @@ -define("ace/snippets/yaml",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = "yaml"; - -}); (function() { +; (function() { window.require(["ace/snippets/yaml"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/snippets/zeek.js b/htdocs/includes/ace/src/snippets/zeek.js index e432c22e116..a1fc7cdff3c 100644 --- a/htdocs/includes/ace/src/snippets/zeek.js +++ b/htdocs/includes/ace/src/snippets/zeek.js @@ -1,10 +1,5 @@ -define("ace/snippets/zeek",["require","exports","module"], function(require, exports, module) { -"use strict"; -exports.snippetText =undefined; -exports.scope = ""; - -}); (function() { +; (function() { window.require(["ace/snippets/zeek"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/htdocs/includes/ace/src/theme-ambiance.js b/htdocs/includes/ace/src/theme-ambiance.js index bac9b4d6339..0830aed50b4 100644 --- a/htdocs/includes/ace/src/theme-ambiance.js +++ b/htdocs/includes/ace/src/theme-ambiance.js @@ -25,7 +25,7 @@ color: #777;\ .ace-ambiance .ace_fold-widget.ace_start,\ .ace-ambiance .ace_fold-widget.ace_end,\ .ace-ambiance .ace_fold-widget.ace_closed{\ -background: none;\ +background: none !important;\ border: none;\ box-shadow: none;\ }\ @@ -169,10 +169,11 @@ background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICA }\ .ace-ambiance .ace_indent-guide {\ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNQUFD4z6Crq/sfAAuYAuYl+7lfAAAAAElFTkSuQmCC\") right repeat-y;\ -}"; +}\ +"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/ambiance"], function(m) { diff --git a/htdocs/includes/ace/src/theme-chaos.js b/htdocs/includes/ace/src/theme-chaos.js index 1a46b5b1d02..630a72f72ce 100644 --- a/htdocs/includes/ace/src/theme-chaos.js +++ b/htdocs/includes/ace/src/theme-chaos.js @@ -121,7 +121,7 @@ color: #777;\ .ace-chaos .ace_fold-widget.ace_start,\ .ace-chaos .ace_fold-widget.ace_end,\ .ace-chaos .ace_fold-widget.ace_closed{\ -background: none;\ +background: none !important;\ border: none;\ box-shadow: none;\ }\ @@ -151,7 +151,7 @@ color: #000;\ "; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/chaos"], function(m) { diff --git a/htdocs/includes/ace/src/theme-chrome.js b/htdocs/includes/ace/src/theme-chrome.js index e55118cb13d..9fa527e4a3f 100644 --- a/htdocs/includes/ace/src/theme-chrome.js +++ b/htdocs/includes/ace/src/theme-chrome.js @@ -124,7 +124,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ "; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/chrome"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-clouds.js b/htdocs/includes/ace/src/theme-clouds.js index 01e6cc0b172..2673f62f815 100644 --- a/htdocs/includes/ace/src/theme-clouds.js +++ b/htdocs/includes/ace/src/theme-clouds.js @@ -91,7 +91,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/clouds"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-clouds_midnight.js b/htdocs/includes/ace/src/theme-clouds_midnight.js index 60f0f654365..d88ece21d43 100644 --- a/htdocs/includes/ace/src/theme-clouds_midnight.js +++ b/htdocs/includes/ace/src/theme-clouds_midnight.js @@ -92,7 +92,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/clouds_midnight"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-cobalt.js b/htdocs/includes/ace/src/theme-cobalt.js index 74f20385609..5459c756153 100644 --- a/htdocs/includes/ace/src/theme-cobalt.js +++ b/htdocs/includes/ace/src/theme-cobalt.js @@ -109,7 +109,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb "; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/cobalt"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-crimson_editor.js b/htdocs/includes/ace/src/theme-crimson_editor.js index 88d70538c49..b162e5be5a3 100644 --- a/htdocs/includes/ace/src/theme-crimson_editor.js +++ b/htdocs/includes/ace/src/theme-crimson_editor.js @@ -114,7 +114,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ exports.cssClass = "ace-crimson-editor"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/crimson_editor"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-dawn.js b/htdocs/includes/ace/src/theme-dawn.js index 8a635b3ddff..923dad68d5f 100644 --- a/htdocs/includes/ace/src/theme-dawn.js +++ b/htdocs/includes/ace/src/theme-dawn.js @@ -104,7 +104,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/dawn"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-dracula.js b/htdocs/includes/ace/src/theme-dracula.js index 78942e2867b..3085b9d9693 100644 --- a/htdocs/includes/ace/src/theme-dracula.js +++ b/htdocs/includes/ace/src/theme-dracula.js @@ -124,7 +124,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb exports.$selectionColorConflict = true; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/dracula"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-dreamweaver.js b/htdocs/includes/ace/src/theme-dreamweaver.js index 26abc55bf93..fa9771e9233 100644 --- a/htdocs/includes/ace/src/theme-dreamweaver.js +++ b/htdocs/includes/ace/src/theme-dreamweaver.js @@ -137,7 +137,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/dreamweaver"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-eclipse.js b/htdocs/includes/ace/src/theme-eclipse.js index 31057e66f0f..5deddde3f19 100644 --- a/htdocs/includes/ace/src/theme-eclipse.js +++ b/htdocs/includes/ace/src/theme-eclipse.js @@ -94,7 +94,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ exports.cssClass = "ace-eclipse"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/eclipse"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-github.js b/htdocs/includes/ace/src/theme-github.js index 7f6baf4acd2..12d70bc7746 100644 --- a/htdocs/includes/ace/src/theme-github.js +++ b/htdocs/includes/ace/src/theme-github.js @@ -99,7 +99,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ }"; var dom = require("../lib/dom"); - dom.importCssString(exports.cssText, exports.cssClass); + dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/github"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-gob.js b/htdocs/includes/ace/src/theme-gob.js index 9c03e7bd055..7326db1ec07 100644 --- a/htdocs/includes/ace/src/theme-gob.js +++ b/htdocs/includes/ace/src/theme-gob.js @@ -108,7 +108,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb "; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/gob"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-gruvbox.js b/htdocs/includes/ace/src/theme-gruvbox.js index d2e6ded6b27..c52e8f0fca8 100644 --- a/htdocs/includes/ace/src/theme-gruvbox.js +++ b/htdocs/includes/ace/src/theme-gruvbox.js @@ -77,7 +77,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/gruvbox"], function(m) { diff --git a/htdocs/includes/ace/src/theme-idle_fingers.js b/htdocs/includes/ace/src/theme-idle_fingers.js index 877b884dc3c..1af5e27a28b 100644 --- a/htdocs/includes/ace/src/theme-idle_fingers.js +++ b/htdocs/includes/ace/src/theme-idle_fingers.js @@ -92,7 +92,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/idle_fingers"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-iplastic.js b/htdocs/includes/ace/src/theme-iplastic.js index d09b09f2b42..6eaf7abe3c7 100644 --- a/htdocs/includes/ace/src/theme-iplastic.js +++ b/htdocs/includes/ace/src/theme-iplastic.js @@ -117,7 +117,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/iplastic"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-katzenmilch.js b/htdocs/includes/ace/src/theme-katzenmilch.js index 45dd629a12b..596d9702050 100644 --- a/htdocs/includes/ace/src/theme-katzenmilch.js +++ b/htdocs/includes/ace/src/theme-katzenmilch.js @@ -117,7 +117,7 @@ rbackground-color: rgba(73, 166, 210, 0.039)\ }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/katzenmilch"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-kr_theme.js b/htdocs/includes/ace/src/theme-kr_theme.js index bb32770a2a4..1509c0b1ead 100644 --- a/htdocs/includes/ace/src/theme-kr_theme.js +++ b/htdocs/includes/ace/src/theme-kr_theme.js @@ -100,7 +100,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/kr_theme"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-kuroir.js b/htdocs/includes/ace/src/theme-kuroir.js index 6d12d2c71c0..85af8e85ba9 100644 --- a/htdocs/includes/ace/src/theme-kuroir.js +++ b/htdocs/includes/ace/src/theme-kuroir.js @@ -57,7 +57,7 @@ background-color:rgba(191, 97, 51, 0.051);}.ace-kuroir .ace_markup.ace_list{colo "; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/kuroir"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-merbivore.js b/htdocs/includes/ace/src/theme-merbivore.js index 636fbe44d43..e638fb1c6e7 100644 --- a/htdocs/includes/ace/src/theme-merbivore.js +++ b/htdocs/includes/ace/src/theme-merbivore.js @@ -91,7 +91,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/merbivore"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-merbivore_soft.js b/htdocs/includes/ace/src/theme-merbivore_soft.js index 4ce881ae5a7..d79865b0f66 100644 --- a/htdocs/includes/ace/src/theme-merbivore_soft.js +++ b/htdocs/includes/ace/src/theme-merbivore_soft.js @@ -92,7 +92,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/merbivore_soft"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-mono_industrial.js b/htdocs/includes/ace/src/theme-mono_industrial.js index 6a00097b0d2..0bd57662e85 100644 --- a/htdocs/includes/ace/src/theme-mono_industrial.js +++ b/htdocs/includes/ace/src/theme-mono_industrial.js @@ -103,7 +103,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/mono_industrial"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-monokai.js b/htdocs/includes/ace/src/theme-monokai.js index ce64226bda5..7eed6b445d9 100644 --- a/htdocs/includes/ace/src/theme-monokai.js +++ b/htdocs/includes/ace/src/theme-monokai.js @@ -101,7 +101,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/monokai"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-nord_dark.js b/htdocs/includes/ace/src/theme-nord_dark.js new file mode 100644 index 00000000000..c97f58317ad --- /dev/null +++ b/htdocs/includes/ace/src/theme-nord_dark.js @@ -0,0 +1,102 @@ +define("ace/theme/nord_dark",["require","exports","module","ace/lib/dom"], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-nord-dark"; +exports.cssText = ".ace-nord-dark .ace_gutter {\ +color: #616e88;\ +}\ +.ace-nord-dark .ace_print-margin {\ +width: 1px;\ +background: #4c566a;\ +}\ +.ace-nord-dark {\ +background-color: #2e3440;\ +color: #d8dee9;\ +}\ +.ace-nord-dark .ace_entity.ace_other.ace_attribute-name,\ +.ace-nord-dark .ace_storage {\ +color: #d8dee9;\ +}\ +.ace-nord-dark .ace_cursor {\ +color: #d8dee9;\ +},\ +.ace-nord-dark .ace_string.ace_regexp {\ +color: #bf616a;\ +}\ +.ace-nord-dark .ace_marker-layer .ace_active-line {\ +background: #434c5ecc;\ +}\ +.ace-nord-dark .ace_marker-layer .ace_selection {\ +background: #434c5ecc;\ +}\ +.ace-nord-dark.ace_multiselect .ace_selection.ace_start {\ +box-shadow: 0 0 3px 0px #2e3440;\ +}\ +.ace-nord-dark .ace_marker-layer .ace_step {\ +background: #ebcb8b;\ +}\ +.ace-nord-dark .ace_marker-layer .ace_bracket {\ +margin: -1px 0 0 -1px;\ +border: 1px solid #88c0d066;\ +}\ +.ace-nord-dark .ace_gutter-active-line {\ +background-color: #434c5ecc;\ +}\ +.ace-nord-dark .ace_marker-layer .ace_selected-word {\ +border: 1px solid #88c0d066;\ +}\ +.ace-nord-dark .ace_invisible {\ +color: #4c566a;\ +}\ +.ace-nord-dark .ace_keyword,\ +.ace-nord-dark .ace_meta,\ +.ace-nord-dark .ace_support.ace_class,\ +.ace-nord-dark .ace_support.ace_type {\ +color: #81a1c1;\ +}\ +.ace-nord-dark .ace_constant.ace_character,\ +.ace-nord-dark .ace_constant.ace_other {\ +color: #d8dee9;\ +}\ +.ace-nord-dark .ace_constant.ace_language {\ +color: #5e81ac;\ +}\ +.ace-nord-dark .ace_constant.ace_escape {\ +color: #ebcB8b;\ +}\ +.ace-nord-dark .ace_constant.ace_numeric {\ +color: #b48ead;\ +}\ +.ace-nord-dark .ace_fold {\ +background-color: #4c566a;\ +border-color: #d8dee9;\ +}\ +.ace-nord-dark .ace_entity.ace_name.ace_function,\ +.ace-nord-dark .ace_entity.ace_name.ace_tag,\ +.ace-nord-dark .ace_support.ace_function,\ +.ace-nord-dark .ace_variable,\ +.ace-nord-dark .ace_variable.ace_language {\ +color: #8fbcbb;\ +}\ +.ace-nord-dark .ace_string {\ +color: #a3be8c;\ +}\ +.ace-nord-dark .ace_comment {\ +color: #616e88;\ +}\ +.ace-nord-dark .ace_indent-guide {\ +box-shadow: inset -1px 0 0 0 #434c5eb3;\ +}\ +"; +exports.$selectionColorConflict = true; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass, false); +}); (function() { + window.require(["ace/theme/nord_dark"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/theme-one_dark.js b/htdocs/includes/ace/src/theme-one_dark.js new file mode 100644 index 00000000000..b99f2287b92 --- /dev/null +++ b/htdocs/includes/ace/src/theme-one_dark.js @@ -0,0 +1,139 @@ +define("ace/theme/one_dark",["require","exports","module","ace/lib/dom"], function(require, exports, module) { + + exports.isDark = true; + exports.cssClass = "ace-one-dark"; + exports.cssText = ".ace-one-dark .ace_gutter {\ +background: #282c34;\ +color: #6a6f7a\ +}\ +.ace-one-dark .ace_print-margin {\ +width: 1px;\ +background: #e8e8e8\ +}\ +.ace-one-dark {\ +background-color: #282c34;\ +color: #abb2bf\ +}\ +.ace-one-dark .ace_cursor {\ +color: #528bff\ +}\ +.ace-one-dark .ace_marker-layer .ace_selection {\ +background: #3d4350\ +}\ +.ace-one-dark.ace_multiselect .ace_selection.ace_start {\ +box-shadow: 0 0 3px 0 #282c34;\ +border-radius: 2px\ +}\ +.ace-one-dark .ace_marker-layer .ace_step {\ +background: #c6dbae\ +}\ +.ace-one-dark .ace_marker-layer .ace_bracket {\ +margin: -1px 0 0 -1px;\ +border: 1px solid #747369\ +}\ +.ace-one-dark .ace_marker-layer .ace_active-line {\ +background: rgba(76, 87, 103, .19)\ +}\ +.ace-one-dark .ace_gutter-active-line {\ +background-color: rgba(76, 87, 103, .19)\ +}\ +.ace-one-dark .ace_marker-layer .ace_selected-word {\ +border: 1px solid #3d4350\ +}\ +.ace-one-dark .ace_fold {\ +background-color: #61afef;\ +border-color: #abb2bf\ +}\ +.ace-one-dark .ace_keyword {\ +color: #c678dd\ +}\ +.ace-one-dark .ace_keyword.ace_operator {\ +color: #c678dd\ +}\ +.ace-one-dark .ace_keyword.ace_other.ace_unit {\ +color: #d19a66\ +}\ +.ace-one-dark .ace_constant.ace_language {\ +color: #d19a66\ +}\ +.ace-one-dark .ace_constant.ace_numeric {\ +color: #d19a66\ +}\ +.ace-one-dark .ace_constant.ace_character {\ +color: #56b6c2\ +}\ +.ace-one-dark .ace_constant.ace_other {\ +color: #56b6c2\ +}\ +.ace-one-dark .ace_support.ace_function {\ +color: #61afef\ +}\ +.ace-one-dark .ace_support.ace_constant {\ +color: #d19a66\ +}\ +.ace-one-dark .ace_support.ace_class {\ +color: #e5c07b\ +}\ +.ace-one-dark .ace_support.ace_type {\ +color: #e5c07b\ +}\ +.ace-one-dark .ace_storage {\ +color: #c678dd\ +}\ +.ace-one-dark .ace_storage.ace_type {\ +color: #c678dd\ +}\ +.ace-one-dark .ace_invalid {\ +color: #fff;\ +background-color: #f2777a\ +}\ +.ace-one-dark .ace_invalid.ace_deprecated {\ +color: #272b33;\ +background-color: #d27b53\ +}\ +.ace-one-dark .ace_string {\ +color: #98c379\ +}\ +.ace-one-dark .ace_string.ace_regexp {\ +color: #e06c75\ +}\ +.ace-one-dark .ace_comment {\ +font-style: italic;\ +color: #5c6370\ +}\ +.ace-one-dark .ace_variable {\ +color: #e06c75\ +}\ +.ace-one-dark .ace_variable.ace_parameter {\ +color: #d19a66\ +}\ +.ace-one-dark .ace_meta.ace_tag {\ +color: #e06c75\ +}\ +.ace-one-dark .ace_entity.ace_other.ace_attribute-name {\ +color: #e06c75\ +}\ +.ace-one-dark .ace_entity.ace_name.ace_function {\ +color: #61afef\ +}\ +.ace-one-dark .ace_entity.ace_name.ace_tag {\ +color: #e06c75\ +}\ +.ace-one-dark .ace_markup.ace_heading {\ +color: #98c379\ +}\ +.ace-one-dark .ace_indent-guide {\ +background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ09NrYAgMjP4PAAtGAwchHMyAAAAAAElFTkSuQmCC) right repeat-y\ +}\ +"; + + var dom = require("../lib/dom"); + dom.importCssString(exports.cssText, exports.cssClass, false); + }); (function() { + window.require(["ace/theme/one_dark"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/htdocs/includes/ace/src/theme-pastel_on_dark.js b/htdocs/includes/ace/src/theme-pastel_on_dark.js index e02957c99b8..cc51053dc43 100644 --- a/htdocs/includes/ace/src/theme-pastel_on_dark.js +++ b/htdocs/includes/ace/src/theme-pastel_on_dark.js @@ -104,7 +104,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/pastel_on_dark"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-solarized_dark.js b/htdocs/includes/ace/src/theme-solarized_dark.js index dad8d3896b9..e9a2664d166 100644 --- a/htdocs/includes/ace/src/theme-solarized_dark.js +++ b/htdocs/includes/ace/src/theme-solarized_dark.js @@ -84,7 +84,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/solarized_dark"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-solarized_light.js b/htdocs/includes/ace/src/theme-solarized_light.js index 70f9383041c..2746ea63c78 100644 --- a/htdocs/includes/ace/src/theme-solarized_light.js +++ b/htdocs/includes/ace/src/theme-solarized_light.js @@ -87,7 +87,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/solarized_light"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-sqlserver.js b/htdocs/includes/ace/src/theme-sqlserver.js index 91724014b01..1b626a28fcf 100644 --- a/htdocs/includes/ace/src/theme-sqlserver.js +++ b/htdocs/includes/ace/src/theme-sqlserver.js @@ -134,7 +134,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ "; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/sqlserver"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-terminal.js b/htdocs/includes/ace/src/theme-terminal.js index 8f87077cae7..b10de0bd323 100644 --- a/htdocs/includes/ace/src/theme-terminal.js +++ b/htdocs/includes/ace/src/theme-terminal.js @@ -110,7 +110,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb "; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/terminal"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-textmate.js b/htdocs/includes/ace/src/theme-textmate.js index 6ad09556895..dc651d74b73 100644 --- a/htdocs/includes/ace/src/theme-textmate.js +++ b/htdocs/includes/ace/src/theme-textmate.js @@ -126,7 +126,7 @@ background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZ exports.$id = "ace/theme/textmate"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/textmate"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-tomorrow.js b/htdocs/includes/ace/src/theme-tomorrow.js index 5a2e3b5a4f2..b1f73da83b6 100644 --- a/htdocs/includes/ace/src/theme-tomorrow.js +++ b/htdocs/includes/ace/src/theme-tomorrow.js @@ -104,7 +104,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/tomorrow"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-tomorrow_night.js b/htdocs/includes/ace/src/theme-tomorrow_night.js index 9cdeedce37b..36c748fd64b 100644 --- a/htdocs/includes/ace/src/theme-tomorrow_night.js +++ b/htdocs/includes/ace/src/theme-tomorrow_night.js @@ -104,7 +104,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/tomorrow_night"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-tomorrow_night_blue.js b/htdocs/includes/ace/src/theme-tomorrow_night_blue.js index 52afc918d78..7bf7fc64680 100644 --- a/htdocs/includes/ace/src/theme-tomorrow_night_blue.js +++ b/htdocs/includes/ace/src/theme-tomorrow_night_blue.js @@ -102,7 +102,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/tomorrow_night_blue"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-tomorrow_night_bright.js b/htdocs/includes/ace/src/theme-tomorrow_night_bright.js index b90c17921a4..3bf12ddd420 100644 --- a/htdocs/includes/ace/src/theme-tomorrow_night_bright.js +++ b/htdocs/includes/ace/src/theme-tomorrow_night_bright.js @@ -117,7 +117,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/tomorrow_night_bright"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-tomorrow_night_eighties.js b/htdocs/includes/ace/src/theme-tomorrow_night_eighties.js index 5759eadbc3d..e5c48fcaedf 100644 --- a/htdocs/includes/ace/src/theme-tomorrow_night_eighties.js +++ b/htdocs/includes/ace/src/theme-tomorrow_night_eighties.js @@ -104,7 +104,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/tomorrow_night_eighties"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-twilight.js b/htdocs/includes/ace/src/theme-twilight.js index 34857c311a4..03e9d07da2a 100644 --- a/htdocs/includes/ace/src/theme-twilight.js +++ b/htdocs/includes/ace/src/theme-twilight.js @@ -80,8 +80,7 @@ color: #DAD085\ color: #F9EE98\ }\ .ace-twilight .ace_entity.ace_name.ace_function,\ -.ace-twilight .ace_meta.ace_tag,\ -.ace-twilight .ace_variable {\ +.ace-twilight .ace_meta.ace_tag {\ color: #AC885B\ }\ .ace-twilight .ace_string {\ @@ -102,10 +101,11 @@ color: #494949\ }\ .ace-twilight .ace_indent-guide {\ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWMQERFpYLC1tf0PAAgOAnPnhxyiAAAAAElFTkSuQmCC) right repeat-y\ -}"; +}\ +"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/twilight"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-vibrant_ink.js b/htdocs/includes/ace/src/theme-vibrant_ink.js index 6fbc5094c93..26f7de9043a 100644 --- a/htdocs/includes/ace/src/theme-vibrant_ink.js +++ b/htdocs/includes/ace/src/theme-vibrant_ink.js @@ -90,7 +90,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/vibrant_ink"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/theme-xcode.js b/htdocs/includes/ace/src/theme-xcode.js index 99a5b75ef9a..daded3a15eb 100644 --- a/htdocs/includes/ace/src/theme-xcode.js +++ b/htdocs/includes/ace/src/theme-xcode.js @@ -84,7 +84,7 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb }"; var dom = require("../lib/dom"); -dom.importCssString(exports.cssText, exports.cssClass); +dom.importCssString(exports.cssText, exports.cssClass, false); }); (function() { window.require(["ace/theme/xcode"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { diff --git a/htdocs/includes/ace/src/worker-base.js b/htdocs/includes/ace/src/worker-base.js new file mode 100644 index 00000000000..ca582ac58ec --- /dev/null +++ b/htdocs/includes/ace/src/worker-base.js @@ -0,0 +1,1421 @@ +"no use strict"; +!(function(window) { +if (typeof window.window != "undefined" && window.document) + return; +if (window.require && window.define) + return; + +if (!window.console) { + window.console = function() { + var msgs = Array.prototype.slice.call(arguments, 0); + postMessage({type: "log", data: msgs}); + }; + window.console.error = + window.console.warn = + window.console.log = + window.console.trace = window.console; +} +window.window = window; +window.ace = window; + +window.onerror = function(message, file, line, col, err) { + postMessage({type: "error", data: { + message: message, + data: err.data, + file: file, + line: line, + col: col, + stack: err.stack + }}); +}; + +window.normalizeModule = function(parentId, moduleName) { + // normalize plugin requires + if (moduleName.indexOf("!") !== -1) { + var chunks = moduleName.split("!"); + return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]); + } + // normalize relative requires + if (moduleName.charAt(0) == ".") { + var base = parentId.split("/").slice(0, -1).join("/"); + moduleName = (base ? base + "/" : "") + moduleName; + + while (moduleName.indexOf(".") !== -1 && previous != moduleName) { + var previous = moduleName; + moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + } + } + + return moduleName; +}; + +window.require = function require(parentId, id) { + if (!id) { + id = parentId; + parentId = null; + } + if (!id.charAt) + throw new Error("worker.js require() accepts only (parentId, id) as arguments"); + + id = window.normalizeModule(parentId, id); + + var module = window.require.modules[id]; + if (module) { + if (!module.initialized) { + module.initialized = true; + module.exports = module.factory().exports; + } + return module.exports; + } + + if (!window.require.tlns) + return console.log("unable to load " + id); + + var path = resolveModuleId(id, window.require.tlns); + if (path.slice(-3) != ".js") path += ".js"; + + window.require.id = id; + window.require.modules[id] = {}; // prevent infinite loop on broken modules + importScripts(path); + return window.require(parentId, id); +}; +function resolveModuleId(id, paths) { + var testPath = id, tail = ""; + while (testPath) { + var alias = paths[testPath]; + if (typeof alias == "string") { + return alias + tail; + } else if (alias) { + return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name); + } else if (alias === false) { + return ""; + } + var i = testPath.lastIndexOf("/"); + if (i === -1) break; + tail = testPath.substr(i) + tail; + testPath = testPath.slice(0, i); + } + return id; +} +window.require.modules = {}; +window.require.tlns = {}; + +window.define = function(id, deps, factory) { + if (arguments.length == 2) { + factory = deps; + if (typeof id != "string") { + deps = id; + id = window.require.id; + } + } else if (arguments.length == 1) { + factory = id; + deps = []; + id = window.require.id; + } + + if (typeof factory != "function") { + window.require.modules[id] = { + exports: factory, + initialized: true + }; + return; + } + + if (!deps.length) + // If there is no dependencies, we inject "require", "exports" and + // "module" as dependencies, to provide CommonJS compatibility. + deps = ["require", "exports", "module"]; + + var req = function(childId) { + return window.require(id, childId); + }; + + window.require.modules[id] = { + exports: {}, + factory: function() { + var module = this; + var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) { + switch (dep) { + // Because "require", "exports" and "module" aren't actual + // dependencies, we must handle them seperately. + case "require": return req; + case "exports": return module.exports; + case "module": return module; + // But for all other dependencies, we can just go ahead and + // require them. + default: return req(dep); + } + })); + if (returnExports) + module.exports = returnExports; + return module; + } + }; +}; +window.define.amd = {}; +require.tlns = {}; +window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { + for (var i in topLevelNamespaces) + require.tlns[i] = topLevelNamespaces[i]; +}; + +window.initSender = function initSender() { + + var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter; + var oop = window.require("ace/lib/oop"); + + var Sender = function() {}; + + (function() { + + oop.implement(this, EventEmitter); + + this.callback = function(data, callbackId) { + postMessage({ + type: "call", + id: callbackId, + data: data + }); + }; + + this.emit = function(name, data) { + postMessage({ + type: "event", + name: name, + data: data + }); + }; + + }).call(Sender.prototype); + + return new Sender(); +}; + +var main = window.main = null; +var sender = window.sender = null; + +window.onmessage = function(e) { + var msg = e.data; + if (msg.event && sender) { + sender._signal(msg.event, msg.data); + } + else if (msg.command) { + if (main[msg.command]) + main[msg.command].apply(main, msg.args); + else if (window[msg.command]) + window[msg.command].apply(window, msg.args); + else + throw new Error("Unknown command:" + msg.command); + } + else if (msg.init) { + window.initBaseUrls(msg.tlns); + sender = window.sender = window.initSender(); + var clazz = require(msg.module)[msg.classname]; + main = window.main = new clazz(sender); + } +}; +})(this); + +define("ace/range",[], function(require, exports, module) { +"use strict"; +var comparePoints = function(p1, p2) { + return p1.row - p2.row || p1.column - p2.column; +}; +var Range = function(startRow, startColumn, endRow, endColumn) { + this.start = { + row: startRow, + column: startColumn + }; + + this.end = { + row: endRow, + column: endColumn + }; +}; + +(function() { + this.isEqual = function(range) { + return this.start.row === range.start.row && + this.end.row === range.end.row && + this.start.column === range.start.column && + this.end.column === range.end.column; + }; + this.toString = function() { + return ("Range: [" + this.start.row + "/" + this.start.column + + "] -> [" + this.end.row + "/" + this.end.column + "]"); + }; + + this.contains = function(row, column) { + return this.compare(row, column) == 0; + }; + this.compareRange = function(range) { + var cmp, + end = range.end, + start = range.start; + + cmp = this.compare(end.row, end.column); + if (cmp == 1) { + cmp = this.compare(start.row, start.column); + if (cmp == 1) { + return 2; + } else if (cmp == 0) { + return 1; + } else { + return 0; + } + } else if (cmp == -1) { + return -2; + } else { + cmp = this.compare(start.row, start.column); + if (cmp == -1) { + return -1; + } else if (cmp == 1) { + return 42; + } else { + return 0; + } + } + }; + this.comparePoint = function(p) { + return this.compare(p.row, p.column); + }; + this.containsRange = function(range) { + return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; + }; + this.intersects = function(range) { + var cmp = this.compareRange(range); + return (cmp == -1 || cmp == 0 || cmp == 1); + }; + this.isEnd = function(row, column) { + return this.end.row == row && this.end.column == column; + }; + this.isStart = function(row, column) { + return this.start.row == row && this.start.column == column; + }; + this.setStart = function(row, column) { + if (typeof row == "object") { + this.start.column = row.column; + this.start.row = row.row; + } else { + this.start.row = row; + this.start.column = column; + } + }; + this.setEnd = function(row, column) { + if (typeof row == "object") { + this.end.column = row.column; + this.end.row = row.row; + } else { + this.end.row = row; + this.end.column = column; + } + }; + this.inside = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column) || this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.insideStart = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.insideEnd = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.compare = function(row, column) { + if (!this.isMultiLine()) { + if (row === this.start.row) { + return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); + } + } + + if (row < this.start.row) + return -1; + + if (row > this.end.row) + return 1; + + if (this.start.row === row) + return column >= this.start.column ? 0 : -1; + + if (this.end.row === row) + return column <= this.end.column ? 0 : 1; + + return 0; + }; + this.compareStart = function(row, column) { + if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + }; + this.compareEnd = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else { + return this.compare(row, column); + } + }; + this.compareInside = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + }; + this.clipRows = function(firstRow, lastRow) { + if (this.end.row > lastRow) + var end = {row: lastRow + 1, column: 0}; + else if (this.end.row < firstRow) + var end = {row: firstRow, column: 0}; + + if (this.start.row > lastRow) + var start = {row: lastRow + 1, column: 0}; + else if (this.start.row < firstRow) + var start = {row: firstRow, column: 0}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + this.extend = function(row, column) { + var cmp = this.compare(row, column); + + if (cmp == 0) + return this; + else if (cmp == -1) + var start = {row: row, column: column}; + else + var end = {row: row, column: column}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + + this.isEmpty = function() { + return (this.start.row === this.end.row && this.start.column === this.end.column); + }; + this.isMultiLine = function() { + return (this.start.row !== this.end.row); + }; + this.clone = function() { + return Range.fromPoints(this.start, this.end); + }; + this.collapseRows = function() { + if (this.end.column == 0) + return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0); + else + return new Range(this.start.row, 0, this.end.row, 0); + }; + this.toScreenRange = function(session) { + var screenPosStart = session.documentToScreenPosition(this.start); + var screenPosEnd = session.documentToScreenPosition(this.end); + + return new Range( + screenPosStart.row, screenPosStart.column, + screenPosEnd.row, screenPosEnd.column + ); + }; + this.moveBy = function(row, column) { + this.start.row += row; + this.start.column += column; + this.end.row += row; + this.end.column += column; + }; + +}).call(Range.prototype); +Range.fromPoints = function(start, end) { + return new Range(start.row, start.column, end.row, end.column); +}; +Range.comparePoints = comparePoints; + +Range.comparePoints = function(p1, p2) { + return p1.row - p2.row || p1.column - p2.column; +}; + + +exports.Range = Range; +}); + +define("ace/lib/oop",[], function(require, exports, module) { +"use strict"; + +exports.inherits = function(ctor, superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); +}; + +exports.mixin = function(obj, mixin) { + for (var key in mixin) { + obj[key] = mixin[key]; + } + return obj; +}; + +exports.implement = function(proto, mixin) { + exports.mixin(proto, mixin); +}; + +}); + +define("ace/apply_delta",[], function(require, exports, module) { +"use strict"; + +function throwDeltaError(delta, errorText){ + console.log("Invalid Delta:", delta); + throw "Invalid Delta: " + errorText; +} + +function positionInDocument(docLines, position) { + return position.row >= 0 && position.row < docLines.length && + position.column >= 0 && position.column <= docLines[position.row].length; +} + +function validateDelta(docLines, delta) { + if (delta.action != "insert" && delta.action != "remove") + throwDeltaError(delta, "delta.action must be 'insert' or 'remove'"); + if (!(delta.lines instanceof Array)) + throwDeltaError(delta, "delta.lines must be an Array"); + if (!delta.start || !delta.end) + throwDeltaError(delta, "delta.start/end must be an present"); + var start = delta.start; + if (!positionInDocument(docLines, delta.start)) + throwDeltaError(delta, "delta.start must be contained in document"); + var end = delta.end; + if (delta.action == "remove" && !positionInDocument(docLines, end)) + throwDeltaError(delta, "delta.end must contained in document for 'remove' actions"); + var numRangeRows = end.row - start.row; + var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0)); + if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars) + throwDeltaError(delta, "delta.range must match delta lines"); +} + +exports.applyDelta = function(docLines, delta, doNotValidate) { + + var row = delta.start.row; + var startColumn = delta.start.column; + var line = docLines[row] || ""; + switch (delta.action) { + case "insert": + var lines = delta.lines; + if (lines.length === 1) { + docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn); + } else { + var args = [row, 1].concat(delta.lines); + docLines.splice.apply(docLines, args); + docLines[row] = line.substring(0, startColumn) + docLines[row]; + docLines[row + delta.lines.length - 1] += line.substring(startColumn); + } + break; + case "remove": + var endColumn = delta.end.column; + var endRow = delta.end.row; + if (row === endRow) { + docLines[row] = line.substring(0, startColumn) + line.substring(endColumn); + } else { + docLines.splice( + row, endRow - row + 1, + line.substring(0, startColumn) + docLines[endRow].substring(endColumn) + ); + } + break; + } +}; +}); + +define("ace/lib/event_emitter",[], function(require, exports, module) { +"use strict"; + +var EventEmitter = {}; +var stopPropagation = function() { this.propagationStopped = true; }; +var preventDefault = function() { this.defaultPrevented = true; }; + +EventEmitter._emit = +EventEmitter._dispatchEvent = function(eventName, e) { + this._eventRegistry || (this._eventRegistry = {}); + this._defaultHandlers || (this._defaultHandlers = {}); + + var listeners = this._eventRegistry[eventName] || []; + var defaultHandler = this._defaultHandlers[eventName]; + if (!listeners.length && !defaultHandler) + return; + + if (typeof e != "object" || !e) + e = {}; + + if (!e.type) + e.type = eventName; + if (!e.stopPropagation) + e.stopPropagation = stopPropagation; + if (!e.preventDefault) + e.preventDefault = preventDefault; + + listeners = listeners.slice(); + for (var i=0; i this.row) + return; + + var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight); + this.setPosition(point.row, point.column, true); + }; + + function $pointsInOrder(point1, point2, equalPointsInOrder) { + var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column; + return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter); + } + + function $getTransformedPoint(delta, point, moveIfEqual) { + var deltaIsInsert = delta.action == "insert"; + var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row); + var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column); + var deltaStart = delta.start; + var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range. + if ($pointsInOrder(point, deltaStart, moveIfEqual)) { + return { + row: point.row, + column: point.column + }; + } + if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) { + return { + row: point.row + deltaRowShift, + column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0) + }; + } + + return { + row: deltaStart.row, + column: deltaStart.column + }; + } + this.setPosition = function(row, column, noClip) { + var pos; + if (noClip) { + pos = { + row: row, + column: column + }; + } else { + pos = this.$clipPositionToDocument(row, column); + } + + if (this.row == pos.row && this.column == pos.column) + return; + + var old = { + row: this.row, + column: this.column + }; + + this.row = pos.row; + this.column = pos.column; + this._signal("change", { + old: old, + value: pos + }); + }; + this.detach = function() { + this.document.off("change", this.$onChange); + }; + this.attach = function(doc) { + this.document = doc || this.document; + this.document.on("change", this.$onChange); + }; + this.$clipPositionToDocument = function(row, column) { + var pos = {}; + + if (row >= this.document.getLength()) { + pos.row = Math.max(0, this.document.getLength() - 1); + pos.column = this.document.getLine(pos.row).length; + } + else if (row < 0) { + pos.row = 0; + pos.column = 0; + } + else { + pos.row = row; + pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); + } + + if (column < 0) + pos.column = 0; + + return pos; + }; + +}).call(Anchor.prototype); + +}); + +define("ace/document",[], function(require, exports, module) { +"use strict"; + +var oop = require("./lib/oop"); +var applyDelta = require("./apply_delta").applyDelta; +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var Range = require("./range").Range; +var Anchor = require("./anchor").Anchor; + +var Document = function(textOrLines) { + this.$lines = [""]; + if (textOrLines.length === 0) { + this.$lines = [""]; + } else if (Array.isArray(textOrLines)) { + this.insertMergedLines({row: 0, column: 0}, textOrLines); + } else { + this.insert({row: 0, column:0}, textOrLines); + } +}; + +(function() { + + oop.implement(this, EventEmitter); + this.setValue = function(text) { + var len = this.getLength() - 1; + this.remove(new Range(0, 0, len, this.getLine(len).length)); + this.insert({row: 0, column: 0}, text); + }; + this.getValue = function() { + return this.getAllLines().join(this.getNewLineCharacter()); + }; + this.createAnchor = function(row, column) { + return new Anchor(this, row, column); + }; + if ("aaa".split(/a/).length === 0) { + this.$split = function(text) { + return text.replace(/\r\n|\r/g, "\n").split("\n"); + }; + } else { + this.$split = function(text) { + return text.split(/\r\n|\r|\n/); + }; + } + + + this.$detectNewLine = function(text) { + var match = text.match(/^.*?(\r\n|\r|\n)/m); + this.$autoNewLine = match ? match[1] : "\n"; + this._signal("changeNewLineMode"); + }; + this.getNewLineCharacter = function() { + switch (this.$newLineMode) { + case "windows": + return "\r\n"; + case "unix": + return "\n"; + default: + return this.$autoNewLine || "\n"; + } + }; + + this.$autoNewLine = ""; + this.$newLineMode = "auto"; + this.setNewLineMode = function(newLineMode) { + if (this.$newLineMode === newLineMode) + return; + + this.$newLineMode = newLineMode; + this._signal("changeNewLineMode"); + }; + this.getNewLineMode = function() { + return this.$newLineMode; + }; + this.isNewLine = function(text) { + return (text == "\r\n" || text == "\r" || text == "\n"); + }; + this.getLine = function(row) { + return this.$lines[row] || ""; + }; + this.getLines = function(firstRow, lastRow) { + return this.$lines.slice(firstRow, lastRow + 1); + }; + this.getAllLines = function() { + return this.getLines(0, this.getLength()); + }; + this.getLength = function() { + return this.$lines.length; + }; + this.getTextRange = function(range) { + return this.getLinesForRange(range).join(this.getNewLineCharacter()); + }; + this.getLinesForRange = function(range) { + var lines; + if (range.start.row === range.end.row) { + lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)]; + } else { + lines = this.getLines(range.start.row, range.end.row); + lines[0] = (lines[0] || "").substring(range.start.column); + var l = lines.length - 1; + if (range.end.row - range.start.row == l) + lines[l] = lines[l].substring(0, range.end.column); + } + return lines; + }; + this.insertLines = function(row, lines) { + console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."); + return this.insertFullLines(row, lines); + }; + this.removeLines = function(firstRow, lastRow) { + console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."); + return this.removeFullLines(firstRow, lastRow); + }; + this.insertNewLine = function(position) { + console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."); + return this.insertMergedLines(position, ["", ""]); + }; + this.insert = function(position, text) { + if (this.getLength() <= 1) + this.$detectNewLine(text); + + return this.insertMergedLines(position, this.$split(text)); + }; + this.insertInLine = function(position, text) { + var start = this.clippedPos(position.row, position.column); + var end = this.pos(position.row, position.column + text.length); + + this.applyDelta({ + start: start, + end: end, + action: "insert", + lines: [text] + }, true); + + return this.clonePos(end); + }; + + this.clippedPos = function(row, column) { + var length = this.getLength(); + if (row === undefined) { + row = length; + } else if (row < 0) { + row = 0; + } else if (row >= length) { + row = length - 1; + column = undefined; + } + var line = this.getLine(row); + if (column == undefined) + column = line.length; + column = Math.min(Math.max(column, 0), line.length); + return {row: row, column: column}; + }; + + this.clonePos = function(pos) { + return {row: pos.row, column: pos.column}; + }; + + this.pos = function(row, column) { + return {row: row, column: column}; + }; + + this.$clipPosition = function(position) { + var length = this.getLength(); + if (position.row >= length) { + position.row = Math.max(0, length - 1); + position.column = this.getLine(length - 1).length; + } else { + position.row = Math.max(0, position.row); + position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length); + } + return position; + }; + this.insertFullLines = function(row, lines) { + row = Math.min(Math.max(row, 0), this.getLength()); + var column = 0; + if (row < this.getLength()) { + lines = lines.concat([""]); + column = 0; + } else { + lines = [""].concat(lines); + row--; + column = this.$lines[row].length; + } + this.insertMergedLines({row: row, column: column}, lines); + }; + this.insertMergedLines = function(position, lines) { + var start = this.clippedPos(position.row, position.column); + var end = { + row: start.row + lines.length - 1, + column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length + }; + + this.applyDelta({ + start: start, + end: end, + action: "insert", + lines: lines + }); + + return this.clonePos(end); + }; + this.remove = function(range) { + var start = this.clippedPos(range.start.row, range.start.column); + var end = this.clippedPos(range.end.row, range.end.column); + this.applyDelta({ + start: start, + end: end, + action: "remove", + lines: this.getLinesForRange({start: start, end: end}) + }); + return this.clonePos(start); + }; + this.removeInLine = function(row, startColumn, endColumn) { + var start = this.clippedPos(row, startColumn); + var end = this.clippedPos(row, endColumn); + + this.applyDelta({ + start: start, + end: end, + action: "remove", + lines: this.getLinesForRange({start: start, end: end}) + }, true); + + return this.clonePos(start); + }; + this.removeFullLines = function(firstRow, lastRow) { + firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1); + lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1); + var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0; + var deleteLastNewLine = lastRow < this.getLength() - 1; + var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow ); + var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 ); + var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow ); + var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length ); + var range = new Range(startRow, startCol, endRow, endCol); + var deletedLines = this.$lines.slice(firstRow, lastRow + 1); + + this.applyDelta({ + start: range.start, + end: range.end, + action: "remove", + lines: this.getLinesForRange(range) + }); + return deletedLines; + }; + this.removeNewLine = function(row) { + if (row < this.getLength() - 1 && row >= 0) { + this.applyDelta({ + start: this.pos(row, this.getLine(row).length), + end: this.pos(row + 1, 0), + action: "remove", + lines: ["", ""] + }); + } + }; + this.replace = function(range, text) { + if (!(range instanceof Range)) + range = Range.fromPoints(range.start, range.end); + if (text.length === 0 && range.isEmpty()) + return range.start; + if (text == this.getTextRange(range)) + return range.end; + + this.remove(range); + var end; + if (text) { + end = this.insert(range.start, text); + } + else { + end = range.start; + } + + return end; + }; + this.applyDeltas = function(deltas) { + for (var i=0; i=0; i--) { + this.revertDelta(deltas[i]); + } + }; + this.applyDelta = function(delta, doNotValidate) { + var isInsert = delta.action == "insert"; + if (isInsert ? delta.lines.length <= 1 && !delta.lines[0] + : !Range.comparePoints(delta.start, delta.end)) { + return; + } + + if (isInsert && delta.lines.length > 20000) { + this.$splitAndapplyLargeDelta(delta, 20000); + } + else { + applyDelta(this.$lines, delta, doNotValidate); + this._signal("change", delta); + } + }; + + this.$safeApplyDelta = function(delta) { + var docLength = this.$lines.length; + if ( + delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength + || delta.action == "insert" && delta.start.row <= docLength + ) { + this.applyDelta(delta); + } + }; + + this.$splitAndapplyLargeDelta = function(delta, MAX) { + var lines = delta.lines; + var l = lines.length - MAX + 1; + var row = delta.start.row; + var column = delta.start.column; + for (var from = 0, to = 0; from < l; from = to) { + to += MAX - 1; + var chunk = lines.slice(from, to); + chunk.push(""); + this.applyDelta({ + start: this.pos(row + from, column), + end: this.pos(row + to, column = 0), + action: delta.action, + lines: chunk + }, true); + } + delta.lines = lines.slice(from); + delta.start.row = row + from; + delta.start.column = column; + this.applyDelta(delta, true); + }; + this.revertDelta = function(delta) { + this.$safeApplyDelta({ + start: this.clonePos(delta.start), + end: this.clonePos(delta.end), + action: (delta.action == "insert" ? "remove" : "insert"), + lines: delta.lines.slice() + }); + }; + this.indexToPosition = function(index, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + for (var i = startRow || 0, l = lines.length; i < l; i++) { + index -= lines[i].length + newlineLength; + if (index < 0) + return {row: i, column: index + lines[i].length + newlineLength}; + } + return {row: l-1, column: index + lines[l-1].length + newlineLength}; + }; + this.positionToIndex = function(pos, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + var index = 0; + var row = Math.min(pos.row, lines.length); + for (var i = startRow || 0; i < row; ++i) + index += lines[i].length + newlineLength; + + return index + pos.column; + }; + +}).call(Document.prototype); + +exports.Document = Document; +}); + +define("ace/lib/lang",[], function(require, exports, module) { +"use strict"; + +exports.last = function(a) { + return a[a.length - 1]; +}; + +exports.stringReverse = function(string) { + return string.split("").reverse().join(""); +}; + +exports.stringRepeat = function (string, count) { + var result = ''; + while (count > 0) { + if (count & 1) + result += string; + + if (count >>= 1) + string += string; + } + return result; +}; + +var trimBeginRegexp = /^\s\s*/; +var trimEndRegexp = /\s\s*$/; + +exports.stringTrimLeft = function (string) { + return string.replace(trimBeginRegexp, ''); +}; + +exports.stringTrimRight = function (string) { + return string.replace(trimEndRegexp, ''); +}; + +exports.copyObject = function(obj) { + var copy = {}; + for (var key in obj) { + copy[key] = obj[key]; + } + return copy; +}; + +exports.copyArray = function(array){ + var copy = []; + for (var i=0, l=array.length; i 0) { - if (pos > length) - pos = length; - } else if (pos == void 0) { - pos = 0; - } else if (pos < 0) { - pos = Math.max(length + pos, 0); - } - - if (!(pos+removeCount < length)) - removeCount = length - pos; - - var removed = this.slice(pos, pos+removeCount); - var insert = slice.call(arguments, 2); - var add = insert.length; - if (pos === length) { - if (add) { - this.push.apply(this, insert); - } - } else { - var remove = Math.min(removeCount, length - pos); - var tailOldPos = pos + remove; - var tailNewPos = tailOldPos + add - remove; - var tailCount = length - tailOldPos; - var lengthAfterRemove = length - remove; - - if (tailNewPos < tailOldPos) { // case A - for (var i = 0; i < tailCount; ++i) { - this[tailNewPos+i] = this[tailOldPos+i]; - } - } else if (tailNewPos > tailOldPos) { // case B - for (i = tailCount; i--; ) { - this[tailNewPos+i] = this[tailOldPos+i]; - } - } // else, add == remove (nothing to do) - - if (add && pos === lengthAfterRemove) { - this.length = lengthAfterRemove; // truncate array - this.push.apply(this, insert); - } else { - this.length = lengthAfterRemove + add; // reserves space - for (i = 0; i < add; ++i) { - this[pos+i] = insert[i]; - } - } - } - return removed; - }; - } -} -if (!Array.isArray) { - Array.isArray = function isArray(obj) { - return _toString(obj) == "[object Array]"; - }; -} -var boxedString = Object("a"), - splitString = boxedString[0] != "a" || !(0 in boxedString); - -if (!Array.prototype.forEach) { - Array.prototype.forEach = function forEach(fun /*, thisp*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - thisp = arguments[1], - i = -1, - length = self.length >>> 0; - if (_toString(fun) != "[object Function]") { - throw new TypeError(); // TODO message - } - - while (++i < length) { - if (i in self) { - fun.call(thisp, self[i], i, object); - } - } - }; -} -if (!Array.prototype.map) { - Array.prototype.map = function map(fun /*, thisp*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - result = Array(length), - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self) - result[i] = fun.call(thisp, self[i], i, object); - } - return result; - }; -} -if (!Array.prototype.filter) { - Array.prototype.filter = function filter(fun /*, thisp */) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - result = [], - value, - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self) { - value = self[i]; - if (fun.call(thisp, value, i, object)) { - result.push(value); - } - } - } - return result; - }; -} -if (!Array.prototype.every) { - Array.prototype.every = function every(fun /*, thisp */) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self && !fun.call(thisp, self[i], i, object)) { - return false; - } - } - return true; - }; -} -if (!Array.prototype.some) { - Array.prototype.some = function some(fun /*, thisp */) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0, - thisp = arguments[1]; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - - for (var i = 0; i < length; i++) { - if (i in self && fun.call(thisp, self[i], i, object)) { - return true; - } - } - return false; - }; -} -if (!Array.prototype.reduce) { - Array.prototype.reduce = function reduce(fun /*, initial*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - if (!length && arguments.length == 1) { - throw new TypeError("reduce of empty array with no initial value"); - } - - var i = 0; - var result; - if (arguments.length >= 2) { - result = arguments[1]; - } else { - do { - if (i in self) { - result = self[i++]; - break; - } - if (++i >= length) { - throw new TypeError("reduce of empty array with no initial value"); - } - } while (true); - } - - for (; i < length; i++) { - if (i in self) { - result = fun.call(void 0, result, self[i], i, object); - } - } - - return result; - }; -} -if (!Array.prototype.reduceRight) { - Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { - var object = toObject(this), - self = splitString && _toString(this) == "[object String]" ? - this.split("") : - object, - length = self.length >>> 0; - if (_toString(fun) != "[object Function]") { - throw new TypeError(fun + " is not a function"); - } - if (!length && arguments.length == 1) { - throw new TypeError("reduceRight of empty array with no initial value"); - } - - var result, i = length - 1; - if (arguments.length >= 2) { - result = arguments[1]; - } else { - do { - if (i in self) { - result = self[i--]; - break; - } - if (--i < 0) { - throw new TypeError("reduceRight of empty array with no initial value"); - } - } while (true); - } - - do { - if (i in this) { - result = fun.call(void 0, result, self[i], i, object); - } - } while (i--); - - return result; - }; -} -if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) { - Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { - var self = splitString && _toString(this) == "[object String]" ? - this.split("") : - toObject(this), - length = self.length >>> 0; - - if (!length) { - return -1; - } - - var i = 0; - if (arguments.length > 1) { - i = toInteger(arguments[1]); - } - i = i >= 0 ? i : Math.max(0, length + i); - for (; i < length; i++) { - if (i in self && self[i] === sought) { - return i; - } - } - return -1; - }; -} -if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) { - Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { - var self = splitString && _toString(this) == "[object String]" ? - this.split("") : - toObject(this), - length = self.length >>> 0; - - if (!length) { - return -1; - } - var i = length - 1; - if (arguments.length > 1) { - i = Math.min(i, toInteger(arguments[1])); - } - i = i >= 0 ? i : length - Math.abs(i); - for (; i >= 0; i--) { - if (i in self && sought === self[i]) { - return i; - } - } - return -1; - }; -} -if (!Object.getPrototypeOf) { - Object.getPrototypeOf = function getPrototypeOf(object) { - return object.__proto__ || ( - object.constructor ? - object.constructor.prototype : - prototypeOfObject - ); - }; -} -if (!Object.getOwnPropertyDescriptor) { - var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + - "non-object: "; - Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { - if ((typeof object != "object" && typeof object != "function") || object === null) - throw new TypeError(ERR_NON_OBJECT + object); - if (!owns(object, property)) - return; - - var descriptor, getter, setter; - descriptor = { enumerable: true, configurable: true }; - if (supportsAccessors) { - var prototype = object.__proto__; - object.__proto__ = prototypeOfObject; - - var getter = lookupGetter(object, property); - var setter = lookupSetter(object, property); - object.__proto__ = prototype; - - if (getter || setter) { - if (getter) descriptor.get = getter; - if (setter) descriptor.set = setter; - return descriptor; - } - } - descriptor.value = object[property]; - return descriptor; - }; -} -if (!Object.getOwnPropertyNames) { - Object.getOwnPropertyNames = function getOwnPropertyNames(object) { - return Object.keys(object); - }; -} -if (!Object.create) { - var createEmpty; - if (Object.prototype.__proto__ === null) { - createEmpty = function () { - return { "__proto__": null }; - }; - } else { - createEmpty = function () { - var empty = {}; - for (var i in empty) - empty[i] = null; - empty.constructor = - empty.hasOwnProperty = - empty.propertyIsEnumerable = - empty.isPrototypeOf = - empty.toLocaleString = - empty.toString = - empty.valueOf = - empty.__proto__ = null; - return empty; - } - } - - Object.create = function create(prototype, properties) { - var object; - if (prototype === null) { - object = createEmpty(); - } else { - if (typeof prototype != "object") - throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); - var Type = function () {}; - Type.prototype = prototype; - object = new Type(); - object.__proto__ = prototype; - } - if (properties !== void 0) - Object.defineProperties(object, properties); - return object; - }; -} - -function doesDefinePropertyWork(object) { - try { - Object.defineProperty(object, "sentinel", {}); - return "sentinel" in object; - } catch (exception) { - } -} -if (Object.defineProperty) { - var definePropertyWorksOnObject = doesDefinePropertyWork({}); - var definePropertyWorksOnDom = typeof document == "undefined" || - doesDefinePropertyWork(document.createElement("div")); - if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { - var definePropertyFallback = Object.defineProperty; - } -} - -if (!Object.defineProperty || definePropertyFallback) { - var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; - var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " - var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + - "on this javascript engine"; - - Object.defineProperty = function defineProperty(object, property, descriptor) { - if ((typeof object != "object" && typeof object != "function") || object === null) - throw new TypeError(ERR_NON_OBJECT_TARGET + object); - if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) - throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); - if (definePropertyFallback) { - try { - return definePropertyFallback.call(Object, object, property, descriptor); - } catch (exception) { - } - } - if (owns(descriptor, "value")) { - - if (supportsAccessors && (lookupGetter(object, property) || - lookupSetter(object, property))) - { - var prototype = object.__proto__; - object.__proto__ = prototypeOfObject; - delete object[property]; - object[property] = descriptor.value; - object.__proto__ = prototype; - } else { - object[property] = descriptor.value; - } - } else { - if (!supportsAccessors) - throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); - if (owns(descriptor, "get")) - defineGetter(object, property, descriptor.get); - if (owns(descriptor, "set")) - defineSetter(object, property, descriptor.set); - } - - return object; - }; -} -if (!Object.defineProperties) { - Object.defineProperties = function defineProperties(object, properties) { - for (var property in properties) { - if (owns(properties, property)) - Object.defineProperty(object, property, properties[property]); - } - return object; - }; -} -if (!Object.seal) { - Object.seal = function seal(object) { - return object; - }; -} -if (!Object.freeze) { - Object.freeze = function freeze(object) { - return object; - }; -} -try { - Object.freeze(function () {}); -} catch (exception) { - Object.freeze = (function freeze(freezeObject) { - return function freeze(object) { - if (typeof object == "function") { - return object; - } else { - return freezeObject(object); - } - }; - })(Object.freeze); -} -if (!Object.preventExtensions) { - Object.preventExtensions = function preventExtensions(object) { - return object; - }; -} -if (!Object.isSealed) { - Object.isSealed = function isSealed(object) { - return false; - }; -} -if (!Object.isFrozen) { - Object.isFrozen = function isFrozen(object) { - return false; - }; -} -if (!Object.isExtensible) { - Object.isExtensible = function isExtensible(object) { - if (Object(object) === object) { - throw new TypeError(); // TODO message - } - var name = ''; - while (owns(object, name)) { - name += '?'; - } - object[name] = true; - var returnValue = owns(object, name); - delete object[name]; - return returnValue; - }; -} -if (!Object.keys) { - var hasDontEnumBug = true, - dontEnums = [ - "toString", - "toLocaleString", - "valueOf", - "hasOwnProperty", - "isPrototypeOf", - "propertyIsEnumerable", - "constructor" - ], - dontEnumsLength = dontEnums.length; - - for (var key in {"toString": null}) { - hasDontEnumBug = false; - } - - Object.keys = function keys(object) { - - if ( - (typeof object != "object" && typeof object != "function") || - object === null - ) { - throw new TypeError("Object.keys called on a non-object"); - } - - var keys = []; - for (var name in object) { - if (owns(object, name)) { - keys.push(name); - } - } - - if (hasDontEnumBug) { - for (var i = 0, ii = dontEnumsLength; i < ii; i++) { - var dontEnum = dontEnums[i]; - if (owns(object, dontEnum)) { - keys.push(dontEnum); - } - } - } - return keys; - }; - -} -if (!Date.now) { - Date.now = function now() { - return new Date().getTime(); - }; -} -var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003" + - "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + - "\u2029\uFEFF"; -if (!String.prototype.trim) { - ws = "[" + ws + "]"; - var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), - trimEndRegexp = new RegExp(ws + ws + "*$"); - String.prototype.trim = function trim() { - return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); - }; -} - -function toInteger(n) { - n = +n; - if (n !== n) { // isNaN - n = 0; - } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) { - n = (n > 0 || -1) * Math.floor(Math.abs(n)); - } - return n; -} - -function isPrimitive(input) { - var type = typeof input; - return ( - input === null || - type === "undefined" || - type === "boolean" || - type === "number" || - type === "string" - ); -} - -function toPrimitive(input) { - var val, valueOf, toString; - if (isPrimitive(input)) { - return input; - } - valueOf = input.valueOf; - if (typeof valueOf === "function") { - val = valueOf.call(input); - if (isPrimitive(val)) { - return val; - } - } - toString = input.toString; - if (typeof toString === "function") { - val = toString.call(input); - if (isPrimitive(val)) { - return val; - } - } - throw new TypeError(); -} -var toObject = function (o) { - if (o == null) { // this matches both null and undefined - throw new TypeError("can't convert "+o+" to object"); - } - return Object(o); -}; - -}); diff --git a/htdocs/includes/ace/src/worker-css.js b/htdocs/includes/ace/src/worker-css.js index a7d914e3397..8cccc059adb 100644 --- a/htdocs/includes/ace/src/worker-css.js +++ b/htdocs/includes/ace/src/worker-css.js @@ -209,7 +209,6 @@ window.onmessage = function(e) { } else if (msg.init) { window.initBaseUrls(msg.tlns); - require("ace/lib/es5-shim"); sender = window.sender = window.initSender(); var clazz = require(msg.module)[msg.classname]; main = window.main = new clazz(sender); @@ -787,8 +786,8 @@ EventEmitter._signal = function(eventName, e) { EventEmitter.once = function(eventName, callback) { var _self = this; - this.addEventListener(eventName, function newCallback() { - _self.removeEventListener(eventName, newCallback); + this.on(eventName, function newCallback() { + _self.off(eventName, newCallback); callback.apply(null, arguments); }); if (!callback) { @@ -860,7 +859,9 @@ EventEmitter.removeEventListener = function(eventName, callback) { }; EventEmitter.removeAllListeners = function(eventName) { - if (this._eventRegistry) this._eventRegistry[eventName] = []; + if (!eventName) this._eventRegistry = this._defaultHandlers = undefined; + if (this._eventRegistry) this._eventRegistry[eventName] = undefined; + if (this._defaultHandlers) this._defaultHandlers[eventName] = undefined; }; exports.EventEmitter = EventEmitter; @@ -960,7 +961,7 @@ var Anchor = exports.Anchor = function(doc, row, column) { }); }; this.detach = function() { - this.document.removeEventListener("change", this.$onChange); + this.document.off("change", this.$onChange); }; this.attach = function(doc) { this.document = doc || this.document; @@ -1292,6 +1293,16 @@ var Document = function(textOrLines) { } }; + this.$safeApplyDelta = function(delta) { + var docLength = this.$lines.length; + if ( + delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength + || delta.action == "insert" && delta.start.row <= docLength + ) { + this.applyDelta(delta); + } + }; + this.$splitAndapplyLargeDelta = function(delta, MAX) { var lines = delta.lines; var l = lines.length - MAX + 1; @@ -1314,7 +1325,7 @@ var Document = function(textOrLines) { this.applyDelta(delta, true); }; this.revertDelta = function(delta) { - this.applyDelta({ + this.$safeApplyDelta({ start: this.clonePos(delta.start), end: this.clonePos(delta.end), action: (delta.action == "insert" ? "remove" : "insert"), @@ -1410,589 +1421,217 @@ var Mirror = exports.Mirror = function(sender) { }); define("ace/mode/css/csslint",[], function(require, exports, module) { -var parserlib = {}; -(function(){ -function EventTarget(){ - this._listeners = {}; -} -EventTarget.prototype = { - constructor: EventTarget, - addListener: function(type, listener){ - if (!this._listeners[type]){ - this._listeners[type] = []; - } +var CSSLint = (function(){ + var module = module || {}, + exports = exports || {}; +var parserlib = (function () { +var require; +require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= 0 && this._ltIndex < this._lt.length){ - - i++; - this._token = this._lt[this._ltIndex++]; - info = tokenInfo[this._token.type]; - while((info.channel !== undefined && channel !== info.channel) && - this._ltIndex < this._lt.length){ - this._token = this._lt[this._ltIndex++]; - info = tokenInfo[this._token.type]; - i++; - } - if ((info.channel === undefined || channel === info.channel) && - this._ltIndex <= this._lt.length){ - this._ltIndexCache.push(i); - return this._token.type; - } - } - token = this._getToken(); - if (token.type > -1 && !tokenInfo[token.type].hide){ - token.channel = tokenInfo[token.type].channel; - this._token = token; - this._lt.push(token); - this._ltIndexCache.push(this._lt.length - this._ltIndex + i); - if (this._lt.length > 5){ - this._lt.shift(); - } - if (this._ltIndexCache.length > 5){ - this._ltIndexCache.shift(); - } - this._ltIndex = this._lt.length; - } - info = tokenInfo[token.type]; - if (info && - (info.hide || - (info.channel !== undefined && channel !== info.channel))){ - return this.get(channel); - } else { - return token.type; - } - }, - LA: function(index){ - var total = index, - tt; - if (index > 0){ - if (index > 5){ - throw new Error("Too much lookahead."); - } - while(total){ - tt = this.get(); - total--; - } - while(total < index){ - this.unget(); - total++; - } - } else if (index < 0){ - - if(this._lt[this._ltIndex+index]){ - tt = this._lt[this._ltIndex+index].type; - } else { - throw new Error("Too much lookbehind."); - } - - } else { - tt = this._token.type; - } - - return tt; - - }, - LT: function(index){ - this.LA(index); - return this._lt[this._ltIndex+index-1]; - }, - peek: function(){ - return this.LA(1); - }, - token: function(){ - return this._token; - }, - tokenName: function(tokenType){ - if (tokenType < 0 || tokenType > this._tokenData.length){ - return "UNKNOWN_TOKEN"; - } else { - return this._tokenData[tokenType].name; - } - }, - tokenType: function(tokenName){ - return this._tokenData[tokenName] || -1; - }, - unget: function(){ - if (this._ltIndexCache.length){ - this._ltIndex -= this._ltIndexCache.pop();//--; - this._token = this._lt[this._ltIndex - 1]; - } else { - throw new Error("Too much lookahead."); - } - } - -}; - - -parserlib.util = { -StringReader: StringReader, -SyntaxError : SyntaxError, -SyntaxUnit : SyntaxUnit, -EventTarget : EventTarget, -TokenStreamBase : TokenStreamBase -}; -})(); -(function(){ -var EventTarget = parserlib.util.EventTarget, -TokenStreamBase = parserlib.util.TokenStreamBase, -StringReader = parserlib.util.StringReader, -SyntaxError = parserlib.util.SyntaxError, -SyntaxUnit = parserlib.util.SyntaxUnit; - -var Colors = { - aliceblue :"#f0f8ff", - antiquewhite :"#faebd7", - aqua :"#00ffff", - aquamarine :"#7fffd4", - azure :"#f0ffff", - beige :"#f5f5dc", - bisque :"#ffe4c4", - black :"#000000", - blanchedalmond :"#ffebcd", - blue :"#0000ff", - blueviolet :"#8a2be2", - brown :"#a52a2a", - burlywood :"#deb887", - cadetblue :"#5f9ea0", - chartreuse :"#7fff00", - chocolate :"#d2691e", - coral :"#ff7f50", - cornflowerblue :"#6495ed", - cornsilk :"#fff8dc", - crimson :"#dc143c", - cyan :"#00ffff", - darkblue :"#00008b", - darkcyan :"#008b8b", - darkgoldenrod :"#b8860b", - darkgray :"#a9a9a9", - darkgrey :"#a9a9a9", - darkgreen :"#006400", - darkkhaki :"#bdb76b", - darkmagenta :"#8b008b", - darkolivegreen :"#556b2f", - darkorange :"#ff8c00", - darkorchid :"#9932cc", - darkred :"#8b0000", - darksalmon :"#e9967a", - darkseagreen :"#8fbc8f", - darkslateblue :"#483d8b", - darkslategray :"#2f4f4f", - darkslategrey :"#2f4f4f", - darkturquoise :"#00ced1", - darkviolet :"#9400d3", - deeppink :"#ff1493", - deepskyblue :"#00bfff", - dimgray :"#696969", - dimgrey :"#696969", - dodgerblue :"#1e90ff", - firebrick :"#b22222", - floralwhite :"#fffaf0", - forestgreen :"#228b22", - fuchsia :"#ff00ff", - gainsboro :"#dcdcdc", - ghostwhite :"#f8f8ff", - gold :"#ffd700", - goldenrod :"#daa520", - gray :"#808080", - grey :"#808080", - green :"#008000", - greenyellow :"#adff2f", - honeydew :"#f0fff0", - hotpink :"#ff69b4", - indianred :"#cd5c5c", - indigo :"#4b0082", - ivory :"#fffff0", - khaki :"#f0e68c", - lavender :"#e6e6fa", - lavenderblush :"#fff0f5", - lawngreen :"#7cfc00", - lemonchiffon :"#fffacd", - lightblue :"#add8e6", - lightcoral :"#f08080", - lightcyan :"#e0ffff", - lightgoldenrodyellow :"#fafad2", - lightgray :"#d3d3d3", - lightgrey :"#d3d3d3", - lightgreen :"#90ee90", - lightpink :"#ffb6c1", - lightsalmon :"#ffa07a", - lightseagreen :"#20b2aa", - lightskyblue :"#87cefa", - lightslategray :"#778899", - lightslategrey :"#778899", - lightsteelblue :"#b0c4de", - lightyellow :"#ffffe0", - lime :"#00ff00", - limegreen :"#32cd32", - linen :"#faf0e6", - magenta :"#ff00ff", - maroon :"#800000", - mediumaquamarine:"#66cdaa", - mediumblue :"#0000cd", - mediumorchid :"#ba55d3", - mediumpurple :"#9370d8", - mediumseagreen :"#3cb371", - mediumslateblue :"#7b68ee", - mediumspringgreen :"#00fa9a", - mediumturquoise :"#48d1cc", - mediumvioletred :"#c71585", - midnightblue :"#191970", - mintcream :"#f5fffa", - mistyrose :"#ffe4e1", - moccasin :"#ffe4b5", - navajowhite :"#ffdead", - navy :"#000080", - oldlace :"#fdf5e6", - olive :"#808000", - olivedrab :"#6b8e23", - orange :"#ffa500", - orangered :"#ff4500", - orchid :"#da70d6", - palegoldenrod :"#eee8aa", - palegreen :"#98fb98", - paleturquoise :"#afeeee", - palevioletred :"#d87093", - papayawhip :"#ffefd5", - peachpuff :"#ffdab9", - peru :"#cd853f", - pink :"#ffc0cb", - plum :"#dda0dd", - powderblue :"#b0e0e6", - purple :"#800080", - red :"#ff0000", - rosybrown :"#bc8f8f", - royalblue :"#4169e1", - saddlebrown :"#8b4513", - salmon :"#fa8072", - sandybrown :"#f4a460", - seagreen :"#2e8b57", - seashell :"#fff5ee", - sienna :"#a0522d", - silver :"#c0c0c0", - skyblue :"#87ceeb", - slateblue :"#6a5acd", - slategray :"#708090", - slategrey :"#708090", - snow :"#fffafa", - springgreen :"#00ff7f", - steelblue :"#4682b4", - tan :"#d2b48c", - teal :"#008080", - thistle :"#d8bfd8", - tomato :"#ff6347", - turquoise :"#40e0d0", - violet :"#ee82ee", - wheat :"#f5deb3", - white :"#ffffff", - whitesmoke :"#f5f5f5", - yellow :"#ffff00", - yellowgreen :"#9acd32", - activeBorder :"Active window border.", - activecaption :"Active window caption.", - appworkspace :"Background color of multiple document interface.", - background :"Desktop background.", - buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.", - buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.", - buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.", - buttontext :"Text on push buttons.", - captiontext :"Text in caption, size box, and scrollbar arrow box.", - graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.", - greytext :"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.", - highlight :"Item(s) selected in a control.", - highlighttext :"Text of item(s) selected in a control.", - inactiveborder :"Inactive window border.", - inactivecaption :"Inactive window caption.", - inactivecaptiontext :"Color of text in an inactive caption.", - infobackground :"Background color for tooltip controls.", - infotext :"Text color for tooltip controls.", - menu :"Menu background.", - menutext :"Text in menus.", - scrollbar :"Scroll bar gray area.", - threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", - threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", - threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", - threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", - threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", - window :"Window background.", - windowframe :"Window frame.", - windowtext :"Text in windows." -}; -function Combinator(text, line, col){ +var Parser = require("./Parser"); +function Combinator(text, line, col) { SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE); this.type = "unknown"; - if (/^\s+$/.test(text)){ + if (/^\s+$/.test(text)) { this.type = "descendant"; - } else if (text == ">"){ + } else if (text === ">") { this.type = "child"; - } else if (text == "+"){ + } else if (text === "+") { this.type = "adjacent-sibling"; - } else if (text == "~"){ + } else if (text === "~") { this.type = "sibling"; } @@ -2000,7 +1639,322 @@ function Combinator(text, line, col){ Combinator.prototype = new SyntaxUnit(); Combinator.prototype.constructor = Combinator; -function MediaFeature(name, value){ + + +},{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(require,module,exports){ +"use strict"; + +module.exports = Matcher; + +var StringReader = require("../util/StringReader"); +var SyntaxError = require("../util/SyntaxError"); +function Matcher(matchFunc, toString) { + this.match = function(expression) { + var result; + expression.mark(); + result = matchFunc(expression); + if (result) { + expression.drop(); + } else { + expression.restore(); + } + return result; + }; + this.toString = typeof toString === "function" ? toString : function() { + return toString; + }; +} +Matcher.prec = { + MOD: 5, + SEQ: 4, + ANDAND: 3, + OROR: 2, + ALT: 1 +}; +Matcher.parse = function(str) { + var reader, eat, expr, oror, andand, seq, mod, term, result; + reader = new StringReader(str); + eat = function(matcher) { + var result = reader.readMatch(matcher); + if (result === null) { + throw new SyntaxError( + "Expected " + matcher, reader.getLine(), reader.getCol()); + } + return result; + }; + expr = function() { + var m = [ oror() ]; + while (reader.readMatch(" | ") !== null) { + m.push(oror()); + } + return m.length === 1 ? m[0] : Matcher.alt.apply(Matcher, m); + }; + oror = function() { + var m = [ andand() ]; + while (reader.readMatch(" || ") !== null) { + m.push(andand()); + } + return m.length === 1 ? m[0] : Matcher.oror.apply(Matcher, m); + }; + andand = function() { + var m = [ seq() ]; + while (reader.readMatch(" && ") !== null) { + m.push(seq()); + } + return m.length === 1 ? m[0] : Matcher.andand.apply(Matcher, m); + }; + seq = function() { + var m = [ mod() ]; + while (reader.readMatch(/^ (?![&|\]])/) !== null) { + m.push(mod()); + } + return m.length === 1 ? m[0] : Matcher.seq.apply(Matcher, m); + }; + mod = function() { + var m = term(); + if (reader.readMatch("?") !== null) { + return m.question(); + } else if (reader.readMatch("*") !== null) { + return m.star(); + } else if (reader.readMatch("+") !== null) { + return m.plus(); + } else if (reader.readMatch("#") !== null) { + return m.hash(); + } else if (reader.readMatch(/^\{\s*/) !== null) { + var min = eat(/^\d+/); + eat(/^\s*,\s*/); + var max = eat(/^\d+/); + eat(/^\s*\}/); + return m.braces(Number(min), Number(max)); + } + return m; + }; + term = function() { + if (reader.readMatch("[ ") !== null) { + var m = expr(); + eat(" ]"); + return m; + } + return Matcher.fromType(eat(/^[^ ?*+#{]+/)); + }; + result = expr(); + if (!reader.eof()) { + throw new SyntaxError( + "Expected end of string", reader.getLine(), reader.getCol()); + } + return result; +}; +Matcher.cast = function(m) { + if (m instanceof Matcher) { + return m; + } + return Matcher.parse(m); +}; +Matcher.fromType = function(type) { + var ValidationTypes = require("./ValidationTypes"); + return new Matcher(function(expression) { + return expression.hasNext() && ValidationTypes.isType(expression, type); + }, type); +}; +Matcher.seq = function() { + var ms = Array.prototype.slice.call(arguments).map(Matcher.cast); + if (ms.length === 1) { + return ms[0]; + } + return new Matcher(function(expression) { + var i, result = true; + for (i = 0; result && i < ms.length; i++) { + result = ms[i].match(expression); + } + return result; + }, function(prec) { + var p = Matcher.prec.SEQ; + var s = ms.map(function(m) { + return m.toString(p); + }).join(" "); + if (prec > p) { + s = "[ " + s + " ]"; + } + return s; + }); +}; +Matcher.alt = function() { + var ms = Array.prototype.slice.call(arguments).map(Matcher.cast); + if (ms.length === 1) { + return ms[0]; + } + return new Matcher(function(expression) { + var i, result = false; + for (i = 0; !result && i < ms.length; i++) { + result = ms[i].match(expression); + } + return result; + }, function(prec) { + var p = Matcher.prec.ALT; + var s = ms.map(function(m) { + return m.toString(p); + }).join(" | "); + if (prec > p) { + s = "[ " + s + " ]"; + } + return s; + }); +}; +Matcher.many = function(required) { + var ms = Array.prototype.slice.call(arguments, 1).reduce(function(acc, v) { + if (v.expand) { + var ValidationTypes = require("./ValidationTypes"); + acc.push.apply(acc, ValidationTypes.complex[v.expand].options); + } else { + acc.push(Matcher.cast(v)); + } + return acc; + }, []); + + if (required === true) { + required = ms.map(function() { + return true; + }); + } + + var result = new Matcher(function(expression) { + var seen = [], max = 0, pass = 0; + var success = function(matchCount) { + if (pass === 0) { + max = Math.max(matchCount, max); + return matchCount === ms.length; + } else { + return matchCount === max; + } + }; + var tryMatch = function(matchCount) { + for (var i = 0; i < ms.length; i++) { + if (seen[i]) { + continue; + } + expression.mark(); + if (ms[i].match(expression)) { + seen[i] = true; + if (tryMatch(matchCount + (required === false || required[i] ? 1 : 0))) { + expression.drop(); + return true; + } + expression.restore(); + seen[i] = false; + } else { + expression.drop(); + } + } + return success(matchCount); + }; + if (!tryMatch(0)) { + pass++; + tryMatch(0); + } + + if (required === false) { + return max > 0; + } + for (var i = 0; i < ms.length; i++) { + if (required[i] && !seen[i]) { + return false; + } + } + return true; + }, function(prec) { + var p = required === false ? Matcher.prec.OROR : Matcher.prec.ANDAND; + var s = ms.map(function(m, i) { + if (required !== false && !required[i]) { + return m.toString(Matcher.prec.MOD) + "?"; + } + return m.toString(p); + }).join(required === false ? " || " : " && "); + if (prec > p) { + s = "[ " + s + " ]"; + } + return s; + }); + result.options = ms; + return result; +}; +Matcher.andand = function() { + var args = Array.prototype.slice.call(arguments); + args.unshift(true); + return Matcher.many.apply(Matcher, args); +}; +Matcher.oror = function() { + var args = Array.prototype.slice.call(arguments); + args.unshift(false); + return Matcher.many.apply(Matcher, args); +}; +Matcher.prototype = { + constructor: Matcher, + match: function() { + throw new Error("unimplemented"); + }, + toString: function() { + throw new Error("unimplemented"); + }, + func: function() { + return this.match.bind(this); + }, + then: function(m) { + return Matcher.seq(this, m); + }, + or: function(m) { + return Matcher.alt(this, m); + }, + andand: function(m) { + return Matcher.many(true, this, m); + }, + oror: function(m) { + return Matcher.many(false, this, m); + }, + star: function() { + return this.braces(0, Infinity, "*"); + }, + plus: function() { + return this.braces(1, Infinity, "+"); + }, + question: function() { + return this.braces(0, 1, "?"); + }, + hash: function() { + return this.braces(1, Infinity, "#", Matcher.cast(",")); + }, + braces: function(min, max, marker, optSep) { + var m1 = this, m2 = optSep ? optSep.then(this) : this; + if (!marker) { + marker = "{" + min + "," + max + "}"; + } + return new Matcher(function(expression) { + var result = true, i; + for (i = 0; i < max; i++) { + if (i > 0 && optSep) { + result = m2.match(expression); + } else { + result = m1.match(expression); + } + if (!result) { + break; + } + } + return i >= min; + }, function() { + return m1.toString(Matcher.prec.MOD) + marker; + }); + } +}; + +},{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(require,module,exports){ +"use strict"; + +module.exports = MediaFeature; + +var SyntaxUnit = require("../util/SyntaxUnit"); + +var Parser = require("./Parser"); +function MediaFeature(name, value) { SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE); this.name = name; @@ -2009,9 +1963,19 @@ function MediaFeature(name, value){ MediaFeature.prototype = new SyntaxUnit(); MediaFeature.prototype.constructor = MediaFeature; -function MediaQuery(modifier, mediaType, features, line, col){ - SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); + +},{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(require,module,exports){ +"use strict"; + +module.exports = MediaQuery; + +var SyntaxUnit = require("../util/SyntaxUnit"); + +var Parser = require("./Parser"); +function MediaQuery(modifier, mediaType, features, line, col) { + + SyntaxUnit.call(this, (modifier ? modifier + " " : "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); this.modifier = modifier; this.mediaType = mediaType; this.features = features; @@ -2020,7 +1984,30 @@ function MediaQuery(modifier, mediaType, features, line, col){ MediaQuery.prototype = new SyntaxUnit(); MediaQuery.prototype.constructor = MediaQuery; -function Parser(options){ + + +},{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(require,module,exports){ +"use strict"; + +module.exports = Parser; + +var EventTarget = require("../util/EventTarget"); +var SyntaxError = require("../util/SyntaxError"); +var SyntaxUnit = require("../util/SyntaxUnit"); + +var Combinator = require("./Combinator"); +var MediaFeature = require("./MediaFeature"); +var MediaQuery = require("./MediaQuery"); +var PropertyName = require("./PropertyName"); +var PropertyValue = require("./PropertyValue"); +var PropertyValuePart = require("./PropertyValuePart"); +var Selector = require("./Selector"); +var SelectorPart = require("./SelectorPart"); +var SelectorSubPart = require("./SelectorSubPart"); +var TokenStream = require("./TokenStream"); +var Tokens = require("./Tokens"); +var Validation = require("./Validation"); +function Parser(options) { EventTarget.call(this); @@ -2039,11 +2026,12 @@ Parser.SELECTOR_TYPE = 7; Parser.SELECTOR_PART_TYPE = 8; Parser.SELECTOR_SUB_PART_TYPE = 9; -Parser.prototype = function(){ +Parser.prototype = function() { - var proto = new EventTarget(), //new prototype + var proto = new EventTarget(), // new prototype prop, additions = { + __proto__: null, constructor: Parser, DEFAULT_TYPE : 0, COMBINATOR_TYPE : 1, @@ -2056,10 +2044,9 @@ Parser.prototype = function(){ SELECTOR_PART_TYPE : 8, SELECTOR_SUB_PART_TYPE : 9, - _stylesheet: function(){ + _stylesheet: function() { var tokenStream = this._tokenStream, - charset = null, count, token, tt; @@ -2068,20 +2055,20 @@ Parser.prototype = function(){ this._charset(); this._skipCruft(); - while (tokenStream.peek() == Tokens.IMPORT_SYM){ + while (tokenStream.peek() === Tokens.IMPORT_SYM) { this._import(); this._skipCruft(); } - while (tokenStream.peek() == Tokens.NAMESPACE_SYM){ + while (tokenStream.peek() === Tokens.NAMESPACE_SYM) { this._namespace(); this._skipCruft(); } tt = tokenStream.peek(); - while(tt > Tokens.EOF){ + while (tt > Tokens.EOF) { try { - switch(tt){ + switch (tt) { case Tokens.MEDIA_SYM: this._media(); this._skipCruft(); @@ -2102,9 +2089,17 @@ Parser.prototype = function(){ this._viewport(); this._skipCruft(); break; - case Tokens.UNKNOWN_SYM: //unknown @ rule + case Tokens.DOCUMENT_SYM: + this._document(); + this._skipCruft(); + break; + case Tokens.SUPPORTS_SYM: + this._supports(); + this._skipCruft(); + break; + case Tokens.UNKNOWN_SYM: // unknown @ rule tokenStream.get(); - if (!this.options.strict){ + if (!this.options.strict) { this.fire({ type: "error", error: null, @@ -2112,12 +2107,12 @@ Parser.prototype = function(){ line: tokenStream.LT(0).startLine, col: tokenStream.LT(0).startCol }); - count=0; - while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){ - count++; //keep track of nesting depth + count = 0; + while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) { + count++; // keep track of nesting depth } - while(count){ + while (count) { tokenStream.advance([Tokens.RBRACE]); count--; } @@ -2130,8 +2125,8 @@ Parser.prototype = function(){ this._readWhitespace(); break; default: - if(!this._ruleset()){ - switch(tt){ + if (!this._ruleset()) { + switch (tt) { case Tokens.CHARSET_SYM: token = tokenStream.LT(1); this._charset(false); @@ -2145,14 +2140,14 @@ Parser.prototype = function(){ this._namespace(false); throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol); default: - tokenStream.get(); //get the last token + tokenStream.get(); // get the last token this._unexpectedToken(tokenStream.token()); } } } - } catch(ex) { - if (ex instanceof SyntaxError && !this.options.strict){ + } catch (ex) { + if (ex instanceof SyntaxError && !this.options.strict) { this.fire({ type: "error", error: ex, @@ -2168,21 +2163,21 @@ Parser.prototype = function(){ tt = tokenStream.peek(); } - if (tt != Tokens.EOF){ + if (tt !== Tokens.EOF) { this._unexpectedToken(tokenStream.token()); } this.fire("endstylesheet"); }, - _charset: function(emit){ + _charset: function(emit) { var tokenStream = this._tokenStream, charset, token, line, col; - if (tokenStream.match(Tokens.CHARSET_SYM)){ + if (tokenStream.match(Tokens.CHARSET_SYM)) { line = tokenStream.token().startLine; col = tokenStream.token().startCol; @@ -2195,7 +2190,7 @@ Parser.prototype = function(){ this._readWhitespace(); tokenStream.mustMatch(Tokens.SEMICOLON); - if (emit !== false){ + if (emit !== false) { this.fire({ type: "charset", charset:charset, @@ -2206,10 +2201,9 @@ Parser.prototype = function(){ } }, - _import: function(emit){ + _import: function(emit) { var tokenStream = this._tokenStream, - tt, uri, importToken, mediaList = []; @@ -2226,7 +2220,7 @@ Parser.prototype = function(){ tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); - if (emit !== false){ + if (emit !== false) { this.fire({ type: "import", uri: uri, @@ -2238,7 +2232,7 @@ Parser.prototype = function(){ }, - _namespace: function(emit){ + _namespace: function(emit) { var tokenStream = this._tokenStream, line, @@ -2249,7 +2243,7 @@ Parser.prototype = function(){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; this._readWhitespace(); - if (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.match(Tokens.IDENT)) { prefix = tokenStream.token().value; this._readWhitespace(); } @@ -2261,7 +2255,7 @@ Parser.prototype = function(){ tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); - if (emit !== false){ + if (emit !== false) { this.fire({ type: "namespace", prefix: prefix, @@ -2273,11 +2267,119 @@ Parser.prototype = function(){ }, - _media: function(){ + _supports: function(emit) { + var tokenStream = this._tokenStream, + line, + col; + + if (tokenStream.match(Tokens.SUPPORTS_SYM)) { + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + this._supports_condition(); + this._readWhitespace(); + + tokenStream.mustMatch(Tokens.LBRACE); + this._readWhitespace(); + + if (emit !== false) { + this.fire({ + type: "startsupports", + line: line, + col: col + }); + } + + while (true) { + if (!this._ruleset()) { + break; + } + } + + tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); + + this.fire({ + type: "endsupports", + line: line, + col: col + }); + } + }, + + _supports_condition: function() { + var tokenStream = this._tokenStream, + ident; + + if (tokenStream.match(Tokens.IDENT)) { + ident = tokenStream.token().value.toLowerCase(); + + if (ident === "not") { + tokenStream.mustMatch(Tokens.S); + this._supports_condition_in_parens(); + } else { + tokenStream.unget(); + } + } else { + this._supports_condition_in_parens(); + this._readWhitespace(); + + while (tokenStream.peek() === Tokens.IDENT) { + ident = tokenStream.LT(1).value.toLowerCase(); + if (ident === "and" || ident === "or") { + tokenStream.mustMatch(Tokens.IDENT); + this._readWhitespace(); + this._supports_condition_in_parens(); + this._readWhitespace(); + } + } + } + }, + + _supports_condition_in_parens: function() { + var tokenStream = this._tokenStream, + ident; + + if (tokenStream.match(Tokens.LPAREN)) { + this._readWhitespace(); + if (tokenStream.match(Tokens.IDENT)) { + ident = tokenStream.token().value.toLowerCase(); + if (ident === "not") { + this._readWhitespace(); + this._supports_condition(); + this._readWhitespace(); + tokenStream.mustMatch(Tokens.RPAREN); + } else { + tokenStream.unget(); + this._supports_declaration_condition(false); + } + } else { + this._supports_condition(); + this._readWhitespace(); + tokenStream.mustMatch(Tokens.RPAREN); + } + } else { + this._supports_declaration_condition(); + } + }, + + _supports_declaration_condition: function(requireStartParen) { + var tokenStream = this._tokenStream; + + if (requireStartParen !== false) { + tokenStream.mustMatch(Tokens.LPAREN); + } + this._readWhitespace(); + this._declaration(); + tokenStream.mustMatch(Tokens.RPAREN); + }, + + _media: function() { var tokenStream = this._tokenStream, line, col, - mediaList;// = []; + mediaList; // = []; tokenStream.mustMatch(Tokens.MEDIA_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; @@ -2296,14 +2398,20 @@ Parser.prototype = function(){ col: col }); - while(true) { - if (tokenStream.peek() == Tokens.PAGE_SYM){ + while (true) { + if (tokenStream.peek() === Tokens.PAGE_SYM) { this._page(); - } else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){ + } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) { this._font_face(); - } else if (tokenStream.peek() == Tokens.VIEWPORT_SYM){ + } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) { this._viewport(); - } else if (!this._ruleset()){ + } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM) { + this._document(); + } else if (tokenStream.peek() === Tokens.SUPPORTS_SYM) { + this._supports(); + } else if (tokenStream.peek() === Tokens.MEDIA_SYM) { + this._media(); + } else if (!this._ruleset()) { break; } } @@ -2318,34 +2426,34 @@ Parser.prototype = function(){ col: col }); }, - _media_query_list: function(){ + _media_query_list: function() { var tokenStream = this._tokenStream, mediaList = []; this._readWhitespace(); - if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){ + if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN) { mediaList.push(this._media_query()); } - while(tokenStream.match(Tokens.COMMA)){ + while (tokenStream.match(Tokens.COMMA)) { this._readWhitespace(); mediaList.push(this._media_query()); } return mediaList; }, - _media_query: function(){ + _media_query: function() { var tokenStream = this._tokenStream, type = null, ident = null, token = null, expressions = []; - if (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.match(Tokens.IDENT)) { ident = tokenStream.token().value.toLowerCase(); - if (ident != "only" && ident != "not"){ + if (ident !== "only" && ident !== "not") { tokenStream.unget(); ident = null; } else { @@ -2355,24 +2463,24 @@ Parser.prototype = function(){ this._readWhitespace(); - if (tokenStream.peek() == Tokens.IDENT){ + if (tokenStream.peek() === Tokens.IDENT) { type = this._media_type(); - if (token === null){ + if (token === null) { token = tokenStream.token(); } - } else if (tokenStream.peek() == Tokens.LPAREN){ - if (token === null){ + } else if (tokenStream.peek() === Tokens.LPAREN) { + if (token === null) { token = tokenStream.LT(1); } expressions.push(this._media_expression()); } - if (type === null && expressions.length === 0){ + if (type === null && expressions.length === 0) { return null; } else { this._readWhitespace(); - while (tokenStream.match(Tokens.IDENT)){ - if (tokenStream.token().value.toLowerCase() != "and"){ + while (tokenStream.match(Tokens.IDENT)) { + if (tokenStream.token().value.toLowerCase() !== "and") { this._unexpectedToken(tokenStream.token()); } @@ -2383,10 +2491,10 @@ Parser.prototype = function(){ return new MediaQuery(ident, type, expressions, token.startLine, token.startCol); }, - _media_type: function(){ + _media_type: function() { return this._media_feature(); }, - _media_expression: function(){ + _media_expression: function() { var tokenStream = this._tokenStream, feature = null, token, @@ -2398,7 +2506,7 @@ Parser.prototype = function(){ feature = this._media_feature(); this._readWhitespace(); - if (tokenStream.match(Tokens.COLON)){ + if (tokenStream.match(Tokens.COLON)) { this._readWhitespace(); token = tokenStream.LT(1); expression = this._expression(); @@ -2407,16 +2515,18 @@ Parser.prototype = function(){ tokenStream.mustMatch(Tokens.RPAREN); this._readWhitespace(); - return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); + return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null); }, - _media_feature: function(){ + _media_feature: function() { var tokenStream = this._tokenStream; + this._readWhitespace(); + tokenStream.mustMatch(Tokens.IDENT); return SyntaxUnit.fromToken(tokenStream.token()); }, - _page: function(){ + _page: function() { var tokenStream = this._tokenStream, line, col, @@ -2428,13 +2538,13 @@ Parser.prototype = function(){ this._readWhitespace(); - if (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.match(Tokens.IDENT)) { identifier = tokenStream.token().value; - if (identifier.toLowerCase() === "auto"){ + if (identifier.toLowerCase() === "auto") { this._unexpectedToken(tokenStream.token()); } } - if (tokenStream.peek() == Tokens.COLON){ + if (tokenStream.peek() === Tokens.COLON) { pseudoPage = this._pseudo_page(); } @@ -2459,13 +2569,13 @@ Parser.prototype = function(){ }); }, - _margin: function(){ + _margin: function() { var tokenStream = this._tokenStream, line, col, marginSym = this._margin_sym(); - if (marginSym){ + if (marginSym) { line = tokenStream.token().startLine; col = tokenStream.token().startCol; @@ -2489,18 +2599,17 @@ Parser.prototype = function(){ return false; } }, - _margin_sym: function(){ + _margin_sym: function() { var tokenStream = this._tokenStream; - if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, - Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, - Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, - Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, - Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, - Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, - Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) - { + if (tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, + Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, + Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, + Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, + Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, + Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, + Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) { return SyntaxUnit.fromToken(tokenStream.token()); } else { return null; @@ -2508,7 +2617,7 @@ Parser.prototype = function(){ }, - _pseudo_page: function(){ + _pseudo_page: function() { var tokenStream = this._tokenStream; @@ -2518,7 +2627,7 @@ Parser.prototype = function(){ return tokenStream.token().value; }, - _font_face: function(){ + _font_face: function() { var tokenStream = this._tokenStream, line, col; @@ -2543,40 +2652,126 @@ Parser.prototype = function(){ }); }, - _viewport: function(){ - var tokenStream = this._tokenStream, + _viewport: function() { + var tokenStream = this._tokenStream, line, col; - tokenStream.mustMatch(Tokens.VIEWPORT_SYM); - line = tokenStream.token().startLine; - col = tokenStream.token().startCol; + tokenStream.mustMatch(Tokens.VIEWPORT_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; - this._readWhitespace(); + this._readWhitespace(); - this.fire({ - type: "startviewport", - line: line, - col: col - }); + this.fire({ + type: "startviewport", + line: line, + col: col + }); - this._readDeclarations(true); + this._readDeclarations(true); - this.fire({ - type: "endviewport", - line: line, - col: col - }); + this.fire({ + type: "endviewport", + line: line, + col: col + }); }, - _operator: function(inFunction){ + _document: function() { + + var tokenStream = this._tokenStream, + token, + functions = [], + prefix = ""; + + tokenStream.mustMatch(Tokens.DOCUMENT_SYM); + token = tokenStream.token(); + if (/^@-([^-]+)-/.test(token.value)) { + prefix = RegExp.$1; + } + + this._readWhitespace(); + functions.push(this._document_function()); + + while (tokenStream.match(Tokens.COMMA)) { + this._readWhitespace(); + functions.push(this._document_function()); + } + + tokenStream.mustMatch(Tokens.LBRACE); + this._readWhitespace(); + + this.fire({ + type: "startdocument", + functions: functions, + prefix: prefix, + line: token.startLine, + col: token.startCol + }); + + var ok = true; + while (ok) { + switch (tokenStream.peek()) { + case Tokens.PAGE_SYM: + this._page(); + break; + case Tokens.FONT_FACE_SYM: + this._font_face(); + break; + case Tokens.VIEWPORT_SYM: + this._viewport(); + break; + case Tokens.MEDIA_SYM: + this._media(); + break; + case Tokens.KEYFRAMES_SYM: + this._keyframes(); + break; + case Tokens.DOCUMENT_SYM: + this._document(); + break; + default: + ok = Boolean(this._ruleset()); + } + } + + tokenStream.mustMatch(Tokens.RBRACE); + token = tokenStream.token(); + this._readWhitespace(); + + this.fire({ + type: "enddocument", + functions: functions, + prefix: prefix, + line: token.startLine, + col: token.startCol + }); + }, + + _document_function: function() { + + var tokenStream = this._tokenStream, + value; + + if (tokenStream.match(Tokens.URI)) { + value = tokenStream.token().value; + this._readWhitespace(); + } else { + value = this._function(); + } + + return value; + }, + + _operator: function(inFunction) { var tokenStream = this._tokenStream, token = null; if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || - (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){ + inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS])) { token = tokenStream.token(); this._readWhitespace(); } @@ -2584,13 +2779,13 @@ Parser.prototype = function(){ }, - _combinator: function(){ + _combinator: function() { var tokenStream = this._tokenStream, value = null, token; - if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ + if (tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) { token = tokenStream.token(); value = new Combinator(token.value, token.startLine, token.startCol); this._readWhitespace(); @@ -2599,57 +2794,67 @@ Parser.prototype = function(){ return value; }, - _unary_operator: function(){ + _unary_operator: function() { var tokenStream = this._tokenStream; - if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){ + if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])) { return tokenStream.token().value; } else { return null; } }, - _property: function(){ + _property: function() { - var tokenStream = this._tokenStream, - value = null, - hack = null, - tokenValue, + var tokenStream = this._tokenStream, + value = null, + hack = null, + propertyName = "", token, line, col; - if (tokenStream.peek() == Tokens.STAR && this.options.starHack){ + if (tokenStream.peek() === Tokens.STAR && this.options.starHack) { tokenStream.get(); token = tokenStream.token(); hack = token.value; line = token.startLine; col = token.startCol; } - - if(tokenStream.match(Tokens.IDENT)){ + if (tokenStream.peek() === Tokens.MINUS) { + tokenStream.get(); token = tokenStream.token(); - tokenValue = token.value; - if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){ + propertyName = token.value; + line = token.startLine; + col = token.startCol; + } + + if (tokenStream.match(Tokens.IDENT)) { + token = tokenStream.token(); + propertyName += token.value; + if (propertyName.charAt(0) === "_" && this.options.underscoreHack) { hack = "_"; - tokenValue = tokenValue.substring(1); + propertyName = propertyName.substring(1); } - value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol)); + value = new PropertyName(propertyName, hack, line || token.startLine, col || token.startCol); this._readWhitespace(); + } else if (tokenStream.peek() === Tokens.RBRACE) { + } else { + this._unexpectedToken(tokenStream.LT(1)); } return value; }, - _ruleset: function(){ + _ruleset: function() { var tokenStream = this._tokenStream, tt, selectors; try { selectors = this._selectors_group(); - } catch (ex){ - if (ex instanceof SyntaxError && !this.options.strict){ + } catch (ex) { + if (ex instanceof SyntaxError && !this.options.strict) { this.fire({ type: "error", error: ex, @@ -2658,7 +2863,7 @@ Parser.prototype = function(){ col: ex.col }); tt = tokenStream.advance([Tokens.RBRACE]); - if (tt == Tokens.RBRACE){ + if (tt === Tokens.RBRACE) { } else { throw ex; } @@ -2668,7 +2873,7 @@ Parser.prototype = function(){ } return true; } - if (selectors){ + if (selectors) { this.fire({ type: "startrule", @@ -2691,19 +2896,19 @@ Parser.prototype = function(){ return selectors; }, - _selectors_group: function(){ + _selectors_group: function() { var tokenStream = this._tokenStream, selectors = [], selector; selector = this._selector(); - if (selector !== null){ + if (selector !== null) { selectors.push(selector); - while(tokenStream.match(Tokens.COMMA)){ + while (tokenStream.match(Tokens.COMMA)) { this._readWhitespace(); selector = this._selector(); - if (selector !== null){ + if (selector !== null) { selectors.push(selector); } else { this._unexpectedToken(tokenStream.LT(1)); @@ -2713,7 +2918,7 @@ Parser.prototype = function(){ return selectors.length ? selectors : null; }, - _selector: function(){ + _selector: function() { var tokenStream = this._tokenStream, selector = [], @@ -2721,7 +2926,7 @@ Parser.prototype = function(){ combinator = null, ws = null; nextSelector = this._simple_selector_sequence(); - if (nextSelector === null){ + if (nextSelector === null) { return null; } @@ -2730,26 +2935,26 @@ Parser.prototype = function(){ do { combinator = this._combinator(); - if (combinator !== null){ + if (combinator !== null) { selector.push(combinator); nextSelector = this._simple_selector_sequence(); - if (nextSelector === null){ + if (nextSelector === null) { this._unexpectedToken(tokenStream.LT(1)); } else { selector.push(nextSelector); } } else { - if (this._readWhitespace()){ + if (this._readWhitespace()) { ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol); combinator = this._combinator(); nextSelector = this._simple_selector_sequence(); - if (nextSelector === null){ - if (combinator !== null){ + if (nextSelector === null) { + if (combinator !== null) { this._unexpectedToken(tokenStream.LT(1)); } } else { - if (combinator !== null){ + if (combinator !== null) { selector.push(combinator); } else { selector.push(ws); @@ -2762,18 +2967,18 @@ Parser.prototype = function(){ } } - } while(true); + } while (true); return new Selector(selector, selector[0].line, selector[0].col); }, - _simple_selector_sequence: function(){ + _simple_selector_sequence: function() { var tokenStream = this._tokenStream, elementName = null, modifiers = [], - selectorText= "", + selectorText = "", components = [ - function(){ + function() { return tokenStream.match(Tokens.HASH) ? new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : null; @@ -2786,31 +2991,30 @@ Parser.prototype = function(){ i = 0, len = components.length, component = null, - found = false, line, col; line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; elementName = this._type_selector(); - if (!elementName){ + if (!elementName) { elementName = this._universal(); } - if (elementName !== null){ + if (elementName !== null) { selectorText += elementName; } - while(true){ - if (tokenStream.peek() === Tokens.S){ + while (true) { + if (tokenStream.peek() === Tokens.S) { break; } - while(i < len && component === null){ + while (i < len && component === null) { component = components[i++].call(this); } - if (component === null){ - if (selectorText === ""){ + if (component === null) { + if (selectorText === "") { return null; } else { break; @@ -2828,35 +3032,35 @@ Parser.prototype = function(){ new SelectorPart(elementName, modifiers, selectorText, line, col) : null; }, - _type_selector: function(){ + _type_selector: function() { var tokenStream = this._tokenStream, ns = this._namespace_prefix(), elementName = this._element_name(); - if (!elementName){ - if (ns){ + if (!elementName) { + if (ns) { tokenStream.unget(); - if (ns.length > 1){ + if (ns.length > 1) { tokenStream.unget(); } } return null; } else { - if (ns){ + if (ns) { elementName.text = ns + elementName.text; elementName.col -= ns.length; } return elementName; } }, - _class: function(){ + _class: function() { var tokenStream = this._tokenStream, token; - if (tokenStream.match(Tokens.DOT)){ + if (tokenStream.match(Tokens.DOT)) { tokenStream.mustMatch(Tokens.IDENT); token = tokenStream.token(); return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); @@ -2865,12 +3069,12 @@ Parser.prototype = function(){ } }, - _element_name: function(){ + _element_name: function() { var tokenStream = this._tokenStream, token; - if (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.match(Tokens.IDENT)) { token = tokenStream.token(); return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); @@ -2878,12 +3082,12 @@ Parser.prototype = function(){ return null; } }, - _namespace_prefix: function(){ + _namespace_prefix: function() { var tokenStream = this._tokenStream, value = ""; - if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){ + if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) { - if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){ + if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) { value += tokenStream.token().value; } @@ -2894,38 +3098,38 @@ Parser.prototype = function(){ return value.length ? value : null; }, - _universal: function(){ + _universal: function() { var tokenStream = this._tokenStream, value = "", ns; ns = this._namespace_prefix(); - if(ns){ + if (ns) { value += ns; } - if(tokenStream.match(Tokens.STAR)){ + if (tokenStream.match(Tokens.STAR)) { value += "*"; } return value.length ? value : null; - }, - _attrib: function(){ + }, + _attrib: function() { var tokenStream = this._tokenStream, value = null, ns, token; - if (tokenStream.match(Tokens.LBRACKET)){ + if (tokenStream.match(Tokens.LBRACKET)) { token = tokenStream.token(); value = token.value; value += this._readWhitespace(); ns = this._namespace_prefix(); - if (ns){ + if (ns) { value += ns; } @@ -2933,8 +3137,8 @@ Parser.prototype = function(){ value += tokenStream.token().value; value += this._readWhitespace(); - if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, - Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){ + if (tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, + Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) { value += tokenStream.token().value; value += this._readWhitespace(); @@ -2951,7 +3155,7 @@ Parser.prototype = function(){ return null; } }, - _pseudo: function(){ + _pseudo: function() { var tokenStream = this._tokenStream, pseudo = null, @@ -2959,35 +3163,39 @@ Parser.prototype = function(){ line, col; - if (tokenStream.match(Tokens.COLON)){ + if (tokenStream.match(Tokens.COLON)) { - if (tokenStream.match(Tokens.COLON)){ + if (tokenStream.match(Tokens.COLON)) { colons += ":"; } - if (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.match(Tokens.IDENT)) { pseudo = tokenStream.token().value; line = tokenStream.token().startLine; col = tokenStream.token().startCol - colons.length; - } else if (tokenStream.peek() == Tokens.FUNCTION){ + } else if (tokenStream.peek() === Tokens.FUNCTION) { line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol - colons.length; pseudo = this._functional_pseudo(); } - if (pseudo){ + if (pseudo) { pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col); + } else { + var startLine = tokenStream.LT(1).startLine, + startCol = tokenStream.LT(0).startCol; + throw new SyntaxError("Expected a `FUNCTION` or `IDENT` after colon at line " + startLine + ", col " + startCol + ".", startLine, startCol); } } return pseudo; }, - _functional_pseudo: function(){ + _functional_pseudo: function() { var tokenStream = this._tokenStream, value = null; - if(tokenStream.match(Tokens.FUNCTION)){ + if (tokenStream.match(Tokens.FUNCTION)) { value = tokenStream.token().value; value += this._readWhitespace(); value += this._expression(); @@ -2997,15 +3205,15 @@ Parser.prototype = function(){ return value; }, - _expression: function(){ + _expression: function() { var tokenStream = this._tokenStream, value = ""; - while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, - Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, - Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, - Tokens.RESOLUTION, Tokens.SLASH])){ + while (tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, + Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, + Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, + Tokens.RESOLUTION, Tokens.SLASH])) { value += tokenStream.token().value; value += this._readWhitespace(); @@ -3014,7 +3222,7 @@ Parser.prototype = function(){ return value.length ? value : null; }, - _negation: function(){ + _negation: function() { var tokenStream = this._tokenStream, line, @@ -3023,7 +3231,7 @@ Parser.prototype = function(){ arg, subpart = null; - if (tokenStream.match(Tokens.NOT)){ + if (tokenStream.match(Tokens.NOT)) { value = tokenStream.token().value; line = tokenStream.token().startLine; col = tokenStream.token().startCol; @@ -3040,13 +3248,13 @@ Parser.prototype = function(){ return subpart; }, - _negation_arg: function(){ + _negation_arg: function() { var tokenStream = this._tokenStream, args = [ this._type_selector, this._universal, - function(){ + function() { return tokenStream.match(Tokens.HASH) ? new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : null; @@ -3058,7 +3266,6 @@ Parser.prototype = function(){ arg = null, i = 0, len = args.length, - elementName, line, col, part; @@ -3066,15 +3273,15 @@ Parser.prototype = function(){ line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; - while(i < len && arg === null){ + while (i < len && arg === null) { arg = args[i].call(this); i++; } - if (arg === null){ + if (arg === null) { this._unexpectedToken(tokenStream.LT(1)); } - if (arg.type == "elementName"){ + if (arg.type === "elementName") { part = new SelectorPart(arg, [], arg.toString(), line, col); } else { part = new SelectorPart(null, [arg], arg.toString(), line, col); @@ -3083,31 +3290,30 @@ Parser.prototype = function(){ return part; }, - _declaration: function(){ + _declaration: function() { - var tokenStream = this._tokenStream, - property = null, - expr = null, - prio = null, - error = null, - invalid = null, - propertyName= ""; + var tokenStream = this._tokenStream, + property = null, + expr = null, + prio = null, + invalid = null, + propertyName = ""; property = this._property(); - if (property !== null){ + if (property !== null) { tokenStream.mustMatch(Tokens.COLON); this._readWhitespace(); expr = this._expr(); - if (!expr || expr.length === 0){ + if (!expr || expr.length === 0) { this._unexpectedToken(tokenStream.LT(1)); } prio = this._prio(); propertyName = property.toString(); - if (this.options.starHack && property.hack == "*" || - this.options.underscoreHack && property.hack == "_") { + if (this.options.starHack && property.hack === "*" || + this.options.underscoreHack && property.hack === "_") { propertyName = property.text; } @@ -3134,7 +3340,7 @@ Parser.prototype = function(){ } }, - _prio: function(){ + _prio: function() { var tokenStream = this._tokenStream, result = tokenStream.match(Tokens.IMPORTANT_SYM); @@ -3143,21 +3349,20 @@ Parser.prototype = function(){ return result; }, - _expr: function(inFunction){ + _expr: function(inFunction) { - var tokenStream = this._tokenStream, - values = [], + var values = [], value = null, operator = null; value = this._term(inFunction); - if (value !== null){ + if (value !== null) { values.push(value); do { operator = this._operator(inFunction); - if (operator){ + if (operator) { values.push(operator); } /*else { values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); @@ -3166,44 +3371,45 @@ Parser.prototype = function(){ value = this._term(inFunction); - if (value === null){ + if (value === null) { break; } else { values.push(value); } - } while(true); + } while (true); } return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null; }, - _term: function(inFunction){ + _term: function(inFunction) { var tokenStream = this._tokenStream, unary = null, value = null, endChar = null, + part = null, token, line, col; unary = this._unary_operator(); - if (unary !== null){ + if (unary !== null) { line = tokenStream.token().startLine; col = tokenStream.token().startCol; } - if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){ + if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) { value = this._ie_function(); - if (unary === null){ + if (unary === null) { line = tokenStream.token().startLine; col = tokenStream.token().startCol; } - } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])){ + } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) { token = tokenStream.token(); endChar = token.endChar; value = token.value + this._expr(inFunction).text; - if (unary === null){ + if (unary === null) { line = tokenStream.token().startLine; col = tokenStream.token().startCol; } @@ -3211,24 +3417,25 @@ Parser.prototype = function(){ value += endChar; this._readWhitespace(); } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, - Tokens.ANGLE, Tokens.TIME, - Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){ + Tokens.ANGLE, Tokens.TIME, + Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) { value = tokenStream.token().value; - if (unary === null){ + if (unary === null) { line = tokenStream.token().startLine; col = tokenStream.token().startCol; + part = PropertyValuePart.fromToken(tokenStream.token()); } this._readWhitespace(); } else { token = this._hexcolor(); - if (token === null){ - if (unary === null){ + if (token === null) { + if (unary === null) { line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; } - if (value === null){ - if (tokenStream.LA(3) == Tokens.EQUALS && this.options.ieFilters){ + if (value === null) { + if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters) { value = this._ie_function(); } else { value = this._function(); @@ -3237,7 +3444,7 @@ Parser.prototype = function(){ } else { value = token.value; - if (unary === null){ + if (unary === null) { line = token.startLine; col = token.startCol; } @@ -3245,31 +3452,31 @@ Parser.prototype = function(){ } - return value !== null ? + return part !== null ? part : value !== null ? new PropertyValuePart(unary !== null ? unary + value : value, line, col) : null; }, - _function: function(){ + _function: function() { var tokenStream = this._tokenStream, functionText = null, expr = null, lt; - if (tokenStream.match(Tokens.FUNCTION)){ + if (tokenStream.match(Tokens.FUNCTION)) { functionText = tokenStream.token().value; this._readWhitespace(); expr = this._expr(true); functionText += expr; - if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){ + if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) { do { - if (this._readWhitespace()){ + if (this._readWhitespace()) { functionText += tokenStream.token().value; } - if (tokenStream.LA(0) == Tokens.COMMA){ + if (tokenStream.LA(0) === Tokens.COMMA) { functionText += tokenStream.token().value; } @@ -3279,12 +3486,12 @@ Parser.prototype = function(){ tokenStream.match(Tokens.EQUALS); functionText += tokenStream.token().value; lt = tokenStream.peek(); - while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) { tokenStream.get(); functionText += tokenStream.token().value; lt = tokenStream.peek(); } - } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + } while (tokenStream.match([Tokens.COMMA, Tokens.S])); } tokenStream.match(Tokens.RPAREN); @@ -3295,21 +3502,20 @@ Parser.prototype = function(){ return functionText; }, - _ie_function: function(){ + _ie_function: function() { var tokenStream = this._tokenStream, functionText = null, - expr = null, lt; - if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){ + if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) { functionText = tokenStream.token().value; do { - if (this._readWhitespace()){ + if (this._readWhitespace()) { functionText += tokenStream.token().value; } - if (tokenStream.LA(0) == Tokens.COMMA){ + if (tokenStream.LA(0) === Tokens.COMMA) { functionText += tokenStream.token().value; } @@ -3319,12 +3525,12 @@ Parser.prototype = function(){ tokenStream.match(Tokens.EQUALS); functionText += tokenStream.token().value; lt = tokenStream.peek(); - while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) { tokenStream.get(); functionText += tokenStream.token().value; lt = tokenStream.peek(); } - } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + } while (tokenStream.match([Tokens.COMMA, Tokens.S])); tokenStream.match(Tokens.RPAREN); functionText += ")"; @@ -3334,17 +3540,17 @@ Parser.prototype = function(){ return functionText; }, - _hexcolor: function(){ + _hexcolor: function() { var tokenStream = this._tokenStream, token = null, color; - if(tokenStream.match(Tokens.HASH)){ + if (tokenStream.match(Tokens.HASH)) { token = tokenStream.token(); color = token.value; - if (!/#[a-f0-9]{3,6}/i.test(color)){ + if (!/#[a-f0-9]{3,6}/i.test(color)) { throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); } this._readWhitespace(); @@ -3353,7 +3559,7 @@ Parser.prototype = function(){ return token; }, - _keyframes: function(){ + _keyframes: function() { var tokenStream = this._tokenStream, token, tt, @@ -3362,7 +3568,7 @@ Parser.prototype = function(){ tokenStream.mustMatch(Tokens.KEYFRAMES_SYM); token = tokenStream.token(); - if (/^@\-([^\-]+)\-/.test(token.value)) { + if (/^@-([^-]+)-/.test(token.value)) { prefix = RegExp.$1; } @@ -3382,7 +3588,7 @@ Parser.prototype = function(){ this._readWhitespace(); tt = tokenStream.peek(); - while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) { + while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) { this._keyframe_rule(); this._readWhitespace(); tt = tokenStream.peek(); @@ -3398,21 +3604,19 @@ Parser.prototype = function(){ this._readWhitespace(); tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); }, - _keyframe_name: function(){ - var tokenStream = this._tokenStream, - token; + _keyframe_name: function() { + var tokenStream = this._tokenStream; tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); return SyntaxUnit.fromToken(tokenStream.token()); }, - _keyframe_rule: function(){ - var tokenStream = this._tokenStream, - token, - keyList = this._key_list(); + _keyframe_rule: function() { + var keyList = this._key_list(); this.fire({ type: "startkeyframerule", @@ -3432,16 +3636,14 @@ Parser.prototype = function(){ }, - _key_list: function(){ + _key_list: function() { var tokenStream = this._tokenStream, - token, - key, keyList = []; keyList.push(this._key()); this._readWhitespace(); - while(tokenStream.match(Tokens.COMMA)){ + while (tokenStream.match(Tokens.COMMA)) { this._readWhitespace(); keyList.push(this._key()); this._readWhitespace(); @@ -3450,17 +3652,17 @@ Parser.prototype = function(){ return keyList; }, - _key: function(){ + _key: function() { var tokenStream = this._tokenStream, token; - if (tokenStream.match(Tokens.PERCENTAGE)){ + if (tokenStream.match(Tokens.PERCENTAGE)) { return SyntaxUnit.fromToken(tokenStream.token()); - } else if (tokenStream.match(Tokens.IDENT)){ + } else if (tokenStream.match(Tokens.IDENT)) { token = tokenStream.token(); - if (/from|to/i.test(token.value)){ + if (/from|to/i.test(token.value)) { return SyntaxUnit.fromToken(token); } @@ -3468,18 +3670,18 @@ Parser.prototype = function(){ } this._unexpectedToken(tokenStream.LT(1)); }, - _skipCruft: function(){ - while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){ + _skipCruft: function() { + while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) { } }, - _readDeclarations: function(checkStart, readMargins){ + _readDeclarations: function(checkStart, readMargins) { var tokenStream = this._tokenStream, tt; this._readWhitespace(); - if (checkStart){ + if (checkStart) { tokenStream.mustMatch(Tokens.LBRACE); } @@ -3487,11 +3689,11 @@ Parser.prototype = function(){ try { - while(true){ + while (true) { - if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){ - } else if (this._declaration()){ - if (!tokenStream.match(Tokens.SEMICOLON)){ + if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) { + } else if (this._declaration()) { + if (!tokenStream.match(Tokens.SEMICOLON)) { break; } } else { @@ -3504,7 +3706,7 @@ Parser.prototype = function(){ this._readWhitespace(); } catch (ex) { - if (ex instanceof SyntaxError && !this.options.strict){ + if (ex instanceof SyntaxError && !this.options.strict) { this.fire({ type: "error", error: ex, @@ -3513,9 +3715,9 @@ Parser.prototype = function(){ col: ex.col }); tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); - if (tt == Tokens.SEMICOLON){ + if (tt === Tokens.SEMICOLON) { this._readDeclarations(false, readMargins); - } else if (tt != Tokens.RBRACE){ + } else if (tt !== Tokens.RBRACE) { throw ex; } @@ -3525,45 +3727,45 @@ Parser.prototype = function(){ } }, - _readWhitespace: function(){ + _readWhitespace: function() { var tokenStream = this._tokenStream, ws = ""; - while(tokenStream.match(Tokens.S)){ + while (tokenStream.match(Tokens.S)) { ws += tokenStream.token().value; } return ws; }, - _unexpectedToken: function(token){ + _unexpectedToken: function(token) { throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); }, - _verifyEnd: function(){ - if (this._tokenStream.LA(1) != Tokens.EOF){ + _verifyEnd: function() { + if (this._tokenStream.LA(1) !== Tokens.EOF) { this._unexpectedToken(this._tokenStream.LT(1)); } }, - _validateProperty: function(property, value){ + _validateProperty: function(property, value) { Validation.validate(property, value); }, - parse: function(input){ + parse: function(input) { this._tokenStream = new TokenStream(input, Tokens); this._stylesheet(); }, - parseStyleSheet: function(input){ + parseStyleSheet: function(input) { return this.parse(input); }, - parseMediaQuery: function(input){ + parseMediaQuery: function(input) { this._tokenStream = new TokenStream(input, Tokens); var result = this._media_query(); this._verifyEnd(); return result; }, - parsePropertyValue: function(input){ + parsePropertyValue: function(input) { this._tokenStream = new TokenStream(input, Tokens); this._readWhitespace(); @@ -3573,7 +3775,7 @@ Parser.prototype = function(){ this._verifyEnd(); return result; }, - parseRule: function(input){ + parseRule: function(input) { this._tokenStream = new TokenStream(input, Tokens); this._readWhitespace(); @@ -3582,7 +3784,7 @@ Parser.prototype = function(){ this._verifyEnd(); return result; }, - parseSelector: function(input){ + parseSelector: function(input) { this._tokenStream = new TokenStream(input, Tokens); this._readWhitespace(); @@ -3592,510 +3794,482 @@ Parser.prototype = function(){ this._verifyEnd(); return result; }, - parseStyleAttribute: function(input){ - input += "}"; // for error recovery in _readDeclarations() + parseStyleAttribute: function(input) { + input += "}"; // for error recovery in _readDeclarations() this._tokenStream = new TokenStream(input, Tokens); this._readDeclarations(); } }; - for (prop in additions){ - if (additions.hasOwnProperty(prop)){ + for (prop in additions) { + if (Object.prototype.hasOwnProperty.call(additions, prop)) { proto[prop] = additions[prop]; } } return proto; }(); -var Properties = { - "align-items" : "flex-start | flex-end | center | baseline | stretch", - "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", - "align-self" : "auto | flex-start | flex-end | center | baseline | stretch", - "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch", - "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", - "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch", - "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | | ", - "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", - "animation" : 1, - "animation-delay" : { multi: "
'; } From d0ed15ce5c6f3918807681fc9eeaaa001c7ef605 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Apr 2022 17:12:54 +0200 Subject: [PATCH 292/752] Typo --- htdocs/accountancy/admin/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 8cef3a05cf4..03cd41a43a9 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -24,7 +24,7 @@ /** * \file htdocs/accountancy/admin/export.php * \ingroup Accountancy (Double entries) - * \brief Setup page to configure accounting expert module + * \brief Setup page to configure accounting export module */ require '../../main.inc.php'; From 440b5350df6511f5076803fcdf1b696e6cfa90ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Apr 2022 17:12:45 +0200 Subject: [PATCH 293/752] # WARNING: head commit changed in the meantime Merge branch '14.0' of git@github.com:Dolibarr/dolibarr.git into 14.0 --- htdocs/compta/accounting-files.php | 368 ++++++++++++++++------------- 1 file changed, 199 insertions(+), 169 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index a06dd8dacaf..3942e7cb6dd 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -19,11 +19,11 @@ * along with this program. If not, see . */ - /** - * \file htdocs/compta/accounting-files.php - * \ingroup compta - * \brief Page to show portoflio and files of a thirdparty and download it - */ +/** + * \file htdocs/compta/accounting-files.php + * \ingroup compta + * \brief Page to show portoflio and files of a thirdparty and download it + */ if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file if (!defined('NOTOKENRENEWAL')) { @@ -499,7 +499,7 @@ if ($result && $action == "dl" && !$error) { $zip->addFromString('transactions.csv', $log); $zip->close(); - ///Then download the zipped file. + // Then download the zipped file. header('Content-Type: application/zip'); header('Content-disposition: attachment; filename='.basename($zipname)); header('Content-Length: '.filesize($zipname)); @@ -578,7 +578,7 @@ print '
'; foreach ($listofchoices as $choice => $val) { if (empty($val['enabled'])) { - continue; // list not qualified + continue; // list not qualified } $disabled = ''; if (empty($val['perms'])) { @@ -588,14 +588,13 @@ foreach ($listofchoices as $choice => $val) { print '
'; } -print ''; +print ''; print ''."\n"; print dol_get_fiche_end(); if (!empty($date_start) && !empty($date_stop)) { - $param = 'action=searchfiles'; $param .= '&date_startday='.GETPOST('date_startday', 'int'); $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); @@ -603,25 +602,47 @@ if (!empty($date_start) && !empty($date_stop)) { $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); foreach ($listofchoices as $choice => $val) { - $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); + if (GETPOST($choice, 'int')) { + $param .= '&'.$choice.'=1'; + } } - print '
'."\n"; - print ''; + + $TData = dol_sort_array($filesarray, $sortfield, $sortorder); + + + $filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip'; echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - foreach ($listofchoices as $choice => $val) { - print ''; + print ''."\n"; + print $langs->trans("Download"); + print '
'; - print ''; - print '
'."\n"; + $param .= '&action=searchfiles'; + + /* + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + foreach ($listofchoices as $choice => $val) { + print ''; + } + + print ''; + print ''."\n"; + */ print '
'; @@ -645,172 +666,181 @@ if (!empty($date_start) && !empty($date_stop)) { print ''.$langs->trans("Currency").''; } print ''; - if ($result) { - $TData = dol_sort_array($filesarray, $sortfield, $sortorder); - if (empty($TData)) { - print ''.$langs->trans("NoItem").''; - if (!empty($conf->multicurrency->enabled)) { - print ''; + if (empty($TData)) { + print ''.$langs->trans("NoRecordFound").''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print ''; + } else { + // Sort array by date ASC to calculate balance + + $totalET_debit = 0; + $totalIT_debit = 0; + $totalVAT_debit = 0; + $totalET_credit = 0; + $totalIT_credit = 0; + $totalVAT_credit = 0; + + // Display array + foreach ($TData as $data) { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print ''; + + // Type + print ''.$langs->trans($data['item']).''; + + // Date + print ''; + print dol_print_date($data['date'], 'day'); + print "\n"; + + // Date due + print ''; + print dol_print_date($data['date_due'], 'day'); + print "\n"; + + // Ref + print ''; + + if ($data['item'] == 'Invoice') { + $invoice->id = $data['id']; + $invoice->ref = $data['ref']; + $invoice->total_ht = $data['amount_ht']; + $invoice->total_ttc = $data['amount_ttc']; + $invoice->total_tva = $data['amount_vat']; + $invoice->multicurrency_code = $data['currency']; + print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } elseif ($data['item'] == 'SupplierInvoice') { + $supplier_invoice->id = $data['id']; + $supplier_invoice->ref = $data['ref']; + $supplier_invoice->total_ht = $data['amount_ht']; + $supplier_invoice->total_ttc = $data['amount_ttc']; + $supplier_invoice->total_tva = $data['amount_vat']; + $supplier_invoice->multicurrency_code = $data['currency']; + print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } elseif ($data['item'] == 'ExpenseReport') { + $expensereport->id = $data['id']; + $expensereport->ref = $data['ref']; + print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); + } elseif ($data['item'] == 'SalaryPayment') { + $salary_payment->id = $data['id']; + $salary_payment->ref = $data['ref']; + print $salary_payment->getNomUrl(1); + } elseif ($data['item'] == 'Donation') { + $don->id = $data['id']; + $don->ref = $data['ref']; + print $don->getNomUrl(1, 0, '', 0); + } elseif ($data['item'] == 'SocialContributions') { + $charge_sociales->id = $data['id']; + $charge_sociales->ref = $data['ref']; + print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); + } elseif ($data['item'] == 'VariousPayment') { + $various_payment->id = $data['id']; + $various_payment->ref = $data['ref']; + print $various_payment->getNomUrl(1, '', 0, 0); + } elseif ($data['item'] == 'LoanPayment') { + $payment_loan->id = $data['id']; + $payment_loan->ref = $data['ref']; + print $payment_loan->getNomUrl(1, 0, 0, '', 0); + } else { + print $data['ref']; } - print ''; - } else { - // Sort array by date ASC to calculate balance + print ''; - $totalET_debit = 0; - $totalIT_debit = 0; - $totalVAT_debit = 0; - $totalET_credit = 0; - $totalIT_credit = 0; - $totalVAT_credit = 0; - - // Display array - foreach ($TData as $data) { - $html_class = ''; - //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; - //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; - print ''; - - // Type - print ''.$langs->trans($data['item']).''; - - // Date - print ''; - print dol_print_date($data['date'], 'day'); - print "\n"; - - // Date due - print ''; - print dol_print_date($data['date_due'], 'day'); - print "\n"; - - // Ref - print ''; - - if ($data['item'] == 'Invoice') { - $invoice->id = $data['id']; - $invoice->ref = $data['ref']; - $invoice->total_ht = $data['amount_ht']; - $invoice->total_ttc = $data['amount_ttc']; - $invoice->total_tva = $data['amount_vat']; - $invoice->multicurrency_code = $data['currency']; - print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } elseif ($data['item'] == 'SupplierInvoice') { - $supplier_invoice->id = $data['id']; - $supplier_invoice->ref = $data['ref']; - $supplier_invoice->total_ht = $data['amount_ht']; - $supplier_invoice->total_ttc = $data['amount_ttc']; - $supplier_invoice->total_tva = $data['amount_vat']; - $supplier_invoice->multicurrency_code = $data['currency']; - print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } elseif ($data['item'] == 'ExpenseReport') { - $expensereport->id = $data['id']; - $expensereport->ref = $data['ref']; - print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); - } elseif ($data['item'] == 'SalaryPayment') { - $salary_payment->id = $data['id']; - $salary_payment->ref = $data['ref']; - print $salary_payment->getNomUrl(1); - } elseif ($data['item'] == 'Donation') { - $don->id = $data['id']; - $don->ref = $data['ref']; - print $don->getNomUrl(1, 0, '', 0); - } elseif ($data['item'] == 'SocialContributions') { - $charge_sociales->id = $data['id']; - $charge_sociales->ref = $data['ref']; - print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); - } elseif ($data['item'] == 'VariousPayment') { - $various_payment->id = $data['id']; - $various_payment->ref = $data['ref']; - print $various_payment->getNomUrl(1, '', 0, 0); - } elseif ($data['item'] == 'LoanPayment') { - $payment_loan->id = $data['id']; - $payment_loan->ref = $data['ref']; - print $payment_loan->getNomUrl(1, 0, 0, '', 0); - } else { - print $data['ref']; - } - print ''; - - // File link - print ''; - if (!empty($data['files'])) { - foreach ($data['files'] as $id => $filecursor) { - print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; + // File link + print ''; + if (!empty($data['files'])) { + foreach ($data['files'] as $id => $filecursor) { + $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0); + if ($tmppreview) { + print $tmppreview; } + $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']); + print ''; + if (empty($tmppreview)) { + print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright'); + } + print $filename; + print '
'; } - print "\n"; + } + print "\n"; - // Paid - print ''.$data['paid'].''; + // Paid + print ''.($data['paid'] ? yn($data['paid']) : '').''; - // Total ET - print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; - // Total IT - print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; - // Total VAT - print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; + // Total ET + print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; + // Total IT + print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; + // Total VAT + print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; - print ''.dol_escape_htmltag($data['thirdparty_name'])."\n"; + print ''.dol_escape_htmltag($data['thirdparty_name'])."\n"; - print ''.$data['thirdparty_code']."\n"; + print ''.$data['thirdparty_code']."\n"; - print ''.$data['country_code']."\n"; + print ''.$data['country_code']."\n"; - print ''.dol_escape_htmltag($data['vatnum'])."\n"; + // VAT number + print ''.dol_escape_htmltag($data['vatnum'])."\n"; - if ($data['sens']) { - $totalET_credit += $data['amount_ht']; - $totalIT_credit += $data['amount_ttc']; - $totalVAT_credit += $data['amount_vat']; - } else { - $totalET_debit -= $data['amount_ht']; - $totalIT_debit -= $data['amount_ttc']; - $totalVAT_debit -= $data['amount_vat']; - } - - if (!empty($conf->multicurrency->enabled)) { - print ''.$data['currency']."\n"; - } - - print "\n"; + if ($data['sens']) { + $totalET_credit += $data['amount_ht']; + $totalIT_credit += $data['amount_ttc']; + $totalVAT_credit += $data['amount_vat']; + } else { + $totalET_debit -= $data['amount_ht']; + $totalIT_debit -= $data['amount_ttc']; + $totalVAT_debit -= $data['amount_vat']; } - // Total credits - print ''; - print ''.$langs->trans('Total').' '.$langs->trans('Income').''; - print ''.price(price2num($totalET_credit, 'MT')).''; - print ''.price(price2num($totalIT_credit, 'MT')).''; - print ''.price(price2num($totalVAT_credit, 'MT')).''; - print ''; if (!empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Total debits - print ''; - print ''.$langs->trans('Total').' '.$langs->trans('Outcome').''; - print ''.price(price2num($totalET_debit, 'MT')).''; - print ''.price(price2num($totalIT_debit, 'MT')).''; - print ''.price(price2num($totalVAT_debit, 'MT')).''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Balance - print ''; - print ''.$langs->trans('Total').''; - print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''; - print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''; - print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; + print ''.$data['currency']."\n"; } + print "\n"; } + + // Total credits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Income').''; + print ''.price(price2num($totalET_credit, 'MT')).''; + print ''.price(price2num($totalIT_credit, 'MT')).''; + print ''.price(price2num($totalVAT_credit, 'MT')).''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Total debits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Outcome').''; + print ''.price(price2num($totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_debit, 'MT')).''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Balance + print ''; + print ''.$langs->trans('Total').''; + print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; } + print ""; print '
'; } From 0c0ff4dec9c77f18a84110f4aa42d2e6b61d6a5f Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 10 Feb 2022 17:06:46 +0100 Subject: [PATCH 294/752] add WORKFLOW_TICKET_CREATE_INTERVENTION to workflow constants --- htdocs/core/modules/modWorkflow.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index dc05bf9dc66..248d3c006ce 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -95,7 +95,8 @@ class modWorkflow extends DolibarrModules 8=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0), 9=>array('WORKFLOW_BILL_ON_RECEPTION', 'chaine', '1', 'WORKFLOW_BILL_ON_RECEPTION', 0, 'current', 0), 10=>array('WORKFLOW_TICKET_LINK_CONTRACT', 'chaine', '0', 'Automatically link a ticket to available contracts', 0, 'current', 0), - 11=>array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0) + 11=>array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0), + 11=>array('WORKFLOW_TICKET_CREATE_INTERVENTION', 'chaine', '1', 'WORKFLOW_TICKET_CREATE_INTERVENTION', 0, 'current', 0) ); // Boxes From 4790006c3a1adabd9e87af11efb0cc9cc6469af4 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 10 Feb 2022 17:09:09 +0100 Subject: [PATCH 295/752] workflow config: add button for WORKFLOW_TICKET_CREATE_INTERVENTION --- htdocs/admin/workflow.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index da82f163a7f..a684d642b2f 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -71,6 +71,12 @@ $workflowcodes = array( 'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)), 'picto'=>'bill' ), + 'WORKFLOW_TICKET_CREATE_INTERVENTION' => array ( + 'family'=>'create', + 'position'=>25, + 'enabled'=>(!empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)), + 'picto'=>'ticket' + ), 'separator1'=>array('family'=>'separator', 'position'=>25, 'title'=>''), From 8db171ae4153dbafc41bf3037b8d575d2d5ba912 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 10 Feb 2022 17:11:35 +0100 Subject: [PATCH 296/752] add translation string for workflow ticket fichinter creation --- htdocs/langs/en_US/workflow.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 6ddf8d9c6a3..e5c07583931 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -7,6 +7,7 @@ descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a sales order after a descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (the new invoice will have same amount as the proposal) descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a sales order is closed (the new invoice will have same amount as the order) +descWORKFLOW_TICKET_CREATE_INTERVENTION=Create an intervention when opening a ticket from backend and link it to the ticket. # Autoclassify customer proposal or order descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when sales order is set to billed (and if the amount of the order is the same as the total amount of the signed linked proposal) descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when customer invoice is validated (and if the amount of the invoice is the same as the total amount of the signed linked proposal) From ea68ed9c07e55e84cc3a356d906db27960d2c3a6 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 7 Feb 2022 17:02:19 +0100 Subject: [PATCH 297/752] move automatic intervention creation from ticket/card.php to triggers/workflow.php --- ...e_20_modWorkflow_WorkflowManager.class.php | 23 ++++++++++++++++++- htdocs/ticket/card.php | 22 ------------------ 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 4e98af5c6c7..ff9787dbb06 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -435,7 +435,6 @@ class InterfaceWorkflowManager extends DolibarrTriggers $number_contracts_found = 0; foreach ($company_ids as $company_id) { $contrat->socid = $company_id; - $list = $contrat->getListOfContracts($option = 'all', $status = [Contrat::STATUS_DRAFT, Contrat::STATUS_VALIDATED], $product_categories = [$conf->global->TICKET_PRODUCT_CATEGORY], $line_status = [ContratLigne::STATUS_INITIAL, ContratLigne::STATUS_OPEN]); if (is_array($list) && !empty($list)) { $number_contracts_found = count($list); @@ -457,6 +456,28 @@ class InterfaceWorkflowManager extends DolibarrTriggers if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs'); } } + // Automatically create intervention + if (!empty($conf->ficheinter->enabled) && !empty($conf->ticket->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_TICKET_CREATE_INTERVENTION) && !empty($object->fk_soc)) { + $fichinter = new Fichinter($this->db); + $fichinter->socid = $object->fk_soc; + $fichinter->fk_project = $projectid; + $fichinter->fk_contrat = (int) $object->fk_contract; + $fichinter->author = $user->id; + $fichinter->model_pdf = 'soleil'; + $fichinter->origin = $object->element; + $fichinter->origin_id = $object->id; + + // Extrafields + $extrafields = new ExtraFields($this->db); + $extrafields->fetch_name_optionals_label($fichinter->table_element); + $array_options = $extrafields->getOptionalsFromPost($fichinter->table_element); + $fichinter->array_options = $array_options; + + $id = $fichinter->create($user); + if ($id <= 0) { + setEventMessages($fichinter->error, null, 'errors'); + } + } } return 0; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 1cebeec3506..99913e6c997 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -254,28 +254,6 @@ if (empty($reshook)) { $result = $object->assignUser($user, $user->id, 1); $object->add_contact($user->id, "SUPPORTTEC", 'internal'); } - - // Auto create fiche intervention - if (!empty($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE)) { - $fichinter = new Fichinter($db); - $fichinter->socid = $object->fk_soc; - $fichinter->fk_project = $projectid; - $fichinter->fk_contrat = $object->fk_contract; - $fichinter->author = $user->id; - $fichinter->model_pdf = 'soleil'; - $fichinter->origin = $object->element; - $fichinter->origin_id = $object->id; - - // Extrafields - $extrafields->fetch_name_optionals_label($fichinter->table_element); - $array_options = $extrafields->getOptionalsFromPost($fichinter->table_element); - $fichinter->array_options = $array_options; - - $id = $fichinter->create($user); - if ($id <= 0) { - setEventMessages($fichinter->error, null, 'errors'); - } - } } if (!$error) { From 424125ca03403532778069c430e381b323064ca9 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Tue, 8 Feb 2022 11:22:38 +0100 Subject: [PATCH 298/752] Workflow fichinter: use default fichinter pdf model --- .../triggers/interface_20_modWorkflow_WorkflowManager.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index ff9787dbb06..e229e40fd8a 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -463,7 +463,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers $fichinter->fk_project = $projectid; $fichinter->fk_contrat = (int) $object->fk_contract; $fichinter->author = $user->id; - $fichinter->model_pdf = 'soleil'; + $fichinter->model_pdf = (!empty($conf->global->FICHEINTER_ADDON_PDF)) ? $conf->global->FICHEINTER_ADDON_PDF : 'soleil'; $fichinter->origin = $object->element; $fichinter->origin_id = $object->id; From 35d596e1dcedd7634c39a16b6e0ceea005c505e3 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 10 Feb 2022 17:28:18 +0100 Subject: [PATCH 299/752] rename constant TICKET_AUTO_CREATE_FICHINTER_CREATE to WORKFLOW_TICKET_CREATE_INTERVENTION --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 1876d3428b4..3859c1331e2 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -117,6 +117,7 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value ALTER TABLE llx_ticket ADD COLUMN date_last_msg_sent datetime AFTER date_read; UPDATE llx_const SET name = 'WORKFLOW_TICKET_LINK_CONTRACT' WHERE name = 'TICKET_AUTO_ASSIGN_CONTRACT_CREATE'; +UPDATE llx_const SET name = 'WORKFLOW_TICKET_CREATE_INTERVENTION' WHERE name = 'TICKET_AUTO_CREATE_FICHINTER_CREATE'; CREATE TABLE llx_stock_mouvement_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, From ac7f02e0d37bff9e45884f3630287155158eadd1 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 10 Feb 2022 17:47:40 +0100 Subject: [PATCH 300/752] stickler corrections --- htdocs/admin/workflow.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index a684d642b2f..a68f49e36e3 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -72,10 +72,10 @@ $workflowcodes = array( 'picto'=>'bill' ), 'WORKFLOW_TICKET_CREATE_INTERVENTION' => array ( - 'family'=>'create', - 'position'=>25, - 'enabled'=>(!empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)), - 'picto'=>'ticket' + 'family'=>'create', + 'position'=>25, + 'enabled'=>(!empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)), + 'picto'=>'ticket' ), 'separator1'=>array('family'=>'separator', 'position'=>25, 'title'=>''), From 2ec7818c75cdf2c03801a074aade499e6e2fe7c2 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Fri, 18 Mar 2022 10:13:19 +0100 Subject: [PATCH 301/752] When the ficheinter can't be created, display an error. --- .../interface_20_modWorkflow_WorkflowManager.class.php | 4 ++-- htdocs/fichinter/class/fichinter.class.php | 2 +- htdocs/langs/en_US/interventions.lang | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index e229e40fd8a..1d46aec1008 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -457,9 +457,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } // Automatically create intervention - if (!empty($conf->ficheinter->enabled) && !empty($conf->ticket->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_TICKET_CREATE_INTERVENTION) && !empty($object->fk_soc)) { + if (!empty($conf->ficheinter->enabled) && !empty($conf->ticket->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_TICKET_CREATE_INTERVENTION)) { $fichinter = new Fichinter($this->db); - $fichinter->socid = $object->fk_soc; + $fichinter->socid = (int) $object->fk_soc; $fichinter->fk_project = $projectid; $fichinter->fk_contrat = (int) $object->fk_contract; $fichinter->author = $user->id; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index fac008ec304..ee2bf9269ce 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -255,7 +255,7 @@ class Fichinter extends CommonObject } if ($this->socid <= 0) { - $this->error = 'ErrorBadParameterForFunc'; + $this->error = 'ErrorFicheinterCompanyDoesNotExist'; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 7c117fcd1f2..a57a84fc4c8 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -67,3 +67,4 @@ ToCreateAPredefinedIntervention=To create a predefined or recurring intervention ConfirmReopenIntervention=Are you sure you want to open back the intervention %s? GenerateInter=Generate intervention FichinterNoContractLinked=Intervention %s has been created without a linked contract. +ErrorFicheinterCompanyDoesNotExist=Company does not exist. Intervention has not been created. From 7469cf79f5b5694242c0f4c1715828c9f387ea01 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Fri, 18 Mar 2022 10:17:16 +0100 Subject: [PATCH 302/752] enhance option explanation string --- htdocs/langs/en_US/workflow.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index e5c07583931..803a31c9646 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -7,7 +7,7 @@ descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a sales order after a descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (the new invoice will have same amount as the proposal) descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a sales order is closed (the new invoice will have same amount as the order) -descWORKFLOW_TICKET_CREATE_INTERVENTION=Create an intervention when opening a ticket from backend and link it to the ticket. +descWORKFLOW_TICKET_CREATE_INTERVENTION=On ticket creation, automatically create an intervention. # Autoclassify customer proposal or order descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when sales order is set to billed (and if the amount of the order is the same as the total amount of the signed linked proposal) descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when customer invoice is validated (and if the amount of the invoice is the same as the total amount of the signed linked proposal) From a913bf387546a30f5176281640e632ecab2387f9 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 4 Apr 2022 09:47:34 +0200 Subject: [PATCH 303/752] fix regression: use $hookmanager as a global variable to avoid errors on thirdparty page. --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 116c2beeb20..99921ac5fb0 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -41,7 +41,7 @@ */ function societe_prepare_head(Societe $object) { - global $db, $langs, $conf, $user; + global $db, $langs, $conf, $user, $hookmanager; $h = 0; $head = array(); From 563716b633badb6b8db073f2abacd55063bea098 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Mon, 4 Apr 2022 10:00:10 +0200 Subject: [PATCH 304/752] 16.0 - Proposal for trigger prefix consistency: instead of adding missing prefix, check that trigger starts with declared prefix --- htdocs/core/class/commonobject.class.php | 26 ++---------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ef9856a2035..c4d0635dde7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1988,10 +1988,6 @@ abstract class CommonObject $result = $this->fetchCommon($id); } if ($result >= 0) { - - if (!empty(self::TRIGGER_PREFIX) && strpos($trigkey, self::TRIGGER_PREFIX) !== 0) { - $trigkey = self::TRIGGER_PREFIX . '_' . $trigkey; - } $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors } if ($result < 0) { @@ -4274,9 +4270,6 @@ abstract class CommonObject if ($trigkey) { // Call trigger - if (!empty(self::TRIGGER_PREFIX) && strpos($trigkey, self::TRIGGER_PREFIX) !== 0) { - $trigkey = self::TRIGGER_PREFIX . '_' . $trigkey; - } $result = $this->call_trigger($trigkey, $user); if ($result < 0) { $error++; @@ -5610,9 +5603,8 @@ abstract class CommonObject { // phpcs:enable global $langs, $conf; - - if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX) !== 0) { - $triggerName = self::TRIGGER_PREFIX . '_' . $triggerName; + if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX . '_') !== 0) { + throw new Exception('The trigger "' . $triggerName . '" does not start with "' . self::TRIGGER_PREFIX . '_" as required.'); } if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; @@ -6201,9 +6193,6 @@ abstract class CommonObject if (!$error && $trigger) { // Call trigger $this->context = array('extrafieldaddupdate'=>1); - if (!empty(self::TRIGGER_PREFIX) && strpos($trigger, self::TRIGGER_PREFIX) !== 0) { - $trigger = self::TRIGGER_PREFIX . '_' . $trigger; - } $result = $this->call_trigger($trigger, $userused); if ($result < 0) { $error++; @@ -6322,9 +6311,6 @@ abstract class CommonObject if (!$error && $trigger) { // Call trigger $this->context = array('extralanguagesaddupdate'=>1); - if (!empty(self::TRIGGER_PREFIX) && strpos($trigger, self::TRIGGER_PREFIX) !== 0) { - $trigger = self::TRIGGER_PREFIX . '_' . $trigger; - } $result = $this->call_trigger($trigger, $userused); if ($result < 0) { $error++; @@ -6523,10 +6509,6 @@ abstract class CommonObject if (!$error && $trigger) { // Call trigger $this->context = array('extrafieldupdate'=>1); - - if (!empty(self::TRIGGER_PREFIX) && strpos($trigger, self::TRIGGER_PREFIX) !== 0) { - $trigger = self::TRIGGER_PREFIX . '_' . $trigger; - } $result = $this->call_trigger($trigger, $userused); if ($result < 0) { $error++; @@ -9447,10 +9429,6 @@ abstract class CommonObject if (!$error && !$notrigger) { // Call trigger - - if (!empty(self::TRIGGER_PREFIX) && strpos($triggercode, self::TRIGGER_PREFIX) !== 0) { - $triggercode = self::TRIGGER_PREFIX . '_' . $triggercode; - } $result = $this->call_trigger($triggercode, $user); if ($result < 0) { $error++; From 53b185ce9c987f4dbd8b0aae80e380c8f78f8f17 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Mon, 4 Apr 2022 10:19:51 +0200 Subject: [PATCH 305/752] fix condition on remx --- htdocs/comm/remx.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index f8a4c12fba7..1e3f56c30db 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -62,7 +62,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { exit; } -if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user->rights->societe->creer) { +if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -153,7 +153,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user- } } -if ($action == 'setremise' && $user->rights->societe->creer) { +if ($action == 'setremise' && ($user->rights->societe->creer || $user->rights->facture->creer)) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -192,7 +192,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) { } } -if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $user->rights->societe->creer) { +if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) From 9fec63c9088c75c83da68dde7ffcac19cedfc047 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Mon, 4 Apr 2022 10:20:43 +0200 Subject: [PATCH 306/752] Empty commit to re-launch Travis From 2009cc96e0e7d31a2e1cf3a422cd850a59112198 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Mon, 4 Apr 2022 10:21:06 +0200 Subject: [PATCH 307/752] clean branch --- htdocs/core/lib/security.lib.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b26c723a014..3ea554a4a8f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -615,9 +615,6 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta if ($feature == 'task') { $feature = 'projet_task'; } - if ($feature == 'banque') { - $feature = 'fk_account@bank_account'; - } $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object From 6cac982507056f0c401b63bf8894cd6bf7679ba4 Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 4 Apr 2022 10:32:17 +0200 Subject: [PATCH 308/752] FIX - Fix the adding of lines in the create invoice functions --- htdocs/compta/facture/class/facture.class.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 58da30ad205..fab80677c25 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -800,6 +800,10 @@ class Facture extends CommonInvoice $fk_parent_line = 0; } + // Complete vat rate with code + $vatrate = $newinvoiceline->tva_tx; + if ($newinvoiceline->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$newinvoiceline->vat_src_code.')'; + $newinvoiceline->fk_parent_line = $fk_parent_line; if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { @@ -810,7 +814,37 @@ class Facture extends CommonInvoice $newinvoiceline->fk_remise_except = $discountId; } - $result = $newinvoiceline->insert(); + $result = $this->addline( + $newinvoiceline->desc, + $newinvoiceline->subprice, + $newinvoiceline->qty, + $vatrate, + $newinvoiceline->localtax1_tx, + $newinvoiceline->localtax2_tx, + $newinvoiceline->fk_product, + $newinvoiceline->remise_percent, + $newinvoiceline->date_start, + $newinvoiceline->date_end, + $newinvoiceline->fk_code_ventilation, + $newinvoiceline->info_bits, + $newinvoiceline->fk_remise_except, + 'HT', + 0, + $newinvoiceline->product_type, + $newinvoiceline->rang, + $newinvoiceline->special_code, + $newinvoiceline->element, + $newinvoiceline->id, + $fk_parent_line, + $newinvoiceline->fk_fournprice, + $newinvoiceline->pa_ht, + $newinvoiceline->label, + $newinvoiceline->array_options, + $newinvoiceline->situation_percent, + $newinvoiceline->fk_prev_id, + $newinvoiceline->fk_unit, + $newinvoiceline->pu_ht_devise + ); // Defined the new fk_parent_line if ($result > 0 && $newinvoiceline->product_type == 9) { From 2913759bb705712b94b6d8e2591215e23d7b3cb6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Apr 2022 10:45:50 +0200 Subject: [PATCH 309/752] Fix syntax --- htdocs/core/modules/modCommande.class.php | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index cc6f8baab80..b31db42658d 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -335,35 +335,35 @@ class modCommande extends DolibarrModules } // End add extra fields - $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande']; - $this->import_regex_array[$r] = [ + $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande'); + $this->import_regex_array[$r] = array( 'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency' - ]; + ); - $this->import_updatekeys_array[$r] = ['c.ref' => 'Ref']; - $this->import_convertvalue_array[$r] = [ - 'c.fk_soc' => [ + $this->import_updatekeys_array[$r] = array('c.ref' => 'Ref'); + $this->import_convertvalue_array[$r] = array( + 'c.fk_soc' => array( 'rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty' - ], - 'c.fk_user_valid' => [ + ), + 'c.fk_user_valid' => array( 'rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user' - ], - 'c.fk_mode_reglement' => [ + ), + 'c.fk_mode_reglement' => array( 'rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment' - ], - ]; + ), + ); //Import CPV Lines $r++; From 2690f4459f58eebeacb7b1905282f61e9bfd8aa3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Apr 2022 13:17:45 +0200 Subject: [PATCH 310/752] NEW Enhance the import. Can use 'auto' for the ref (import of orders) --- htdocs/commande/list.php | 18 ++++- htdocs/core/commonfieldsinimport.inc.php | 63 ++++++++++++++++ htdocs/core/extrafieldsinexport.inc.php | 2 +- htdocs/core/extrafieldsinimport.inc.php | 75 +++++++++++++++++++ .../barcode/mod_barcode_product_standard.php | 2 +- .../core/modules/facture/mod_facture_mars.php | 2 +- .../modules/facture/mod_facture_mercure.php | 2 +- .../modules/facture/mod_facture_terre.php | 4 +- .../core/modules/facture/modules_facture.php | 5 +- .../modules/fichinter/modules_fichinter.php | 6 +- .../holiday/mod_holiday_immaculate.php | 6 +- .../core/modules/holiday/modules_holiday.php | 6 +- .../modules/import/import_csv.modules.php | 27 ++++++- .../modules/import/import_xlsx.modules.php | 31 ++++++-- htdocs/core/modules/modCommande.class.php | 54 ++++++------- .../product_batch/mod_lot_advanced.php | 2 +- .../modules/product_batch/mod_lot_free.php | 6 +- .../product_batch/mod_lot_standard.php | 4 +- .../modules/product_batch/mod_sn_advanced.php | 4 +- .../modules/product_batch/mod_sn_free.php | 6 +- .../modules/product_batch/mod_sn_standard.php | 2 +- .../modules/reception/mod_reception_beryl.php | 4 +- .../modules/reception/modules_reception.php | 4 +- .../modules_facturefournisseur.php | 2 +- .../modules_commandefournisseur.php | 6 +- .../mod_supplier_proposal_marbre.php | 6 +- .../mod_supplier_proposal_saphir.php | 6 +- .../modules_supplier_proposal.php | 8 +- .../takepos/mod_takepos_ref_universal.php | 2 +- .../core/modules/takepos/modules_takepos.php | 7 +- htdocs/core/modules/ticket/modules_ticket.php | 8 +- .../template/class/myobject.class.php | 2 +- .../core/modules/modMyModule.class.php | 37 +++++---- 33 files changed, 311 insertions(+), 108 deletions(-) create mode 100644 htdocs/core/commonfieldsinimport.inc.php create mode 100644 htdocs/core/extrafieldsinimport.inc.php diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index fcbd00fe945..52071b672fe 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -201,6 +201,7 @@ $arrayfields = array( 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990), 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995), + 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999), 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) ); // Extra fields @@ -441,7 +442,7 @@ $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture $sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,'; $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,'; $sql .= ' c.fk_cond_reglement,c.fk_mode_reglement,c.fk_shipping_method,'; -$sql .= ' c.fk_input_reason'; +$sql .= ' c.fk_input_reason, c.import_key'; if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { $sql .= ", cc.fk_categorie, cc.fk_soc"; } @@ -1275,6 +1276,11 @@ if ($resql) { print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); print ''; } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + print ''; + } // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { print ''; @@ -1436,6 +1442,9 @@ if ($resql) { if (!empty($arrayfields['c.facture']['checked'])) { print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); } + if (!empty($arrayfields['c.import_key']['checked'])) { + print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['c.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); } @@ -2063,6 +2072,13 @@ if ($resql) { $totalarray['nbfield']++; } } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''.$obj->import_key.''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; diff --git a/htdocs/core/commonfieldsinimport.inc.php b/htdocs/core/commonfieldsinimport.inc.php new file mode 100644 index 00000000000..60716b8b109 --- /dev/null +++ b/htdocs/core/commonfieldsinimport.inc.php @@ -0,0 +1,63 @@ +db); + + // Add common fields + foreach ($tmpobject->fields as $keyfield => $valuefield) { + $fieldname = $keyforalias.'.'.$keyfield; + $fieldlabel = ucfirst($valuefield['label']); + $typeFilter = "Text"; + $typefield = preg_replace('/\(.*$/', '', $valuefield['type']); // double(24,8) -> double + switch ($typefield) { + case 'int': + case 'integer': + case 'double': + case 'price': + $typeFilter = "Numeric"; + break; + case 'date': + case 'datetime': + case 'timestamp': + $typeFilter = "Date"; + break; + case 'boolean': + $typeFilter = "Boolean"; + break; + /* + * case 'sellist': + * $tmp=''; + * $tmpparam=jsonOrUnserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null + * if ($tmpparam['options'] && is_array($tmpparam['options'])) { + * $tmpkeys=array_keys($tmpparam['options']); + * $tmp=array_shift($tmpkeys); + * } + * if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; + * break; + */ + } + $helpfield = ''; + if (!empty($valuefield['help'])) { + $helpfield = preg_replace('/\(.*$/', '', $valuefield['help']); + } + if ($valuefield['enabled']) { + $this->import_fields_array[$r][$fieldname] = $fieldlabel; + $this->import_TypeFields_array[$r][$fieldname] = $typeFilter; + $this->import_entities_array[$r][$fieldname] = $keyforelement; + $this->import_help_array[$r][$fieldname] = $helpfield; + } + } +} else { + dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile); +} +// End add common fields diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php index fc2210eabd8..4962e353741 100644 --- a/htdocs/core/extrafieldsinexport.inc.php +++ b/htdocs/core/extrafieldsinexport.inc.php @@ -12,7 +12,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) { // Add extra fields $sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields"; -$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type != 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC'; +$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC'; //print $sql; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) diff --git a/htdocs/core/extrafieldsinimport.inc.php b/htdocs/core/extrafieldsinimport.inc.php new file mode 100644 index 00000000000..bbfcd7b9fdb --- /dev/null +++ b/htdocs/core/extrafieldsinimport.inc.php @@ -0,0 +1,75 @@ +db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC'; +//print $sql; +$resql = $this->db->query($sql); +if ($resql) { // This can fail when class is used on old database (during migration for example) + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = $keyforaliasextra.'.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $typeFilter = "Text"; + $typefield = preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double + switch ($typefield) { + case 'int': + case 'integer': + case 'double': + case 'price': + $typeFilter = "Numeric"; + break; + case 'date': + case 'datetime': + case 'timestamp': + $typeFilter = "Date"; + break; + case 'boolean': + $typeFilter = "Boolean"; + break; + case 'checkbox': + case 'select': + if (!empty($conf->global->EXPORT_LABEL_FOR_SELECT)) { + $tmpparam = jsonOrUnserialize($obj->param); // $tmpparam may be array with 'options' = array(key1=>val1, key2=>val2 ...) + if ($tmpparam['options'] && is_array($tmpparam['options'])) { + $typeFilter = "Select:".$obj->param; + } + } + break; + case 'sellist': + $tmp = ''; + $tmpparam = jsonOrUnserialize($obj->param); // $tmp may be array 'options' => array 'c_currencies:code_iso:code_iso' => null + if (is_array($tmpparam) && array_key_exists('options', $tmpparam) && $tmpparam['options'] && is_array($tmpparam['options'])) { + $tmpkeys = array_keys($tmpparam['options']); + $tmp = array_shift($tmpkeys); + } + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { + $typeFilter = "List:".$tmp; + } + break; + } + if ($obj->type != 'separate') { + // If not a computed field + if (empty($obj->fieldcomputed)) { + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $this->import_TypeFields_array[$r][$fieldname] = $typeFilter; + $this->import_entities_array[$r][$fieldname] = $keyforelement; + } else { + // If this is a computed field + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $this->import_TypeFields_array[$r][$fieldname] = $typeFilter.'Compute'; + $this->import_entities_array[$r][$fieldname] = $keyforelement; + } + } + } +} +// End add axtra fields diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index c101001af4c..17b5a9bb16a 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -176,7 +176,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value if OK, '' if module not configured, <0 if KO */ - public function getNextValue($objproduct = null, $type = '') + public function getNextValue($objproduct, $type = '') { global $db, $conf; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index c7a69a82caa..ef34b145e52 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -150,7 +150,7 @@ class mod_facture_mars extends ModeleNumRefFactures * @param Societe $objsoc Object third party * @param Facture $invoice Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value + * @return string Value if OK, 0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 621bb8e6d2d..7a572615a21 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -171,7 +171,7 @@ class mod_facture_mercure extends ModeleNumRefFactures $this->error = $numFinal; } - return $numFinal; + return $numFinal; } diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 55f6dd816d1..9660be93266 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -185,7 +185,7 @@ class mod_facture_terre extends ModeleNumRefFactures * @param Societe $objsoc Object third party * @param Facture $invoice Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Next ref value or last ref if $mode is 'last' + * @return string Next ref value or last ref if $mode is 'last', <= 0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { @@ -259,6 +259,8 @@ class mod_facture_terre extends ModeleNumRefFactures } else { dol_print_error('', 'Bad parameter for getNextValue'); } + + return 0; } /** diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index e188f66b1ad..480c532cc1f 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -132,10 +132,11 @@ abstract class ModeleNumRefFactures * Renvoi prochaine valeur attribuee * * @param Societe $objsoc Objet societe - * @param Facture $facture Objet facture + * @param Facture $invoice Objet facture + * @param string $mode 'next' for next value or 'last' for last value * @return string Value */ - public function getNextValue($objsoc, $facture) + public function getNextValue($objsoc, $invoice, $mode = 'next') { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 8cf79227d4f..185ef4cf73b 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -122,9 +122,11 @@ abstract class ModeleNumRefFicheinter /** * Return the next assigned value * - * @return string Value + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO */ - public function getNextValue() + public function getNextValue($objsoc = 0, $object = '') { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 84d6638a27e..a1647a67953 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -117,11 +117,11 @@ class mod_holiday_immaculate extends ModelNumRefHolidays /** * Return next value * - * @param Societe $user user object + * @param Societe $objsoc third party object * @param Object $holiday holiday object * @return string Value if OK, 0 if KO */ - public function getNextValue($user, $holiday) + public function getNextValue($objsoc, $holiday) { global $db, $conf; @@ -134,7 +134,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays return 0; } - $numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $user, $holiday->date_create); + $numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $objsoc, $holiday->date_create); return $numFinal; } diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 65b08f4bba8..7b6e13ea992 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -126,10 +126,10 @@ class ModelNumRefHolidays * Return next value * * @param Societe $objsoc third party object - * @param Object $contract contract object - * @return string Value + * @param Object $holiday Holiday object + * @return string Value if OK, 0 if KO */ - public function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $holiday) { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 947dd3d18d3..e45630df298 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -324,7 +324,8 @@ class ImportCsv extends ModeleImports //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); //var_dump($array_match_file_to_database); - //var_dump($arrayrecord); + //var_dump($arrayrecord); exit; + $array_match_database_to_file = array_flip($array_match_file_to_database); $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); @@ -367,12 +368,15 @@ class ImportCsv extends ModeleImports //dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]); } - // array of fields to column index + // Define array to convert fields ('c.ref', ...) into column index (1, ...) $arrayfield = array(); foreach ($sort_array_match_file_to_database as $key => $val) { $arrayfield[$val] = ($key - 1); } + // $arrayrecord start at key 0 + // $sort_array_match_file_to_database start at key 1 + // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) foreach ($sort_array_match_file_to_database as $key => $val) { $fieldalias = preg_replace('/\..*$/i', '', $val); @@ -595,9 +599,24 @@ class ImportCsv extends ModeleImports if (!empty($classModForNumber) && !empty($pathModForNumber) && is_readable(DOL_DOCUMENT_ROOT.$pathModForNumber)) { require_once DOL_DOCUMENT_ROOT.$pathModForNumber; $modForNumber = new $classModForNumber; - $defaultref = $modForNumber->getNextValue(null, null); + + $tmpobject = null; + // Set the object when we can + if (!empty($objimport->array_import_convertvalue[0][$val]['classobject'])) { + $pathForObject = $objimport->array_import_convertvalue[0][$val]['pathobject']; + require_once DOL_DOCUMENT_ROOT.$pathForObject; + $tmpclassobject = $objimport->array_import_convertvalue[0][$val]['classobject']; + $tmpobject = new $tmpclassobject($this->db); + foreach ($arrayfield as $tmpkey => $tmpval) { // $arrayfield is array('c.ref'=>0, ...) + if (in_array($tmpkey, array('t.date', 'c.date_commande'))) { + $tmpobject->date = dol_stringtotime($arrayrecord[$arrayfield[$tmpkey]]['val'], 1); + } + } + } + + $defaultref = $modForNumber->getNextValue(null, $tmpobject); } - if (is_numeric($defaultref) && $defaultref <= 0) { + if (is_numeric($defaultref) && $defaultref <= 0) { // If error $defaultref = ''; } $newval = $defaultref; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 3747e8f6847..9fa5cbf2c44 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -367,7 +367,8 @@ class ImportXlsx extends ModeleImports //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); //var_dump($array_match_file_to_database); - //var_dump($arrayrecord); + //var_dump($arrayrecord); exit; + $array_match_database_to_file = array_flip($array_match_file_to_database); $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); @@ -410,12 +411,15 @@ class ImportXlsx extends ModeleImports //dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]); } - // array of fields to column index + // Define array to convert fields ('c.ref', ...) into column index (1, ...) $arrayfield = array(); foreach ($sort_array_match_file_to_database as $key => $val) { - $arrayfield[$val] = ($key - 1); + $arrayfield[$val] = ($key); } + // $arrayrecord start at key 1 + // $sort_array_match_file_to_database start at key 1 + // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) foreach ($sort_array_match_file_to_database as $key => $val) { $fieldalias = preg_replace('/\..*$/i', '', $val); @@ -619,7 +623,7 @@ class ImportXlsx extends ModeleImports $this->thirpartyobject->get_codecompta('supplier'); $newval = $this->thirpartyobject->code_compta_fournisseur; if (empty($newval)) { - $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" + $arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null" } //print 'code_compta_fournisseur='.$newval; } @@ -636,9 +640,24 @@ class ImportXlsx extends ModeleImports if (!empty($classModForNumber) && !empty($pathModForNumber) && is_readable(DOL_DOCUMENT_ROOT.$pathModForNumber)) { require_once DOL_DOCUMENT_ROOT.$pathModForNumber; $modForNumber = new $classModForNumber; - $defaultref = $modForNumber->getNextValue(null, null); + + $tmpobject = null; + // Set the object with the date property when we can + if (!empty($objimport->array_import_convertvalue[0][$val]['classobject'])) { + $pathForObject = $objimport->array_import_convertvalue[0][$val]['pathobject']; + require_once DOL_DOCUMENT_ROOT.$pathForObject; + $tmpclassobject = $objimport->array_import_convertvalue[0][$val]['classobject']; + $tmpobject = new $tmpclassobject($this->db); + foreach ($arrayfield as $tmpkey => $tmpval) { // $arrayfield is array('c.ref'=>1, ...) + if (in_array($tmpkey, array('t.date', 'c.date_commande'))) { + $tmpobject->date = dol_stringtotime($arrayrecord[$arrayfield[$tmpkey]]['val'], 1); + } + } + } + + $defaultref = $modForNumber->getNextValue(null, $tmpobject); } - if (is_numeric($defaultref) && $defaultref <= 0) { + if (is_numeric($defaultref) && $defaultref <= 0) { // If error $defaultref = ''; } $newval = $defaultref; diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index b5c07d5221e..af3d033e670 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -296,18 +296,18 @@ class modCommande extends DolibarrModules $this->import_entities_array[$r] = array(); $this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'commande', 'extra' => MAIN_DB_PREFIX.'commande_extrafields'); $this->import_tables_creator_array[$r] = array('c' => 'fk_user_author'); // Fields to store import user id + $import_sample = array(); $this->import_fields_array[$r] = array( 'c.ref' => 'Ref*', 'c.ref_client' => 'RefCustomer', 'c.fk_soc' => 'ThirdPartyName*', 'c.fk_projet' => 'ProjectId', 'c.date_creation' => 'DateCreation', - 'c.date_valid' => 'DateValid', - 'c.date_commande' => 'DateOrder', + 'c.date_valid' => 'DateValidation', + 'c.date_commande' => 'OrderDate*', 'c.fk_user_modif' => 'ModifiedById', 'c.fk_user_valid' => 'ValidatedById', - 'c.fk_statut' => 'Status*', - 'c.remise_percent' => 'GlobalDiscount', + //'c.remise_percent' => 'GlobalDiscount', 'c.total_tva' => 'TotalTVA', 'c.total_ht' => 'TotalHT', 'c.total_ttc' => 'TotalTTC', @@ -317,7 +317,8 @@ class modCommande extends DolibarrModules 'c.date_livraison' => 'DeliveryDate', 'c.fk_cond_reglement' => 'Payment Condition', 'c.fk_mode_reglement' => 'Payment Mode', - 'c.model_pdf' => 'Model' + 'c.model_pdf' => 'Model', + 'c.fk_statut' => 'Status*' ); if (!empty($conf->multicurrency->enabled)) { @@ -327,29 +328,26 @@ class modCommande extends DolibarrModules $this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; $this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } - - // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commande' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - $import_extrafield_sample[$fieldname] = $fieldlabel; - } - } - // End add extra fields + $keyforselect = 'commande'; + $keyforelement = 'order'; + $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php'; $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande'); $this->import_regex_array[$r] = array( 'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency' ); - + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('c.ref' => 'Ref'); $this->import_convertvalue_array[$r] = array( + 'c.ref' => array( + 'rule'=>'getrefifauto', + 'class'=>(empty($conf->global->COMMANDE_ADDON) ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON), + 'path'=>"/core/modules/commande/".(empty($conf->global->COMMANDE_ADDON) ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON).'.php', + 'classobject'=>'Commande', + 'pathobject'=>'/commande/class/commande.class.php', + ), 'c.fk_soc' => array( 'rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', @@ -410,17 +408,11 @@ class modCommande extends DolibarrModules $this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } - // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commandedet' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); - } - } - // End add extra fields + $import_extrafield_sample = array(); + $keyforselect = 'commandedet'; + $keyforelement = 'orderline'; + $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php'; $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commandedet']; $this->import_regex_array[$r] = [ diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php index d44a261a16b..d56178697f5 100644 --- a/htdocs/core/modules/product_batch/mod_lot_advanced.php +++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php @@ -128,7 +128,7 @@ class mod_lot_advanced extends ModeleNumRefBatch /** * Return next free value * - * @param Societe $objsoc Object Societe + * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ diff --git a/htdocs/core/modules/product_batch/mod_lot_free.php b/htdocs/core/modules/product_batch/mod_lot_free.php index def14bd37b3..d6b24945ab0 100644 --- a/htdocs/core/modules/product_batch/mod_lot_free.php +++ b/htdocs/core/modules/product_batch/mod_lot_free.php @@ -93,11 +93,11 @@ class mod_lot_free extends ModeleNumRefBatch /** * Return an example of result returned by getNextValue * - * @param product $objproduct Object product - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for * @return string Return next value */ - public function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objsoc, $object) { global $langs; return ''; diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index 59de1965a6e..fc8d1389a00 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -111,11 +111,11 @@ class mod_lot_standard extends ModeleNumRefBatch /** * Return next free value * - * @param Product $objprod Object product + * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objprod, $object) + public function getNextValue($objsoc, $object) { global $db, $conf; diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php index abe094220d2..6ee931d51a9 100644 --- a/htdocs/core/modules/product_batch/mod_sn_advanced.php +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -128,11 +128,11 @@ class mod_sn_advanced extends ModeleNumRefBatch /** * Return next free value * - * @param Product $objprod Object product + * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objprod, $object) + public function getNextValue($objsoc, $object) { global $db, $conf; diff --git a/htdocs/core/modules/product_batch/mod_sn_free.php b/htdocs/core/modules/product_batch/mod_sn_free.php index 67d39ec085a..f6b2417d34b 100644 --- a/htdocs/core/modules/product_batch/mod_sn_free.php +++ b/htdocs/core/modules/product_batch/mod_sn_free.php @@ -92,11 +92,11 @@ class mod_sn_free extends ModeleNumRefBatch /** * Return an example of result returned by getNextValue * - * @param product $objproduct Object product - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for * @return string Return next value */ - public function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objsoc, $object) { global $langs; return ''; diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index 845044c39f3..d6c109cff81 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -111,7 +111,7 @@ class mod_sn_standard extends ModeleNumRefBatch /** * Return next free value * - * @param Societe $objsoc Object product + * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index bbfc0daee45..6570f2c864a 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -96,10 +96,10 @@ class mod_reception_beryl extends ModelNumRefReception * Return next value * * @param Societe $objsoc Third party object - * @param Object $shipment Shipment object + * @param Object $reception Reception object * @return string Value if OK, 0 if KO */ - public function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $reception) { global $db, $conf; diff --git a/htdocs/core/modules/reception/modules_reception.php b/htdocs/core/modules/reception/modules_reception.php index 145a04fbd31..f519974382b 100644 --- a/htdocs/core/modules/reception/modules_reception.php +++ b/htdocs/core/modules/reception/modules_reception.php @@ -110,10 +110,10 @@ abstract class ModelNumRefReception * Returns next value assigned * * @param Societe $objsoc Third party object - * @param Object $shipment Shipment object + * @param Object $reception Reception object * @return string Value */ - public function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $reception) { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index acb3ad8fa2a..546596ab640 100644 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -120,7 +120,7 @@ abstract class ModeleNumRefSuppliersInvoices * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ - public function getNextValue($objsoc, $object, $mode) + public function getNextValue($objsoc, $object, $mode = 'next') { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index 6fe3cb8883d..51c4e5f07d3 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -120,9 +120,11 @@ abstract class ModeleNumRefSuppliersOrders /** Returns next value assigned * - * @return string Valeur + * @param Societe $objsoc Object third party + * @param Object $object Object + * @return string Valeur */ - public function getNextValue() + public function getNextValue($objsoc = 0, $object = '') { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index b225899cef2..2e618b3ece3 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -120,9 +120,9 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal /** * Return next value * - * @param Societe $objsoc Object third party - * @param Propal $supplier_proposal Object commercial proposal - * @return string Next value + * @param Societe $objsoc Object third party + * @param SupplierProposal $supplier_proposal Object commercial proposal + * @return string Next value */ public function getNextValue($objsoc, $supplier_proposal) { diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php index e7db54062cb..57cba16c01b 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -120,9 +120,9 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal /** * Return next value * - * @param Societe $objsoc Object third party - * @param Propal $supplier_proposal Object supplier_proposal - * @return string Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param SupplierProposal $supplier_proposal Object commercial proposal + * @return string Value if OK, 0 if KO */ public function getNextValue($objsoc, $supplier_proposal) { diff --git a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php index 0b6f0b3725d..5a3d9e2280a 100644 --- a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php +++ b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php @@ -124,11 +124,11 @@ abstract class ModeleNumRefSupplierProposal /** * Renvoi prochaine valeur attribuee * - * @param Societe $objsoc Object third party - * @param Propal $propal Object commercial proposal - * @return string Valeur + * @param Societe $objsoc Object third party + * @param SupplierProposal $supplier_proposal Object commercial proposal + * @return string Valeur */ - public function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $supplier_proposal) { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index b3d26b39511..7e46c10a341 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -119,7 +119,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos * @param string $mode 'next' for next value or 'last' for last value * @return string Value if KO, <0 if KO */ - public function getNextValue($objsoc = 0, $invoice = null, $mode = 'next') + public function getNextValue($objsoc = null, $invoice = null, $mode = 'next') { global $db, $conf; diff --git a/htdocs/core/modules/takepos/modules_takepos.php b/htdocs/core/modules/takepos/modules_takepos.php index b9fae565647..24fa70b7f28 100644 --- a/htdocs/core/modules/takepos/modules_takepos.php +++ b/htdocs/core/modules/takepos/modules_takepos.php @@ -89,9 +89,12 @@ abstract class ModeleNumRefTakepos /** * Renvoi prochaine valeur attribuee * - * @return string Valeur + * @param Societe $objsoc Object thirdparty + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string Value if KO, <0 if KO */ - public function getNextValue() + public function getNextValue($objsoc = null, $invoice = null, $mode = 'next') { global $langs; return $langs->trans('NotAvailable'); diff --git a/htdocs/core/modules/ticket/modules_ticket.php b/htdocs/core/modules/ticket/modules_ticket.php index 1d2bc944022..c8561382436 100644 --- a/htdocs/core/modules/ticket/modules_ticket.php +++ b/htdocs/core/modules/ticket/modules_ticket.php @@ -115,11 +115,11 @@ abstract class ModeleNumRefTicket /** * Renvoi prochaine valeur attribuee * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string Valeur + * @param Societe $objsoc Object third party + * @param Ticket $ticket Object ticket + * @return string Valeur */ - public function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $ticket) { global $langs; return $langs->trans("NotAvailable"); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d6e59e4b2bd..288fd88eae6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -122,7 +122,7 @@ class MyObject extends CommonObject 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled'), 'validate'=>1), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>2000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled'), 'validate'=>1), ); /** diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 874d964ad6e..898dd2692e4 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -382,20 +382,29 @@ class modMyModule extends DolibarrModules $r = 1; /* BEGIN MODULEBUILDER IMPORT MYOBJECT */ /* - $langs->load("mymodule@mymodule"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@mymodule'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobject@mymodule'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ + $langs->load("mymodule@mymodule"); + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->import_icon[$r]='myobject@mymodule'; + $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'mymodule_myobject', 'extra' => MAIN_DB_PREFIX.'mymodule_myobject_extrafields'); + $this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id + $import_sample = array(); + $keyforclass = 'MyObject'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobject@mymodule'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinimport.inc.php'; + $import_extrafield_sample = array(); + $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php'; + $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'mymodule_myobject'); + $this->import_regex_array[$r] = array(); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); + $this->import_updatekeys_array[$r] = array('t.ref' => 'Ref'); + $this->import_convertvalue_array[$r] = array( + 't.ref' => array('rule'=>'getrefifauto', 'class'=>(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON), 'path'=>"/core/modules/commande/".(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON).'.php'), + 't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), + 't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'), + 't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'), + ); + $r++; */ /* END MODULEBUILDER IMPORT MYOBJECT */ } From af45691c9d23255e3ced8c66eaef280767b4da74 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Apr 2022 13:35:08 +0200 Subject: [PATCH 311/752] Clean import profiles --- htdocs/core/modules/modCommande.class.php | 19 ++++++++---------- htdocs/core/modules/modFacture.class.php | 4 ++-- htdocs/core/modules/modFournisseur.class.php | 9 ++------- htdocs/core/modules/modPropale.class.php | 20 +++++++------------ htdocs/langs/en_US/bills.lang | 1 - htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/propal.lang | 1 - .../core/modules/modMyModule.class.php | 8 +++++++- 8 files changed, 27 insertions(+), 36 deletions(-) diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index af3d033e670..9aac30fe8a5 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -196,10 +196,10 @@ class modCommande extends DolibarrModules 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country', 'co.code'=>"CountryCode", 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_commande'=>"OrderDate", - 'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.remise_percent'=>"GlobalDiscount", 'c.total_ht'=>"TotalHT", + 'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.total_ht'=>"TotalHT", 'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate', 'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', - 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', + 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', 'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC", 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel' ); @@ -220,7 +220,7 @@ class modCommande extends DolibarrModules //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", - // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", + // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.total_ht'=>"Numeric", // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text", // 'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric", // 'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text' @@ -228,7 +228,7 @@ class modCommande extends DolibarrModules $this->export_TypeFields_array[$r] = array( 's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.date_creation'=>"Date", - 'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", + 'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text', @@ -238,8 +238,8 @@ class modCommande extends DolibarrModules 's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company', 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"order", 'c.ref'=>"order", 'c.ref_client'=>"order", 'c.fk_soc'=>"order", 'c.date_creation'=>"order", 'c.date_commande'=>"order", 'c.amount_ht'=>"order", - 'c.remise_percent'=>"order", 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order", - 'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.label'=>"order_line", 'cd.description'=>"order_line", + 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order", + 'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.description'=>"order_line", 'cd.product_type'=>'order_line', 'cd.tva_tx'=>"order_line", 'cd.qty'=>"order_line", 'cd.total_ht'=>"order_line", 'cd.total_tva'=>"order_line", 'cd.total_ttc'=>"order_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product' ); @@ -307,7 +307,6 @@ class modCommande extends DolibarrModules 'c.date_commande' => 'OrderDate*', 'c.fk_user_modif' => 'ModifiedById', 'c.fk_user_valid' => 'ValidatedById', - //'c.remise_percent' => 'GlobalDiscount', 'c.total_tva' => 'TotalTVA', 'c.total_ht' => 'TotalHT', 'c.total_ttc' => 'TotalTTC', @@ -379,15 +378,13 @@ class modCommande extends DolibarrModules $this->import_entities_array[$r] = array(); $this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields'); $this->import_fields_array[$r] = array( - 'cd.fk_commande' => 'SalesOrder*', - 'cd.fk_parent_line' => 'PrParentLine', + 'cd.fk_commande' => 'CustomerOrder*', + 'cd.fk_parent_line' => 'ParentLine', 'cd.fk_product' => 'IdProduct', - 'cd.label' => 'Label', 'cd.description' => 'LineDescription', 'cd.tva_tx' => 'LineVATRate', 'cd.qty' => 'LineQty', 'cd.remise_percent' => 'Reduc. Percent', - 'cd.remise' => 'Reduc.', 'cd.price' => 'Price', 'cd.subprice' => 'Sub Price', 'cd.total_ht' => 'LineTotalHT', diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 72838e92079..b64ecca6cc1 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -276,7 +276,7 @@ class modFacture extends DolibarrModules 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text', 'none.rest'=>"NumericCompute", 'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text', - 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric", + 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date", 'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', $alias_product_perentity . '.accountancy_code_sell'=>'Text', @@ -289,7 +289,7 @@ class modFacture extends DolibarrModules $this->export_entities_array[$r] = array( 's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', - 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line", + 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line", 'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line', 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product', diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index befeb143ec9..e8ec02f0333 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -626,9 +626,8 @@ class modFournisseur extends DolibarrModules $this->import_tables_array[$r] = array('fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields'); $this->import_fields_array[$r] = array( 'fd.fk_facture_fourn' => 'InvoiceRef*', - 'fd.fk_parent_line' => 'FacParentLine', + 'fd.fk_parent_line' => 'ParentLine', 'fd.fk_product' => 'IdProduct', - 'fd.label' => 'Label', 'fd.description' => 'LineDescription', 'fd.pu_ht' => 'PriceUHT', 'fd.pu_ttc' => 'PriceUTTC', @@ -670,7 +669,6 @@ class modFournisseur extends DolibarrModules 'fd.fk_facture_fourn' => '(PROV001)', 'fd.fk_parent_line' => '', 'fd.fk_product' => '', - 'fd.label' => '', 'fd.description' => 'Test Product', 'fd.pu_ht' => '50000', 'fd.pu_ttc' => '50000', @@ -720,7 +718,6 @@ class modFournisseur extends DolibarrModules 'c.source' => 'Source', 'c.fk_statut' => 'Status*', 'c.billed' => 'Billed(0/1)', - 'c.remise_percent' => 'GlobalDiscount', 'c.total_tva' => 'TotalTVA', 'c.total_ht' => 'TotalHT', 'c.total_ttc' => 'TotalTTC', @@ -788,14 +785,12 @@ class modFournisseur extends DolibarrModules $this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields'); $this->import_fields_array[$r] = array( 'cd.fk_commande' => 'PurchaseOrder*', - 'cd.fk_parent_line' => 'PrParentLine', + 'cd.fk_parent_line' => 'ParentLine', 'cd.fk_product' => 'IdProduct', - 'cd.label' => 'Label', 'cd.description' => 'LineDescription', 'cd.tva_tx' => 'LineVATRate', 'cd.qty' => 'LineQty', 'cd.remise_percent' => 'Reduc. Percent', - 'cd.remise' => 'Reduc.', 'cd.subprice' => 'Sub Price', 'cd.total_ht' => 'LineTotalHT', 'cd.total_tva' => 'LineTotalVAT', diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 4f0633cd578..de6b026d899 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -190,10 +190,10 @@ class modPropale extends DolibarrModules $this->export_fields_array[$r] = array( 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", - 'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.remise_percent'=>"GlobalDiscount", + 'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.total_ht'=>"TotalHT", 'c.total_ttc'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate', 'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', - 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', + 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', 'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC", 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel' ); @@ -214,14 +214,14 @@ class modPropale extends DolibarrModules //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date", - // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text", + // 'c.fin_validite'=>"Date",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text", // 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", // 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text' //); $this->export_TypeFields_array[$r] = array( 's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.datec'=>"Date", 'c.datep'=>"Date", 'c.fin_validite'=>"Date", - 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', + 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text', 'c.entity'=>'List:entity:label:rowid', @@ -229,9 +229,9 @@ class modPropale extends DolibarrModules $this->export_entities_array[$r] = array( 's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"propal", 'c.ref'=>"propal", 'c.ref_client'=>"propal", - 'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.remise_percent'=>"propal", 'c.total_ht'=>"propal", + 'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.total_ht'=>"propal", 'c.total_ttc'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line', - 'cd.label'=>"propal_line", 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line", + 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line", 'cd.total_ht'=>"propal_line", 'cd.total_tva'=>"propal_line", 'cd.total_ttc'=>"propal_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product' ); $this->export_dependencies_array[$r] = array('propal_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -293,7 +293,6 @@ class modPropale extends DolibarrModules 'c.datec' => 'DateCreation', 'c.datep' => 'DatePropal', 'c.fin_validite' => 'DateEndPropal', - 'c.remise_percent' => 'GlobalDiscount', 'c.total_ht' => 'TotalHT', 'c.total_ttc' => 'TotalTTC', 'c.fk_statut' => 'Status*', @@ -330,7 +329,6 @@ class modPropale extends DolibarrModules 'c.datec' => '2020-01-01', 'c.datep' => '2020-01-01', 'c.fin_validite' => '2020-01-01', - 'c.remise_percent' => '', 'c.total_ht' => '0', 'c.total_ttc' => '0', 'c.fk_statut' => '1', @@ -367,15 +365,13 @@ class modPropale extends DolibarrModules ); $this->import_fields_array[$r] = array( 'cd.fk_propal' => 'Proposal*', - 'cd.fk_parent_line' => 'PrParentLine', + 'cd.fk_parent_line' => 'ParentLine', 'cd.fk_product' => 'IdProduct', - 'cd.label' => 'Label', 'cd.description' => 'LineDescription', 'cd.product_type' => 'TypeOfLineServiceOrProduct', 'cd.tva_tx' => 'LineVATRate', 'cd.qty' => 'LineQty', 'cd.remise_percent' => 'Reduc. Percent', - 'cd.remise' => 'Reduc.', 'cd.price' => 'Price', 'cd.subprice' => 'Sub Price', 'cd.total_ht' => 'LineTotalHT', @@ -411,13 +407,11 @@ class modPropale extends DolibarrModules 'cd.fk_propal' => 'PROV(0001)', 'cd.fk_parent_line' => '', 'cd.fk_product' => '', - 'cd.label' => '', 'cd.description' => 'Line description', 'cd.product_type' => '1', 'cd.tva_tx' => '0', 'cd.qty' => '2', 'cd.remise_percent' => '0', - 'cd.remise' => '0', 'cd.price' => '', 'cd.subprice' => '5000', 'cd.total_ht' => '10000', diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 68c08c9f234..eada0da8899 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -601,7 +601,6 @@ BILL_SUPPLIER_DELETEInDolibarr=Supplier invoice deleted UnitPriceXQtyLessDiscount=Unit price x Qty - Discount CustomersInvoicesArea=Customer billing area SupplierInvoicesArea=Supplier billing area -FacParentLine=Invoice Line Parent SituationTotalRayToRest=Remainder to pay without taxe PDFSituationTitle=Situation n° %d SituationTotalProgress=Total progress %d %% diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 62d167ea233..7e57db2091b 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -244,6 +244,7 @@ Designation=Description DescriptionOfLine=Description of line DateOfLine=Date of line DurationOfLine=Duration of line +ParentLine=Parent line ID Model=Doc template DefaultModel=Default doc template Action=Event diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index ed25b5501dc..aa5ef73f7dc 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -101,7 +101,6 @@ ConfirmMassValidationQuestion=Are you sure you want to validate the selected rec ConfirmMassSignatureQuestion=Are you sure you want to sign the selected records ? IdProposal=Proposal ID IdProduct=Product ID -PrParentLine=Proposal Parent Line LineBuyPriceHT=Buy Price Amount net of tax for line SignPropal=Accept proposal RefusePropal=Refuse proposal diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 898dd2692e4..b1caea730f9 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -399,7 +399,13 @@ class modMyModule extends DolibarrModules $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('t.ref' => 'Ref'); $this->import_convertvalue_array[$r] = array( - 't.ref' => array('rule'=>'getrefifauto', 'class'=>(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON), 'path'=>"/core/modules/commande/".(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON).'.php'), + 't.ref' => array( + 'rule'=>'getrefifauto', + 'class'=>(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON), + 'path'=>"/core/modules/commande/".(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON).'.php' + 'classobject'=>'MyObject', + 'pathobject'=>'/mymodule/class/myobject.class.php', + ), 't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), 't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'), 't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'), From ea61e517308a8f54ab974c0643a2b58023ecb55d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Apr 2022 13:59:50 +0200 Subject: [PATCH 312/752] Fix phpunit --- htdocs/core/extrafieldsinexport.inc.php | 2 +- htdocs/core/extrafieldsinimport.inc.php | 2 +- test/phpunit/CodingPhpTest.php | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php index 4962e353741..b31b02c3460 100644 --- a/htdocs/core/extrafieldsinexport.inc.php +++ b/htdocs/core/extrafieldsinexport.inc.php @@ -12,7 +12,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) { // Add extra fields $sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields"; -$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC'; +$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".((int) $conf->entity).') ORDER BY pos ASC'; //print $sql; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) diff --git a/htdocs/core/extrafieldsinimport.inc.php b/htdocs/core/extrafieldsinimport.inc.php index bbfcd7b9fdb..4845d9a6d44 100644 --- a/htdocs/core/extrafieldsinimport.inc.php +++ b/htdocs/core/extrafieldsinimport.inc.php @@ -12,7 +12,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) { // Add extra fields $sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields"; -$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC'; +$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".((int) $conf->entity).') ORDER BY pos ASC'; //print $sql; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on old database (during migration for example) diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 4ddab0b97c3..5637f0194ac 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -227,6 +227,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase if (! in_array($file['name'], array( 'objectline_view.tpl.php', 'extrafieldsinexport.inc.php', + 'extrafieldsinimport.inc.php', 'DolQueryCollector.php' ))) { // Must not found $this->db-> From 2455d8fe5202fd040f9a522d6056dc3fab95a0f7 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 4 Apr 2022 14:31:48 +0200 Subject: [PATCH 313/752] avoid fetch_objectlinked for each page of the document --- htdocs/core/class/commonobject.class.php | 8 ++++++++ htdocs/core/lib/pdf.lib.php | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 232aa6b5789..f7eb6a67263 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -123,6 +123,11 @@ abstract class CommonObject */ public $linkedObjects; + /** + * @var boolean is linkedObjects full loaded. Loaded by ->fetchObjectLinked + */ + public $linkedObjectsFullLoaded = false; + /** * @var Object To store a cloned copy of object before to edit it and keep track of old properties */ @@ -3834,6 +3839,9 @@ abstract class CommonObject } else { $sql .= "(fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."')"; $sql .= " ".$clause." (fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."')"; + if ($sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { + $this->linkedObjectsFullLoaded = true; + } } $sql .= " ORDER BY ".$orderby; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ea8c6c2ce23..b273f93b69f 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2282,7 +2282,9 @@ function pdf_getLinkedObjects(&$object, $outputlangs) $linkedobjects = array(); - $object->fetchObjectLinked(); + if (empty($object->linkedObjectsFullLoaded)) { + $object->fetchObjectLinked(); + } foreach ($object->linkedObjects as $objecttype => $objects) { if ($objecttype == 'facture') { From 01d100fc0cbaa6fca255dbd3324d98b50fb7ad8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Apr 2022 15:11:29 +0200 Subject: [PATCH 314/752] Missing autofocus on title field --- htdocs/compta/facture/card-rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6116db707e2..6d7f7f6010e 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -967,7 +967,7 @@ if ($action == 'create') { // Title print ''.$langs->trans("Title").''; - print ''; + print ''; print ''; // Third party From 71012a7933bfd44570377563546c4135fa6451e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Mar 2022 13:21:32 +0100 Subject: [PATCH 315/752] FIX #19777 #20281 --- htdocs/compta/paiement/cheque/card.php | 50 ++++++++++++------- .../cheque/class/remisecheque.class.php | 1 + htdocs/core/class/html.formfile.class.php | 6 +-- .../modules/cheque/modules_chequereceipts.php | 3 +- htdocs/ecm/class/ecmfiles.class.php | 6 ++- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 32f81532ecf..2fcd4d780ff 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -41,12 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -// Security check -$fieldname = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname); +$object = new RemiseCheque($db); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -63,11 +58,22 @@ if (empty($page) || $page == -1) { $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -$dir = $conf->bank->dir_output.'/checkdeposits/'; +$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits"; + $filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear')); $filteraccountid = GETPOST('accountid', 'int'); -$object = new RemiseCheque($db); +// Security check +$fieldname = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname); + +$usercanread = $user->rights->banque->cheque; +$usercancreate = $user->rights->banque->cheque; +$usercandelete = $user->rights->banque->cheque; + /* @@ -242,7 +248,9 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) { $langs->load("other"); - $file = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque').GETPOST('file'); + $filetodelete = GETPOST('file', 'alpha'); + $file = $upload_dir.'/'.$filetodelete; + $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); @@ -633,6 +641,12 @@ if ($action == 'new') { $i = 1; if ($num > 0) { while ($objp = $db->fetch_object($resql)) { + $paymentstatic->id = $objp->pid; + $paymentstatic->ref = $objp->pref; + + $accountlinestatic->id = $objp->rowid; + $accountlinestatic->ref = $objp->ref; + print ''; print ''.$i.''; print ''.dol_print_date($db->jdate($objp->date), 'day').''; // Operation date @@ -642,8 +656,6 @@ if ($action == 'new') { print ''.price($objp->amount).''; // Link to payment print ''; - $paymentstatic->id = $objp->pid; - $paymentstatic->ref = $objp->pref; if ($paymentstatic->id) { print $paymentstatic->getNomUrl(1); } else { @@ -652,8 +664,6 @@ if ($action == 'new') { print ''; // Link to bank transaction print ''; - $accountlinestatic->id = $objp->rowid; - $accountlinestatic->ref = $objp->ref; if ($accountlinestatic->id > 0) { print $accountlinestatic->getNomUrl(1); } else { @@ -663,10 +673,10 @@ if ($action == 'new') { // Action button print ''; if ($object->statut == 0) { - print 'rowid.'">'.img_delete().''; + print 'rowid.'">'.img_delete().''; } if ($object->statut == 1 && $objp->statut != 2) { - print 'rowid.'">'.img_picto($langs->trans("RejectCheck"), 'disable').''; + print 'rowid.'">'.img_picto($langs->trans("RejectCheck"), 'disable').''; } if ($objp->statut == 2) { print '   '.img_picto($langs->trans('CheckRejected'), 'statut8').''; @@ -722,11 +732,13 @@ print '
'; if ($action != 'new') { if ($object->statut == 1) { - $filename = dol_sanitizeFileName($object->ref); - $filedir = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'checkdeposits'); + // Documents + $objref = dol_sanitizeFileName($object->ref); + $filedir = $upload_dir.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - - print $formfile->showdocuments('remisecheque', $filename, $filedir, $urlsource, 1, 1); + $genallowed = $usercancreate; + $delallowed = $usercandelete; + print $formfile->showdocuments('remisecheque', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); print '
'; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 683b2fd0423..559697bf495 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -615,6 +615,7 @@ class RemiseCheque extends CommonObject // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charseSupprimert_output = $outputlangs->charset_output; + $result = $docmodel->write_file($this, $conf->bank->dir_output.'/checkdeposits', $this->ref, $outputlangs); if ($result > 0) { //$outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index fcca60dad78..349b05416aa 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -359,9 +359,9 @@ class FormFile * Return a string to show the box with list of available documents for object. * This also set the property $this->numoffiles * - * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:myobject', 'mymodule_temp', ...) - * @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. - * @param string $filedir Directory to scan + * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:MyObject', 'mymodule_temp', ...) + * @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into a subdir of module. + * @param string $filedir Directory to scan (must not end with a /). Example: '/mydolibarrdocuments/facture/FAYYMM-1234' * @param string $urlsource Url of origin page (for return) * @param int|string[] $genallowed Generation is allowed (1/0 or array list of templates) * @param int $delallowed Remove is allowed (1/0) diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index dfdf0fbe363..e50a6877848 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -126,8 +126,7 @@ abstract class ModeleNumRefChequeReceipts } /** - * \class ModeleChequeReceipts - * \brief Classe mere des modeles de + * Class parent for templates of document generation */ abstract class ModeleChequeReceipts extends CommonDocGenerator { diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 035a7aee9c6..a451a462ea3 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -327,7 +327,11 @@ class EcmFiles extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->errors[] = 'Error DB_ERROR_RECORD_ALREADY_EXISTS : '.$this->db->lasterror(); + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + } dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } From 04140d8dc05b4186d302f16a86e91a2ba045bcf9 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 4 Apr 2022 15:45:16 +0200 Subject: [PATCH 316/752] add class name on tds expensereport rule card --- htdocs/admin/expensereport_rules.php | 68 ++++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 6799ab339bd..f15b996939d 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -185,31 +185,31 @@ if ($action != 'edit') { echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo ''; echo ''; echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo '
' . $langs->trans('ExpenseReportApplyTo') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . '
' . $langs->trans('ExpenseReportApplyTo') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . ' 
'; - echo '
' . $form->selectarray('apply_to', $tab_apply, '', 0) . '
'; - echo '
' . $form->select_dolusers('', 'fk_user') . '
'; - echo '
' . $form->select_dolgroups('', 'fk_usergroup') . '
'; + echo '
' . $form->selectarray('apply_to', $tab_apply, '', 0) . '
'; + echo '
' . $form->select_dolusers('', 'fk_user') . '
'; + echo '
' . $form->select_dolgroups('', 'fk_usergroup') . '
'; echo '
' . $form->selectExpense('', 'fk_c_type_fees', 0, 1, 1) . '' . $form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0) . '' . $form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0) . '' . $form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0) . ' ' . $conf->currency . '' . $form->selectyesno('restrictive', 0, 1) . '' . $form->selectExpense('', 'fk_c_type_fees', 0, 1, 1) . '' . $form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0) . '' . $form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0) . ' ' . $conf->currency . '' . $form->selectyesno('restrictive', 0, 1) . '
'; @@ -227,21 +227,21 @@ if ($action == 'edit') { echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo ''; foreach ($rules as $rule) { - echo ''; + echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ' - + '; foreach ($rules as $rule) { - echo ''; + echo ''; echo ''; print ''; print ''; } From 1fec350ccc42daf13415ed366bc191f9d8626381 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 4 Apr 2022 22:51:30 +0200 Subject: [PATCH 321/752] fix: Bad dirthday displayed date (d-1) in the Bithday Widget --- htdocs/core/boxes/box_birthdays.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 62cfaa590ab..be0abcdfdde 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -119,7 +119,7 @@ class box_birthdays extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateb, "day", 'gmt').' - '.$age.' '.$langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( From 3ab993127d516fce71df43815cf6f65b43d5e843 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 02:17:01 +0200 Subject: [PATCH 322/752] NEW Accept 'auto' for ref of object on import of purchase order/proposal --- htdocs/core/modules/modFournisseur.class.php | 15 ++++++++++++++- htdocs/core/modules/modPropale.class.php | 17 ++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index e8ec02f0333..708cd1fb408 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -612,7 +612,13 @@ class modFournisseur extends DolibarrModules $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('f.ref' => 'Ref'); $this->import_convertvalue_array[$r] = array( - //'c.ref'=>array('rule'=>'getrefifauto'), + 'f.ref' => array( + 'rule'=>'getrefifauto', + 'class'=>(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER), + 'path'=>"/core/modules/supplier_invoice/".(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).'.php', + 'classobject'=>'FactureFournisseur', + 'pathobject'=>'/fourn/class/fournisseur.facture.class.php', + ), 'f.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'), 'f.fk_account' => array('rule' => 'fetchidfromref', 'file' => '/compta/bank/class/account.class.php', 'class' => 'Account', 'method' => 'fetch', 'element' => 'bank_account'), ); @@ -759,6 +765,13 @@ class modFournisseur extends DolibarrModules $this->import_updatekeys_array[$r] = array('c.ref' => 'Ref'); $this->import_convertvalue_array[$r] = array( + 'c.ref' => array( + 'rule'=>'getrefifauto', + 'class'=>(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER), + 'path'=>"/core/modules/supplier_order/".(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).'.php', + 'classobject'=>'CommandeFournisseur', + 'pathobject'=>'/fourn/class/fournisseur.commande.class.php', + ), 'c.fk_soc' => array( 'rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index de6b026d899..3419d4c866e 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -342,16 +342,23 @@ class modPropale extends DolibarrModules 'c.multicurrency_total_ttc' => '0' ]; $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); - $this->import_updatekeys_array[$r] = ['c.ref'=>'Ref']; - $this->import_convertvalue_array[$r] = [ - 'c.fk_soc' => [ + $this->import_updatekeys_array[$r] = array('c.ref'=>'Ref'); + $this->import_convertvalue_array[$r] = array( + 'c.ref' => array( + 'rule'=>'getrefifauto', + 'class'=>(empty($conf->global->PROPALE_ADDON) ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON), + 'path'=>"/core/modules/propale/".(empty($conf->global->PROPALE_ADDON) ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON).'.php', + 'classobject'=>'Propal', + 'pathobject'=>'/comm/propal/class/propal.class.php', + ), + 'c.fk_soc' => array( 'rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty' - ] - ]; + ) + ); //Import Proposal Lines $r++; From b929c2f671908619ec69a4900eb6a196e023fc3e Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 5 Apr 2022 11:46:06 +0200 Subject: [PATCH 323/752] FIX 16.0 - supplier invoice card creates two invoices instead of one when creating from a template --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index f4d628d5882..95bd9cbd136 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -929,7 +929,7 @@ if (empty($reshook)) { } // Standard invoice or Deposit invoice, not from a Predefined template invoice - if (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT && GETPOST('fac_rec') <= 0) { + elseif (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT && GETPOST('fac_rec') <= 0) { if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); $action = 'create'; From b199234afe1d9c7371a6ce35c789a95b0fee1893 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 5 Apr 2022 12:01:09 +0200 Subject: [PATCH 324/752] FIX : each time we create a supplier order, we need to give it a ref_supplier --- htdocs/fourn/commande/list.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index de195504d39..56ebfb5cbf7 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -292,10 +292,8 @@ if (empty($reshook)) { $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) { - $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier; - $default_ref_supplier+=1; - } + $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier; + $default_ref_supplier+=1; $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($datefacture)) { From 392ba6deedb42a31f7388bff636feecb1411058e Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 5 Apr 2022 12:16:06 +0200 Subject: [PATCH 325/752] FIX 16.0 - my previous fix was incomplete (missing parentheses around OR-separated conditions) + replace GETPOST('fac_rec', 'int') with variable + make sure it works even if, one day, the "nothing selected" value for the template supplier invoice selector changes to -1 instead of '' --- htdocs/fourn/facture/card.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 95bd9cbd136..02e77d13f58 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -76,7 +76,7 @@ $lineid = GETPOST('lineid', 'int'); $projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); -$fac_rec = GETPOST('fac_rec', 'int'); +$fac_recid = GETPOST('fac_rec', 'int'); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -885,7 +885,7 @@ if (empty($reshook)) { } // Standard invoice or Deposit invoice, created from a Predefined template invoice - if ((GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) { + elseif ($fac_recid > 0 && (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT)) { if (empty($dateinvoice)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); @@ -918,7 +918,7 @@ if (empty($reshook)) { $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Source facture - $object->fac_rec = GETPOST('fac_rec', 'int'); + $object->fac_rec = $fac_recid; $fac_rec = new FactureFournisseurRec($db); $fac_rec->fetch($object->fac_rec); $fac_rec->fetch_lines(); @@ -929,7 +929,7 @@ if (empty($reshook)) { } // Standard invoice or Deposit invoice, not from a Predefined template invoice - elseif (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT && GETPOST('fac_rec') <= 0) { + elseif ($fac_recid <= 0 && (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT)) { if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); $action = 'create'; @@ -2024,15 +2024,15 @@ if ($action == 'create') { $exampletemplateinvoice = new FactureFournisseurRec($db); $invoice_predefined = new FactureFournisseurRec($db); - if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { - $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); + if (empty($origin) && empty($originid) && $fac_recid > 0) { + $invoice_predefined->fetch($fac_recid); } // Third party print ''; print ''; // Overwrite some values if creation of invoice is from a predefined invoice - if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { - $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); + if (empty($origin) && empty($originid) && $fac_recid > 0) { + $invoice_predefined->fetch($fac_recid); $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later if (empty($projectid)) { @@ -2088,15 +2088,15 @@ if ($action == 'create') { if ($num > 0) { print ''; } @@ -2432,7 +2432,7 @@ if ($action == 'create') { // Help of substitution key $htmltext = ''; - if (GETPOST('fac_rec', 'int') > 0) { + if ($fac_recid > 0) { $dateexample = $newdateinvoice ? $newdateinvoice : $dateinvoice; if (empty($dateexample)) { $dateexample = dol_now(); From b872fb2eac3ad2392ac0699a402add7aa69481d6 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 5 Apr 2022 12:28:40 +0200 Subject: [PATCH 326/752] FIX 16.0 - missing quotes in SQL for frequency unit update for template supplier invoices --- htdocs/fourn/class/fournisseur.facture-rec.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index f77dd5638f7..5d109d7ad2c 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -1769,7 +1769,7 @@ class FactureFournisseurRec extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); if (!empty($unit)) { - $sql .= ', unit_frequency = '.$this->db->escape($unit); + $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; } $sql .= ' WHERE rowid = ' . (int) $this->id; From f0433244aa1a8809ceb0f2ca11d20cdb5fd4bfd2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 13:36:25 +0200 Subject: [PATCH 327/752] Fix sql --- .../facture/class/facture-rec.class.php | 10 +- .../class/fournisseur.facture-rec.class.php | 131 +++++++++--------- 2 files changed, 67 insertions(+), 74 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 2bfb250df83..290467a9d54 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -2130,7 +2130,7 @@ class FactureLigneRec extends CommonInvoiceLine include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; - $sql .= " fk_facture = ".$this->fk_facture; + $sql .= " fk_facture = ".((int) $this->fk_facture); $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", description='".$this->db->escape($this->desc)."'"; $sql .= ", price=".price2num($this->price); @@ -2142,10 +2142,10 @@ class FactureLigneRec extends CommonInvoiceLine $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); - $sql .= ", product_type=".$this->product_type; - $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; - $sql .= ", subprice='".price2num($this->subprice)."'"; - $sql .= ", info_bits='".price2num($this->info_bits)."'"; + $sql .= ", product_type=".((int) $this->product_type); + $sql .= ", remise_percent=".price2num($this->remise_percent); + $sql .= ", subprice=".price2num($this->subprice); + $sql .= ", info_bits=".price2num($this->info_bits); $sql .= ", date_start_fill=".(int) $this->date_start_fill; $sql .= ", date_end_fill=".(int) $this->date_end_fill; if (empty($this->skip_update_total)) { diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index f77dd5638f7..ea725f7b1e9 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -299,40 +299,34 @@ class FactureFournisseurRec extends CommonInvoice $sql .= ') VALUES ('; $sql .= "'".$this->db->escape($this->titre)."'"; $sql .= ", '".$this->db->escape($this->ref_supplier)."'"; - $sql .= ', ' . (int) $conf->entity; - $sql .= ', ' . (int) $facfourn_src->socid; + $sql .= ", ".((int) $conf->entity); + $sql .= ", ".((int) $facfourn_src->socid); $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ', ' . (int) $this->suspended; - if (!empty(GETPOST('libelle'))) { - $sql .= ", '" . $this->db->escape(GETPOST('libelle')) . "'"; - } elseif (! empty($this->libelle)) { - $sql .= ", '" . $this->db->escape($this->libelle) . "'"; - } else { - $sql .= ", ''"; - } - $sql .= ', ' .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount - $sql .= ', ' .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0'); - $sql .= ', ' . (int) $user->id; - $sql .= ', ' .(!empty($this->fk_project) ? $this->fk_project : 'NULL'); // Fields declarded on creation - $sql .= ', ' .(!empty($facfourn_src->fk_account) ? $facfourn_src->fk_account : 'NULL'); - $sql .= ', ' .($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL'); - $sql .= ', ' .($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL'); - $sql .= ", '".($facfourn_src->date_echeance > 0 ? $this->db->idate($facfourn_src->date_echeance) : 'NULL')."'"; // date_lim_reglement - $sql .= ', ' .(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL'); // Fields declarded on creation - $sql .= ', ' .(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL'); // Fields declarded on creation - $sql .= ', ' .(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL'); // Fields declarded on creation - $sql .= ', ' . (int) $facfourn_src->fk_multicurrency; + $sql .= ", ".((int) $this->suspended); + $sql .= ", '".$this->db->escape($this->libelle)."'"; + $sql .= ", " .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount + $sql .= ", " .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0'); + $sql .= ", " .((int) $user->id); + $sql .= ", " .(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL'); + $sql .= ", " .(!empty($facfourn_src->fk_account) ? ((int) $facfourn_src->fk_account) : 'NULL'); + $sql .= ", " .($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL'); + $sql .= ", " .($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL'); + $sql .= ", ".($facfourn_src->date_echeance > 0 ? "'".$this->db->idate($facfourn_src->date_echeance)."'" : 'NULL'); // date_lim_reglement + $sql .= ", " .(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL'); + $sql .= ", " .(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL'); + $sql .= ", " .(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL'); + $sql .= ", " . (int) $facfourn_src->fk_multicurrency; $sql .= ", '".$this->db->escape($facfourn_src->multicurrency_code)."'"; - $sql .= ', ' . (float) $facfourn_src->multicurrency_tx; - $sql .= ', ' . (int) $this->usenewprice; // Fields declarded on creation - $sql .= ', ' . (int) $this->frequency; // Fields declarded on creation - $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; // Fields declarded on creation - $sql .= ', ' .(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL'); // Fields declarded on creation - $sql .= ', ' .(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL'); // Fields declarded on creation - $sql .= ', ' . (int) $this->nb_gen_done; // Fields declarded on creation - $sql .= ', ' . (int) $this->nb_gen_max; // Fields declarded on creation - $sql .= ', ' . (int) $this->auto_validate; // Fields declarded on creation - $sql .= ', ' . (int) $this->generate_pdf; // Fields declarded on creation + $sql .= ", " . (float) $facfourn_src->multicurrency_tx; + $sql .= ", " . (int) $this->usenewprice; + $sql .= ", " . (int) $this->frequency; + $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; + $sql .= ", " .(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL'); + $sql .= ", " .(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL'); + $sql .= ", " . (int) $this->nb_gen_done; + $sql .= ", " . (int) $this->nb_gen_max; + $sql .= ", " . (int) $this->auto_validate; + $sql .= ", " . (int) $this->generate_pdf; $sql .= ')'; if ($this->db->query($sql)) { @@ -475,44 +469,43 @@ class FactureFournisseurRec extends CommonInvoice $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_rec SET"; - $sql .= ' titre = "' . (!empty($this->titre) ? $this->titre .'",' : '"",') ; - $sql .= ' ref_supplier = "'. (!empty($this->ref_supplier) ? $this->ref_supplier .'",' : '" ",'); - $sql .= " entity = ". (!empty($this->entity) ? $this->entity : 1) . ','; + $sql .= " titre = '" . (!empty($this->titre) ? $this->db->escape($this->titre) : "")."'," ; + $sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',"; + $sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ','; if ($this->fk_soc > 0) $sql .= " fk_soc = ". (int) $this->fk_soc. ','; - $sql .= ' tms = "'. date('Y-m-d H:i:s', dol_now()) . '",'; - $sql .= " suspended = ". (!empty($this->suspended) ? $this->suspended : 0) . ','; - $sql .= ' libelle = "'. (!empty($this->libelle) ? $this->libelle : 'NULL') . '",'; - $sql .= " amount = ". (!empty($this->amount) ? $this->amount : 0.00) . ','; - $sql .= " remise = ". (!empty($this->remise) ? $this->remise : 'NULL') . ','; - $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? $this->vat_src_code : 'NULL') . ','; - $sql .= " localtax1 = ". (!empty($this->localtax1) ? $this->localtax1 : 0.00) . ','; - $sql .= " localtax2 = ". (!empty($this->localtax2) ? $this->localtax2 : 0.00) . ','; - $sql .= " total_ht = ". (!empty($this->total_ht) ? $this->total_ht : 0.00) . ','; - $sql .= " total_tva = ". (!empty($this->total_tva) ? $this->total_tva : 0.00) . ','; - $sql .= " total_ttc = ". (!empty($this->total_ttc) ? $this->total_ttc : 0.00) . ','; - $sql .= " fk_user_modif = ". $user->id . ','; - $sql .= " fk_projet = ". (!empty($this->fk_project) ? $this->fk_project : 'NULL') . ','; - $sql .= " fk_account = ". (!empty($this->fk_account) ? $this->fk_account : 'NULL') . ','; - $sql .= " fk_mode_reglement = ". (!empty($this->mode_reglement_id) ? $this->mode_reglement_id : 'NULL') . ','; - $sql .= " fk_cond_reglement = ". (!empty($this->cond_reglement_id) ? $this->cond_reglement_id : 'NULL') . ','; - $sql .= " date_lim_reglement = ". (!empty($this->date_lim_reglement) ? '"'.date("Y-m-d H:i:s", $this->date_lim_reglement).'"' : 'NULL') . ','; - $sql .= ' note_private = "'. (!empty($this->note_private) ? $this->note_private : '') . '",'; - $sql .= ' note_public = "'. (!empty($this->note_public) ? $this->note_public : '') . '",'; - $sql .= ' modelpdf = "'. (!empty($this->model_pdf) ? $this->model_pdf : 'NULL') . '",'; - $sql .= " fk_multicurrency = ". (!empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL') . ','; - $sql .= ' multicurrency_code = "'. (!empty($this->multicurrency_code) ? $this->multicurrency_code : 'NULL') . '",'; - $sql .= " multicurrency_tx = ". (!empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1) . ','; - $sql .= " multicurrency_total_ht = ". (!empty($this->multicurrency_total_ht) ? $this->multicurrency_total_ht : 0.00) . ','; - $sql .= " multicurrency_total_tva = ". (!empty($this->multicurrency_total_tva) ? $this->multicurrency_total_tva : 0.00) . ','; - $sql .= " multicurrency_total_ttc = ". (!empty($this->multicurrency_total_ttc) ? $this->multicurrency_total_ttc : 0.00) . ','; - $sql .= " usenewprice = ". (!empty($this->usenewprice) ? $this->usenewprice : 0) . ','; - $sql .= " frequency = ". (!empty($this->frequency) ? $this->frequency : 0). ','; - $sql .= ' unit_frequency = "'. (!empty($this->unit_frequency) ? $this->unit_frequency : 0). '",'; - $sql .= " date_when = ". (!empty($this->date_when) ? '"'.date("Y-m-d H:i:s", $this->date_when).'"' : 0) . ','; - $sql .= " date_last_gen = ". (!empty($this->date_last_gen) ? '"'.date("Y-m-d H:i:s", $this->date_last_gen).'"' : 0) . ','; - $sql .= " nb_gen_done = ". (!empty($this->nb_gen_done) ? $this->nb_gen_done : 0) . ','; - $sql .= " nb_gen_max = ". (!empty($this->nb_gen_max) ? $this->nb_gen_max : 0) . ','; - $sql .= " auto_validate = ". (!empty($this->auto_validate) ? $this->auto_validate : 0); + $sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ','; + $sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ","; + $sql .= " amount = ". (!empty($this->amount) ? ((float) $this->amount) : 0.00) . ','; + $sql .= " remise = ". (!empty($this->remise) ? ((float) $this->remise) : 'NULL') . ','; + $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->vat_src_code."'" : 'NULL') . ','; + $sql .= " localtax1 = ". (!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00) . ','; + $sql .= " localtax2 = ". (!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00) . ','; + $sql .= " total_ht = ". (!empty($this->total_ht) ? ((float) $this->total_ht) : 0.00) . ','; + $sql .= " total_tva = ". (!empty($this->total_tva) ? ((float) $this->total_tva) : 0.00) . ','; + $sql .= " total_ttc = ". (!empty($this->total_ttc) ? ((float) $this->total_ttc) : 0.00) . ','; + $sql .= " fk_user_modif = ". ((int) $user->id) . ','; + $sql .= " fk_projet = ". (!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL') . ','; + $sql .= " fk_account = ". (!empty($this->fk_account) ? ((int) $this->fk_account) : 'NULL') . ','; + $sql .= " fk_mode_reglement = ". (!empty($this->mode_reglement_id) ? ((int) $this->mode_reglement_id) : 'NULL') . ','; + $sql .= " fk_cond_reglement = ". (!empty($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : 'NULL') . ','; + $sql .= " date_lim_reglement = ". (!empty($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL') . ','; + $sql .= " note_private = '". (!empty($this->note_private) ? $this->db->escape($this->note_private) : '') . "',"; + $sql .= " note_public = '". (!empty($this->note_public) ? $this->db->escape($this->note_public) : '') . "',"; + $sql .= " modelpdf = ". (!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL') . ","; + $sql .= " fk_multicurrency = ". (!empty($this->fk_multicurrency) ? ((int) $this->fk_multicurrency) : 'NULL') . ','; + $sql .= " multicurrency_code = ". (!empty($this->multicurrency_code) ? "'".$this->db->escape($this->multicurrency_code)."'" : 'NULL') . ","; + $sql .= " multicurrency_tx = ". (!empty($this->multicurrency_tx) ? ((float) $this->multicurrency_tx) : 1) . ','; + $sql .= " multicurrency_total_ht = ". (!empty($this->multicurrency_total_ht) ? ((float) $this->multicurrency_total_ht) : 0.00) . ','; + $sql .= " multicurrency_total_tva = ". (!empty($this->multicurrency_total_tva) ? ((float) $this->multicurrency_total_tva) : 0.00) . ','; + $sql .= " multicurrency_total_ttc = ". (!empty($this->multicurrency_total_ttc) ? ((float) $this->multicurrency_total_ttc) : 0.00) . ','; + $sql .= " usenewprice = ". (!empty($this->usenewprice) ? ((int) $this->usenewprice) : 0) . ','; + $sql .= " frequency = ". (!empty($this->frequency) ? ((int) $this->frequency) : 0). ','; + $sql .= " unit_frequency = '". (!empty($this->unit_frequency) ? $this->db->escape($this->unit_frequency) : ''). "',"; + $sql .= " date_when = ". (!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL') . ','; + $sql .= " date_last_gen = ". (!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL') . ','; + $sql .= " nb_gen_done = ". (!empty($this->nb_gen_done) ? ((int) $this->nb_gen_done) : 0) . ','; + $sql .= " nb_gen_max = ". (!empty($this->nb_gen_max) ? ((int) $this->nb_gen_max) : 0) . ','; + $sql .= " auto_validate = ". (!empty($this->auto_validate) ? ((int) $this->auto_validate) : 0); $sql .= " WHERE rowid = ". (int) $this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); From 7c591d95d94b064ff2eac0cc31742d57dc087dbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 13:48:39 +0200 Subject: [PATCH 328/752] Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop --- .../class/fournisseur.facture-rec.class.php | 101 +++++++++--------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index b55246ad30e..abbf0db90fe 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -1759,14 +1759,15 @@ class FactureFournisseurRec extends CommonInvoice return -2; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET frequency = ".($frequency ? ((int) $this->db->escape($frequency)) : "NULL"); if (!empty($unit)) { - $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; + $sql .= ", unit_frequency = '".$this->db->escape($unit)."'"; } - $sql .= ' WHERE rowid = ' . (int) $this->id; + $sql .= " WHERE rowid = ".((int) $this->id); + + dol_syslog(get_class($this).'::setFrequencyAndUnit', LOG_DEBUG); - dol_syslog(get_class($this). '::setFrequencyAndUnit', LOG_DEBUG); if ($this->db->query($sql)) { $this->frequency = $frequency; if (!empty($unit)) { @@ -1774,7 +1775,7 @@ class FactureFournisseurRec extends CommonInvoice } return 1; } else { - dol_print_error($this->db); + $this->error = $this->db->lasterror(); return -1; } } @@ -1789,17 +1790,18 @@ class FactureFournisseurRec extends CommonInvoice public function setNextDate($date, $increment_nb_gen_done = 0) { if (!$this->table_element) { - dol_syslog(get_class($this). '::setNextDate was called on objet with property table_element not defined', LOG_ERR); + dol_syslog(get_class($this).'::setNextDate was called on objet with property table_element not defined', LOG_ERR); return -1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET date_when = ' .($date ? "'".$this->db->idate($date)."'" : 'null'); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET date_when = " .($date ? "'".$this->db->idate($date)."'" : "NULL"); if ($increment_nb_gen_done > 0) { - $sql .= ', nb_gen_done = nb_gen_done + 1'; + $sql .= ", nb_gen_done = nb_gen_done + 1"; } - $sql .= ' WHERE rowid = ' . (int) $this->id; + $sql .= " WHERE rowid = " . (int) $this->id; + + dol_syslog(get_class($this).'::setNextDate', LOG_DEBUG); - dol_syslog(get_class($this). '::setNextDate', LOG_DEBUG); if ($this->db->query($sql)) { $this->date_when = $date; if ($increment_nb_gen_done > 0) { @@ -1807,7 +1809,7 @@ class FactureFournisseurRec extends CommonInvoice } return 1; } else { - dol_print_error($this->db); + $this->error = $this->db->lasterror(); return -1; } } @@ -1821,7 +1823,7 @@ class FactureFournisseurRec extends CommonInvoice public function setMaxPeriod($nb) { if (!$this->table_element) { - dol_syslog(get_class($this). '::setMaxPeriod was called on objet with property table_element not defined', LOG_ERR); + dol_syslog(get_class($this).'::setMaxPeriod was called on objet with property table_element not defined', LOG_ERR); return -1; } @@ -1829,11 +1831,12 @@ class FactureFournisseurRec extends CommonInvoice $nb = 0; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '. (int) $nb; - $sql .= ' WHERE rowid = ' . (int) $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET nb_gen_max = ". (int) $nb; + $sql .= " WHERE rowid = " . (int) $this->id; + + dol_syslog(get_class($this).'::setMaxPeriod', LOG_DEBUG); - dol_syslog(get_class($this). '::setMaxPeriod', LOG_DEBUG); if ($this->db->query($sql)) { $this->nb_gen_max = $nb; return 1; @@ -1852,15 +1855,16 @@ class FactureFournisseurRec extends CommonInvoice public function setAutoValidate($validate) { if (!$this->table_element) { - dol_syslog(get_class($this). '::setAutoValidate was called on objet with property table_element not defined', LOG_ERR); + dol_syslog(get_class($this).'::setAutoValidate was called on objet with property table_element not defined', LOG_ERR); return -1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.((int) $validate); - $sql .= ' WHERE rowid = ' . (int) $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET auto_validate = ".((int) $validate); + $sql .= " WHERE rowid = " . (int) $this->id; + + dol_syslog(get_class($this).'::setAutoValidate', LOG_DEBUG); - dol_syslog(get_class($this). '::setAutoValidate', LOG_DEBUG); if ($this->db->query($sql)) { $this->auto_validate = $validate; return 1; @@ -1879,15 +1883,16 @@ class FactureFournisseurRec extends CommonInvoice public function setGeneratePdf($validate) { if (!$this->table_element) { - dol_syslog(get_class($this). '::setGeneratePdf was called on objet with property table_element not defined', LOG_ERR); + dol_syslog(get_class($this).'::setGeneratePdf was called on objet with property table_element not defined', LOG_ERR); return -1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET generate_pdf = '. (int) $validate; - $sql .= ' WHERE rowid = ' . (int) $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET generate_pdf = ". (int) $validate; + $sql .= " WHERE rowid = " . (int) $this->id; + + dol_syslog(get_class($this).'::setGeneratePdf', LOG_DEBUG); - dol_syslog(get_class($this). '::setGeneratePdf', LOG_DEBUG); if ($this->db->query($sql)) { $this->generate_pdf = $validate; return 1; @@ -1906,15 +1911,16 @@ class FactureFournisseurRec extends CommonInvoice public function setModelPdf($model) { if (!$this->table_element) { - dol_syslog(get_class($this). '::setModelPdf was called on objet with property table_element not defined', LOG_ERR); + dol_syslog(get_class($this).'::setModelPdf was called on objet with property table_element not defined', LOG_ERR); return -1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET modelpdf = '".$this->db->escape($model)."'"; - $sql .= ' WHERE rowid = ' . (int) $this->id; + $sql .= " WHERE rowid = " . (int) $this->id; + + dol_syslog(get_class($this).'::setModelPdf', LOG_DEBUG); - dol_syslog(get_class($this). '::setModelPdf', LOG_DEBUG); if ($this->db->query($sql)) { $this->model_pdf = $model; return 1; @@ -2137,8 +2143,8 @@ class FactureFournisseurLigneRec extends CommonObjectLine $sql .= ' fk_facture_fourn = ' . (int) $this->fk_facture_fourn; $sql .= ', fk_parent_line = ' . (int) $this->fk_parent; $sql .= ', fk_product = ' . (int) $this->fk_product; - $sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'null'); - $sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'null'); + $sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'NULL'); + $sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'NULL'); $sql .= ", description = '" . $this->db->escape($this->description) . "'"; $sql .= ', pu_ht = ' . price2num($this->pu_ht); $sql .= ', pu_ttc = ' . price2num($this->pu_ttc); @@ -2146,27 +2152,26 @@ class FactureFournisseurLigneRec extends CommonObjectLine $sql .= ", remise_percent = '" . price2num($this->remise_percent) . "'"; $sql .= ', fk_remise_except = ' . (int) $this->fk_remise_except; $sql .= ", vat_src_code = '" . $this->db->escape($this->vat_src_code) . "'"; - $sql .= ', tva_tx =' . price2num($this->tva_tx); + $sql .= ', tva_tx = ' . price2num($this->tva_tx); $sql .= ', localtax1_tx = ' . price2num($this->localtax1_tx); $sql .= ", localtax1_type = '" . $this->db->escape($this->localtax1_type) . "'"; $sql .= ', localtax2_tx = ' . price2num($this->localtax2_tx); $sql .= ", localtax2_type = '" . $this->db->escape($this->localtax2_type) . "'"; if (empty($this->skip_update_total)) { - $sql .= ', total_ht =' . price2num($this->total_ht); - $sql .= ', total_tva =' . price2num($this->total_tva); - $sql .= ', total_localtax1 =' . price2num($this->total_localtax1); - $sql .= ', total_localtax2 =' . price2num($this->total_localtax2); - $sql .= ', total_ttc =' . price2num($this->total_ttc); + $sql .= ', total_ht = ' . price2num($this->total_ht); + $sql .= ', total_tva = ' . price2num($this->total_tva); + $sql .= ', total_localtax1 = ' . price2num($this->total_localtax1); + $sql .= ', total_localtax2 = ' . price2num($this->total_localtax2); + $sql .= ', total_ttc = ' . price2num($this->total_ttc); } - $sql .= ', product_type =' . (int) $this->product_type; - $sql .= ', date_start =' . (int) $this->date_start; - $sql .= ', date_end =' . (int) $this->date_end; - $sql .= ", info_bits ='" . price2num($this->info_bits) . "'"; + $sql .= ', product_type = ' . (int) $this->product_type; + $sql .= ', date_start = ' . (int) $this->date_start; + $sql .= ', date_end = ' . (int) $this->date_end; + $sql .= ", info_bits = " . ((int) $this->info_bits); $sql .= ', special_code =' . (int) $this->special_code; - $sql .= ', rang =' . (int) $this->rang; - $sql .= ', fk_unit =' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null'); - $sql .= ', fk_user_modif =' . (int) $user; - + $sql .= ', rang = ' . (int) $this->rang; + $sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null'); + $sql .= ', fk_user_modif = ' . (int) $user; $sql .= ' WHERE rowid = ' . (int) $this->id; $this->db->begin(); From 9bf156b98107567788087ffabe223e0c1b920a30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 13:54:09 +0200 Subject: [PATCH 329/752] Doc --- htdocs/core/db/DoliDB.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index f23a66bbee4..66e54a4fc3c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -106,7 +106,7 @@ abstract class DoliDB implements Database */ public function idate($param, $gm = 'tzserver') { - // TODO $param should be gmt, so we should add $gm to 'gmt' instead of default 'tzserver' + // TODO $param should be gmt, so we should have default $gm to 'gmt' instead of default 'tzserver' return dol_print_date($param, "%Y-%m-%d %H:%M:%S", $gm); } From 63016b79ea810157cf320c675d86741d1256c342 Mon Sep 17 00:00:00 2001 From: bomuux Date: Mon, 4 Apr 2022 18:06:11 +0200 Subject: [PATCH 330/752] Bug: Cannot set thirdparty customer accountancy code to empty string When thirdparty customer accountancy code is set to a non empty string, one cannot set it back to empty string due to thirdparty property deprecation : code_compta to code_compta_client --- htdocs/comm/card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 90d3ed128f7..177d3e1f668 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -159,7 +159,8 @@ if (empty($reshook)) { // set accountancy code if ($action == 'setcustomeraccountancycode') { $result = $object->fetch($id); - $object->code_compta = GETPOST("customeraccountancycode"); + $object->code_compta_client = GETPOST("customeraccountancycode"); + $object->code_compta = $object->code_compta_client; // For Backward compatibility $result = $object->update($object->id, $user, 1, 1, 0); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -357,9 +358,9 @@ if ($object->id > 0) { print ''; print ''; print ''; } From 26f7a50838db4fee72c34800d366ea318ab96a8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 14:15:27 +0200 Subject: [PATCH 331/752] Update linkedobjectblock.tpl.php --- htdocs/reception/tpl/linkedobjectblock.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 3d61a7da815..009534b91b5 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -56,7 +56,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> - +
' . $langs->trans('ExpenseReportApplyTo') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . '
' . $langs->trans('ExpenseReportApplyTo') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . ' 
'; + echo ''; if ($action == 'edit' && $object->id == $rule->id) { $selected = ($object->is_for_all > 0) ? 'A' : ($object->fk_usergroup > 0 ? 'G' : 'U'); echo '
' . $form->selectarray('apply_to', $tab_apply, $selected, 0) . '
'; @@ -259,7 +259,7 @@ foreach ($rules as $rule) { echo '
'; + echo ''; if ($action == 'edit' && $object->id == $rule->id) { echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1); } else { @@ -278,7 +278,7 @@ foreach ($rules as $rule) { echo ''; + echo ''; if ($action == 'edit' && $object->id == $rule->id) { echo $form->selectarray('code_expense_rules_type', $tab_rules_type, $object->code_expense_rules_type, 0); } else { @@ -287,7 +287,7 @@ foreach ($rules as $rule) { echo ''; + echo ''; if ($action == 'edit' && $object->id == $rule->id) { print $form->selectDate(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0); } else { @@ -296,7 +296,7 @@ foreach ($rules as $rule) { echo ''; + echo ''; if ($action == 'edit' && $object->id == $rule->id) { print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0); } else { @@ -305,7 +305,7 @@ foreach ($rules as $rule) { echo ''; + echo ''; if ($action == 'edit' && $object->id == $rule->id) { echo '' . $conf->currency; } else { @@ -314,7 +314,7 @@ foreach ($rules as $rule) { echo ''; + echo ''; if ($action == 'edit' && $object->id == $rule->id) { echo $form->selectyesno('restrictive', $object->restrictive, 1); } else { From 5f6c5ccf926c38dce51a2a4fe3154530ba9ced9a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 4 Apr 2022 16:25:31 +0200 Subject: [PATCH 317/752] NEW Supplier order - Show ref supplier of reception in linked object block --- htdocs/reception/tpl/linkedobjectblock.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 1bfecac3f1d..3d61a7da815 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -56,7 +56,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> getNomUrl(1); ?>ref_supplier; ?> date_delivery, 'day'); ?> rights->reception->lire) { From f4a780f3f66f149a762bab038e57eb5427b96a0d Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 4 Apr 2022 16:28:42 +0200 Subject: [PATCH 318/752] add name on tr data --- htdocs/admin/expensereport_rules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index f15b996939d..9204e72f049 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -239,7 +239,7 @@ if ($action == 'edit') { echo '
'; if ($action == 'edit' && $object->id == $rule->id) { From ad145c94ca5a9ad2f4632e7b7621ab1ad5fd1547 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 4 Apr 2022 17:23:34 +0200 Subject: [PATCH 319/752] add comment --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f7eb6a67263..a8233a3d29f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -125,6 +125,7 @@ abstract class CommonObject /** * @var boolean is linkedObjects full loaded. Loaded by ->fetchObjectLinked + * important for pdf generation time reduction */ public $linkedObjectsFullLoaded = false; From b03d7c60ff30bc6cecfdce1ded14a5ab9faf962c Mon Sep 17 00:00:00 2001 From: bomuux Date: Mon, 4 Apr 2022 18:06:11 +0200 Subject: [PATCH 320/752] Bug: Cannot set thirdparty customer accountancy code to empty string When thirdparty customer accountancy code is set to a non empty string, one cannot set it back to empty string due to thirdparty property deprecation : code_compta to code_compta_client --- htdocs/comm/card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index de387ce60f3..4aca208681b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -162,7 +162,8 @@ if (empty($reshook)) { // set accountancy code if ($action == 'setcustomeraccountancycode') { $result = $object->fetch($id); - $object->code_compta = GETPOST("customeraccountancycode"); + $object->code_compta_client = GETPOST("customeraccountancycode"); + $object->code_compta = $object->code_compta_client; // For Backward compatibility $result = $object->update($object->id, $user, 1, 1, 0); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -360,9 +361,9 @@ if ($object->id > 0) { print '
'; - print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); + print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer); print ''; - print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); + print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer); print '
'.$langs->trans('Supplier').''; - if ($societe->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency))) { + if ($societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) { $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); print $societe->getNomUrl(1, 'supplier'); print ''; @@ -2050,15 +2050,15 @@ if ($action == 'create') { }); '; } - if (!GETPOST('fac_rec', 'int')) { + if ($fac_recid <= 0) { print ' '; } } print '
'.$langs->trans('CreateFromRepeatableInvoice').''; - //print ''; + //print ''; print '
'.$langs->trans('Project').''; print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); - print ' id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'">'; + print ' id.($fac_recid > 0 ? '&fac_rec='.$fac_recid : '')).'">'; print '
'; - print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); + print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer); print ''; - print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer); + print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer); print '
getNomUrl(1); ?>ref_supplier; ?>ref_supplier); ?> date_delivery, 'day'); ?> rights->reception->lire) { From ed7fd099258ff780453dfd5739ca0db805182c95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 14:36:09 +0200 Subject: [PATCH 332/752] Fix regression --- htdocs/core/lib/company.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 116c2beeb20..b8b6d1c728a 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -42,6 +42,8 @@ function societe_prepare_head(Societe $object) { global $db, $langs, $conf, $user; + global $hookmanager; + $h = 0; $head = array(); From 59fec7d0949cf860f01753d484242e7436f54e5f Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 5 Apr 2022 15:10:31 +0200 Subject: [PATCH 333/752] implement cache managed by current object --- htdocs/core/class/commonobject.class.php | 4 ++++ htdocs/core/lib/pdf.lib.php | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a8233a3d29f..e04ac12636d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3779,6 +3779,10 @@ abstract class CommonObject { global $conf, $hookmanager, $action; + // important for pdf generation time reduction + // this boolean is true if $this->linkedObjects has already been loaded with all objects linked without filter + if ($this->linkedObjectsFullLoaded) return 1; + $this->linkedObjectsIds = array(); $this->linkedObjects = array(); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index b273f93b69f..ea8c6c2ce23 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2282,9 +2282,7 @@ function pdf_getLinkedObjects(&$object, $outputlangs) $linkedobjects = array(); - if (empty($object->linkedObjectsFullLoaded)) { - $object->fetchObjectLinked(); - } + $object->fetchObjectLinked(); foreach ($object->linkedObjects as $objecttype => $objects) { if ($objecttype == 'facture') { From aa42df9961e4c0865b8f1382b870317ab521281b Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 5 Apr 2022 15:11:37 +0200 Subject: [PATCH 334/752] just for glory --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e04ac12636d..02d016d2ce7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Josep Lluís Amador * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Grégory Blémand * * 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 From 759f7e051e62efe14dd593d032c80374af8dea45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 15:18:52 +0200 Subject: [PATCH 335/752] Update files.lib.php --- htdocs/core/lib/files.lib.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 37bc946a8b6..58e282bf7a5 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2087,7 +2087,10 @@ function dol_uncompress($inputfile, $outputdir) include_once DOL_DOCUMENT_ROOT."/core/class/utils.class.php"; $utils = new Utils($db); + $fileinfo = pathinfo($inputfile); + $fileinfo["extension"] = strtolower($fileinfo["extension"]); + if ($fileinfo["extension"] == "zip") { if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS)) { dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir); @@ -2146,8 +2149,8 @@ function dol_uncompress($inputfile, $outputdir) } return array('error'=>'ErrNoZipEngine'); - } elseif (in_array($fileinfo["extension"], array('gz','bz2','zst'))) { - $extension = pathinfo($fileinfo["filename"], PATHINFO_EXTENSION); + } elseif (in_array($fileinfo["extension"], array('gz', 'bz2', 'zst'))) { + $extension = strtolower(pathinfo($fileinfo["filename"], PATHINFO_EXTENSION)); if ($extension == "tar") { $cmd = 'tar -C '.escapeshellcmd(dol_sanitizePathName($outputdir)).' -xvf '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"])); $resarray = $utils->executeCLI($cmd, $outputdir); From 3385cb80718bc3baf77db81551cc9e4f74a93b56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 15:19:55 +0200 Subject: [PATCH 336/752] Update files.lib.php --- htdocs/core/lib/files.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 58e282bf7a5..472636d7354 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2085,9 +2085,6 @@ function dol_uncompress($inputfile, $outputdir) { global $conf, $langs, $db; - include_once DOL_DOCUMENT_ROOT."/core/class/utils.class.php"; - $utils = new Utils($db); - $fileinfo = pathinfo($inputfile); $fileinfo["extension"] = strtolower($fileinfo["extension"]); @@ -2150,6 +2147,9 @@ function dol_uncompress($inputfile, $outputdir) return array('error'=>'ErrNoZipEngine'); } elseif (in_array($fileinfo["extension"], array('gz', 'bz2', 'zst'))) { + include_once DOL_DOCUMENT_ROOT."/core/class/utils.class.php"; + $utils = new Utils($db); + $extension = strtolower(pathinfo($fileinfo["filename"], PATHINFO_EXTENSION)); if ($extension == "tar") { $cmd = 'tar -C '.escapeshellcmd(dol_sanitizePathName($outputdir)).' -xvf '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"])); From efa302f865566be627863efa68a16264101f16c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 15:23:17 +0200 Subject: [PATCH 337/752] Fix phpunit --- .../class/fournisseur.facture-rec.class.php | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index abbf0db90fe..fea334e43cf 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -477,7 +477,7 @@ class FactureFournisseurRec extends CommonInvoice $sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ","; $sql .= " amount = ". (!empty($this->amount) ? ((float) $this->amount) : 0.00) . ','; $sql .= " remise = ". (!empty($this->remise) ? ((float) $this->remise) : 'NULL') . ','; - $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->vat_src_code."'" : 'NULL') . ','; + $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL') . ','; $sql .= " localtax1 = ". (!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00) . ','; $sql .= " localtax2 = ". (!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00) . ','; $sql .= " total_ht = ". (!empty($this->total_ht) ? ((float) $this->total_ht) : 0.00) . ','; @@ -1132,28 +1132,28 @@ class FactureFournisseurRec extends CommonInvoice $sql .= ", ref = '" . $this->db->escape($ref) . "'"; $sql .= ", label = '" . $this->db->escape($label) . "'"; $sql .= ", description = '" . $this->db->escape($desc) . "'"; - $sql .= ', pu_ht=' . price2num($pu_ht); - $sql .= ', qty=' . price2num($qty); - $sql .= ", remise_percent='" . price2num($remise_percent) . "'"; - $sql .= ", vat_src_code='" . $this->db->escape($vat_src_code) . "'"; - $sql .= ', tva_tx=' . price2num($txtva); - $sql .= ', localtax1_tx=' . (float) $txlocaltax1; - $sql .= ", localtax1_type='" . $this->db->escape($localtaxes_type[0]) . "'"; - $sql .= ', localtax2_tx=' . (float) $txlocaltax2; - $sql .= ", localtax2_type='" . $this->db->escape($localtaxes_type[2]) . "'"; - $sql .= ", total_ht='" . price2num($total_ht) . "'"; - $sql .= ", total_tva='" . price2num($total_tva) . "'"; - $sql .= ", total_localtax1='" . price2num($total_localtax1) . "'"; - $sql .= ", total_localtax2='" . price2num($total_localtax2) . "'"; - $sql .= ", total_ttc='" . price2num($total_ttc) . "'"; - $sql .= ', product_type=' . (int) $product_type; - $sql .= ', date_start=' . (empty($date_start) ? 'NULL' : (int) $date_start); - $sql .= ', date_end=' . (empty($date_end) ? 'NULL' : (int) $date_end); - $sql .= ', info_bits=' . (int) $info_bits; - $sql .= ', special_code=' . (int) $special_code; - $sql .= ', rang=' . (int) $rang; - $sql .= ', fk_unit=' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null'); - $sql .= ', fk_user_modif=' . (int) $user; + $sql .= ', pu_ht = ' . price2num($pu_ht); + $sql .= ', qty = ' . price2num($qty); + $sql .= ", remise_percent = '" . price2num($remise_percent) . "'"; + $sql .= ", vat_src_code = '" . $this->db->escape($vat_src_code) . "'"; + $sql .= ', tva_tx = ' . price2num($txtva); + $sql .= ', localtax1_tx = ' . (float) $txlocaltax1; + $sql .= ", localtax1_type = '" . $this->db->escape($localtaxes_type[0]) . "'"; + $sql .= ', localtax2_tx = ' . (float) $txlocaltax2; + $sql .= ", localtax2_type = '" . $this->db->escape($localtaxes_type[2]) . "'"; + $sql .= ", total_ht = '" . price2num($total_ht) . "'"; + $sql .= ", total_tva = '" . price2num($total_tva) . "'"; + $sql .= ", total_localtax1 = '" . price2num($total_localtax1) . "'"; + $sql .= ", total_localtax2 = '" . price2num($total_localtax2) . "'"; + $sql .= ", total_ttc = '" . price2num($total_ttc) . "'"; + $sql .= ', product_type = ' . (int) $product_type; + $sql .= ', date_start = ' . (empty($date_start) ? 'NULL' : (int) $date_start); + $sql .= ', date_end = ' . (empty($date_end) ? 'NULL' : (int) $date_end); + $sql .= ', info_bits = ' . (int) $info_bits; + $sql .= ', special_code = ' . (int) $special_code; + $sql .= ', rang = ' . (int) $rang; + $sql .= ', fk_unit = ' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null'); + $sql .= ', fk_user_modif = ' . (int) $user; $sql .= ', multicurrency_subprice = '.price2num($pu_ht_devise); $sql .= ', multicurrency_total_ht = '.price2num($multicurrency_total_ht); $sql .= ', multicurrency_total_tva = '.price2num($multicurrency_total_tva); From 046089f3716b55cfde7bcf6cce92e81b27072634 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 5 Apr 2022 15:38:54 +0200 Subject: [PATCH 338/752] FIX 16.0 - ref_client set instead of ref_supplier (maybe copy-paste error) --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 02e77d13f58..b1f2be177f6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -903,7 +903,7 @@ if (empty($reshook)) { $object->date = $dateinvoice; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); $object->note_private = trim(GETPOST('note_private', 'restricthtml')); - $object->ref_client = GETPOST('ref_client'); + $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOST('projectid', 'int'); $object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id')); From d143b8bf6e4ee2eeb21c4b0152f4ad1123245d6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 17:19:12 +0200 Subject: [PATCH 339/752] Debug dol_uncompress and add phpunit tests --- htdocs/core/class/utils.class.php | 16 +++++++--- htdocs/core/lib/files.lib.php | 35 +++++++++++++++------- test/phpunit/FilesLibTest.php | 50 +++++++++++++++++++++++++++---- 3 files changed, 81 insertions(+), 20 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 4a4db439822..f3d46e09f30 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -651,12 +651,13 @@ class Utils * Warning: The command line is sanitize so can't contains any redirection char '>'. Use param $redirectionfile if you need it. * @param string $outputfile A path for an output file (used only when method is 2). For example: $conf->admin->dir_temp.'/out.tmp'; * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method - * @param string $redirectionfile If defined, a redirection of output to this files is added. + * @param string $redirectionfile If defined, a redirection of output to this file is added. * @param int $noescapecommand 1=Do not escape command. Warning: Using this parameter need you alreay sanitized the command. if not, it will lead to security vulnerability. * This parameter is provided for backward compatibility with external modules. Always use 0 in core. + * @param string $redirectionfileerr If defined, a redirection of error is added to this file instead of to channel 1. * @return array array('result'=>...,'output'=>...,'error'=>...). result = 0 means OK. */ - public function executeCLI($command, $outputfile, $execmethod = 0, $redirectionfile = null, $noescapecommand = 0) + public function executeCLI($command, $outputfile, $execmethod = 0, $redirectionfile = null, $noescapecommand = 0, $redirectionfileerr = null) { global $conf, $langs; @@ -667,10 +668,17 @@ class Utils if (empty($noescapecommand)) { $command = escapeshellcmd($command); } + if ($redirectionfile) { $command .= " > ".dol_sanitizePathName($redirectionfile); } - $command .= " 2>&1"; + + if ($redirectionfileerr && ($redirectionfileerr != $redirectionfile)) { + // If we ask a redirect of stderr on a given file not already used for stdout + $command .= " 2> ".dol_sanitizePathName($redirectionfileerr); + } else { + $command .= " 2>&1"; + } if (!empty($conf->global->MAIN_EXEC_USE_POPEN)) { $execmethod = $conf->global->MAIN_EXEC_USE_POPEN; @@ -679,7 +687,7 @@ class Utils $execmethod = 1; } //$execmethod=1; - dol_syslog("Utils::executeCLI execmethod=".$execmethod." system:".$command, LOG_DEBUG); + dol_syslog("Utils::executeCLI execmethod=".$execmethod." command=".$command, LOG_DEBUG); $output_arr = array(); if ($execmethod == 1) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3bbef8b1b96..2cf0beb013f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2094,6 +2094,9 @@ function dol_uncompress($inputfile, $outputdir) include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; $archive = new PclZip($inputfile); + // We create output dir manually, so it uses the correct permission (When created by the archive->extract, dir is rwx for everybody). + dol_mkdir(dol_sanitizePathName($outputdir)); + // Extract into outputdir, but only files that match the regex '/^((?!\.\.).)*$/' that means "does not include .." $result = $archive->extract(PCLZIP_OPT_PATH, $outputdir, PCLZIP_OPT_BY_PREG, '/^((?!\.\.).)*$/'); @@ -2150,10 +2153,19 @@ function dol_uncompress($inputfile, $outputdir) include_once DOL_DOCUMENT_ROOT."/core/class/utils.class.php"; $utils = new Utils($db); + dol_mkdir(dol_sanitizePathName($outputdir)); + $outputfilename = escapeshellcmd(dol_sanitizePathName($outputdir).'/'.dol_sanitizeFileName($fileinfo["filename"])); + dol_delete_file($outputfilename.'.tmp'); + dol_delete_file($outputfilename.'.err'); + $extension = strtolower(pathinfo($fileinfo["filename"], PATHINFO_EXTENSION)); if ($extension == "tar") { $cmd = 'tar -C '.escapeshellcmd(dol_sanitizePathName($outputdir)).' -xvf '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"])); - $resarray = $utils->executeCLI($cmd, $outputdir); + + $resarray = $utils->executeCLI($cmd, $outputfilename.'.tmp', 0, $outputfilename.'.err', 0); + if ($resarray["result"] != 0) { + $resarray["error"] .= file_get_contents($outputfilename.'.err'); + } } else { $program = ""; if ($fileinfo["extension"] == "gz") { @@ -2163,22 +2175,23 @@ function dol_uncompress($inputfile, $outputdir) } elseif ($fileinfo["extension"] == "zst") { $program = 'zstd'; } else { - return array('error'=>'ErrFileExtension'); + return array('error'=>'ErrorBadFileExtension'); } $cmd = $program.' -dc '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"])); - $outputfilename = escapeshellcmd(dol_sanitizePathName($outputdir).'/'.dol_sanitizeFileName($fileinfo["filename"])); - $resarray = $utils->executeCLI($cmd, $outputfilename, 0, $outputfilename); - if ($resarray["output"] == 2) { - $resarray["error"] = "ErrFilePermOrFileNotFound"; - } - if ($resarray["output"] == 1) { - $resarray["error"] = "Error"; + $cmd .= ' > '.$outputfilename; + + $resarray = $utils->executeCLI($cmd, $outputfilename.'.tmp', 0, null, 1, $outputfilename.'.err'); + if ($resarray["result"] != 0) { + $errfilecontent = @file_get_contents($outputfilename.'.err'); + if ($errfilecontent) { + $resarray["error"] .= " - ".$errfilecontent; + } } } - return $resarray["output"] != 0 ? $resarray["error"] : array(); + return $resarray["result"] != 0 ? array('error' => $resarray["error"]) : array(); } - return array('error'=>'ErrFileExtension'); + return array('error'=>'ErrorBadFileExtension'); } diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index b98237d1b29..48a00c8214d 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -401,10 +401,14 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; + // Format zip + print "\n"; + print 'testDolCompressUnCompress zip'."\n"; + $format='zip'; $filein=dirname(__FILE__).'/Example_import_company_1.csv'; $fileout=$conf->admin->dir_temp.'/test.'.$format; - $dirout=$conf->admin->dir_temp.'/test'; + $dirout=$conf->admin->dir_temp.'/testdir'.$format; dol_delete_file($fileout); $count=0; @@ -417,18 +421,50 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $conf->logbuffer=array(); $result=dol_compress_file($filein, $fileout, $format, $errorstring); - print __METHOD__." result=".$result."\n"; + print __METHOD__." compress result=".$result."\n"; print join(', ', $conf->logbuffer); $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." into ".$fileout." : ".$errorstring); $result=dol_uncompress($fileout, $dirout); - print __METHOD__." result=".join(',', $result)."\n"; + print __METHOD__." uncompress result=".join(',', $result)."\n"; $this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout); + // Format gz + print "\n"; + print 'testDolCompressUnCompress gz'."\n"; + + $format='gz'; + $filein=dirname(__FILE__).'/Example_import_company_1.csv'; + $fileout=$conf->admin->dir_temp.'/test.'.$format; + $dirout=$conf->admin->dir_temp.'/testdir'.$format; + + dol_delete_file($fileout); + $count=0; + dol_delete_dir_recursive($dirout, $count, 1); + + $errorstring = ''; + + dol_mkdir($conf->admin->dir_temp); + $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1; + $conf->logbuffer=array(); + + $result=dol_compress_file($filein, $fileout, $format, $errorstring); + print __METHOD__." compress result=".$result."\n"; + print join(', ', $conf->logbuffer); + $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." into ".$fileout." : ".$errorstring); + + $result=dol_uncompress($fileout, $dirout); + print __METHOD__." uncompress result=".join(',', $result)."\n"; + print join(', ', $conf->logbuffer); + $this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout); + + + // Test compression of a directory + // $dirout is $conf->admin->dir_temp.'/testdirgz' $excludefiles = '/(\.back|\.old|\.log|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i'; if (preg_match($excludefiles, 'a/temp/b')) { echo '----- Regex OK -----'."\n"; } - $result=dol_compress_dir($dirout, $conf->admin->dir_temp.'/testdir.zip', 'zip', $excludefiles); - print __METHOD__." result=".$result."\n"; + $result=dol_compress_dir($dirout, $conf->admin->dir_temp.'/testcompressdirzip.zip', 'zip', $excludefiles); + print __METHOD__." dol_compress_dir result=".$result."\n"; print join(', ', $conf->logbuffer); $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_dir of ".$dirout." into ".$conf->admin->dir_temp.'/testdir.zip'); } @@ -466,6 +502,10 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $db=$this->savdb; + if (empty($user->rights->facture)) { + $user->rights->facture = new stdClass(); + } + //$dummyuser=new User($db); //$result=restrictedArea($dummyuser,'societe'); From 216b4b7309a601b4db04628a6b0ebc43f3152bf0 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 5 Apr 2022 17:30:36 +0200 Subject: [PATCH 340/752] 16.0 - deprecate `amount` field of FactureFournisseur and FactureFournisseurRec --- htdocs/fourn/class/fournisseur.facture-rec.class.php | 5 +++++ htdocs/fourn/class/fournisseur.facture.class.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index fea334e43cf..7d90c239ba7 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -79,6 +79,11 @@ class FactureFournisseurRec extends CommonInvoice public $suspended; public $libelle; + + /** + * @deprecated + * @var double $amount + */ public $amount; public $remise; public $vat_src_code; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 24561e08785..b90fbbbd86a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -181,6 +181,10 @@ class FactureFournisseur extends CommonInvoice */ public $date_echeance; + /** + * @deprecated + * @var double $amount + */ public $amount = 0; public $remise = 0; From bb30a1c8c6883033cfe6e489843a6237df324eb6 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 5 Apr 2022 17:31:04 +0200 Subject: [PATCH 341/752] FIX 16.0 SQL error on update --- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b90fbbbd86a..b602c27af57 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1262,7 +1262,7 @@ class FactureFournisseur extends CommonInvoice } $sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " paye=".(isset($this->paye) ? $this->paye : "null").","; - $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; + $sql .= " amount=".(isset($this->amount) ? doubleval($this->amount) : "null").","; $sql .= " remise=".(isset($this->remise) ? $this->remise : "null").","; $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; @@ -1276,7 +1276,7 @@ class FactureFournisseur extends CommonInvoice $sql .= " fk_user_author=".(isset($this->author) ? $this->author : "null").","; $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").","; $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? $this->fk_facture_source : "null").","; - $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; + $sql .= " fk_projet=".(isset($this->fk_project) ? intval($this->fk_project) : "null").","; $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; $sql .= " date_lim_reglement=".(dol_strlen($this->date_echeance) != 0 ? "'".$this->db->idate($this->date_echeance)."'" : 'null').","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; From dd6706e521dd70076659bc9caaa9a4d295ceb635 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 5 Apr 2022 17:31:34 +0200 Subject: [PATCH 342/752] NEW display errors in a message box after generating documents --- htdocs/core/class/commonobject.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 232aa6b5789..cc3ea5ae820 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5380,16 +5380,19 @@ abstract class CommonObject return 1; } else { $outputlangs->charset_output = $sav_charset_output; - dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); + dol_syslog("Error generating document for ".__CLASS__.". Error: ".$obj->error, LOG_ERR); + setEventMessages($obj->error, $obj->errors, 'errors'); return -1; } } else { if (!$filefound) { $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; - dol_print_error('', $this->error); + dol_syslog($this->error, LOG_ERR); + setEventMessage($this->error, 'errors'); } else { $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound); - dol_print_error('', $this->error); + dol_syslog($this->error, LOG_ERR); + setEventMessage($this->error, 'errors'); } return -1; } From c7d5ecd4f7f7cd1d37ca33fbfc4a21938f476cc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 17:39:56 +0200 Subject: [PATCH 343/752] Renamed hidden option INVOICE_CAN_ALWAYS_BE_EDITED into INVOICE_CAN_BE_EDITED_EVEN_IF_PAYMENT_DONE for better understanding. --- htdocs/compta/facture/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0802a4c9bb8..102e0cf7f4a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -737,7 +737,7 @@ if (empty($reshook)) { // On verifie si aucun paiement n'a ete effectue if ($ventilExportCompta == 0) { - if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { + if (!empty($conf->global->INVOICE_CAN_BE_EDITED_EVEN_IF_PAYMENT_DONE) || ($resteapayer == $object->total_ttc && empty($object->paye))) { $result = $object->setDraft($user, $idwarehouse); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -5340,13 +5340,13 @@ if ($action == 'create') { $ventilExportCompta = $object->getVentilExportCompta(); if ($ventilExportCompta == 0) { - if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) { + if (!empty($conf->global->INVOICE_CAN_BE_EDITED_EVEN_IF_PAYMENT_DONE) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) { if (!$objectidnext && $object->is_last_in_cycle()) { if ($usercanunvalidate) { - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', true, $params); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif&token='.newToken(), '', true, $params); } else { $params['attr']['title'] = $langs->trans('NotEnoughPermissions'); - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', false, $params); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif&token='.newToken(), '', false, $params); } } elseif (!$object->is_last_in_cycle()) { $params['attr']['title'] = $langs->trans('NotLastInCycle'); From a8a83b30dc709df50e9b5e3641d2924af4339fd5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 18:17:45 +0200 Subject: [PATCH 344/752] FIX Can't edit bank record --- htdocs/compta/bank/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index f8cc88e1be4..61614b211bd 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -65,7 +65,8 @@ $hookmanager->initHooks(array('bankcard', 'globalcard')); // Security check $id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha'); -$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; +$fieldid = GETPOST("id") ? 'rowid' : 'ref'; + $result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); From 8a9e8cd36b710034b98cd179c0c401d328c26482 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 18:17:49 +0200 Subject: [PATCH 345/752] css --- htdocs/theme/md/style.css.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 04a3c948a80..f2fee83c291 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -119,7 +119,7 @@ $dol_no_mouse_hover = $conf->dol_no_mouse_hover; $useboldtitle = (isset($conf->global->THEME_ELDY_USEBOLDTITLE) ? $conf->global->THEME_ELDY_USEBOLDTITLE : 0); $borderwidth = 2; -$userborderontable = getDolGlobalInt('THEME_ELDY_USEBORDERONTABLE');; +$userborderontable = getDolGlobalInt('THEME_ELDY_USEBORDERONTABLE'); // Case of option always editable if (!isset($conf->global->THEME_ELDY_BACKBODY)) { @@ -3677,8 +3677,8 @@ div.colorback } .liste_titre_bydiv { - border-right: 1px solid var(--colortopbordertitle1); - border-left: 1px solid var(--colortopbordertitle1); + border-right: 1px solid #ccc; + border-left: 1px solid #ccc; } table.liste, table.noborder, table.formdoc, div.noborder { @@ -3692,13 +3692,13 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-top-style: solid; border-bottom-width: 1px; - border-bottom-color: var(--colortopbordertitle1); + border-bottom-color: #BBB; border-bottom-style: solid; - border-right: 1px solid var(--colortopbordertitle1); - border-left: 1px solid var(--colortopbordertitle1); + border-right: 1px solid #ccc; + border-left: 1px solid #ccc; margin: 0px 0px 20px 0px; @@ -4094,15 +4094,15 @@ div.liste_titre { padding-bottom: 2px; /*border-right-width: 1px; - border-right-color: var(--colortopbordertitle1); + border-right-color: #BBB; border-right-style: solid; border-left-width: 1px; - border-left-color: var(--colortopbordertitle1); + border-left-color: #BBB; border-left-style: solid;*/ border-top-width: 1px; - border-top-color: var(--colortopbordertitle1); + border-top-color: #BBB; border-top-style: solid; } div.liste_titre_bydiv { From 91909928d4ca5c73038f1146c66ce1e89ce1d608 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 18:19:06 +0200 Subject: [PATCH 346/752] FIX Can't edit bank record --- htdocs/compta/bank/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 8430d9e7440..283258a08a0 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -65,7 +65,8 @@ $hookmanager->initHooks(array('bankcard', 'globalcard')); // Security check $id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha'); -$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; +$fieldid = GETPOST("id", 'int') ? 'rowid' : 'ref'; + $result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); From 7896baa6c98ddcdac2a6f122583a11c619647125 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 18:20:45 +0200 Subject: [PATCH 347/752] css --- htdocs/compta/bank/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 61614b211bd..b0444b90dcc 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -725,7 +725,7 @@ if ($action == 'create') { print '
'; if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) { - print '
'; + //print '
'; print ''; From 3eabb52176e76f1180a02b9712f3e8a9fc2042ce Mon Sep 17 00:00:00 2001 From: "goup2cloud.com" Date: Tue, 5 Apr 2022 18:21:28 +0200 Subject: [PATCH 348/752] Changed --- htdocs/contrat/services_list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 39dfe336a31..adf7a4b6ed7 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -326,25 +326,25 @@ if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $fil $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; } if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') { - $sql .= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; + $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."' AND '".$db->idate($filter_dateouvertureprevue_end)."'"; } if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') { $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; } if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') { - $sql .= " AND '".$db->idate($filter_date1_end)."'"; + $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."' AND '".$db->idate($filter_date1_end)."'"; } if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') { $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; } if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') { - $sql .= " AND '".$db->idate($filter_date2_end)."'"; + $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."' AND '".$db->idate($filter_date2_end)."'"; } if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') { $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; } if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') { - $sql .= " AND '".$db->idate($filter_datecloture_end)."'"; + $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."' AND '".$db->idate($filter_datecloture_end)."'"; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; From d213be235eef7917902898f45da6e6b04e16d1c7 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Tue, 5 Apr 2022 18:32:29 +0200 Subject: [PATCH 349/752] Cleaner way of fixing the SQL error on update --- htdocs/fourn/class/fournisseur.facture.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b602c27af57..176f79a51de 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1178,7 +1178,8 @@ class FactureFournisseur extends CommonInvoice $this->paye = trim($this->paye); } if (isset($this->amount)) { - $this->amount = trim($this->amount); + if (empty($this->amount)) $this->amount = 0; + else $this->amount = doubleval($this->amount); } if (isset($this->remise)) { $this->remise = trim($this->remise); @@ -1225,7 +1226,8 @@ class FactureFournisseur extends CommonInvoice $this->fk_facture_source = trim($this->fk_facture_source); } if (isset($this->fk_project)) { - $this->fk_project = trim($this->fk_project); + if (empty($this->fk_project)) $this->fk_project = null; + else $this->fk_project = intval($this->fk_project); } if (isset($this->cond_reglement_id)) { $this->cond_reglement_id = trim($this->cond_reglement_id); @@ -1262,7 +1264,7 @@ class FactureFournisseur extends CommonInvoice } $sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " paye=".(isset($this->paye) ? $this->paye : "null").","; - $sql .= " amount=".(isset($this->amount) ? doubleval($this->amount) : "null").","; + $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; $sql .= " remise=".(isset($this->remise) ? $this->remise : "null").","; $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; @@ -1276,7 +1278,7 @@ class FactureFournisseur extends CommonInvoice $sql .= " fk_user_author=".(isset($this->author) ? $this->author : "null").","; $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").","; $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? $this->fk_facture_source : "null").","; - $sql .= " fk_projet=".(isset($this->fk_project) ? intval($this->fk_project) : "null").","; + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; $sql .= " date_lim_reglement=".(dol_strlen($this->date_echeance) != 0 ? "'".$this->db->idate($this->date_echeance)."'" : 'null').","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; From f9c9e518c356e60e316c2bf524143289f896bdb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2022 19:14:00 +0200 Subject: [PATCH 350/752] Load tables for opensurvey only when module opensurvey is enabled --- htdocs/core/modules/modOpenSurvey.class.php | 7 +++++++ ....key.sql => llx_opensurvey_comments-opensurvey.key.sql} | 0 ...comments.sql => llx_opensurvey_comments-opensurvey.sql} | 0 ...ons.sql => llx_opensurvey_formquestions-opensurvey.sql} | 0 ...e.key.sql => llx_opensurvey_sondage-opensurvey.key.sql} | 0 ...y_sondage.sql => llx_opensurvey_sondage-opensurvey.sql} | 0 ....sql => llx_opensurvey_user_formanswers-opensurvey.sql} | 0 ...ey.sql => llx_opensurvey_user_studs-opensurvey.key.sql} | 0 ..._studs.sql => llx_opensurvey_user_studs-opensurvey.sql} | 0 9 files changed, 7 insertions(+) rename htdocs/install/mysql/tables/{llx_opensurvey_comments.key.sql => llx_opensurvey_comments-opensurvey.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_opensurvey_comments.sql => llx_opensurvey_comments-opensurvey.sql} (100%) rename htdocs/install/mysql/tables/{llx_opensurvey_formquestions.sql => llx_opensurvey_formquestions-opensurvey.sql} (100%) rename htdocs/install/mysql/tables/{llx_opensurvey_sondage.key.sql => llx_opensurvey_sondage-opensurvey.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_opensurvey_sondage.sql => llx_opensurvey_sondage-opensurvey.sql} (100%) rename htdocs/install/mysql/tables/{llx_opensurvey_user_formanswers.sql => llx_opensurvey_user_formanswers-opensurvey.sql} (100%) rename htdocs/install/mysql/tables/{llx_opensurvey_user_studs.key.sql => llx_opensurvey_user_studs-opensurvey.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_opensurvey_user_studs.sql => llx_opensurvey_user_studs-opensurvey.sql} (100%) diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index 87a4f453801..9cc9310cd19 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -182,6 +182,13 @@ class modOpenSurvey extends DolibarrModules */ public function init($options = '') { + global $conf, $langs; + + $result = $this->_load_tables('/install/mysql/tables/', 'opensurvey'); + 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') + } + // Permissions $this->remove($options); diff --git a/htdocs/install/mysql/tables/llx_opensurvey_comments.key.sql b/htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_comments.key.sql rename to htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.key.sql diff --git a/htdocs/install/mysql/tables/llx_opensurvey_comments.sql b/htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_comments.sql rename to htdocs/install/mysql/tables/llx_opensurvey_comments-opensurvey.sql diff --git a/htdocs/install/mysql/tables/llx_opensurvey_formquestions.sql b/htdocs/install/mysql/tables/llx_opensurvey_formquestions-opensurvey.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_formquestions.sql rename to htdocs/install/mysql/tables/llx_opensurvey_formquestions-opensurvey.sql diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.key.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage-opensurvey.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_sondage.key.sql rename to htdocs/install/mysql/tables/llx_opensurvey_sondage-opensurvey.key.sql diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage-opensurvey.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_sondage.sql rename to htdocs/install/mysql/tables/llx_opensurvey_sondage-opensurvey.sql diff --git a/htdocs/install/mysql/tables/llx_opensurvey_user_formanswers.sql b/htdocs/install/mysql/tables/llx_opensurvey_user_formanswers-opensurvey.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_user_formanswers.sql rename to htdocs/install/mysql/tables/llx_opensurvey_user_formanswers-opensurvey.sql diff --git a/htdocs/install/mysql/tables/llx_opensurvey_user_studs.key.sql b/htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_user_studs.key.sql rename to htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.key.sql diff --git a/htdocs/install/mysql/tables/llx_opensurvey_user_studs.sql b/htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_opensurvey_user_studs.sql rename to htdocs/install/mysql/tables/llx_opensurvey_user_studs-opensurvey.sql From 946061af384798cdcb9df2633f70934447ca3ae2 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 5 Apr 2022 20:21:48 +0200 Subject: [PATCH 351/752] Update README.md --- htdocs/datapolicy/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/datapolicy/README.md b/htdocs/datapolicy/README.md index e2bde95a6d8..0d70b287a81 100644 --- a/htdocs/datapolicy/README.md +++ b/htdocs/datapolicy/README.md @@ -1,5 +1,7 @@ DataPolicy ========== + This module provides features to be compliant with data privacy rules of your country. -A schedlued job is installed to automatically clean old record in your database. You defined what to delete and when in the setup of module. \ No newline at end of file +A scheduled job is installed to automatically delete old records in your database. +In the setup of the module you define what should be deleted and when. From 32f601a48b6707afd7e6a0726da8835c57a17444 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 6 Apr 2022 09:15:53 +0200 Subject: [PATCH 352/752] rename css class name --- htdocs/admin/expensereport_rules.php | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 9204e72f049..1146232dca3 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -185,14 +185,14 @@ if ($action != 'edit') { echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo ''; @@ -227,14 +227,14 @@ if ($action == 'edit') { echo '
' . $langs->trans('ExpenseReportApplyTo') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . '
' . $langs->trans('ExpenseReportApplyTo') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . ' 
'; - echo ''; + echo ''; echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo ''; From c4f0c60a11804662916cb84fb5a075b27d87267c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 6 Apr 2022 09:19:56 +0200 Subject: [PATCH 353/752] FIX: Filter on Object Referent page give CRSF page --- htdocs/product/stats/bom.php | 1 + htdocs/product/stats/commande_fournisseur.php | 1 + htdocs/product/stats/contrat.php | 2 +- htdocs/product/stats/facture.php | 1 + htdocs/product/stats/facture_fournisseur.php | 1 + htdocs/product/stats/mo.php | 1 + htdocs/product/stats/propal.php | 1 + htdocs/product/stats/supplier_proposal.php | 1 + 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index 52eec409185..5ab7a8f40a8 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -247,6 +247,7 @@ if ($id > 0 || !empty($ref)) { } print '
'."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index fd64a1c0572..c7283399a43 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -198,6 +198,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index cb7c84fc863..4c958a20370 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -183,7 +183,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; - + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index b3e5571ac5a..da81f915b45 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -214,6 +214,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 212674582f9..e85801c8642 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -197,6 +197,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 5a5c33312ca..adfe989289e 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -176,6 +176,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index b83d0368b75..096848d6205 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -199,6 +199,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index d583d58bff8..a60261af115 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -198,6 +198,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } From a0cb04bafc1651e24b4ff763857460fb04045b7a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 11:21:46 +0200 Subject: [PATCH 354/752] Fix css --- htdocs/core/boxes/box_birthdays.php | 6 +++--- htdocs/core/boxes/box_birthdays_members.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 62cfaa590ab..41e51eee45e 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -131,7 +131,7 @@ class box_birthdays extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); + $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text' => ''.$langs->trans("None").''); } $this->db->free($result); @@ -144,8 +144,8 @@ class box_birthdays extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover left"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' ); } } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 5e772ff3593..6138664db2d 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -128,7 +128,7 @@ class box_birthdays_members extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); + $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text' => ''.$langs->trans("None").''); } $this->db->free($result); @@ -141,8 +141,8 @@ class box_birthdays_members extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover left"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' ); } } From c3ae63f587f76670c113746f0d2f1e62b129548a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 11:34:49 +0200 Subject: [PATCH 355/752] FIX out of memory when more than 100 000 invoices. --- htdocs/compta/facture/list.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ccf3c2f3f0c..f2cc5943e7a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -757,12 +757,28 @@ $sql .= ' f.rowid DESC '; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + /* This old and fast method to get and count full list returns all record so use a high amount of memory. $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + */ + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + if ($sall || $search_product_category > 0 || $search_user > 0) { + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql); + } else { + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid/', '', $sqlforcount); + } + $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount); + + $resql = $db->query($sqlforcount); + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } $sql .= $db->plimit($limit + 1, $offset); From 8be5cccb4ef0a6c4352d9b4903e4f09dae8e6d38 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 6 Apr 2022 12:32:10 +0200 Subject: [PATCH 356/752] Reverse stock movements on mo consumed product --- htdocs/langs/en_US/mrp.lang | 1 + htdocs/mrp/class/mo.class.php | 72 ++++++++++++++++++++++++++++++++++- htdocs/mrp/mo_production.php | 10 ++++- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 4dc74122ea9..525c0f4c150 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -69,6 +69,7 @@ ForAQuantityToConsumeOf=For a quantity to disassemble of %s ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order? ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and/or production for the quantities set. This will also update the stock and record stock movements. ProductionForRef=Production of %s +CancelProductionForRef=Cancellation of product stock decrementation for product %s AutoCloseMO=Close automatically the Manufacturing Order if quantities to consume and to produce are reached NoStockChangeOnServices=No stock change on services ProductQtyToConsumeByMO=Product quantity still to consume by open MO diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index de9913fdb9f..f3600960706 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -750,12 +750,82 @@ class Mo extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { + global $langs; + $langs->load('stocks'); + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } - return $this->deleteLineCommon($user, $idline, $notrigger); + $productstatic = new Product($this->db); + $fk_movement = GETPOST('fk_movement', 'int'); + $arrayoflines = $this->fetchLinesLinked('consumed', $idline); + + if (! empty($arrayoflines)) { + $this->db->begin(); + + $stockmove = new MouvementStock($this->db); + $stockmove->setOrigin($this->element, $this->id); + + if (! empty($fk_movement)) { + $moline = new MoLine($this->db); + $TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement)); + $moline = array_shift($TArrayMoLine); + + $movement = new MouvementStock($this->db); + $movement->fetch($fk_movement); + $productstatic->fetch($movement->product_id); + $qtytoprocess = $movement->qty; + + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); + + if (($qtytoprocess >= 0)) { + $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $movement->batch, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $movement->batch, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + return $moline->delete($user, $notrigger); + } + else { + foreach ($arrayoflines as $key => $arrayofline) { + $lineDetails = $arrayoflines[$key]; + $productstatic->fetch($lineDetails['fk_product']); + $qtytoprocess = $lineDetails['qty']; + $id_product_batch = (! empty($lineDetails['batch']) ? $lineDetails['batch'] : 0); + + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); + + if ($qtytoprocess >= 0) { + $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $id_product_batch, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $id_product_batch, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + } + return $this->deleteLineCommon($user, $idline, $notrigger); + } + } + else { + return $this->deleteLineCommon($user, $idline, $notrigger); + } } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 545a7aaf202..ba04152bd7d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -49,6 +49,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mocard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$fk_movement = GETPOST('fk_movement', 'int'); $collapse = GETPOST('collapse', 'aZ09comma'); @@ -445,7 +446,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation to delete line if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid.'&fk_movement='.$fk_movement, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation if ($action == 'clone') { @@ -969,7 +970,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Action delete line if ($permissiontodelete) { - print '
'; + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); + print ''; } print ''; From 370965a0bbd7feba44c60f8ea3509f5813184e7a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 13:29:52 +0200 Subject: [PATCH 357/752] Rename build_path_from_id_categ into buildPathFromId and set it private --- ChangeLog | 1 + htdocs/categories/class/categorie.class.php | 14 ++++++-------- htdocs/ecm/class/ecmdirectory.class.php | 18 ++++++++---------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36c645dfef0..880406bb189 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,6 +32,7 @@ Following changes may create regressions for some external modules, but were nec * verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true. * The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead. * All triggers with a name XXX_UPDATE have been rename with name XXX_MODIFY for code consistency purpose. +* Rename build_path_from_id_categ() into buildPathFromId() and set method to private ***** ChangeLog for 15.0.1 compared to 15.0.0 ***** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index a3d2dc3e57f..434b994ccd2 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1141,10 +1141,10 @@ class Categorie extends CommonObject } // We add the fullpath property to each elements of first level (no parent exists) - dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); + dol_syslog(get_class($this)."::get_full_arbo call to buildPathFromId", LOG_DEBUG); foreach ($this->cats as $key => $val) { //print 'key='.$key.'
'."\n"; - $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) + $this->buildPathFromId($key, 0); // Process a branch from the root category key (this category has no parent) } // Include or exclude leaf including $markafterid from tree @@ -1174,7 +1174,6 @@ class Categorie extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel. * It is called by get_full_arbo() @@ -1185,19 +1184,18 @@ class Categorie extends CommonObject * @return void * @see get_full_arbo() */ - public function build_path_from_id_categ($id_categ, $protection = 1000) + private function buildPathFromId($id_categ, $protection = 1000) { - // phpcs:enable - dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); + //dol_syslog(get_class($this)."::buildPathFromId id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); if (!empty($this->cats[$id_categ]['fullpath'])) { // Already defined - dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); + dol_syslog(get_class($this)."::buildPathFromId fullpath and fulllabel already defined", LOG_WARNING); return; } // First build full array $motherof - //$this->load_motherof(); // Disabled because already done by caller of build_path_from_id_categ + //$this->load_motherof(); // Disabled because already done by caller of buildPathFromId // $this->cats[$id_categ] is supposed to be already an array. We just want to complete it with property fullpath and fulllabel diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index f99a567a314..fb9b2a35dd0 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -627,10 +627,10 @@ class EcmDirectory extends CommonObject * date_c Date creation * fk_user_c User creation * login_c Login creation - * fullpath Full path of id (Added by build_path_from_id_categ call) - * fullrelativename Full path name (Added by build_path_from_id_categ call) - * fulllabel Full label (Added by build_path_from_id_categ call) - * level Level of line (Added by build_path_from_id_categ call) + * fullpath Full path of id (Added by buildPathFromId call) + * fullrelativename Full path name (Added by buildPathFromId call) + * fulllabel Full label (Added by buildPathFromId call) + * level Level of line (Added by buildPathFromId call) * * @param int $force Force reload of full arbo even if already loaded in cache $this->cats * @return array Tableau de array @@ -698,10 +698,10 @@ class EcmDirectory extends CommonObject // We add properties fullxxx to all elements foreach ($this->cats as $key => $val) { - if (isset($motherof[$key])) { + if (isset($this->motherof[$key])) { continue; } - $this->build_path_from_id_categ($key, 0); + $this->buildPathFromId($key, 0); } $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); @@ -710,7 +710,6 @@ class EcmDirectory extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all its childs. * Separator between directories is always '/', whatever is OS. @@ -719,9 +718,8 @@ class EcmDirectory extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - public function build_path_from_id_categ($id_categ, $protection = 0) + private function buildPathFromId($id_categ, $protection = 0) { - // phpcs:enable // Define fullpath if (!empty($this->cats[$id_categ]['id_mere'])) { $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; @@ -745,7 +743,7 @@ class EcmDirectory extends CommonObject } if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) { foreach ($this->cats[$id_categ]['id_children'] as $key => $val) { - $this->build_path_from_id_categ($val, $protection); + $this->buildPathFromId($val, $protection); } } } From 798c7a8a0bdb1bba11c802b24d08a964d14b3431 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 6 Apr 2022 14:09:44 +0200 Subject: [PATCH 358/752] try with tzserver --- htdocs/core/boxes/box_birthdays.php | 2 +- htdocs/user/card.php | 8 ++++---- htdocs/user/class/user.class.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index be0abcdfdde..02c39c2f625 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -119,7 +119,7 @@ class box_birthdays extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day", 'tzserver').' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 23437a7564c..ebb001e6ca9 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1255,7 +1255,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Date birth print '
'; print ''; print "\n"; @@ -1565,7 +1565,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Date of birth print ''; print ''; print "\n"; @@ -2712,9 +2712,9 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; print "\n"; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2b284f6878e..04eebd6b6c9 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1731,7 +1731,7 @@ class User extends CommonObject $sql .= ", login = '".$this->db->escape($this->login)."'"; $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null"); $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' - $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth)."'" : 'null'); + $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth, 'tzserver')."'" : 'null'); if (!empty($user->admin)) { $sql .= ", admin = ".(int) $this->admin; // admin flag can be set/unset only by an admin user } From 9459971ba4412815b005f6d6680b683587afac93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 14:53:22 +0200 Subject: [PATCH 359/752] Removed the awful "group by" on list of invoices. Add index on datef. --- htdocs/compta/facture/list.php | 21 ++++++++++++++----- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ .../install/mysql/tables/llx_facture.key.sql | 1 + htdocs/install/mysql/tables/llx_facture.sql | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c92b744c03f..02c0ec21e7a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -194,12 +194,12 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen $fieldstosearchall = array( 'f.ref'=>'Ref', 'f.ref_client'=>'RefCustomer', - 'pd.description'=>'Description', + 'f.note_public'=>'NotePublic', 's.nom'=>"ThirdParty", 's.name_alias'=>"AliasNameShort", 's.zip'=>"Zip", 's.town'=>"Town", - 'f.note_public'=>'NotePublic', + 'pd.description'=>'Description', ); if (empty($user->socid)) { $fieldstosearchall["f.note_private"] = "NotePrivate"; @@ -568,11 +568,14 @@ $sql .= ' state.code_departement as state_code, state.nom as state_name,'; $sql .= ' country.code as country_code,'; $sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,'; $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender'; -// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) -// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. +// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0). +// A Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. +// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles. +/* if (!$sall) { $sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed'; } +*/ if ($search_categ_cus && $search_categ_cus != -1) { $sql .= ", cc.fk_categorie, cc.fk_soc"; } @@ -598,9 +601,13 @@ $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; } + +// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles. +/* if (!$sall) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; } +*/ if ($sall || $search_product_category > 0) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; } @@ -798,6 +805,8 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles. +/* if (!$sall) { $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.fk_soc, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,'; $sql .= ' f.localtax1, f.localtax2,'; @@ -827,6 +836,8 @@ if (!$sall) { $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; } else { +*/ +if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } @@ -1624,7 +1635,7 @@ if ($resql) { print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['f.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type", "", $param, 'class="right"', $sortfield, $sortorder); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 16e2943045a..fdb34f2191e 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -99,6 +99,8 @@ ALTER TABLE llx_partnership ADD UNIQUE INDEX uk_fk_type_fk_member (fk_type, fk_m -- v16 +ALTER TABLE llx_facture ADD INDEX idx_facture_datef (datef); + ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL; INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_MODIFY','Customer proposal modified','Executed when a customer proposal is modified','propal',2); diff --git a/htdocs/install/mysql/tables/llx_facture.key.sql b/htdocs/install/mysql/tables/llx_facture.key.sql index a46e27c851d..ee25f8c09d8 100644 --- a/htdocs/install/mysql/tables/llx_facture.key.sql +++ b/htdocs/install/mysql/tables/llx_facture.key.sql @@ -29,6 +29,7 @@ ALTER TABLE llx_facture ADD INDEX idx_facture_fk_projet (fk_projet); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_account (fk_account); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_currency (fk_currency); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut); +ALTER TABLE llx_facture ADD INDEX idx_facture_datef (datef); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index d701005666c..8c7e2db385c 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -26,7 +26,7 @@ create table llx_facture ( rowid integer AUTO_INCREMENT PRIMARY KEY, - ref varchar(30) NOT NULL, -- invoice reference number + ref varchar(30) NOT NULL, -- invoice reference number entity integer DEFAULT 1 NOT NULL, -- multi company id ref_ext varchar(255), -- reference into an external system (not used by dolibarr) From 69eaf1e708867db595f32182b8fd731dfb53ab5d Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 6 Apr 2022 14:59:18 +0200 Subject: [PATCH 360/752] Rework some code --- htdocs/mrp/class/mo.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index f3600960706..147a600cbc2 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -783,9 +783,9 @@ class Mo extends CommonObject $codemovementCancel = $langs->trans("StockIncrease"); if (($qtytoprocess >= 0)) { - $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $movement->batch, $codemovementCancel); + $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel); } else { - $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $movement->batch, $codemovementCancel); + $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel); } if ($idstockmove < 0) { $this->error++; @@ -801,16 +801,15 @@ class Mo extends CommonObject $lineDetails = $arrayoflines[$key]; $productstatic->fetch($lineDetails['fk_product']); $qtytoprocess = $lineDetails['qty']; - $id_product_batch = (! empty($lineDetails['batch']) ? $lineDetails['batch'] : 0); // Reverse stock movement $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); $codemovementCancel = $langs->trans("StockIncrease"); if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', '', dol_now(), $id_product_batch, $codemovementCancel); + $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel); } else { - $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', '', $id_product_batch, $codemovementCancel); + $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel); } if ($idstockmove < 0) { $this->error++; From de6e3c6d5513a1255d50124e2f7e6779e47510f5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 6 Apr 2022 13:19:34 +0000 Subject: [PATCH 361/752] Fixing style errors. --- htdocs/mrp/class/mo.class.php | 120 +++++++++++++++++----------------- htdocs/mrp/mo_production.php | 12 ++-- 2 files changed, 65 insertions(+), 67 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 147a600cbc2..2c0773dd9be 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -750,81 +750,79 @@ class Mo extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - global $langs; - $langs->load('stocks'); + global $langs; + $langs->load('stocks'); if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } - $productstatic = new Product($this->db); - $fk_movement = GETPOST('fk_movement', 'int'); - $arrayoflines = $this->fetchLinesLinked('consumed', $idline); + $productstatic = new Product($this->db); + $fk_movement = GETPOST('fk_movement', 'int'); + $arrayoflines = $this->fetchLinesLinked('consumed', $idline); - if (! empty($arrayoflines)) { - $this->db->begin(); + if (! empty($arrayoflines)) { + $this->db->begin(); - $stockmove = new MouvementStock($this->db); - $stockmove->setOrigin($this->element, $this->id); + $stockmove = new MouvementStock($this->db); + $stockmove->setOrigin($this->element, $this->id); - if (! empty($fk_movement)) { - $moline = new MoLine($this->db); - $TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement)); - $moline = array_shift($TArrayMoLine); + if (! empty($fk_movement)) { + $moline = new MoLine($this->db); + $TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement)); + $moline = array_shift($TArrayMoLine); - $movement = new MouvementStock($this->db); - $movement->fetch($fk_movement); - $productstatic->fetch($movement->product_id); - $qtytoprocess = $movement->qty; + $movement = new MouvementStock($this->db); + $movement->fetch($fk_movement); + $productstatic->fetch($movement->product_id); + $qtytoprocess = $movement->qty; - // Reverse stock movement - $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); - $codemovementCancel = $langs->trans("StockIncrease"); + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); - if (($qtytoprocess >= 0)) { - $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel); - } else { - $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel); - } - if ($idstockmove < 0) { - $this->error++; - $this->db->rollback(); - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } else { - $this->db->commit(); - } - return $moline->delete($user, $notrigger); - } - else { - foreach ($arrayoflines as $key => $arrayofline) { - $lineDetails = $arrayoflines[$key]; - $productstatic->fetch($lineDetails['fk_product']); - $qtytoprocess = $lineDetails['qty']; + if (($qtytoprocess >= 0)) { + $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + return $moline->delete($user, $notrigger); + } else { + foreach ($arrayoflines as $key => $arrayofline) { + $lineDetails = $arrayoflines[$key]; + $productstatic->fetch($lineDetails['fk_product']); + $qtytoprocess = $lineDetails['qty']; - // Reverse stock movement - $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); - $codemovementCancel = $langs->trans("StockIncrease"); + // Reverse stock movement + $labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref); + $codemovementCancel = $langs->trans("StockIncrease"); - if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel); - } else { - $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel); - } - if ($idstockmove < 0) { - $this->error++; - $this->db->rollback(); - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } else { - $this->db->commit(); - } - } - return $this->deleteLineCommon($user, $idline, $notrigger); - } - } - else { - return $this->deleteLineCommon($user, $idline, $notrigger); - } + if ($qtytoprocess >= 0) { + $idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel); + } else { + $idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel); + } + if ($idstockmove < 0) { + $this->error++; + $this->db->rollback(); + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } else { + $this->db->commit(); + } + } + return $this->deleteLineCommon($user, $idline, $notrigger); + } + } else { + return $this->deleteLineCommon($user, $idline, $notrigger); + } } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index ba04152bd7d..fc9f5ee1a11 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -970,12 +970,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Action delete line if ($permissiontodelete) { - $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); - print ''; + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']); + print ''; } print ''; From c2f2f982357b95c7ff205f426cc7b41e2d28fdad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 15:25:10 +0200 Subject: [PATCH 362/752] css --- htdocs/compta/paymentbybanktransfer/index.php | 2 +- htdocs/compta/prelevement/index.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index b8675b3a7e5..70379b8285c 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -159,7 +159,7 @@ if ($resql) { print ''; print ''; print ''; print ''; print '
' . $langs->trans('ExpenseReportApplyTo') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . '' . $langs->trans('Type') . '' . $langs->trans('ExpenseReportLimitOn') . '' . $langs->trans('ExpenseReportDateStart') . '' . $langs->trans('ExpenseReportDateEnd') . '' . $langs->trans('ExpenseReportLimitAmount') . '' . $langs->trans('ExpenseReportRestrictive') . ' 
'; + print ''; + print img_picto('', 'delete'); + print ''; + print '
'.$langs->trans("DateOfBirth").''; - print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0); + print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0, 0, '', 0, '', '', 1, '', '', 'tzserver'); print '
'.$langs->trans("DateOfBirth").''; - print dol_print_date($object->birth, 'day'); + print dol_print_date($object->birth, 'day', 'tzserver'); print '
'.$langs->trans("DateOfBirth").''; if ($caneditfield) { - echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0); + echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); } else { - print dol_print_date($object->birth, 'day'); + print dol_print_date($object->birth, 'day', 'tzserver'); } print '
'; - print ''; - print img_picto('', 'delete'); - print ''; - print ''; + print ''; + print img_picto('', 'delete'); + print ''; + print '
'; - print price($obj->amount); + print ''.price($obj->amount).''; print ''; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 4aef7e8b9e4..63c8bbcf344 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -148,6 +148,7 @@ if ($resql) { $thirdpartystatic->id = $obj->socid; $thirdpartystatic->name = $obj->name; $thirdpartystatic->email = $obj->email; + $thirdpartystatic->tva_intra = $obj->tva_intra; print '
'; print $invoicestatic->getNomUrl(1, 'withdraw'); @@ -158,7 +159,7 @@ if ($resql) { print ''; - print price($obj->amount); + print ''.price($obj->amount).''; print ''; From 2e91b0107af160b6bd629a11c015397067157362 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 15:35:49 +0200 Subject: [PATCH 363/752] Fix missing data in tooltip --- htdocs/compta/paymentbybanktransfer/index.php | 11 ++++++++++- htdocs/compta/prelevement/index.php | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 70379b8285c..1bdbaa33da8 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -102,7 +102,7 @@ print '

'; */ $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; $sql .= " pfd.date_demande, pfd.amount,"; -$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra"; +$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { @@ -149,6 +149,15 @@ if ($resql) { $thirdpartystatic->name = $obj->name; $thirdpartystatic->email = $obj->email; $thirdpartystatic->tva_intra = $obj->tva_intra; + $thirdpartystatic->siren = $obj->idprof1; + $thirdpartystatic->siret = $obj->idprof2; + $thirdpartystatic->ape = $obj->idprof3; + $thirdpartystatic->idprof1 = $obj->idprof1; + $thirdpartystatic->idprof2 = $obj->idprof2; + $thirdpartystatic->idprof3 = $obj->idprof3; + $thirdpartystatic->idprof4 = $obj->idprof4; + $thirdpartystatic->idprof5 = $obj->idprof5; + $thirdpartystatic->idprof6 = $obj->idprof6; print ''; print $invoicestatic->getNomUrl(1, 'withdraw'); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 63c8bbcf344..fc640eccc1c 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -102,7 +102,7 @@ print '

'; */ $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; $sql .= " pfd.date_demande, pfd.amount,"; -$sql .= " s.nom as name, s.email, s.rowid as socid"; +$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { @@ -149,6 +149,15 @@ if ($resql) { $thirdpartystatic->name = $obj->name; $thirdpartystatic->email = $obj->email; $thirdpartystatic->tva_intra = $obj->tva_intra; + $thirdpartystatic->siren = $obj->idprof1; + $thirdpartystatic->siret = $obj->idprof2; + $thirdpartystatic->ape = $obj->idprof3; + $thirdpartystatic->idprof1 = $obj->idprof1; + $thirdpartystatic->idprof2 = $obj->idprof2; + $thirdpartystatic->idprof3 = $obj->idprof3; + $thirdpartystatic->idprof4 = $obj->idprof4; + $thirdpartystatic->idprof5 = $obj->idprof5; + $thirdpartystatic->idprof6 = $obj->idprof6; print ''; print $invoicestatic->getNomUrl(1, 'withdraw'); From 0b8f4489c87f6ab24c19b5c086c46fd40540ddbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 15:55:43 +0200 Subject: [PATCH 364/752] css --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 7405fcedb18..dedb1ad445d 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1469,7 +1469,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (!empty($conf->prelevement->enabled)) { $colspan += 2; } - print ''.$langs->trans("NoBANRecord").''; + print ''.$langs->trans("NoBANRecord").''; } print ''; From 5a8d5618f2cbf6bb5397c6c59c678ea7c876cb20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 16:15:34 +0200 Subject: [PATCH 365/752] Fix error message on IBAN/BIC validation --- htdocs/compta/bank/class/account.class.php | 8 ++++++-- htdocs/compta/prelevement/create.php | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c2745b31426..5a484e9e97c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1441,9 +1441,13 @@ class Account extends CommonObject // Call function to check BAN - if (!checkIbanForAccount($this) || !checkSwiftForAccount($this)) { + if (!checkIbanForAccount($this)) { $this->error_number = 12; - $this->error_message = 'IBANSWIFTControlError'; + $this->error_message = 'IBANNotValid'; + } + if (!checkSwiftForAccount($this)) { + $this->error_number = 12; + $this->error_message = 'SwiftNotValid'; } /*if (! checkBanForAccount($this)) { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 3f00a4f0660..1049ce4cf1a 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -449,9 +449,17 @@ if ($resql) { // RIB print ''; - print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic; - if ($bac->verif() <= 0) { - print img_warning('Error on default bank number for IBAN : '.$bac->error_message); + if ($bac->id > 0) { + if (!empty($bac->iban) || !empty($bac->bic)) { + print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic; + if ($bac->verif() <= 0) { + print img_warning('Error on default bank number for IBAN : '.$langs->trans($bac->error_message)); + } + } else { + print img_warning($langs->trans("IBANNotDefined")); + } + } else { + print img_warning($langs->trans("NoBankAccountDefined")); } print ''; From 33b5605a728eb3120081918145300eb154a0b751 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 16:49:59 +0200 Subject: [PATCH 366/752] Code comment --- .../prelevement/class/bonprelevement.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index e5697ab3cb3..27c96bd47db 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -918,7 +918,7 @@ class BonPrelevement extends CommonObject if (!$error) { $ref = substr($year, -2).$month; - $sql = "SELECT substring(ref from char_length(ref) - 1)"; + $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX" $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " WHERE ref LIKE '%".$this->db->escape($ref)."%'"; $sql .= " AND entity = ".((int) $conf->entity); @@ -929,8 +929,14 @@ class BonPrelevement extends CommonObject if ($resql) { $row = $this->db->fetch_row($resql); - $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0]) + 1, 0, 2), 2, "0", STR_PAD_LEFT); + // Build the new ref + $ref = "T".$ref.str_pad(dol_substr("00".(intval($row[0]) + 1), 0, 2), 2, "0", STR_PAD_LEFT); + + // $conf->abc->dir_output may be: + // /home/ldestailleur/git/dolibarr_15.0/documents/abc/ + // or + // /home/ldestailleur/git/dolibarr_15.0/documents/X/abc with X >= 2 with multicompany. if ($type != 'bank-transfer') { $dir = $conf->prelevement->dir_output.'/receipts'; } else { @@ -947,7 +953,7 @@ class BonPrelevement extends CommonObject $sql .= "ref, entity, datec, type"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($ref)."'"; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".($type == 'bank-transfer' ? 'bank-transfer' : 'debit-order')."'"; $sql .= ")"; From 8f93584f974c9d15b62def68694325251cabc352 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 16:56:23 +0200 Subject: [PATCH 367/752] Fix trans --- htdocs/compta/paymentbybanktransfer/index.php | 2 +- htdocs/langs/en_US/withdrawals.lang | 1 + htdocs/langs/fr_FR/withdrawals.lang | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 1bdbaa33da8..bf7e31611d2 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -90,7 +90,7 @@ print $bprev->nbOfInvoiceToPay('bank-transfer'); print ''; print ''; -print ''.$langs->trans("AmountToWithdraw").''; +print ''.$langs->trans("AmountToTransfer").''; print ''; print price($bprev->SommeAPrelever('bank-transfer'), '', '', 1, -1, -1, 'auto'); print '

'; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index eb25d563f62..9d145ef354d 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -31,6 +31,7 @@ SupplierInvoiceWaitingWithdraw=Vendor invoice waiting for payment by credit tran InvoiceWaitingWithdraw=Invoice waiting for direct debit InvoiceWaitingPaymentByBankTransfer=Invoice waiting for credit transfer AmountToWithdraw=Amount to withdraw +AmountToTransfer=Amount to transfer NoInvoiceToWithdraw=No invoice open for '%s' is waiting. Go on tab '%s' on invoice card to make a request. NoSupplierInvoiceToWithdraw=No supplier invoice with open 'Direct credit requests' is waiting. Go on tab '%s' on invoice card to make a request. ResponsibleUser=User Responsible diff --git a/htdocs/langs/fr_FR/withdrawals.lang b/htdocs/langs/fr_FR/withdrawals.lang index fae9c7e2f78..03b60e71bca 100644 --- a/htdocs/langs/fr_FR/withdrawals.lang +++ b/htdocs/langs/fr_FR/withdrawals.lang @@ -31,6 +31,7 @@ SupplierInvoiceWaitingWithdraw=Facture fournisseur en attente de paiement par vi InvoiceWaitingWithdraw=Factures en attente de prélèvement InvoiceWaitingPaymentByBankTransfer=Facture en attente de virement AmountToWithdraw=Somme à prélever +AmountToTransfer=Somme à transferrer NoInvoiceToWithdraw=Aucune facture ouverte pour '%s' n'est en attente. Allez sur l'onglet '%s' sur la facture pour faire une demande. NoSupplierInvoiceToWithdraw=Aucune facture fournisseur avec des demandes de virement ouvertes n'est en attente. Allez sur l'onglet '%s' sur la fiche facture pour faire une demande. ResponsibleUser=Utilisateur responsable From 32875a1e6ca5cd20e171815e18c8b66a02ff05f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 17:06:49 +0200 Subject: [PATCH 368/752] Fix trans --- htdocs/compta/paymentbybanktransfer/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index bf7e31611d2..6c14987e5ba 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -66,7 +66,7 @@ if (prelevement_check_config('bank-transfer') < 0) { $newcardbutton = ''; if ($usercancreate) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type=bank-transfer'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewPaymentByBankTransfer'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type=bank-transfer'); } print load_fiche_titre($langs->trans("SuppliersStandingOrdersArea"), $newcardbutton); From 091ca31b6cc661edc38ded9b1b4d0947a4740fb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 17:32:56 +0200 Subject: [PATCH 369/752] NEW Add method hintindex() in database handlers. --- htdocs/compta/facture/list.php | 31 ++++++++++++++++++++----------- htdocs/core/db/DoliDB.class.php | 11 +++++++++++ htdocs/core/db/mysqli.class.php | 13 +++++++++++++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 06da94e8e2b..eedc3297018 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -598,6 +598,9 @@ if (!empty($search_categ_cus) && $search_categ_cus != '-1') { } $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; +if ($sortfield == "f.datef") { + $sql .= $db->hintindex('idx_facture_datef'); +} if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; } @@ -846,14 +849,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -$sql .= ' ORDER BY '; -$listfield = explode(',', $sortfield); -$listorder = explode(',', $sortorder); -foreach ($listfield as $key => $value) { - $sql .= $listfield[$key].' '.($listorder[$key] ? $listorder[$key] : 'DESC').','; -} -$sql .= ' f.rowid DESC '; - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* This old and fast method to get and count full list returns all record so use a high amount of memory. @@ -870,8 +865,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; @@ -880,7 +879,17 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= ' ORDER BY '; +$listfield = explode(',', $sortfield); +$listorder = explode(',', $sortorder); +foreach ($listfield as $key => $value) { + $sql .= $listfield[$key].' '.($listorder[$key] ? $listorder[$key] : 'DESC').','; +} +$sql .= ' f.rowid DESC '; +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 66e54a4fc3c..aae315ec992 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -96,6 +96,17 @@ abstract class DoliDB implements Database return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } + /** + * Return SQL string to force an index + * + * @param string $nameofindex Name of index + * @return string SQL string + */ + public function hintindex($nameofindex) + { + return ''; + } + /** * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. * Function to use to build INSERT, UPDATE or WHERE predica diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 81a331add8a..582fd08811f 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -168,6 +168,18 @@ class DoliDBMysqli extends DoliDB } + /** + * Return SQL string to force an index + * + * @param string $nameofindex Name of index + * @return string SQL string + */ + public function hintindex($nameofindex) + { + return " FORCE INDEX(".preg_replace('/[^a-z0-9_]/', '', $nameofindex).")"; + } + + /** * Convert a SQL request in Mysql syntax to native syntax * @@ -180,6 +192,7 @@ class DoliDBMysqli extends DoliDB return $line; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database From 4f1e280355badfbb46527acbf81a56c36084e223 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 6 Apr 2022 20:09:50 +0200 Subject: [PATCH 370/752] Update interface_80_modStripe_Stripe.class.php add D at THIR-D-PARTY if (!empty($conf->global->STRIPE_DELETE_STRIPE_ACCOUNT_WHEN_DELETING_THIRDPARTY)) --- htdocs/core/triggers/interface_80_modStripe_Stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 0e571f26c98..dfac4c5b84d 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -183,7 +183,7 @@ class InterfaceStripe extends DolibarrTriggers if ($action == 'COMPANY_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->STRIPE_DELETE_STRIPE_ACCOUNT_WHEN_DELETING_THIRPARTY)) { + if (!empty($conf->global->STRIPE_DELETE_STRIPE_ACCOUNT_WHEN_DELETING_THIRDPARTY)) { // By default, we do not delete the stripe account. We may need to reuse it with its payment_intent, for example if delete is for a merge of thirdparties. $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. From 9db2f2c3f235f5dedd14c568e7e906955002c65c Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 6 Apr 2022 20:12:35 +0200 Subject: [PATCH 371/752] Update company.lib.php add D of THIR-D-PARTIES ($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB) --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index b8b6d1c728a..197a6c95687 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -180,7 +180,7 @@ function societe_prepare_head(Societe $object) // Related items if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) - && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) { + && empty($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; $head[$h][1] = $langs->trans("Referers"); $head[$h][2] = 'consumption'; From 81e68c892d292ec9633a3001b06dda69467c58ad Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 6 Apr 2022 20:43:07 +0200 Subject: [PATCH 372/752] Update currencies_iso-4217.txt --- dev/resources/iso-normes/currencies_iso-4217.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dev/resources/iso-normes/currencies_iso-4217.txt b/dev/resources/iso-normes/currencies_iso-4217.txt index bc392b72e9c..e24faa4283e 100644 --- a/dev/resources/iso-normes/currencies_iso-4217.txt +++ b/dev/resources/iso-normes/currencies_iso-4217.txt @@ -1,8 +1,12 @@ # File of all ISO-4217 currencies codes -# http://en.wikipedia.org/wiki/ISO_4217 -# http://fx.sauder.ubc.ca/currency_table.html for symbols for 2 letter code # -# Code,Name,Nb decimals +# https://en.wikipedia.org/wiki/ISO_4217 +# https://en.wikipedia.org/wiki/Currency_symbol for symbols for 2 letter code +# + + +# Code, Currency Name, Nb decimals + AED,UAE Dirham,2 AFN,Afghanistan Afghani,2 ALL,Albanian Lek,2 From afdefad55b998f1b040b108715d2f445c6e02833 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 21:01:04 +0200 Subject: [PATCH 373/752] FIX bad link to add a customer price (token duplicated) --- htdocs/product/price.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 42066170f17..47322e2c692 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1298,7 +1298,7 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''; + print ''; } else { print '
' . $langs->trans("AddCustomerPrice") . '
'; } From 2e890d9d283e36e27b422cd6a6ed527667dfb69e Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 6 Apr 2022 21:08:23 +0200 Subject: [PATCH 374/752] Update societe.class.php note_public => NotePublic note_private => NotePrivate see #20419 --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 015a8c92af6..25d2831f853 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -193,8 +193,8 @@ class Societe extends CommonObject 'tva_intra' =>array('type'=>'varchar(20)', 'label'=>'Tva intra', 'enabled'=>1, 'visible'=>-1, 'position'=>210), 'capital' =>array('type'=>'double(24,8)', 'label'=>'Capital', 'enabled'=>1, 'visible'=>-1, 'position'=>215), 'fk_stcomm' =>array('type'=>'integer', 'label'=>'CommercialStatus', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>220), - 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>225), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>230), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>225), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>230), 'prefix_comm' =>array('type'=>'varchar(5)', 'label'=>'Prefix comm', 'enabled'=>'$conf->global->SOCIETE_USEPREFIX', 'visible'=>-1, 'position'=>235), 'client' =>array('type'=>'tinyint(4)', 'label'=>'Client', 'enabled'=>1, 'visible'=>-1, 'position'=>240), 'fournisseur' =>array('type'=>'tinyint(4)', 'label'=>'Fournisseur', 'enabled'=>1, 'visible'=>-1, 'position'=>245), From 524b001f3b565e5741c75f347f3e2a73a7ad864d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Apr 2022 21:14:35 +0200 Subject: [PATCH 375/752] Add $dolibarr_main_restrict_os_commands in security center. --- htdocs/admin/system/security.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 40656928824..8a480ea49ca 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -266,10 +266,20 @@ print '
'; print '$dolibarr_main_restrict_ip: '; if (empty($dolibarr_main_restrict_ip)) { - print ''.$langs->trans("None").''; + print $langs->trans("None"); //print ' ('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')'; +} else { + print $dolibarr_main_restrict_ip; } +print '
'; +print '$dolibarr_main_restrict_os_commands: '; +if (empty($dolibarr_main_restrict_os_commands)) { + print $langs->trans("None"); +} else { + print $dolibarr_main_restrict_os_commands; +} +print ' ('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore').')'; print '
'; if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) { From ed1bdd26dbbf1e3b20ba3483d212df5358ac0435 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 00:09:11 +0200 Subject: [PATCH 376/752] Rename some jobs --- htdocs/core/modules/modFacture.class.php | 4 ++-- htdocs/core/modules/modFournisseur.class.php | 4 ++-- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 3 +++ htdocs/langs/en_US/bills.lang | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index b64ecca6cc1..817fa1b53cf 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -113,7 +113,7 @@ class modFacture extends DolibarrModules $datestart = dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( 0 => array( - 'label'=>'RecurringInvoices', + 'label'=>'RecurringInvoicesJob', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', @@ -122,7 +122,7 @@ class modFacture extends DolibarrModules 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, - 'priority'=>50, + 'priority'=>51, 'status'=>1, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 708cd1fb408..aef28514c61 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -133,7 +133,7 @@ class modFournisseur extends DolibarrModules $datestart = dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( 0 => array( - 'label'=>'RecurringSupplierInvoices', + 'label'=>'RecurringSupplierInvoicesJob', 'jobtype'=>'method', 'class'=>'fourn/class/fournisseur.facture-rec.class.php', 'objectname'=>'FactureFournisseurRec', @@ -142,7 +142,7 @@ class modFournisseur extends DolibarrModules 'comment'=>'Generate recurring supplier invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, - 'priority'=>50, + 'priority'=>51, 'status'=>1, 'datestart'=>$datestart )); diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index fdb34f2191e..7aa4ff82e4b 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -99,6 +99,9 @@ ALTER TABLE llx_partnership ADD UNIQUE INDEX uk_fk_type_fk_member (fk_type, fk_m -- v16 +UPDATE llx_cronjob set label = 'RecurringInvoicesJob' where label = 'RecurringInvoices'; +UPDATE llx_cronjob set label = 'RecurringSupplierInvoicesJob' where label = 'RecurringSupplierInvoices'; + ALTER TABLE llx_facture ADD INDEX idx_facture_datef (datef); ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index eada0da8899..a70d2eb8f21 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -283,6 +283,8 @@ RecurringInvoices=Recurring invoices RecurringInvoice=Recurring invoice RepeatableInvoice=Template invoice RepeatableInvoices=Template invoices +RecurringInvoicesJob=Generation of recurring invoices (sales invoices) +RecurringSupplierInvoicesJob=Generation of recurring invoices (purchase invoices) Repeatable=Template Repeatables=Templates ChangeIntoRepeatableInvoice=Convert into template invoice From 291002fe1129a050bd1031198ba81a90a69992e4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 7 Apr 2022 10:31:54 +0200 Subject: [PATCH 377/752] fix: bad poermission int modulebuilder template --- htdocs/modulebuilder/template/myobject_document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index d1040364182..aa213461e24 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -132,7 +132,7 @@ if ($enablepermissioncheck) { $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php } else { $permissiontoread = 1; - $permission = 1; + $permissiontoadd = 1; } // Security check (enable the most restrictive one) From 9ffe82e25937983ca5f2c2ed14699b7c8857fd65 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 7 Apr 2022 10:32:23 +0200 Subject: [PATCH 378/752] FIX : originproductline array td identification --- htdocs/core/class/commonobject.class.php | 16 ++++++++-------- htdocs/core/tpl/originproductline.tpl.php | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1064d34561d..02421ea9157 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4805,18 +4805,18 @@ abstract class CommonObject global $langs, $hookmanager, $conf, $form; print ''; - print ''.$langs->trans('Ref').''; - print ''.$langs->trans('Description').''; - print ''.$langs->trans('VATRate').''; - print ''.$langs->trans('PriceUHT').''; + print ''.$langs->trans('Ref').''; + print ''.$langs->trans('Description').''; + print ''.$langs->trans('VATRate').''; + print ''.$langs->trans('PriceUHT').''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans('PriceUHTCurrency').''; + print ''.$langs->trans('PriceUHTCurrency').''; } - print ''.$langs->trans('Qty').''; + print ''.$langs->trans('Qty').''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''.$langs->trans('Unit').''; + print ''.$langs->trans('Unit').''; } - print ''.$langs->trans('ReductionShort').''; + print ''.$langs->trans('ReductionShort').''; print ''.$form->showCheckAddButtons('checkforselect', 1).''; print ''; $i = 0; diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index d4943ac454d..93c2bd3a8df 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -27,20 +27,20 @@ if (empty($conf) || !is_object($conf)) { tpl['strike']) ? '' : ' strikefordisabled').'">'; -print ''.$this->tpl['label'].''; -print ''.$this->tpl['description'].''; -print ''.$this->tpl['vat_rate'].''; -print ''.$this->tpl['price'].''; +print ''.$this->tpl['label'].''; +print ''.$this->tpl['description'].''; +print ''.$this->tpl['vat_rate'].''; +print ''.$this->tpl['price'].''; if (!empty($conf->multicurrency->enabled)) { - print ''.$this->tpl['multicurrency_price'].''; + print ''.$this->tpl['multicurrency_price'].''; } -print ''.$this->tpl['qty'].''; +print ''.$this->tpl['qty'].''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''.$langs->trans($this->tpl['unit']).''; + print ''.$langs->trans($this->tpl['unit']).''; } -print ''.$this->tpl['remise_percent'].''; +print ''.$this->tpl['remise_percent'].''; $selected = 1; if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) { From 35ee6096b6346a489ac9f8434f2248be72b4d52f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 7 Apr 2022 10:38:46 +0200 Subject: [PATCH 379/752] FIX increased the size of the "note" field --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_actioncomm.sql | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 7aa4ff82e4b..634e17b33b4 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -312,3 +312,6 @@ UPDATE llx_c_availability SET type_duration = 'w', qty = 4 WHERE code = 'AV_4W'; ALTER TABLE llx_boxes_def ADD COLUMN fk_user integer DEFAULT 0 NOT NULL; ALTER TABLE llx_contratdet ADD COLUMN rang integer DEFAULT 0 AFTER info_bits; + +ALTER TABLE llx_actioncomm MODIFY COLUMN note mediumtext; + diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 2f3f7660698..d4d0b65ef25 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -55,7 +55,7 @@ create table llx_actioncomm durationp real, -- planed duration label varchar(255) NOT NULL, -- label/title of event or topic of email - note text, -- private note of event or content of email + note mediumtext, -- private note of event or content of email calling_duration integer, -- when event is a phone call, duration of phone call From 75b74a5fd352c94e51f17fc22fafbf0edda04533 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 7 Apr 2022 10:43:31 +0200 Subject: [PATCH 380/752] FIX : identification new td --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/tpl/originproductline.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 59d6ab59f34..62a8038d4d4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4948,7 +4948,7 @@ abstract class CommonObject print ''.$langs->trans('Unit').''; } print ''.$langs->trans('ReductionShort').''; - print ''.$langs->trans('TotalHT').''; + print ''.$langs->trans('TotalHT').''; print ''.$form->showCheckAddButtons('checkforselect', 1).''; print ''; $i = 0; diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index dfbf2ac3ea4..c19ef7bcf59 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -41,7 +41,7 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { } print ''.$this->tpl['remise_percent'].''; -print ''.$this->tpl['total_ht'].''; +print ''.$this->tpl['total_ht'].''; $selected = 1; if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) { From 49a0485427cc0e126fa0eaf50612eb6f2a905e1c Mon Sep 17 00:00:00 2001 From: habot-it Date: Fri, 18 Feb 2022 08:43:36 +0000 Subject: [PATCH 381/752] Add options in function pdf_pagefoot of pdf.lib.php - Revision --- htdocs/core/lib/pdf.lib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c79cbbca645..278b1aeb512 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1154,8 +1154,6 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } } - $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak - // For customize footer if (is_object($hookmanager)) { $parameters = array('line1' => $line1, 'line2' => $line2, 'line3' => $line3, 'line4' => $line4, 'outputlangs'=>$outputlangs); @@ -1171,7 +1169,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Option for footer background color (without freetext zone) if (!empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', '', $fill_color = array($r, $g, $b)); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } if ($line) { // Free text @@ -1196,7 +1196,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $posy -= $conf->global->PDF_FOOTER_TOP_MARGIN; } else { $posy--; } + if ($conf->global->PDF_FOOTER_DISABLE_PAGEBREAK === '1') { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); + if ($conf->global->PDF_FOOTER_DISABLE_PAGEBREAK === '1') { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak $posy -= $mycustomfooterheight - 3; } else { @@ -1207,7 +1209,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Option for footer background color (without freetext zone) if (!empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', '', $fill_color = array($r, $g, $b)); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } if ($line) { // Free text @@ -1267,8 +1271,6 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); } - $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak - return $marginwithfooter; } From f1771af53cab8827e849c6053369ef692d6c6132 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 7 Apr 2022 11:03:25 +0200 Subject: [PATCH 382/752] FIX : originproductline array td identification data-id --- htdocs/core/tpl/originproductline.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 93c2bd3a8df..6929b23fcad 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -26,7 +26,7 @@ if (empty($conf) || !is_object($conf)) { tpl['strike']) ? '' : ' strikefordisabled').'">'; +print ''; print ''.$this->tpl['label'].''; print ''.$this->tpl['description'].''; print ''.$this->tpl['vat_rate'].''; From ed9435321f764d21c6db6f635d7ae3256eb7a02f Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 6 Apr 2022 21:08:23 +0200 Subject: [PATCH 383/752] Update societe.class.php note_public => NotePublic note_private => NotePrivate see #20419 --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e04c05ddaca..0f7ad23acb0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -193,8 +193,8 @@ class Societe extends CommonObject 'tva_intra' =>array('type'=>'varchar(20)', 'label'=>'Tva intra', 'enabled'=>1, 'visible'=>-1, 'position'=>210), 'capital' =>array('type'=>'double(24,8)', 'label'=>'Capital', 'enabled'=>1, 'visible'=>-1, 'position'=>215), 'fk_stcomm' =>array('type'=>'integer', 'label'=>'CommercialStatus', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>220), - 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>225), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>230), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>225), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>230), 'prefix_comm' =>array('type'=>'varchar(5)', 'label'=>'Prefix comm', 'enabled'=>'$conf->global->SOCIETE_USEPREFIX', 'visible'=>-1, 'position'=>235), 'client' =>array('type'=>'tinyint(4)', 'label'=>'Client', 'enabled'=>1, 'visible'=>-1, 'position'=>240), 'fournisseur' =>array('type'=>'tinyint(4)', 'label'=>'Fournisseur', 'enabled'=>1, 'visible'=>-1, 'position'=>245), From 4693ef42bd10a4d64df843357a20c4c35ca2d9d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 11:18:56 +0200 Subject: [PATCH 384/752] Enhance responsive --- htdocs/comm/propal/card.php | 2 ++ htdocs/commande/card.php | 2 ++ htdocs/compta/facture/card.php | 2 ++ htdocs/fichinter/card.php | 2 ++ htdocs/fourn/commande/card.php | 2 ++ htdocs/fourn/facture/card.php | 2 ++ htdocs/supplier_proposal/card.php | 2 ++ 7 files changed, 14 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 10903ea3556..d73a9769d17 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1892,11 +1892,13 @@ if ($action == 'create') { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); + print '
'; print ''; $objectsrc->printOriginLinesList(); print '
'; + print '
'; } } elseif ($object->id > 0) { /* diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index e8f88800693..b54784a82b2 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1862,11 +1862,13 @@ if ($action == 'create' && $usercancreate) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); + print '
'; print ''; $objectsrc->printOriginLinesList('', $selectedLines); print '
'; + print '
'; } print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 102e0cf7f4a..2273fc27c3b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3815,11 +3815,13 @@ if ($action == 'create') { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); + print '
'; print ''; $objectsrc->printOriginLinesList('', $selectedLines); print '
'; + print '
'; } print "\n"; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 80f39e17730..0d7e5278a14 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1003,11 +1003,13 @@ if ($action == 'create') { $title = $langs->trans('Services'); print load_fiche_titre($title); + print '
'; print ''; $objectsrc->printOriginLinesList(empty($conf->global->FICHINTER_PRINT_PRODUCTS) ? 'services' : ''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on print '
'; + print '
'; } print ''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index b71ba0de941..d895e688080 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1840,11 +1840,13 @@ if ($action == 'create') { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); + print '
'; print ''; $objectsrc->printOriginLinesList('', $selectedLines); print '
'; + print '
'; } print "\n"; } elseif (!empty($object->id)) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index f4d628d5882..37bcd3199c5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2557,11 +2557,13 @@ if ($action == 'create') { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); + print '
'; print ''; $objectsrc->printOriginLinesList('', $selectedLines); print '
'; + print '
'; } print "\n"; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index f0594b90b6f..077300f9386 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1425,11 +1425,13 @@ if ($action == 'create') { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); + print '
'; print ''; $objectsrc->printOriginLinesList(); print '
'; + print '
'; } } else { /* From 5e8f632a9ba8393f44b57a6b0cf5a986f275df12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 11:22:28 +0200 Subject: [PATCH 385/752] Close #20571 --- htdocs/install/mysql/data/llx_c_paiement.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_paiement.sql b/htdocs/install/mysql/data/llx_c_paiement.sql index e29b47639f2..400e2f24276 100644 --- a/htdocs/install/mysql/data/llx_c_paiement.sql +++ b/htdocs/install/mysql/data/llx_c_paiement.sql @@ -30,6 +30,7 @@ -- Types paiement -- +-- Payment modes insert into llx_c_paiement (id,code,libelle,type,active) values ( 1, 'TIP', 'TIP', 2, 0); insert into llx_c_paiement (id,code,libelle,type,active) values ( 2, 'VIR', 'Transfer', 2, 1); insert into llx_c_paiement (id,code,libelle,type,active) values ( 3, 'PRE', 'Debit order', 2, 1); @@ -40,8 +41,10 @@ insert into llx_c_paiement (id,code,libelle,type,active) values (50, 'VAD', 'Onl insert into llx_c_paiement (id,code,libelle,type,active) values (51, 'TRA', 'Traite', 2, 0); insert into llx_c_paiement (id,code,libelle,type,active) values (52, 'LCR', 'LCR', 2, 0); insert into llx_c_paiement (id,code,libelle,type,active) values (53, 'FAC', 'Factor', 2, 0); +-- Payment services INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (100, 'KLA', 'Klarna', 1, 0); INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (101, 'SOF', 'Sofort', 1, 0); INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (102, 'BAN', 'Bancontact', 1, 0); INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (103, 'IDE', 'iDeal', 1, 0); INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (104, 'GIR', 'Giropay', 1, 0); +INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (105, 'PPL', 'PayPal', 1, 0); From 93777f81f367d085c6a7a3f6edc0faab5ab72e3c Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 7 Apr 2022 11:23:27 +0200 Subject: [PATCH 386/752] NEW : identification tr by data-id --- htdocs/core/tpl/originproductline.tpl.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index c19ef7bcf59..55d385fcd50 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Charlie Benke + * Copyright (C) 2022 Gauthier VERDOL * * 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 @@ -26,7 +27,7 @@ if (empty($conf) || !is_object($conf)) { tpl['strike']) ? '' : ' strikefordisabled').'">'; +print ''; print ''.$this->tpl['label'].''; print ''.$this->tpl['description'].''; print ''.$this->tpl['vat_rate'].''; From 06f8af71effc40ba3b04a2c6ebacda1839bbb4d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 11:24:39 +0200 Subject: [PATCH 387/752] Code comment --- htdocs/install/mysql/data/llx_c_paiement.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/data/llx_c_paiement.sql b/htdocs/install/mysql/data/llx_c_paiement.sql index 400e2f24276..a266070da2b 100644 --- a/htdocs/install/mysql/data/llx_c_paiement.sql +++ b/htdocs/install/mysql/data/llx_c_paiement.sql @@ -37,6 +37,7 @@ insert into llx_c_paiement (id,code,libelle,type,active) values ( 3, 'PRE', 'Deb insert into llx_c_paiement (id,code,libelle,type,active) values ( 4, 'LIQ', 'Cash', 2, 1); insert into llx_c_paiement (id,code,libelle,type,active) values ( 6, 'CB', 'Credit card', 2, 1); insert into llx_c_paiement (id,code,libelle,type,active) values ( 7, 'CHQ', 'Cheque', 2, 1); +-- Alternative not common payment modes insert into llx_c_paiement (id,code,libelle,type,active) values (50, 'VAD', 'Online payment', 2, 0); insert into llx_c_paiement (id,code,libelle,type,active) values (51, 'TRA', 'Traite', 2, 0); insert into llx_c_paiement (id,code,libelle,type,active) values (52, 'LCR', 'LCR', 2, 0); From a4b9883eac9a6dbdaf5a967be042cbbf2bd53fd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 13:14:51 +0200 Subject: [PATCH 388/752] Use checkbox instead of combo to save clicks when adding a resource --- htdocs/core/tpl/resource_add.tpl.php | 25 ++++++++++++++++++------- htdocs/resource/element_resource.php | 17 ++++++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index 64d545ba583..5e605337c0c 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -13,9 +13,11 @@ require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; $form = new Form($db); $formresources = new FormResource($db); -$out = '
'; +$out = ''; -$out .= '
'; +$out .= '
'; + +$out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -23,21 +25,30 @@ $out .= ''; $out .= ''; $out .= ''; +$out .= '
'; // Place -$out .= '
'.$langs->trans("SelectResource").'
'; -$out .= '
'; +$out .= '
'.$langs->trans("SelectResource").'
'; +$out .= '
'; $events = array(); $out .= $formresources->select_resource_list('', 'fk_resource', '', 1, 1, 0, $events, '', 2, null); $out .= '
'; -$out .= '
'.$form->selectyesno('busy', (GETPOSTISSET('busy') ? GETPOST('busy') : 1), 1).'
'; -$out .= '
'.$form->selectyesno('mandatory', (GETPOSTISSET('mandatory') ? GETPOST('mandatory') : 0), 1).'
'; +$out .= '
'; +//$out .= $form->selectyesno('busy', (GETPOSTISSET('busy') ? GETPOST('busy') : 1), 1); +$out .= ''; +$out .= '
'; +$out .= '
'; +//$out .= $form->selectyesno('mandatory', (GETPOSTISSET('mandatory') ? GETPOST('mandatory') : 0), 1); +$out .= ''; +$out .= '
'; -$out .= '
'; +$out .= '
'; $out .= ''; $out .= '
'; +$out .= '
'; + $out .= ''; $out .= '
'; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 068dba8c50a..f4c6f3d3856 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -46,10 +46,6 @@ $sortfield = GETPOST('sortfield','alpha'); $page = GETPOST('page','int'); */ -if (!$user->rights->resource->read) { - accessforbidden(); -} - $object = new Dolresource($db); $hookmanager->initHooks(array('element_resource')); @@ -71,11 +67,22 @@ $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $socid = GETPOST('socid', 'int'); +if (empty($mandatory)) { + $mandatory = 0; +} +if (empty($busy)) { + $busy = 0; +} + if ($socid > 0) { // Special for thirdparty $element_id = $socid; $element = 'societe'; } +if (!$user->rights->resource->read) { + accessforbidden(); +} + // Permission is not permission on resources. We just make link here on objects. if ($element == 'action') { $result = restrictedArea($user, 'agenda', $element_id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); @@ -365,7 +372,7 @@ if (!$ret) { print '
'; - print ''; + print '
'; // Type if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { From 485e163cf6df25570c010bd30a88ad1418bd7c17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 13:16:51 +0200 Subject: [PATCH 389/752] default value --- htdocs/core/tpl/resource_add.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index 5e605337c0c..02bc8ce421f 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -40,7 +40,7 @@ $out .= 'trans('Mandatory').' '; //$out .= $form->selectyesno('mandatory', (GETPOSTISSET('mandatory') ? GETPOST('mandatory') : 0), 1); -$out .= ''; +$out .= ''; $out .= ''; $out .= '
'; From 0ed7c643f88886c3820110f0a01b2df01a541f8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 13:28:24 +0200 Subject: [PATCH 390/752] Close #20547 --- htdocs/comm/action/class/actioncomm.class.php | 32 +++++++++++++++++-- htdocs/core/actions_sendmails.inc.php | 8 ++--- ...terface_50_modAgenda_ActionsAuto.class.php | 4 ++- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a5b4f1d8ce9..f93f5aeccb7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -868,6 +868,16 @@ class ActionComm extends CommonObject $this->event_paid = $obj->event_paid; $this->status = $obj->status; + //email information + $this->email_msgid=$obj->email_msgid; + $this->email_from=$obj->email_from; + $this->email_sender=$obj->email_sender; + $this->email_to=$obj->email_to; + $this->email_tocc=$obj->email_tocc; + $this->email_tobcc=$obj->email_tobcc; + $this->email_subject=$obj->email_subject; + $this->errors_to=$obj->errors_to; + $this->fetch_optionals(); if ($loadresources) { @@ -1582,8 +1592,25 @@ class ActionComm extends CommonObject if (isset($this->transparency)) { $tooltip .= '
'.$langs->trans('Busy').': '.yn($this->transparency); } + if (!empty($this->email_msgid)) { + $langs->load("mails"); + $tooltip .= '
'; + //$tooltip .= '
'.img_picto('', 'email').' '.$langs->trans("Email").''; + $tooltip .= '
'.$langs->trans('MailTopic').': '.$this->email_subject; + $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_from); + $tooltip .= '
'.$langs->trans('MailTo').':, '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); + if (!empty($this->email_tocc)) { + $tooltip .= '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_tocc); + } + /* Disabled because bcc must remain by defintion not visible + if (!empty($this->email_tobcc)) { + $tooltip .= '
'.$langs->trans('MailCCC').': '.$this->email_tobcc; + } */ + } if (!empty($this->note_private)) { - $tooltip .= '
'.$langs->trans('Note').': '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '
', $this->note_private)); + $tooltip .= '

'.$langs->trans('Description').':
'; + $texttoshow = dolGetFirstLineOfText($this->note_private, 10); + $tooltip .= (dol_textishtml($texttoshow) ? str_replace(array("\r", "\n"), "", $texttoshow) : str_replace(array("\r", "\n"), '
', $texttoshow)); } $linkclose = ''; //if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) @@ -1594,9 +1621,8 @@ class ActionComm extends CommonObject $label = $langs->trans("ShowAction"); $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, 0, '', 1).'"'; $linkclose .= ' class="'.$classname.' classfortooltip"'; - /* $hookmanager->initHooks(array('actiondao')); $parameters=array('id'=>$this->id); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index d31f8d60dfc..f0ef66eb78b 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -109,7 +109,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO } $subject = ''; - $actionmsg = ''; + //$actionmsg = ''; $actionmsg2 = ''; $langs->load('mails'); @@ -317,7 +317,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO if ($action == 'send' || $action == 'relance') { $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); - if ($message) { + /*if ($message) { $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); if ($sendtocc) { @@ -326,7 +326,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $message); - } + }*/ } // Create form object @@ -376,7 +376,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array. $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $object->actionmsg = $actionmsg; // Long text (@todo Replace this with $message, we already have details of email in dedicated properties) + $object->actionmsg = $message; // Long text $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...); $object->trackid = $trackid; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 2ff5d3f9c43..cf6a8220c29 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -958,11 +958,13 @@ class InterfaceActionsAuto extends DolibarrTriggers } } + /* Seems no more required: We have the data in dedicated field now. if (!empty($user->login)) { $object->actionmsg = dol_concatdesc($langs->transnoentities("Author").': '.$user->login, $object->actionmsg); } elseif (isset($object->origin_email)) { $object->actionmsg = dol_concatdesc($langs->transnoentities("Author").': '.$object->origin_email, $object->actionmsg); } + */ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -1019,7 +1021,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; - $actioncomm->note_private = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg) + $actioncomm->note_private = $object->actionmsg; $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; From 4cac6b7e29e36f44f0dfa37a90b86179237c25f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 14:03:14 +0200 Subject: [PATCH 391/752] css --- htdocs/compta/facture/card.php | 8 ++++---- htdocs/core/tpl/contacts.tpl.php | 2 +- htdocs/langs/en_US/companies.lang | 2 +- htdocs/theme/eldy/global.inc.php | 12 +++++++----- htdocs/theme/md/style.css.php | 17 +++++++++++------ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2273fc27c3b..9956fd32b97 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3522,7 +3522,7 @@ if ($action == 'create') { if ($socid > 0) { // Discounts for third party - print '
'; + print '"; - //} if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) { print ''; print ''; print ''; - // Parent company - if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) { - print ''; - print ''; - print ''; - } - // Prospect/Customer print ''; print ''; + print ''; + print ''; + } + // Assign a sale representative print ''; print ''; diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 242250c8835..2bb2f61375b 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -21,8 +21,8 @@ button.dropdown-item.global-search-item { } #topmenu-bookmark-dropdown .dropdown-menu { - min-width: 300px; - max-width: 360px; + min-width: 360px; + max-width: 400px; } @@ -499,4 +499,9 @@ div.quickaddblock:focus { margin-left: 5px; right: 0; } + + #topmenu-bookmark-dropdown .dropdown-menu { + min-width: 280px; + max-width: 360px; + } } From 96c866400f5ef23e07b87e2990ecf3b9bf7d4487 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 16:05:55 +0200 Subject: [PATCH 398/752] css --- htdocs/contact/card.php | 4 ++-- htdocs/societe/card.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 229bfc0530b..ee1d10181ca 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -624,7 +624,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { */ $object->canvas = $canvas; - $object->state_id = GETPOST("state_id"); + $object->state_id = GETPOST("state_id", "int"); // We set country_id, country_code and label for the selected country $object->country_id = GETPOST("country_id") ? GETPOST("country_id", "int") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); @@ -697,7 +697,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } else { print ''; } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 37ac9805374..a8b2fb151c6 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1671,7 +1671,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; } From fc7a4dba4a3eff50248bf1abf87b146be5b6b9e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 16:26:22 +0200 Subject: [PATCH 399/752] Removed not up to date notices --- README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 0d0e2d89d00..b227b16ccba 100644 --- a/README.md +++ b/README.md @@ -220,15 +220,7 @@ These are features that Dolibarr does **not** yet fully support: - Payroll module - No native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc. - Dolibarr can't do coffee (yet) -- The REST API currently cannot: - - Add new ledger entry [#14675](https://github.com/Dolibarr/dolibarr/issues/14675) - - Get virtual products (aka lots) [#14457](https://github.com/Dolibarr/dolibarr/issues/14457) - - Add special taxcodes to a line on a supplier invoice (vat_src_code) [#14404](https://github.com/Dolibarr/dolibarr/issues/14404) - - Get or post shipments on customer orders [#18074](https://github.com/Dolibarr/dolibarr/issues/18074) - - Get or post shipments on supplier orders [#14334](https://github.com/Dolibarr/dolibarr/issues/14334) - - Add an image to a product [#14262](https://github.com/Dolibarr/dolibarr/issues/14262) - - Add multiprices to products [#12812](https://github.com/Dolibarr/dolibarr/issues/12812) - +- ## DOCUMENTATION From a120f6552125dd96fd07857b0e86f2b2252d6576 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 16:32:03 +0200 Subject: [PATCH 400/752] FIX country not visible into list of states --- htdocs/core/class/html.formcompany.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index fbaee3331c5..f976fac978d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -406,7 +406,7 @@ class FormCompany extends Form // Show break $key = $langs->trans("Country".strtoupper($obj->country_code)); $valuetoshow = ($key != "Country".strtoupper($obj->country_code)) ? $obj->country_code." - ".$key : $obj->country; - print '\n"; + print '\n"; $country = $obj->country; } From e6a0ca5042e78631f24cfebf98d58513b2595a1d Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 7 Apr 2022 16:32:08 +0200 Subject: [PATCH 401/752] FIX errors to catch --- htdocs/core/class/commonobject.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cc3ea5ae820..ea7de60f67e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5380,19 +5380,20 @@ abstract class CommonObject return 1; } else { $outputlangs->charset_output = $sav_charset_output; + $this->error = $obj->error; + $this->errors = $obj->errors; dol_syslog("Error generating document for ".__CLASS__.". Error: ".$obj->error, LOG_ERR); - setEventMessages($obj->error, $obj->errors, 'errors'); return -1; } } else { if (!$filefound) { $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; + $this->errors[] = $this->error; dol_syslog($this->error, LOG_ERR); - setEventMessage($this->error, 'errors'); } else { $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound); + $this->errors[] = $this->error; dol_syslog($this->error, LOG_ERR); - setEventMessage($this->error, 'errors'); } return -1; } From 37fbe859df0d9d22a2d9afcce4ba52c326db98c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 16:32:03 +0200 Subject: [PATCH 402/752] FIX country not visible into list of states --- htdocs/core/class/html.formcompany.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index edc431819da..103db86998c 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -406,7 +406,7 @@ class FormCompany extends Form // Show break $key = $langs->trans("Country".strtoupper($obj->country_code)); $valuetoshow = ($key != "Country".strtoupper($obj->country_code)) ? $obj->country_code." - ".$key : $obj->country; - print '\n"; + print '\n"; $country = $obj->country; } From f884137433c42a8d10ed1c0d766973be263e0e35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 17:12:17 +0200 Subject: [PATCH 403/752] Forgot to update the COPYRIGHT 4 days ago after jqquery upgrade. --- COPYRIGHT | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index a5e1f4a4005..a2101a1db0a 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -50,8 +50,8 @@ TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes JS libraries: Ace 1.4.14 BSD Yes JS library to get code syntaxique coloration in a textarea. ChartJS 3.7.1 MIT License Yes JS library for graph -jQuery 3.5.1 MIT License Yes JS library -jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI +jQuery 3.6.0 MIT License Yes JS library +jQuery UI 1.13.1 GPL and MIT License Yes JS library plugin UI jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors From 41ee9739db45a74f3731b0e215db13ed9d50d16f Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 7 Apr 2022 17:16:02 +0200 Subject: [PATCH 404/752] FIX: Add 'recruitment' into check array --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 3ea554a4a8f..c0c540754fc 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -616,7 +616,7 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $feature = 'projet_task'; } - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object From 6e0888ca0ec5118e7094b24e2364ec740ee6c32e Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 7 Apr 2022 17:17:20 +0200 Subject: [PATCH 405/752] FIX: action comm list: holiday last day not included + handle duration with halfdays --- htdocs/comm/action/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 722423c0cd9..51d0f99b6b8 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -979,8 +979,8 @@ if ($resql) { $event->type = 'holiday'; $event->type_picto = 'holiday'; - $event->datep = $db->jdate($obj->date_start); - $event->datef = $db->jdate($obj->date_end); + $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1); + $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1; $event->date_start_in_calendar = $event->datep; $event->date_end_in_calendar = $event->datef; From 746cec015b77341a4e80084e4a7132523bd68913 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 17:50:18 +0200 Subject: [PATCH 406/752] Fix remove warning on chartjs 3.5 --- htdocs/core/class/dolgraph.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index b46ca096547..488becd06b7 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1303,11 +1303,13 @@ class DolGraph $this->stringtoshow .= $xaxis; /* For Chartjs v2.9 */ + /* if (empty($showlegend)) { $this->stringtoshow .= 'legend: { display: false }, '."\n"; } else { $this->stringtoshow .= 'legend: { maxWidth: '.round($this->width / 2).', labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ? 'right' : 'top') . '\' }, '."\n"; } + */ /* For Chartjs v3.5 */ $this->stringtoshow .= 'plugins: { '."\n"; @@ -1318,7 +1320,9 @@ class DolGraph } $this->stringtoshow .= "}, \n"; - $this->stringtoshow .= 'scales: { xAxes: [{ '; + /* For Chartjs v2.9 */ + /* + $this->stringtoshow .= 'scales: { xAxis: [{ '; if ($this->hideXValues) { $this->stringtoshow .= ' ticks: { display: false }, display: true,'; } @@ -1328,11 +1332,12 @@ class DolGraph $this->stringtoshow .= ', stacked: true'; } $this->stringtoshow .= ' }]'; - $this->stringtoshow .= ', yAxes: [{ ticks: { beginAtZero: true }'; + $this->stringtoshow .= ', yAxis: [{ ticks: { beginAtZero: true }'; if ($type == 'bar' && count($arrayofgroupslegend) > 0) { $this->stringtoshow .= ', stacked: true'; } $this->stringtoshow .= ' }] }'; + */ // Add a callback to change label to show only positive value if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) { From cbae64f9aab1b3a15dae9d2265cb64c643917e1d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 17:51:38 +0200 Subject: [PATCH 407/752] FIX Add a hack to fix a bug in jquery 3.6.0/select 2 --- htdocs/core/js/lib_head.js.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 5d47fa5f605..3fe6dee8820 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1198,4 +1198,22 @@ $(document).ready(function() { } }); + +/* + * Hacky fix for a bug in select2 with jQuery 3.6.0's new nested-focus "protection" + * see: https://github.com/select2/select2/issues/5993 + * see: https://github.com/jquery/jquery/issues/4382 + * + * TODO: Recheck with the select2 GH issue and remove once this is fixed on their side + */ +$(document).on('select2:open', () => { + console.log("Execute the focus (click on combo or use space when on component"); + let allFound = document.querySelectorAll('.select2-container--open .select2-search__field'); + $(this).one('mouseup keyup',()=>{ + setTimeout(()=>{ + allFound[allFound.length - 1].focus(); + },0); + }); +}); + // End of lib_head.js.php From de737b6b23d94c34bc36fb654b9778e2a65042fd Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 7 Apr 2022 18:07:30 +0200 Subject: [PATCH 408/752] FIX: holiday/leave requests: write status change emails in HTML --- htdocs/holiday/card.php | 73 +++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 3ca389176e7..42b7a7313f0 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -449,10 +449,9 @@ if (empty($reshook)) $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysToValidateBody")."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateBody")."

\n"; $delayForRequest = $object->getConfCP('delayForRequest'); //$delayForRequest = $delayForRequest * (60*60*24); @@ -464,8 +463,7 @@ if (empty($reshook)) { if ($object->date_debut < $nextMonth) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."

\n"; } } @@ -475,20 +473,21 @@ if (empty($reshook)) $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateAlertSolde")."

\n"; } } - $message .= "\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id; + + $message .= "
    "; + $message .= "
  • ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Envoi du mail $result = $mail->sendfile(); @@ -603,19 +602,20 @@ if (empty($reshook)) $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; + $message .= "

".$langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - $message .= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $message .= "
    \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Envoi du mail $result = $mail->sendfile(); @@ -689,20 +689,21 @@ if (empty($reshook)) $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message .= GETPOST('detail_refuse', 'alpha')."\n\n"; + $message .= "

".$langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; + $message .= "

".GETPOST('detail_refuse', 'alpha')."

"; - $message .= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $message .= "
    \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Envoi du mail $result = $mail->sendfile(); @@ -838,18 +839,20 @@ if (empty($reshook)) $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $message .= "

".$langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; + + $message .= "
    \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Envoi du mail $result = $mail->sendfile(); From baa4608812230ad89a6e0db5574350afa3ebb8f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 18:16:06 +0200 Subject: [PATCH 409/752] Debug v16 --- htdocs/adherents/list.php | 14 ++++++-------- htdocs/holiday/list.php | 15 +++++++++------ htdocs/hrm/index.php | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 996f2d16c8d..e58def3f481 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -505,7 +505,7 @@ if (GETPOSTISSET("search_status")) { if ($search_type > 0) { $membertype = new AdherentType($db); - $result = $membertype->fetch(GETPOST("type", 'int')); + $result = $membertype->fetch($search_type); $titre .= " (".$membertype->label.")"; } @@ -767,7 +767,7 @@ if (!empty($arrayfields['d.email']['checked'])) { } // End of subscription date if (!empty($arrayfields['d.datefin']['checked'])) { - print '
'; @@ -858,7 +858,7 @@ if (!empty($arrayfields['state.nom']['checked'])) { print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['country.code_iso']['checked'])) { - print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['d.phone']['checked'])) { print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder); @@ -873,7 +873,7 @@ if (!empty($arrayfields['d.email']['checked'])) { print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['d.datefin']['checked'])) { - print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, '', $sortfield, $sortorder, 'center '); } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1110,16 +1110,14 @@ while ($i < min($num, $limit)) { // End of subscription date $datefin = $db->jdate($obj->datefin); if (!empty($arrayfields['d.datefin']['checked'])) { + print ''; } else { - print ''; } + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index b4985100e44..bcae536f720 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -721,7 +721,7 @@ if ($resql) { if (!empty($arrayfields['cp.statut']['checked'])) { print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); @@ -789,21 +789,23 @@ if ($resql) { } } if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['cp.fk_validator']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['cp.fk_type']['checked'])) { - print ''; if (!$i) { $totalarray['nbfield']++; @@ -813,7 +815,8 @@ if ($resql) { print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 2603d73ab81..84e336c9b97 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -235,7 +235,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { print ''; print ''; - print ''; + print ''; print ''; $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; From 0e36097eba04d730554d05b7ce9ef7a9053e0f1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 19:16:50 +0200 Subject: [PATCH 410/752] Save result of some methods into cached properties. --- htdocs/core/class/commoninvoice.class.php | 37 ++++++++++++++++++----- htdocs/core/class/discount.class.php | 6 ++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index eedc1b2fa10..e49f8a6a728 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -93,6 +93,14 @@ abstract class CommonInvoice extends CommonObject const STATUS_ABANDONED = 3; + public $sumpayed; + public $sumpayed_multicurrency; + public $sumdeposit; + public $sumdeposit_multicurrency; + public $sumcreditnote; + public $sumcreditnote_multicurrency; + + /** * Return remain amount to pay. Property ->id and ->total_ttc must be set. * This does not include open direct debit requests. @@ -118,8 +126,8 @@ abstract class CommonInvoice extends CommonObject * Return amount of payments already done. This must include ONLY the record into the payment table. * Payments dones using discounts, credit notes, etc are not included. * - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return float Amount of payment already done, <0 if KO + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return float Amount of payment already done, <0 and set ->error if KO */ public function getSommePaiement($multicurrency = 0) { @@ -138,10 +146,13 @@ abstract class CommonInvoice extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); + $this->db->free($resql); if ($multicurrency) { + $this->sumpayed_multicurrency = $obj->multicurrency_amount; return $obj->multicurrency_amount; } else { + $this->sumpayed = $obj->amount; return $obj->amount; } } else { @@ -154,13 +165,13 @@ abstract class CommonInvoice extends CommonObject * Return amount (with tax) of all deposits invoices used by invoice. * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return float <0 if KO, Sum of deposits amount otherwise + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return float <0 and set ->error if KO, Sum of deposits amount otherwise */ public function getSumDepositsUsed($multicurrency = 0) { if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { - // TODO + // FACTURE_DEPOSITS_ARE_JUST_PAYMENTS was never supported for purchase invoice, so we can return 0 with no need of SQL for this case. return 0.0; } @@ -170,6 +181,12 @@ abstract class CommonInvoice extends CommonObject $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); if ($result >= 0) { + if ($multicurrency) { + $this->sumdeposit_multicurrency = $result; + } else { + $this->sumdeposit = $result; + } + return $result; } else { $this->error = $discountstatic->error; @@ -180,8 +197,8 @@ abstract class CommonInvoice extends CommonObject /** * Return amount (with tax) of all credit notes invoices + excess received used by invoice * - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return float <0 if KO, Sum of credit notes and deposits amount otherwise + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return float <0 and set ->error if KO, Sum of credit notes and deposits amount otherwise */ public function getSumCreditNotesUsed($multicurrency = 0) { @@ -190,6 +207,12 @@ abstract class CommonInvoice extends CommonObject $discountstatic = new DiscountAbsolute($this->db); $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); if ($result >= 0) { + if ($multicurrency) { + $this->sumcreditnote_multicurrency = $result; + } else { + $this->sumcreditnote = $result; + } + return $result; } else { $this->error = $discountstatic->error; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index bdc5e746566..dff1383a629 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -562,7 +562,7 @@ class DiscountAbsolute * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @param int $multicurrency 1=Return multicurrency_amount instead of amount. TODO Add a mode multicurrency = -1 to return array with amount + multicurrency amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ public function getSumDepositsUsed($invoice, $multicurrency = 0) @@ -603,7 +603,7 @@ class DiscountAbsolute * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @param int $multicurrency 1=Return multicurrency_amount instead of amount. TODO Add a mode multicurrency = -1 to return array with amount + multicurrency amount * @return int <0 if KO, Sum of credit notes and excess received amount otherwise */ public function getSumCreditNotesUsed($invoice, $multicurrency = 0) @@ -643,7 +643,7 @@ class DiscountAbsolute * Return amount (with tax) of all converted amount for this credit note * * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $multicurrency Return multicurrency_amount instead of amount. TODO Add a mode multicurrency = -1 to return array with amount + multicurrency amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) From e66b4a687dd3286b38b80ae3ff5cd28d0bc514b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 19:23:45 +0200 Subject: [PATCH 411/752] Close #19414 --- htdocs/core/lib/functions.lib.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a9739989c41..50d0e8ee9e3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7470,13 +7470,23 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__DATE_YMD__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : null) : ''; $substitutionarray['__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : null) : ''; + $already_payed_all = 0; + if (is_object($object) && ($object instanceof Facture)) { + $already_payed_all = $object->sumpayed + $object->sumdeposit + $object->sumcreditnote; + } + + $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : ''; + $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : ''; $substitutionarray['__AMOUNT_TEXT__'] = is_object($object) ? dol_convertToWord($object->total_ttc, $outputlangs, '', true) : ''; $substitutionarray['__AMOUNT_TEXTCURRENCY__'] = is_object($object) ? dol_convertToWord($object->total_ttc, $outputlangs, $conf->currency, true) : ''; - $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : ''; + + $substitutionarray['__AMOUNT_REMAIN__'] = is_object($object) ? $object->total_ttc - $already_payed_all : ''; + $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) : ''; $substitutionarray['__AMOUNT_VAT_TEXT__'] = is_object($object) ? (isset($object->total_vat) ? dol_convertToWord($object->total_vat, $outputlangs, '', true) : dol_convertToWord($object->total_tva, $outputlangs, '', true)) : ''; $substitutionarray['__AMOUNT_VAT_TEXTCURRENCY__'] = is_object($object) ? (isset($object->total_vat) ? dol_convertToWord($object->total_vat, $outputlangs, $conf->currency, true) : dol_convertToWord($object->total_tva, $outputlangs, $conf->currency, true)) : ''; + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; } @@ -7484,8 +7494,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; } - $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ? price($object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) : ''; + // Amount keys formated in a currency $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? ($object->total_ht ? price($object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) : ''; + $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ? price($object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) : ''; + $substitutionarray['__AMOUNT_REMAIN_FORMATED__'] = is_object($object) ? ($object->total_ttc ? price($object->total_ttc - $already_payed_all, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) : ''; $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object) ? (isset($object->total_vat) ? price($object->total_vat, 0, $outputlangs, 0, -1, -1, $conf->currency) : ($object->total_tva ? price($object->total_tva, 0, $outputlangs, 0, -1, -1, $conf->currency) : null)) : ''; if ($onlykey != 2 || $mysoc->useLocalTax(1)) { $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? ($object->total_localtax1 ? price($object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) : ''; From 3a2815a9c0c4278ab00364a5b95a62bbf4d1be18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 23:44:57 +0200 Subject: [PATCH 412/752] Debug and clean v16 --- htdocs/core/login/functions_dolibarr.php | 4 ++++ .../install/mysql/migration/15.0.0-16.0.0.sql | 9 ++++++- htdocs/install/mysql/tables/llx_user.sql | 3 +-- htdocs/install/repair.php | 24 ++++++++++++------- htdocs/user/class/user.class.php | 1 + 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 292ce1b44f5..610072aa35a 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -143,7 +143,11 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes $ret = $mc->checkRight($obj->rowid, $entitytotest); if ($ret < 0) { dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO entity '".$entitytotest."' not allowed for user '".$obj->rowid."'", LOG_NOTICE); + $login = ''; // force authentication failure + if ($mc->db->lasterror()) { + $_SESSION["dol_loginmesg"] = $mc->db->lasterror(); + } } } } diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 634e17b33b4..3aa5cd9c9cd 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -288,9 +288,16 @@ ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER dom -- Set default ticket type to OTHER if no default exists UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1); -ALTER TABLE llx_user ADD COLUMN ref_employee varchar(50) DEFAULT NULL; + +ALTER TABLE llx_user DROP COLUMN webcal_login; +ALTER TABLE llx_user DROP COLUMN module_comm; +ALTER TABLE llx_user DROP COLUMN module_compta; +ALTER TABLE llx_user DROP COLUMN ref_int; + +ALTER TABLE llx_user ADD COLUMN ref_employee varchar(50) DEFAULT NULL AFTER entity; ALTER TABLE llx_user ADD COLUMN national_registration_number varchar(50) DEFAULT NULL; + ALTER TABLE llx_propal ADD last_main_doc VARCHAR(255) NULL AFTER model_pdf; UPDATE llx_c_country SET eec=0 WHERE eec IS NULL; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 694ed360b21..ae3715eb028 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -22,8 +22,8 @@ create table llx_user rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id + ref_employee varchar(50), ref_ext varchar(50), -- reference into an external system (not used by dolibarr) - ref_int varchar(50), -- reference into an internal system (deprecated) admin smallint DEFAULT 0, -- user has admin profile @@ -108,7 +108,6 @@ create table llx_user import_key varchar(14), -- import key default_range integer, default_c_exp_tax_cat integer, - employee_number varchar(50), national_registration_number varchar(50), fk_warehouse integer -- default warehouse os user )ENGINE=innodb; diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 8e4cc851d28..802711f4ff3 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -94,8 +94,8 @@ print 'Option repair_link_dispatch_lines_supplier_order_lines, (\'test\' or \'co // Init data print 'Option set_empty_time_spent_amount (\'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount', 'alpha') ?GETPOST('set_empty_time_spent_amount', 'alpha') : 'undefined').'
'."\n"; // Structure -print 'Option force_utf8_on_tables, for mysql/mariadb only (\'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables', 'alpha') ?GETPOST('force_utf8_on_tables', 'alpha') : 'undefined').'
'."\n"; -print "Option force_utf8mb4_on_tables (EXPERIMENTAL!), for mysql/mariadb only ('test' or 'confirmed') is ".(GETPOST('force_utf8mb4_on_tables', 'alpha') ? GETPOST('force_utf8mb4_on_tables', 'alpha') : 'undefined')."
\n"; +print 'Option force_utf8_on_tables (force utf8 + row=dynamic), for mysql/mariadb only (\'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables', 'alpha') ?GETPOST('force_utf8_on_tables', 'alpha') : 'undefined').'
'."\n"; +print "Option force_utf8mb4_on_tables (force utf8mb4 + row=dynamic, EXPERIMENTAL!), for mysql/mariadb only ('test' or 'confirmed') is ".(GETPOST('force_utf8mb4_on_tables', 'alpha') ? GETPOST('force_utf8mb4_on_tables', 'alpha') : 'undefined')."
\n"; // Rebuild sequence print 'Option rebuild_sequences, for postgresql only (\'test\' or \'confirmed\') is '.(GETPOST('rebuild_sequences', 'alpha') ?GETPOST('rebuild_sequences', 'alpha') : 'undefined').'
'."\n"; print '
'; @@ -176,7 +176,8 @@ $oneoptionset = 0; $oneoptionset = (GETPOST('standard', 'alpha') || GETPOST('restore_thirdparties_logos', 'alpha') || GETPOST('clean_linked_elements', 'alpha') || GETPOST('clean_menus', 'alpha') || GETPOST('clean_orphelin_dir', 'alpha') || GETPOST('clean_product_stock_batch', 'alpha') || GETPOST('set_empty_time_spent_amount', 'alpha') || GETPOST('rebuild_product_thumbs', 'alpha') || GETPOST('clean_perm_table', 'alpha') - || GETPOST('force_disable_of_modules_not_found', 'alpha') || GETPOST('force_utf8_on_tables', 'alpha') + || GETPOST('force_disable_of_modules_not_found', 'alpha') + || GETPOST('force_utf8_on_tables', 'alpha') || GETPOST('force_utf8mb4_on_tables', 'alpha') || GETPOST('rebuild_sequences', 'alpha')); if ($ok && $oneoptionset) { @@ -1218,7 +1219,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { // force utf8 on tables if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { - print '
'; + print ''; if ($db->type == "mysql" || $db->type == "mysqli") { $force_utf8_on_tables = GETPOST('force_utf8_on_tables', 'alpha'); @@ -1240,11 +1241,18 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { print ''; print ''; print ''; - print ''; + + $leavecode = empty($typeleaves[$obj->fk_type]) ? 'Undefined' : $typeleaves[$obj->fk_type]['code']; + print ''; $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e2d36ab4695..fb04930299b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -756,6 +756,8 @@ if (!defined('NOLOGIN')) { $login = ''; } + $dol_authmode = ''; + if ($login) { $dol_authmode = $conf->authmode; // This properties is defined only when logged, to say what mode was successfully used $dol_tz = $_POST["tz"]; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index fb9178e1ed0..dc94669d54f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -312,8 +312,8 @@ print 'dol_hide_topmenu='.$dol_hide_topmenu."\n"; print 'dol_hide_leftmenu='.$dol_hide_leftmenu."\n"; print 'dol_optimize_smallscreen='.$dol_optimize_smallscreen."\n"; print 'dol_no_mouse_hover='.$dol_no_mouse_hover."\n"; -print 'dol_screenwidth='.$_SESSION['dol_screenwidth']."\n"; -print 'dol_screenheight='.$_SESSION['dol_screenheight']."\n"; +print 'dol_screenwidth='.(empty($_SESSION['dol_screenwidth']) ? '' : $_SESSION['dol_screenwidth'])."\n"; +print 'dol_screenheight='.(empty($_SESSION['dol_screenheight']) ? '' : $_SESSION['dol_screenheight'])."\n"; print 'fontsize='.$fontsize."\n"; print 'nbtopmenuentries='.$nbtopmenuentries."\n"; print 'fontsizesmaller='.$fontsizesmaller."\n"; From 1f73f19ff70d09d7a021133dfb82c57720cb643f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2022 00:42:39 +0200 Subject: [PATCH 415/752] php8 --- htdocs/takepos/index.php | 41 ++++++++++++++++++++++---------------- htdocs/takepos/invoice.php | 7 ++++--- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 31c51a4c7b1..b23907b64f1 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -57,7 +57,7 @@ $action = GETPOST('action', 'aZ09'); $setterminal = GETPOST('setterminal', 'int'); $setcurrency = GETPOST('setcurrency', 'aZ09'); -if ($_SESSION["takeposterminal"] == "") { +if (empty($_SESSION["takeposterminal"])) { if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") { $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal } elseif (!empty($_COOKIE["takeposterminal"])) { @@ -114,6 +114,11 @@ $result = restrictedArea($user, 'takepos', 0, ''); $form = new Form($db); +$disablejs = 0; +$disablehead = 0; +$arrayofjs = array(); +$arrayofcss = array(); + // Title $title = 'TakePOS - Dolibarr '.DOL_VERSION; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { @@ -129,22 +134,22 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); global->TAKEPOS_COLOR_THEME == 1) { +if (getDolGlobalInt('TAKEPOS_COLOR_THEME') == 1) { print ''; } ?> '; } } - // This hook is used to show the embedded form to make payments with external payment modules (ie Payzen, ...) + + // For any other payment services + // This hook can be used to show the embedded form to make payments with external payment modules (ie Payzen, ...) $parameters = [ 'paymentmethod' => $paymentmethod, 'amount' => price2num(GETPOST("newamount"), 'MT'), + 'currency' => $currency, 'tag' => GETPOST("tag", 'alpha'), 'dopayment' => GETPOST('dopayment', 'alpha') ]; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 81d24c9f7c3..b1a3213ec33 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -805,6 +805,8 @@ if ($ispaymentok) { } } + dol_syslog("FinalPaymentAmt = ".$FinalPaymentAmt." paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0, '_payment'); + // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { $db->begin(); diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 7405fcedb18..06397108da5 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -750,12 +750,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
'.$langs->trans('Discounts').''; + print '
'.$langs->trans('DiscountStillRemaining').''; $thirdparty = $soc; $discount_type = 0; @@ -4355,8 +4355,8 @@ if ($action == 'create') { // Relative and absolute discounts print ''."\n"; - print '
'.$langs->trans('Discounts'); - print ''; + print '
'.$langs->trans('DiscountStillRemaining').''; $thirdparty = $soc; $discount_type = 0; $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); @@ -5222,7 +5222,7 @@ if ($action == 'create') { print ''; print ''; - print '

'; + print '


'; if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 2dd9751a4c6..5f463e44846 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -259,7 +259,7 @@ $arrayfields = array( 'rowid' => array('label'=>$langs->trans("Id"), 'checked'=>1), 'nature' => array('label'=>$langs->trans("NatureOfContact"), 'checked'=>1), 'thirdparty' => array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), - 'contact' => array('label'=>$langs->trans("Users").'/'.$langs->trans("Contacts"), 'checked'=>1), + 'contact' => array('label'=>$langs->trans("Users").' | '.$langs->trans("Contacts"), 'checked'=>1), 'type' => array('label'=>$langs->trans("ContactType"), 'checked'=>1), 'status' => array('label'=>$langs->trans("Status"), 'checked'=>1), 'link' => array('label'=>$langs->trans("Link"), 'checked'=>1), diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index edd6f7b7dd8..093fb47189d 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -361,7 +361,7 @@ ListOfThirdParties=List of Third Parties ShowCompany=Third Party ShowContact=Contact-Address ContactsAllShort=All (No filter) -ContactType=Contact type +ContactType=Contact role ContactForOrders=Order's contact ContactForOrdersOrShipments=Order's or shipment's contact ContactForProposals=Proposal's contact diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 0715723bf55..70b1028bca2 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3612,6 +3612,13 @@ td.border, div.tagtable div div.border { .fichehalfright table.noborder { margin: 0px 0px 0px 0px; } +table.liste, table.noborder:not(.paymenttable):not(.margintable):not(.tableforcontact), table.formdoc, div.noborder:not(.paymenttable):not(.margintable):not(.tableforcontact) { + + border-left: 1px solid var(--colortopbordertitle1); + border-right: 1px solid var(--colortopbordertitle1); + +} table.liste, table.noborder, table.formdoc, div.noborder { width: 100%; border-collapse: separate !important; @@ -3621,11 +3628,6 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-top-style: solid; margin: 0px 0px 20px 0px; - - border-left: 1px solid var(--colortopbordertitle1); - border-right: 1px solid var(--colortopbordertitle1); - /*width: calc(100% - 7px); border-collapse: separate !important; border-spacing: 0px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f2fee83c291..9189f81856a 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3681,6 +3681,17 @@ div.colorback border-left: 1px solid #ccc; } +table.liste, table.noborder:not(.paymenttable):not(.margintable):not(.tableforcontact), table.formdoc, div.noborder:not(.paymenttable):not(.margintable):not(.tableforcontact) { + + border-left: 1px solid #BBB; + border-right: 1px solid #BBB; + +} +table.liste, table.noborder.paymenttable, table.noborder.margintable, table.noborder.tableforcontact, table.formdoc, div.noborder.paymenttable, div.noborder.margintable, div.noborder.tableforcontact { + border-left: 1px solid #f0f0f0; + border-right: 1px solid #f0f0f0; +} table.liste, table.noborder, table.formdoc, div.noborder { width: calc(100% - 2px); /* -2 to fix a bug. Without, a scroll appears due to overflow-x: auto; of div-table-responsive */ @@ -3695,12 +3706,6 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-bottom-color: #BBB; border-bottom-style: solid; - - border-right: 1px solid #ccc; - border-left: 1px solid #ccc; - - margin: 0px 0px 20px 0px; -webkit-border-radius: 0.1em; From 27acaa45f515341b59a1cc15621cba54b481a29d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 14:18:24 +0200 Subject: [PATCH 392/752] Clean deprecated field --- .../class/fournisseur.facture-rec.class.php | 23 ++++++------ .../fourn/class/fournisseur.facture.class.php | 36 ++++--------------- 2 files changed, 17 insertions(+), 42 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 7d90c239ba7..ab68cd3ecc6 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -79,13 +79,19 @@ class FactureFournisseurRec extends CommonInvoice public $suspended; public $libelle; + public $label; /** - * @deprecated * @var double $amount + * @deprecated */ public $amount; + /** + * @var double $remise + * @deprecated + */ public $remise; + public $vat_src_code; public $localtax1; public $localtax2; @@ -173,8 +179,6 @@ class FactureFournisseurRec extends CommonInvoice 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>40), 'suspended' =>array('type'=>'integer', 'label'=>'Suspended', 'enabled'=>1, 'visible'=>-1, 'position'=>225), 'libelle' =>array('type'=>'varchar(100)', 'label'=>'Libelle', 'enabled'=>1, 'showoncombobox' => 0, 'visible'=>-1, 'position'=>15), - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), - 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40), 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>65, 'isameasure'=>1), @@ -278,8 +282,7 @@ class FactureFournisseurRec extends CommonInvoice $sql .= ', datec'; $sql .= ', suspended'; $sql .= ', libelle'; - $sql .= ', amount'; - $sql .= ', remise'; + $sql .= ', total_ttc'; $sql .= ', fk_user_author'; $sql .= ', fk_projet'; $sql .= ', fk_account'; @@ -310,7 +313,6 @@ class FactureFournisseurRec extends CommonInvoice $sql .= ", ".((int) $this->suspended); $sql .= ", '".$this->db->escape($this->libelle)."'"; $sql .= ", " .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount - $sql .= ", " .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0'); $sql .= ", " .((int) $user->id); $sql .= ", " .(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL'); $sql .= ", " .(!empty($facfourn_src->fk_account) ? ((int) $facfourn_src->fk_account) : 'NULL'); @@ -480,8 +482,6 @@ class FactureFournisseurRec extends CommonInvoice if ($this->fk_soc > 0) $sql .= " fk_soc = ". (int) $this->fk_soc. ','; $sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ','; $sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ","; - $sql .= " amount = ". (!empty($this->amount) ? ((float) $this->amount) : 0.00) . ','; - $sql .= " remise = ". (!empty($this->remise) ? ((float) $this->remise) : 'NULL') . ','; $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL') . ','; $sql .= " localtax1 = ". (!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00) . ','; $sql .= " localtax2 = ". (!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00) . ','; @@ -553,7 +553,7 @@ class FactureFournisseurRec extends CommonInvoice { $sql = 'SELECT f.rowid, f.titre, f.ref_supplier, f.entity, f.fk_soc'; $sql .= ', f.datec, f.tms, f.suspended'; - $sql .= ', f.libelle, f.amount, f.remise'; + $sql .= ', f.libelle as label'; $sql .= ', f.vat_src_code, f.localtax1, f.localtax2'; $sql .= ', f.total_tva, f.total_ht, f.total_ttc'; $sql .= ', f.fk_user_author, f.fk_user_modif'; @@ -593,9 +593,8 @@ class FactureFournisseurRec extends CommonInvoice $this->date_creation = $obj->datec; $this->date_modification = $obj->tms; $this->suspended = $obj->suspended; - $this->libelle = $obj->libelle; - $this->amount = $obj->amount; - $this->remise = $obj->remise; + $this->libelle = $obj->label; + $this->label = $obj->label; $this->vat_src_code = $obj->vat_src_code; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 176f79a51de..9912f71df4b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -182,10 +182,14 @@ class FactureFournisseur extends CommonInvoice public $date_echeance; /** - * @deprecated * @var double $amount + * @deprecated */ public $amount = 0; + /** + * @var double $remise + * @deprecated + */ public $remise = 0; /** @@ -404,11 +408,6 @@ class FactureFournisseur extends CommonInvoice $this->date = $now; } - $socid = $this->socid; - $ref_supplier = $this->ref_supplier; - $amount = $this->amount; - $remise = $this->remise; - // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); @@ -456,7 +455,6 @@ class FactureFournisseur extends CommonInvoice $this->total_ttc = $_facrec->total_ttc; // Fields always coming from template - $this->remise = $_facrec->remise; $this->fk_incoterms = $_facrec->fk_incoterms; $this->location_incoterms = $_facrec->location_incoterms; @@ -475,7 +473,6 @@ class FactureFournisseur extends CommonInvoice $this->array_options = $_facrec->array_options; - //if (! $this->remise) $this->remise = 0; if (! $this->mode_reglement_id) { $this->mode_reglement_id = 0; } @@ -545,10 +542,6 @@ class FactureFournisseur extends CommonInvoice $this->date_echeance = $forceduedate; } - if (!$remise) { - $remise = 0; - } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn ("; $sql .= "ref"; $sql .= ", ref_supplier"; @@ -882,8 +875,6 @@ class FactureFournisseur extends CommonInvoice $sql .= " t.tms,"; $sql .= " t.libelle as label,"; $sql .= " t.paye,"; - $sql .= " t.amount,"; - $sql .= " t.remise,"; $sql .= " t.close_code,"; $sql .= " t.close_note,"; $sql .= " t.tva,"; @@ -948,11 +939,8 @@ class FactureFournisseur extends CommonInvoice $this->label = $obj->label; $this->paye = $obj->paye; $this->paid = $obj->paye; - $this->amount = $obj->amount; - $this->remise = $obj->remise; $this->close_code = $obj->close_code; $this->close_note = $obj->close_note; - //$this->tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ht = $obj->total_ht; @@ -1177,22 +1165,12 @@ class FactureFournisseur extends CommonInvoice if (isset($this->paye)) { $this->paye = trim($this->paye); } - if (isset($this->amount)) { - if (empty($this->amount)) $this->amount = 0; - else $this->amount = doubleval($this->amount); - } - if (isset($this->remise)) { - $this->remise = trim($this->remise); - } if (isset($this->close_code)) { $this->close_code = trim($this->close_code); } if (isset($this->close_note)) { $this->close_note = trim($this->close_note); } - /*if (isset($this->tva)) { - $this->tva = trim($this->tva); - }*/ if (isset($this->localtax1)) { $this->localtax1 = trim($this->localtax1); } @@ -1264,8 +1242,6 @@ class FactureFournisseur extends CommonInvoice } $sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " paye=".(isset($this->paye) ? $this->paye : "null").","; - $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; - $sql .= " remise=".(isset($this->remise) ? $this->remise : "null").","; $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; //$sql .= " tva=".(isset($this->tva) ? $this->tva : "null").","; @@ -2452,7 +2428,7 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); - // Libere remise liee a ligne de facture + // Free the discount linked to a line of invoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_invoice_supplier_line = NULL'; $sql .= ' WHERE fk_invoice_supplier_line = '.((int) $rowid); From 4ced0bac8965f4ca1cf54a4cb291d025aaa6808f Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 7 Apr 2022 14:39:14 +0200 Subject: [PATCH 393/752] =?UTF-8?q?replace=20throw=20new=20Exception(?= =?UTF-8?q?=E2=80=A6)=20with=20dol=5Fprint=5Ferror=20+=20exit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b1f7997b4f7..6713157c78f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5620,7 +5620,8 @@ abstract class CommonObject // phpcs:enable global $langs, $conf; if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX . '_') !== 0) { - throw new Exception('The trigger "' . $triggerName . '" does not start with "' . self::TRIGGER_PREFIX . '_" as required.'); + dol_print_error('', 'The trigger "' . $triggerName . '" does not start with "' . self::TRIGGER_PREFIX . '_" as required.'); + exit; } if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; From bc7ad806e7f4185dd38fede5d4ecd1e955e19081 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 15:01:20 +0200 Subject: [PATCH 394/752] Try to fix a strange logic. --- htdocs/societe/card.php | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 2f2b1bcd89d..a591465cb23 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1180,14 +1180,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { document.formsoc.private.value=1; }); - var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '0' : '1') . '; + var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ? '0' : '1') . '; + init_customer_categ(); $("#customerprospect").change(function() { init_customer_categ(); }); function init_customer_categ() { console.log("is customer or prospect = "+jQuery("#customerprospect").val()); - if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() != 0 || !canHaveCategoryIfNotCustomerProspectSupplier)) + if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier) { jQuery(".visibleifcustomer").hide(); } @@ -1206,16 +1207,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (jQuery("#fournisseur").val() == 0) { jQuery(".visibleifsupplier").hide(); - if (jQuery("#customerprospect").val() == 0 && canHaveCategoryIfNotCustomerProspectSupplier && jQuery(".visibleifcustomer").is(":hidden")) { - jQuery(".visibleifcustomer").show(); - } } else { jQuery(".visibleifsupplier").show(); - if (jQuery("#customerprospect").val() == 0 && jQuery(".visibleifcustomer").is(":visible")) { - jQuery(".visibleifcustomer").hide(); - } } } @@ -1646,12 +1641,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $langs->load('categories'); // Customer - //if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { print '
'.$form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).''; @@ -1921,14 +1914,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } }); - var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '0' : '1') . '; + var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ? '0' : '1') . '; + init_customer_categ(); $("#customerprospect").change(function() { init_customer_categ(); }); function init_customer_categ() { console.log("is customer or prospect = "+jQuery("#customerprospect").val()); - if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() != 0 || !canHaveCategoryIfNotCustomerProspectSupplier)) + if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier) { jQuery(".visibleifcustomer").hide(); } @@ -1947,16 +1941,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (jQuery("#fournisseur").val() == 0) { jQuery(".visibleifsupplier").hide(); - if (jQuery("#customerprospect").val() == 0 && canHaveCategoryIfNotCustomerProspectSupplier && jQuery(".visibleifcustomer").is(":hidden")) { - jQuery(".visibleifcustomer").show(); - } } else { jQuery(".visibleifsupplier").show(); - if (jQuery("#customerprospect").val() == 0 && jQuery(".visibleifcustomer").is(":visible")) { - jQuery(".visibleifcustomer").hide(); - } } }; @@ -2748,7 +2736,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Tags / categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client || (!$object->fournisseur && !empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { + if ($object->prospect || $object->client || !empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT)) { print '
'.$langs->trans("CustomersCategoriesShort").''; print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1); From 3e5e74c68759fe2b1b84ea4e2dd75fe286539e67 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 15:39:03 +0200 Subject: [PATCH 395/752] Close #17632 --- htdocs/contrat/list.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 55bd7071ee8..6c23cfcf720 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -338,18 +338,24 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } } // Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('search_dfyear' => $search_dfyear, 'search_op2df'=>$search_op2df); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if ($search_dfyear > 0 && $search_op2df) { - if ($search_op2df == '<=') { - $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; - } elseif ($search_op2df == '>=') { - $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; - } else { - $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; +// Add HAVING from hooks +$parameters = array('search_dfyear' => $search_dfyear, 'search_op2df'=>$search_op2df); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + if ($search_dfyear > 0 && $search_op2df) { + if ($search_op2df == '<=') { + $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; + } elseif ($search_op2df == '>=') { + $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + } else { + $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + } } } +$sql .= $hookmanager->resPrint; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { From 56bfa20d7044001723a6fe5944441132ca863b7c Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 7 Apr 2022 15:59:42 +0200 Subject: [PATCH 396/752] FIX : dont update object price on each iteration when updating situation for all lines --- htdocs/compta/facture/card.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9956fd32b97..2cf5e13ff8b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2560,9 +2560,10 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'warnings'); $result = -1; } else { - $object->update_percent($line, GETPOST('all_progress')); + $object->update_percent($line, GETPOST('all_progress'), false); } } + $object->update_price(1); } } elseif ($action == 'updateline' && $usercancreate && !$cancel) { header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5fe58adcd7b..2b368d7bd75 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3725,11 +3725,12 @@ class Facture extends CommonInvoice /** * Update invoice line with percentage * - * @param FactureLigne $line Invoice line - * @param int $percent Percentage + * @param FactureLigne $line Invoice line + * @param int $percent Percentage + * @param boolean $update_price Update object price * @return void */ - public function update_percent($line, $percent) + public function update_percent($line, $percent, $update_price = true) { // phpcs:enable global $mysoc, $user; @@ -3756,7 +3757,11 @@ class Facture extends CommonInvoice $line->multicurrency_total_tva = $tabprice[17]; $line->multicurrency_total_ttc = $tabprice[18]; $line->update($user); - $this->update_price(1); + + // sometimes it is better to not update price for each line, ie when updating situation on all lines + if ($update_price) { + $this->update_price(1); + } } /** From b8d19c9311c2a01de0bb5d53ed5ea2d97d97c61a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 15:59:50 +0200 Subject: [PATCH 397/752] Debug v16 --- htdocs/main.inc.php | 2 +- htdocs/societe/card.php | 20 ++++++++++---------- htdocs/theme/eldy/dropdown.inc.php | 9 +++++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dc8b49c775f..e2d36ab4695 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2410,7 +2410,7 @@ function printDropdownQuickadd() "position" => 50, ), array( - "url" => "/compta/facture/card.php?action=create", + "url" => "/contrat/card.php?action=create", "title" => "NewContractSubscription@contracts", "name" => "Contract@contracts", "picto" => "object_contract", diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index a591465cb23..37ac9805374 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1320,16 +1320,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'.$langs->trans('ParentCompany').''; - print img_picto('', 'company', 'class="paddingrightonly"'); - print $form->select_thirdparty_list('', 'parent_company_id', '', $langs->trans("ThirdParty")); - print '
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; @@ -1675,6 +1665,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Parent company + if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) { + print '
'.$langs->trans('ParentCompany').''; + print img_picto('', 'company', 'class="paddingrightonly"'); + print $form->select_company(GETPOST('parent_company_id'), 'parent_company_id'); + print '
'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'
'; - print img_picto('', 'company').$form->select_company($socid, 'socid', '', 'SelectThirdParty'); + print img_picto('', 'company').$form->select_company($socid, 'socid', '', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); print '
'.$langs->trans('ParentCompany').''; print img_picto('', 'company', 'class="paddingrightonly"'); - print $form->select_company(GETPOST('parent_company_id'), 'parent_company_id'); + print $form->select_company(GETPOST('parent_company_id'), 'parent_company_id', '', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); print '
'; + print ''; $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); print $form->selectarray('search_filter', $selectarray, $search_filter); print ''; if ($datefin) { - print ''; print dol_print_date($datefin, 'day'); if ($memberstatic->hasDelay()) { $textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; print " ".img_warning($langs->trans("SubscriptionLate").$textlate); } - print ''; if (!empty($obj->subscription)) { print $langs->trans("SubscriptionNotReceived"); if ($obj->statut > 0) { @@ -1128,8 +1126,8 @@ while ($i < min($num, $limit)) { } else { print ' '; } - print '
'.$userstatic->getNomUrl(-1, 'leave').''.$userstatic->getNomUrl(-1, 'leave').''.$approbatorstatic->getNomUrl(-1).''.$approbatorstatic->getNomUrl(-1).''; $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); - print empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; + $labeltypeleavetoshow = empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; + + print ''; + print $labeltypeleavetoshow; print ''; $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates $totalduration += $nbopenedday; - print $nbopenedday.' '.$langs->trans('DurationDays'); + print $nbopenedday; + //print ' '.$langs->trans('DurationDays'); print '
'.$holidaystatic->getNomUrl(1).''.$userstatic->getNomUrl(-1, 'leave').''.$userstatic->getNomUrl(-1, 'leave').''.dol_escape_htmltag($langs->trans($typeleaves[$obj->fk_type]['code'])).'

*** Force page code and collation of tables into utf8/utf8_unicode_ci (for mysql/mariadb only)

*** Force page code and collation of tables into utf8/utf8_unicode_ci and row_format=dynamic (for mysql/mariadb only)
'; print $table; - $sql = "ALTER TABLE ".$table." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"; - print ''; + $sql1 = "ALTER TABLE ".$table." ROW_FORMAT=dynamic"; + $sql2 = "ALTER TABLE ".$table." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"; + print ''; + print ''; if ($force_utf8_on_tables == 'confirmed') { - $resql = $db->query($sql); - print ' - Done ('.($resql ? 'OK' : 'KO').')'; + $resql1 = $db->query($sql1); + if ($resql1) { + $resql2 = $db->query($sql2); + } else { + $resql2 = false; + } + print ' - Done ('.(($resql1 && $resql2) ? 'OK' : 'KO').')'; } else { print ' - Disabled'; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 84118961692..28542667dff 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -357,6 +357,7 @@ class User extends CommonObject */ public $fk_warehouse; + public $fields = array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'lastname'=>array('type'=>'varchar(50)', 'label'=>'LastName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1), From 88066d3fca6adc5fbe920eaf31d34ebcfcdb4a44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2022 23:53:02 +0200 Subject: [PATCH 413/752] Clean data --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 3aa5cd9c9cd..5f8b1d886c3 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -322,3 +322,5 @@ ALTER TABLE llx_contratdet ADD COLUMN rang integer DEFAULT 0 AFTER info_bits; ALTER TABLE llx_actioncomm MODIFY COLUMN note mediumtext; +DELETE FROM llx_boxes WHERE box_id IN (select rowid FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php')); +DELETE FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php'); From 994b500a6820eafc5c208276187d62bf42a0241a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2022 00:14:29 +0200 Subject: [PATCH 414/752] PHP 8.0 compatibility --- ChangeLog | 3 ++- htdocs/core/lib/agenda.lib.php | 6 +++--- htdocs/core/tpl/list_print_total.tpl.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/hrm/index.php | 12 +++++++----- htdocs/main.inc.php | 2 ++ htdocs/theme/eldy/style.css.php | 4 ++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 880406bb189..31bfa1c1cff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,8 @@ English Dolibarr ChangeLog For users: --------------- -NEW: ... +NEW: PHP 8.0 compatibility + Modules diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index d2528f45dfa..488010609f9 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -93,7 +93,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit, '', '', '0', false, 'minwidth100 maxwidth500 widthcentpercentminusxx'); print ''; - if ($conf->resource->enabled) { + if (!empty($conf->resource->enabled)) { include_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; $formresource = new FormResource($db); @@ -105,14 +105,14 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh } } - if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { + if (!empty($conf->societe->enabled) && !empty($user->rights->societe->lire)) { print '
'; print img_picto($langs->trans("ThirdParty"), 'company', 'class="fawidth30 inline-block"'); print $form->select_company($socid, 'search_socid', '', ' ', 0, 0, null, 0, 'minwidth100 maxwidth500'); print '
'; } - if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { + if (!empty($conf->projet->enabled) && !empty($user->rights->projet->lire)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; $formproject = new FormProjets($db); diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index b015dc51fdc..8d84228e2ec 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -14,7 +14,7 @@ if (isset($totalarray['pos'])) { $i++; if (!empty($totalarray['pos'][$i])) { print '
'; - if ($totalarray['type'][$i] == 'duration') { + if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') { print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0); } else { print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index da71a2a795d..0af7e083aec 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2627,7 +2627,7 @@ class FactureFournisseur extends CommonInvoice // phpcs:enable global $conf, $langs; - $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut as status'; + $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut as status, ff.total_ht, ff.total_ttc'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff'; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ff.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 84e336c9b97..c573b78ed51 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -34,17 +34,17 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; -if ($conf->deplacement->enabled) { +if (!empty($conf->deplacement->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; } -if ($conf->expensereport->enabled) { +if (!empty($conf->expensereport->enabled)) { require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; } -if ($conf->recruitment->enabled) { +if (!empty($conf->recruitment->enabled)) { require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; } -if ($conf->holiday->enabled) { +if (!empty($conf->holiday->enabled)) { require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; } @@ -236,7 +236,9 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { print '
'.$holidaystatic->getNomUrl(1).''.$userstatic->getNomUrl(-1, 'leave').''.dol_escape_htmltag($langs->trans($typeleaves[$obj->fk_type]['code'])).''.dol_escape_htmltag($langs->trans($leavecode)).'
'; // Type Prospect/Customer/Supplier - print ''; if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field - print ''; + print ''; } if ($object->client) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 70b1028bca2..fb28ca919d8 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4729,6 +4729,7 @@ div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bot } #dolpaymenttable { min-width: 320px; font-size: 16px; + max-width: 600px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { From 284649fd4b52b4f789eeacac7543785a198145a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 8 Apr 2022 13:35:21 +0200 Subject: [PATCH 419/752] Update objectonoff.php --- htdocs/core/ajax/objectonoff.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 5bac89345ce..ffd05c4747e 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -88,7 +88,10 @@ if (($action == 'set') && !empty($id)) { $triggerkey = strtoupper($element).'_UPDATE'; // Special case if ($triggerkey == 'SOCIETE_UPDATE') { - $triggerkey = 'COMPANY_UPDATE'; + $triggerkey = 'COMPANY_MODIFY'; + } + if ($triggerkey == 'PRODUCT_UPDATE') { + $triggerkey = 'PRODUCT_MODIFY'; } $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); From bedb08df506062649b130d4c28f307725fcdafbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2022 15:15:55 +0200 Subject: [PATCH 420/752] Clean and debug online payment code --- htdocs/adherents/class/adherent.class.php | 6 +- htdocs/don/class/paymentdonation.class.php | 7 +- htdocs/public/payment/newpayment.php | 144 ++------------------- htdocs/public/payment/paymentok.php | 33 +++-- 4 files changed, 36 insertions(+), 154 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 60311518ef8..39b6eaa97d0 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1534,9 +1534,9 @@ class Adherent extends CommonObject * * @param int $date Date of effect of subscription * @param double $amount Amount of subscription (0 accepted for some members) - * @param int $accountid Id bank account - * @param string $operation Type of payment (if Id bank account provided). Example: 'CB', ... - * @param string $label Label operation (if Id bank account provided) + * @param int $accountid Id bank account. NOT USED. + * @param string $operation Code of payment mode (if Id bank account provided). Example: 'CB', ... NOT USED. + * @param string $label Label operation (if Id bank account provided). * @param string $num_chq Numero cheque (if Id bank account provided) * @param string $emetteur_nom Name of cheque writer * @param string $emetteur_banque Name of bank of cheque diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 0f8db03597d..6de83f5570e 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -64,7 +64,8 @@ class PaymentDonation extends CommonObject public $amounts = array(); // Array of amounts - public $typepayment; + public $fk_typepayment; // Payment mode ID + public $paymenttype; // Payment mode ID public $num_payment; @@ -268,7 +269,8 @@ class PaymentDonation extends CommonObject $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->amount = $obj->amount; - $this->fk_typepayment = $obj->fk_typepayment; + $this->fk_typepayment = $obj->fk_typepayment; // For backward compatibility + $this->paymenttype = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; $this->note_public = $obj->note_public; $this->fk_bank = $obj->fk_bank; @@ -545,6 +547,7 @@ class PaymentDonation extends CommonObject $this->datep = ''; $this->amount = ''; $this->fk_typepayment = ''; + $this->paymenttype = ''; $this->num_payment = ''; $this->note_public = ''; $this->fk_bank = ''; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index cc77c2b7e81..b61a2e22a06 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2170,6 +2170,13 @@ print '
'; // Add more content on page for some services if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payment mode + // Save some data for the paymentok + $remoteip = getUserRemoteIP(); + $_SESSION["currencyCodeType"] = $currency; + $_SESSION["FinalPaymentAmt"] = $amount; + $_SESSION['ipaddress'] = ($remoteip ? $remoteip : 'unknown'); // Payer ip + $_SESSION["paymentType"] = ''; + // For Stripe if (GETPOST('dopayment_stripe', 'alpha')) { // Personalized checkout @@ -2634,141 +2641,6 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } ?> - - // Old code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION off and STRIPE_USE_NEW_CHECKOUT off - - // Create a Stripe client. - var stripe = Stripe(''); - - // Create an instance of Elements - var elements = stripe.elements(); - - // Custom styling can be passed to options when creating an Element. - // (Note that this demo uses a wider set of styles than the guide below.) - var style = { - base: { - color: '#32325d', - lineHeight: '24px', - fontFamily: '"Helvetica Neue", Helvetica, sans-serif', - fontSmoothing: 'antialiased', - fontSize: '16px', - '::placeholder': { - color: '#aab7c4' - } - }, - invalid: { - color: '#fa755a', - iconColor: '#fa755a' - } - }; - - // Create an instance of the card Element - var card = elements.create('card', {style: style}); - - // Add an instance of the card Element into the `card-element`
- card.mount('#card-element'); - - // Handle real-time validation errors from the card Element. - card.addEventListener('change', function(event) { - var displayError = document.getElementById('card-errors'); - if (event.error) { - displayError.textContent = event.error.message; - } else { - displayError.textContent = ''; - } - }); - - // Handle form submission - var form = document.getElementById('payment-form'); - console.log(form); - form.addEventListener('submit', function(event) { - event.preventDefault(); - global->STRIPE_USE_3DSECURE)) { // Ask credit card directly, no 3DS test - ?> - /* Use token */ - stripe.createToken(card).then(function(result) { - if (result.error) { - // Inform the user if there was an error - var errorElement = document.getElementById('card-errors'); - errorElement.textContent = result.error.message; - } else { - // Send the token to your server - stripeTokenHandler(result.token); - } - }); - - /* Use 3DS source */ - stripe.createSource(card).then(function(result) { - if (result.error) { - // Inform the user if there was an error - var errorElement = document.getElementById('card-errors'); - errorElement.textContent = result.error.message; - } else { - // Send the source to your server - stripeSourceHandler(result.source); - } - }); - - }); - - - /* Insert the Token into the form so it gets submitted to the server */ - function stripeTokenHandler(token) { - // Insert the token ID into the form so it gets submitted to the server - var form = document.getElementById('payment-form'); - - var hiddenInput = document.createElement('input'); - hiddenInput.setAttribute('type', 'hidden'); - hiddenInput.setAttribute('name', 'stripeToken'); - hiddenInput.setAttribute('value', token.id); - form.appendChild(hiddenInput); - - var hiddenInput2 = document.createElement('input'); - hiddenInput2.setAttribute('type', 'hidden'); - hiddenInput2.setAttribute('name', 'token'); - hiddenInput2.setAttribute('value', ''); - form.appendChild(hiddenInput2); - - // Submit the form - jQuery('#buttontopay').hide(); - jQuery('#hourglasstopay').show(); - console.log("submit token"); - form.submit(); - } - - /* Insert the Source into the form so it gets submitted to the server */ - function stripeSourceHandler(source) { - // Insert the source ID into the form so it gets submitted to the server - var form = document.getElementById('payment-form'); - - var hiddenInput = document.createElement('input'); - hiddenInput.setAttribute('type', 'hidden'); - hiddenInput.setAttribute('name', 'stripeSource'); - hiddenInput.setAttribute('value', source.id); - form.appendChild(hiddenInput); - - var hiddenInput2 = document.createElement('input'); - hiddenInput2.setAttribute('type', 'hidden'); - hiddenInput2.setAttribute('name', 'token'); - hiddenInput2.setAttribute('value', ''); - form.appendChild(hiddenInput2); - - // Submit the form - jQuery('#buttontopay').hide(); - jQuery('#hourglasstopay').show(); - console.log("submit source"); - form.submit(); - } - $paymentmethod, - 'amount' => price2num(GETPOST("newamount"), 'MT'), + 'amount' => $amount, 'currency' => $currency, 'tag' => GETPOST("tag", 'alpha'), 'dopayment' => GETPOST('dopayment', 'alpha') diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index b1a3213ec33..0ee6fa10bc7 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -243,9 +243,9 @@ if (!empty($conf->paypal->enabled)) { $fulltag = $FULLTAG; $payerID = $PAYPALPAYERID; // Set by newpayment.php - $paymentType = $_SESSION['PaymentType']; // Value can be 'Mark', 'Sole', 'Sale' for example $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; + $paymentType = $_SESSION['PaymentType']; // Value can be 'Mark', 'Sole', 'Sale' for example // From env $ipaddress = $_SESSION['ipaddress']; @@ -317,12 +317,14 @@ if (!empty($conf->paypal->enabled)) { if (!empty($conf->paybox->enabled)) { if ($paymentmethod == 'paybox') { + // TODO Add a check to validate that payment is ok. $ispaymentok = true; // We call this page only if payment is ok on payment system } } if (!empty($conf->stripe->enabled)) { if ($paymentmethod == 'stripe') { + // TODO Add a check to validate that payment is ok. We can request Stripe with payment_intent and payment_intent_client_secret $ispaymentok = true; // We call this page only if payment is ok on payment system } } @@ -334,16 +336,21 @@ if (empty($ipaddress)) { } if (empty($TRANSACTIONID)) { $TRANSACTIONID = $_SESSION['TRANSACTIONID']; + if (empty($TRANSACTIONID) && GETPOST('payment_intent', 'alphanohtml')) { + // For the case we use STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 2 + $TRANSACTIONID = GETPOST('payment_intent', 'alphanohtml'); + } } if (empty($FinalPaymentAmt)) { $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; } -if (empty($paymentType)) { - $paymentType = $_SESSION["paymentType"]; -} if (empty($currencyCodeType)) { $currencyCodeType = $_SESSION['currencyCodeType']; } +// Seems used onyl by Paypal +if (empty($paymentType)) { + $paymentType = $_SESSION["paymentType"]; +} $fulltag = $FULLTAG; $tmptag = dolExplodeIntoArray($fulltag, '.', '='); @@ -419,7 +426,7 @@ if ($ispaymentok) { } } - dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0, '_payment'); + dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId." currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0, '_payment'); // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { @@ -520,7 +527,7 @@ if ($ispaymentok) { dol_syslog("Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0, '_payment'); } - $operation = $paymentType; // Payment mode code + $operation = dol_getIdFromCode($db, $paymentTypeId, 'c_paiement', 'id', 'code', 1); // Payment mode code returned from payment mode id $num_chq = ''; $emetteur_nom = ''; $emetteur_banque = ''; @@ -879,7 +886,7 @@ if ($ispaymentok) { $db->rollback(); } } else { - $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['INV'].'. May be payment was already recorded.'; + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type id" ('.$paymentTypeId.') to record the payment of invoice '.$tmptag['INV'].'. May be payment was already recorded.'; $ispostactionok = -1; } } else { @@ -994,7 +1001,7 @@ if ($ispaymentok) { $ispostactionok = -1; } } else { - $postactionmessages[] = 'Failed to get a valid value for "amount paid" (' . $FinalPaymentAmt . ') or "payment type" (' . $paymentType . ') to record the payment of order ' . $tmptag['ORD'] . '. May be payment was already recorded.'; + $postactionmessages[] = 'Failed to get a valid value for "amount paid" (' . $FinalPaymentAmt . ') or "payment type id" (' . $paymentTypeId . ') to record the payment of order ' . $tmptag['ORD'] . '. May be payment was already recorded.'; $ispostactionok = -1; } } else { @@ -1054,7 +1061,7 @@ if ($ispaymentok) { } $paiement->fk_donation = $don->id; - $paiement->datepaid = $now; + $paiement->datep = $now; $paiement->paymenttype = $paymentTypeId; $paiement->num_payment = ''; $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; @@ -1108,7 +1115,7 @@ if ($ispaymentok) { $db->rollback(); } } else { - $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of donation '.$tmptag['DON'].'. May be payment was already recorded.'; + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type id" ('.$paymentTypeId.') to record the payment of donation '.$tmptag['DON'].'. May be payment was already recorded.'; $ispostactionok = -1; } } else { @@ -1299,7 +1306,7 @@ if ($ispaymentok) { } } } else { - $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['ATT'].'. May be payment was already recorded.'; + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type id" ('.$paymentTypeId.') to record the payment of invoice '.$tmptag['ATT'].'. May be payment was already recorded.'; $ispostactionok = -1; } } else { @@ -1492,7 +1499,7 @@ if ($ispaymentok) { } } } else { - $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['ATT'].'. May be payment was already recorded.'; + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type id" ('.$paymentTypeId.') to record the payment of invoice '.$tmptag['ATT'].'. May be payment was already recorded.'; $ispostactionok = -1; } } else { @@ -1509,9 +1516,9 @@ if ($ispaymentok) { $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION['onlinetoken'] : $PAYPALTOKEN; $payerID = empty($PAYPALPAYERID) ? $_SESSION['payerID'] : $PAYPALPAYERID; // Set by newpayment.php - $paymentType = $_SESSION['PaymentType']; $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; + $paymentType = $_SESSION['PaymentType']; // Seems used by paypal only if (is_object($object) && method_exists($object, 'call_trigger')) { // Call trigger From 0673a4826ab05d81c89417d34e8e3800a4134290 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2022 17:13:41 +0200 Subject: [PATCH 421/752] FIX currency visible into tooltip --- htdocs/compta/facture/card.php | 3 ++- htdocs/langs/en_US/banks.lang | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2cf5e13ff8b..6e271982bea 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4946,7 +4946,7 @@ if ($action == 'create') { $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,'; $sql .= ' c.code as payment_code, c.libelle as payment_label,'; $sql .= ' pf.amount,'; - $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal'; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal, ba.currency_code as bacurrency_code'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; @@ -4989,6 +4989,7 @@ if ($action == 'create') { $bankaccountstatic->ref = $objp->baref; $bankaccountstatic->label = $objp->baref; $bankaccountstatic->number = $objp->banumber; + $bankaccountstatic->currency_code = $objp->bacurrency_code; if (!empty($conf->accounting->enabled)) { $bankaccountstatic->account_number = $objp->account_number; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 331ddb62e7f..a3e0bc2f901 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -183,5 +183,5 @@ NoBankAccountDefined=No bank account defined NoRecordFoundIBankcAccount=No record found in bank account. Commonly, this occurs when a record has been deleted manually from the list of transaction in the bank account (for example during a reconciliation of the bank account). Another reason is that the payment was recorded when the module "%s" was disabled. AlreadyOneBankAccount=Already one bank account defined SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=SEPA transfer: 'Payment Type' at 'Credit Transfer' level -SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=SEPA XML: PaymentTypeInformation is mandatory and can now be placed at CreditTransferTransactionInformation level (instead of Payment level). We strongly recommend to place PaymentTypeInformation at Payment level, as all banks will not necessarily accept it at CreditTransferTransactionInformation level. Contact your bank before placing PaymentTypeInformation at CreditTransferTransactionInformation level. +SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=When generatin a SEPA XML file for Credit transfers, the section "PaymentTypeInformation" can now be placed inside the "CreditTransferTransactionInformation" section (instead of "Payment" section). We strongly recommend to keep this unchecked to place PaymentTypeInformation at Payment level, as all banks will not necessarily accept it at CreditTransferTransactionInformation level. Contact your bank before placing PaymentTypeInformation at CreditTransferTransactionInformation level. ToCreateRelatedRecordIntoBank=To create missing related bank record From 003bcd60fa4358c80dd05c281e42b4b043e1f5f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2022 19:52:40 +0200 Subject: [PATCH 422/752] FIX Add protection on bad input of payment on multicurrency invoices --- htdocs/compta/paiement.php | 9 +++- .../compta/paiement/class/paiement.class.php | 46 +++++++++++++++++-- htdocs/langs/en_US/errors.lang | 8 +--- .../class/multicurrency.class.php | 18 ++++---- 4 files changed, 60 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index df6e32f5cf8..774495091a5 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -190,6 +190,7 @@ if (empty($reshook)) { // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { + $langs->load("errors"); setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors'); $error++; } @@ -220,6 +221,8 @@ if (empty($reshook)) { $thirdparty->fetch($socid); } + $multicurrency_code = array(); + // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new Facture($db); @@ -228,6 +231,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -237,6 +241,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $multicurrency_amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } if (!empty($conf->banque->enabled)) { @@ -252,9 +257,11 @@ if (empty($reshook)) { $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->fk_account = GETPOST('accountid', 'int'); if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or @@ -271,7 +278,7 @@ if (empty($reshook)) { if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note } - $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid', 'int'), GETPOST('chqemetteur'), GETPOST('chqbank')); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 32edc0629bd..07213fe0ce0 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -72,8 +72,9 @@ class Paiement extends CommonObject public $amount; // Total amount of payment (in the main currency) public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) - public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency)> - public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency)> + public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency) + public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency) + public $multicurrency_code = array(); // array: invoice ID => currency code for that invoice public $pos_change = 0; // Excess received in TakePOS cash payment @@ -230,7 +231,7 @@ class Paiement extends CommonObject global $conf, $langs; $error = 0; - $way = $this->getWay(); + $way = $this->getWay(); // 'dolibarr' to use amount, 'customer' to use foreign multicurrency amount $now = dol_now(); @@ -239,16 +240,37 @@ class Paiement extends CommonObject $totalamount_converted = 0; $atleastonepaymentnotnull = 0; - if ($way == 'dolibarr') { + if ($way == 'dolibarr') { // Payments were entered into the column of main currency $amounts = &$this->amounts; $amounts_to_update = &$this->multicurrency_amounts; - } else { + } else { // Payments were entered into the column of foreign currency $amounts = &$this->multicurrency_amounts; $amounts_to_update = &$this->amounts; } + $currencyofpayment = ''; + foreach ($amounts as $key => $value) { // How payment is dispatch + if (empty($value)) { + continue; + } + // $key is id of invoice, $value is amount, $way is a 'dolibarr' if amount is in main currency, 'customer' if in foreign currency $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way); + // Add controls of input validity + if ($value_converted === false) { + // We failed to find the conversion for one invoice + $this->error = 'FailedToFoundTheConversionRateForInvoice'; + return -1; + } + if (empty($currencyofpayment)) { + $currencyofpayment = $this->multicurrency_code[$key]; + } + if ($currencyofpayment != $this->multicurrency_code[$key]) { + // If we have invoices with different currencies in the payment, we stop here + $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; + return -1; + } + $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -260,6 +282,19 @@ class Paiement extends CommonObject } } + if (!empty($currencyofpayment)) { + // We must check that the currency of invoices is the same than the currency of the bank + $bankaccount = new Account($this->db); + $bankaccount->fetch($this->fk_account); + $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code; + if ($currencyofpayment != $bankcurrencycode && $currencyofpayment != $conf->currency && $bankcurrencycode != $conf->currency) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorYouTryToPayInvoicesInACurrencyFromBankWithAnotherCurrency', $currencyofpayment, $bankcurrencycode); + return -1; + } + } + + $totalamount = price2num($totalamount); $totalamount_converted = price2num($totalamount_converted); @@ -305,6 +340,7 @@ class Paiement extends CommonObject if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)"; + // TODO Add multicurrency_code and multicurrency_tx $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).")"; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index c117355cd44..3a7b4abeff7 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -281,6 +281,8 @@ ErrorRequestTooLarge=Error, request too large ErrorNotApproverForHoliday=You are not the approver for leave %s ErrorAttributeIsUsedIntoProduct=This attribute is used in one or more product variants ErrorAttributeValueIsUsedIntoProduct=This attribute value is used in one or more product variants +ErrorPaymentInBothCurrency=Error, all amounts must be entered in the same column +ErrorYouTryToPayInvoicesInACurrencyFromBankWithAnotherCurrency=You try to pay invoices in the currency %s from an account with the currency %s # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. @@ -314,10 +316,8 @@ WarningTheHiddenOptionIsOn=Warning, the hidden option %s is on. WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. -<<<<<<< HEAD WarningPaypalPaymentNotCompatibleWithStrict=The value 'Strict' makes the online payment features not working correctly. Use 'Lax' instead. -<<<<<<< HEAD # Validate RequireValidValue = Value not valid RequireAtLeastXString = Requires at least %s character(s) @@ -338,7 +338,3 @@ BadSetupOfField = Error bad setup of field BadSetupOfFieldClassNotFoundForValidation = Error bad setup of field : Class not found for validation BadSetupOfFieldFileNotFound = Error bad setup of field : File not found for inclusion BadSetupOfFieldFetchNotCallable = Error bad setup of field : Fetch not callable on class -======= -======= ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git ->>>>>>> branch '14.0' of git@github.com:Dolibarr/dolibarr.git diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 1ebf33d3925..8b42f7cb25b 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -559,11 +559,11 @@ class MultiCurrency extends CommonObject /** * Get the conversion of amount with invoice rate * - * @param int $fk_facture id of facture - * @param double $amount amount to convert - * @param string $way 'dolibarr' mean the amount is in dolibarr currency - * @param string $table facture or facture_fourn - * @return double amount converted + * @param int $fk_facture id of facture + * @param double $amount amount to convert + * @param string $way 'dolibarr' mean the amount is in dolibarr currency + * @param string $table facture or facture_fourn + * @return double|boolean amount converted or false if conversion fails */ public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way = 'dolibarr', $table = 'facture') { @@ -576,16 +576,16 @@ class MultiCurrency extends CommonObject return price2num($amount / $multicurrency_tx, 'MU'); } } else { - return $amount; + return false; } } /** * Get current invoite rate * - * @param int $fk_facture id of facture - * @param string $table facture or facture_fourn - * @return bool + * @param int $fk_facture id of facture + * @param string $table facture or facture_fourn + * @return float|bool Rate of currency or false if error */ public static function getInvoiceRate($fk_facture, $table = 'facture') { From eecbc05bc33354b4cd6e4b9d472099d018f24cff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 00:00:57 +0200 Subject: [PATCH 423/752] Show amount into popup of payment --- htdocs/compta/paiement/class/paiement.class.php | 3 +++ htdocs/fourn/class/paiementfourn.class.php | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 07213fe0ce0..86dcbdeff39 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1212,6 +1212,9 @@ class Paiement extends CommonObject $label .= dol_print_date($dateofpayment, 'dayhour', 'tzuser'); } } + if ($this->amount) { + $label .= '
'.$langs->trans("Amount").': '.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency); + } if ($mode == 'withlistofinvoices') { $arraybill = $this->getBillsArray(); if (is_array($arraybill) && count($arraybill) > 0) { diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 75984c94f99..b85b373f81f 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -596,6 +596,10 @@ class PaiementFourn extends Paiement { global $langs, $conf, $hookmanager; + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + $result = ''; $text = $this->ref; // Sometimes ref contains label @@ -610,8 +614,12 @@ class PaiementFourn extends Paiement $label = img_picto('', $this->picto).' '.$langs->trans("Payment").'
'; $label .= ''.$langs->trans("Ref").': '.$text; - if ($this->datepaye ? $this->datepaye : $this->date) { - $label .= '
'.$langs->trans("Date").': '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour', 'tzuser'); + $dateofpayment = ($this->datepaye ? $this->datepaye : $this->date); + if ($dateofpayment) { + $label .= '
'.$langs->trans("Date").': '.dol_print_date($dateofpayment, 'dayhour', 'tzuser'); + } + if ($this->amount) { + $label .= '
'.$langs->trans("Amount").': '.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency); } $linkclose = ''; From 0cdc146f5b897438099524b63c3fceee872101af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 00:55:40 +0200 Subject: [PATCH 424/752] FIX add tools to fix bad bank amount in accounting with multicurrency --- htdocs/accountancy/journal/bankjournal.php | 35 +++++++++++-------- .../install/mysql/migration/14.0.0-15.0.0.sql | 5 +++ htdocs/install/mysql/migration/repair.sql | 5 +++ htdocs/install/mysql/tables/llx_bank.sql | 3 +- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 2530454d056..4841b8bf171 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -117,7 +117,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; +$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.amount_main_currency, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -142,7 +142,7 @@ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=".((int) $id_journal); -$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy +$sql .= ' AND b.amount <> 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) { $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'"; } @@ -282,6 +282,7 @@ if ($result) { $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; + $reg = array(); if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]); } else { @@ -296,6 +297,12 @@ if ($result) { $tabtype[$obj->rowid] = 'unknown'; $tabmoreinfo[$obj->rowid] = array(); + $amounttouse = $obj->amount; + if (!empty($obj->amount_main_currency)) { + // If $obj->amount_main_currency is set, it means that $obj->amount is not in same currency, we must use $obj->amount_main_currency + $amounttouse = $obj->amount_main_currency; + } + // get_url may return -1 which is not traversable if (is_array($links) && count($links) > 0) { // Now loop on each link of record in bank (code similar to bankentries_list.php) @@ -334,7 +341,7 @@ if ($result) { $societestatic->email = $tabcompany[$obj->rowid]['email']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); if ($compta_soc) { - $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; } } elseif ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; @@ -350,7 +357,7 @@ if ($result) { $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. } if ($compta_user) { - $tabtp[$obj->rowid][$compta_user] += $obj->amount; + $tabtp[$obj->rowid][$compta_user] += $amounttouse; } } elseif ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; @@ -383,7 +390,7 @@ if ($result) { $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); - $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; + $tabtp[$obj->rowid][$objmid->accountancy_code] += $amounttouse; } } elseif ($links[$key]['type'] == 'payment_donation') { $paymentdonstatic->id = $links[$key]['url_id']; @@ -391,7 +398,7 @@ if ($result) { $paymentdonstatic->fk_donation = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; - $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_donation] += $amounttouse; } elseif ($links[$key]['type'] == 'member') { $paymentsubscriptionstatic->id = $links[$key]['url_id']; $paymentsubscriptionstatic->ref = $links[$key]['url_id']; @@ -399,14 +406,14 @@ if ($result) { $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); - $tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_subscription] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; - $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_vat] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id']; @@ -438,7 +445,7 @@ if ($result) { if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. $compta_user = $userstatic->accountancy_code; if ($compta_user) { - $tabtp[$obj->rowid][$compta_user] += $obj->amount; + $tabtp[$obj->rowid][$compta_user] += $amounttouse; $tabuser[$obj->rowid] = array( 'id' => $userstatic->id, 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), @@ -465,14 +472,14 @@ if ($result) { $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word $tabpay[$obj->rowid]["account_various"] = $account_various; - $tabtp[$obj->rowid][$account_subledger] += $obj->amount; + $tabtp[$obj->rowid][$account_subledger] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; $paymentloanstatic->fk_loan = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; - //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; + //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); @@ -488,14 +495,14 @@ if ($result) { } elseif ($links[$key]['type'] == 'banktransfert') { $accountLinestatic->fetch($links[$key]['url_id']); $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); - $tabtp[$obj->rowid][$account_transfer] += $obj->amount; + $tabtp[$obj->rowid][$account_transfer] += $amounttouse; $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); } } } - $tabbq[$obj->rowid][$compta_bank] += $obj->amount; + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; // If no links were found to know the amount on thirdparty, we try to guess it. // This may happens on bank entries without the links lines to 'company'. @@ -542,7 +549,7 @@ if ($result) { } }*/ - // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; $i++; } diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index ab037313dfb..30636a8bb98 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -509,3 +509,8 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value -- VMYSQL4.3 ALTER TABLE llx_user MODIFY COLUMN fk_soc integer NULL; -- VPGSQL8.2 ALTER TABLE llx_user ALTER COLUMN fk_soc DROP NOT NULL; + +-- Add column to help to fix a very critical bug when transferring into accounting bank record of a bank account into another currency. +-- Idea is to update this column manually in v15 with value in currency of company for bank that are not into the main currency and the transfer +-- into accounting will use it in priority if value is not null. +ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 4935577cbf8..070f3a2c5da 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -557,3 +557,8 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; + +-- Sequence to fix the content of llx_bank.amount_main_currency +-- DROP TABLE tmp_bank; +-- CREATE TABLE tmp_bank SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment' INNER JOIN llx_paiement as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; +-- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; diff --git a/htdocs/install/mysql/tables/llx_bank.sql b/htdocs/install/mysql/tables/llx_bank.sql index 0e1dbc403da..d0a8e34790b 100644 --- a/htdocs/install/mysql/tables/llx_bank.sql +++ b/htdocs/install/mysql/tables/llx_bank.sql @@ -24,7 +24,8 @@ create table llx_bank tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, datev date, -- date de valeur dateo date, -- date operation - amount double(24,8) NOT NULL default 0, + amount double(24,8) NOT NULL default 0, -- amount in the currency of the bank account + amount_main_currency double(24,8) NULL, -- amount in the main currency of the company label varchar(255), fk_account integer, fk_user_author integer, From d6860ca41b49b463fa08e1b9576d009dc842c1c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 00:55:40 +0200 Subject: [PATCH 425/752] FIX bad bank amount in accounting with multicurrency --- htdocs/accountancy/journal/bankjournal.php | 35 +++-- htdocs/compta/bank/class/account.class.php | 11 +- htdocs/compta/paiement.php | 12 +- .../compta/paiement/class/paiement.class.php | 139 ++++++++++++------ htdocs/fourn/class/paiementfourn.class.php | 48 +++++- htdocs/fourn/facture/paiement.php | 12 +- .../install/mysql/migration/14.0.0-15.0.0.sql | 5 + htdocs/install/mysql/migration/repair.sql | 5 + htdocs/install/mysql/tables/llx_bank.sql | 3 +- 9 files changed, 196 insertions(+), 74 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 2530454d056..4841b8bf171 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -117,7 +117,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; +$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.amount_main_currency, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -142,7 +142,7 @@ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=".((int) $id_journal); -$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy +$sql .= ' AND b.amount <> 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) { $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'"; } @@ -282,6 +282,7 @@ if ($result) { $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; + $reg = array(); if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]); } else { @@ -296,6 +297,12 @@ if ($result) { $tabtype[$obj->rowid] = 'unknown'; $tabmoreinfo[$obj->rowid] = array(); + $amounttouse = $obj->amount; + if (!empty($obj->amount_main_currency)) { + // If $obj->amount_main_currency is set, it means that $obj->amount is not in same currency, we must use $obj->amount_main_currency + $amounttouse = $obj->amount_main_currency; + } + // get_url may return -1 which is not traversable if (is_array($links) && count($links) > 0) { // Now loop on each link of record in bank (code similar to bankentries_list.php) @@ -334,7 +341,7 @@ if ($result) { $societestatic->email = $tabcompany[$obj->rowid]['email']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); if ($compta_soc) { - $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; } } elseif ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; @@ -350,7 +357,7 @@ if ($result) { $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. } if ($compta_user) { - $tabtp[$obj->rowid][$compta_user] += $obj->amount; + $tabtp[$obj->rowid][$compta_user] += $amounttouse; } } elseif ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; @@ -383,7 +390,7 @@ if ($result) { $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); - $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; + $tabtp[$obj->rowid][$objmid->accountancy_code] += $amounttouse; } } elseif ($links[$key]['type'] == 'payment_donation') { $paymentdonstatic->id = $links[$key]['url_id']; @@ -391,7 +398,7 @@ if ($result) { $paymentdonstatic->fk_donation = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; - $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_donation] += $amounttouse; } elseif ($links[$key]['type'] == 'member') { $paymentsubscriptionstatic->id = $links[$key]['url_id']; $paymentsubscriptionstatic->ref = $links[$key]['url_id']; @@ -399,14 +406,14 @@ if ($result) { $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); - $tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_subscription] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; - $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_vat] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id']; @@ -438,7 +445,7 @@ if ($result) { if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. $compta_user = $userstatic->accountancy_code; if ($compta_user) { - $tabtp[$obj->rowid][$compta_user] += $obj->amount; + $tabtp[$obj->rowid][$compta_user] += $amounttouse; $tabuser[$obj->rowid] = array( 'id' => $userstatic->id, 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), @@ -465,14 +472,14 @@ if ($result) { $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word $tabpay[$obj->rowid]["account_various"] = $account_various; - $tabtp[$obj->rowid][$account_subledger] += $obj->amount; + $tabtp[$obj->rowid][$account_subledger] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; $paymentloanstatic->fk_loan = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; - //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; + //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); @@ -488,14 +495,14 @@ if ($result) { } elseif ($links[$key]['type'] == 'banktransfert') { $accountLinestatic->fetch($links[$key]['url_id']); $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); - $tabtp[$obj->rowid][$account_transfer] += $obj->amount; + $tabtp[$obj->rowid][$account_transfer] += $amounttouse; $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); } } } - $tabbq[$obj->rowid][$compta_bank] += $obj->amount; + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; // If no links were found to know the amount on thirdparty, we try to guess it. // This may happens on bank entries without the links lines to 'company'. @@ -542,7 +549,7 @@ if ($result) { } }*/ - // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; $i++; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 5a484e9e97c..45472008bf7 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -513,9 +513,10 @@ class Account extends CommonObject * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. * @param int $datev Date value * @param string $num_releve Label of bank receipt for reconciliation + * @param float $amount_main_currency Amount * @return int Rowid of added entry, <0 if KO */ - public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '') + public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '', $amount_main_currency = null) { // Deprecation warning if (is_numeric($oper)) { @@ -573,6 +574,7 @@ class Account extends CommonObject $accline->datev = $datev; $accline->label = $label; $accline->amount = $amount; + $accline->amount_main_currency = $amount_main_currency; $accline->fk_user_author = $user->id; $accline->fk_account = $this->id; $accline->fk_type = $oper; @@ -1789,7 +1791,8 @@ class AccountLine extends CommonObject */ public $datev; - public $amount; + public $amount; /* Amount of payment in the bank account currency */ + public $amount_main_currency; /* Amount in the currency of company if bank account use another currency */ /** * @var int ID @@ -1950,6 +1953,7 @@ class AccountLine extends CommonObject $sql .= ", datev"; $sql .= ", label"; $sql .= ", amount"; + $sql .= ", amount_main_currency"; $sql .= ", fk_user_author"; $sql .= ", num_chq"; $sql .= ", fk_account"; @@ -1964,7 +1968,8 @@ class AccountLine extends CommonObject $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", ".price2num($this->amount); - $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author : "null"); + $sql .= ", ".(empty($this->amount_main_currency) ? "NULL" : price2num($this->amount_main_currency)); + $sql .= ", ".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) : "null"); $sql .= ", ".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null"); $sql .= ", '".$this->db->escape($this->fk_account)."'"; $sql .= ", '".$this->db->escape($this->fk_type)."'"; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 96d482b33ae..30234ae92fc 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -133,7 +133,7 @@ if (empty($reshook)) { } } - $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key)); } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key)); @@ -190,6 +190,7 @@ if (empty($reshook)) { // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { + $langs->load("errors"); setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors'); $error++; } @@ -220,6 +221,8 @@ if (empty($reshook)) { $thirdparty->fetch($socid); } + $multicurrency_code = array(); + // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new Facture($db); @@ -228,6 +231,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -237,6 +241,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $multicurrency_amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } if (!empty($conf->banque->enabled)) { @@ -252,13 +257,16 @@ if (empty($reshook)) { $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->fk_account = GETPOST('accountid', 'int'); if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or // this->amounts if this->multicurrency_amounts filled. + // This also set ->amount and ->multicurrency_amount $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -271,7 +279,7 @@ if (empty($reshook)) { if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note } - $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid', 'int'), GETPOST('chqemetteur'), GETPOST('chqbank')); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 3abf38fb16e..edab2922efb 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -72,8 +72,9 @@ class Paiement extends CommonObject public $amount; // Total amount of payment (in the main currency) public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) - public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency)> - public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency)> + public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency) + public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency) + public $multicurrency_code = array(); // array: invoice ID => currency code for that invoice public $pos_change = 0; // Excess received in TakePOS cash payment @@ -82,12 +83,12 @@ class Paiement extends CommonObject public $paiementcode; // Code of payment. /** - * @var string type libelle + * @var string Type of payment label */ public $type_label; /** - * @var string type code + * @var string Type of payment code (seems duplicate with $paiementcode); */ public $type_code; @@ -230,7 +231,7 @@ class Paiement extends CommonObject global $conf, $langs; $error = 0; - $way = $this->getWay(); + $way = $this->getWay(); // 'dolibarr' to use amount, 'customer' to use foreign multicurrency amount $now = dol_now(); @@ -239,16 +240,37 @@ class Paiement extends CommonObject $totalamount_converted = 0; $atleastonepaymentnotnull = 0; - if ($way == 'dolibarr') { + if ($way == 'dolibarr') { // Payments were entered into the column of main currency $amounts = &$this->amounts; $amounts_to_update = &$this->multicurrency_amounts; - } else { + } else { // Payments were entered into the column of foreign currency $amounts = &$this->multicurrency_amounts; $amounts_to_update = &$this->amounts; } + $currencyofpayment = ''; + foreach ($amounts as $key => $value) { // How payment is dispatch + if (empty($value)) { + continue; + } + // $key is id of invoice, $value is amount, $way is a 'dolibarr' if amount is in main currency, 'customer' if in foreign currency $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way); + // Add controls of input validity + if ($value_converted === false) { + // We failed to find the conversion for one invoice + $this->error = 'FailedToFoundTheConversionRateForInvoice'; + return -1; + } + if (empty($currencyofpayment)) { + $currencyofpayment = $this->multicurrency_code[$key]; + } + if ($currencyofpayment != $this->multicurrency_code[$key]) { + // If we have invoices with different currencies in the payment, we stop here + $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; + return -1; + } + $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -260,6 +282,19 @@ class Paiement extends CommonObject } } + if (!empty($currencyofpayment)) { + // We must check that the currency of invoices is the same than the currency of the bank + $bankaccount = new Account($this->db); + $bankaccount->fetch($this->fk_account); + $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code; + if ($currencyofpayment != $bankcurrencycode && $currencyofpayment != $conf->currency && $bankcurrencycode != $conf->currency) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorYouTryToPayInvoicesInACurrencyFromBankWithAnotherCurrency', $currencyofpayment, $bankcurrencycode); + return -1; + } + } + + $totalamount = price2num($totalamount); $totalamount_converted = price2num($totalamount_converted); @@ -597,17 +632,22 @@ class Paiement extends CommonObject $result = $acc->fetch($this->fk_account); $totalamount = $this->amount; + $totalamount_main_currency = null; if (empty($totalamount)) { $totalamount = $this->total; // For backward compatibility } // if dolibarr currency != bank currency then we received an amount in customer currency (currently I don't manage the case : my currency is USD, the customer currency is EUR and he paid me in GBP. Seems no sense for me) if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) { - $totalamount = $this->multicurrency_amount; + $totalamount = $this->multicurrency_amount; // We will insert into llx_bank.amount in foreign currency + $totalamount_main_currency = $this->amount; // We will also save the amount in main currency into column llx_bank.amount_main_currency } if ($mode == 'payment_supplier') { $totalamount = -$totalamount; + if (isset($totalamount_main_currency)) { + $totalamount_main_currency = -$totalamount_main_currency; + } } // Insert payment into llx_bank @@ -621,8 +661,11 @@ class Paiement extends CommonObject $user, $emetteur_nom, $emetteur_banque, - $accountancycode - ); + $accountancycode, + null, + '', + $totalamount_main_currency + ); // Mise a jour fk_bank dans llx_paiement // On connait ainsi le paiement qui a genere l'ecriture bancaire @@ -667,7 +710,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/comm/card.php?socid=', $fac->thirdparty->name, 'company' - ); + ); if ($result <= 0) { dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror()); } @@ -685,7 +728,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/fourn/card.php?socid=', $fac->thirdparty->name, 'company' - ); + ); if ($result <= 0) { dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror()); } @@ -703,7 +746,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/compta/prelevement/card.php?id=', $this->num_payment, 'withdraw' - ); + ); } // Add link 'InvoiceRefused' in bank_url @@ -714,7 +757,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/compta/prelevement/card.php?id=', $this->num_prelevement, 'withdraw' - ); + ); } if (!$error && !$notrigger) { @@ -1241,40 +1284,40 @@ class Paiement extends CommonObject $langs->load('compta'); /*if ($mode == 0) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 1) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 5) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 6) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - }*/ + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 1) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 2) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 3) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 4) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 5) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 6) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + }*/ return ''; } diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index de9aa4eade9..db2a503673c 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -160,11 +160,12 @@ class PaiementFourn extends Paiement $error = 0; $way = $this->getWay(); + $now = dol_now(); + // Clean parameters $totalamount = 0; $totalamount_converted = 0; - - dol_syslog(get_class($this)."::create", LOG_DEBUG); + $atleastonepaymentnotnull = 0; if ($way == 'dolibarr') { $amounts = &$this->amounts; @@ -174,23 +175,62 @@ class PaiementFourn extends Paiement $amounts_to_update = &$this->amounts; } + $currencyofpayment = ''; + foreach ($amounts as $key => $value) { + if (empty($value)) { + continue; + } + // $key is id of invoice, $value is amount, $way is a 'dolibarr' if amount is in main currency, 'customer' if in foreign currency $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value ? $value : 0, $way, 'facture_fourn'); + // Add controls of input validity + if ($value_converted === false) { + // We failed to find the conversion for one invoice + $this->error = 'FailedToFoundTheConversionRateForInvoice'; + return -1; + } + if (empty($currencyofpayment)) { + $currencyofpayment = $this->multicurrency_code[$key]; + } + if ($currencyofpayment != $this->multicurrency_code[$key]) { + // If we have invoices with different currencies in the payment, we stop here + $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; + return -1; + } + $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); $newvalue = price2num($value, 'MT'); $amounts[$key] = $newvalue; $totalamount += $newvalue; + if (!empty($newvalue)) { + $atleastonepaymentnotnull++; + } } + + if (!empty($currencyofpayment)) { + // We must check that the currency of invoices is the same than the currency of the bank + $bankaccount = new Account($this->db); + $bankaccount->fetch($this->fk_account); + $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code; + if ($currencyofpayment != $bankcurrencycode && $currencyofpayment != $conf->currency && $bankcurrencycode != $conf->currency) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorYouTryToPayInvoicesInACurrencyFromBankWithAnotherCurrency', $currencyofpayment, $bankcurrencycode); + return -1; + } + } + + $totalamount = price2num($totalamount); $totalamount_converted = price2num($totalamount_converted); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $this->db->begin(); if ($totalamount <> 0) { // On accepte les montants negatifs $ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); - $now = dol_now(); if ($way == 'dolibarr') { $total = $totalamount; @@ -346,7 +386,7 @@ class PaiementFourn extends Paiement $this->total = $total; $this->multicurrency_amount = $mtotal; $this->db->commit(); - dol_syslog('PaiementFourn::Create Ok Total = '.$this->total); + dol_syslog('PaiementFourn::Create Ok Total = '.$this->amount.', Total currency = '.$this->multicurrency_amount); return $this->id; } else { $this->db->rollback(); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 33c07c58e99..cb9ca7437bb 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -252,6 +252,8 @@ if (empty($reshook)) { $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $multicurrency_code = array(); + // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new FactureFournisseur($db); @@ -260,6 +262,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -269,6 +272,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $multicurrency_amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } //var_dump($amounts); @@ -288,12 +292,16 @@ if (empty($reshook)) { $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; + $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching $paiement->paiementid = GETPOST('paiementid', 'int'); - $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml'); $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->fk_account = GETPOST('accountid', 'int'); if (!$error) { + // Create payment and update this->multicurrency_amounts if this->amounts filled or + // this->amounts if this->multicurrency_amounts filled. + // This also set ->amount and ->multicurrency_amount $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -302,7 +310,7 @@ if (empty($reshook)) { } if (!$error) { - $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', ''); + $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, GETPOST('chqemetteur'), GETPOST('chqbank')); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index ab037313dfb..30636a8bb98 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -509,3 +509,8 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value -- VMYSQL4.3 ALTER TABLE llx_user MODIFY COLUMN fk_soc integer NULL; -- VPGSQL8.2 ALTER TABLE llx_user ALTER COLUMN fk_soc DROP NOT NULL; + +-- Add column to help to fix a very critical bug when transferring into accounting bank record of a bank account into another currency. +-- Idea is to update this column manually in v15 with value in currency of company for bank that are not into the main currency and the transfer +-- into accounting will use it in priority if value is not null. +ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 4935577cbf8..070f3a2c5da 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -557,3 +557,8 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; + +-- Sequence to fix the content of llx_bank.amount_main_currency +-- DROP TABLE tmp_bank; +-- CREATE TABLE tmp_bank SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment' INNER JOIN llx_paiement as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; +-- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; diff --git a/htdocs/install/mysql/tables/llx_bank.sql b/htdocs/install/mysql/tables/llx_bank.sql index 0e1dbc403da..d0a8e34790b 100644 --- a/htdocs/install/mysql/tables/llx_bank.sql +++ b/htdocs/install/mysql/tables/llx_bank.sql @@ -24,7 +24,8 @@ create table llx_bank tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, datev date, -- date de valeur dateo date, -- date operation - amount double(24,8) NOT NULL default 0, + amount double(24,8) NOT NULL default 0, -- amount in the currency of the bank account + amount_main_currency double(24,8) NULL, -- amount in the main currency of the company label varchar(255), fk_account integer, fk_user_author integer, From 68d11f2e892468037b6aa5e18a866de4d29845bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 02:42:32 +0200 Subject: [PATCH 426/752] Fix phpunit regression --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fab80677c25..b1eb8656645 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -843,7 +843,7 @@ class Facture extends CommonInvoice $newinvoiceline->situation_percent, $newinvoiceline->fk_prev_id, $newinvoiceline->fk_unit, - $newinvoiceline->pu_ht_devise + $newinvoiceline->multicurrency_subprice ); // Defined the new fk_parent_line From c65b7fd2ffafccea49115d71e56b773017ed5e6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 02:51:40 +0200 Subject: [PATCH 427/752] Fix regression php8 --- htdocs/core/lib/pdf.lib.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d9612d58652..37223701ff7 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1167,7 +1167,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $posy = $marginwithfooter + 0; // Option for footer background color (without freetext zone) - if (!empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + if (getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', '', $fill_color = array($r, $g, $b)); @@ -1176,7 +1176,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ if ($line) { // Free text $pdf->SetXY($dims['lm'], -$posy); - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default + if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default $pdf->MultiCell(0, 3, $line, 0, $align, 0); } else { $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); @@ -1187,18 +1187,21 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetY(-$posy); // Hide footer line if footer background color is set - if (empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); } // Option for set top margin height of footer after freetext - if (!empty($conf->global->PDF_FOOTER_TOP_MARGIN) || ($conf->global->PDF_FOOTER_TOP_MARGIN === '0')) { - $posy -= $conf->global->PDF_FOOTER_TOP_MARGIN; - } else { $posy--; } + if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalString('PDF_FOOTER_TOP_MARGIN') === '0') { + // TODO Remove this case. Height should be good automatically, only $posy-- should be required. + $posy -= getDolGlobalInt('PDF_FOOTER_TOP_MARGIN'); + } else { + $posy--; + } - if ($conf->global->PDF_FOOTER_DISABLE_PAGEBREAK === '1') { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak + if (getDolGlobalString('PDF_FOOTER_DISABLE_PAGEBREAK') === '1') { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); - if ($conf->global->PDF_FOOTER_DISABLE_PAGEBREAK === '1') { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak + if (getDolGlobalString('PDF_FOOTER_DISABLE_PAGEBREAK') === '1') { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak $posy -= $mycustomfooterheight - 3; } else { @@ -1207,7 +1210,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $posy = $marginwithfooter + 0; // Option for footer background color (without freetext zone) - if (!empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + if (getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR, '%d, %d, %d'); $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak $pdf->Rect(0, $dims['hk'] - $posy + $freetextheight, $dims['wk'] + 1, $marginwithfooter + 1, 'F', '', $fill_color = array($r, $g, $b)); @@ -1216,7 +1219,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ if ($line) { // Free text $pdf->SetXY($dims['lm'], -$posy); - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default + if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default $pdf->MultiCell(0, 3, $line, 0, $align, 0); } else { $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); @@ -1227,14 +1230,17 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetY(-$posy); // Hide footer line if footer background color is set - if (empty($conf->global->PDF_FOOTER_BACKGROUND_COLOR)) { + if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); } // Option for set top margin height of footer after freetext - if (!empty($conf->global->PDF_FOOTER_TOP_MARGIN) || ($conf->global->PDF_FOOTER_TOP_MARGIN === '0')) { - $posy -= $conf->global->PDF_FOOTER_TOP_MARGIN; - } else { $posy--; } + if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalString('PDF_FOOTER_TOP_MARGIN') === '0') { + // TODO Remove this case. Height should be good automatically, only $posy-- should be required. + $posy -= getDolGlobalString('PDF_FOOTER_TOP_MARGIN'); + } else { + $posy--; + } if (!empty($line1)) { $pdf->SetFont('', 'B', 7); From 631d2da6b35be88d8ca9cd064606431a35dd6336 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 03:26:38 +0200 Subject: [PATCH 428/752] Fix php8 --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ac26cf0c56a..9d122cfce7e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -778,7 +778,7 @@ class ActionComm extends CommonObject $sql .= " a.fk_contact, a.percent as percentage,"; $sql .= " a.fk_element as elementid, a.elementtype,"; $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; - $sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,"; + $sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_sender, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,"; $sql .= " c.id as type_id, c.type as type_type, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; $sql .= " s.nom as socname,"; $sql .= " u.firstname, u.lastname as lastname,"; From 1aecff854bd9dc79d7b64f27d4d8c339a7bf61fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 14:40:29 +0200 Subject: [PATCH 429/752] Fix missing limit in redirect --- htdocs/compta/bank/bankentries_list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 524d8c79d4a..421080951f2 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -276,6 +276,9 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if ($offset) { $param .= '&offset='.urlencode($offset); } + if ($limit) { + $param .= '&limit='.urlencode($limit); + } if ($search_conciliated != '' && $search_conciliated != '-1') { $param .= '&search_conciliated='.urlencode($search_conciliated); } From da0fcb556fee1104cbdce6398d861f76b61fc392 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 15:28:01 +0200 Subject: [PATCH 430/752] Fix css --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 3889ab026a0..5a9b1054773 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3014,7 +3014,7 @@ if ($action == 'create') { } // Show link for "recalculate" if ($object->getVentilExportCompta() == 0) { - $s = $langs->trans("ReCalculate").' '; + $s = ''.$langs->trans("ReCalculate").' '; $s .= ''.$langs->trans("Mode1").''; $s .= ' / '; $s .= ''.$langs->trans("Mode2").''; From 4ff1c4467c3ec6311e922cd7a202b3d8b60f7c85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 15:48:25 +0200 Subject: [PATCH 431/752] Clean package.json to avoid false alert of security (not used) --- package.json => test/acceptance/package.json | 6 ------ 1 file changed, 6 deletions(-) rename package.json => test/acceptance/package.json (71%) diff --git a/package.json b/test/acceptance/package.json similarity index 71% rename from package.json rename to test/acceptance/package.json index 338ced65637..9bf55927540 100644 --- a/package.json +++ b/test/acceptance/package.json @@ -7,10 +7,4 @@ "scripts": { "test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/setup.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty" }, - "dependencies": { - "chart.js": "^2.9.4", - "cucumber-pretty": "^6.0.0", - "jquery": "^3.6.0", - "node-fetch": "^3.1.1" - } } From 71516ecd3e92961001a5b6fb27b84461f4403c71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 15:48:25 +0200 Subject: [PATCH 432/752] Clean package.json to avoid false alert of security (not used) Conflicts: package.json --- package.json => test/acceptance/package.json | 5 ----- 1 file changed, 5 deletions(-) rename package.json => test/acceptance/package.json (75%) diff --git a/package.json b/test/acceptance/package.json similarity index 75% rename from package.json rename to test/acceptance/package.json index 02c9b2abcb9..9bf55927540 100644 --- a/package.json +++ b/test/acceptance/package.json @@ -7,9 +7,4 @@ "scripts": { "test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/setup.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty" }, - "dependencies": { - "chart.js": "^2.9.4", - "cucumber-pretty": "^6.0.0", - "node-fetch": "^2.6.1" - } } From 857048c9bd1aa38e00ddbdc868a3936963805f1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Apr 2022 15:56:01 +0200 Subject: [PATCH 433/752] Rename file to avoid false alert due to fucking composer that brings tons of useless libraries with vulnerabilities. --- composer.json => composer.json.disabled | 0 composer.lock | 2347 ----------------------- 2 files changed, 2347 deletions(-) rename composer.json => composer.json.disabled (100%) delete mode 100644 composer.lock diff --git a/composer.json b/composer.json.disabled similarity index 100% rename from composer.json rename to composer.json.disabled diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 93a719913a5..00000000000 --- a/composer.lock +++ /dev/null @@ -1,2347 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "ea80667c2a5aaabe388fbae4716d7dfb", - "packages": [ - { - "name": "ckeditor/ckeditor", - "version": "4.12.1", - "source": { - "type": "git", - "url": "https://github.com/ckeditor/ckeditor-releases.git", - "reference": "b1a25e93ae0b038f45dcba458f4c2c18bd7318e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ckeditor/ckeditor-releases/zipball/b1a25e93ae0b038f45dcba458f4c2c18bd7318e5", - "reference": "b1a25e93ae0b038f45dcba458f4c2c18bd7318e5", - "shasum": "" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+", - "LGPL-2.1+", - "MPL-1.1+" - ], - "authors": [ - { - "name": "CKSource", - "homepage": "http://cksource.com" - } - ], - "description": "JavaScript WYSIWYG web text editor.", - "homepage": "http://ckeditor.com", - "keywords": [ - "CKEditor", - "editor", - "fckeditor", - "html", - "javascript", - "richtext", - "text", - "wysiwyg" - ], - "support": { - "forum": "http://ckeditor.com/forums", - "issues": "http://dev.ckeditor.com", - "source": "http://github.com/ckeditor/ckeditor-dev", - "wiki": "http://docs.ckeditor.com" - }, - "time": "2019-06-28T10:41:23+00:00" - }, - { - "name": "maximebf/debugbar", - "version": "v1.15.1", - "source": { - "type": "git", - "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6c4277f6117e4864966c9cb58fb835cee8c74a1e", - "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "psr/log": "^1.0", - "symfony/var-dumper": "^2.6|^3|^4" - }, - "require-dev": { - "phpunit/phpunit": "^5" - }, - "suggest": { - "kriswallsmith/assetic": "The best way to manage assets", - "monolog/monolog": "Log using Monolog", - "predis/predis": "Redis storage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-4": { - "DebugBar\\": "src/DebugBar/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Maxime Bouroumeau-Fuseau", - "email": "maxime.bouroumeau@gmail.com", - "homepage": "http://maximebf.com" - }, - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "Debug bar in the browser for php application", - "homepage": "https://github.com/maximebf/php-debugbar", - "keywords": [ - "debug", - "debugbar" - ], - "support": { - "issues": "https://github.com/maximebf/php-debugbar/issues", - "source": "https://github.com/maximebf/php-debugbar/tree/v1.15.1" - }, - "time": "2019-09-24T14:55:42+00:00" - }, - { - "name": "mike42/escpos-php", - "version": "v2.2", - "source": { - "type": "git", - "url": "https://github.com/mike42/escpos-php.git", - "reference": "e5496cf819b048b11877117bd14a9cea4fb17c03" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mike42/escpos-php/zipball/e5496cf819b048b11877117bd14a9cea4fb17c03", - "reference": "e5496cf819b048b11877117bd14a9cea4fb17c03", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "guzzlehttp/guzzle": "^5.3", - "phpunit/phpunit": "^4.8", - "squizlabs/php_codesniffer": "^3.2" - }, - "suggest": { - "ext-gd": "Used for image printing if present.", - "ext-imagick": "Will be used for image printing if present. Required for PDF printing or use of custom fonts.", - "guzzlehttp/guzzle": "Allows the use of the ApiConnector to send print jobs over HTTP." - }, - "type": "library", - "autoload": { - "psr-4": { - "Mike42\\": "src/Mike42" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Billington", - "email": "michael.billington@gmail.com" - } - ], - "description": "PHP receipt printer library for use with ESC/POS-compatible thermal and impact printers", - "homepage": "https://github.com/mike42/escpos-php", - "keywords": [ - "ESC-POS", - "driver", - "escpos", - "print", - "receipt" - ], - "support": { - "issues": "https://github.com/mike42/escpos-php/issues", - "source": "https://github.com/mike42/escpos-php/tree/v2.2" - }, - "time": "2019-10-05T05:59:00+00:00" - }, - { - "name": "mobiledetect/mobiledetectlib", - "version": "2.8.39", - "source": { - "type": "git", - "url": "https://github.com/serbanghita/Mobile-Detect.git", - "reference": "0fd6753003fc870f6e229bae869cc1337c99bc45" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/0fd6753003fc870f6e229bae869cc1337c99bc45", - "reference": "0fd6753003fc870f6e229bae869cc1337c99bc45", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8.35||~5.7" - }, - "type": "library", - "autoload": { - "psr-0": { - "Detection": "namespaced/" - }, - "classmap": [ - "Mobile_Detect.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Serban Ghita", - "email": "serbanghita@gmail.com", - "homepage": "http://mobiledetect.net", - "role": "Developer" - } - ], - "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.", - "homepage": "https://github.com/serbanghita/Mobile-Detect", - "keywords": [ - "detect mobile devices", - "mobile", - "mobile detect", - "mobile detector", - "php mobile detect" - ], - "support": { - "issues": "https://github.com/serbanghita/Mobile-Detect/issues", - "source": "https://github.com/serbanghita/Mobile-Detect/tree/2.8.39" - }, - "time": "2022-02-17T19:24:25+00:00" - }, - { - "name": "nnnick/chartjs", - "version": "v2.9.4", - "source": { - "type": "git", - "url": "https://github.com/chartjs/Chart.js.git", - "reference": "9bd4cf82fda9f50a5fb50b72843e06ab88124278" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/chartjs/Chart.js/zipball/9bd4cf82fda9f50a5fb50b72843e06ab88124278", - "reference": "9bd4cf82fda9f50a5fb50b72843e06ab88124278", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "release/2.0": "v2.0-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "NICK DOWNIE", - "email": "hello@nickdownie.com" - } - ], - "description": "Simple HTML5 charts using the canvas element.", - "homepage": "https://www.chartjs.org/", - "keywords": [ - "JS", - "chart" - ], - "support": { - "issues": "https://github.com/chartjs/Chart.js/issues", - "source": "https://github.com/chartjs/Chart.js/tree/v2.9.4" - }, - "time": "2020-10-19T12:22:11+00:00" - }, - { - "name": "phpoffice/phpexcel", - "version": "1.8.2", - "source": { - "type": "git", - "url": "https://github.com/PHPOffice/PHPExcel.git", - "reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/1441011fb7ecdd8cc689878f54f8b58a6805f870", - "reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "ext-xml": "*", - "ext-xmlwriter": "*", - "php": "^5.2|^7.0" - }, - "require-dev": { - "squizlabs/php_codesniffer": "2.*" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1" - ], - "authors": [ - { - "name": "Maarten Balliauw", - "homepage": "http://blog.maartenballiauw.be" - }, - { - "name": "Erik Tilt" - }, - { - "name": "Franck Lefevre", - "homepage": "http://rootslabs.net" - }, - { - "name": "Mark Baker", - "homepage": "http://markbakeruk.net" - } - ], - "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", - "homepage": "https://github.com/PHPOffice/PHPExcel", - "keywords": [ - "OpenXML", - "excel", - "xlsx" - ], - "abandoned": "phpoffice/phpspreadsheet", - "time": "2018-11-22T23:07:24+00:00" - }, - { - "name": "psr/log", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/1.1.3" - }, - "time": "2020-03-23T09:12:05+00:00" - }, - { - "name": "restler/framework", - "version": "3.0.0-RC6", - "target-dir": "Luracast/Restler", - "source": { - "type": "git", - "url": "https://github.com/Luracast/Restler-Framework.git", - "reference": "d52e61600d153bca60a287c35141c5c01863127b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/d52e61600d153bca60a287c35141c5c01863127b", - "reference": "d52e61600d153bca60a287c35141c5c01863127b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "replace": { - "luracast/restler": "3.*" - }, - "suggest": { - "bshaffer/oauth2-server-php": "If you want to use OAuth2 for authentication", - "illuminate/view": "If you want to use laravel blade templates with Html format", - "mustache/mustache": "If you want to use mustache/handlebar templates with Html format", - "rodneyrehm/plist": "If you need Apple plist binary/xml format", - "symfony/yaml": "If you need YAML format", - "twig/twig": "If you want to use twig templates with Html format", - "zendframework/zendamf": "If you need AMF format" - }, - "type": "library", - "extra": { - "branch-alias": { - "master": "v3.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Luracast\\Restler": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1" - ], - "authors": [ - { - "name": "Luracast", - "email": "arul@luracast.com" - } - ], - "description": "Just the Restler Framework without the tests and examples", - "homepage": "http://luracast.com/products/restler/", - "keywords": [ - "api", - "framework", - "rest", - "server" - ], - "support": { - "source": "https://github.com/Luracast/Restler-Framework/tree/3.0.0-RC6" - }, - "time": "2020-02-13T16:05:12+00:00" - }, - { - "name": "stripe/stripe-php", - "version": "v6.43.1", - "source": { - "type": "git", - "url": "https://github.com/stripe/stripe-php.git", - "reference": "42fcdaf99c44bb26937223f8eae1f263491d5ab8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/stripe/stripe-php/zipball/42fcdaf99c44bb26937223f8eae1f263491d5ab8", - "reference": "42fcdaf99c44bb26937223f8eae1f263491d5ab8", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "php-coveralls/php-coveralls": "1.*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0", - "symfony/process": "~2.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "Stripe\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Stripe and contributors", - "homepage": "https://github.com/stripe/stripe-php/contributors" - } - ], - "description": "Stripe PHP Library", - "homepage": "https://stripe.com/", - "keywords": [ - "api", - "payment processing", - "stripe" - ], - "support": { - "issues": "https://github.com/stripe/stripe-php/issues", - "source": "https://github.com/stripe/stripe-php/tree/master" - }, - "time": "2019-08-29T16:56:12+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.20.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.20-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T14:02:19+00:00" - }, - { - "name": "symfony/var-dumper", - "version": "v3.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/var-dumper.git", - "reference": "737e07704cca83f9dd0af926d45ce27eedc25657" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/737e07704cca83f9dd0af926d45ce27eedc25657", - "reference": "737e07704cca83f9dd0af926d45ce27eedc25657", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "twig/twig": "~1.20|~2.0" - }, - "suggest": { - "ext-symfony_debug": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "files": [ - "Resources/functions/dump.php" - ], - "psr-4": { - "Symfony\\Component\\VarDumper\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony mechanism for exploring and dumping PHP variables", - "homepage": "https://symfony.com", - "keywords": [ - "debug", - "dump" - ], - "support": { - "source": "https://github.com/symfony/var-dumper/tree/master" - }, - "time": "2015-11-18T13:48:51+00:00" - }, - { - "name": "tecnickcom/tcpdf", - "version": "6.3.2", - "source": { - "type": "git", - "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "9fde7bb9b404b945e7ea88fb7eccd23d9a4e324b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/9fde7bb9b404b945e7ea88fb7eccd23d9a4e324b", - "reference": "9fde7bb9b404b945e7ea88fb7eccd23d9a4e324b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "config", - "include", - "tcpdf.php", - "tcpdf_parser.php", - "tcpdf_import.php", - "tcpdf_barcodes_1d.php", - "tcpdf_barcodes_2d.php", - "include/tcpdf_colors.php", - "include/tcpdf_filters.php", - "include/tcpdf_font_data.php", - "include/tcpdf_fonts.php", - "include/tcpdf_images.php", - "include/tcpdf_static.php", - "include/barcodes/datamatrix.php", - "include/barcodes/pdf417.php", - "include/barcodes/qrcode.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0" - ], - "authors": [ - { - "name": "Nicola Asuni", - "email": "info@tecnick.com", - "role": "lead" - } - ], - "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", - "homepage": "http://www.tcpdf.org/", - "keywords": [ - "PDFD32000-2008", - "TCPDF", - "barcodes", - "datamatrix", - "pdf", - "pdf417", - "qrcode" - ], - "support": { - "source": "https://github.com/tecnickcom/TCPDF/tree/6.3.2" - }, - "time": "2019-09-20T09:35:01+00:00" - } - ], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^8.0", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.0" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2020-11-10T18:47:58+00:00" - }, - { - "name": "php-parallel-lint/php-console-color", - "version": "v0.3", - "source": { - "type": "git", - "url": "https://github.com/php-parallel-lint/PHP-Console-Color.git", - "reference": "b6af326b2088f1ad3b264696c9fd590ec395b49e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Color/zipball/b6af326b2088f1ad3b264696c9fd590ec395b49e", - "reference": "b6af326b2088f1ad3b264696c9fd590ec395b49e", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "replace": { - "jakub-onderka/php-console-color": "*" - }, - "require-dev": { - "php-parallel-lint/php-code-style": "1.0", - "php-parallel-lint/php-parallel-lint": "1.0", - "php-parallel-lint/php-var-dump-check": "0.*", - "phpunit/phpunit": "~4.3", - "squizlabs/php_codesniffer": "1.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "JakubOnderka\\PhpConsoleColor\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Jakub Onderka", - "email": "jakub.onderka@gmail.com" - } - ], - "support": { - "issues": "https://github.com/php-parallel-lint/PHP-Console-Color/issues", - "source": "https://github.com/php-parallel-lint/PHP-Console-Color/tree/master" - }, - "time": "2020-05-14T05:47:14+00:00" - }, - { - "name": "php-parallel-lint/php-console-highlighter", - "version": "v0.5", - "source": { - "type": "git", - "url": "https://github.com/php-parallel-lint/PHP-Console-Highlighter.git", - "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Highlighter/zipball/21bf002f077b177f056d8cb455c5ed573adfdbb8", - "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.4.0", - "php-parallel-lint/php-console-color": "~0.2" - }, - "replace": { - "jakub-onderka/php-console-highlighter": "*" - }, - "require-dev": { - "php-parallel-lint/php-code-style": "~1.0", - "php-parallel-lint/php-parallel-lint": "~1.0", - "php-parallel-lint/php-var-dump-check": "~0.1", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~1.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "JakubOnderka\\PhpConsoleHighlighter\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jakub Onderka", - "email": "acci@acci.cz", - "homepage": "http://www.acci.cz/" - } - ], - "description": "Highlight PHP code in terminal", - "support": { - "issues": "https://github.com/php-parallel-lint/PHP-Console-Highlighter/issues", - "source": "https://github.com/php-parallel-lint/PHP-Console-Highlighter/tree/master" - }, - "time": "2020-05-13T07:37:49+00:00" - }, - { - "name": "php-parallel-lint/php-parallel-lint", - "version": "v0.9.2", - "source": { - "type": "git", - "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", - "reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/2ead2e4043ab125bee9554f356e0a86742c2d4fa", - "reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "jakub-onderka/php-console-highlighter": "~0.3", - "nette/tester": "~1.3" - }, - "suggest": { - "jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet" - }, - "bin": [ - "parallel-lint" - ], - "type": "library", - "autoload": { - "classmap": [ - "./" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Jakub Onderka", - "email": "jakub.onderka@gmail.com" - } - ], - "description": "This tool check syntax of PHP files about 20x faster than serial check.", - "homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint", - "support": { - "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v0.9.2" - }, - "time": "2015-12-15T10:42:16+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.2.2", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" - }, - "time": "2020-09-03T19:13:55+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" - }, - "time": "2020-09-17T18:55:26+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.10.3", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" - }, - "time": "2020-03-05T15:02:03+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/2.2" - }, - "time": "2015-10-06T15:47:00+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5" - }, - "time": "2017-11-27T13:52:08+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" - }, - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/master" - }, - "time": "2017-02-26T11:10:40+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.12", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/1.4" - }, - "abandoned": true, - "time": "2017-12-04T08:55:13+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.36", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/4.8.36" - }, - "time": "2017-06-21T08:07:12+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues", - "source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/2.3" - }, - "abandoned": true, - "time": "2015-10-02T06:51:40+00:00" - }, - { - "name": "phpunit/phpunit-selenium", - "version": "2.0.3", - "source": { - "type": "git", - "url": "https://github.com/giorgiosironi/phpunit-selenium.git", - "reference": "013037eeea481657d236431634042648797e1da8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/giorgiosironi/phpunit-selenium/zipball/013037eeea481657d236431634042648797e1da8", - "reference": "013037eeea481657d236431634042648797e1da8", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-dom": "*", - "php": ">=5.3.3", - "phpunit/phpunit": "~4.8", - "sebastian/comparator": "~1.0" - }, - "require-dev": { - "phing/phing": "2.*" - }, - "type": "library", - "autoload": { - "classmap": [ - "PHPUnit/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Giorgio Sironi", - "email": "info@giorgiosironi.com", - "role": "developer" - }, - { - "name": "Ivan Kurnosov", - "email": "zerkms@zerkms.com", - "role": "developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "original developer" - } - ], - "description": "Selenium Server integration for PHPUnit", - "homepage": "http://www.phpunit.de/", - "keywords": [ - "phpunit", - "selenium", - "testing", - "xunit" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/phpunit-selenium/issues", - "source": "https://github.com/giorgiosironi/phpunit-selenium/tree/2.x" - }, - "time": "2017-01-23T22:15:32+00:00" - }, - { - "name": "sebastian/comparator", - "version": "1.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/1.2" - }, - "time": "2017-01-29T09:50:25+00:00" - }, - { - "name": "sebastian/diff", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/1.4" - }, - "time": "2017-05-22T07:24:03+00:00" - }, - { - "name": "sebastian/environment", - "version": "1.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/1.3" - }, - "time": "2016-08-18T05:49:44+00:00" - }, - { - "name": "sebastian/exporter", - "version": "1.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/master" - }, - "time": "2016-06-17T09:04:28+00:00" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/1.1.1" - }, - "time": "2015-10-12T03:26:01+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/master" - }, - "time": "2016-10-03T07:41:43+00:00" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/1.0.6" - }, - "time": "2015-06-21T13:59:46+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "2.9.2", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "bin": [ - "scripts/phpcs", - "scripts/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" - }, - "time": "2018-11-07T22:31:41+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.20.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.20-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T14:02:19+00:00" - }, - { - "name": "symfony/yaml", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "88289caa3c166321883f67fe5130188ebbb47094" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/88289caa3c166321883f67fe5130188ebbb47094", - "reference": "88289caa3c166321883f67fe5130188ebbb47094", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.9.1", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<3.9.1" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" - }, - "type": "library", - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozart/assert/issues", - "source": "https://github.com/webmozart/assert/tree/master" - }, - "time": "2020-07-08T17:02:28+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "restler/framework": 5 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.6.0", - "ext-curl": "*" - }, - "platform-dev": [], - "plugin-api-version": "2.0.0" -} From d7da57960f36d9fb104bc47b45c4ecffc93ce6ea Mon Sep 17 00:00:00 2001 From: javierybar <36415318+javierybar@users.noreply.github.com> Date: Sun, 10 Apr 2022 15:33:35 +0200 Subject: [PATCH 434/752] FIX Tax 2 is lost when order is invoiced --- htdocs/core/actions_massactions.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 22e5bb3f1a6..a45d4a3b17f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -657,6 +657,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. } else { // If we want one invoice per order or if there is no first invoice yet for this thirdparty. $objecttmp->socid = $cmd->socid; + $objecttmp->fetch_thirdparty(); $objecttmp->type = $objecttmp::TYPE_STANDARD; $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id; $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id; From 40720fad25fdeaf1fd9b4ff059567afaf509937d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2022 02:01:32 +0200 Subject: [PATCH 435/752] Fix php8 compatibility --- htdocs/adherents/type.php | 8 ++++---- htdocs/core/class/commonstickergenerator.class.php | 2 +- .../modules/printsheet/doc/pdf_standardlabel.class.php | 2 +- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- htdocs/main.inc.php | 7 ++++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 76dd0617cee..eb3c83d57dd 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -358,7 +358,7 @@ if ($action == 'create') { print '
'; print ''; // Morphy @@ -375,7 +375,7 @@ if ($action == 'create') { print ''; print ''; print ''; diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 284b41ee4ba..8085adf6283 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -289,7 +289,7 @@ abstract class CommonStickerGenerator // phpcs:enable $this->_Metric = $format['metric']; $this->_Avery_Name = $format['name']; - $this->_Avery_Code = $format['code']; + $this->_Avery_Code = empty($format['code'])?'':$format['code']; $this->_Margin_Left = $this->convertMetric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); $this->_Margin_Top = $this->convertMetric($format['marginTop'], $this->_Metric, $this->_Metric_Doc); $this->_X_Space = $this->convertMetric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc); diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 079b46003c4..bf1da990923 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -135,7 +135,7 @@ class pdf_standardlabel extends CommonStickerGenerator $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image $tmp = dol_getImageSize($photo, false); - if ($tmp['height']) { + if (!empty($tmp['height'])) { $imgratio = $tmp['width'] / $tmp['height']; if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index bbbae8afd16..3db65e198c5 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -40,7 +40,7 @@ if (!is_object($form)) { ?> Date: Mon, 11 Apr 2022 02:09:24 +0200 Subject: [PATCH 436/752] Fix update note --- htdocs/adherents/type.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index eb3c83d57dd..bcd6c99afbf 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -125,6 +125,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); + $object->note_public = trim($comment); $object->mail_valid = trim($mail_valid); $object->vote = (int) $vote; @@ -176,6 +177,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) { $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); + $object->note_public = trim($comment); $object->mail_valid = trim($mail_valid); $object->vote = (boolean) trim($vote); @@ -783,7 +785,7 @@ if ($rowid > 0) { print ''; print ''; // Morphy From 18488cf1dde807699899ca6c95c2e87482a4d285 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 11 Apr 2022 13:53:35 +0200 Subject: [PATCH 437/752] FIX replenish and manage product stock by warhouse --- htdocs/product/stock/replenish.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 0f13770d3b3..a4ce5577361 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -904,10 +904,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } // Desired stock - print ''; + print ''; // Limit stock for alert - print ''; + print ''; // Current stock (all warehouses) print ''; // To order - print ''; + print ''; // Supplier print ''; print ''; print ''; + print ''; } $db->free($result); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a20d2cd62b2..b9812d8eec3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6174,19 +6174,22 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param integer $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param integer $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param integer $set_time_end Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). - * @param string $prefix Prefix for fields name - * @param string $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only - * @return string Html for selectDate + * @param string $prefix Prefix for fields name + * @param string $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only + * @param string $forcenewline Force new line between the 2 dates. + * @return string Html for selectDate * @see form_date(), select_month(), select_year(), select_dayofweek() */ - public function selectDateToDate($set_time = '', $set_time_end = '', $prefix = 're', $empty = 0) + public function selectDateToDate($set_time = '', $set_time_end = '', $prefix = 're', $empty = 0, $forcenewline = 0) { global $langs; $ret = $this->selectDate($set_time, $prefix.'_start', 0, 0, $empty, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("from"), 'tzuserrel'); - $ret .= '
'; + if ($forcenewline) { + $ret .= '
'; + } $ret .= $this->selectDate($set_time_end, $prefix.'_end', 0, 0, $empty, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"), 'tzuserrel'); return $ret; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index b955fa4a51d..1d3faca93cb 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -790,7 +790,7 @@ class FormFile } // Button - $genbutton = 'trans("FileSharedViaALink"), 'globe').' '; - $out .= ''; + $out .= ''; $out .= ajax_autoselect('downloadlink'.$file['rowid']); } else { //print ''.$langs->trans("FileNotShared").''; @@ -1451,7 +1451,7 @@ class FormFile $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); print img_picto($langs->trans("FileSharedViaALink"), 'globe').' '; - print ''; + print ''; } else { //print ''.$langs->trans("FileNotShared").''; } @@ -1931,7 +1931,7 @@ class FormFile $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); print img_picto($langs->trans("FileSharedViaALink"), 'globe').' '; - print ''; + print ''; } //if (! empty($useinecm) && $useinecm != 6) print ''; + print ''; } else { print $fulllink; } diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 96409faf2f9..8629044f83b 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1426,7 +1426,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $out .= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); } // Button - $genbutton = 'trans("Generate"); - $genbutton = '; font-weight: ; vertical-align: middle; - height: 24px; + height: 28px; } tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, form.liste_titre div a, div.liste_titre a { text-shadow: none !important; @@ -4222,8 +4222,8 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nt background: -moz-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); } -.noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), -.noborder .oddeven.tagtr:nth-child(even):not(:last-child) .tagtd:not(.liste_titre) +.noborder > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), +.noborder .oddeven.tagtr:nth-child(even):not(:last-of-type) .tagtd:not(.liste_titre) { border-bottom: 1px solid #e0e0e0; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9189f81856a..5ebeb73261e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -466,6 +466,9 @@ input, select { -webkit-box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); } +#mainbody input.buttongen, #mainbody button.buttongen { + padding: 3px 4px; +} input.button.massactionconfirmed { margin: 4px; @@ -4149,7 +4152,7 @@ tr.liste_titre th, th.liste_titre, tr.liste_titre td, td.liste_titre, form.liste font-family: ; font-weight: ; vertical-align: middle; - height: 24px; + height: 28px; } tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, form.liste_titre div a, div.liste_titre a { text-shadow: none !important; @@ -4275,8 +4278,8 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nt background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); } -.noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), -.noborder .tagtr:nth-child(even):not(:last-child) .oddeven.tagtd:not(.liste_titre) +.noborder > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), +.noborder .tagtr:nth-child(even):not(:last-of-type) .oddeven.tagtd:not(.liste_titre) { border-bottom: 1px solid #ddd; } From 8f3335f75d5cf5908e15aaece46fb557385eb9ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2022 21:17:35 +0200 Subject: [PATCH 448/752] CSS --- htdocs/user/bank.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 16030f0f95c..fe59f002baa 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -619,7 +619,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $db->free($resql); if ($num <= 0) { - print '
'.$langs->trans('NatureOfThirdParty').''; + print '
'.$langs->trans('NatureOfThirdParty').''; print $object->getTypeUrl(1); print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); print '
'.$langs->trans("Amount").''; - print ''; + print ''; print '
'.$langs->trans("VoteAllowed").''; @@ -389,12 +389,12 @@ if ($action == 'create') { print '
'.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('comment', (GETPOSTISSET('comment') ? GETPOST('comment', 'restricthtml') : $object->note_public), '', 200, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '
'.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', GETPOSTISSET('mail_valid') ? GETPOST('mail_valid') : $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); print '
'.($fk_entrepot > 0 ? $desiredstockwarehouse : $desiredstock).''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $desiredstockwarehouse : $desiredstock).''.($fk_entrepot > 0 ? $alertstockwarehouse : $alertstock).''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $alertstockwarehouse : $alertstock).''.$warning.$stock; @@ -923,7 +923,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''.$ordered.' '.$picto.''; From dd6238cb2de55d0d4caf0a0384ea76c5e09538d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2022 15:24:39 +0200 Subject: [PATCH 438/752] Try to save on fetch --- htdocs/core/actions_massactions.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index a45d4a3b17f..c5ff1d8f82a 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -657,7 +657,8 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. } else { // If we want one invoice per order or if there is no first invoice yet for this thirdparty. $objecttmp->socid = $cmd->socid; - $objecttmp->fetch_thirdparty(); + $objecttmp->thirdparty = $cmd->thirdparty; + $objecttmp->type = $objecttmp::TYPE_STANDARD; $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id; $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id; From 67e7c91c3ed34b1c8a0f94c0e5032e4ee7ce8edb Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Mon, 11 Apr 2022 15:47:38 +0200 Subject: [PATCH 439/752] pmp inventory conf MAIN_PRODUCT_PERENTITY_SHARED --- htdocs/product/inventory/inventory.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 2b21de99079..77cdc965164 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -194,6 +194,15 @@ if (empty($reshook)) { setEventMessages($db->lasterror(), null, 'errors'); break; } + if(!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } } // Update line with id of stock movement (and the start quantity if it has changed this last recording) From ddb50264aeb5c132ec89aa39c09c074f0b65e234 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 11 Apr 2022 13:58:59 +0000 Subject: [PATCH 440/752] Fixing style errors. --- htdocs/product/inventory/inventory.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 77cdc965164..9cef5671041 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -194,15 +194,15 @@ if (empty($reshook)) { setEventMessages($db->lasterror(), null, 'errors'); break; } - if(!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; - $resqlpmp = $db->query($sqlpmp); - if (! $resqlpmp) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - } + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } } // Update line with id of stock movement (and the start quantity if it has changed this last recording) From af5444dc910ca098b1e0dd9687aaec892f412f0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2022 16:48:56 +0200 Subject: [PATCH 441/752] FIX ref not set in message of closing shipment --- htdocs/expedition/class/expedition.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3415dabc33d..5b3e5886639 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2210,7 +2210,6 @@ class Expedition extends CommonObject $this->statut = self::STATUS_CLOSED; - // If stock increment is done on closing if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -2221,10 +2220,12 @@ class Expedition extends CommonObject // TODO possibilite d'expedier a partir d'une propale ou autre origine ? $sql = "SELECT cd.fk_product, cd.subprice,"; $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " e.ref,"; $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expedition as e ON ed.fk_expedition = e.rowid"; $sql .= " WHERE ed.fk_expedition = ".((int) $this->id); $sql .= " AND cd.rowid = ed.fk_origin_line"; @@ -2252,7 +2253,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2262,7 +2263,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; From 89b7c8298b4f7f27b4d3b08079014826437677a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Mon, 11 Apr 2022 17:25:45 +0200 Subject: [PATCH 442/752] Module builder: Translate permissions label --- htdocs/modulebuilder/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index f3922aa6342..f8abd703bf0 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3008,7 +3008,7 @@ if ($module == 'initmodule') print ''; - print $perm[1]; + print $langs->trans($perm[1]); print ''; From 480fda43c5360428379b2090d8f95189aa73cab2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2022 17:34:19 +0200 Subject: [PATCH 443/752] Clean code --- htdocs/expedition/class/expedition.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 5b3e5886639..0dec85b2e4f 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2179,8 +2179,8 @@ class Expedition extends CommonObject $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut='.self::STATUS_CLOSED; - $sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0'; + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET fk_statut = ".self::STATUS_CLOSED; + $sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut > 0"; $resql = $this->db->query($sql); if ($resql) { @@ -2208,7 +2208,8 @@ class Expedition extends CommonObject } } - $this->statut = self::STATUS_CLOSED; + $this->statut = self::STATUS_CLOSED; // Will be revert to STATUS_VALIDATED at end if there is a rollback + $this->status = self::STATUS_CLOSED; // Will be revert to STATUS_VALIDATED at end if there is a rollback // If stock increment is done on closing if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { @@ -2294,6 +2295,8 @@ class Expedition extends CommonObject return 1; } else { $this->statut = self::STATUS_VALIDATED; + $this->status = self::STATUS_VALIDATED; + $this->db->rollback(); return -1; } From 9547b9e7febb4312bd491d6d3e089d0eb7c521e3 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:01:25 +0200 Subject: [PATCH 444/752] Fix: Online signature of proposals does not work well with multicompany --- htdocs/core/ajax/onlineSign.php | 4 ++++ htdocs/public/onlinesign/newonlinesign.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 5110918541f..ce9ae57864d 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -48,6 +48,10 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} include '../../main.inc.php'; $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 8bd95d23c8d..2a9ed568fe8 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -431,11 +431,12 @@ if ($action == "dosign" && empty($cancel)) { "ref" : \''.dol_escape_js($REF).'\', "securekey" : \''.dol_escape_js($SECUREKEY).'\', "mode" : \''.dol_escape_htmltag($source).'\', + "entity" : \''.dol_escape_htmltag($entity).'\', }, success: function(response) { if(response == "success"){ console.log("Success on saving signature"); - window.location.replace("'.$_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&message=signed&securekey='.urlencode($SECUREKEY).'"); + window.location.replace("'.$_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&message=signed&securekey='.urlencode($SECUREKEY).($conf->multicompany->enabled?'&entity='.$entity:'').'"); }else{ console.error(response); } From 62b74962535ed38c424e569d9dbd79b25653ab16 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:26:49 +0200 Subject: [PATCH 445/752] Fix: Direct download don't work with multicompany --- htdocs/document.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/document.php b/htdocs/document.php index 060722e8d5b..fc894091615 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Pierre Morin * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2022 Ferran Marcet * * 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 @@ -140,6 +141,11 @@ if (!empty($hashp)) $modulepart = $moduleparttocheck; $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir } + $entity = $ecmfile->entity; + if ($entity != $conf->entity) { + $conf->entity = $entity; + $conf->setValues($db); + } } else { $langs->load("errors"); accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"), 0, 0, 1); From b8bccd62efa45ce1617eaa3d4a0278c3d3305adc Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 11 Apr 2022 18:41:36 +0200 Subject: [PATCH 446/752] Update newonlinesign.php --- htdocs/public/onlinesign/newonlinesign.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 2a9ed568fe8..d1020dc2c1d 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -193,7 +193,7 @@ $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1); if ($action == 'refusepropal') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&securekey='.urlencode($SECUREKEY), $langs->trans('RefusePropal'), $langs->trans('ConfirmRefusePropal', $object->ref), 'confirm_refusepropal', '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?ref='.urlencode($ref).'&securekey='.urlencode($SECUREKEY).($conf->multicompany->enabled?'&entity='.$entity:''), $langs->trans('RefusePropal'), $langs->trans('ConfirmRefusePropal', $object->ref), 'confirm_refusepropal', '', '', 1); } // Check link validity for param 'source' to avoid use of the examples as value From c035ee6f2a5844e139626e628dab33455315f6c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2022 19:21:04 +0200 Subject: [PATCH 447/752] Look and feel v16 --- htdocs/compta/bank/bankentries_list.php | 22 ++++++++++++++-------- htdocs/compta/facture/prelevement.php | 2 +- htdocs/core/class/html.form.class.php | 15 +++++++++------ htdocs/core/class/html.formfile.class.php | 8 ++++---- htdocs/ecm/file_card.php | 2 +- htdocs/societe/paymentmodes.php | 4 ++-- htdocs/theme/eldy/global.inc.php | 6 +++--- htdocs/theme/md/style.css.php | 9 ++++++--- 8 files changed, 40 insertions(+), 28 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 8893f91c2c2..3cf7da7820e 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -980,21 +980,27 @@ if ($resql) { $moreforfilter = ''; $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('DateOperationShort').' '; + $moreforfilter .= $langs->trans('DateOperationShort'); $moreforfilter .= ($conf->browser->layout == 'phone' ? '
' : ' '); $moreforfilter .= '
'; - $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'
'; - //$moreforfilter .= ' - '; - $moreforfilter .= '
'.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')).'
'; + $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + $moreforfilter .= '
'; + $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' '); + $moreforfilter .= '
'; + $moreforfilter .= $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + $moreforfilter .= '
'; $moreforfilter .= '
'; $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('DateValueShort').' '; + $moreforfilter .= $langs->trans('DateValueShort'); $moreforfilter .= ($conf->browser->layout == 'phone' ? '
' : ' '); $moreforfilter .= '
'; - $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'
'; - //$moreforfilter .= ' - '; - $moreforfilter .= '
'.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')).'
'; + $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + $moreforfilter .= '
'; + $moreforfilter .= ($conf->browser->layout == 'phone' ? '' : ' '); + $moreforfilter .= '
'; + $moreforfilter .= $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + $moreforfilter .= '
'; $moreforfilter .= '
'; if (!empty($conf->categorie->enabled)) { diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index cd34a027651..316254b0398 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -912,7 +912,7 @@ if ($object->id > 0) { } if (!$numopen && !$numclosed) { - print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print "
"; } else { @@ -671,7 +671,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $db->free($resql); if ($num <= 0) { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; } else { @@ -721,7 +721,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $db->free($resql); if ($num <= 0) { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; } else { From f679392d26ad3f902c9f42d0e38f6a5c897e29d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 02:26:37 +0200 Subject: [PATCH 449/752] FIX missing picto in combo of mass actions of thirdparties. --- htdocs/societe/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index da056ec33da..bdc0fae08e0 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -870,10 +870,10 @@ if ($user->rights->societe->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if ($user->rights->societe->creer) { - $arrayofmassactions['preenable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToEnabled"); + $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToEnabled"); } if ($user->rights->societe->creer) { - $arrayofmassactions['predisable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); + $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); From cfe554b04cbec7987f1f4b8951ba75a9d87a3831 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 03:08:31 +0200 Subject: [PATCH 450/752] Fix var not defined --- htdocs/modulebuilder/index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 872a88b28aa..39f70d30d2d 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -46,6 +46,9 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); +$sortfield = ''; +$sortorder = ''; + $module = GETPOST('module', 'alpha'); $tab = GETPOST('tab', 'aZ09'); $tabobj = GETPOST('tabobj', 'alpha'); From 98c7139859afd3cf4810137deeb87621702641f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 10:34:50 +0200 Subject: [PATCH 451/752] Fix regression on fetchObjectLinked when used in loop on a static object --- htdocs/compta/facture/class/facture.class.php | 2 -- htdocs/core/class/commonobject.class.php | 17 +++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 87a59c2c960..7ad0a8ed4bc 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1630,8 +1630,6 @@ class Facture extends CommonInvoice */ public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $fetch_situation = false) { - global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext)) { return -1; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 09c0e591ac7..d53080437a7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -126,10 +126,9 @@ abstract class CommonObject public $linkedObjects; /** - * @var boolean is linkedObjects full loaded. Loaded by ->fetchObjectLinked - * important for pdf generation time reduction + * @var boolean Array of boolean with object id as key and value as true if linkedObjects full loaded. Loaded by ->fetchObjectLinked. Important for pdf generation time reduction. */ - public $linkedObjectsFullLoaded = false; + public $linkedObjectsFullLoaded = array(); /** * @var Object To store a cloned copy of object before to edit it and keep track of old properties @@ -3781,9 +3780,11 @@ abstract class CommonObject { global $conf, $hookmanager, $action; - // important for pdf generation time reduction - // this boolean is true if $this->linkedObjects has already been loaded with all objects linked without filter - if ($this->linkedObjectsFullLoaded) return 1; + // Important for pdf generation time reduction + // This boolean is true if $this->linkedObjects has already been loaded with all objects linked without filter + if ($this->id > 0 && !empty($this->linkedObjectsFullLoaded[$this->id])) { + return 1; + } $this->linkedObjectsIds = array(); $this->linkedObjects = array(); @@ -3846,8 +3847,8 @@ abstract class CommonObject } else { $sql .= "(fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."')"; $sql .= " ".$clause." (fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."')"; - if ($sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { - $this->linkedObjectsFullLoaded = true; + if ($this->id > 0 && $sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { + $this->linkedObjectsFullLoaded[$this->id] = true; } } $sql .= " ORDER BY ".$orderby; From f4023b4e44160e0861eb09a0d0d407e5420575e3 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 12 Apr 2022 11:08:50 +0200 Subject: [PATCH 452/752] Add missing entity on salary's payment --- htdocs/salaries/class/paymentsalary.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 76236bb88aa..506e9b73ea5 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -164,9 +164,9 @@ class PaymentSalary extends CommonObject $this->db->begin(); if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_salary, datec, datep, amount,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,"; $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; - $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " VALUES (".$conf->entity.", ".$this->chid.", '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datepaye)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).","; From a6407257dd2752b6f2931f43b0c4bcdf9b1ffe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:11:26 +0200 Subject: [PATCH 453/752] Allow to view tabs in module builder --- htdocs/langs/en_US/modulebuilder.lang | 5 +- htdocs/modulebuilder/index.php | 127 ++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 7ba539d3bd4..6376024ea0b 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -143,4 +143,7 @@ AsciiToHtmlConverter=Ascii to HTML converter AsciiToPdfConverter=Ascii to PDF converter TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. -ImportExportProfiles=Import and export profiles \ No newline at end of file +ImportExportProfiles=Import and export profiles +ListOfTabsEntries=List of tab entries +TabsDefDesc= Define here the tabs provided by your module +TabsDefDescTooltip=The tabs provided by your module/application are defined into the array $this->tabs into the module descriptor file. You can edit manually this file or use the embedded editor. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 82567e05fac..16671ddf137 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1931,6 +1931,11 @@ if ($module == 'initmodule') { $head2[$h][2] = 'permissions'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=tabs&module='.$module.($forceddirread ? '@'.$dirread : ''); + $head2[$h][1] = $langs->trans("Tabs"); + $head2[$h][2] = 'tabs'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Menus"); $head2[$h][2] = 'menus'; @@ -3902,6 +3907,128 @@ if ($module == 'initmodule') { print ''; } + if ($tab == 'tabs') { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + $tabs = $moduleobj->tabs; + + if ($action != 'editfile' || empty($file)) { + print ''; + $htmlhelp = $langs->trans("TabsDefDescTooltip", '{s1}'); + $htmlhelp = str_replace('{s1}', ''.$langs->trans('Setup').' - '.$langs->trans('Tabs').'', $htmlhelp); + print $form->textwithpicto($langs->trans("TabsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; + print '
'; + print '
'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + + print '
'; + print load_fiche_titre($langs->trans("ListOfTabsEntries"), '', ''); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + + print ''; + print_liste_field_titre("ObjectType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Tab", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Title", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("LangFile", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Path", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print "\n"; + + if (count($tabs)) { + foreach ($tabs as $tab) { + $parts = explode(':', $tab['data']); + + $objectType = $parts[0]; + $tabName = $parts[1]; + $tabTitle = isset($parts[2]) ? $parts[2] : ''; + $langFile = isset($parts[3]) ? $parts[3] : ''; + $condition = isset($parts[4]) ? $parts[4] : ''; + $path = isset($parts[5]) ? $parts[5] : ''; + + // If we want to remove the tab, then the format is 'tabname:optionalcondition' + // See: https://wiki.dolibarr.org/index.php?title=Tabs_system#To_remove_an_existing_tab + if ($tabName[0] === '-') { + $tabTitle = ''; + $condition = isset($parts[2]) ? $parts[2] : ''; + } + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } + } else { + print ''; + } + + print '
'; + print dol_escape_htmltag($parts[0]); + print ''; + if ($tabName[0] === "+") + print '' . dol_escape_htmltag($tabName) . ''; + else + print '' . dol_escape_htmltag($tabName) . ''; + print ''; + print dol_escape_htmltag($tabTitle); + print ''; + print dol_escape_htmltag($langFile); + print ''; + print dol_escape_htmltag($condition); + print ''; + print dol_escape_htmltag($path); + print '
'.$langs->trans("None").'
'; + print '
'; + + print '
'; + } else { + $fullpathoffile = dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab != 'description') { print dol_get_fiche_end(); } From 25a851ac70f70df00e5408e344b26b3b5a979c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:12:43 +0200 Subject: [PATCH 454/752] Fix translation --- htdocs/langs/en_US/modulebuilder.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 6376024ea0b..5544c2b932a 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -145,5 +145,5 @@ TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. ImportExportProfiles=Import and export profiles ListOfTabsEntries=List of tab entries -TabsDefDesc= Define here the tabs provided by your module +TabsDefDesc=Define here the tabs provided by your module TabsDefDescTooltip=The tabs provided by your module/application are defined into the array $this->tabs into the module descriptor file. You can edit manually this file or use the embedded editor. From a747f574b3dc5144e9e695f1ec42d19935ca1ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:15:40 +0200 Subject: [PATCH 455/752] Improve comment --- htdocs/modulebuilder/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 16671ddf137..14385864b6b 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3957,7 +3957,7 @@ if ($module == 'initmodule') { $condition = isset($parts[4]) ? $parts[4] : ''; $path = isset($parts[5]) ? $parts[5] : ''; - // If we want to remove the tab, then the format is 'tabname:optionalcondition' + // If we want to remove the tab, then the format is 'objecttype:tabname:optionalcondition' // See: https://wiki.dolibarr.org/index.php?title=Tabs_system#To_remove_an_existing_tab if ($tabName[0] === '-') { $tabTitle = ''; From 752cc6f4a7adbc4fd791ef6229ce28feb5c8569d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 12 Apr 2022 11:17:24 +0200 Subject: [PATCH 456/752] Lint source code --- htdocs/modulebuilder/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 14385864b6b..937ef6d83fb 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3971,10 +3971,11 @@ if ($module == 'initmodule') { print ''; print ''; - if ($tabName[0] === "+") + if ($tabName[0] === "+") { print '' . dol_escape_htmltag($tabName) . ''; - else + } else { print '' . dol_escape_htmltag($tabName) . ''; + } print ''; print ''; From a006eaecdeac66bf6f1c67112a9dde9e77e8029e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 13:02:33 +0200 Subject: [PATCH 457/752] Fix trans --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 996f2d16c8d..441ce85ec86 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -482,7 +482,7 @@ if (GETPOSTISSET("search_status")) { $titre = $langs->trans("MembersListToValid"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') { - $titre = $langs->trans("MembersValidated"); + $titre = $langs->trans("MenuMembersValidated"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') { $titre = $langs->trans("MembersWithSubscriptionToReceive"); From d41676cf8bd71789a90eeb08ed66f72cdf0f1de9 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 12 Apr 2022 13:57:00 +0200 Subject: [PATCH 458/752] Close #20609 : new massaction asign sale representative --- htdocs/core/actions_massactions.inc.php | 38 +++++++++++++++++++++++++ htdocs/core/tpl/massactions_pre.tpl.php | 10 ++++++- htdocs/langs/en_US/main.lang | 4 +++ htdocs/societe/list.php | 3 ++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c5ff1d8f82a..5ec011f5017 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1602,6 +1602,44 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == } } +if (!$error && ($massaction == 'affectcommercial' || ($action == 'affectcommercial' && $confirm == 'yes')) && $permissiontoadd) { + $db->begin(); + + $objecttmp = new $objectclass($db); + $nbok = 0; + + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result>0) { + if (in_array($objecttmp->element, array('societe'))) { + $result = $objecttmp->setSalesRep(GETPOST("commercial", "alpha")); + } + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("CommercialsAffected", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("CommercialAffected"), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } +} + // Approve for leave only if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) { $db->begin(); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index de034f652d3..4e138b0f1dc 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -217,7 +217,15 @@ if ($massaction == 'preenable') { if ($massaction == 'predisable') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDisabling"), $langs->trans("ConfirmMassDisablingQuestion", count($toselect)), "disable", null, '', 0, 200, 500, 1); } - +if ($massaction == 'presetcommercial') { + $formquestion = array(); + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); + $formquestion[] = array('type' => 'other', + 'name' => 'affectedcommercial', + 'label' => $form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0), + 'value' => $form->multiselectarray('commercial', $userlist, null, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1)); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAllocateCommercial"), $langs->trans("ConfirmAllocateCommercialQuestion", count($toselect)), "affectcommercial", $formquestion, 1, 0, 200, 500, 1); +} if ($massaction == 'preapproveleave') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, 'yes', 0, 200, 500, 1); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c66895e58a4..b39124c7c53 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1169,3 +1169,7 @@ CanceledShown=Canceled shown Terminate=Terminate Terminated=Terminated AddLineOnPosition=Add line on position (at the end if empty) +ConfirmAllocateCommercial=Assign sales representative confirmation +ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? +CommercialsAffected=Sales representatives affected +CommercialAffected=Sales representative affected \ No newline at end of file diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3544611ac45..26e955e7ab4 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -875,6 +875,9 @@ if ($user->rights->societe->creer) { if ($user->rights->societe->creer) { $arrayofmassactions['predisable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); } +if ($user->rights->societe->creer) { + $arrayofmassactions['presetcommercial'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); +} if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); } From b1cc271ad5d6c6aa0916d9c25add1e20c60cb026 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 14:23:39 +0200 Subject: [PATCH 459/752] Fix trans --- htdocs/langs/en_US/modulebuilder.lang | 2 +- htdocs/modulebuilder/index.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 7610aa78e9e..5466900bbe0 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -144,6 +144,6 @@ AsciiToPdfConverter=Ascii to PDF converter TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. ImportExportProfiles=Import and export profiles -ValidateModBuilderDesc=Put 1 if this field need to be validated with $this->validateField() or 0 if validation required +ValidateModBuilderDesc=Set this to 1 if you want to have the method $this->validateField() of object being called to validate the content of the field during insert or upadate. Set 0 if there is no validation required. WarningDatabaseIsNotUpdated=Warning: The database is not updated automatically, you must destroy tables and disable-enable the module to have tables recreated LinkToParentMenu=Parent menu (fk_xxxxmenu) \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index b3a7ce9dfaf..1a5987f3e80 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2726,7 +2726,7 @@ if ($module == 'initmodule') { print '
'; print ''; print ''; - print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; // We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobjet->fields may have been @@ -2763,7 +2763,7 @@ if ($module == 'initmodule') { if (!empty($properties)) { // Line to add a property print ''; - print ''; + print ''; print ''; print ''; print ''; From c51aff99af711f0a7a04fcd2de99ab243ad2175c Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 12 Apr 2022 14:38:17 +0200 Subject: [PATCH 460/752] Add missing entity on adding new VAT --- htdocs/compta/tva/class/tva.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 45d3d2e74b4..ce5ff657eca 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -125,6 +125,7 @@ class Tva extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; + $sql .= "entity,"; $sql .= "datec,"; $sql .= "datep,"; $sql .= "datev,"; @@ -136,6 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; + $sql .= " '".$conf->entity."',"; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; From adda436dab9acc806ff33c5ea25e9f21df41f90d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 12 Apr 2022 12:45:05 +0000 Subject: [PATCH 461/752] Fixing style errors. --- htdocs/compta/tva/class/tva.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index ce5ff657eca..c9fcf18d587 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -125,7 +125,7 @@ class Tva extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; - $sql .= "entity,"; + $sql .= "entity,"; $sql .= "datec,"; $sql .= "datep,"; $sql .= "datev,"; @@ -137,7 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; - $sql .= " '".$conf->entity."',"; + $sql .= " '".$conf->entity."',"; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; From 599c90ae6be05967f29e349b38a19ea6290c53fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 14:57:12 +0200 Subject: [PATCH 462/752] FIX dol_string_onlythesehtmltags can keep html comments --- htdocs/core/lib/functions.lib.php | 9 +++++++-- htdocs/modulebuilder/index.php | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 50d0e8ee9e3..24557d1e90e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6521,7 +6521,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, { $allowed_tags = array( "html", "head", "meta", "body", "article", "a", "abbr", "b", "blockquote", "br", "cite", "div", "dl", "dd", "dt", "em", "font", "img", "ins", "hr", "i", "li", "link", - "ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6" + "ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6", + "comment" // this tags is added to manage comment that are replaced into ... ); if ($allowiframe) { $allowed_tags[] = "iframe"; @@ -6534,7 +6535,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $stringtoclean = dol_string_nounprintableascii($stringtoclean, 0); - $stringtoclean = preg_replace('//', '', $stringtoclean); + //$stringtoclean = preg_replace('//', '', $stringtoclean); + $stringtoclean = preg_replace('//', '\1', $stringtoclean); $stringtoclean = preg_replace('/:/i', ':', $stringtoclean); $stringtoclean = preg_replace('/:|�+58|:/i', '', $stringtoclean); // refused string ':' encoded (no reason to have a : encoded like this) to disable 'javascript:...' @@ -6557,6 +6559,9 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $temp = str_replace('__!DOCTYPE_HTML__', '', $temp); // Restore the DOCTYPE + $temp = preg_replace('/([^>]*)<\/comment>/', '', $temp); // Restore html comments + + return $temp; } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1a5987f3e80..95e83c3ed39 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1641,6 +1641,7 @@ if ($action == 'savefile' && empty($cancel)) { $content = GETPOST('editfilecontent', $check); + // Save file on disk if ($content) { dol_delete_file($pathoffile); @@ -2128,7 +2129,9 @@ if ($module == 'initmodule') { print ''; print ''; } @@ -2299,6 +2312,7 @@ if ($module == 'initmodule') { } if ($tab == 'dictionaries') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $dicts = $moduleobj->dictionaries; @@ -2333,7 +2347,7 @@ if ($module == 'initmodule') { print '
'.$langs->trans("Property"); + print ''.$langs->trans("Property"); print ' ('.$langs->trans("SeeExamples").')'; print ''; @@ -2752,7 +2752,7 @@ if ($module == 'initmodule') { //print ''.$langs->trans("Disabled").''.$form->textwithpicto($langs->trans("Validate"), $langs->trans("ValidateModBuilderDesc")).''.$langs->trans("Comment").'
'; print $langs->trans("EditorUrl"); print ''; - print $moduleobj->editor_url; + if (!empty($moduleobj->editor_url)) { + print ''.$moduleobj->editor_url.' '.img_picto('', 'globe').''; + } print '
'; From 386b8bee5e0be25d49e78b4df609bbe2332a71bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 15:26:21 +0200 Subject: [PATCH 463/752] Fix deletion/creation of extrafields. --- htdocs/modulebuilder/index.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 95e83c3ed39..01c05dadac8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -466,7 +466,12 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { dolReplaceInFile($destfile2, $arrayreplacement); } else { $langs->load("errors"); - setEventMessages($langs->trans('ErrorFailToCreateFile', ''), null, 'errors'); + if ($result1 <= 0) { + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile1), null, 'errors'); + } + if ($result2 <= 0) { + setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile2), null, 'errors'); + } } // TODO Enable in class the property $isextrafieldmanaged = 1 } @@ -780,6 +785,19 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { if (!$result) { setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors'); } else { + // If we delete a sql file + if (preg_match('/\.sql$/', $relativefilename)) { + if (preg_match('/\.key\.sql$/', $relativefilename)) { + $relativefilename = preg_replace('/\.key\.sql$/', '.sql', $relativefilename); + $filetodelete = $dirins.'/'.$relativefilename; + $result = dol_delete_file($filetodelete); + } elseif (preg_match('/\.sql$/', $relativefilename)) { + $relativefilename = preg_replace('/\.sql$/', '.key.sql', $relativefilename); + $filetodelete = $dirins.'/'.$relativefilename; + $result = dol_delete_file($filetodelete); + } + } + if (dol_is_dir_empty($dirtodelete)) { dol_delete_dir($dirtodelete); } @@ -1641,7 +1659,6 @@ if ($action == 'savefile' && empty($cancel)) { $content = GETPOST('editfilecontent', $check); - // Save file on disk if ($content) { dol_delete_file($pathoffile); @@ -2573,8 +2590,9 @@ if ($module == 'initmodule') { print '
'; print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).($realpathtoclass ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; + // API file print '
'; - print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).($realpathtoapi ? '' : '').''; + print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi ? '' : '').(dol_is_file($realpathtoapi)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'').($realpathtoapi ? '' : '').''; if (dol_is_file($realpathtoapi)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2591,7 +2609,7 @@ if ($module == 'initmodule') { } // PHPUnit print '
'; - print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).($realpathtophpunit ? '' : '').''; + print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit ? '' : '').(dol_is_file($realpathtophpunit)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'').($realpathtophpunit ? '' : '').''; if (dol_is_file($realpathtophpunit)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2624,7 +2642,7 @@ if ($module == 'initmodule') { print ' '.img_picto($langs->trans("Edit"), 'edit').''; //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).($realpathtosqlextra ? '' : '').''; + print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextra ? '' : '').''; if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2636,7 +2654,7 @@ if ($module == 'initmodule') { } //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).($realpathtosqlextrakey ? '' : '').''; + print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextrakey ? '' : '').''; if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; From 04ad919a2cdb8c31d7a080388a2ab29ed2766ca5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 15:51:46 +0200 Subject: [PATCH 464/752] Debug modulebuilder for v16. --- htdocs/modulebuilder/index.php | 53 ++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 01c05dadac8..7389e2ea7a5 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -473,7 +473,11 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile2), null, 'errors'); } } - // TODO Enable in class the property $isextrafieldmanaged = 1 + + // Now we update the object file to set $isextrafieldmanaged to 0 + $srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php'; + $arrayreplacement = array('/\$isextrafieldmanaged = 0;/' => '$isextrafieldmanaged = 1;'); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } @@ -775,6 +779,8 @@ if ($dirins && $action == 'addlanguage' && !empty($module)) { // remove/delete File if ($dirins && $action == 'confirm_removefile' && !empty($module)) { + $objectname = $tabobj; + $relativefilename = dol_sanitizePathName(GETPOST('file', 'restricthtml')); if ($relativefilename) { $dirnametodelete = dirname($relativefilename); @@ -808,6 +814,11 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { $arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\','); dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } + + // Now we update the object file to set $isextrafieldmanaged to 0 + $srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php'; + $arrayreplacement = array('/\$isextrafieldmanaged = 1;/' => '$isextrafieldmanaged = 0;'); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } } } @@ -2064,6 +2075,7 @@ if ($module == 'initmodule') { // Note module is inside $dirread if ($tab == 'description') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $pathtofilereadme = $modulelowercase.'/README.md'; $pathtochangelog = $modulelowercase.'/ChangeLog.md'; @@ -2224,6 +2236,7 @@ if ($module == 'initmodule') { } if ($tab == 'languages') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("LanguageDefDesc").'
'; print '
'; @@ -2263,7 +2276,7 @@ if ($module == 'initmodule') { $pathtofile = 'langs/'.$langfile['relativename']; } print '
'.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; print '
'; print ''; - print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, ' aaa '); + print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'thsticky thstickygrey '); print_liste_field_titre("Table", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("SQL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); @@ -2351,7 +2365,7 @@ if ($module == 'initmodule') { while ($i < $maxi) { print ''; - print ''; @@ -2395,7 +2409,7 @@ if ($module == 'initmodule') { $i++; } } else { - print ''; + print ''; } print '
'; + print ''; print ($i + 1); print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; @@ -2429,6 +2443,7 @@ if ($module == 'initmodule') { } if ($tab == 'objects') { + print ''."\n"; $head3 = array(); $h = 0; @@ -3096,6 +3111,7 @@ if ($module == 'initmodule') { } if ($tab == 'menus') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $menus = $moduleobj->menu; @@ -3126,6 +3142,7 @@ if ($module == 'initmodule') { print ''; print ''; + print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'thsticky '); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("LinkToParentMenu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); @@ -3141,9 +3158,16 @@ if ($module == 'initmodule') { print "\n"; if (count($menus)) { + $i = 0; foreach ($menus as $menu) { + $i++; + print ''; + print ''; + print ''; @@ -3229,6 +3253,7 @@ if ($module == 'initmodule') { } if ($tab == 'permissions') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $perms = $moduleobj->rights; @@ -3322,6 +3347,7 @@ if ($module == 'initmodule') { } if ($tab == 'hooks') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("HooksDefDesc").'
'; print '
'; @@ -3342,7 +3368,7 @@ if ($module == 'initmodule') { print ''.$pathtohook.''; print ''; print ''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { print ''.$langs->trans("FileNotYetGenerated").''; print ''.img_picto('Generate', 'generate', 'class="paddingleft"').''; @@ -3376,6 +3402,7 @@ if ($module == 'initmodule') { } if ($tab == 'triggers') { + print ''."\n"; require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); @@ -3401,7 +3428,7 @@ if ($module == 'initmodule') { print ''; - print ''; + print ''; print ''; } } else { @@ -3441,6 +3468,7 @@ if ($module == 'initmodule') { } if ($tab == 'css') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("CSSDesc").'
'; print '
'; @@ -3452,8 +3480,8 @@ if ($module == 'initmodule') { print ' '.$langs->trans("CSSFile").' : '; if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print '
'; - print ''; + print ''; + print ''; } else { print ''.$langs->trans("FileNotYetGenerated").''; print ''; @@ -3486,6 +3514,7 @@ if ($module == 'initmodule') { } if ($tab == 'js') { + print ''."\n"; if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("JSDesc").'
'; print '
'; @@ -3531,6 +3560,7 @@ if ($module == 'initmodule') { } if ($tab == 'widgets') { + print ''."\n"; require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; $widgets = ModeleBoxes::getWidgetsList(array('/'.strtolower($module).'/core/boxes')); @@ -3582,6 +3612,7 @@ if ($module == 'initmodule') { } if ($tab == 'exportimport') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $exportlist = $moduleobj->export_label; @@ -3621,6 +3652,7 @@ if ($module == 'initmodule') { } if ($tab == 'cli') { + print ''."\n"; $clifiles = array(); $i = 0; @@ -3699,6 +3731,7 @@ if ($module == 'initmodule') { } if ($tab == 'cron') { + print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $cronjobs = $moduleobj->cronjobs; @@ -3820,6 +3853,7 @@ if ($module == 'initmodule') { } if ($tab == 'specifications') { + print ''."\n"; $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); if ($action != 'editfile' || empty($file)) { @@ -3933,6 +3967,7 @@ if ($module == 'initmodule') { } if ($tab == 'buildpackage') { + print ''."\n"; print ''.$langs->trans("BuildPackageDesc").''; print '
'; From 1bfd9c695fda90db19047a04305877bf809580e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 16:29:25 +0200 Subject: [PATCH 465/752] Update tva.class.php --- htdocs/compta/tva/class/tva.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c9fcf18d587..a6828587763 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -137,7 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; - $sql .= " '".$conf->entity."',"; + $sql .= " ".((int) $conf->entity.", "; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -146,8 +146,8 @@ class Tva extends CommonObject $sql .= " '".$this->db->escape($this->note)."',"; $sql .= " '".$this->db->escape($this->fk_account)."',"; $sql .= " '".$this->db->escape($this->type_payment)."',"; - $sql .= " '".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id)."',"; - $sql .= " '".$this->db->escape($this->fk_user_modif)."'"; + $sql .= " ".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id).","; + $sql .= " ".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : (int) $user->id); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); From 6cbcc54bd964eab272fd3e7f6ea63efc65dec6b5 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 12 Apr 2022 19:19:41 +0200 Subject: [PATCH 466/752] Fix: The resource dropdown does not show the values --- htdocs/resource/class/html.formresource.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 99916b8ed70..fa775bf5d58 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 Frédéric France + * Copyright (C) 2022 Ferran Marcet * * 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 @@ -224,9 +225,10 @@ class FormResource $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); } elseif ($format == 3) { $value = $arraytypes['code']; - } elseif (empty($value)) { - print ' '; + } else { + $value = ' '; } + print $value; print ''; } } From ed172421f0bf1b425fb86227686dbcc633558d54 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 12 Apr 2022 19:20:45 +0200 Subject: [PATCH 467/752] Fix: The resource dropdown does not show the values --- htdocs/resource/class/html.formresource.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index fa775bf5d58..a541dfab700 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -225,7 +225,8 @@ class FormResource $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); } elseif ($format == 3) { $value = $arraytypes['code']; - } else { + } + if (empty($value)) { $value = ' '; } print $value; From 5e76c1a45d627ab077413ceab556694549558c0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 21:59:34 +0200 Subject: [PATCH 468/752] Fix doc --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 30636a8bb98..6f35a9f1c44 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -512,5 +512,5 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value -- Add column to help to fix a very critical bug when transferring into accounting bank record of a bank account into another currency. -- Idea is to update this column manually in v15 with value in currency of company for bank that are not into the main currency and the transfer --- into accounting will use it in priority if value is not null. +-- into accounting will use it in priority if value is not null. The script repair.sql contains the sequence to fix datas in llx_bank. ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; From 6a7212a48df1a03baeed55960379992303141ad6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 22:02:46 +0200 Subject: [PATCH 469/752] Fix sql error --- htdocs/compta/tva/class/tva.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index a6828587763..1b71cb261e1 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -137,7 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; - $sql .= " ".((int) $conf->entity.", "; + $sql .= " ".((int) $conf->entity).", "; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; From 914b037a9aa0a458cc253f5d4d3f7888d3ec9dae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2022 22:35:12 +0200 Subject: [PATCH 470/752] Fix regression: bad cache management of linked object loading. --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d53080437a7..a3c9c2e8122 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3847,7 +3847,7 @@ abstract class CommonObject } else { $sql .= "(fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."')"; $sql .= " ".$clause." (fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."')"; - if ($this->id > 0 && $sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { + if ($loadalsoobjects && $this->id > 0 && $sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { $this->linkedObjectsFullLoaded[$this->id] = true; } } From e9e10e84b2adb333e276f8dd5fce713b34ed87bb Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Wed, 13 Apr 2022 10:47:33 +0200 Subject: [PATCH 471/752] ensure priority in this usage ensure priority in this usage --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bd3cf69c86a..6fd09ed9723 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1690,7 +1690,7 @@ class Product extends CommonObject $testExit = array('multiprices','multiprices_ttc','multiprices_base_type','multiprices_min','multiprices_min_ttc','multiprices_tva_tx','multiprices_recuperableonly'); foreach ($testExit as $field) { - if (!isset($this->$field[$level])) { + if (!isset($this->{$field}[$level])) { return array(); } } From 29242a23c36be39dfe7f76a21ae02aecce75165b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Apr 2022 12:11:35 +0200 Subject: [PATCH 472/752] Update product.class.php --- htdocs/product/class/product.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6fd09ed9723..8ff89d8d086 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1690,7 +1690,11 @@ class Product extends CommonObject $testExit = array('multiprices','multiprices_ttc','multiprices_base_type','multiprices_min','multiprices_min_ttc','multiprices_tva_tx','multiprices_recuperableonly'); foreach ($testExit as $field) { - if (!isset($this->{$field}[$level])) { + if (!isset($this->$field)) { + return array(); + } + $tmparray = $this->$field; + if (!isset($tmparray[$level])) { return array(); } } From d154696c32b3ccdeb02b161fd3e04d27db2a3c02 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 13 Apr 2022 16:15:07 +0200 Subject: [PATCH 473/752] morecss select_compagny --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0153f554169..f6989d90d59 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1921,7 +1921,7 @@ if ($action == 'create') { $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300')), array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans('PuttingPricesUpToDate'), 'value' => (!empty($conf->global->PROPOSAL_CLONE_UPDATE_PRICES) ? 1 : 0)), ); if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->delivery_date)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3a903e233de..53b6d40d6b0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2043,7 +2043,7 @@ if ($action == 'create' && $usercancreate) { if ($action == 'clone') { // Create an array for form $formquestion = array( - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)')) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)', '', 0, 0, null, 0, 'maxwidth300')) ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } From 90366b1b81799d1244275e1559f1b9d8589204d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Apr 2022 16:21:25 +0200 Subject: [PATCH 474/752] Revert "NEW : Import with select boxes" --- htdocs/imports/import.php | 188 +++++++++----------------------- htdocs/langs/en_US/exports.lang | 4 +- htdocs/langs/fr_FR/exports.lang | 4 +- 3 files changed, 54 insertions(+), 142 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 9ec98f8a495..01f152f1ea5 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -136,14 +136,13 @@ $step = (GETPOST('step') ? GETPOST('step') : 1); $import_name = GETPOST('import_name'); $hexa = GETPOST('hexa'); $importmodelid = GETPOST('importmodelid'); -$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 2); +$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 1); $endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') : array()); $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); $separator_used = str_replace('\t', "\t", $separator); - $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); @@ -161,7 +160,7 @@ foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem, 2); $key = $tabelem[0]; $val = (isset($tabelem[1]) ? $tabelem[1] : ''); - if ($key && $val && ($key > 0 && $step != 4)) { + if ($key && $val) { $array_match_file_to_database[$key] = $val; } } @@ -326,16 +325,13 @@ if ($action == 'saveorder') { $pos = 0; foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield - $posbis = 0; - - $namefield = ''; + $posbis = 0; $namefield = ''; foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); if ($posbis < $pos) { $posbis++; continue; } - // We found the key of targets that is at position pos $namefield = $key; //dol_syslog('AjaxImport Field name found for file field nb '.$fieldnb.'='.$namefield); @@ -1008,7 +1004,7 @@ if ($step == 4 && $datatoimport) { $lefti = 1; foreach ($array_match_file_to_database as $key => $val) { $var = !$var; - show_elem($fieldssource, $key, $val, $var, 1, '', $listofkeys); // key is field number in source file + show_elem($fieldssource, $key, $val, $var); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; $listofkeys[$key] = 1; $fieldsplaced[$key] = 1; @@ -1027,7 +1023,7 @@ if ($step == 4 && $datatoimport) { while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 1, '', $listofkeys); // key start after field number in source file + show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file //print '> '.$lefti.'-'.$newkey; $listofkeys[$key] = 1; $lefti++; @@ -1041,14 +1037,11 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1188,51 +1180,35 @@ if ($step == 4 && $datatoimport) { if ($conf->use_javascript_ajax) { print ''."\n"; @@ -1495,20 +1471,6 @@ if ($step == 5 && $datatoimport) { if ($action == 'launchsimu') { print '   '.$langs->trans("Modify").''; } - if ($excludefirstline == 2) { - print $form->textwithpicto("", $langs->trans("WarningFirstImportedLine", $excludefirstline), 1, 'warning', "warningexcludefirstline"); - print ''; - } print ''; // Keys for data UPDATE (not INSERT of new data) @@ -2131,21 +2093,18 @@ $db->close(); /** * Function to put the movable box of a source field * - * @param array $fieldssource List of source fields - * @param int $pos Pos - * @param string $key Key - * @param boolean $var Line style (odd or not) - * @param boolean $isimportedfield Verify if it's an imported field - * @param int $nostyle Hide style - * @param array $listofkeys List of keys for select boxes + * @param array $fieldssource List of source fields + * @param int $pos Pos + * @param string $key Key + * @param boolean $var Line style (odd or not) + * @param int $nostyle Hide style * @return void */ -function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = '', &$listofkeys = array()) +function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') { global $langs, $bc; - // $height = '24px'; - $height = '30px'; + $height = '24px'; if ($key == 'none') { //stop multiple duplicate ids with no number @@ -2162,7 +2121,7 @@ function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = if ($pos && $pos > count($fieldssource)) { // No fields print ''; print ''; print ''; print ''; - } elseif (empty($isimportedfield)) { - $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; - if ($example) { - if (!utf8_check($example)) { - $example = utf8_encode($example); - } - print ''; - print ''; - print ''; - print ''; - } } else { // Print field of source file print ''; print ''; - print ''; print ''; print ''; } diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 8bbc6f1ad98..f2f2d2cf587 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -8,7 +8,7 @@ ImportableDatas=Importable dataset SelectExportDataSet=Choose dataset you want to export... SelectImportDataSet=Choose dataset you want to import... SelectExportFields=Choose the fields you want to export, or select a predefined export profile -SelectImportFields=Choose the source file fields you want to import and their target field in database by choosing the fields with the select box, or select a predefined import profile: +SelectImportFields=Choose the source file fields you want to import and their target field in database by moving them up and down with anchor %s, or select a predefined import profile: NotImportedFields=Fields of source file not imported SaveExportModel=Save your selections as an export profile/template (for reuse). SaveImportModel=Save this import profile (for reuse) ... @@ -135,5 +135,3 @@ NbInsert=Number of inserted lines: %s NbUpdate=Number of updated lines: %s MultipleRecordFoundWithTheseFilters=Multiple records have been found with these filters: %s StocksWithBatch=Stocks and location (warehouse) of products with batch/serial number -WarningFirstImportedLine=The first line(s) will not be imported with the current selection -EmptyField=Empty field \ No newline at end of file diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 4f4490ef4a5..5c87e8f186f 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -8,7 +8,7 @@ ImportableDatas=Lot de données importables SelectExportDataSet=Choisissez un lot prédéfini de données que vous désirez exporter… SelectImportDataSet=Choisissez un lot prédéfini de données que vous désirez importer… SelectExportFields=Choisissez les champs à exporter, ou choisissez un profil d'export prédéfini -SelectImportFields=Choisissez les champs du fichier source à importer et leur destination dans la base en utilisant les boîtes de sélection, ou choisissez un profil d'import prédéfini: +SelectImportFields=Choisissez les champs du fichier source à importer et leur destination dans la base en les déplaçant vers le haut ou vers le bas via l'ancre %s, ou choisissez un profil d'import prédéfini: NotImportedFields=Champs du fichier source non importés SaveExportModel=Enregistrer ce profil d'export (si vous désirez le réutiliser ultérieurement) … SaveImportModel=Enregistrer ce profil d'import (si vous désirez le réutiliser ultérieurement) … @@ -135,5 +135,3 @@ NbInsert=Nombre de lignes insérées: %s NbUpdate=Nombre de lignes mises à jour: %s MultipleRecordFoundWithTheseFilters=Plusieurs enregistrements ont été trouvés avec ces filtres: %s StocksWithBatch=Stocks et entrepôts des produits avec numéro de lot/série -WarningFirstImportedLine=Les première(s) ligne(s) ne seront pas importée(s) avec cette selection -EmptyField=Champ vide From 5f7f9a751508dc5840151b0f674a671a2a88281a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 14 Apr 2022 09:48:06 +0200 Subject: [PATCH 475/752] FIX include tpl path in product stock --- htdocs/product/stock/tpl/stockcorrection.tpl.php | 2 +- htdocs/product/stock/tpl/stocktransfer.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index eb84df7d14e..6afea0abe54 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -180,7 +180,7 @@ print ''; print ''; // Extrafield template -include 'extrafields_add.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
'; + print $i; + print ''; print dol_escape_htmltag($menu['type']); print ''.img_picto($langs->trans("Edit"), 'edit').' '; - print ''.img_picto($langs->trans("Delete"), 'delete').'
'; print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Delete"), 'delete').'
'.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').''.img_picto('Generate', 'generate', 'class="paddingleft"').''; // List of target fields - // $height = '24px'; //needs px for css height attribute below - $height = '30px'; + $height = '24px'; //needs px for css height attribute below $i = 0; $mandatoryfieldshavesource = true; - $fieldselect = 1; - print ''; - $pos = 1; + print '
'; foreach ($fieldstarget as $code => $label) { print ''; @@ -1058,7 +1051,7 @@ if ($step == 4 && $datatoimport) { $tablealias = preg_replace('/(\..*)$/i', '', $code); $tablename = $objimport->array_import_tables[0][$tablealias]; - $entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... + $entityicon = $entitytoicon[$entity] ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... print ''; @@ -1078,7 +1071,7 @@ if ($step == 4 && $datatoimport) { print ''; // Info field print ''; print ''; - $fieldselect++; } print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; - $filecolumn = !empty($array_match_database_to_file[$code])?$array_match_database_to_file[$code]:0; + $filecolumn = $array_match_database_to_file[$code]; // Source field info $htmltext = ''.$langs->trans("FieldSource").'
'; if ($filecolumn > count($fieldssource)) { @@ -1098,7 +1091,7 @@ if ($step == 4 && $datatoimport) { } // Source required $htmltext .= $langs->trans("SourceRequired").': '.yn(preg_match('/\*$/', $label)).'
'; - $example = !empty($objimport->array_import_examplevalues[0][$code])?$objimport->array_import_examplevalues[0][$code]:""; + $example = $objimport->array_import_examplevalues[0][$code]; // Example if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion if ($example) { @@ -1136,7 +1129,6 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1155,7 +1147,7 @@ if ($step == 4 && $datatoimport) { if (empty($fieldsplaced[$key])) { // $nbofnotimportedfields++; - show_elem($fieldssource, $key, '', $var, 0, 'nostyle', $listofkeys); + show_elem($fieldssource, $key, '', $var, 'nostyle'); //print '> '.$lefti.'-'.$key; $listofkeys[$key] = 1; $lefti++; @@ -1164,7 +1156,7 @@ if ($step == 4 && $datatoimport) { // Print one more empty field $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 1, 'nostyle', $listofkeys); + show_elem($fieldssource, $newkey, '', $var, 'nostyle'); //print '> '.$lefti.'-'.$newkey; $listofkeys[$newkey] = 1; $nbofnotimportedfields++; @@ -1177,7 +1169,7 @@ if ($step == 4 && $datatoimport) { $i = 0; while ($i < $nbofnotimportedfields) { // Print empty cells - show_elem('', '', 'none', $var, 0, 'nostyle', $listofkeys); + show_elem('', '', 'none', $var, 'nostyle'); $i++; } print '
'; - //print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; print $langs->trans("NoFields"); @@ -2177,65 +2136,22 @@ function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = print ' '; print '
'; - print ' '; - print ''; - print $langs->trans("EmptyField").': '; - print ' ('.$example.')'; - print '
'; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - //print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; - $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; - if ($example != "") { - print $langs->trans("Field").' '.$pos.': '; - } else { - print $langs->trans("EmptyField").': '; - } + print ''; + print $langs->trans("Field").' '.$pos; + $example = $fieldssource[$pos]['example1']; if ($example) { if (!utf8_check($example)) { $example = utf8_encode($example); } - } - $nameselect = ($pos > 0) ? $pos : (-$pos); - print ''; - print '
'; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index ccedf993221..f1c08b7673e 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -137,7 +137,7 @@ print ''; print ''; // Extrafield template -include 'extrafields_add.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print ''; From c90d758b0ff06021b5eafd72b69c0276fa88e4eb Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 14 Apr 2022 11:06:54 +0200 Subject: [PATCH 476/752] New : add of unique(entity,label) --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ .../tables/llx_takepos_floor_tables.key.sql | 16 ++++++++++++++++ htdocs/takepos/floors.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 5f8b1d886c3..745955c7bcd 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -324,3 +324,5 @@ ALTER TABLE llx_actioncomm MODIFY COLUMN note mediumtext; DELETE FROM llx_boxes WHERE box_id IN (select rowid FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php')); DELETE FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php'); + +ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql b/htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql new file mode 100644 index 00000000000..e90cd67e889 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_takepos_floor_tables.key.sql @@ -0,0 +1,16 @@ +-- Copyright (C) 2018 SuperAdmin +-- +-- 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_takepos_floor_tables ADD UNIQUE(entity,label); \ No newline at end of file diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 64040a24466..73e84109116 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -104,7 +104,7 @@ if ($action == "updatename") { if (strlen($newname) > 3) { $newname = substr($newname, 0, 3); // Only 3 chars } - $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid = ".((int) $place)); + $resql = $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid = ".((int) $place)); } if ($action == "add") { From 0fcfb7c5fd3988fb362ee550dd7edc6beb185c97 Mon Sep 17 00:00:00 2001 From: atm-arnaud Date: Thu, 14 Apr 2022 12:08:06 +0200 Subject: [PATCH 477/752] FIX intervention entity missing --- htdocs/fichinter/class/fichinter.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 371853dc70c..92b628b9aab 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -426,7 +426,7 @@ class Fichinter extends CommonObject $sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; $sql .= " f.date_valid as datev,"; $sql .= " f.tms as datem,"; - $sql .= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; + $sql .= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat, f.entity as entity"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; if ($ref) { $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; @@ -459,6 +459,7 @@ class Fichinter extends CommonObject $this->model_pdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf; // deprecated $this->fk_contrat = $obj->fk_contrat; + $this->entity = $obj->entity; $this->user_creation = $obj->fk_user_author; From f15438dd039dc3f6ecb7c4c3642d83f8e57e7927 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 14 Apr 2022 12:28:51 +0200 Subject: [PATCH 478/752] NEW: data sign on propal list --- htdocs/comm/propal/list.php | 71 ++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 73b4c479b2e..561682ba02f 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -123,6 +123,15 @@ $search_fk_input_reason = GETPOST("search_fk_input_reason", 'int'); $search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); +$search_date_signature_startday = GETPOST('search_date_signature_startday', 'int'); +$search_date_signature_startmonth = GETPOST('search_date_signature_startmonth', 'int'); +$search_date_signature_startyear = GETPOST('search_date_signature_startyear', 'int'); +$search_date_signature_endday = GETPOST('search_date_signature_endday', 'int'); +$search_date_signature_endmonth = GETPOST('search_date_signature_endmonth', 'int'); +$search_date_signature_endyear = GETPOST('search_date_signature_endyear', 'int'); +$search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear); +$search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear); + $search_status = GETPOST('search_status', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -207,6 +216,7 @@ $arrayfields = array( 'p.date'=>array('label'=>"DatePropal", 'checked'=>1), 'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1), 'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0), + 'p.date_signature'=>array('label'=>"DateSigning", 'checked'=>0), 'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0), 'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>!empty($conf->expedition->enabled)), 'p.fk_input_reason'=>array('label'=>"Origin", 'checked'=>0, 'enabled'=>1), @@ -337,6 +347,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_fk_shipping_method = ''; $search_fk_input_reason = ''; $search_fk_mode_reglement = ''; + $search_date_signature_startday = ''; + $search_date_signature_startmonth = ''; + $search_date_signature_startyear = ''; + $search_date_signature_endday = ''; + $search_date_signature_endmonth = ''; + $search_date_signature_endyear = ''; + $search_date_signature_start = ''; + $search_date_signature_end = ''; } if ($object_statut != '') { $search_status = $object_statut; @@ -517,6 +535,7 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' p.rowid, p.entity as propal_entity, p.note_private, p.total_ht, p.total_tva, p.total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut as status, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; $sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; +$sql .= ' p.date_signature as dsignature,'; $sql .= ' p.note_public, p.note_private,'; $sql .= ' p.fk_cond_reglement,p.fk_mode_reglement,p.fk_shipping_method,p.fk_input_reason,'; $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; @@ -701,6 +720,12 @@ if ($search_sale > 0) { if ($search_user > 0) { $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".((int) $search_user); } +if ($search_date_signature_start) { + $sql .= " AND p.date_signature >= '".$db->idate($search_date_signature_start)."'"; +} +if ($search_date_signature_end) { + $sql .= " AND p.date_signature <= '".$db->idate($search_date_signature_end)."'"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -917,6 +942,24 @@ if ($resql) { if ($search_country) { $param .= '&search_country='.urlencode($search_country); } + if ($search_date_signature_startday) { + $param .= '&search_date_signature_startday='.urlencode($search_date_signature_startday); + } + if ($search_date_signature_startmonth) { + $param .= '&search_date_signature_startmonth='.urlencode($search_date_signature_startmonth); + } + if ($search_date_signature_startyear) { + $param .= '&search_date_signature_startyear='.urlencode($search_date_signature_startyear); + } + if ($search_date_signature_endday) { + $param .= '&search_date_signature_endday='.urlencode($search_date_signature_endday); + } + if ($search_date_signature_endmonth) { + $param .= '&search_date_signature_endmonth='.urlencode($search_date_signature_endmonth); + } + if ($search_date_signature_endyear) { + $param .= '&search_date_signature_endyear='.urlencode($search_date_signature_endyear); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -1148,6 +1191,17 @@ if ($resql) { print '
'; print ''; } + // Date Signature + if (!empty($arrayfields['p.date_signature']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_signature_start ? $search_date_signature_start : -1, 'search_date_signature_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_signature_end ? $search_date_signature_end : -1, 'search_date_signature_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print ''; + } // Availability if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; @@ -1361,7 +1415,10 @@ if ($resql) { print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder); } if (!empty($arrayfields['p.date_livraison']['checked'])) { - print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'p.date_livraison', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.date_signature']['checked'])) { + print_liste_field_titre($arrayfields['p.date_signature']['label'], $_SERVER["PHP_SELF"], 'p.date_signature', '', $param, 'align="center"', $sortfield, $sortorder); } if (!empty($arrayfields['ava.rowid']['checked'])) { print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); @@ -1720,6 +1777,18 @@ if ($resql) { $totalarray['nbfield']++; } } + // Date Signature + if (!empty($arrayfields['p.date_signature']['checked'])) { + if ($obj->dsignature) { + print ''.dol_print_date($db->jdate($obj->dsignature), 'day'); + print ''; + } else { + print ' '; + } + if (!$i) { + $totalarray['nbfield']++; + } + } // Availability if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; From 3d21023110a27ab96d6ff0fafb8ae6eb3117709a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 14:11:40 +0200 Subject: [PATCH 479/752] Label of option --- htdocs/admin/pdf.php | 6 +++--- htdocs/langs/en_US/companies.lang | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index fd8377b0a27..1e015d69f9c 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -309,7 +309,7 @@ print ''.$langs->trans("Par // Show sender name -/* Set option as hidden because no need of this for 99.99% of users. +/* Set option as hidden because no need of this for 99.99% of users. Having it as hidden feature is enough. print ''.$langs->trans("MAIN_PDF_HIDE_SENDER_NAME").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MAIN_PDF_HIDE_SENDER_NAME'); @@ -321,7 +321,7 @@ print ''; // Hide VAT Intra on address -print ''.$langs->trans("ShowVATIntaInAddress").''; +print ''.$langs->trans("ShowVATIntaInAddress").' - '.$langs->trans("ThirdPartyAddress").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MAIN_TVAINTRA_NOT_IN_ADDRESS'); } else { @@ -340,7 +340,7 @@ for ($i = 1; $i <= 6; $i++) { $pid = img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } if ($pid) { - print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid.''; + print ''.$langs->trans("ShowProfIdInAddress").' - '.$pid.' - '.$langs->trans("ThirdPartyAddress").''; $keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS'; if ($conf->use_javascript_ajax) { print ajax_constantonoff($keyforconstant); diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 093fb47189d..b1438691cd9 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -19,6 +19,7 @@ ProspectionArea=Prospection area IdThirdParty=Id third party IdCompany=Company Id IdContact=Contact Id +ThirdPartyAddress=Third-party address ThirdPartyContacts=Third-party contacts ThirdPartyContact=Third-party contact/address Company=Company From 8a9be6705d4c674013dfa2ab74184b2370d73df4 Mon Sep 17 00:00:00 2001 From: kamel Date: Thu, 14 Apr 2022 14:14:07 +0200 Subject: [PATCH 480/752] FIX: Call of printOriginObjectLine hook --- htdocs/core/class/commonobject.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 02421ea9157..7828e61b166 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4824,11 +4824,9 @@ abstract class CommonObject if (!empty($this->lines)) { foreach ($this->lines as $line) { if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { - if (empty($line->fk_parent_line)) { - $parameters = array('line'=>$line, 'i'=>$i); - $action = ''; - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } + $parameters = array('line' => $line, 'i' => $i); + $action = ''; + $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } else { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); } From e0d208214731df7f404c33b1488f543e4ad0d109 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Thu, 14 Apr 2022 16:49:08 +0200 Subject: [PATCH 481/752] Update barcode_EAN13.txt start formatting & english translation --- dev/resources/iso-normes/barcode_EAN13.txt | 64 +++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/dev/resources/iso-normes/barcode_EAN13.txt b/dev/resources/iso-normes/barcode_EAN13.txt index f4496327ee4..f6b3c5f5ebb 100644 --- a/dev/resources/iso-normes/barcode_EAN13.txt +++ b/dev/resources/iso-normes/barcode_EAN13.txt @@ -16,57 +16,57 @@ Voici la liste des codes pays ou systeme : EN == -Meaning of the numbers. +Meaning of the numbers: -- 2 digits for the country code or system code +- first 2-3 digits for the country code or system code - 5 digits for the company identifier - 5 digits for item identifier - 1 digit for checksum This rule has been twisted many times to improve the use of the available numbers. -Here is the list of country codes or system: +Here is the list of country codes or system: List ==== -00 � 13 UCC (Etats-Unis et Canada) -20 � 29 Codification interne en magasin -30 � 37 GENCOD-EAN France -380 BCCI (Bulgarie) -383 SANA (Slovenie) -385 CRO-EAN (Croatie) -387 EAN-BIH (Bosnie-Herzegovine) -400 � 440 CCG (Allemagne) -45 + 49 Distribution Code Center � DCC (Japon) -460 � 469 UNISCAN - EAN Russie (Federation de Russie) -471 CAN (Taiwan) -474 EAN Estonie -475 EAN Lettonie -476 EAN Azerba� djan -477 EAN Lituanie -478 EAN Ouzbekistan -479 EAN Sri Lanka -480 PANC (Philippines) -481 EAN Bielorussie -482 EAN Ukraine -484 EAN Moldavie -485 EAN Armenie -486 EAN Georgie -487 EAN Kazakhstan -489 HKANA (Hong Kong) -50 E Centre UK +00 - 13 UCC (U.S.A / États-Unis & Canada) +20 - 29 Flag for internal numbering / Codification interne en magasin +30 - 37 GENCOD-EAN France +380 BCCI (Bulgaria) +383 SANA (Slovenia) +385 CRO-EAN (Croatia) +387 EAN-BIH (Bosnia-Herzegovina) +400-440 CCG (Allemagne/Germany) +45 + 49 Distribution Code Center - DCC (Japan) +460-469 UNISCAN - EAN Russia (Federation de Russie) +471 CAN Taiwan +474 EAN Estonia +475 EAN Latvia +476 EAN Azerbaijan +477 EAN Lithuania +478 EAN Uzbekistan +479 EAN Sri Lanka +480 PANC Philippines +481 EAN Belarus +482 EAN Ukraine +484 EAN Moldova +485 EAN Armenia +486 EAN Georgia +487 EAN Kazakhstan +489 HKANA Hong Kong +50 E Centre UK - United Kingdom 520 HELLCAN-EAN HELLAS (Grece) 528 EAN Liban 529 EAN Chypre -531 EAN-MAC (FYR Mac�donie) +531 EAN-MAC (FYR Macedonie) 535 EAN Malte 539 EAN Irlande -54 ICODIF/EAN Belgique. Luxembourg +54 ICODIF/EAN Belgique. Luxembourg 560 CODIPOR (Portugal) 569 EAN Islande -57 EAN Danemark +57 EAN Danemark 590 EAN Pologne 594 EAN Roumanie 599 H.A.P.M.H. (Hongrie) From 02a3cfbb5f16672f2fff6c65f0fe6a0a3386d56b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 21:43:55 +0200 Subject: [PATCH 482/752] Update paymentsalary.class.php --- htdocs/salaries/class/paymentsalary.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 506e9b73ea5..08e850c259a 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -166,7 +166,7 @@ class PaymentSalary extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,"; $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; - $sql .= " VALUES (".$conf->entity.", ".$this->chid.", '".$this->db->idate($now)."',"; + $sql .= " VALUES (".((int) $conf->entity).", ".((int) $this->chid).", '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datepaye)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).","; From d62d24a337778890f042a58aaa17d3ab459160aa Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 14 Apr 2022 21:47:35 +0200 Subject: [PATCH 483/752] add code to get documents list by knowledgemanagement with api --- htdocs/api/class/api_documents.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index da49e4cbba7..d4e35e848ac 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -458,6 +458,20 @@ class Documents extends DolibarrApi } $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); + } elseif ($modulepart == 'knowledgemanagement') { + require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php'; + + if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) { + throw new RestException(401); + } + + $object = new KnowledgeRecord($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'Expense report not found'); + } + + $upload_dir = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.dol_sanitizeFileName($object->ref); } elseif ($modulepart == 'categorie' || $modulepart == 'category') { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; From 0023850c9a6f37c31db33d95a018ea3ee8d55fb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 22:16:17 +0200 Subject: [PATCH 484/752] Update api_documents.class.php --- htdocs/api/class/api_documents.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index d4e35e848ac..9bf7dd7c117 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -468,7 +468,7 @@ class Documents extends DolibarrApi $object = new KnowledgeRecord($this->db); $result = $object->fetch($id, $ref); if (!$result) { - throw new RestException(404, 'Expense report not found'); + throw new RestException(404, 'KM article not found'); } $upload_dir = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.dol_sanitizeFileName($object->ref); From 06f112d3ce5454cd428d7862bea2fdd7402d426e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 22:43:43 +0200 Subject: [PATCH 485/752] Update main.inc.php --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e66c9e9d313..dd8010dfa92 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -265,7 +265,7 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { $cookiearrayvalue[$tmpkey] = $_POST[$postkey]; } } - $cookiename = ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? $tmpautoset[0] : '__Secure-'.$tmpautoset[0]); // __Secure- || __Host- + $cookiename = $tmpautoset[0]; $cookievalue = json_encode($cookiearrayvalue); //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); if (PHP_VERSION_ID < 70300) { From 75d3b3527c148aa2e444f0ac70da2b2aaac7eb4c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Apr 2022 22:45:56 +0200 Subject: [PATCH 486/752] Update main.inc.php --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dd8010dfa92..3b5793a2cf1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -297,7 +297,7 @@ if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { // Must be done after the include of filefunc.inc.php so global variables of conf file are defined (like $dolibarr_main_instance_unique_id or $dolibarr_main_force_https). // Note: the function dol_getprefix() is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. $prefix = dol_getprefix(''); -$sessionname = ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? 'DOLSESSID_'.$prefix : '__Secure-DOLSESSID_'.$prefix); // __Secure- || __Host- +$sessionname = 'DOLSESSID_'.$prefix; $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; if (!empty($_COOKIE[$sessiontimeout])) { ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]); From b4fb6cf527e9499e5763075572d420014734cc8a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 15 Apr 2022 09:13:41 +0200 Subject: [PATCH 487/752] fix: HTML on PRODUCT_LOT_ENABLE_QUALITY_CONTROL --- htdocs/product/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 420203eedae..98f264bb09e 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1396,8 +1396,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Quality control if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { - print ''.$langs->trans("LifeTime").''; - print ''.$langs->trans("QCFrequency").''; + print ''.$langs->trans("LifeTime").''; + print ''.$langs->trans("QCFrequency").''; } // Other attributes @@ -2443,19 +2443,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Custom code if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) { - print ''.$langs->trans("CustomCode").''.$object->customcode.''; + print ''.$langs->trans("CustomCode").''.$object->customcode.''; // Origin country code print ''.$langs->trans("Origin").''.getCountry($object->country_id, 0, $db); if (!empty($object->state_id)) { print ' - '.getState($object->state_id, 0, $db); } - print ''; + print ''; } // Quality Control if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { - print ''.$langs->trans("LifeTime").''.$object->lifetime.''; + print ''.$langs->trans("LifeTime").''.$object->lifetime.''; print ''.$langs->trans("QCFrequency").''.$object->qc_frequency.''; } From 24bb6c6f8345b80fc49ef097d3a7f1dbd0103a3f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 15 Apr 2022 10:20:52 +0200 Subject: [PATCH 488/752] fix: clean mess up around element_tag table --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index ab037313dfb..c0d7a328e59 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -509,3 +509,16 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value -- VMYSQL4.3 ALTER TABLE llx_user MODIFY COLUMN fk_soc integer NULL; -- VPGSQL8.2 ALTER TABLE llx_user ALTER COLUMN fk_soc DROP NOT NULL; + +DROP TABLE IF EXISTS llx_element_tag; -- in migration 3.2.0 to 3.3.0 there is a element_tag table creation that is notin create table +CREATE TABLE llx_element_tag +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_categorie integer NOT NULL, + fk_element integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_element_tag ADD UNIQUE INDEX idx_element_tag_uk (fk_categorie, fk_element); + +ALTER TABLE llx_element_tag ADD CONSTRAINT fk_element_tag_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); From e0b766588ab32e577445af2ccb6a1d703334b0ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Apr 2022 10:44:37 +0200 Subject: [PATCH 489/752] Remove a step no more done --- build/makepack-howto.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index 477d129d459..47d68bafd6c 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -24,7 +24,6 @@ To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dol (/home/dolibarr/wwwroot/files/lastbuild). - Post a news on dolibarr.org/dolibarr.fr + social networks -- Send mail on mailings-list ***** Actions to do a RELEASE ***** @@ -52,4 +51,3 @@ To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dol on server to point to new files (used by some web sites). - Post a news on dolibarr.org/dolibarr.fr + social networks -- Send mail on mailings-list From d445fdd172657c44cd61e28f9a89415093467dfc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Apr 2022 10:49:11 +0200 Subject: [PATCH 490/752] Doc --- build/makepack-howto.txt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index 47d68bafd6c..d4e37e32629 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -8,12 +8,13 @@ This files describe steps made by Dolibarr packaging team to make a beta version of Dolibarr, step by step. - Check all files are commited. -- Update version/info in ChangeLog. -To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +- Update version/info in ChangeLog, for this you can: +To generate a changelog of a major new version x.y.0 (from a repo on branch develop), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +To generate a changelog of a major new version x.y.0 (from a repo on branch x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -- To know number of lines changes: git diff --shortstat A B -- Update version number with x.y.z-w in htdocs/filefunc.inc.php +Recopy the content of the output file into the file ChangeLog. +- Note: To know number of lines changes: git diff --shortstat A B +- Update version number with x.y.z-w in file htdocs/filefunc.inc.php - Commit all changes. - Run makepack-dolibarr.pl to generate all packages. @@ -31,12 +32,13 @@ This files describe steps made by Dolibarr packaging team to make a complete release of Dolibarr, step by step. - Check all files are commited. -- Update version/info in ChangeLog. -To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +- Update version/info in ChangeLog, for this you can: +To generate a changelog of a major new version x.y.0 (from a repo on branch develop), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +To generate a changelog of a major new version x.y.0 (from a repo pn branch x.y), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -- To know number of lines changes: git diff --shortstat A B -- Update version number with x.y.z in htdocs/filefunc.inc.php +Recopy the content of the output file into the file ChangeLog. +- Note: To know the number of lines changes: git diff --shortstat A B +- Update version number with x.y.z in file htdocs/filefunc.inc.php - Commit all changes. - Run makepack-dolibarr.pl to generate all packages. From 6b264733e44dcb6d3cbac58243fb52b9e66b7548 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 15 Apr 2022 11:21:02 +0200 Subject: [PATCH 491/752] Move-checkbox-column-as-first-column-on-modulebuilder --- .../modulebuilder/template/myobject_list.php | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 0ecd42bda26..5317c581952 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -536,7 +536,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, 'left'); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -546,6 +546,11 @@ print ''; +// Action column +print ''; foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -590,11 +595,6 @@ print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { print ''; }*/ -// Action column -print ''; print ''."\n"; $totalarray = array(); @@ -603,6 +603,7 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -630,7 +631,6 @@ print $hookmanager->resPrint; $totalarray['nbfield']++; }*/ // Action column -print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; print ''."\n"; @@ -676,6 +676,16 @@ while ($i < $imaxinloop) { // Show here line of result $j = 0; print ''; + // Action column + print ''; 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'))) { @@ -731,16 +741,6 @@ while ($i < $imaxinloop) { /*if (!empty($arrayfields['anotherfield']['checked'])) { print ''; }*/ - // Action column - print ''; if (!$i) { $totalarray['nbfield']++; } From 292df417fe25cf7a327cee3404c00b841892dabc Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 15 Apr 2022 11:32:53 +0200 Subject: [PATCH 492/752] NEW: Add column template invoice in invoice list --- htdocs/compta/facture/list.php | 38 +++++++++++ htdocs/core/class/html.form.class.php | 95 +++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index eedc3297018..1c4ce0cdecf 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -47,6 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -135,6 +136,7 @@ $search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int'); $search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear); $search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear); $search_categ_cus = GETPOST("search_categ_cus", 'int'); +$search_fac_rec_source = GETPOST("search_fac_rec_source", 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -251,6 +253,7 @@ $arrayfields = array( 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>502), 'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), 'f.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))), + 'f.fk_fac_rec_source'=>array('label'=>'GeneratedFromTemplate', 'checked'=>0, 'position'=>520, 'enabled'=>'1'), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); @@ -360,6 +363,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_datelimit_endyear = ''; $search_datelimit_start = ''; $search_datelimit_end = ''; + $search_fac_rec_source = ''; $option = ''; $filter = ''; $toselect = ''; @@ -566,6 +570,7 @@ $sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.pho $sql .= ' typent.code as typent_code,'; $sql .= ' state.code_departement as state_code, state.nom as state_name,'; $sql .= ' country.code as country_code,'; +$sql .= ' f.fk_fac_rec_source,'; $sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,'; $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender'; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0). @@ -801,6 +806,10 @@ if ($search_sale > 0) { if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user); } + +if ($search_fac_rec_source > 0) { + $sql .= " AND f.fk_fac_rec_source = ".((int) $search_fac_rec_source); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -1079,6 +1088,9 @@ if ($resql) { if ($search_categ_cus > 0) { $param .= '&search_categ_cus='.urlencode($search_categ_cus); } + if ($search_fac_rec_source > 0) { + $param .= '&search_fac_rec_source='.urlencode($search_fac_rec_source); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -1500,6 +1512,12 @@ if ($resql) { print ''; } + if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { + // Template Invoice + print ''; + } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; From 1ccf209c47f711694739d9a68e206040a957c014 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 15 Apr 2022 14:31:44 +0200 Subject: [PATCH 497/752] Close #20653 : edit discount pourcentage --- htdocs/comm/propal/card.php | 9 ++++++++- htdocs/commande/card.php | 7 +++++++ htdocs/compta/facture/card.php | 7 +++++++ htdocs/core/tpl/objectline_title.tpl.php | 19 ++++++++++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f6989d90d59..7e653914d08 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -831,7 +831,14 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif ($action == 'addline' && $usercancreate) { // Add line + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define vat_rate + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } + }elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 53b6d40d6b0..c4c5905ba0c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -628,6 +628,13 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define remise_percent + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } } elseif ($action == 'addline' && $usercancreate) { // Add a new line $langs->load('errors'); $error = 0; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10a9429fbe2..ad57b610364 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1976,6 +1976,13 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); } + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define vat_rate + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); + } } elseif ($action == 'addline' && $usercancreate) { // Add a new line $langs->load('errors'); $error = 0; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index e8dbec2ac77..f4f962db554 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -105,7 +105,24 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { } // Reduction short -print ''; +print ''; // Fields for situation invoice if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { From a77ae1ecd95955839010f1875782fb6a8a285b54 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 15 Apr 2022 14:31:59 +0200 Subject: [PATCH 498/752] fix style errors --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7e653914d08..84078a4f38d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -838,7 +838,7 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - }elseif ($action == 'addline' && $usercancreate) { // Add line + } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); From dea1465fc7f3b5509a46c720e503a3d8c86d01c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 15 Apr 2022 14:44:19 +0200 Subject: [PATCH 499/752] add context --- htdocs/societe/consumption.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 3624f80187d..2ab5a836c51 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -4,7 +4,7 @@ * Copyright (C) 2013-2015 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2015-2017 Ferran Marcet - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2022 Frédéric France * * 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 @@ -86,7 +86,7 @@ $type_element = GETPOST('type_element') ? GETPOST('type_element') : ''; $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('consumptionthirdparty')); +$hookmanager->initHooks(array('consumptionthirdparty', 'globalcard')); /* From 4688b96d93a52c1ef95bcf7ff1d20d26ae74d1b3 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 15 Apr 2022 15:19:14 +0200 Subject: [PATCH 500/752] Add option MAIN_CHECKBOX_LEFT_COLUMN --- .../modulebuilder/template/myobject_list.php | 60 ++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 5317c581952..8a3b65af292 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -536,8 +536,12 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, 'left'); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, 'left'); // This also change content of $arrayfields +} else { + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +} + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; +$searchpicto = $form->showFilterButtons('left'); +print $searchpicto; +print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print '
'; + 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 ''; + } + print ''.$obj->anotherfield.''; - 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 ''; - } - print ''; print ''; + $form->selectInvoiceRec($search_fac_rec_source, 'search_fac_rec_source'); + print ''; @@ -1659,6 +1677,9 @@ if ($resql) { if (!empty($arrayfields['f.note_private']['checked'])) { print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } + if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { + print_liste_field_titre($arrayfields['f.fk_fac_rec_source']['label'], $_SERVER["PHP_SELF"], "f.fk_fac_rec_source", "", $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['f.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type", "", $param, 'class="right"', $sortfield, $sortorder); } @@ -2335,6 +2356,23 @@ if ($resql) { $totalarray['nbfield']++; } } + // Template Invoice + if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { + print ''; + if (!empty($obj->fk_fac_rec_source)) { + $facrec = new FactureRec($db); + $result = $facrec->fetch($obj->fk_fac_rec_source); + if ($result < 0) { + setEventMessages($facrec->error, $facrec->errors, 'errors'); + } else { + print $facrec->getNomUrl(); + } + } + print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b9812d8eec3..5b74816dfc3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9774,6 +9774,101 @@ class Form } } + /** + * Output a combo list with invoices qualified for a third party + * + * @param int $selected Id invoice preselected + * @param string $htmlname Name of HTML select + * @param int $maxlength Maximum length of label + * @param int $option_only Return only html options lines without the select tag + * @param string $show_empty Add an empty line ('1' or string to show for empty line) + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled + * @param string $morecss More css added to the select component + * @return int Nbr of project if OK, <0 if KO + */ + public function selectInvoiceRec($selected = '', $htmlname = 'facrecid', $maxlength = 24, $option_only = 0, $show_empty = '1', $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500') + { + global $user, $conf, $langs; + + $out = ''; + + dol_syslog('FactureRec::fetch', LOG_DEBUG); + + $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc'; + //$sql.= ', el.fk_source'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as f'; + $sql .= " WHERE f.entity IN (" . getEntity('invoice') . ")"; + $sql .= " ORDER BY f.titre ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + // Use select2 selector + if (!empty($conf->use_javascript_ajax)) { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); + $out .= $comboenhancement; + $morecss = 'minwidth200imp maxwidth500'; + } + + if (empty($option_only)) { + $out .= ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, '', '', $limit, 0, 0, 1); + +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if ($moreforfilter) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if (!empty($massactionbutton)) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +} + +print '
'; +print ''; + +print ''; + +// Filter: Ref +if (!empty($arrayfields['pndf.rowid']['checked'])) { + print ''; +} + +// Filter: Date +if (!empty($arrayfields['pndf.datep']['checked'])) { + print ''; +} + +// Filter: Thirdparty +if (!empty($arrayfields['u.login']['checked'])) { + print ''; +} + +// Filter: Payment type +if (!empty($arrayfields['c.libelle']['checked'])) { + print ''; +} + +// Filter: Cheque number (fund transfer) +if (!empty($arrayfields['pndf.num_payment']['checked'])) { + print ''; +} + +// Filter: Bank account +if (!empty($arrayfields['ba.label']['checked'])) { + print ''; +} + +// Filter: Amount +if (!empty($arrayfields['pndf.amount']['checked'])) { + print ''; +} + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +// Buttons +print ''; + +print ''; + +print ''; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.rowid']['checked'])) { + print_liste_field_titre($arrayfields['pndf.rowid']['label'], $_SERVER["PHP_SELF"], 'pndf.rowid', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.datep']['checked'])) { + print_liste_field_titre($arrayfields['pndf.datep']['label'], $_SERVER["PHP_SELF"], 'pndf.datep', '', $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.lastname', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['c.libelle']['checked'])) { + print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.num_payment']['checked'])) { + print_liste_field_titre($arrayfields['pndf.num_payment']['label'], $_SERVER["PHP_SELF"], "pndf.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pndf.num_payment']['tooltip']); +} +if (!empty($arrayfields['ba.label']['checked'])) { + print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.amount']['checked'])) { + print_liste_field_titre($arrayfields['pndf.amount']['label'], $_SERVER["PHP_SELF"], 'pndf.amount', '', $param, '', $sortfield, $sortorder, 'right '); +} + +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +print ''; + +$checkedCount = 0; +foreach ($arrayfields as $column) { + if ($column['checked']) { + $checkedCount++; + } +} + +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) { + $objp = $db->fetch_object($resql); + + $paymentexpensereportstatic->id = $objp->rowid; + $paymentexpensereportstatic->ref = $objp->ref; + $paymentexpensereportstatic->datepaye = $objp->datep; + + $userstatic->id = $objp->userid; + $userstatic->lastname = $objp->lastname; + $userstatic->firstname = $objp->firstname; + + print ''; + + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref + if (!empty($arrayfields['pndf.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['pndf.datep']['checked'])) { + $dateformatforpayment = 'dayhour'; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thirdparty + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Pyament type + if (!empty($arrayfields['c.libelle']['checked'])) { + $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Cheque number (fund transfer) + if (!empty($arrayfields['pndf.num_payment']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Bank account + if (!empty($arrayfields['ba.label']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount + if (!empty($arrayfields['pndf.amount']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + $totalarray['pos'][$checkedCount] = 'amount'; + $totalarray['val']['amount'] += $objp->pamount; + } + + // Buttons + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + + print ''; + $i++; +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +print '
'; + print ''; + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print ''; + print ''; + $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1); + print ''; + print ''; + print ''; + $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1); + print ''; + print ''; + print ''; +print $form->showFilterAndCheckAddButtons(0); +print '
'.(($offset * $limit) + $i).''.$paymentexpensereportstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; + if ($userstatic->id > 0) { + print $userstatic->getNomUrl(1); + } + print ''.$payment_type.' '.dol_trunc($objp->num_paiement, 32).''.$objp->num_paiement.''; + if ($objp->bid) { + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->iban = $objp->iban_prefix; + $accountstatic->bic = $objp->bic; + $accountstatic->currency_code = $objp->currency_code; + $accountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->code; + + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print ''.price($objp->pamount).'
'; +print '
'; +print ''; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/langs/en_US/expensereports.lang b/htdocs/langs/en_US/expensereports.lang new file mode 100644 index 00000000000..624a278b393 --- /dev/null +++ b/htdocs/langs/en_US/expensereports.lang @@ -0,0 +1 @@ +ExpenseReportPayments=Expense report payments From 8f397a38091fd1b577d697a1075542a33f3c644e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 15 Apr 2022 12:25:22 +0000 Subject: [PATCH 494/752] Fixing style errors. --- htdocs/expensereport/payment/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index d5073fa190a..8308ea3fc4c 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -299,7 +299,7 @@ if ($search_amount) { $param .= '&search_amount='.urlencode($search_amount); } -if($search_bank_account) { +if ($search_bank_account) { $param .= '&search_bank_account='.urlencode($search_bank_account); } From 0960320cf8ba8abefde72a70cf8efe28bebbb1ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Apr 2022 14:27:53 +0200 Subject: [PATCH 495/752] Fix missing icon in mass action --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c1165641b03..3bc9d97abd9 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -876,7 +876,7 @@ if ($user->rights->societe->creer) { $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); } if ($user->rights->societe->creer) { - $arrayofmassactions['presetcommercial'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); + $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); From 8c808ea5f5542ded307e163a0f32c1e0aed5835c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Apr 2022 14:31:00 +0200 Subject: [PATCH 496/752] Label --- htdocs/societe/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3bc9d97abd9..5884679950f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -249,7 +249,7 @@ $arrayfields = array( 's.idprof6'=>array('label'=>"ProfId6Short", 'position'=>45, 'checked'=>$checkedprofid6), 's.tva_intra'=>array('label'=>"VATIntraShort", 'position'=>50, 'checked'=>0), 'customerorsupplier'=>array('label'=>'NatureOfThirdParty', 'position'=>61, 'checked'=>1), - 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'position'=>62, 'checked'=>$checkprospectlevel), + 's.fk_prospectlevel'=>array('label'=>"ProspectLevel", 'position'=>62, 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'position'=>63, 'checked'=>$checkstcomm), 's2.nom'=>array('label'=>'ParentCompany', 'position'=>64, 'checked'=>0), 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), @@ -1648,7 +1648,7 @@ while ($i < min($num, $limit)) { $titlealt = $val['label']; } if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; + print ''.img_action($titlealt, $val['code'], $val['picto']).''; } } print '
'.$langs->trans('ReductionShort').''; +print $langs->trans('ReductionShort'); + +if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { + global $mysoc; + + if (empty($disableedit)) { + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').''; + } + //print ''; + if (GETPOST('mode', 'aZ09') == 'remiseforalllines') { + print '
'; + print ' %'; + print ''; + print '
'; + } +} +print '
'."\n"; @@ -547,10 +551,12 @@ print '
'; // Action column -print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -595,6 +601,13 @@ print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { print ''; }*/ +// Action column +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; $totalarray = array(); @@ -603,7 +616,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; -print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -631,6 +646,9 @@ print $hookmanager->resPrint; $totalarray['nbfield']++; }*/ // Action column +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} $totalarray['nbfield']++; print ''."\n"; @@ -677,15 +695,17 @@ while ($i < $imaxinloop) { $j = 0; print ''; // Action column - print ''; } - print ''; 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'))) { @@ -741,6 +761,18 @@ while ($i < $imaxinloop) { /*if (!empty($arrayfields['anotherfield']['checked'])) { print ''; }*/ + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } if (!$i) { $totalarray['nbfield']++; } From 81f0aedc8f55b02297e62bf2b0d936a668b52db9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 15 Apr 2022 16:17:03 +0200 Subject: [PATCH 501/752] FIX SEPA ICS is not mandatory for bank transfer --- htdocs/compta/prelevement/create.php | 35 ++++++++++++++++------- htdocs/compta/prelevement/fiche-rejet.php | 6 ++-- htdocs/compta/prelevement/fiche-stat.php | 6 ++-- htdocs/compta/prelevement/list.php | 18 +++++++----- htdocs/compta/prelevement/orders_list.php | 18 +++++++----- htdocs/compta/prelevement/rejets.php | 18 +++++++----- htdocs/compta/prelevement/stats.php | 8 ++++-- 7 files changed, 69 insertions(+), 40 deletions(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 172cf020e34..6416468fd63 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -39,12 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); // Get supervariables @@ -54,6 +48,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; $format = GETPOST('format', 'aZ09'); $id_bankaccount = GETPOST('id_bankaccount', 'int'); +$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -63,6 +59,17 @@ $offset = $limit * $page; $hookmanager->initHooks(array('directdebitcreatecard', 'globalcard')); +// Security check +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + +$error = 0; /* * Actions @@ -95,13 +102,15 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $bank = new Account($db); $bank->fetch($conf->global->{$default_account}); - if ((empty($bank->ics) && $type !== 'bank-transfer') + // ICS is not mandatory with payment by bank transfer + /*if ((empty($bank->ics) && $type !== 'bank-transfer') || (empty($bank->ics_transfer) && $type === 'bank-transfer') - ) { + ) {*/ + if (empty($bank->ics) && $type !== 'bank-transfer') { $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}')); setEventMessages($errormessage, null, 'errors'); - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php'); - exit; + $action = ''; + $error++; } @@ -136,12 +145,16 @@ if (empty($reshook)) { setEventMessages($texttoshow, null); } - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id); + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type)); exit; } } $objectclass = "BonPrelevement"; + if ($type == 'bank-transfer') { + $uploaddir = $conf->paymentbybanktransfer->dir_output; + } else { $uploaddir = $conf->prelevement->dir_output; + } include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 8711f663d55..e1850575dc0 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -40,7 +40,7 @@ if ($user->socid > 0) { } // Get supervariables -$prev_id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $type = GETPOST('type', 'aZ09'); @@ -77,8 +77,8 @@ if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transf llxHeader('', $langs->trans("WithdrawalsReceipts")); -if ($prev_id > 0 || $ref) { - if ($object->fetch($prev_id, $ref) >= 0) { +if ($id > 0 || $ref) { + if ($object->fetch($id, $ref) >= 0) { $head = prelevement_prepare_head($object); print dol_get_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 4a9bfbf6345..9336ad51370 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -38,7 +38,7 @@ if ($user->socid > 0) { } // Get supervariables -$prev_id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $type = GETPOST('type', 'aZ09'); @@ -76,8 +76,8 @@ if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transf llxHeader('', $langs->trans("WithdrawalsReceipts")); -if ($prev_id > 0 || $ref) { - if ($object->fetch($prev_id, $ref) >= 0) { +if ($id > 0 || $ref) { + if ($object->fetch($id, $ref) >= 0) { $head = prelevement_prepare_head($object); print dol_get_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index feb69bdc7fb..095d07460b9 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -42,13 +42,6 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'di $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -80,6 +73,17 @@ $company = new Societe($db); $hookmanager->initHooks(array('withdrawalsreceiptslineslist')); +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 3ca9ce32fbe..2733223b5b5 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -33,13 +33,6 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals')); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -72,6 +65,17 @@ if ($type == 'bank-transfer') { $usercancreate = $user->rights->paymentbybanktransfer->create; } +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index ed8c704bcfa..3aa57a6f3e0 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -33,13 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); // Get supervariables @@ -54,6 +47,17 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * View diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index ae1dd54a13c..7c7bce9f2ef 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -31,14 +31,18 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); +$type = GETPOST('type', 'aZ09'); + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { $result = restrictedArea($user, 'prelevement', '', '', 'bons'); - -$type = GETPOST('type', 'aZ09'); +} /* From 34409144b3dbde6d4641f83026b2ea84c8969870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 15 Apr 2022 16:24:54 +0200 Subject: [PATCH 502/752] Update agenda.lang --- htdocs/langs/en_US/agenda.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index bc9c7dab537..bbe5b56cdf9 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -66,6 +66,7 @@ ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status ShipmentDeletedInDolibarr=Shipment %s deleted ShipmentCanceledInDolibarr=Shipment %s canceled ReceptionValidatedInDolibarr=Reception %s validated +ReceptionClassifyClosedInDolibarr=Reception %s classified closed OrderCreatedInDolibarr=Order %s created OrderValidatedInDolibarr=Order %s validated OrderDeliveredInDolibarr=Order %s classified delivered From cc9c49afc911e80b0ee407b9fbe1f5ca65f9cd89 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 15 Apr 2022 16:40:41 +0200 Subject: [PATCH 503/752] TODO ICS is not used with bank transfer --- htdocs/compta/bank/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 62b97f6d100..a6e8a3824e7 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -759,6 +759,7 @@ if ($action == 'create') { print ''; } + // TODO ICS is not used with bank transfer ! if ($conf->paymentbybanktransfer->enabled) { print ''; print ''; From 140f983ca790d967741a1d11fd7f6e2030980cbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Apr 2022 18:04:58 +0200 Subject: [PATCH 504/752] Fix look and feel v16 for the Quick add feature. --- htdocs/main.inc.php | 8 ++------ htdocs/theme/eldy/dropdown.inc.php | 16 +++++++++++---- htdocs/theme/eldy/global.inc.php | 13 ++++++++++--- htdocs/theme/md/dropdown.inc.php | 31 ++++++++++++++++++++++-------- htdocs/theme/md/style.css.php | 9 +++++---- 5 files changed, 52 insertions(+), 25 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 59a43daac65..805d7b9e105 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2348,9 +2348,7 @@ function top_menu_quickadd() $html .= ' '; $html .= ' @@ -2559,9 +2557,7 @@ function top_menu_bookmark() } else { $html .= ' '; */ + // Show Quick Add link + print ''; + print ''; + print ''; + // Show bugtrack link print '\n"; + if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) { + print '\n"; + } else { + print '\n"; + } if (!$i) { $totalarray['nbfield']++; } From ed7044e01866a1db58520f49fea8b1b79669b712 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 17 Apr 2022 00:10:35 +0200 Subject: [PATCH 510/752] Missing files.lib.php for dol_is_dir --- htdocs/emailcollector/class/emailcollector.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 032ee4b534b..345f62656c0 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -23,6 +23,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; From 7f27b8c499bb8318136af00ba36fc6ff49466100 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 17 Apr 2022 03:56:36 +0200 Subject: [PATCH 511/752] Use default e-mail sender/notif/body/signature for tickets if they exist Otherwise, when params have not been configured, error message due to an empty "from e-mail" is unclear --- htdocs/admin/ticket.php | 22 +++++++++++++--------- htdocs/core/modules/modTicket.class.php | 6 +++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index ebf4187eabf..db786894e1d 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -103,10 +103,11 @@ if ($action == 'updateMask') { include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); + $notification_email_description = "Sender of ticket replies sent from Dolibarr"; if (!empty($notification_email)) { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, $notification_email_description, $conf->entity); + } else { // If an empty e-mail address is providen, use the global "FROM" since an empty field will cause other issues + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $conf->global->MAIN_MAIL_EMAIL_FROM, 'chaine', 0, $notification_email_description, $conf->entity); } if (!($res > 0)) { $error++; @@ -114,30 +115,33 @@ if ($action == 'updateMask') { // altairis : differentiate notification email FROM and TO $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha'); + $notification_email_to_description = "Notified e-mail for ticket replies sent from Dolibarr"; if (!empty($notification_email_to)) { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, $notification_email_to_description, $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, $notification_email_to_description, $conf->entity); } if (!($res > 0)) { $error++; } $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml'); + $mail_intro_description = "Introduction text of ticket replies sent from Dolibarr"; if (!empty($mail_intro)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, $mail_intro_description, $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', '', 'chaine', 0, $mail_intro_description, $conf->entity); } if (!($res > 0)) { $error++; } $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml'); + $signature_description = "Signature of ticket replies sent from Dolibarr"; if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, $signature_description, $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', '', 'chaine', 0, $signature_description, $conf->entity); } if (!($res > 0)) { $error++; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index ff7eb1ee18f..e315877d648 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -40,6 +40,7 @@ class modTicket extends DolibarrModules public function __construct($db) { global $langs, $conf; + $langs->load("ticket"); $this->db = $db; @@ -111,7 +112,10 @@ class modTicket extends DolibarrModules 5 => array('TICKET_DELAY_BEFORE_FIRST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time before a first answer to a ticket (in hours). Display a warning in tickets list if not respected.', 0), 6 => array('TICKET_DELAY_SINCE_LAST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time between two answers on the same ticket (in hours). Display a warning in tickets list if not respected.', 0), 7 => array('TICKET_NOTIFY_AT_CLOSING', 'chaine', '0', 'Default notify contacts when closing a module', 0), - 8 => array('TICKET_PRODUCT_CATEGORY', 'chaine', 0, 'The category of product that is being used for ticket accounting', 0) + 8 => array('TICKET_PRODUCT_CATEGORY', 'chaine', 0, 'The category of product that is being used for ticket accounting', 0), + 9 => array('TICKET_NOTIFICATION_EMAIL_FROM', 'chaine', $conf->global->MAIN_MAIL_EMAIL_FROM, 'Sender of ticket replies sent from Dolibarr', 0), + 10 => array('TICKET_MESSAGE_MAIL_INTRO', 'chaine', $langs->trans('TicketMessageMailIntroText'), 'Introduction text of ticket replies sent from Dolibarr', 0), + 11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $langs->trans('TicketMessageMailSignatureText'), 'Signature of ticket replies sent from Dolibarr', 0) ); From ad0199afd112991aa6999a23058f616d37d668c4 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 17 Apr 2022 03:57:00 +0200 Subject: [PATCH 512/752] Rephrased ticket labels --- htdocs/admin/ticket.php | 4 ++-- htdocs/langs/en_US/ticket.lang | 16 ++++++++-------- htdocs/langs/fr_FR/ticket.lang | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index db786894e1d..43f19047bf8 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -648,7 +648,7 @@ print ''; print ''; // Email for notification of TICKET_CREATE -print ''; +print ''; print ''; print '
'; -$searchpicto = $form->showFilterButtons('left'); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; - 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; + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 ''; } - print ''; + print ''.$obj->anotherfield.''; + 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 ''; + } + print '
'.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')'.$object->ics_transfer.'
' . $langs->trans("ShowQuickAddLink") . ''; + print ajax_constantonoff("MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); + print ' 
'; print $form->textwithpicto($langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")), $langs->trans("ShowBugTrackLinkDesc")); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1dc7d4e2092..a396d87fbef 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2234,3 +2234,4 @@ TemplateforBusinessCards=Template for a business card in different size InventorySetup= Inventory Setup ExportUseLowMemoryMode=Use a low memory mode ExportUseLowMemoryModeHelp=Use the low memory mode to execute the exec of the dump (compression is done through a pipe instead of into the PHP memory). This method does not allow to check that file is completed and error message can't be reported if it fails. +ShowQuickAddLink=Show a link to quickly add an element in top right menu From 8caa45ee807257ec006fe32e7c403a16405653cf Mon Sep 17 00:00:00 2001 From: Lenin Rivas <53640168+leninrivas@users.noreply.github.com> Date: Mon, 18 Apr 2022 12:22:29 -0500 Subject: [PATCH 509/752] Show only code multicurrency in lists --- htdocs/compta/facture/list.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index eedc3297018..213b5cf2f01 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -2188,7 +2188,11 @@ if ($resql) { // Currency if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print ''.dol_escape_htmltag($obj->multicurrency_code).' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'.dol_escape_htmltag($obj->multicurrency_code).' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'.dol_escape_htmltag($obj->multicurrency_code)."
'.$langs->trans("TicketEmailNotificationTo").' ('.$langs->trans("Creation").')
'.$langs->trans("TicketEmailNotificationTo").''; print ''; @@ -675,7 +675,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // Texte d'introduction $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print '
'.$langs->trans("TicketMessageMailIntroLabelAdmin").' ('.$langs->trans("Responses").')'; +print '
'.$langs->trans("TicketMessageMailIntroLabelAdmin"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index edd54911bad..dc67521c3a8 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -90,10 +90,10 @@ TicketPublicAccess=A public interface requiring no identification is available a TicketSetupDictionaries=The type of ticket, severity and analytic codes are configurable from dictionaries TicketParamModule=Module variable setup TicketParamMail=Email setup -TicketEmailNotificationFrom=Notification email from -TicketEmailNotificationFromHelp=Used into ticket message answer by example -TicketEmailNotificationTo=Notifications email to -TicketEmailNotificationToHelp=Send email notifications to this address. +TicketEmailNotificationFrom=Sender e-mail for ticket answers +TicketEmailNotificationFromHelp=Sender e-mail for ticket answers sent from Dolibarr +TicketEmailNotificationTo=Notify ticket creation to this e-mail address +TicketEmailNotificationToHelp=If present, this e-mail address will be notified of a ticket creation TicketNewEmailBodyLabel=Text message sent after creating a ticket TicketNewEmailBodyHelp=The text specified here will be inserted into the email confirming the creation of a new ticket from the public interface. Information on the consultation of the ticket are automatically added. TicketParamPublicInterface=Public interface setup @@ -219,9 +219,9 @@ ErrorMailRecipientIsEmptyForSendTicketMessage=Recipient is empty. No email send TicketGoIntoContactTab=Please go into "Contacts" tab to select them TicketMessageMailIntro=Introduction TicketMessageMailIntroHelp=This text is added only at the beginning of the email and will not be saved. -TicketMessageMailIntroLabelAdmin=Introduction to the message when sending email -TicketMessageMailIntroText=Hello,
A new response was sent on a ticket that you contact. Here is the message:
-TicketMessageMailIntroHelpAdmin=This text will be inserted before the text of the response to a ticket. +TicketMessageMailIntroLabelAdmin=Introduction text to all ticket answers +TicketMessageMailIntroText=Hello,
A new answer has been added to a ticket that you follow. Here is the message:
+TicketMessageMailIntroHelpAdmin=This text will be inserted before the answer when replying to a ticket from Dolibarr TicketMessageMailSignature=Signature TicketMessageMailSignatureHelp=This text is added only at the end of the email and will not be saved. TicketMessageMailSignatureText=

Sincerely,

--

@@ -289,7 +289,7 @@ TicketNewEmailBody=This is an automatic email to confirm you have registered a n TicketNewEmailBodyCustomer=This is an automatic email to confirm a new ticket has just been created into your account. TicketNewEmailBodyInfosTicket=Information for monitoring the ticket TicketNewEmailBodyInfosTrackId=Ticket tracking number: %s -TicketNewEmailBodyInfosTrackUrl=You can view the progress of the ticket by clicking the link above. +TicketNewEmailBodyInfosTrackUrl=You can view the progress of the ticket by clicking the following link TicketNewEmailBodyInfosTrackUrlCustomer=You can view the progress of the ticket in the specific interface by clicking the following link TicketCloseEmailBodyInfosTrackUrlCustomer=You can consult the history of this ticket by clicking the following link TicketEmailPleaseDoNotReplyToThisEmail=Please do not reply directly to this email! Use the link to reply into the interface. diff --git a/htdocs/langs/fr_FR/ticket.lang b/htdocs/langs/fr_FR/ticket.lang index bc51a7627fd..f6f5e7f38c4 100644 --- a/htdocs/langs/fr_FR/ticket.lang +++ b/htdocs/langs/fr_FR/ticket.lang @@ -90,10 +90,10 @@ TicketPublicAccess=Une interface publique ne nécessitant aucune identification TicketSetupDictionaries=Les types de ticket, sévérité et codes analytiques sont paramétrables à partir des dictionnaires TicketParamModule=Configuration des variables du module TicketParamMail=Configuration de la messagerie -TicketEmailNotificationFrom=Email from de notification -TicketEmailNotificationFromHelp=Utilisé dans les messages de réponses des tickets par exemple -TicketEmailNotificationTo=E-mail de notification à -TicketEmailNotificationToHelp=Envoyer des notifications par e-mail à cette adresse. +TicketEmailNotificationFrom=Adresse e-mail émettrice des réponses aux tickets +TicketEmailNotificationFromHelp=Adresse e-mail émettrice des réponses aux tickets envoyées depuis Dolibarr +TicketEmailNotificationTo=Notifier cette adresse e-mail lors d'un nouveau ticket +TicketEmailNotificationToHelp=Si présente, cette adresse e-mail sera notifiée de la création d'un nouvau ticket TicketNewEmailBodyLabel=Texte du message envoyé après la création d'un ticket TicketNewEmailBodyHelp=Le texte spécifié ici sera inséré dans l'e-mail confirmant la création d'un nouveau ticket depuis l'interface publique. Les informations sur la consultation du ticket sont automatiquement ajoutées. TicketParamPublicInterface=Configuration de l'interface publique\n @@ -209,7 +209,7 @@ TicketGoIntoContactTab=Rendez-vous dans le tableau "Contacts" pour les sélectio TicketMessageMailIntro=Introduction TicketMessageMailIntroHelp=Ce texte est ajouté seulement au début de l'email et ne sera pas sauvegardé. TicketMessageMailIntroLabelAdmin=Introduction du message lors de l'envoi d'un e-mail -TicketMessageMailIntroText=Bonjour
Une nouvelle réponse a été ajoutée à un ticket que vous suivez. Voici le message :
+TicketMessageMailIntroText=Bonjour,
Une nouvelle réponse a été ajoutée à un ticket que vous suivez. Voici le message :
TicketMessageMailIntroHelpAdmin=Ce texte sera inséré après le message de réponse. TicketMessageMailSignature=Signature TicketMessageMailSignatureHelp=Ce texte est ajouté seulement à la fin de l'email et ne sera pas sauvegardé. @@ -271,8 +271,8 @@ TicketNewEmailBody=Ceci est un message automatique pour confirmer l'enregistreme TicketNewEmailBodyCustomer=Ceci est un email automatique pour confirmer qu'un nouveau ticket vient d'être créé dans votre compte. TicketNewEmailBodyInfosTicket=Informations pour la surveillance du ticket TicketNewEmailBodyInfosTrackId=Numéro de suivi du ticket : %s -TicketNewEmailBodyInfosTrackUrl=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-dessus. -TicketNewEmailBodyInfosTrackUrlCustomer=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-dessus. +TicketNewEmailBodyInfosTrackUrl=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-contre +TicketNewEmailBodyInfosTrackUrlCustomer=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-contre TicketEmailPleaseDoNotReplyToThisEmail=Merci de ne pas répondre directement à ce courriel ! Utilisez le lien pour répondre via l'interface. TicketPublicInfoCreateTicket=Ce formulaire vous permet d'enregistrer un ticket dans notre système de gestion. TicketPublicPleaseBeAccuratelyDescribe=Veuillez décrire avec précision le problème. Fournissez le plus d'informations possibles pour nous permettre d'identifier correctement votre demande. From cbdf74e00c7f7dbf5f19c03b906c28e77e4102b2 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 18 Apr 2022 02:28:02 +0200 Subject: [PATCH 513/752] i18n the default email collector descriptions --- .../core/modules/modEmailCollector.class.php | 45 +++++++++---------- htdocs/langs/en_US/admin.lang | 14 +++++- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 566d050aacd..2c96aa249d7 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -263,7 +263,8 @@ class modEmailCollector extends DolibarrModules */ public function init($options = '') { - global $conf, $user; + global $conf, $user, $langs; + $langs->load("admin"); $sql = array(); @@ -271,21 +272,20 @@ class modEmailCollector extends DolibarrModules $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionA1 = 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated.'; - $descriptionA1 .= ' If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.'; - + $descriptionA1 = $langs->trans('EmailCollectorExampleToCollectTicketRequestsDesc'); + $label = $langs->trans('EmailCollectorExampleToCollectTicketRequests'); $sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requets', 'Example to collect ticket requests', '".$this->db->escape($descriptionA1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; + $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requests', '".$this->db->escape($label)."', '".$this->db->escape($descriptionA1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; $sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; $sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; $sqlforexampleFilterA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; - $sqlforexampleFilterA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $sqlforexampleFilterA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; $sqlforexampleA4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)"; - $sqlforexampleA4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $sqlforexampleA4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; $sql[] = $sqlforexampleA1; $sql[] = $sqlforexampleFilterA1; @@ -301,10 +301,10 @@ class modEmailCollector extends DolibarrModules $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionA1 = 'This collector will scan your mailbox "Sent" directory to find emails that was sent as an answer of another email directly from your email software and not from Dolibarr. If such an email is found, the event of answer is recorded into Dolibarr.'; - + $descriptionA1 = $langs->trans('EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware'); + $label = $langs->trans('EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware'); $sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Responses_Out', 'Example to collect answers to emails done from your external email software', '".$this->db->escape($descriptionA1)."', 'Sent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; + $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Responses_Out', '".$this->db->escape($label)."', '".$this->db->escape($descriptionA1)."', 'Sent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; $sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".((int) $conf->entity)."), 'isanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; @@ -324,10 +324,10 @@ class modEmailCollector extends DolibarrModules $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionB1 = 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event (Module Agenda must be enabled) with the email response will be recorded at the good place. For example, if your send a commercial proposal, order, invoice or message for a ticket by email from the application, and your customer answers your email, the system will automatically catch the answer and add it into your ERP.'; - + $descriptionB1 = $langs->trans('EmailCollectorExampleToCollectDolibarrAnswersDesc'); + $label = $langs->trans('EmailCollectorExampleToCollectDolibarrAnswers'); $sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses_In', 'Example to collect any received email that is a response of an email sent from Dolibarr', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; + $sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses_In', '".$this->db->escape($label)."', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; $sqlforexampleB2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; $sqlforexampleB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".((int) $conf->entity)."), 'isanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; $sqlforexampleB3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)"; @@ -345,12 +345,10 @@ class modEmailCollector extends DolibarrModules $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionC1 = "This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated."; - $descriptionC1 .= " If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.
"; - $descriptionC1 .= "Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1."; - + $descriptionC1 = $langs->trans("EmailCollectorExampleToCollectLeadsDesc"); + $label = $langs->trans('EmailCollectorExampleToCollectLeads'); $sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', 'Example to collect leads', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; + $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', '".$this->db->escape($label)."', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; $sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; $sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; @@ -376,11 +374,10 @@ class modEmailCollector extends DolibarrModules $tmpresql = $this->db->query($tmpsql); if ($tmpresql) { if ($this->db->num_rows($tmpresql) == 0) { - $descriptionC1 = "This collector will scan your mailbox to find emails send for a recruitment (Module Recruitment must be enabled). You can complete this collector if you want to automaticallycreate a candidature for a job request."; - $descriptionC1 .= "Note: With this initial example, the title of the candidature is generated including the email."; - + $descriptionC1 = $langs->trans("EmailCollectorExampleToCollectJobCandidaturesDesc"); + $label = $langs->trans('EmailCollectorExampleToCollectJobCandidatures'); $sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)"; - $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Candidatures', 'Example to collect email for job candidatures', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; + $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Candidatures', '".$this->db->escape($label)."', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)"; $sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)"; $sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1dc7d4e2092..a3473139638 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2066,12 +2066,22 @@ EmailcollectorOperations=Operations to do by collector EmailcollectorOperationsDesc=Operations are executed from top to bottom order MaxEmailCollectPerCollect=Max number of emails collected per collect CollectNow=Collect now -ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s ? +ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s? DateLastCollectResult=Date of latest collect try DateLastcollectResultOk=Date of latest collect success LastResult=Latest result EmailCollectorConfirmCollectTitle=Email collect confirmation -EmailCollectorConfirmCollect=Do you want to run the collection for this collector now ? +EmailCollectorConfirmCollect=Do you want to run this collector now? +EmailCollectorExampleToCollectTicketRequestsDesc=Collect emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. Activate also Collect_Responses to collect answers of your client directly on the ticket view (you must reply from Dolibarr). +EmailCollectorExampleToCollectTicketRequests=Example collecting the ticket request (first message only) +EmailCollectorExampleToCollectAnswersFromExternalEmailSoftwareDesc=Scan your mailbox "Sent" directory to find emails that was sent as an answer of another email directly from your email software and not from Dolibarr. If such an email is found, the event of answer is recorded into Dolibarr +EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware=Example collecting e-mail answers sent from an external e-mail software +EmailCollectorExampleToCollectDolibarrAnswersDesc=Collect all emails that are an answer of an email sent from your application. An event (Module Agenda must be enabled) with the email response will be recorded at the good place. For example, if your send a commercial proposal, order, invoice or message for a ticket by email from the application, and your customer answers your email, the system will automatically catch the answer and add it into your ERP. +EmailCollectorExampleToCollectDolibarrAnswers=Example collecting all ingoing messages being answers to messages sent from Dolibarr' +EmailCollectorExampleToCollectLeadsDesc=Collect emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.
Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1. +EmailCollectorExampleToCollectLeads=Example collecting leads +EmailCollectorExampleToCollectJobCandidaturesDesc=Collect emails applying to job offers (Module Recruitment must be enabled). You can complete this collector if you want to automatically create a candidature for a job request. Note: With this initial example, the title of the candidature is generated including the email. +EmailCollectorExampleToCollectJobCandidatures=Example collecting job candidatures received by e-mail NoNewEmailToProcess=No new email (matching filters) to process NothingProcessed=Nothing done XEmailsDoneYActionsDone=%s emails qualified, %s emails successfully processed (for %s record/actions done) From d5361c31477214b01dd87a9a1af3df8563059e45 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 18 Apr 2022 03:41:40 +0200 Subject: [PATCH 514/752] Improved default signature for tickets --- htdocs/core/modules/modTicket.class.php | 4 +++- htdocs/langs/en_US/ticket.lang | 2 +- htdocs/langs/fr_FR/ticket.lang | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index e315877d648..f7bed1e5ae8 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -104,6 +104,7 @@ class modTicket extends DolibarrModules // List of particular constants to add when module is enabled // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // Example: + $default_signature = $langs->trans('TicketMessageMailSignatureText', $conf->global->MAIN_INFO_SOCIETE_NOM); $this->const = array( 1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0), 2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0), @@ -115,7 +116,8 @@ class modTicket extends DolibarrModules 8 => array('TICKET_PRODUCT_CATEGORY', 'chaine', 0, 'The category of product that is being used for ticket accounting', 0), 9 => array('TICKET_NOTIFICATION_EMAIL_FROM', 'chaine', $conf->global->MAIN_MAIL_EMAIL_FROM, 'Sender of ticket replies sent from Dolibarr', 0), 10 => array('TICKET_MESSAGE_MAIL_INTRO', 'chaine', $langs->trans('TicketMessageMailIntroText'), 'Introduction text of ticket replies sent from Dolibarr', 0), - 11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $langs->trans('TicketMessageMailSignatureText'), 'Signature of ticket replies sent from Dolibarr', 0) + 11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $default_signature, 'Signature of ticket replies sent from Dolibarr', 0) + ); diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index dc67521c3a8..c1cfa5e9757 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -224,7 +224,7 @@ TicketMessageMailIntroText=Hello,
A new answer has been added to a ticket tha TicketMessageMailIntroHelpAdmin=This text will be inserted before the answer when replying to a ticket from Dolibarr TicketMessageMailSignature=Signature TicketMessageMailSignatureHelp=This text is added only at the end of the email and will not be saved. -TicketMessageMailSignatureText=

Sincerely,

--

+TicketMessageMailSignatureText=Message sent by %s via Dolibarr TicketMessageMailSignatureLabelAdmin=Signature of response email TicketMessageMailSignatureHelpAdmin=This text will be inserted after the response message. TicketMessageHelp=Only this text will be saved in the message list on ticket card. diff --git a/htdocs/langs/fr_FR/ticket.lang b/htdocs/langs/fr_FR/ticket.lang index f6f5e7f38c4..e19871f09df 100644 --- a/htdocs/langs/fr_FR/ticket.lang +++ b/htdocs/langs/fr_FR/ticket.lang @@ -213,7 +213,7 @@ TicketMessageMailIntroText=Bonjour,
Une nouvelle réponse a été ajoutée TicketMessageMailIntroHelpAdmin=Ce texte sera inséré après le message de réponse. TicketMessageMailSignature=Signature TicketMessageMailSignatureHelp=Ce texte est ajouté seulement à la fin de l'email et ne sera pas sauvegardé. -TicketMessageMailSignatureText=

Cordialement,

--

+TicketMessageMailSignatureText=Message envoyé par %s via Dolibarr TicketMessageMailSignatureLabelAdmin=Signature de l'email de réponse TicketMessageMailSignatureHelpAdmin=Ce texte sera inséré après le message de réponse. TicketMessageHelp=Seul ce texte sera sauvegardé dans la liste des messages sur la fiche ticket. From bf5076e18178344dbde2a8099cbd5201eaede35b Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 18 Apr 2022 04:00:58 +0200 Subject: [PATCH 515/752] set MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER to TRUE by default This is way more readable --- htdocs/core/modules/modTicket.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index f7bed1e5ae8..483c5ff27cc 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -116,8 +116,8 @@ class modTicket extends DolibarrModules 8 => array('TICKET_PRODUCT_CATEGORY', 'chaine', 0, 'The category of product that is being used for ticket accounting', 0), 9 => array('TICKET_NOTIFICATION_EMAIL_FROM', 'chaine', $conf->global->MAIN_MAIL_EMAIL_FROM, 'Sender of ticket replies sent from Dolibarr', 0), 10 => array('TICKET_MESSAGE_MAIL_INTRO', 'chaine', $langs->trans('TicketMessageMailIntroText'), 'Introduction text of ticket replies sent from Dolibarr', 0), - 11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $default_signature, 'Signature of ticket replies sent from Dolibarr', 0) - + 11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $default_signature, 'Signature of ticket replies sent from Dolibarr', 0), + 12 => array('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER', 'chaine', "1", 'Disable the rendering of headers in tickets', 0) ); From 37ab728846946db83e911f8f9315f3da07f41090 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 18 Apr 2022 04:54:50 +0200 Subject: [PATCH 516/752] Allow users to switch on e-mail headers again in UI --- htdocs/admin/emailcollector_list.php | 29 ++++++++++++++++++++++++++++ htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 31 insertions(+) diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 9e93dd78b86..7784bda0cac 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -29,6 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formcategory.class.php"; + dol_include_once('/emailcollector/class/emailcollector.class.php'); // Load translation files required by page @@ -594,6 +596,33 @@ print $hookmanager->resPrint; print '
'."\n"; print '
'."\n"; +$formcategory = new FormCategory($db); + +print load_fiche_titre($langs->trans("Other"), '', ''); +print ''; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + +// Hide e-mail headers from collected messages +print ''; +print ''; +print ''; +print ''; + +print '
'.$langs->trans("Parameter").'
'.$langs->trans("EmailCollectorHideMailHeaders").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $formcategory->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND); +} +print ''; +print $formcategory->textwithpicto('', $langs->trans("EmailCollectorHideMailHeadersHelp"), 1, 'help'); +print '

'; print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a3473139638..fe555e7b699 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2070,6 +2070,8 @@ ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s DateLastCollectResult=Date of latest collect try DateLastcollectResultOk=Date of latest collect success LastResult=Latest result +EmailCollectorHideMailHeaders=Hide headers of collected e-mails +EmailCollectorHideMailHeadersHelp=When enabled, e-mail headers are ignored during the collection EmailCollectorConfirmCollectTitle=Email collect confirmation EmailCollectorConfirmCollect=Do you want to run this collector now? EmailCollectorExampleToCollectTicketRequestsDesc=Collect emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. Activate also Collect_Responses to collect answers of your client directly on the ticket view (you must reply from Dolibarr). From aa36e396a3338451090dee16338699dcc91f6fc5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 18 Apr 2022 22:23:44 +0000 Subject: [PATCH 517/752] Fixing style errors. --- htdocs/admin/ticket.php | 2 +- htdocs/core/modules/modTicket.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 43f19047bf8..f257b040636 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -106,7 +106,7 @@ if ($action == 'updateMask') { $notification_email_description = "Sender of ticket replies sent from Dolibarr"; if (!empty($notification_email)) { $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, $notification_email_description, $conf->entity); - } else { // If an empty e-mail address is providen, use the global "FROM" since an empty field will cause other issues + } else { // If an empty e-mail address is providen, use the global "FROM" since an empty field will cause other issues $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $conf->global->MAIN_MAIL_EMAIL_FROM, 'chaine', 0, $notification_email_description, $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 483c5ff27cc..8fa132d4843 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -104,7 +104,7 @@ class modTicket extends DolibarrModules // List of particular constants to add when module is enabled // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // Example: - $default_signature = $langs->trans('TicketMessageMailSignatureText', $conf->global->MAIN_INFO_SOCIETE_NOM); + $default_signature = $langs->trans('TicketMessageMailSignatureText', $conf->global->MAIN_INFO_SOCIETE_NOM); $this->const = array( 1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0), 2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0), From 68cfe61fb8fa8a72c8b5c10a4fb54fab2d8af1fd Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 19 Apr 2022 17:59:59 +0200 Subject: [PATCH 518/752] FIX get TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCE const in TakePos --- htdocs/takepos/admin/setup.php | 2 +- htdocs/takepos/ajax/ajax.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index e631776490a..849c5c56481 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -392,7 +392,7 @@ if (!empty($conf->barcode->enabled)) { print ''; print $form->textwithpicto($langs->trans("TakeposBarcodeRuleToInsertProduct"), $langs->trans("TakeposBarcodeRuleToInsertProductDesc")); print ''; - print ''; + print ''; print "\n"; } diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index a3bcc04b5c8..491a9754748 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -111,8 +111,8 @@ if ($action == 'getProducts') { } } - if (!empty($conf->barcode->enabled) && !empty($conf->global->TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT)) { - $barcode_rules = $conf->global->TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT; + $barcode_rules = getDolGlobalString('TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT'); + if (!empty($conf->barcode->enabled) && !empty($barcode_rules)) { $barcode_rules_list = array(); // get barcode rules From aa86b2c71fc7b82f80d5173e7b6b31f2b12dd39e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Apr 2022 22:26:27 +0200 Subject: [PATCH 519/752] Fix root passfield not editable on install Fix user photo when gravatar not reachable --- htdocs/admin/system/dolibarr.php | 3 ++- htdocs/core/class/html.form.class.php | 6 +++--- htdocs/install/fileconf.php | 3 ++- htdocs/langs/en_US/admin.lang | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index d10e789f39c..e58cf45dd7e 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -435,7 +435,8 @@ foreach ($configfileparameters as $key => $value) { if (empty($valuetoshow)) { print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); } - print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; + print ''; + print '  => '.$langs->trans("HashForPing").''.md5('dolibarr'.$valuetoshow).''."\n"; } elseif ($newkey == 'dolibarr_main_prod') { print ${$newkey}; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d3e14b09c85..d656fbde897 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9101,12 +9101,12 @@ class Form if (!empty($conf->gravatar->enabled) && $email && empty($noexternsourceoverwrite)) { // see https://gravatar.com/site/implement/images/php/ $ret .= ''; - $ret .= 'Gravatar avatar'; // gravatar need md5 hash + $ret .= ''; // gravatar need md5 hash } else { if ($nophoto == 'company') { - $ret .= '
'.img_picto('', 'company').'
'; + $ret .= '
'.img_picto('', 'company').'
'; } else { - $ret .= 'No photo'; + $ret .= ''; } } } diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 42ea5e423af..03c5984d780 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -613,12 +613,13 @@ jQuery(document).ready(function() { function init_needroot() { + console.log("init_needroot force_install_noedit="); /*alert(jQuery("#db_create_database").prop("checked")); */ if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked")) { jQuery(".hideroot").show(); + if (empty($force_install_noedit)) { ?> jQuery(".needroot").removeAttr('disabled'); } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5af3fe19592..84df64fe655 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2219,4 +2219,5 @@ EachTerminalHasItsOwnCounter=Each terminal use its own counter. FillAndSaveAccountIdAndSecret=Fill and save account ID and secret first PreviousHash=Previous hash LateWarningAfter="Late" warning after -TemplateforBusinessCards=Template for a business card in different size \ No newline at end of file +TemplateforBusinessCards=Template for a business card in different size +HashForPing=Hash used for ping From 1e96cd636f81935b452cc5e40a7814e93bdc5d40 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 19 Apr 2022 22:38:42 +0200 Subject: [PATCH 520/752] FIX Accountancy - Missing language key --- htdocs/langs/en_US/accountancy.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index fd5ff8461fe..c66e0295bfa 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -302,6 +302,7 @@ NotYetAccounted=Not yet transferred to accounting ShowTutorial=Show Tutorial NotReconciled=Not reconciled WarningRecordWithoutSubledgerAreExcluded=Warning, all lines without subledger account defined are filtered and excluded from this view +AccountRemovedFromCurrentChartOfAccount=Accounting account that does not exist in the current chart of accounts ## Admin BindingOptions=Binding options From 307476786cc33f94447e78db3c58882f47523185 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Apr 2022 23:24:08 +0200 Subject: [PATCH 521/752] Fix label of remain to pay on vendor invoices FIX tool to fix bank account not in main currency for vendor invoice --- htdocs/compta/bank/card.php | 8 +++--- htdocs/fourn/facture/card.php | 30 ++++++++++------------- htdocs/install/mysql/migration/repair.sql | 3 +++ htdocs/langs/en_US/withdrawals.lang | 4 ++- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 283258a08a0..9211fa71b9e 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -769,13 +769,13 @@ if ($action == 'create') { print ''; if ($conf->prelevement->enabled) { - print ''.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')'; + print ''.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').''; print ''.$object->ics.''; print ''; } if ($conf->paymentbybanktransfer->enabled) { - print ''.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')'; + print ''.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').''; print ''.$object->ics_transfer.''; print ''; } @@ -1068,12 +1068,12 @@ if ($action == 'create') { print ''; if ($conf->prelevement->enabled) { - print ''.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')'; + print ''.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').''; print ''; } if ($conf->paymentbybanktransfer->enabled) { - print ''.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')'; + print ''.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').''; print ''; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 5a9b1054773..71c7a4beaf5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1846,7 +1846,7 @@ if ($action == 'create') { $currency_code = $conf->currency; $societe = ''; - if (GETPOST('socid') > 0) { + if (GETPOST('socid', 'int') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) { @@ -3285,10 +3285,9 @@ if ($action == 'create') { // Remainder to pay print ''; print ''; - if ($resteapayeraffiche >= 0) { - print $langs->trans('RemainderToPay'); - } else { - print $langs->trans('ExcessPaid'); + print $langs->trans('RemainderToPay'); + if ($resteapayeraffiche < 0) { + print ' ('.$langs->trans('NegativeIfExcessPaid').')'; } print ''; print ''; @@ -3298,10 +3297,9 @@ if ($action == 'create') { if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print ''; print ''; - if ($resteapayeraffiche <= 0) { - print $langs->trans('RemainderToPayBackMulticurrency'); - } else { - print $langs->trans('ExcessPaidMulticurrency'); + print $langs->trans('RemainderToPayMulticurrency'); + if ($resteapayeraffiche < 0) { + print ' ('.$langs->trans('NegativeIfExcessPaid').')'; } print ''; print ''; @@ -3322,10 +3320,9 @@ if ($action == 'create') { // Remainder to pay back print ''; print ''; - if ($resteapayeraffiche <= 0) { - print $langs->trans('RemainderToPayBack'); - } else { - print $langs->trans('ExcessPaid'); + print $langs->trans('RemainderToPayBack'); + if ($resteapayeraffiche > 0) { + print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; } print ''; print ''; @@ -3335,10 +3332,9 @@ if ($action == 'create') { if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print ''; print ''; - if ($resteapayeraffiche <= 0) { - print $langs->trans('RemainderToPayBackMulticurrency'); - } else { - print $langs->trans('ExcessPaidMulticurrency'); + print $langs->trans('RemainderToPayBackMulticurrency'); + if ($resteapayeraffiche> 0) { + print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; } print ''; print ''; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 070f3a2c5da..2e7f42a2727 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -562,3 +562,6 @@ DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; -- DROP TABLE tmp_bank; -- CREATE TABLE tmp_bank SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment' INNER JOIN llx_paiement as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; -- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; +-- DROP TABLE tmp_bank2; +-- CREATE TABLE tmp_bank2 SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment_supplier' INNER JOIN llx_paiementfourn as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; +-- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank2 as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 9d145ef354d..75cee952bcd 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -137,6 +137,7 @@ SEPAFRST=SEPA FRST ExecutionDate=Execution date CreateForSepa=Create direct debit file ICS=Creditor Identifier - ICS +IDS=Debitor Identifier END_TO_END="EndToEndId" SEPA XML tag - Unique id assigned per transaction USTRD="Unstructured" SEPA XML tag ADDDAYS=Add days to Execution Date @@ -154,4 +155,5 @@ ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default ErrorICSmissing=Missing ICS in Bank account %s TotalAmountOfdirectDebitOrderDiffersFromSumOfLines=Total amount of direct debit order differs from sum of lines WarningSomeDirectDebitOrdersAlreadyExists=Warning: There is already some pending Direct Debit orders (%s) requested for an amount of %s -WarningSomeCreditTransferAlreadyExists=Warning: There is already some pending Credit Transfer (%s) requested for an amount of %s \ No newline at end of file +WarningSomeCreditTransferAlreadyExists=Warning: There is already some pending Credit Transfer (%s) requested for an amount of %s +UsedFor=Used for %s \ No newline at end of file From ad7fcd264b15b467c75719add855bbd51934fc32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Apr 2022 23:39:09 +0200 Subject: [PATCH 522/752] FIX Tabulation must be allowed for HTML content --- htdocs/main.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9d96eb63a27..1d09b9f9887 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -108,10 +108,11 @@ function testSqlAndScriptInject($val, $type) // We check string because some hacks try to obfuscate evil strings by inserting non printable chars. Example: 'java(ascci09)scr(ascii00)ipt' is processed like 'javascript' (whatever is place of evil ascii char) // We should use dol_string_nounprintableascii but function is not yet loaded/available // Example of valid UTF8 chars: - // utf8=utf8mb3: '\x0A', '\x0D', '\x7E' + // utf8=utf8mb3: '\x09', '\x0A', '\x0D', '\x7E' // utf8=utf8mb3: '\xE0\xA0\x80' // utf8mb4: '\xF0\x9D\x84\x9E' (but this may be refused by the database insert if pagecode is utf8=utf8mb3) - $newval = preg_replace('/[\x00-\x09\x0B-\x0C\x0E-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace + $newval = preg_replace('/[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace + // Note that $newval may also be completely empty '' when non valid UTF8 are found. if ($newval != $val) { // If $val has changed after removing non valid UTF8 chars, it means we have an evil string. From 0faec59f56c5c72e54146fe3c773610be16717fe Mon Sep 17 00:00:00 2001 From: melina Date: Wed, 20 Apr 2022 08:13:01 +0200 Subject: [PATCH 523/752] FIX conflict and integrate Lionel fix --- htdocs/takepos/ajax/ajax.php | 133 ++++++++++++++++++++++++++++++++--- 1 file changed, 125 insertions(+), 8 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index ab4c9af2904..3ec334bd703 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -53,6 +53,8 @@ if (empty($user->rights->takepos->run)) { accessforbidden(); } +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('takeposproductsearch')); /* * View @@ -70,9 +72,10 @@ if ($action == 'getProducts') { $res = array(); if (is_array($prods) && count($prods) > 0) { foreach ($prods as $prod) { - if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { + // remove products without stock $prod->load_stock('nobatch,novirtual'); - if ($prod->stock_warehouse[$conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal']}]->real <= 0) { + if ($prod->stock_warehouse[getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])]->real <= 0) { continue; } } @@ -117,25 +120,138 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price '; - if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + $barcode_rules = getDolGlobalString('TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT'); + if (!empty($conf->barcode->enabled) && !empty($barcode_rules)) { + $barcode_rules_list = array(); + + // get barcode rules + $barcode_char_nb = 0; + $barcode_rules_arr = explode('+', $barcode_rules); + foreach ($barcode_rules_arr as $barcode_rules_values) { + $barcode_rules_values_arr = explode(':', $barcode_rules_values); + if (count($barcode_rules_values_arr) == 2) { + $char_nb = intval($barcode_rules_values_arr[1]); + $barcode_rules_list[] = array('code' => $barcode_rules_values_arr[0], 'char_nb' => $char_nb); + $barcode_char_nb += $char_nb; + } + } + + $barcode_value_list = array(); + $barcode_offset = 0; + $barcode_length = dol_strlen($term); + if ($barcode_length == $barcode_char_nb) { + $rows = array(); + + // split term with barcode rules + foreach ($barcode_rules_list as $barcode_rule_arr) { + $code = $barcode_rule_arr['code']; + $char_nb = $barcode_rule_arr['char_nb']; + $barcode_value_list[$code] = substr($term, $barcode_offset, $char_nb); + $barcode_offset += $char_nb; + } + + if (isset($barcode_value_list['ref'])) { + // search product from reference + $sql = "SELECT rowid, ref, label, tosell, tobuy, barcode, price"; + $sql .= " FROM " . $db->prefix() . "product as p"; + $sql .= " WHERE entity IN (" . getEntity('product') . ")"; + $sql .= " AND ref = '" . $db->escape($barcode_value_list['ref']) . "'"; + if ($filteroncategids) { + $sql .= " AND EXISTS (SELECT cp.fk_product FROM " . $db->prefix() . "categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN (".$db->sanitize($filteroncategids)."))"; + } + $sql .= " AND tosell = 1"; + $sql .= " AND (barcode IS NULL OR barcode != '" . $db->escape($term) . "')"; + + $resql = $db->query($sql); + if ($resql && $db->num_rows($resql) == 1) { + if ($obj = $db->fetch_object($resql)) { + $qty = 1; + if (isset($barcode_value_list['qu'])) { + $qty_str = $barcode_value_list['qu']; + if (isset($barcode_value_list['qd'])) { + $qty_str .= '.' . $barcode_value_list['qd']; + } + $qty = floatval($qty_str); + } + + $ig = '../public/theme/common/nophoto.png'; + if (empty($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES)) { + $objProd = new Product($db); + $objProd->fetch($obj->rowid); + $image = $objProd->show_photos('product', $conf->product->multidir_output[$objProd->entity], 'small', 1); + + $match = array(); + preg_match('@src="([^"]+)"@', $image, $match); + $file = array_pop($match); + + if ($file != '') { + if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { + $ig = $file.'&cache=1'; + } else { + $ig = $file.'&cache=1&publictakepos=1&modulepart=product'; + } + } + } + + $rows[] = array( + 'rowid' => $obj->rowid, + 'ref' => $obj->ref, + 'label' => $obj->label, + 'tosell' => $obj->tosell, + 'tobuy' => $obj->tobuy, + 'barcode' => $obj->barcode, + 'price' => $obj->price, + 'object' => 'product', + 'img' => $ig, + 'qty' => $qty, + ); + } + $db->free($resql); + } + } + + if (count($rows) == 1) { + echo json_encode($rows); + exit(); + } + } + } + + $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price' ; + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { $sql .= ', ps.reel'; } + // Add fields from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; - if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; $sql .= ' ON (p.rowid = ps.fk_product'; $sql .= " AND ps.fk_entrepot = ".((int) getDolGlobalInt("CASHDESK_ID_WAREHOUSE".$_SESSION['takeposterminal'])); } + + // Add tables from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))'; } - $sql .= ' AND p.tosell = 1'; - if ($conf->global->TAKEPOS_PRODUCT_IN_STOCK == 1) { + $sql .= ' AND tosell = 1'; + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { $sql .= ' AND ps.reel > 0'; } - $sql .= natural_search(array('p.ref', 'p.label', 'p.barcode'), $term); + $sql .= natural_search(array('ref', 'label', 'barcode'), $term); + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $resql = $db->query($sql); if ($resql) { $rows = array(); @@ -168,6 +284,7 @@ if ($action == 'getProducts') { 'price' => $obj->price, 'object' => 'product', 'img' => $ig, + 'qty' => 1, //'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) ); } From 6788cd179c82725397922347c40f9347e0a1e931 Mon Sep 17 00:00:00 2001 From: melina Date: Wed, 20 Apr 2022 12:01:17 +0200 Subject: [PATCH 524/752] Add hooks completeAjaxReturnArray --- htdocs/takepos/ajax/ajax.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index a3bcc04b5c8..5f30b8599b3 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -267,6 +267,11 @@ if ($action == 'getProducts') { 'qty' => 1, //'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) ); + // Add entries to row from hooks + $parameters=array(); + $parameters['row'] = end($rows); + $parameters['obj'] = $obj; + $reshook=$hookmanager->executeHooks('completeAjaxReturnArray', $parameters); } echo json_encode($rows); } else { From c23ed7c47b016d386f8df3c456371d4baebaa2a7 Mon Sep 17 00:00:00 2001 From: melina Date: Wed, 20 Apr 2022 14:47:36 +0200 Subject: [PATCH 525/752] Add hooks completeJSProductDisplay --- htdocs/takepos/index.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index b23907b64f1..d64c497d05f 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -360,7 +360,13 @@ function LoadProducts(position, issubcat) { $("#prodiv"+ishow).data("iscat", 0); $("#prodiv"+ishow).attr("class","wrapper2"); $("#prowatermark"+ishow).hide(); - ishow++; //Next product to show after print data product + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> } //console.log("Hide the prowatermark for ishow="+ishow); idata++; //Next data everytime @@ -615,6 +621,13 @@ function Search2(keyCodeForEnter) { } $("#prodiv" + i).data("rowid", data[i]['rowid']); $("#prodiv" + i).data("iscat", 0); + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> } }).always(function (data) { // If there is only 1 answer From db3edba5784180e1472557d27930e798e4f80412 Mon Sep 17 00:00:00 2001 From: melina Date: Wed, 20 Apr 2022 14:51:55 +0200 Subject: [PATCH 526/752] Delete comments --- htdocs/takepos/ajax/ajax.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 5f30b8599b3..9afde9ba341 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -211,14 +211,14 @@ if ($action == 'getProducts') { $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price' ; // Add fields from hooks $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; // Add tables from hooks $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); $sql .= $hookmanager->resPrint; $sql .= ' WHERE entity IN ('.getEntity('product').')'; @@ -229,7 +229,7 @@ if ($action == 'getProducts') { $sql .= natural_search(array('ref', 'label', 'barcode'), $term); // Add where from hooks $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); $sql .= $hookmanager->resPrint; $resql = $db->query($sql); From 6e8ba543ded0790237a09a85ca5fcdf16c2c0156 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 20 Apr 2022 13:33:22 +0000 Subject: [PATCH 527/752] Fixing style errors. --- htdocs/takepos/ajax/ajax.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 9afde9ba341..f794ac0584a 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -218,7 +218,7 @@ if ($action == 'getProducts') { // Add tables from hooks $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); + $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); $sql .= $hookmanager->resPrint; $sql .= ' WHERE entity IN ('.getEntity('product').')'; @@ -229,7 +229,7 @@ if ($action == 'getProducts') { $sql .= natural_search(array('ref', 'label', 'barcode'), $term); // Add where from hooks $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); + $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); $sql .= $hookmanager->resPrint; $resql = $db->query($sql); From d9521d40e4b3dd26dcb866f8fc76dc4d679cf5ff Mon Sep 17 00:00:00 2001 From: fred1201 Date: Thu, 21 Apr 2022 07:39:51 +0200 Subject: [PATCH 528/752] Update index.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace call function text( ) by html() to fix display in take post when spécial caracter are store in database: éèà become éàè --- htdocs/takepos/index.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index b23907b64f1..c0045fc67d8 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -232,7 +232,7 @@ function PrintCategories(first) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); + $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label']); $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).attr('class', 'wrapper'); @@ -266,7 +266,7 @@ function MoreCategories(moreorless) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).text(categories[i+( * pagecategories)]['label']); + $("#catdesc"+i).html(categories[i+( * pagecategories)]['label']); $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+( * pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+( * pagecategories)]['rowid']); $("#catwatermark"+i).show(); @@ -295,8 +295,8 @@ function LoadProducts(position, issubcat) { jQuery.each(subcategories, function(i, val) { if (currentcat==val.fk_parent) { $("#prodivdesc"+ishow).show(); - $("#prodesc"+ishow).text(val.label); - $("#probutton"+ishow).text(val.label); + $("#prodesc"+ishow).html(val.label); + $("#probutton"+ishow).html(val.label); $("#probutton"+ishow).show(); $("#proprice"+ishow).attr("class", "hidden"); $("#proprice"+ishow).html(""); @@ -343,13 +343,13 @@ function LoadProducts(position, issubcat) { if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);'; } else { - echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; + echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);'; } echo '$("#proimg"+ishow).attr("title", titlestring);'; echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; } else { echo '$("#probutton"+ishow).show();'; - echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);'; + echo '$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);'; } ?> if (data[parseInt(idata)]['price_formated']) { @@ -414,9 +414,9 @@ function MoreProducts(moreorless) { if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?> $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']); - $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + $("#prodesc"+ishow).html(data[parseInt(idata)]['label']); - $("#probutton"+ishow).text(data[parseInt(idata)]['label']); + $("#probutton"+ishow).html(data[parseInt(idata)]['label']); $("#probutton"+ishow).show(); if (data[parseInt(idata)]['price_formated']) { $("#proprice"+ishow).attr("class", "productprice"); @@ -597,10 +597,10 @@ function Search2(keyCodeForEnter) { if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?> $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); - $("#prodesc" + i).text(data[i]['label']); + $("#prodesc" + i).html(data[i]['label']); $("#prodivdesc" + i).show(); - $("#probutton" + i).text(data[i]['label']); + $("#probutton" + i).html(data[i]['label']); $("#probutton" + i).show(); if (data[i]['price_formated']) { $("#proprice" + i).attr("class", "productprice"); From 731d85130c702fc9414490a1784e65d9eda3ba7e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Apr 2022 09:49:00 +0200 Subject: [PATCH 529/752] FIX missing hook parameter --- htdocs/core/class/html.form.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d656fbde897..6a7bd9a688f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8404,7 +8404,7 @@ class Form public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) { global $conf, $langs, $hookmanager; - global $bc, $action; + global $action; $linktoelem = ''; $linktoelemlist = ''; @@ -8450,11 +8450,10 @@ class Form ); } - // Can complete the possiblelink array - $hookmanager->initHooks(array('commonobject')); - $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan); - if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the object we can link to + // Can complete the possiblelink array + $hookmanager->initHooks(array('commonobject')); + $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan, 'possiblelinks' => $possiblelinks); $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } From 8878eb6d76445653bac28817006877d5d163f237 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Apr 2022 14:52:06 +0200 Subject: [PATCH 530/752] FIX compatibility with multicompany sharings --- htdocs/core/modules/project/mod_project_simple.php | 6 +++--- htdocs/core/modules/project/mod_project_universal.php | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index b1dbe4bae48..921b68f492b 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -125,14 +125,14 @@ class mod_project_simple extends ModeleNumRefProjects */ public function getNextValue($objsoc, $project) { - global $db, $conf; + global $db; // First, we get the max value $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."projet"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity IN (".getEntity('projectnumber', 1, $project).")"; $resql = $db->query($sql); if ($resql) { @@ -147,7 +147,7 @@ class mod_project_simple extends ModeleNumRefProjects return -1; } - $date = empty($project->date_c) ?dol_now() : $project->date_c; + $date = (empty($project->date_c) ? dol_now() : $project->date_c); //$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m", $date); diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 550d72c4f68..47fd83842ed 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -136,8 +136,11 @@ class mod_project_universal extends ModeleNumRefProjects return 0; } - $date = empty($project->date_c) ?dol_now() : $project->date_c; - $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); + // Get entities + $entity = getEntity('projectnumber', 1, $project); + + $date = (empty($project->date_c) ? dol_now() : $project->date_c); + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc : ''), $date, 'next', false, null, $entity); return $numFinal; } From 2a5c54d4e4deb51439531e8561e5b151e84789e0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Apr 2022 16:02:41 +0200 Subject: [PATCH 531/752] FIX compatibility for ticket number sharing --- htdocs/core/modules/ticket/mod_ticket_simple.php | 2 +- htdocs/core/modules/ticket/mod_ticket_universal.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 523da47191d..76d8e4f8d79 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -129,7 +129,7 @@ class mod_ticket_simple extends ModeleNumRefTicket $sql .= " FROM ".MAIN_DB_PREFIX."ticket"; $search = $this->prefix."____-%"; $sql .= " WHERE ref LIKE '".$db->escape($search)."'"; - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity IN (".getEntity('ticketnumber', 1, $ticket).")"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index 176af782dc7..2c46376eea1 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -134,8 +134,11 @@ class mod_ticket_universal extends ModeleNumRefTicket return 0; } + // Get entities + $entity = getEntity('ticketnumber', 1, $ticket); + $date = empty($ticket->datec) ? dol_now() : $ticket->datec; - $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date); + $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date, 'next', false, null, $entity); return $numFinal; } From 2992b3e84580c400b9afb401a1c9bb3f4f9253de Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 22 Apr 2022 09:24:23 +0200 Subject: [PATCH 532/752] NEW send last document in mass mailing action --- htdocs/core/actions_massactions.inc.php | 46 ++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5ec011f5017..171383d7008 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -306,29 +306,51 @@ if (!$error && $massaction == 'confirm_presend') { // TODO Set subdir to be compatible with multi levels dir trees // $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element) $filedir = $uploaddir.'/'.$subdir.dol_sanitizeFileName($objectobj->ref); - $file = $filedir.'/'.$filename; + $filepath = $filedir.'/'.$filename; // For supplier invoices, we use the file provided by supplier, not the one we generate if ($objectobj->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($uploaddir.'/'.get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); - $file = $fileparams['fullname']; + $filepath = $fileparams['fullname']; } - $mime = dol_mimetype($file); + // try to find other files generated for this object (last_main_doc) + $filename_found = ''; + $filepath_found = ''; + $file_check_list = array(); + $file_check_list[] = array( + 'name' => $filename, + 'path' => $filepath, + ); + if (!empty($objectobj->last_main_doc)) { + $file_check_list[] = array( + 'name' => basename($objectobj->last_main_doc), + 'path' => DOL_DATA_ROOT . '/' . $objectobj->last_main_doc, + ); + } + foreach ($file_check_list as $file_check_arr) { + if (dol_is_file($file_check_arr['path'])) { + $filename_found = $file_check_arr['name']; + $filepath_found = $file_check_arr['path']; + break; + } + } - if (dol_is_file($file)) { + if ($filepath_found) { // Create form object $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array( - 'paths'=>array($file), - 'names'=>array($filename), - 'mimes'=>array($mime) + 'paths'=>array($filepath_found), + 'names'=>array($filename_found), + 'mimes'=>array(dol_mimetype($filepath_found)) ); } else { - $nbignored++; - $langs->load("errors"); - $resaction .= '
'.$langs->trans('ErrorCantReadFile', $file).'

'; - dol_syslog('Failed to read file: '.$file, LOG_WARNING); - continue; + $nbignored++; + $langs->load("errors"); + foreach ($file_check_list as $file_check_arr) { + $resaction .= '
'.$langs->trans('ErrorCantReadFile', $file_check_arr['path']).'

'; + dol_syslog('Failed to read file: '.$file_check_arr['path'], LOG_WARNING); + } + continue; } } From ca0f98d09f65f7aa107ca30bab815388d2ebb410 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 22 Apr 2022 13:50:39 +0200 Subject: [PATCH 533/752] FIX : label tax cat trad --- htdocs/expensereport/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 50ee78b4097..31cf21c34ae 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2068,7 +2068,8 @@ if ($action == 'create') { // IK if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; - print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); + $exp_tax_cat_label = dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); + print $langs->trans($exp_tax_cat_label); print ''; } From 609ef9bfa79c47cc91b322b1276c956eccaa8400 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 22 Apr 2022 14:26:16 +0200 Subject: [PATCH 534/752] FIX : var name --- htdocs/expensereport/payment/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index 8308ea3fc4c..fa8ba9bcdcf 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -523,7 +523,7 @@ while ($i < min($num, $limit)) { // Cheque number (fund transfer) if (!empty($arrayfields['pndf.num_payment']['checked'])) { - print ''.$objp->num_paiement.''; + print ''.$objp->num_payment.''; if (!$i) { $totalarray['nbfield']++; } From 6f9f78af33db723907284b7d3f814518a971165d Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 22 Apr 2022 14:28:43 +0200 Subject: [PATCH 535/752] FIX : var name --- htdocs/expensereport/payment/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index fa8ba9bcdcf..f5196181cf2 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -515,7 +515,7 @@ while ($i < min($num, $limit)) { // Pyament type if (!empty($arrayfields['c.libelle']['checked'])) { $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; - print ''.$payment_type.' '.dol_trunc($objp->num_paiement, 32).''; + print ''.$payment_type.' '.dol_trunc($objp->num_payment, 32).''; if (!$i) { $totalarray['nbfield']++; } From d2ec1efb42acd6454628a1ef9ddc8d9f8cc28d2e Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 22 Apr 2022 14:49:22 +0200 Subject: [PATCH 536/752] fix #20690: add lang filter for people --- htdocs/core/modules/mailings/contacts1.modules.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index bd4300ea71d..1450fe75b8c 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -311,6 +311,13 @@ class mailing_contacts1 extends MailingTargets else dol_print_error($this->db); $s .= ''; + + //Choose language + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($this->db); + $s .= $langs->trans("DefaultLang").': '; + $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + return $s; } @@ -344,6 +351,7 @@ class mailing_contacts1 extends MailingTargets $filter_category = GETPOST('filter_category', 'alpha'); $filter_category_customer = GETPOST('filter_category_customer', 'alpha'); $filter_category_supplier = GETPOST('filter_category_supplier', 'alpha'); + $filter_lang = GETPOST('filter_lang', 'alpha'); $cibles = array(); @@ -391,6 +399,7 @@ class mailing_contacts1 extends MailingTargets if ($filter_category_customer <> 'all') $sql .= " AND c2.label = '".$this->db->escape($filter_category_customer)."'"; if ($filter_category_supplier <> 'all') $sql .= " AND c3s.fk_categorie = c3.rowid AND c3s.fk_soc = sp.fk_soc"; if ($filter_category_supplier <> 'all') $sql .= " AND c3.label = '".$this->db->escape($filter_category_supplier)."'"; + if ($filter_lang <> '') $sql .= " AND sp.default_lang = '".$this->db->escape($filter_lang)."'"; // Filter on nature $key = $filter; { @@ -404,7 +413,7 @@ class mailing_contacts1 extends MailingTargets $key = $filter_jobposition; if (!empty($key) && $key != 'all') $sql .= " AND sp.poste ='".$this->db->escape($key)."'"; $sql .= " ORDER BY sp.email"; - //print "wwwwwwx".$sql; + // print "wwwwwwx".$sql; // Stocke destinataires dans cibles $result = $this->db->query($sql); From 72ac1fdfd2e4eb69a7b53c5a8a2060e687e9f871 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 22 Apr 2022 15:05:38 +0200 Subject: [PATCH 537/752] fix #20690: add lang filter for companies --- .../modules/mailings/thirdparties.modules.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 05e9f4f12c4..9dc9e716cf3 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -79,6 +79,11 @@ class mailing_thirdparties extends MailingTargets $sql .= " WHERE s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; + + if (GETPOST('default_lang','alpha')) + { + $sql .= " AND s.default_lang LIKE '".GETPOST('default_lang','alpha')."%'"; + } } else { @@ -126,6 +131,13 @@ class mailing_thirdparties extends MailingTargets $addDescription .= $langs->trans("Disabled"); } } + if (GETPOST('default_lang','alpha')) + { + $addFilter .= " AND s.default_lang LIKE '".GETPOST('default_lang','alpha')."%'"; + $addDescription = $langs->trans('DefaultLang')."="; + } + + $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c"; $sql .= " WHERE s.email <> ''"; @@ -147,7 +159,6 @@ class mailing_thirdparties extends MailingTargets $sql .= $addFilter; } $sql .= " ORDER BY email"; - // Stock recipients emails into targets table $result = $this->db->query($sql); if ($result) @@ -314,6 +325,14 @@ class mailing_thirdparties extends MailingTargets $s .= ''; $s .= ''; $s .= ''; + + + //Choose language + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($this->db); + $s .= $langs->trans("DefaultLang").': '; + $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + return $s; } From 9fd3a4b2c9c99c56f46b8e9559372f142c33ad09 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 22 Apr 2022 13:30:43 +0000 Subject: [PATCH 538/752] Fixing style errors. --- htdocs/core/modules/mailings/thirdparties.modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 9dc9e716cf3..07b08e60d60 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -80,9 +80,9 @@ class mailing_thirdparties extends MailingTargets $sql .= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; - if (GETPOST('default_lang','alpha')) + if (GETPOST('default_lang', 'alpha')) { - $sql .= " AND s.default_lang LIKE '".GETPOST('default_lang','alpha')."%'"; + $sql .= " AND s.default_lang LIKE '".GETPOST('default_lang', 'alpha')."%'"; } } else @@ -131,9 +131,9 @@ class mailing_thirdparties extends MailingTargets $addDescription .= $langs->trans("Disabled"); } } - if (GETPOST('default_lang','alpha')) + if (GETPOST('default_lang', 'alpha')) { - $addFilter .= " AND s.default_lang LIKE '".GETPOST('default_lang','alpha')."%'"; + $addFilter .= " AND s.default_lang LIKE '".GETPOST('default_lang', 'alpha')."%'"; $addDescription = $langs->trans('DefaultLang')."="; } From 5eb74772d619d895250f690506ce77dc7cece1d6 Mon Sep 17 00:00:00 2001 From: Nicolas SILOBRE <45969285+ns-info90@users.noreply.github.com> Date: Sat, 23 Apr 2022 03:41:17 +0200 Subject: [PATCH 539/752] Update pdf_rouget.modules.php Correction of units in the total weight --- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 211231b9812..94e048382dc 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -212,7 +212,7 @@ class pdf_rouget extends ModelePdfExpedition } // Load traductions files required by page - $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); + $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "other")); $nblines = count($object->lines); From 16c607f4d8c0d826c4a7436599f028428e890393 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Apr 2022 18:39:26 +0200 Subject: [PATCH 540/752] Fix responsive --- htdocs/compta/localtax/card.php | 22 ++++++++++++++-------- htdocs/compta/localtax/list.php | 5 ++++- htdocs/compta/paiement_vat.php | 19 +++++++++++-------- htdocs/compta/tva/card.php | 11 ++++++----- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 35c6aa399fe..45cb1f03bb8 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; $langs->loadLangs(array('compta', 'banks', 'bills')); $id = GETPOST("id", 'int'); -$action = GETPOST("action", "alpha"); -$cancel = GETPOST('cancel'); +$action = GETPOST("action", "aZ09"); +$cancel = GETPOST('cancel', 'aZ09'); $refund = GETPOST("refund", "int"); if (empty($refund)) { @@ -143,7 +143,7 @@ $form = new Form($db); $title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card"); $help_url = ''; -llxHeader("", $title, $helpurl); +llxHeader('', $title, $helpurl); if ($action == 'create') { print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); @@ -157,11 +157,13 @@ if ($action == 'create') { print ''; + // Date of payment print ""; print ''; + // End date of period print ''; @@ -173,20 +175,24 @@ if ($action == 'create') { print ''; if (!empty($conf->banque->enabled)) { - print ''; - + // Type payment print '\n"; print ""; + + // Bank account + print ''; // Number print ''."\n"; } + // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 6590e250832..6f6fc303262 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -63,6 +63,7 @@ if ($result) { $i = 0; $total = 0; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.$langs->trans("DatePayment").''; print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1); print '
'.$langs->trans("Amount").'
'.$langs->trans("Account").''; - $form->select_comptes(GETPOST("accountid", "int"), "accountid", 0, "courant=1", 2); // Affiche liste des comptes courant - print '
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype"); + $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype", '', 0, 1, 0, 0, 1,'maxwidth500 widthcentpercentminusx'); print "
'.$langs->trans("Account").''; + print img_picto('', 'bank_account', 'pictofixedwidth'); + $form->select_comptes(GETPOST("accountid", "int"), "accountid", 0, "courant=1", 2, '', 0, 'maxwidth500 widthcentpercentminusx'); // Affiche liste des comptes courant + print '
'.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print '
'; print ''; print ''; @@ -85,7 +86,7 @@ if ($result) { print '\n"; $total = $total + $obj->amount; - print ""; + print ''; print "\n"; $i++; @@ -94,6 +95,8 @@ if ($result) { print ''; print "
'.$langs->trans("Ref").''.dol_print_date($db->jdate($obj->datep), 'day')."".price($obj->amount)."'.price($obj->amount).'
'.price($total).'
"; + print '
'; + $db->free($result); } else { dol_print_error($db); diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index ce224735927..2f7b775096d 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -207,14 +207,15 @@ if ($action == 'create') { print ''; print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype", "int") : $tva->paiementtype, "paiementtype"); + $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype", "int") : $tva->paiementtype, "paiementtype", '', 0, 1, 0, 0, 1,'maxwidth500 widthcentpercentminusx'); print "\n"; print ''; print ''; print ''.$langs->trans('AccountToDebit').''; print ''; - $form->select_comptes(GETPOST("accountid") ? GETPOST("accountid", "int") : $tva->accountid, "accountid", 0, '', 1); // Show opend bank account list + print img_picto('', 'bank_account', 'pictofixedwidth'); + $form->select_comptes(GETPOST("accountid", "int") ? GETPOST("accountid", "int") : $tva->accountid, "accountid", 0, '', 1, '', 0, 'maxwidth500 widthcentpercentminusx'); // Show opend bank account list print ''; // Number @@ -225,7 +226,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans("Comments").''; - print ''; + print ''; print ''; print ''; @@ -238,6 +239,7 @@ if ($action == 'create') { $num = 1; $i = 0; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; //print ''; @@ -259,14 +261,14 @@ if ($action == 'create') { if ($objp->datev > 0) { print ''."\n"; } else { - print "\n"; + print ''."\n"; } - print '"; + print '"; - print '"; + print '"; - print '"; + print '"; print '
'.$langs->trans("SocialContribution").''.dol_print_date($objp->datev, 'day').'!!!!!!'.price($objp->amount)."'.price($objp->amount)."'.price($sumpaid)."'.price($sumpaid)."'.price($objp->amount - $sumpaid)."'.price($objp->amount - $sumpaid)."'; @@ -279,7 +281,7 @@ if ($action == 'create') { } */ $remaintopay = $objp->amount - $sumpaid; print ''; - print ''; + print ''; } else { print '-'; } @@ -303,6 +305,7 @@ if ($action == 'create') { } print "
"; + print '
'; // Bouton Save payment print '
'.$langs->trans("ClosePaidVATAutomatically"); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 317838009c7..3ffb405f8ad 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -460,7 +460,7 @@ if ($action == 'create') { print '
'; print ''; - //print "
\n"; + print "\n"; // Label if ($refund == 1) { @@ -468,7 +468,7 @@ if ($action == 'create') { } else { $label = $langs->trans("VATPayment"); } - print ''.$langs->trans("Label").''; + print ''.$langs->trans("Label").''; print ''.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); @@ -490,14 +490,15 @@ if ($action == 'create') { // Type payment print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); + $form->select_types_paiements(GETPOST("type_payment", 'int'), "type_payment", '', 0, 1, 0, 0, 1,'maxwidth500 widthcentpercentminusx'); print "\n"; print ""; if (!empty($conf->banque->enabled)) { + // Bank account print ''.$langs->trans("BankAccount").''; print img_picto('', 'bank_account', 'pictofixedwidth'); - $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 1); // List of bank account available + $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusx'); // List of bank account available print ''; } @@ -509,7 +510,7 @@ if ($action == 'create') { // Comments print ''; print ''.$langs->trans("Comments").''; - print ''; + print ''; print ''; // Other attributes From 97328f732e1ee3841b28c9d02a8745926f6393e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Apr 2022 23:02:53 +0200 Subject: [PATCH 541/752] Fix error managemnt when getting RSS. --- htdocs/core/class/rssparser.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index c3c434d1aed..2048a80bae6 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -227,11 +227,16 @@ class RssParser } else { try { $result = getURLContent($this->_urlRSS, 'GET', '', 1, array(), array('http', 'https'), 0); + if (!empty($result['content'])) { $str = $result['content']; + } elseif (!empty($result['curl_error_msg'])){ + $this->error = 'Error retrieving URL '.$this->_urlRSS.' - '.$result['curl_error_msg']; + return -1; } } catch (Exception $e) { - print 'Error retrieving URL '.$this->_urlRSS.' - '.$e->getMessage(); + $this->error = 'Error retrieving URL '.$this->_urlRSS.' - '.$e->getMessage(); + return -2; } } @@ -248,7 +253,8 @@ class RssParser } $xmlparser = xml_parser_create(''); - if (!is_resource($xmlparser)) { + + if (!is_resource($xmlparser) && !is_object($xmlparser)) { $this->error = "ErrorFailedToCreateParser"; return -1; } @@ -256,10 +262,11 @@ class RssParser xml_set_object($xmlparser, $this); xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); xml_set_character_data_handler($xmlparser, 'feed_cdata'); + $status = xml_parse($xmlparser, $str); xml_parser_free($xmlparser); $rss = $this; - //var_dump($rss->_format);exit; + //var_dump($status.' '.$rss->_format);exit; } } From 8bb9cc83ebbdddc10ab9e898be9462bb3a748f8a Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 25 Apr 2022 09:30:05 +0200 Subject: [PATCH 542/752] Fix migration warning. --- htdocs/core/extrafieldsinimport.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/extrafieldsinimport.inc.php b/htdocs/core/extrafieldsinimport.inc.php index 4845d9a6d44..395b67520d1 100644 --- a/htdocs/core/extrafieldsinimport.inc.php +++ b/htdocs/core/extrafieldsinimport.inc.php @@ -11,7 +11,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) { } // Add extra fields -$sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields"; +$sql = "SELECT name, label, type, param, fieldcomputed, fielddefault, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields"; $sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".((int) $conf->entity).') ORDER BY pos ASC'; //print $sql; $resql = $this->db->query($sql); From 8a2cc52b5c5ca3cd7d5aed43fe77eed4182ef27c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 25 Apr 2022 10:14:30 +0200 Subject: [PATCH 543/752] FIX wrong website data root with multicompany --- htdocs/admin/website.php | 6 +++--- htdocs/core/class/html.formwebsite.class.php | 2 +- htdocs/core/filemanagerdol/connectors/php/config.php | 2 +- htdocs/core/lib/website.lib.php | 4 ++-- htdocs/public/website/index.php | 4 ++-- htdocs/public/website/styles.css.php | 2 +- htdocs/website/class/website.class.php | 8 +++++--- htdocs/website/class/websitepage.class.php | 2 +- htdocs/website/index.php | 10 +++++----- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index d1a24ff072c..17858b9991c 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -113,7 +113,7 @@ $tabcond[1] = (!empty($conf->website->enabled)); // List of help for fields $tabhelp = array(); -$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref')); +$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/websiteref')); // List of check for fields (NOT USED YET) $tabfieldcheck = array(); @@ -271,8 +271,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($resql) { $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09')); if ($newname != $website->ref) { - $srcfile = DOL_DATA_ROOT.'/website/'.$website->ref; - $destfile = DOL_DATA_ROOT.'/website/'.$newname; + $srcfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website->ref; + $destfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$newname; if (dol_is_dir($destfile)) { $error++; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index a4db07f95c0..5d553887777 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -173,7 +173,7 @@ class FormWebsite $langs->load("admin"); - $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$'); + $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/samples', 'files', 0, '^page-sample-.*\.html$'); $arrayofsamples = array(); $arrayofsamples['empty'] = 'EmptyPage'; // Always this one first diff --git a/htdocs/core/filemanagerdol/connectors/php/config.php b/htdocs/core/filemanagerdol/connectors/php/config.php index 73c222841cc..c2d7478e36e 100644 --- a/htdocs/core/filemanagerdol/connectors/php/config.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.php @@ -50,7 +50,7 @@ $Config['Enabled'] = true; $extEntity = (empty($entity) ? 1 : $entity); // For multicompany with external access $Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=medias'.(empty($website) ? '' : '_'.$website).'&entity='.$extEntity.'&file='; -$Config['UserFilesAbsolutePathRelative'] = (empty($website) ? ((!empty($entity) ? '/'.$entity : '').'/medias/') : ('/website/'.$website)); +$Config['UserFilesAbsolutePathRelative'] = (!empty($entity) ? '/'.$entity : '').(empty($website) ? '/medias/' : ('/website/'.$website)); // Fill the following value it you prefer to specify the absolute path for the diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index ca907ae6f1c..eeb68458252 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -495,7 +495,7 @@ function includeContainer($containerref) $containerref .= '.php'; } - $fullpathfile = DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref; + $fullpathfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity.'/' : '').'/website/'.$websitekey.'/'.$containerref; if (empty($includehtmlcontentopened)) { $includehtmlcontentopened = 0; @@ -984,7 +984,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so if (!$error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) { global $dolibarr_main_data_root; - $pathofwebsite = $dolibarr_main_data_root.'/website/'.$website->ref; + $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity.'/' : '').'/website/'.$website->ref; $filehtmlheader = $pathofwebsite.'/htmlheader.html'; $filecss = $pathofwebsite.'/styles.css.php'; $filejs = $pathofwebsite.'/javascript.js.php'; diff --git a/htdocs/public/website/index.php b/htdocs/public/website/index.php index d72fedefa7e..4b0342693d8 100644 --- a/htdocs/public/website/index.php +++ b/htdocs/public/website/index.php @@ -169,9 +169,9 @@ if ($pageid == 'css') { // No more used ? //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); //else header('Cache-Control: no-cache'); - $original_file = $dolibarr_main_data_root.'/website/'.$websitekey.'/styles.css.php'; + $original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey.'/styles.css.php'; } else { - $original_file = $dolibarr_main_data_root.'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; + $original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; } // Find the subdirectory name as the reference diff --git a/htdocs/public/website/styles.css.php b/htdocs/public/website/styles.css.php index a0002b5380b..73cbed73dbd 100644 --- a/htdocs/public/website/styles.css.php +++ b/htdocs/public/website/styles.css.php @@ -122,7 +122,7 @@ if (empty($pageid)) // Security: Delete string ../ into $original_file global $dolibarr_main_data_root; -$original_file = $dolibarr_main_data_root.'/website/'.$website.'/styles.css.php'; +$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/styles.css.php'; // Find the subdirectory name as the reference $refname = basename(dirname($original_file)."/"); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 80a48048151..8dfaf284ea5 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -587,6 +587,8 @@ class Website extends CommonObject */ public function delete(User $user, $notrigger = false) { + global $conf; + dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; @@ -618,7 +620,7 @@ class Website extends CommonObject } if (!$error && !empty($this->ref)) { - $pathofwebsite = DOL_DATA_ROOT.'/website/'.$this->ref; + $pathofwebsite = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$this->ref; dol_delete_dir_recursive($pathofwebsite); } @@ -678,8 +680,8 @@ class Website extends CommonObject $oldidforhome = $object->fk_default_home; $oldref = $object->ref; - $pathofwebsiteold = $dolibarr_main_data_root.'/website/'.dol_sanitizeFileName($oldref); - $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.dol_sanitizeFileName($newref); + $pathofwebsiteold = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($oldref); + $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($newref); dol_delete_dir_recursive($pathofwebsitenew); $fileindex = $pathofwebsitenew.'/index.php'; diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 0126f8a4dc4..6b65df983ca 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -642,7 +642,7 @@ class WebsitePage extends CommonObject if ($result > 0) { global $dolibarr_main_data_root; - $pathofwebsite = $dolibarr_main_data_root.'/website/'.$websiteobj->ref; + $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websiteobj->ref; $filealias = $pathofwebsite.'/'.$this->pageurl.'.php'; $filetpl = $pathofwebsite.'/page'.$this->id.'.tpl.php'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8ac4d612264..346a6715647 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -226,7 +226,7 @@ if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createco global $dolibarr_main_data_root; -$pathofwebsite = $dolibarr_main_data_root.'/website/'.$websitekey; +$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey; $filehtmlheader = $pathofwebsite.'/htmlheader.html'; $filecss = $pathofwebsite.'/styles.css.php'; $filejs = $pathofwebsite.'/javascript.js.php'; @@ -1924,7 +1924,7 @@ if ($usercanedit && (($action == 'updatesource' || $action == 'updatecontent' || $tmpwebsite = new Website($db); if ($newwebsiteid > 0 && $newwebsiteid != $object->id) { $tmpwebsite->fetch($newwebsiteid); - $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.$tmpwebsite->ref; + $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$tmpwebsite->ref; } else { $tmpwebsite = $object; } @@ -2573,7 +2573,7 @@ if (!GETPOST('hide_websitemenu')) { if ($websitekey) { $virtualurl = ''; - $dataroot = DOL_DATA_ROOT.'/website/'.$websitekey; + $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey; if (!empty($object->virtualhost)) { $virtualurl = $object->virtualhost; } @@ -3342,7 +3342,7 @@ if ($action == 'editcss') { // VirtualHost print ''; - $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/{s1}'.$websitekey.'{s2}'); + $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/{s1}'.$websitekey.'{s2}'); $htmltext = str_replace(array('{s1}', '{s2}'), array('', ''), $htmltext); $htmltext .= '
'; $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); @@ -3528,7 +3528,7 @@ if ($action == 'createsite') { print ''; $htmltext = $langs->trans("SetHereVirtualHost", '{s1}'); - $htmltext = str_replace('{s1}', DOL_DATA_ROOT.'/website/websiteref', $htmltext); + $htmltext = str_replace('{s1}', DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/websiteref', $htmltext); $htmltext .= '
'; $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), '{s1}'); From 7e7ae863c7c9afa4512bcb4c760bee7351b4a021 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 25 Apr 2022 10:19:52 +0200 Subject: [PATCH 544/752] FIX syntax error --- htdocs/core/class/html.formwebsite.class.php | 2 +- htdocs/core/lib/website.lib.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 5d553887777..a4db07f95c0 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -173,7 +173,7 @@ class FormWebsite $langs->load("admin"); - $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/samples', 'files', 0, '^page-sample-.*\.html$'); + $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$'); $arrayofsamples = array(); $arrayofsamples['empty'] = 'EmptyPage'; // Always this one first diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index eeb68458252..87608d81118 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -495,7 +495,7 @@ function includeContainer($containerref) $containerref .= '.php'; } - $fullpathfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity.'/' : '').'/website/'.$websitekey.'/'.$containerref; + $fullpathfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey.'/'.$containerref; if (empty($includehtmlcontentopened)) { $includehtmlcontentopened = 0; @@ -984,7 +984,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so if (!$error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) { global $dolibarr_main_data_root; - $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity.'/' : '').'/website/'.$website->ref; + $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website->ref; $filehtmlheader = $pathofwebsite.'/htmlheader.html'; $filecss = $pathofwebsite.'/styles.css.php'; $filejs = $pathofwebsite.'/javascript.js.php'; From e6ce81bf8be6adbde09c4c8e67e8ecea453cd117 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 25 Apr 2022 11:20:00 +0200 Subject: [PATCH 545/752] Move confirm_createbills mass action to order list --- htdocs/commande/list.php | 342 +++++++++++++++++++++++ htdocs/core/actions_massactions.inc.php | 343 ------------------------ 2 files changed, 342 insertions(+), 343 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 52071b672fe..4859412f692 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -302,6 +302,348 @@ if (empty($reshook)) { $uploaddir = $conf->commande->multidir_output[$conf->entity]; $triggersendname = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if ($massaction == 'confirm_createbills') { // Create bills from orders. + $orders = GETPOST('toselect', 'array'); + $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); + $validate_invoices = GETPOST('validate_invoices', 'int'); + + $errors = array(); + + $TFact = array(); + $TFactThird = array(); + $TFactThirdNbLines = array(); + + $nb_bills_created = 0; + $lastid= 0; + $lastref = ''; + + $db->begin(); + + foreach ($orders as $id_order) { + $cmd = new Commande($db); + if ($cmd->fetch($id_order) <= 0) { + continue; + } + $cmd->fetch_thirdparty(); + + $objecttmp = new Facture($db); + if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { + // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it. + $objecttmp = $TFactThird[$cmd->socid]; + } else { + // If we want one invoice per order or if there is no first invoice yet for this thirdparty. + $objecttmp->socid = $cmd->socid; + $objecttmp->thirdparty = $cmd->thirdparty; + + $objecttmp->type = $objecttmp::TYPE_STANDARD; + $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id; + $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id; + + $objecttmp->fk_project = $cmd->fk_project; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; + if (empty($createbills_onebythird)) { + $objecttmp->ref_client = $cmd->ref_client; + } + + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + if (empty($datefacture)) { + $datefacture = dol_now(); + } + + $objecttmp->date = $datefacture; + $objecttmp->origin = 'commande'; + $objecttmp->origin_id = $id_order; + + $objecttmp->array_options = $cmd->array_options; // Copy extrafields + + $res = $objecttmp->create($user); + + if ($res > 0) { + $nb_bills_created++; + $lastref = $objecttmp->ref; + $lastid = $objecttmp->id; + + $TFactThird[$cmd->socid] = $objecttmp; + $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang + } else { + $langs->load("errors"); + $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error); + $error++; + } + } + + if ($objecttmp->id > 0) { + $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order); + + if ($res == 0) { + $errors[] = $objecttmp->error; + $error++; + } + + if (!$error) { + $lines = $cmd->lines; + if (empty($lines) && method_exists($cmd, 'fetch_lines')) { + $cmd->fetch_lines(); + $lines = $cmd->lines; + } + + $fk_parent_line = 0; + $num = count($lines); + + for ($i = 0; $i < $num; $i++) { + $desc = ($lines[$i]->desc ? $lines[$i]->desc : ''); + // If we build one invoice for several orders, we must put the ref of order on the invoice line + if (!empty($createbills_onebythird)) { + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); + } + + if ($lines[$i]->subprice < 0) { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc = $objecttmp->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); + if ($discountid > 0) { + $result = $objecttmp->insert_discount($discountid); + //$result=$discount->link_to_invoice($lineid,$id); + } else { + setEventMessages($discount->error, $discount->errors, 'errors'); + $error++; + break; + } + } else { + // Positive line + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); + // Date start + $date_start = false; + if ($lines[$i]->date_debut_prevue) { + $date_start = $lines[$i]->date_debut_prevue; + } + if ($lines[$i]->date_debut_reel) { + $date_start = $lines[$i]->date_debut_reel; + } + if ($lines[$i]->date_start) { + $date_start = $lines[$i]->date_start; + } + //Date end + $date_end = false; + if ($lines[$i]->date_fin_prevue) { + $date_end = $lines[$i]->date_fin_prevue; + } + if ($lines[$i]->date_fin_reel) { + $date_end = $lines[$i]->date_fin_reel; + } + if ($lines[$i]->date_end) { + $date_end = $lines[$i]->date_end; + } + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals(); + $array_options = $lines[$i]->array_options; + } + + $objecttmp->context['createfromclone']; + + $rang = $lines[$i]->rang; + //there may already be rows from previous orders + if (!empty($createbills_onebythird)) + $rang = $TFactThirdNbLines[$cmd->socid]; + + $result = $objecttmp->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $product_type, + $rang, + $lines[$i]->special_code, + $objecttmp->origin, + $lines[$i]->rowid, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, + $lines[$i]->label, + $array_options, + 100, + 0, + $lines[$i]->fk_unit + ); + if ($result > 0) { + $lineid = $result; + if (!empty($createbills_onebythird)) //increment rang to keep order + $TFactThirdNbLines[$rcp->socid]++; + } else { + $lineid = 0; + $error++; + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + } + } + } + + //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. + + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { + $TFactThird[$cmd->socid] = $objecttmp; + } else { + $TFact[$objecttmp->id] = $objecttmp; + } + } + + // Build doc with all invoices + $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; + $toselect = array(); + + if (!$error && $validate_invoices) { + $massaction = $action = 'builddoc'; + + foreach ($TAllFact as &$objecttmp) { + $result = $objecttmp->validate($user); + if ($result <= 0) { + $error++; + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + break; + } + + $id = $objecttmp->id; // For builddoc action + + // Builddoc + $donotredirect = 1; + $upload_dir = $conf->facture->dir_output; + $permissiontoadd = $user->rights->facture->creer; + + // Call action to build doc + $savobject = $object; + $object = $objecttmp; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + $object = $savobject; + } + + $massaction = $action = 'confirm_createbills'; + } + + if (!$error) { + $db->commit(); + + if ($nb_bills_created == 1) { + $texttoshow = $langs->trans('BillXCreated', '{s1}'); + $texttoshow = str_replace('{s1}', ''.$lastref.'', $texttoshow); + setEventMessages($texttoshow, null, 'mesgs'); + } else { + setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); + } + + // Make a redirect to avoid to bill twice if we make a refresh or back + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_orderday) { + $param .= '&search_orderday='.urlencode($search_orderday); + } + if ($search_ordermonth) { + $param .= '&search_ordermonth='.urlencode($search_ordermonth); + } + if ($search_orderyear) { + $param .= '&search_orderyear='.urlencode($search_orderyear); + } + if ($search_deliveryday) { + $param .= '&search_deliveryday='.urlencode($search_deliveryday); + } + if ($search_deliverymonth) { + $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + } + if ($search_deliveryyear) { + $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_ref_customer) { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_total_ht != '') { + $param .= '&search_total_ht='.urlencode($search_total_ht); + } + if ($search_total_vat != '') { + $param .= '&search_total_vat='.urlencode($search_total_vat); + } + if ($search_total_ttc != '') { + $param .= '&search_total_ttc='.urlencode($search_total_ttc); + } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($billed != '') { + $param .= '&billed='.urlencode($billed); + } + + header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); + exit; + } else { + $db->rollback(); + + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; + setEventMessages("Error", null, 'errors'); + $error++; + } + } } if ($action == 'validate' && $permissiontoadd) { if (GETPOST('confirm') == 'yes') { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5ec011f5017..c0a35947b9d 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -625,349 +625,6 @@ if (!$error && $massaction == 'confirm_presend') { } } -// TODO Move this action into commande/list.php if called only by this page. -if ($massaction == 'confirm_createbills') { // Create bills from orders. - $orders = GETPOST('toselect', 'array'); - $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); - $validate_invoices = GETPOST('validate_invoices', 'int'); - - $errors = array(); - - $TFact = array(); - $TFactThird = array(); - $TFactThirdNbLines = array(); - - $nb_bills_created = 0; - $lastid= 0; - $lastref = ''; - - $db->begin(); - - foreach ($orders as $id_order) { - $cmd = new Commande($db); - if ($cmd->fetch($id_order) <= 0) { - continue; - } - $cmd->fetch_thirdparty(); - - $objecttmp = new Facture($db); - if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { - // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it. - $objecttmp = $TFactThird[$cmd->socid]; - } else { - // If we want one invoice per order or if there is no first invoice yet for this thirdparty. - $objecttmp->socid = $cmd->socid; - $objecttmp->thirdparty = $cmd->thirdparty; - - $objecttmp->type = $objecttmp::TYPE_STANDARD; - $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id; - $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id; - - $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) { - $objecttmp->ref_client = $cmd->ref_client; - } - - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) { - $datefacture = dol_now(); - } - - $objecttmp->date = $datefacture; - $objecttmp->origin = 'commande'; - $objecttmp->origin_id = $id_order; - - $objecttmp->array_options = $cmd->array_options; // Copy extrafields - - $res = $objecttmp->create($user); - - if ($res > 0) { - $nb_bills_created++; - $lastref = $objecttmp->ref; - $lastid = $objecttmp->id; - - $TFactThird[$cmd->socid] = $objecttmp; - $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang - } else { - $langs->load("errors"); - $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error); - $error++; - } - } - - if ($objecttmp->id > 0) { - $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order); - - if ($res == 0) { - $errors[] = $objecttmp->error; - $error++; - } - - if (!$error) { - $lines = $cmd->lines; - if (empty($lines) && method_exists($cmd, 'fetch_lines')) { - $cmd->fetch_lines(); - $lines = $cmd->lines; - } - - $fk_parent_line = 0; - $num = count($lines); - - for ($i = 0; $i < $num; $i++) { - $desc = ($lines[$i]->desc ? $lines[$i]->desc : ''); - // If we build one invoice for several orders, we must put the ref of order on the invoice line - if (!empty($createbills_onebythird)) { - $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); - } - - if ($lines[$i]->subprice < 0) { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc = $objecttmp->socid; - $discount->amount_ht = abs($lines[$i]->total_ht); - $discount->amount_tva = abs($lines[$i]->total_tva); - $discount->amount_ttc = abs($lines[$i]->total_ttc); - $discount->tva_tx = $lines[$i]->tva_tx; - $discount->fk_user = $user->id; - $discount->description = $desc; - $discountid = $discount->create($user); - if ($discountid > 0) { - $result = $objecttmp->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); - } else { - setEventMessages($discount->error, $discount->errors, 'errors'); - $error++; - break; - } - } else { - // Positive line - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - // Date start - $date_start = false; - if ($lines[$i]->date_debut_prevue) { - $date_start = $lines[$i]->date_debut_prevue; - } - if ($lines[$i]->date_debut_reel) { - $date_start = $lines[$i]->date_debut_reel; - } - if ($lines[$i]->date_start) { - $date_start = $lines[$i]->date_start; - } - //Date end - $date_end = false; - if ($lines[$i]->date_fin_prevue) { - $date_end = $lines[$i]->date_fin_prevue; - } - if ($lines[$i]->date_fin_reel) { - $date_end = $lines[$i]->date_fin_reel; - } - if ($lines[$i]->date_end) { - $date_end = $lines[$i]->date_end; - } - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals(); - $array_options = $lines[$i]->array_options; - } - - $objecttmp->context['createfromclone']; - - $rang = $lines[$i]->rang; - //there may already be rows from previous orders - if (!empty($createbills_onebythird)) - $rang = $TFactThirdNbLines[$cmd->socid]; - - $result = $objecttmp->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $rang, - $lines[$i]->special_code, - $objecttmp->origin, - $lines[$i]->rowid, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht, - $lines[$i]->label, - $array_options, - 100, - 0, - $lines[$i]->fk_unit - ); - if ($result > 0) { - $lineid = $result; - if (!empty($createbills_onebythird)) //increment rang to keep order - $TFactThirdNbLines[$rcp->socid]++; - } else { - $lineid = 0; - $error++; - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - } - } - } - - //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - - if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { - $TFactThird[$cmd->socid] = $objecttmp; - } else { - $TFact[$objecttmp->id] = $objecttmp; - } - } - - // Build doc with all invoices - $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; - $toselect = array(); - - if (!$error && $validate_invoices) { - $massaction = $action = 'builddoc'; - - foreach ($TAllFact as &$objecttmp) { - $result = $objecttmp->validate($user); - if ($result <= 0) { - $error++; - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - break; - } - - $id = $objecttmp->id; // For builddoc action - - // Builddoc - $donotredirect = 1; - $upload_dir = $conf->facture->dir_output; - $permissiontoadd = $user->rights->facture->creer; - - // Call action to build doc - $savobject = $object; - $object = $objecttmp; - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - $object = $savobject; - } - - $massaction = $action = 'confirm_createbills'; - } - - if (!$error) { - $db->commit(); - - if ($nb_bills_created == 1) { - $texttoshow = $langs->trans('BillXCreated', '{s1}'); - $texttoshow = str_replace('{s1}', ''.$lastref.'', $texttoshow); - setEventMessages($texttoshow, null, 'mesgs'); - } else { - setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); - } - - // Make a redirect to avoid to bill twice if we make a refresh or back - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - if ($sall) { - $param .= '&sall='.urlencode($sall); - } - if ($socid > 0) { - $param .= '&socid='.urlencode($socid); - } - if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); - } - if ($search_orderday) { - $param .= '&search_orderday='.urlencode($search_orderday); - } - if ($search_ordermonth) { - $param .= '&search_ordermonth='.urlencode($search_ordermonth); - } - if ($search_orderyear) { - $param .= '&search_orderyear='.urlencode($search_orderyear); - } - if ($search_deliveryday) { - $param .= '&search_deliveryday='.urlencode($search_deliveryday); - } - if ($search_deliverymonth) { - $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); - } - if ($search_deliveryyear) { - $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_company) { - $param .= '&search_company='.urlencode($search_company); - } - if ($search_ref_customer) { - $param .= '&search_ref_customer='.urlencode($search_ref_customer); - } - if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); - } - if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); - } - if ($search_total_ht != '') { - $param .= '&search_total_ht='.urlencode($search_total_ht); - } - if ($search_total_vat != '') { - $param .= '&search_total_vat='.urlencode($search_total_vat); - } - if ($search_total_ttc != '') { - $param .= '&search_total_ttc='.urlencode($search_total_ttc); - } - if ($search_project_ref >= 0) { - $param .= "&search_project_ref=".urlencode($search_project_ref); - } - if ($show_files) { - $param .= '&show_files='.urlencode($show_files); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($billed != '') { - $param .= '&billed='.urlencode($billed); - } - - header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); - exit; - } else { - $db->rollback(); - - $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; - setEventMessages("Error", null, 'errors'); - $error++; - } -} - if (!$error && $massaction == 'cancelorders') { $db->begin(); From e9cfb9b69c17678e9eca50ddb19da5d10cce0fcb Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 25 Apr 2022 11:24:09 +0200 Subject: [PATCH 546/752] Improve error handling confirm_billcreate --- htdocs/commande/list.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4859412f692..38d79aa9698 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -368,7 +368,7 @@ if (empty($reshook)) { $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang } else { $langs->load("errors"); - $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error); + $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); $error++; } } @@ -377,7 +377,7 @@ if (empty($reshook)) { $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order); if ($res == 0) { - $errors[] = $objecttmp->error; + $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); $error++; } @@ -640,7 +640,11 @@ if (empty($reshook)) { $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; - setEventMessages("Error", null, 'errors'); + if (!empty($errors)) { + setEventMessages(null, $errors, 'errors'); + } else { + setEventMessages("Error", null, 'errors'); + } $error++; } } From 40da13922506d9a108d731e51c8eb42dd0fe51ec Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 25 Apr 2022 13:58:33 +0200 Subject: [PATCH 547/752] Add hook massaction to reception list. --- htdocs/reception/list.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 8575c84c026..b3b039c2f68 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -166,6 +166,15 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } if (empty($reshook)) { + // Mass actions + $objectclass = 'Reception'; + $objectlabel = 'Receptions'; + $permissiontoread = $user->rights->reception->lire; + $permissiontoadd = $user->rights->reception->creer; + $permissiontodelete = $user->rights->reception->supprimer; + $uploaddir = $conf->reception->multidir_output[$conf->entity]; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + if ($massaction == 'confirm_createbills') { $receptions = GETPOST('toselect', 'array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); From 752aaeb275a7cf028cb0cf1b2624bb09271745dc Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:07:48 +0200 Subject: [PATCH 548/752] fix : allow cut&paste as real numeric value to excel --- htdocs/compta/resultat/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index ff770acf554..68068dec866 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -1042,7 +1042,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { } $case = strftime("%Y-%m", dol_mktime(12, 0, 0, $mois_modulo, 1, $annee_decalage)); - print ' '; + print ''; if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'BOOKKEEPING') { if (isset($decaiss[$case]) && $decaiss[$case] != 0) { print ''.price(price2num($decaiss[$case], 'MT')).''; @@ -1062,7 +1062,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { } print ""; - print ' '; + print ''; if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'BOOKKEEPING') { if (isset($encaiss[$case])) { print ''.price(price2num($encaiss[$case], 'MT')).''; From 7e44227df24cc4df1441d2a231ca43c8b72aaaa9 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 25 Apr 2022 14:28:57 +0200 Subject: [PATCH 549/752] Cleanup 'confirm_createbills' --- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/contrat/services_list.php | 2 +- htdocs/fichinter/list.php | 2 +- htdocs/fourn/facture/list.php | 45 ++------------------------ htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/projet/tasks/time.php | 2 -- htdocs/user/group/list.php | 2 +- htdocs/user/list.php | 2 +- 10 files changed, 11 insertions(+), 52 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1936d855a7e..8dacc74722e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -172,7 +172,7 @@ $result = restrictedArea($user, 'adherent'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 0b83881e502..aed531d86b4 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -111,7 +111,7 @@ $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index adf7a4b6ed7..f12d48df44a 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -163,7 +163,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 46a9f2eee3f..04d98031e36 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -149,7 +149,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 0e682351992..f110ab78e82 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -228,7 +228,7 @@ if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MA if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -829,7 +829,7 @@ if ($resql) { //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); - //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); + if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) { $langs->load('withdrawals'); $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder"); @@ -837,7 +837,7 @@ if ($resql) { if ($user->rights->fournisseur->facture->supprimer) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } - if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { + if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -868,45 +868,6 @@ if ($resql) { $trackid = 'sinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($massaction == 'createbills') { - //var_dump($_REQUEST); - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans('DateInvoice'); - print ''; - print $form->selectDate('', '', '', '', '', '', 1, 1); - print '
'; - print $langs->trans('CreateOneBillByThird'); - print ''; - print $form->selectyesno('createbills_onebythird', '', 1); - print '
'; - print $langs->trans('ValidateInvoices'); - print ''; - print $form->selectyesno('validate_invoices', 1, 1); - print '
'; - - print '
'; - print '
'; - print ' '; - print ''; - print '
'; - print '
'; - } - if ($search_all) { foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b254ac2b26f..93c92231bfd 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -226,7 +226,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index d71cd9bca56..6d9e44c3799 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -185,7 +185,7 @@ if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 1b8e116092f..4374ffb2d37 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1149,8 +1149,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Form to convert time spent into invoice if ($massaction == 'generateinvoice') { - print ''; - if ($projectstatic->thirdparty->id > 0) { print ''; print ''; diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 04fa0035418..bf8bd407093 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -92,7 +92,7 @@ if (!$user->rights->user->user->lire && !$user->admin) { if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/user/list.php b/htdocs/user/list.php index cd87e286225..4ae920e6dc7 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -203,7 +203,7 @@ $childids = $user->getAllChildIds(1); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } From 22b56bde9eab474052e3b4c54ffd8d877c677819 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 25 Apr 2022 14:30:55 +0200 Subject: [PATCH 550/752] Update changelog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 31bfa1c1cff..428829038f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,7 +34,7 @@ Following changes may create regressions for some external modules, but were nec * The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead. * All triggers with a name XXX_UPDATE have been rename with name XXX_MODIFY for code consistency purpose. * Rename build_path_from_id_categ() into buildPathFromId() and set method to private - +* Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php ***** ChangeLog for 15.0.1 compared to 15.0.0 ***** FIX: #19777 #20281 From 7f1d5fa86731b66d68b95d13a6750a365e471486 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 25 Apr 2022 12:43:58 +0000 Subject: [PATCH 551/752] Fixing style errors. --- htdocs/fourn/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index f110ab78e82..b8ad5e68415 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -829,7 +829,7 @@ if ($resql) { //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); - + if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) { $langs->load('withdrawals'); $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder"); From 694bcda3bbdbac9b79a74cf6b51df477be5660a7 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 25 Apr 2022 22:26:25 +0200 Subject: [PATCH 552/752] Fix #20712 - No more empty wrong line added in bookkeeping confirme_create mode --- htdocs/accountancy/bookkeeping/card.php | 63 ++++++++++++++----------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index c156a388735..0aa57dde3c6 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -260,7 +260,7 @@ if ($action == "confirm_update") { if ($mode != '_tmp') { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } - $action = 'update'; + $action = ''; $id = $object->id; $piece_num = $object->piece_num; } @@ -642,6 +642,12 @@ if ($action == 'create') { } print "\n"; + + // Empty line is the first line of $object->linesmvt + // So we must get the first line (the empty one) and pu it at the end of the array + // in order to display it correctly to the user + $empty_line = array_shift($object->linesmvt); + $object->linesmvt[]= $empty_line; foreach ($object->linesmvt as $line) { print ''; @@ -673,7 +679,33 @@ if ($action == 'create') { print ''."\n"; print ''; print ''; + } elseif (empty($line->numero_compte) || (empty($line->debit) &&empty($line->creit))) { + if ($action == "" || $action == 'add') { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } } else { + print ''; $accountingaccount->fetch(null, $line->numero_compte, true); print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - print '
'; + print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); + print ''; + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + } else { + print ''; + } + print '
'; + print '
'; + print ''; + print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 0).''.length_accounta($line->subledger_account); @@ -715,33 +747,8 @@ if ($action == 'create') { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); } - if (empty($object->date_export) && empty($object->date_validation)) { - if ($action == "" || $action == 'add') { - print '
'; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); - print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: - // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. - // Also, it is not possible to use a value that is not in the list. - // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1); - } else { - print ''; - } - print '
'; - print '
'; - } + print ''; + print '
'; if ($mode == '_tmp' && $action == '') { print '
'; From 6a1d4c2255a0ac9fa77a97960f7315511dd893ce Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 25 Apr 2022 20:36:34 +0000 Subject: [PATCH 553/752] Fixing style errors. --- htdocs/accountancy/bookkeeping/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 0aa57dde3c6..0eff932fd19 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -642,7 +642,7 @@ if ($action == 'create') { } print "\n"; - + // Empty line is the first line of $object->linesmvt // So we must get the first line (the empty one) and pu it at the end of the array // in order to display it correctly to the user @@ -703,7 +703,7 @@ if ($action == 'create') { print ''; print ''; print ''; - } + } } else { print ''; $accountingaccount->fetch(null, $line->numero_compte, true); From fb1c770568e139c4e4cf19a1db51e820f768d110 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Apr 2022 23:37:34 +0200 Subject: [PATCH 554/752] Doc --- htdocs/install/mysql/migration/repair.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 2e7f42a2727..4add688b880 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -559,6 +559,10 @@ DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; -- Sequence to fix the content of llx_bank.amount_main_currency +-- Note: amount is amount in currency of bank account +-- Note: pamount is always amount into the main currency +-- Note: pmulticurrencyamount is in currency of invoice +-- Note: amount_main_currency must be amount in main currency -- DROP TABLE tmp_bank; -- CREATE TABLE tmp_bank SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment' INNER JOIN llx_paiement as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; -- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; From 8de9d63f7df725cdc5d4e59c37b0961e6f59c570 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Apr 2022 00:35:20 +0200 Subject: [PATCH 555/752] FIX Numbering of sepa files --- htdocs/compta/prelevement/class/bonprelevement.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 27c96bd47db..afd6b5e075c 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -920,7 +920,7 @@ class BonPrelevement extends CommonObject $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX" $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; - $sql .= " WHERE ref LIKE '%".$this->db->escape($ref)."%'"; + $sql .= " WHERE ref LIKE '_".$this->db->escape($ref)."%'"; $sql .= " AND entity = ".((int) $conf->entity); $sql .= " ORDER BY ref DESC LIMIT 1"; @@ -931,7 +931,7 @@ class BonPrelevement extends CommonObject $row = $this->db->fetch_row($resql); // Build the new ref - $ref = "T".$ref.str_pad(dol_substr("00".(intval($row[0]) + 1), 0, 2), 2, "0", STR_PAD_LEFT); + $ref = "T".$ref.sprintf("%02d", (intval($row[0]) + 1)); // $conf->abc->dir_output may be: // /home/ldestailleur/git/dolibarr_15.0/documents/abc/ From 134113db646f49d3a97314282e0dea679fdc5843 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Apr 2022 01:00:10 +0200 Subject: [PATCH 556/752] Fix upload of doc for purchase orders --- htdocs/api/class/api_documents.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index da49e4cbba7..44c3b1fcb52 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -597,6 +597,16 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $object = new FactureFournisseur($this->db); + } elseif ($modulepart == 'commande' || $modulepart == 'order') { + $modulepart = 'commande'; + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $object = new Commande($this->db); + } elseif ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') { + $modulepart = 'supplier_order'; + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $object = new CommandeFournisseur($this->db); } elseif ($modulepart == 'project') { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $object = new Project($this->db); @@ -655,7 +665,7 @@ class Documents extends DolibarrApi } // Special cases that need to use get_exdir to get real dir of object - // If future, all object should use this to define path of documents. + // In future, all object should use this to define path of documents. if ($modulepart == 'supplier_invoice') { $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); } From 8980b2e6c09a3d55808ae10b23ecc36a8715d952 Mon Sep 17 00:00:00 2001 From: matll42 Date: Tue, 26 Apr 2022 01:44:53 +0200 Subject: [PATCH 557/752] FIX #20476 migration postgresql 14.0.x to 15.0.x packaging type --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 4b34d3a72ac..58f29acfe60 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -36,7 +36,8 @@ -- VPGSQL8.2 ALTER TABLE llx_partnership ALTER COLUMN date_partnership_end DROP NOT NULL; ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging real DEFAULT NULL; -ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL; +-- VMYSQL4.3 ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL; +-- VPGSQL8.2 ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL USING packaging::real; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_export datetime DEFAULT NULL; From 8d3c2e34f42b8d237c75c022090052da46839cf0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Apr 2022 11:46:00 +0200 Subject: [PATCH 558/752] FIX Check field accountancy code customer is mandatory in mass action --- htdocs/compta/facture/class/facture.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7ad0a8ed4bc..2134570ee2e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2724,7 +2724,7 @@ class Facture extends CommonInvoice // Check for mandatory fields in thirdparty (defined into setup) if (!empty($this->thirdparty) && is_object($this->thirdparty)) { - $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'ACCOUNTANCY_CODE_CUSTOMER'); foreach ($array_to_check as $key) { $keymin = strtolower($key); if (!property_exists($this->thirdparty, $keymin)) { @@ -2756,6 +2756,15 @@ class Facture extends CommonInvoice return -1; } } + if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') { + // Check for mandatory + if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY) && empty($this->thirdparty->code_compta)) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorAccountancyCodeCustomerIsMandatory", $this->thirdparty->name).' ('.$langs->trans("ForbiddenBySetupRules").')'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } } } } From c00a56bee3ce475fa268ea3cb707465702f6b4eb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 26 Apr 2022 16:39:06 +0200 Subject: [PATCH 559/752] fix: truncate too long Ref Customer in PDF Header --- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 6486306d9ed..96966606e1c 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1504,7 +1504,7 @@ class pdf_eratosthene extends ModelePDFCommandes $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3134bbc63f5..1bbbb2c9f3f 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1961,7 +1961,7 @@ class pdf_sponge extends ModelePDFFactures $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 5fb9949acd3..cb2df1a5ed9 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1595,7 +1595,7 @@ class pdf_cyan extends ModelePDFPropales $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { From 399addfb033e07924ec988a65b87329d925b8a7e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 26 Apr 2022 16:40:27 +0200 Subject: [PATCH 560/752] mor docs --- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 +- .../doc/pdf_standard_recruitmentjobposition.modules.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 7e1b1105452..f2d2a473145 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1336,7 +1336,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } /* PHFAVRE $posy+=4; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 50e978aceab..cc215a855ff 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -919,7 +919,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { From 3d4bd1e1553a76c87bcf172d3f8640f86de09cf2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 26 Apr 2022 16:53:40 +0200 Subject: [PATCH 561/752] FIX: truncate Customer Reference too long on PDF header (PR #20718) --- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index f2d2a473145..aba01f51742 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1336,7 +1336,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } /* PHFAVRE $posy+=4; From 5387a8e9530b19d4bdc32127196478c8673cba47 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 26 Apr 2022 19:07:31 +0200 Subject: [PATCH 562/752] FiX miss spelling --- htdocs/accountancy/bookkeeping/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 0eff932fd19..f9ec739e63d 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -679,7 +679,7 @@ if ($action == 'create') { print ''."\n"; print ''; print ''; - } elseif (empty($line->numero_compte) || (empty($line->debit) &&empty($line->creit))) { + } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { if ($action == "" || $action == 'add') { print ''; print ''; From 3f832c1c5d405866b704e9cd9a1beb5aa4d7e423 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 27 Apr 2022 04:46:09 +0200 Subject: [PATCH 563/752] FIX Accountancy - Export format FEC - Prevent tab in label with the formats for which it is the separator --- htdocs/accountancy/class/accountancyexport.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3c30200c130..128b14fa800 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -980,6 +980,8 @@ class AccountancyExport print dol_string_unaccent($date_creation) . $separator; // FEC:EcritureLib + // Clean label operation to prevent problem on export with tab separator & other character + $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation); print dol_string_unaccent($line->label_operation) . $separator; // FEC:Debit @@ -1007,6 +1009,8 @@ class AccountancyExport print $date_limit_payment . $separator; // FEC_suppl:NumFacture + // Clean ref invoice to prevent problem on export with tab separator & other character + $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice); print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1); print $end_line; @@ -1107,6 +1111,8 @@ class AccountancyExport print $date_document . $separator; // FEC:EcritureLib + // Clean label operation to prevent problem on export with tab separator & other character + $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation); print dol_string_unaccent($line->label_operation) . $separator; // FEC:Debit @@ -1134,6 +1140,8 @@ class AccountancyExport print $date_limit_payment . $separator; // FEC_suppl:NumFacture + // Clean ref invoice to prevent problem on export with tab separator & other character + $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice); print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1); @@ -1712,6 +1720,8 @@ class AccountancyExport print self::trunc($line->label_compte, 60).$separator; //Account label print self::trunc($line->doc_ref, 20).$separator; //Piece + // Clean label operation to prevent problem on export with tab separator & other character + $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation); print self::trunc($line->label_operation, 60).$separator; //Operation label print price(abs($line->debit - $line->credit)).$separator; //Amount print $line->sens.$separator; //Direction From dd85c22927a8e17afa59058615ffe32ecfd24dd6 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 27 Apr 2022 08:50:58 +0200 Subject: [PATCH 564/752] remove combox search box --- htdocs/compta/facture/list.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1c4ce0cdecf..c026b3a5db1 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -136,7 +136,7 @@ $search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int'); $search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear); $search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear); $search_categ_cus = GETPOST("search_categ_cus", 'int'); -$search_fac_rec_source = GETPOST("search_fac_rec_source", 'int'); +$search_fac_rec_source_title = GETPOST("search_fac_rec_source_title", 'alpha'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -363,7 +363,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_datelimit_endyear = ''; $search_datelimit_start = ''; $search_datelimit_end = ''; - $search_fac_rec_source = ''; + $search_fac_rec_source_title = ''; $option = ''; $filter = ''; $toselect = ''; @@ -622,6 +622,10 @@ if ($sall || $search_product_category > 0) { if ($search_product_category > 0) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; } + +if (!empty($search_fac_rec_source_title)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_rec as facrec ON f.fk_fac_rec_source=facrec.rowid'; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid'; // We'll need this table joined to the select in order to filter by sale @@ -806,9 +810,8 @@ if ($search_sale > 0) { if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user); } - -if ($search_fac_rec_source > 0) { - $sql .= " AND f.fk_fac_rec_source = ".((int) $search_fac_rec_source); +if (!empty($search_fac_rec_source_title)) { + $sql .= natural_search('facrec.titre', $search_fac_rec_source_title); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -1088,8 +1091,8 @@ if ($resql) { if ($search_categ_cus > 0) { $param .= '&search_categ_cus='.urlencode($search_categ_cus); } - if ($search_fac_rec_source > 0) { - $param .= '&search_fac_rec_source='.urlencode($search_fac_rec_source); + if (!empty($search_fac_rec_source_title)) { + $param .= '&$search_fac_rec_source_title='.urlencode($search_fac_rec_source_title); } // Add $param from extra fields @@ -1515,7 +1518,7 @@ if ($resql) { if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { // Template Invoice print ''; - $form->selectInvoiceRec($search_fac_rec_source, 'search_fac_rec_source'); + print ''; print ''; } // Status @@ -1678,7 +1681,7 @@ if ($resql) { print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { - print_liste_field_titre($arrayfields['f.fk_fac_rec_source']['label'], $_SERVER["PHP_SELF"], "f.fk_fac_rec_source", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['f.fk_fac_rec_source']['label'], $_SERVER["PHP_SELF"], "facrec.titre", "", $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['f.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type", "", $param, 'class="right"', $sortfield, $sortorder); From 543e6f186cdf03113f07b2d7b3ffbebadbda3afa Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 27 Apr 2022 09:03:51 +0200 Subject: [PATCH 565/752] add hook to getSellPrice function --- htdocs/product/class/product.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 84cc2454c21..cf9a0c3fa87 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1804,6 +1804,16 @@ class Product extends CommonObject { global $conf, $db; + // call hook if any + $hookmanager->initHooks(array('productdao')); + $parameters = array('thirdparty_seller'=>$thirdparty_seller, 'thirdparty_buyer' => $thirdparty_buyer, 'pqp' => $pqp); + // Note that $action and $object may have been modified by some hooks + global $action; + $reshook = $hookmanager->executeHooks('getSellPrice', $parameters, $this, $action); + if ( ! empty($reshook)) { + return $hookmanager->resArray; + } + // Update if prices fields are defined $tva_tx = get_default_tva($thirdparty_seller, $thirdparty_buyer, $this->id); $tva_npr = get_default_npr($thirdparty_seller, $thirdparty_buyer, $this->id); From 4939da560f7becf2bf51f5a776ec6c4b1c90ad74 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Wed, 27 Apr 2022 09:25:38 +0200 Subject: [PATCH 566/752] New: Add option to foce delivery receipt to yes Add a constant to force delivery receipt for supplier order. --- htdocs/core/class/html.formmail.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 0c9a1b2531a..818c3b19c7b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1202,6 +1202,9 @@ class FormMail extends Form if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') { $defaultvaluefordeliveryreceipt = 1; } + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_ORDER) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') { + $defaultvaluefordeliveryreceipt = 1; + } $out .= $form->selectyesno('deliveryreceipt', (GETPOSTISSET("deliveryreceipt") ? GETPOST("deliveryreceipt") : $defaultvaluefordeliveryreceipt), 1); } $out .= "\n"; From 25078b292d6996065fd265c678780584d86d8065 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 27 Apr 2022 09:40:09 +0200 Subject: [PATCH 567/752] fix hookmanager --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cf9a0c3fa87..bb411d530c7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1802,7 +1802,7 @@ class Product extends CommonObject */ public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) { - global $conf, $db; + global $conf, $db, $hookmanager; // call hook if any $hookmanager->initHooks(array('productdao')); From c969cef731c9f772f8c86af73d5ce7d71ef1fd84 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Wed, 27 Apr 2022 10:09:22 +0200 Subject: [PATCH 568/752] NEW : Send email to the supplier order contact Select the recipient defined in object contact (Vendor contact following-up order / Contact fournisseur suivi commande) in order to send email to the specific contact and not to generic company email (as for invoice/bill) --- htdocs/core/actions_massactions.inc.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5ec011f5017..3b45cffd772 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -128,6 +128,14 @@ if (!$error && $massaction == 'confirm_presend') { $listofobjectcontacts[$toselectid][$data_email['id']] = $data_email['email']; } } + } elseif ($objectclass == 'CommandeFournisseur') { + $tmparraycontact = array(); + $tmparraycontact = $objecttmp->liste_contact(-1, 'external', 0, 'CUSTOMER'); + if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { + foreach ($tmparraycontact as $data_email) { + $listofobjectcontacts[$toselectid][$data_email['id']] = $data_email['email']; + } + } } $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; @@ -277,6 +285,19 @@ if (!$error && $massaction == 'confirm_presend') { if (count($emails_to_sends) > 0) { $sendto = implode(',', $emails_to_sends); } + } elseif ($objectobj->element == 'order_supplier' && !empty($listofobjectcontacts[$objectid])) { + $emails_to_sends = array(); + $objectobj->fetch_thirdparty(); + $contactidtosend = array(); + foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { + $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email'); + if (!in_array($contactemailid, $contactidtosend)) { + $contactidtosend[] = $contactemailid; + } + } + if (count($emails_to_sends) > 0) { + $sendto = implode(',', $emails_to_sends); + } } else { $objectobj->fetch_thirdparty(); $sendto = $objectobj->thirdparty->email; From fb7f0545e4a08dd5c835e2d1fe816c3003f839d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Wed, 27 Apr 2022 17:56:31 +0200 Subject: [PATCH 569/752] Fix error reporting in getLinesArray() --- htdocs/modulebuilder/template/class/myobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e7da913f39c..51992ada8ee 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -937,8 +937,8 @@ class MyObject extends CommonObject if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; From 5dce613118c367d1957eee36c5ab2a1cfe848a11 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 28 Apr 2022 05:34:02 +0200 Subject: [PATCH 570/752] NEW Accountancy - Product admin - Add product categories --- htdocs/accountancy/admin/productaccount.php | 108 ++++++++++++++++++-- 1 file changed, 100 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 847891c949b..8a8ca0ecf46 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,10 +1,10 @@ - * Copyright (C) 2013-2021 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Ari Elbaz (elarifr) - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Ari Elbaz (elarifr) + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -34,6 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +if (!empty($conf->categorie->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("companies", "compta", "accountancy", "products")); @@ -59,6 +62,8 @@ $account_number_sell = GETPOST('account_number_sell'); $changeaccount = GETPOST('changeaccount', 'array'); $changeaccount_buy = GETPOST('changeaccount_buy', 'array'); $changeaccount_sell = GETPOST('changeaccount_sell', 'array'); +$searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'int') ? GETPOST('search_category_product_operator', 'int') : 0); +$searchCategoryProductList = GETPOST('search_category_product_list', 'array'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha'); @@ -144,6 +149,8 @@ if ($reshook < 0) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + $searchCategoryProductOperator = 0; + $searchCategoryProductList = array(); $search_ref = ''; $search_label = ''; $search_desc = ''; @@ -283,7 +290,16 @@ $aacompta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUN $aacompta_prodsell_intra = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); $aacompta_prodsell_export = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); -llxHeader('', $langs->trans("ProductsBinding")); + +$title = $langs->trans("ProductsBinding"); +$helpurl = ''; + +$paramsCat = ''; +foreach ($searchCategoryProductList as $searchCategoryProduct) { + $paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); +} + +llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, ''); $pcgverid = getDolGlobalString('CHARTOFACCOUNTS'); $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); @@ -308,6 +324,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } +if (!empty($searchCategoryProductList)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ +} $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if (strlen(trim($search_current_account))) { $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, $search_current_account); @@ -318,6 +337,30 @@ if ($search_current_account_valid == 'withoutvalidaccount') { if ($search_current_account_valid == 'withvalidaccount') { $sql .= " AND aa.account_number IS NOT NULL"; } +$searchCategoryProductSqlList = array(); +if ($searchCategoryProductOperator == 1) { + foreach ($searchCategoryProductList as $searchCategoryProduct) { + if (intval($searchCategoryProduct) == -2) { + $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; + } elseif (intval($searchCategoryProduct) > 0) { + $searchCategoryProductSqlList[] = "cp.fk_categorie = ".$db->escape($searchCategoryProduct); + } + } + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; + } +} else { + foreach ($searchCategoryProductList as $searchCategoryProduct) { + if (intval($searchCategoryProduct) == -2) { + $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; + } elseif (intval($searchCategoryProduct) > 0) { + $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")"; + } + } + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; + } +} // Add search filter like if (strlen(trim($search_ref))) { $sql .= natural_search("p.ref", $search_ref); @@ -338,6 +381,15 @@ if ($search_onpurchase != '' && $search_onpurchase != '-1') { $sql .= natural_search('p.tobuy', $search_onpurchase, 1); } +$sql .= " GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; +$sql .= " p.fk_product_type,"; +$sql .= ' p.tms,'; +if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; +} else { + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export"; +} + $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; @@ -365,11 +417,17 @@ if ($result) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } + if ($searchCategoryProductOperator == 1) { + $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); + } + foreach ($searchCategoryProductList as $searchCategoryProduct) { + $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); + } if ($search_ref > 0) { - $param .= "&search_desc=".urlencode($search_ref); + $param .= "&search_ref=".urlencode($search_ref); } if ($search_label > 0) { - $param .= "&search_desc=".urlencode($search_label); + $param .= "&search_label=".urlencode($search_label); } if ($search_desc > 0) { $param .= "&search_desc=".urlencode($search_desc); @@ -461,6 +519,40 @@ if ($result) { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($chk_prod)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1); } + // Filter on categories + $moreforfilter = ''; + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + $moreforfilter .= '
'; + $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); + $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); + $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; + $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); + $moreforfilter .= ' '.$langs->trans('UseOrOperatorForCategories').''; + $moreforfilter .= '
'; + } + + //Show/hide child products. Hidden by default + if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { + $moreforfilter .= '
'; + $moreforfilter .= ''; + $moreforfilter .= ' '; + $moreforfilter .= '
'; + } + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } + + if ($moreforfilter) { + print '
'; + print $moreforfilter; + print '
'; + } + print '
'; print ''; From 1efa44a0220efb7168ba9aa1decd5befc7f8673f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 28 Apr 2022 06:50:37 +0200 Subject: [PATCH 571/752] NEW Accountancy - Add reconcile functionality --- htdocs/accountancy/bookkeeping/list.php | 369 ++++--- .../accountancy/bookkeeping/listbyaccount.php | 449 +++++--- .../bookkeeping/listbysubaccount.php | 979 ------------------ .../accountancy/class/bookkeeping.class.php | 4 +- htdocs/accountancy/class/lettering.class.php | 456 +++++++- htdocs/accountancy/journal/bankjournal.php | 10 + .../accountancy/journal/purchasesjournal.php | 6 + htdocs/accountancy/journal/sellsjournal.php | 6 + htdocs/langs/en_US/accountancy.lang | 18 + 9 files changed, 1052 insertions(+), 1245 deletions(-) delete mode 100644 htdocs/accountancy/bookkeeping/listbysubaccount.php diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index a760a550bef..bc7ea7c7072 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -42,6 +43,10 @@ $langs->loadLangs(array("accountancy", "compta")); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist'; $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); @@ -86,6 +91,7 @@ $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', ' $search_date_validation_endday = GETPOST('search_date_validation_endday', 'int'); $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); +$search_import_key = GETPOST("search_import_key", 'alpha'); //var_dump($search_date_start);exit; if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { @@ -191,6 +197,7 @@ $arrayfields = array( 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), 't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1), + 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { @@ -220,10 +227,12 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ +$param = ''; + if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') { $massaction = ''; } @@ -294,10 +303,11 @@ if (empty($reshook)) { $search_credit = ''; $search_lettering_code = ''; $search_not_reconciled = ''; + $search_import_key = ''; + $toselect = ''; } // Must be after the remove filter action, before the export. - $param = ''; $filter = array(); if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; @@ -416,77 +426,143 @@ if (empty($reshook)) { $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } -} + if (!empty($search_import_key)) { + $filter['t.import_key'] = $search_import_key; + $param .= '&search_import_key='.urlencode($search_import_key); + } -if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); - - if (!empty($import_key)) { - $result = $object->deleteByImportkey($import_key); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + // $delmonth = GETPOST('delmonth', 'int'); + // $delyear = GETPOST('delyear', 'int'); + // if ($delyear == -1) { + // $delyear = 0; + // } + // $deljournal = GETPOST('deljournal', 'alpha'); + // if ($deljournal == -1) { + // $deljournal = 0; + // } + // + // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { + // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + // if ($result < 0) { + // setEventMessages($object->error, $object->errors, 'errors'); + // } else { + // setEventMessages("RecordDeleted", null, 'mesgs'); + // } + // + // // Make a redirect to avoid to launch the delete later after a back button + // header("Location: list.php".($param ? '?'.$param : '')); + // exit; + // } else { + // setEventMessages("NoRecordDeleted", null, 'warnings'); + // } + //} + if ($action == 'setreexport') { + $setreexport = GETPOST('value', 'int'); + if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) { + $error++; } - // Make a redirect to avoid to launch the delete later after a back button - header("Location: list.php".($param ? '?'.$param : '')); - exit; - } -} -if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delmonth = GETPOST('delmonth', 'int'); - $delyear = GETPOST('delyear', 'int'); - if ($delyear == -1) { - $delyear = 0; - } - $deljournal = GETPOST('deljournal', 'alpha'); - if ($deljournal == -1) { - $deljournal = 0; - } - - if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { - $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + if (!$error) { + if ($conf->global->ACCOUNTING_REEXPORT == 1) { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); + } } else { - setEventMessages("RecordDeleted", null, 'mesgs'); + setEventMessages($langs->trans("Error"), null, 'errors'); } - - // Make a redirect to avoid to launch the delete later after a back button - header("Location: list.php".($param ? '?'.$param : '')); - exit; - } else { - setEventMessages("NoRecordDeleted", null, 'warnings'); - } -} -if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); - - if (!empty($mvt_num)) { - $result = $object->deleteMvtNum($mvt_num); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } - - header("Location: list.php?noreset=1".($param ? '&'.$param : '')); - exit; - } -} -if ($action == 'setreexport') { - $setreexport = GETPOST('value', 'int'); - if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) { - $error++; } - if (!$error) { - if ($conf->global->ACCOUNTING_REEXPORT == 1) { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); + // Mass actions + $objectclass = 'Bookkeeping'; + $objectlabel = 'Bookkeeping'; + $permissiontoread = $user->rights->societe->lire; + $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoadd = $user->rights->societe->creer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) { + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $object->fetch($toselectid); + if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) { + $result = $object->deleteMvtNum($object->piece_num); + if ($result > 0) { + $nbok++; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } elseif ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } + + // Message for elements well deleted + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); + } elseif ($nbok > 0) { + setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + } elseif (!$error) { + setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); + } + + if (!$error) { + header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); + exit; + } + } + + // others mass actions + if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + if ($massaction == 'lettering') { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } + } elseif ($action == 'unlettering' && $confirm == "yes") { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } } - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -520,7 +596,8 @@ $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; $sql .= " t.date_export,"; -$sql .= " t.date_validated as date_validation"; +$sql .= " t.date_validated as date_validation,"; +$sql .= " t.import_key"; $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -667,6 +744,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $db->num_rows($resql); } +$arrayofselected = is_array($toselect) ? $toselect : array(); // Output page // -------------------------------------------------------------------- @@ -684,7 +762,7 @@ if ($action == 'export_file') { 'name' => 'notifiedexportdate', 'type' => 'checkbox', 'label' => $langs->trans('NotifiedExportDate'), - 'value' => $checked, + 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'), ); $form_question['separator'] = array('name'=>'separator', 'type'=>'separator'); @@ -703,50 +781,46 @@ if ($action == 'export_file') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300, 600); } -if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.urlencode(GETPOST('mvt_num')).$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); -} - -if ($action == 'delbookkeepingyear') { - $form_question = array(); - $delyear = GETPOST('delyear', 'int'); - $deljournal = GETPOST('deljournal', 'alpha'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $month_array = array(); - for ($i = 1; $i <= 12; $i++) { - $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); - } - $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); - - $form_question['delmonth'] = array( - 'name' => 'delmonth', - 'type' => 'select', - 'label' => $langs->trans('DelMonth'), - 'values' => $month_array, - 'morecss' => 'minwidth150', - 'default' => '' - ); - $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - $form_question['deljournal'] = array( - 'name' => 'deljournal', - 'type' => 'other', // We don't use select here, the journal_array is already a select html component - 'label' => $langs->trans('DelJournal'), - 'value' => $journal_array, - 'default' => $deljournal - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320); -} +//if ($action == 'delbookkeepingyear') { +// $form_question = array(); +// $delyear = GETPOST('delyear', 'int'); +// $deljournal = GETPOST('deljournal', 'alpha'); +// +// if (empty($delyear)) { +// $delyear = dol_print_date(dol_now(), '%Y'); +// } +// $month_array = array(); +// for ($i = 1; $i <= 12; $i++) { +// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); +// } +// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); +// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); +// +// $form_question['delmonth'] = array( +// 'name' => 'delmonth', +// 'type' => 'select', +// 'label' => $langs->trans('DelMonth'), +// 'values' => $month_array, +// 'morecss' => 'minwidth150', +// 'default' => '' +// ); +// $form_question['delyear'] = array( +// 'name' => 'delyear', +// 'type' => 'select', +// 'label' => $langs->trans('DelYear'), +// 'values' => $year_array, +// 'default' => $delyear +// ); +// $form_question['deljournal'] = array( +// 'name' => 'deljournal', +// 'type' => 'other', // We don't use select here, the journal_array is already a select html component +// 'label' => $langs->trans('DelJournal'), +// 'value' => $journal_array, +// 'default' => $deljournal +// ); +// +// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320); +//} // Print form confirm print $formconfirm; @@ -759,6 +833,22 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } +// List of mass actions available +$arrayofmassactions = array(); +/* +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + $arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering'); + $arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering'); +} +*/ +if ($user->rights->accounting->mouvements->supprimer) { + $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions); + print '
'; print ''; print ''; @@ -768,8 +858,7 @@ if ($optioncss != '') { print ''; print ''; print ''; - -$massactionbutton = ''; +print ''; if (count($filter)) { $buttonLabel = $langs->trans("ExportFilteredList"); @@ -794,7 +883,7 @@ if (empty($reshook)) { $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?type=sub'.$param, '', 1, array('morecss' => 'marginleftonly')); $url = './card.php?action=create'; if (!empty($socid)) { @@ -805,9 +894,21 @@ if (empty($reshook)) { print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); +if ($massaction == 'preunlettering') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1); +} elseif ($massaction == 'predeletebookkeepingwriting') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1); +} + +//$topicmail = "Information"; +//$modelmail = "accountingbookkeeping"; +//$objecttmp = new BookKeeping($db); +//$trackid = 'bk'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { +if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } @@ -954,6 +1055,11 @@ if (!empty($arrayfields['t.date_validated']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['t.import_key']['checked'])) { + print '
'; +} // Action column print '\n"; @@ -1252,17 +1361,21 @@ while ($i < min($num, $limit)) { } } - // Action column - print '\n"; + if (!$i) { + $totalarray['nbfield']++; } } - if (empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; + + // Action column + print ''; @@ -1283,11 +1396,11 @@ print "
'; + print ''; + print ''; $searchpicto = $form->showFilterButtons(); @@ -1008,6 +1114,9 @@ if (!empty($arrayfields['t.date_export']['checked'])) { if (!empty($arrayfields['t.date_validated']['checked'])) { print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); } +if (!empty($arrayfields['t.import_key']['checked'])) { + print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +} print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "
'; - if (empty($line->date_export) && empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; + if (!empty($arrayfields['t.import_key']['checked'])) { + print ''.$obj->import_key."'; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // 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($line->id, $arrayofselected)) { + $selected = 1; } + print ''; } print '
"; print '
'; // TODO Replace this with mass delete action -if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; -} +//if ($user->rights->accounting->mouvements->supprimer_tous) { +// print '
'."\n"; +// print ''.$langs->trans("DeleteMvt").''; +// print '
'; +//} print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 837a372a32d..5650cce8767 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; @@ -39,6 +40,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$type = GETPOST('type', 'alpha'); +if ($type == 'sub') { + $context_default = 'bookkeepingbysubaccountlist'; +} else { + $context_default = 'bookkeepingbyaccountlist'; +} +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; $search_date_startyear = GETPOST('search_date_startyear', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); $search_date_startday = GETPOST('search_date_startday', 'int'); @@ -64,6 +75,7 @@ $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', ' $search_date_validation_endday = GETPOST('search_date_validation_endday', 'int'); $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); +$search_import_key = GETPOST("search_import_key", 'alpha'); $search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); @@ -109,7 +121,7 @@ if ($sortfield == "") { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new BookKeeping($db); $formfile = new FormFile($db); -$hookmanager->initHooks(array('bookkeepingbyaccountlist')); +$hookmanager->initHooks(array($context_default)); $formaccounting = new FormAccounting($db); $form = new Form($db); @@ -153,6 +165,7 @@ $arrayfields = array( 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1), + 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { @@ -187,10 +200,13 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Action */ +$param = ''; + if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') { $massaction = ''; } @@ -242,10 +258,11 @@ if (empty($reshook)) { $search_credit = ''; $search_lettering_code = ''; $search_not_reconciled = ''; + $search_import_key = ''; + $toselect = ''; } // Must be after the remove filter action, before the export. - $param = ''; $filter = array(); if (!empty($search_date_start)) { @@ -261,12 +278,20 @@ if (empty($reshook)) { $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); + if ($type == 'sub') { + $filter['t.subledger_account>='] = $search_accountancy_code_start; + } else { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + } + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); } if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); + if ($type == 'sub') { + $filter['t.subledger_account<='] = $search_accountancy_code_end; + } else { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + } + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); } if (!empty($search_label_account)) { $filter['t.label_compte'] = $search_label_account; @@ -326,61 +351,133 @@ if (empty($reshook)) { $filter['t.date_validated<='] = $search_date_validation_end; $param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear; } -} + if (!empty($search_import_key)) { + $filter['t.import_key'] = $search_import_key; + $param .= '&search_import_key='.urlencode($search_import_key); + } -if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); + // param with type of list + $url_param = substr($param, 1); // remove first "&" + if (!empty($type)) { + $param = '&type='.$type.$param; + } - if (!empty($import_key)) { - $result = $object->deleteByImportkey($import_key); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + // $delmonth = GETPOST('delmonth', 'int'); + // $delyear = GETPOST('delyear', 'int'); + // if ($delyear == -1) { + // $delyear = 0; + // } + // $deljournal = GETPOST('deljournal', 'alpha'); + // if ($deljournal == -1) { + // $deljournal = 0; + // } + // + // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { + // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + // if ($result < 0) { + // setEventMessages($object->error, $object->errors, 'errors'); + // } else { + // setEventMessages("RecordDeleted", null, 'mesgs'); + // } + // + // // Make a redirect to avoid to launch the delete later after a back button + // header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); + // exit; + // } else { + // setEventMessages("NoRecordDeleted", null, 'warnings'); + // } + //} + + // Mass actions + $objectclass = 'Bookkeeping'; + $objectlabel = 'Bookkeeping'; + $permissiontoread = $user->rights->societe->lire; + $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoadd = $user->rights->societe->creer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) { + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $object->fetch($toselectid); + if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) { + $result = $object->deleteMvtNum($object->piece_num); + if ($result > 0) { + $nbok++; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } elseif ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } } - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } -} -if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delmonth = GETPOST('delmonth', 'int'); - $delyear = GETPOST('delyear', 'int'); - if ($delyear == -1) { - $delyear = 0; - } - $deljournal = GETPOST('deljournal', 'alpha'); - if ($deljournal == -1) { - $deljournal = 0; - } - - if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { - $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages("RecordDeleted", null, 'mesgs'); + // Message for elements well deleted + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); + } elseif ($nbok > 0) { + setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + } elseif (!$error) { + setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); } - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } else { - setEventMessages("NoRecordDeleted", null, 'warnings'); - } -} -if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); - - if (!empty($mvt_num)) { - $result = $object->deleteMvtNum($mvt_num); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + if (!$error) { + header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); + exit; } + } - header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); - exit; + // others mass actions + if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + if ($massaction == 'lettering') { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } + } elseif ($action == 'unlettering' && $confirm == "yes") { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } + } } } @@ -394,73 +491,101 @@ $formfile = new FormFile($db); $formother = new FormOther($db); $form = new Form($db); -$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("Bookkeeping").')'; +$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('; +if ($type == 'sub') { + $title_page .= $langs->trans("BookkeepingSubAccount"); +} else { + $title_page .= $langs->trans("Bookkeeping"); +} +$title_page .= ')'; llxHeader('', $title_page); // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); + if ($type == 'sub') { + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + } else { + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); + } + if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } -$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); +if ($type == 'sub') { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); +} else { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); +} if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } +$arrayofselected = is_array($toselect) ? $toselect : array(); + $num = count($object->lines); -if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); - print $formconfirm; +///if ($action == 'delbookkeepingyear') { +// $form_question = array(); +// $delyear = GETPOST('delyear', 'int'); +// $deljournal = GETPOST('deljournal', 'alpha'); +// +// if (empty($delyear)) { +// $delyear = dol_print_date(dol_now(), '%Y'); +// } +// $month_array = array(); +// for ($i = 1; $i <= 12; $i++) { +// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); +// } +// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); +// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); +// +// $form_question['delmonth'] = array( +// 'name' => 'delmonth', +// 'type' => 'select', +// 'label' => $langs->trans('DelMonth'), +// 'values' => $month_array, +// 'default' => '' +// ); +// $form_question['delyear'] = array( +// 'name' => 'delyear', +// 'type' => 'select', +// 'label' => $langs->trans('DelYear'), +// 'values' => $year_array, +// 'default' => $delyear +// ); +// $form_question['deljournal'] = array( +// 'name' => 'deljournal', +// 'type' => 'other', // We don't use select here, the journal_array is already a select html component +// 'label' => $langs->trans('DelJournal'), +// 'value' => $journal_array, +// 'default' => $deljournal +// ); +// +// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); +//} + +// Print form confirm +print $formconfirm; + +// List of mass actions available +$arrayofmassactions = array(); +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + $arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering'); + $arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering'); } -if ($action == 'delbookkeepingyear') { - $form_question = array(); - $delyear = GETPOST('delyear', 'int'); - $deljournal = GETPOST('deljournal', 'alpha'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $month_array = array(); - for ($i = 1; $i <= 12; $i++) { - $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); - } - $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); - - $form_question['delmonth'] = array( - 'name' => 'delmonth', - 'type' => 'select', - 'label' => $langs->trans('DelMonth'), - 'values' => $month_array, - 'default' => '' - ); - $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - $form_question['deljournal'] = array( - 'name' => 'deljournal', - 'type' => 'other', // We don't use select here, the journal_array is already a select html component - 'label' => $langs->trans('DelJournal'), - 'value' => $journal_array, - 'default' => $deljournal - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); - print $formconfirm; +if ($user->rights->accounting->mouvements->supprimer) { + $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } - +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions); print '
'; print ''; @@ -469,15 +594,22 @@ if ($optioncss != '') { print ''; } print ''; +print ''; print ''; print ''; +print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); + if ($type == 'sub') { + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + } else { + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + } $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } @@ -488,11 +620,29 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); + +if ($massaction == 'preunlettering') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1); +} elseif ($massaction == 'predeletebookkeepingwriting') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1); +} +//DeleteMvt=Supprimer des lignes d'opérations de la comptabilité +//DelMonth=Mois à effacer +//DelYear=Année à supprimer +//DelJournal=Journal à supprimer +//ConfirmDeleteMvt=Cette action supprime les lignes des opérations pour l'année/mois et/ou pour le journal sélectionné (au moins un critère est requis). Vous devrez utiliser de nouveau la fonctionnalité '%s' pour retrouver vos écritures dans la comptabilité. +//ConfirmDeleteMvtPartial=Cette action supprime l'écriture de la comptabilité (toutes les lignes opérations liées à une même écriture seront effacées). + +//$topicmail = "Information"; +//$modelmail = "accountingbookkeeping"; +//$objecttmp = new BookKeeping($db); +//$trackid = 'bk'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { +if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } @@ -509,9 +659,17 @@ $moreforfilter = ''; $moreforfilter .= '
'; $moreforfilter .= $langs->trans('AccountAccounting').': '; $moreforfilter .= '
'; -$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200'); +if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); +} else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200'); +} $moreforfilter .= ' '; -$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200'); +if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); +} else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200'); +} $moreforfilter .= '
'; $moreforfilter .= '
'; @@ -599,6 +757,11 @@ if (!empty($arrayfields['t.date_validated']['checked'])) { print '
'; print ''; } +if (!empty($arrayfields['t.import_key']['checked'])) { + print ''; + print ''; + print ''; +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -643,6 +806,9 @@ if (!empty($arrayfields['t.date_export']['checked'])) { if (!empty($arrayfields['t.date_validated']['checked'])) { print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); } +if (!empty($arrayfields['t.import_key']['checked'])) { + print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +} // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -667,7 +833,11 @@ while ($i < min($num, $limit)) { $total_debit += $line->debit; $total_credit += $line->credit; - $accountg = length_accountg($line->numero_compte); + if ($type == 'sub') { + $accountg = length_accounta($line->subledger_account); + } else { + $accountg = length_accountg($line->numero_compte); + } //if (empty($accountg)) $accountg = '-'; $colspan = 0; // colspan before field 'label of operation' @@ -686,7 +856,11 @@ while ($i < min($num, $limit)) { // Show a subtotal by accounting account if (isset($displayed_account_number)) { print ''; - print ''.$langs->trans("TotalForAccount").' '.length_accountg($displayed_account_number).':'; + if ($type == 'sub') { + print '' . $langs->trans("TotalForAccount") . ' ' . length_accounta($displayed_account_number) . ':'; + } else { + print '' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':'; + } print ''.price($sous_total_debit).''; print ''.price($sous_total_credit).''; print ''; @@ -712,11 +886,28 @@ while ($i < min($num, $limit)) { // Show the break account print ''; - print ''; - if ($line->numero_compte != "" && $line->numero_compte != '-1') { - print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); + print ''; + if ($type == 'sub') { + if ($line->subledger_account != "" && $line->subledger_account != '-1') { + print $line->subledger_label . ' : ' . length_accounta($line->subledger_account); + } else { + // Should not happen: subledger account must be null or a non empty value + print '' . $langs->trans("Unknown"); + if ($line->subledger_label) { + print ' (' . $line->subledger_label . ')'; + $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined'; + } else { + $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel'; + } + print $form->textwithpicto('', $htmltext); + print ''; + } } else { - print ''.$langs->trans("Unknown").''; + if ($line->numero_compte != "" && $line->numero_compte != '-1') { + print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte); + } else { + print '' . $langs->trans("Unknown") . ''; + } } print ''; print ''; @@ -890,22 +1081,26 @@ while ($i < min($num, $limit)) { } } + if (!empty($arrayfields['t.import_key']['checked'])) { + print ''.$line->import_key."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$line); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (empty($line->date_export) && empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; - } - } - if (empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // 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($line->id, $arrayofselected)) { + $selected = 1; } + print ''; } print ''; if (!$i) { @@ -955,11 +1150,11 @@ print ""; print '
'; // TODO Replace this with mass delete action -if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; -} +//if ($user->rights->accounting->mouvements->supprimer_tous) { +// print '
'."\n"; +// print ''.$langs->trans("DeleteMvt").''; +// print '
'; +//} print ''; diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php deleted file mode 100644 index c6fb95d5ab7..00000000000 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ /dev/null @@ -1,979 +0,0 @@ - - * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2020 Florian Henry - * Copyright (C) 2013-2021 Alexandre Spangaro - * Copyright (C) 2018-2020 Frédéric France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/accountancy/bookkeeping/listbysubaccount.php - * \ingroup Accountancy (Double entries) - * \brief List operation of ledger ordered by subaccount number - */ - -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("accountancy", "compta")); - -$action = GETPOST('action', 'aZ09'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); -$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); -$search_date_export_startyear = GETPOST('search_date_export_startyear', 'int'); -$search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int'); -$search_date_export_startday = GETPOST('search_date_export_startday', 'int'); -$search_date_export_endyear = GETPOST('search_date_export_endyear', 'int'); -$search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int'); -$search_date_export_endday = GETPOST('search_date_export_endday', 'int'); -$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); -$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); -$search_date_validation_startyear = GETPOST('search_date_validation_startyear', 'int'); -$search_date_validation_startmonth = GETPOST('search_date_validation_startmonth', 'int'); -$search_date_validation_startday = GETPOST('search_date_validation_startday', 'int'); -$search_date_validation_endyear = GETPOST('search_date_validation_endyear', 'int'); -$search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', 'int'); -$search_date_validation_endday = GETPOST('search_date_validation_endday', 'int'); -$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); -$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); - -$search_accountancy_code = GETPOST("search_accountancy_code"); -$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); -if ($search_accountancy_code_start == - 1) { - $search_accountancy_code_start = ''; -} -$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); -if ($search_accountancy_code_end == - 1) { - $search_accountancy_code_end = ''; -} -$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); -$search_label_operation = GETPOST('search_label_operation', 'alpha'); -$search_mvt_num = GETPOST('search_mvt_num', 'int'); -$search_direction = GETPOST('search_direction', 'alpha'); -$search_ledger_code = GETPOST('search_ledger_code', 'array'); -$search_debit = GETPOST('search_debit', 'alpha'); -$search_credit = GETPOST('search_credit', 'alpha'); -$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); -$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); - -if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { - $action = 'delbookkeepingyear'; -} - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0) { - $page = 0; -} -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if ($sortorder == "") { - $sortorder = "ASC"; -} -if ($sortfield == "") { - $sortfield = "t.doc_date,t.rowid"; -} - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$object = new BookKeeping($db); -$formfile = new FormFile($db); -$hookmanager->initHooks(array('bookkeepingbysubaccountlist')); - -$formaccounting = new FormAccounting($db); -$form = new Form($db); - -if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; - $sql .= $db->plimit(1); - $res = $db->query($sql); - - if ($res->num_rows > 0) { - $fiscalYear = $db->fetch_object($res); - $search_date_start = strtotime($fiscalYear->date_start); - $search_date_end = strtotime($fiscalYear->date_end); - } else { - $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); - $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) { - $year_start--; // If current month is lower that starting fiscal month, we start last year - } - $year_end = $year_start + 1; - $month_end = $month_start - 1; - if ($month_end < 1) { - $month_end = 12; - $year_end--; - } - $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); - $search_date_end = dol_get_last_day($year_end, $month_end); - } -} - -$arrayfields = array( - // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), - 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), - 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), - 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), - 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), - 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), - 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), - 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), - 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1), -); - -if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { - unset($arrayfields['t.lettering_code']); -} - -if ($search_date_start && empty($search_date_startyear)) { - $tmparray = dol_getdate($search_date_start); - $search_date_startyear = $tmparray['year']; - $search_date_startmonth = $tmparray['mon']; - $search_date_startday = $tmparray['mday']; -} -if ($search_date_end && empty($search_date_endyear)) { - $tmparray = dol_getdate($search_date_end); - $search_date_endyear = $tmparray['year']; - $search_date_endmonth = $tmparray['mon']; - $search_date_endday = $tmparray['mday']; -} - -if (empty($conf->accounting->enabled)) { - accessforbidden(); -} -if ($user->socid > 0) { - accessforbidden(); -} -if (empty($user->rights->accounting->mouvements->lire)) { - accessforbidden(); -} - - -/* - * Action - */ - -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} - -$parameters = array('socid'=>$socid); -$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)) { - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - 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 - $search_doc_date = ''; - $search_accountancy_code = ''; - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_label_account = ''; - $search_doc_ref = ''; - $search_label_operation = ''; - $search_mvt_num = ''; - $search_direction = ''; - $search_ledger_code = array(); - $search_date_start = ''; - $search_date_end = ''; - $search_date_startyear = ''; - $search_date_startmonth = ''; - $search_date_startday = ''; - $search_date_endyear = ''; - $search_date_endmonth = ''; - $search_date_endday = ''; - $search_date_export_start = ''; - $search_date_export_end = ''; - $search_date_export_startyear = ''; - $search_date_export_startmonth = ''; - $search_date_export_startday = ''; - $search_date_export_endyear = ''; - $search_date_export_endmonth = ''; - $search_date_export_endday = ''; - $search_date_validation_start = ''; - $search_date_validation_end = ''; - $search_date_validation_startyear = ''; - $search_date_validation_startmonth = ''; - $search_date_validation_startday = ''; - $search_date_validation_endyear = ''; - $search_date_validation_endmonth = ''; - $search_date_validation_endday = ''; - $search_debit = ''; - $search_credit = ''; - $search_lettering_code = ''; - $search_not_reconciled = ''; - } - - // Must be after the remove filter action, before the export. - $param = ''; - $filter = array(); - - if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear; - } - if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear; - } - if (!empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); - } - if (!empty($search_accountancy_code_start)) { - $filter['t.subledger_account>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); - } - if (!empty($search_accountancy_code_end)) { - $filter['t.subledger_account<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); - } - if (!empty($search_label_account)) { - $filter['t.label_compte'] = $search_label_account; - $param .= '&search_label_compte='.urlencode($search_label_account); - } - if (!empty($search_mvt_num)) { - $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); - } - if (!empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref='.urlencode($search_doc_ref); - } - if (!empty($search_label_operation)) { - $filter['t.label_operation'] = $search_label_operation; - $param .= '&search_label_operation='.urlencode($search_label_operation); - } - if (!empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $param .= '&search_direction='.urlencode($search_direction); - } - if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - foreach ($search_ledger_code as $code) { - $param .= '&search_ledger_code[]='.urlencode($code); - } - } - if (!empty($search_debit)) { - $filter['t.debit'] = $search_debit; - $param .= '&search_debit='.urlencode($search_debit); - } - if (!empty($search_credit)) { - $filter['t.credit'] = $search_credit; - $param .= '&search_credit='.urlencode($search_credit); - } - if (!empty($search_lettering_code)) { - $filter['t.lettering_code'] = $search_lettering_code; - $param .= '&search_lettering_code='.urlencode($search_lettering_code); - } - if (!empty($search_not_reconciled)) { - $filter['t.reconciled_option'] = $search_not_reconciled; - $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); - } - if (!empty($search_date_export_start)) { - $filter['t.date_export>='] = $search_date_export_start; - $param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear; - } - if (!empty($search_date_export_end)) { - $filter['t.date_export<='] = $search_date_export_end; - $param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear; - } - if (!empty($search_date_validation_start)) { - $filter['t.date_validated>='] = $search_date_validation_start; - $param .= '&search_date_validation_startmonth='.$search_date_validation_startmonth.'&search_date_validation_startday='.$search_date_validation_startday.'&search_date_validation_startyear='.$search_date_validation_startyear; - } - if (!empty($search_date_validation_end)) { - $filter['t.date_validated<='] = $search_date_validation_end; - $param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear; - } -} - -if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); - - if (!empty($import_key)) { - $result = $object->deleteByImportkey($import_key); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } -} -if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delmonth = GETPOST('delmonth', 'int'); - $delyear = GETPOST('delyear', 'int'); - if ($delyear == -1) { - $delyear = 0; - } - $deljournal = GETPOST('deljournal', 'alpha'); - if ($deljournal == -1) { - $deljournal = 0; - } - - if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { - $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages("RecordDeleted", null, 'mesgs'); - } - - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } else { - setEventMessages("NoRecordDeleted", null, 'warnings'); - } -} -if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); - - if (!empty($mvt_num)) { - $result = $object->deleteMvtNum($mvt_num); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } - - header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); - exit; - } -} - - -/* - * View - */ - -$formaccounting = new FormAccounting($db); -$formfile = new FormFile($db); -$formother = new FormOther($db); -$form = new Form($db); - -$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("BookkeepingSubAccount").')'; - -llxHeader('', $title_page); - -// List -$nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); - if ($nbtotalofrecords < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); - -if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); -} - -$num = count($object->lines); - - -if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); - print $formconfirm; -} -if ($action == 'delbookkeepingyear') { - $form_question = array(); - $delyear = GETPOST('delyear', 'int'); - $deljournal = GETPOST('deljournal', 'alpha'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $month_array = array(); - for ($i = 1; $i <= 12; $i++) { - $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); - } - $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); - - $form_question['delmonth'] = array( - 'name' => 'delmonth', - 'type' => 'select', - 'label' => $langs->trans('DelMonth'), - 'values' => $month_array, - 'default' => '' - ); - $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - $form_question['deljournal'] = array( - 'name' => 'deljournal', - 'type' => 'other', // We don't use select here, the journal_array is already a select html component - 'label' => $langs->trans('DelJournal'), - 'value' => $journal_array, - 'default' => $deljournal - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); - print $formconfirm; -} - - -print '
'; -print ''; -print ''; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; - -$parameters = array(); -$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); -} - -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); -} - -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); - -print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); -} - -// Reverse sort order -if (preg_match('/^asc/i', $sortorder)) { - $sortorder = "asc"; -} else { - $sortorder = "desc"; -} - -$moreforfilter = ''; - -// Accountancy account -$moreforfilter .= '
'; -$moreforfilter .= $langs->trans('AccountAccounting').': '; -$moreforfilter .= '
'; -$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); -$moreforfilter .= ' '; -$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); -$moreforfilter .= '
'; -$moreforfilter .= '
'; - -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -print '
'; -print $moreforfilter; -print '
'; - -print '
'; -print ''; - -// Filters lines -print ''; - -// Movement number -if (!empty($arrayfields['t.piece_num']['checked'])) { - print ''; -} -// Code journal -if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; -} -// Date document -if (!empty($arrayfields['t.doc_date']['checked'])) { - print ''; -} -// Ref document -if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''; -} -// Label operation -if (!empty($arrayfields['t.label_operation']['checked'])) { - print ''; -} -// Debit -if (!empty($arrayfields['t.debit']['checked'])) { - print ''; -} -// Credit -if (!empty($arrayfields['t.credit']['checked'])) { - print ''; -} -// Lettering code -if (!empty($arrayfields['t.lettering_code']['checked'])) { - print ''; -} -// Date export -if (!empty($arrayfields['t.date_export']['checked'])) { - print ''; -} -// Date validation -if (!empty($arrayfields['t.date_validated']['checked'])) { - print ''; -} - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -// Action column -print ''; -print "\n"; - -print ''; -if (!empty($arrayfields['t.piece_num']['checked'])) { - print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); -} -if (!empty($arrayfields['t.code_journal']['checked'])) { - print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.doc_date']['checked'])) { - print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.doc_ref']['checked'])) { - print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['t.label_operation']['checked'])) { - print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['t.debit']['checked'])) { - print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); -} -if (!empty($arrayfields['t.credit']['checked'])) { - print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); -} -if (!empty($arrayfields['t.lettering_code']['checked'])) { - print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.date_export']['checked'])) { - print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.date_validated']['checked'])) { - print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); -} -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); -print "\n"; - - -$total_debit = 0; -$total_credit = 0; -$sous_total_debit = 0; -$sous_total_credit = 0; -$displayed_account_number = null; // Start with undefined to be able to distinguish with empty - -// Loop on record -// -------------------------------------------------------------------- -$i = 0; -$totalarray = array(); -while ($i < min($num, $limit)) { - $line = $object->lines[$i]; - - $total_debit += $line->debit; - $total_credit += $line->credit; - - $accountg = length_accounta($line->subledger_account); - //if (empty($accountg)) $accountg = '-'; - - $colspan = 0; // colspan before field 'label of operation' - $colspanend = 3; // colspan after debit/credit - if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; } - if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; } - if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; } - - // Is it a break ? - if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - // Show a subtotal by accounting account - if (isset($displayed_account_number)) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - // Show balance of last shown account - $balance = $sous_total_debit - $sous_total_credit; - print ''; - print ''; - if ($balance > 0) { - print ''; - print ''; - } else { - print ''; - print ''; - } - print ''; - print ''; - } - - // Show the break account - print ''; - print ''; - print ''; - - $displayed_account_number = $accountg; - //if (empty($displayed_account_number)) $displayed_account_number='-'; - $sous_total_debit = 0; - $sous_total_credit = 0; - - $colspan = 0; - } - - print ''; - - // Piece number - if (!empty($arrayfields['t.piece_num']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Journal code - if (!empty($arrayfields['t.code_journal']['checked'])) { - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Document date - if (!empty($arrayfields['t.doc_date']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Document ref - if (!empty($arrayfields['t.doc_ref']['checked'])) { - if ($line->doc_type == 'customer_invoice') { - $langs->loadLangs(array('bills')); - - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $objectstatic = new Facture($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'facture'; - - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } elseif ($line->doc_type == 'supplier_invoice') { - $langs->loadLangs(array('bills')); - - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $objectstatic = new FactureFournisseur($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'invoice_supplier'; - - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); - } elseif ($line->doc_type == 'expense_report') { - $langs->loadLangs(array('trips')); - - require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $objectstatic = new ExpenseReport($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'expensereport'; - - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } elseif ($line->doc_type == 'bank') { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $objectstatic = new AccountLine($db); - $objectstatic->fetch($line->fk_doc); - } else { - // Other type - } - - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label operation - if (!empty($arrayfields['t.label_operation']['checked'])) { - // Affiche un lien vers la facture client/fournisseur - $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount debit - if (!empty($arrayfields['t.debit']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; - } - $totalarray['val']['totaldebit'] += $line->debit; - } - - // Amount credit - if (!empty($arrayfields['t.credit']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; - } - $totalarray['val']['totalcredit'] += $line->credit; - } - - // Lettering code - if (!empty($arrayfields['t.lettering_code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Exported operation date - if (!empty($arrayfields['t.date_export']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Validated operation date - if (!empty($arrayfields['t.date_validated']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action column - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; - - print "\n"; - - $i++; -} - -if ($num > 0 && $colspan > 0) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - // Show balance of last shown account - $balance = $sous_total_debit - $sous_total_credit; - print ''; - print ''; - if ($balance > 0) { - print ''; - print ''; - } else { - print ''; - print ''; - } - print ''; - print ''; -} - -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - - -print "
'; - print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); - print ''; - print '
'; - print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; - print ''; - print '
'.$langs->trans("NotReconciled").''; - print '
'; - print '
'; - print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print '
'.$langs->trans("TotalForAccount").' '.length_accounta($displayed_account_number).':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); - print ''; - print price($sous_total_credit - $sous_total_debit); - print '
'; - if ($line->subledger_account != "" && $line->subledger_account != '-1') { - print $line->subledger_label.' : '.length_accounta($line->subledger_account); - } else { - // Should not happen: subledger account must be null or a non empty value - print ''.$langs->trans("Unknown"); - if ($line->subledger_label) { - print ' ('.$line->subledger_label.')'; - $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined'; - } else { - $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel'; - } - print $form->textwithpicto('', $htmltext); - print ''; - } - print '
'; - $object->id = $line->id; - $object->piece_num = $line->piece_num; - print $object->getNomUrl(1, '', 0, '', 1); - print ''.$journaltoshow.''.dol_print_date($line->doc_date, 'day').''; - - print ''; - // Picto + Ref - print '
'; - - if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { - print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - print $documentlink; - } elseif ($line->doc_type == 'bank') { - print $objectstatic->getNomUrl(1); - $bank_ref = strstr($line->doc_ref, '-'); - print " " . $bank_ref; - } else { - print $line->doc_ref; - } - print '
'; - - print "
'.$line->label_operation.''.$line->label_operation.'
('.length_accounta($line->subledger_account).')
'.($line->debit ? price($line->debit) : '').''.($line->credit ? price($line->credit) : '').''.$line->lettering_code.''.dol_print_date($line->date_export, 'dayhour').''.dol_print_date($line->date_validation, 'dayhour').''; - if (empty($line->date_export) && empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; - } - } - if (empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; - } - } - print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); - print ''; - print price($sous_total_credit - $sous_total_debit); - print '
"; -print '
'; - -// TODO Replace this with mass delete action -if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; -} - -print '
'; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a83a311010d..21b723b003b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -852,7 +852,8 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; $sql .= " t.date_export,"; - $sql .= " t.date_validated as date_validation"; + $sql .= " t.date_validated as date_validation,"; + $sql .= " t.import_key"; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -947,6 +948,7 @@ class BookKeeping extends CommonObject $line->date_creation = $this->db->jdate($obj->date_creation); $line->date_export = $this->db->jdate($obj->date_export); $line->date_validation = $this->db->jdate($obj->date_validation); + $line->import_key = $obj->import_key; $this->lines[] = $line; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index f722a716b79..a31a4675851 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -33,6 +33,12 @@ include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class Lettering extends BookKeeping { + /** + * @var BookKeeping[] Bookkeeping cached + */ + public static $bookkeeping_cached = array(); + + /** * letteringThirdparty * @@ -119,6 +125,7 @@ class Lettering extends BookKeeping $ids[$obj2->rowid] = $obj2->rowid; $ids_fact[] = $obj2->fact_id; } + $this->db->free($resql2); } else { $this->errors[] = $this->db->lasterror; return -1; @@ -146,6 +153,7 @@ class Lettering extends BookKeeping while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; } + $this->db->free($resql2); } else { $this->errors[] = $this->db->lasterror; return -1; @@ -205,6 +213,7 @@ class Lettering extends BookKeeping while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; } + $this->db->free($resql2); } else { $this->errors[] = $this->db->lasterror; return -1; @@ -216,6 +225,7 @@ class Lettering extends BookKeeping $result = $this->updateLettering($ids); } } + $this->db->free($resql); } if ($error) { foreach ($this->errors as $errmsg) { @@ -230,17 +240,31 @@ class Lettering extends BookKeeping /** * - * @param array $ids ids array - * @param boolean $notrigger no trigger - * @return number + * @param array $ids ids array + * @param boolean $notrigger no trigger + * @return int */ public function updateLettering($ids = array(), $notrigger = false) { $error = 0; $lettre = 'AAA'; - $sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; - $sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1"; + $sql = "SELECT DISTINCT ab2.lettering_code" . + " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping As ab" . + " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc" . + " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu2 ON bu2.url_id = bu.url_id" . + " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.fk_doc = bu2.fk_bank" . + " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")" . + " AND ab.doc_type = 'bank'" . + " AND ab2.doc_type = 'bank'" . + " AND bu.type = 'company'" . + " AND bu2.type = 'company'" . + " AND ab.subledger_account != ''" . + " AND ab2.subledger_account != ''" . + " AND ab.lettering_code IS NULL" . + " AND ab2.lettering_code != ''" . + " ORDER BY ab2.lettering_code DESC" . + " LIMIT 1 "; $result = $this->db->query($sql); if ($result) { @@ -249,13 +273,14 @@ class Lettering extends BookKeeping if (!empty($obj->lettering_code)) { $lettre++; } + $this->db->free($result); } else { $this->errors[] = 'Error'.$this->db->lasterror(); $error++; } $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; - $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL"; + $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -263,6 +288,7 @@ class Lettering extends BookKeeping $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2); $error++; } + $this->db->free($result); } else { $this->errors[] = 'Erreur sql'.$this->db->lasterror(); $error++; @@ -276,8 +302,7 @@ class Lettering extends BookKeeping $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; $sql .= " lettering_code='".$this->db->escape($lettre)."'"; $sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false - $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL "; - $this->db->begin(); + $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -293,11 +318,422 @@ class Lettering extends BookKeeping dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } - $this->db->rollback(); return -1 * $error; } else { - $this->db->commit(); return 1; } } + + /** + * + * @param array $ids ids array + * @param boolean $notrigger no trigger + * @return int + */ + public function deleteLettering($ids, $notrigger = false) + { + $error = 0; + + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; + $sql .= " lettering_code = NULL"; + $sql .= " , date_lettering = NULL"; + $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).")"; + $sql .= " AND subledger_account != ''"; + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } + + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + return -1 * $error; + } else { + return 1; + } + } + + /** + * Lettering bookkeeping lines all types + * + * @param array $bookkeeping_ids Lettering specific list of bookkeeping id + * @param bool $unlettering Do unlettering + * @return int <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered) + */ + public function bookkeepingLetteringAll($bookkeeping_ids, $unlettering = false) + { + dol_syslog(__METHOD__ . " - ", LOG_DEBUG); + + $error = 0; + $errors = array(); + $nb_lettering = 0; + + $result = $this->bookkeepingLettering($bookkeeping_ids, 'customer_invoice', $unlettering); + if ($result < 0) { + $error++; + $errors = array_merge($errors, $this->errors); + $nb_lettering += abs($result) - 2; + } else { + $nb_lettering += $result; + } + + $result = $this->bookkeepingLettering($bookkeeping_ids, 'supplier_invoice', $unlettering); + if ($result < 0) { + $error++; + $errors = array_merge($errors, $this->errors); + $nb_lettering += abs($result) - 2; + } else { + $nb_lettering += $result; + } + + if ($error) { + $this->errors = $errors; + return -2 - $nb_lettering; + } else { + return $nb_lettering; + } + } + + /** + * Lettering bookkeeping lines + * + * @param array $bookkeeping_ids Lettering specific list of bookkeeping id + * @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice') + * @param bool $unlettering Do unlettering + * @return int <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered) + */ + public function bookkeepingLettering($bookkeeping_ids, $type = 'customer_invoice', $unlettering = false) + { + global $langs; + + $this->errors = array(); + + // Clean parameters + $bookkeeping_ids = is_array($bookkeeping_ids) ? $bookkeeping_ids : array(); + $type = trim($type); + + $error = 0; + $nb_lettering = 0; + $grouped_lines = $this->getLinkedLines($bookkeeping_ids, $type); + foreach ($grouped_lines as $lines) { + $group_error = 0; + $total = 0; + $do_it = !$unlettering; + $lettering_code = null; + $piece_num_lines = array(); + $bookkeeping_lines = array(); + foreach ($lines as $line_infos) { + $bookkeeping_lines[$line_infos['id']] = $line_infos['id']; + $piece_num_lines[$line_infos['piece_num']] = $line_infos['piece_num']; + $total += ($line_infos['credit'] > 0 ? $line_infos['credit'] : -$line_infos['debit']); + + // Check lettering code + if ($unlettering) { + if (isset($lettering_code) && $lettering_code != $line_infos['lettering_code']) { + $this->errors[] = $langs->trans('AccountancyErrorMismatchLetteringCode'); + $group_error++; + break; + } + if (!isset($lettering_code)) $lettering_code = (string)$line_infos['lettering_code']; + if (!empty($line_infos['lettering_code'])) $do_it = true; + } elseif (!empty($line_infos['lettering_code'])) $do_it = false; + } + + // Check balance amount + if (!$group_error && !$unlettering && price2num($total) != 0) { + $this->errors[] = $langs->trans('AccountancyErrorMismatchBalanceAmount', $total); + $group_error++; + } + + // Lettering/Unlettering the group of bookkeeping lines + if (!$group_error && $do_it) { + if ($unlettering) $result = $this->deleteLettering($bookkeeping_lines); + else $result = $this->updateLettering($bookkeeping_lines); + if ($result < 0) { + $group_error++; + } else { + $nb_lettering++; + } + } + + if ($group_error) { + $this->errors[] = $langs->trans('AccountancyErrorLetteringBookkeeping', implode(', ', $piece_num_lines)); + $error++; + } + } + + if ($error) { + return -2 - $nb_lettering; + } else { + return $nb_lettering; + } + } + + /** + * Lettering bookkeeping lines + * + * @param array $bookkeeping_ids Lettering specific list of bookkeeping id + * @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice') + * @return array|int <0 if error otherwise all linked lines by block + */ + public function getLinkedLines($bookkeeping_ids, $type = 'customer_invoice') + { + global $conf, $langs; + $this->errors = array(); + + // Clean parameters + $bookkeeping_ids = is_array($bookkeeping_ids) ? $bookkeeping_ids : array(); + $type = trim($type); + + if ($type == 'customer_invoice') { + $doc_type = 'customer_invoice'; + $bank_url_type = 'payment'; + $payment_element = 'paiement_facture'; + $fk_payment_element = 'fk_paiement'; + $fk_element = 'fk_facture'; + $account_number = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + } elseif ($type == 'supplier_invoice') { + $doc_type = 'supplier_invoice'; + $bank_url_type = 'payment_supplier'; + $payment_element = 'paiementfourn_facturefourn'; + $fk_payment_element = 'fk_paiementfourn'; + $fk_element = 'fk_facturefourn'; + $account_number = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + } else { + $langs->load('errors'); + $this->errors[] = $langs->trans('ErrorBadParameters'); + return -1; + } + + $payment_ids = array(); + + // Get all payment id from bank lines + $sql = "SELECT DISTINCT bu.url_id AS payment_id" . + " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab" . + " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc" . + " WHERE ab.doc_type = 'bank'" . + // " AND ab.subledger_account != ''" . + // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . + " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; + if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; + + dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $payment_ids[$obj->payment_id] = $obj->payment_id; + } + $this->db->free($resql); + + // Get all payment id from payment lines + $sql = "SELECT DISTINCT pe.$fk_payment_element AS payment_id" . + " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab" . + " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe ON pe.$fk_element = ab.fk_doc" . + " WHERE ab.doc_type = '" . $this->db->escape($doc_type) . "'" . + // " AND ab.subledger_account != ''" . + // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . + " AND pe.$fk_payment_element IS NOT NULL"; + if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; + + dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $payment_ids[$obj->payment_id] = $obj->payment_id; + } + $this->db->free($resql); + + if (empty($payment_ids)) { + return array(); + } + + // Get all payments linked by group + $payment_by_group = $this->getLinkedPaymentByGroup($payment_ids, $type); + + $groups = array(); + foreach ($payment_by_group as $payment_list) { + $lines = array(); + + // Get bank lines + $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit" . + " FROM " . MAIN_DB_PREFIX . "bank_url AS bu" . + " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = bu.fk_bank" . + " WHERE bu.url_id IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")" . + " AND bu.type = '" . $this->db->escape($bank_url_type) . "'" . + " AND ab.doc_type = 'bank'" . + " AND ab.subledger_account != ''" . + " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + + dol_syslog(__METHOD__ . " - Get bank lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $lines[$obj->rowid] = array('id' => $obj->rowid, 'piece_num' => $obj->piece_num, 'lettering_code' => $obj->lettering_code, 'debit' => $obj->debit, 'credit' => $obj->credit); + } + $this->db->free($resql); + + // Get payment lines + $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit" . + " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe" . + " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = pe.$fk_element" . + " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")" . + " AND ab.doc_type = '" . $this->db->escape($doc_type) . "'" . + " AND ab.subledger_account != ''" . + " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + + dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $lines[$obj->rowid] = array('id' => $obj->rowid, 'piece_num' => $obj->piece_num, 'lettering_code' => $obj->lettering_code, 'debit' => $obj->debit, 'credit' => $obj->credit); + } + $this->db->free($resql); + + if (!empty($lines)) { + $groups[] = $lines; + } + } + + return $groups; + } + + public function getLinkedPaymentByGroup($payment_ids, $type) + { + global $langs; + + // Clean parameters + $payment_ids = is_array($payment_ids) ? $payment_ids : array(); + $type = trim($type); + + if (empty($payment_ids)) { + return array(); + } + + if ($type == 'customer_invoice') { + $payment_element = 'paiement_facture'; + $fk_payment_element = 'fk_paiement'; + $fk_element = 'fk_facture'; + } elseif ($type == 'supplier_invoice') { + $payment_element = 'paiementfourn_facturefourn'; + $fk_payment_element = 'fk_paiementfourn'; + $fk_element = 'fk_facturefourn'; + } else { + $langs->load('errors'); + $this->errors[] = $langs->trans('ErrorBadParameters'); + return -1; + } + + // Get payment lines + $sql = "SELECT DISTINCT pe2.$fk_payment_element, pe2.$fk_element" . + " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe" . + " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe2 ON pe2.$fk_element = pe.$fk_element" . + " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_ids)) . ")"; + + dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + $current_payment_ids = array(); + $payment_by_element = array(); + $element_by_payment = array(); + while ($obj = $this->db->fetch_object($resql)) { + $current_payment_ids[$obj->$fk_payment_element] = $obj->$fk_payment_element; + $element_by_payment[$obj->$fk_payment_element][$obj->$fk_element] = $obj->$fk_element; + $payment_by_element[$obj->$fk_element][$obj->$fk_payment_element] = $obj->$fk_payment_element; + } + $this->db->free($resql); + + if (count(array_diff($payment_ids, $current_payment_ids))) { + return $this->getLinkedPaymentByGroup($current_payment_ids, $type); + } + + return $this->getGroupElements($payment_by_element, $element_by_payment); + } + + /** + * Get payment ids grouped by payment id and element id in common + * + * @param array &$payment_by_element List of payment ids by element id + * @param array &$element_by_payment List of element ids by payment id + * @param int $element_id Element Id (used for recursive function) + * @param array &$current_group Current group (used for recursive function) + * @return array List of payment ids grouped by payment id and element id in common + */ + public function getGroupElements(&$payment_by_element, &$element_by_payment, $element_id = 0, &$current_group = array()) + { + $grouped_payments = array(); + if ($element_id > 0 && !isset($payment_by_element[$element_id])) { + // Return if specific element id not found + return $grouped_payments; + } + + if ($element_id == 0) { + // Save list when is the begin of recursive function + $save_payment_by_element = $payment_by_element; + $save_element_by_payment = $element_by_payment; + } + + do { + // Get current element id, get this payment id list and delete the entry + $current_element_id = $element_id > 0 ? $element_id : array_keys($payment_by_element)[0]; + $payment_ids = $payment_by_element[$current_element_id]; + unset($payment_by_element[$current_element_id]); + + foreach ($payment_ids as $payment_id) { + // Continue if payment id in not found + if (!isset($element_by_payment[$payment_id])) continue; + + // Set the payment in the current group + $current_group[$payment_id] = $payment_id; + + // Get current element ids, get this payment id list and delete the entry + $element_ids = $element_by_payment[$payment_id]; + unset($element_by_payment[$payment_id]); + + // Set payment id on the current group for each element id of the payment + foreach ($element_ids as $id) { + $this->getGroupElements($payment_by_element, $element_by_payment, $id, $current_group); + } + } + + if ($element_id == 0) { + // Save current group and reset the current group when is the begin of recursive function + $grouped_payments[] = $current_group; + $current_group = array(); + } + } while(!empty($payment_by_element) && $element_id == 0); + + if ($element_id == 0) { + // Restore list when is the begin of recursive function + $payment_by_element = $save_payment_by_element; + $element_by_payment = $save_element_by_payment; + } + + return $grouped_payments; + } } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4841b8bf171..8a02ac3849a 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -665,6 +665,8 @@ if (!$error && $action == 'writebookkeeping') { // Line into thirdparty account foreach ($tabtp[$key] as $k => $mt) { if ($mt) { + $lettering = false; + $reflabel = ''; if (!empty($val['lib'])) { $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); @@ -693,11 +695,13 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->date_creation = $now; if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice + $lettering = true; $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->label_compte = $accountingaccountcustomer->label; } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice + $lettering = true; $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; @@ -780,6 +784,12 @@ if (!$error && $action == 'writebookkeeping') { $errorforline++; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } + } else { + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; + $lettering_static = new Lettering($db); + $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); + } } } } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 8b1ac0d3de3..7c0a8b90f7d 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -377,6 +377,12 @@ if ($action == 'writebookkeeping') { $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } + } else { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; + $lettering_static = new Lettering($db); + $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'supplier_invoice'); + } } } } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 7a5ccd79b21..7cc7f0effbc 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -390,6 +390,12 @@ if ($action == 'writebookkeeping') { $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } + } else { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; + $lettering_static = new Lettering($db); + $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'customer_invoice'); + } } } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index fd5ff8461fe..b3088e4427e 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -395,6 +395,21 @@ Range=Range of accounting account Calculated=Calculated Formula=Formula +## Reconcile +Unlettering=Unreconcile +AccountancyNoLetteringModified=No reconcile modified +AccountancyOneLetteringModifiedSuccessfully=One reconcile successfully modified +AccountancyLetteringModifiedSuccessfully=%s reconcile successfully modified +AccountancyNoUnletteringModified=No unreconcile modified +AccountancyOneUnletteringModifiedSuccessfully=One unreconcile successfully modified +AccountancyUnletteringModifiedSuccessfully=%s unreconcile successfully modified + +## Confirm box +ConfirmMassUnlettering=Bulk Unreconcile confirmation +ConfirmMassUnletteringQuestion=Are you sure you want to Unreconcile the %s selected record(s)? +ConfirmMassDeleteBookkeepingWriting=Bulk Delete confirmation +ConfirmMassDeleteBookkeepingWritingQuestion=This will delete the transaction from the accounting (all lines related to the same transaction will be deleted) Are you sure you want to delete the %s selected record(s)? + ## Error SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) @@ -407,6 +422,9 @@ Binded=Lines bound ToBind=Lines to bind UseMenuToSetBindindManualy=Lines not yet bound, use menu %s to make the binding manually SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices=Sorry this module is not compatible with the experimental feature of situation invoices +AccountancyErrorMismatchLetterCode=Mismatch in reconcile code +AccountancyErrorMismatchBalanceAmount=The balance (%s) is not equal to 0 +AccountancyErrorLetteringBookkeeping=Errors have occurred concerning the transactions: %s ## Import ImportAccountingEntries=Accounting entries From 0c8a6bd6f017bfe2ab899fa74f71659df437392d Mon Sep 17 00:00:00 2001 From: melina Date: Thu, 28 Apr 2022 08:39:02 +0200 Subject: [PATCH 572/752] fix commit --- htdocs/takepos/ajax/ajax.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 9afde9ba341..0de7cb857a6 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -218,7 +218,7 @@ if ($action == 'getProducts') { // Add tables from hooks $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); + $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); $sql .= $hookmanager->resPrint; $sql .= ' WHERE entity IN ('.getEntity('product').')'; @@ -229,7 +229,7 @@ if ($action == 'getProducts') { $sql .= natural_search(array('ref', 'label', 'barcode'), $term); // Add where from hooks $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); + $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); $sql .= $hookmanager->resPrint; $resql = $db->query($sql); @@ -269,9 +269,11 @@ if ($action == 'getProducts') { ); // Add entries to row from hooks $parameters=array(); - $parameters['row'] = end($rows); + $parameters['row'] = $row; $parameters['obj'] = $obj; - $reshook=$hookmanager->executeHooks('completeAjaxReturnArray', $parameters); + $hookmanager->executeHooks('completeAjaxReturnArray', $parameters); + if (!empty($hookmanager->resArray)) $row = $hookmanager->resArray; + $rows[] = $row; } echo json_encode($rows); } else { From f634d7e50384faa0a1df4bd4f2eacb0fb97f7814 Mon Sep 17 00:00:00 2001 From: melina Date: Thu, 28 Apr 2022 08:42:44 +0200 Subject: [PATCH 573/752] fix commit --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 0de7cb857a6..13956794f18 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -254,7 +254,7 @@ if ($action == 'getProducts') { } } - $rows[] = array( + $row = array( 'rowid' => $obj->rowid, 'ref' => $obj->ref, 'label' => $obj->label, From be2502c29f2d69db2dea3972c58e1ae4a889afdd Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 28 Apr 2022 10:50:55 +0200 Subject: [PATCH 574/752] New : module webhook database structure --- .../mysql/tables/llx_webhook_target.key.sql | 27 ++++++++++++++ .../mysql/tables/llx_webhook_target.sql | 36 +++++++++++++++++++ .../llx_webhook_target_extrafields.key.sql | 19 ++++++++++ .../tables/llx_webhook_target_extrafields.sql | 23 ++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_webhook_target.key.sql create mode 100644 htdocs/install/mysql/tables/llx_webhook_target.sql create mode 100644 htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql diff --git a/htdocs/install/mysql/tables/llx_webhook_target.key.sql b/htdocs/install/mysql/tables/llx_webhook_target.key.sql new file mode 100644 index 00000000000..04a0dbb306a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target.key.sql @@ -0,0 +1,27 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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_webhook_target ADD INDEX idx_webhook_target_rowid (rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_ref (ref); +ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_webhook_target ADD UNIQUE INDEX uk_webhook_target_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_field FOREIGN KEY (fk_field) REFERENCES llx_webhook_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_webhook_target.sql b/htdocs/install/mysql/tables/llx_webhook_target.sql new file mode 100644 index 00000000000..f9a6b61d489 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target.sql @@ -0,0 +1,36 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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_webhook_target( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + label varchar(255), + description text, + note_public text, + note_private 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, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status integer NOT NULL, + url varchar(255) NOT NULL, + trigger_codes text NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql new file mode 100644 index 00000000000..c8ebcf12bdc --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql @@ -0,0 +1,19 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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_webhook_target_extrafields ADD INDEX idx_target_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql new file mode 100644 index 00000000000..0af3a1fadda --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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_webhook_target_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From 729d1f57aaa1757470b0a855fec3eebbc4949619 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 28 Apr 2022 10:53:16 +0200 Subject: [PATCH 575/752] fix select fields --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index a3bcc04b5c8..ff2cbd65d51 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -208,7 +208,7 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price' ; + $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price' ; // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook From d376d285888cec7ade770db59a9a032d0aefa831 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Apr 2022 11:12:21 +0200 Subject: [PATCH 576/752] Missing trans --- htdocs/langs/en_US/users.lang | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 888c9f52161..5bfbec87294 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -123,4 +123,8 @@ ForceUserHolidayValidator=Force leave request validator ValidatorIsSupervisorByDefault=By default, the validator is the supervisor of the user. Keep empty to keep this behaviour. UserPersonalEmail=Personal email UserPersonalMobile=Personal mobile phone -WarningNotLangOfInterface=Warning, this is the main language the user speak, not the language of the interface he choosed to see. To change the interface language visible by this user, go on tab %s \ No newline at end of file +WarningNotLangOfInterface=Warning, this is the main language the user speak, not the language of the interface he choosed to see. To change the interface language visible by this user, go on tab %s +DateLastLogin=Date last login +DatePreviousLogin=Date previous login +IPLastLogin=IP last login +IPPreviousLogin=IP previous login From fc6228a48ca487560c112c0d754f5c7b461b8fa2 Mon Sep 17 00:00:00 2001 From: IC-faycal Date: Thu, 28 Apr 2022 11:27:15 +0200 Subject: [PATCH 577/752] NEW Events on Proposal to Return to Draft --- .../triggers/interface_50_modAgenda_ActionsAuto.class.php | 8 ++++++++ htdocs/langs/en_US/agenda.lang | 1 + 2 files changed, 9 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index cf6a8220c29..187e3f5a156 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -186,6 +186,14 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->sendtoid = 0; + } elseif ($action == 'PROPAL_MODIFY') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "propal")); + + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->sendtoid = 0; } elseif ($action == 'PROPAL_SENTBYMAIL') { // Load translation files required by the page diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index bc9c7dab537..73bb8d92346 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -45,6 +45,7 @@ CONTRACT_DELETEInDolibarr=Contract %s deleted PropalClosedSignedInDolibarr=Proposal %s signed PropalClosedRefusedInDolibarr=Proposal %s refused PropalValidatedInDolibarr=Proposal %s validated +PropalBackToDraftInDolibarr=Proposal %s go back to draft status PropalClassifiedBilledInDolibarr=Proposal %s classified billed InvoiceValidatedInDolibarr=Invoice %s validated InvoiceValidatedInDolibarrFromPos=Invoice %s validated from POS From ed4610b36bde8878574d0ab4922627f37f443717 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 28 Apr 2022 11:45:55 +0200 Subject: [PATCH 578/752] FIX : Move column "Real Qty" just before "Real PMP" column --- htdocs/product/inventory/inventory.php | 48 +++++++++++++++++--------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 204c6539c29..f7691193e24 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -910,15 +910,17 @@ if ($object->id > 0) { print ''; } print ''.$langs->trans("ExpectedQty").''; - print ''; - print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); - print ''; if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { print ''.$langs->trans('PMPExpected').''; print ''.$langs->trans('ExpectedValuation').''; + print ''.$form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")).''; print ''.$langs->trans('PMPReal').''; print ''.$langs->trans('RealValuation').''; - } + } else { + print ''; + print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); + print ''; + } if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { // Actions or link to stock movement print ''; @@ -1041,7 +1043,6 @@ if ($object->id > 0) { // Real quantity if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - print ''; $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view; //if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) { @@ -1049,11 +1050,6 @@ if ($object->id > 0) { $hasinput = true; } - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; - print ''; - print ''; if (! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; @@ -1066,6 +1062,14 @@ if ($object->id > 0) { print ''; print price($pmp_valuation); print ''; + + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; + //PMP Real print ''; @@ -1081,18 +1085,22 @@ if ($object->id > 0) { $totalExpectedValuation += $pmp_valuation; $totalRealValuation += $pmp_valuation_real; - } + } else { + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; + } // Picto delete line print ''; print ''.img_delete().''; $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; - print ''; + print ''; print ''; } else { - print ''; - print $obj->qty_view; // qty found - print ''; if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { //PMP Expected if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; @@ -1105,6 +1113,10 @@ if ($object->id > 0) { print price($pmp_valuation); print ''; + print ''; + print $obj->qty_view; // qty found + print ''; + //PMP Real print ''; if (! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; @@ -1119,7 +1131,11 @@ if ($object->id > 0) { $totalExpectedValuation += $pmp_valuation; $totalRealValuation += $pmp_valuation_real; - } + } else { + print ''; + print $obj->qty_view; // qty found + print ''; + } if ($obj->fk_movement > 0) { $stockmovment = new MouvementStock($db); $stockmovment->fetch($obj->fk_movement); From 701960bd70654bf643d07d5c53f829cb175e6d85 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 28 Apr 2022 11:47:13 +0200 Subject: [PATCH 579/752] try to fix build fail --- htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql index 0af3a1fadda..a01ac0e1d1c 100644 --- a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql @@ -16,7 +16,7 @@ create table llx_webhook_target_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, fk_object integer NOT NULL, import_key varchar(14) -- import key ) ENGINE=innodb; From 75f540c30cde44d9dc1eef300f44c319e29e7205 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 28 Apr 2022 11:49:15 +0200 Subject: [PATCH 580/752] fix for reshook when several module use the hook but only on is concerned --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bb411d530c7..1bacf75c7d2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1810,7 +1810,7 @@ class Product extends CommonObject // Note that $action and $object may have been modified by some hooks global $action; $reshook = $hookmanager->executeHooks('getSellPrice', $parameters, $this, $action); - if ( ! empty($reshook)) { + if ( ! empty($hookmanager->resArray)) { return $hookmanager->resArray; } From f0e65e8bdd259ba8aedc4cbc0d9a74e4a95833fd Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Thu, 14 Apr 2022 00:37:26 +0400 Subject: [PATCH 581/752] FIX #20733 Inventory: Do not use batch qty even if present if batch module is disabled. --- htdocs/product/inventory/class/inventory.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index bb55bc1b143..c506204d3f0 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -306,9 +306,14 @@ class Inventory extends CommonObject $inventoryline->fk_warehouse = $obj->fk_warehouse; $inventoryline->fk_product = $obj->fk_product; $inventoryline->batch = $obj->batch; - $inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty $inventoryline->datec = dol_now(); + if ($conf->productbatch->enabled) { + $inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty + }else{ + $inventoryline->qty_stock = $obj->reel; + } + $resultline = $inventoryline->create($user); if ($resultline <= 0) { $this->error = $inventoryline->error; From 6ab88d0169572afbee05f63e8c41979260a62691 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 28 Apr 2022 10:09:02 +0000 Subject: [PATCH 582/752] Fixing style errors. --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index c506204d3f0..f49b262bc13 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -310,7 +310,7 @@ class Inventory extends CommonObject if ($conf->productbatch->enabled) { $inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty - }else{ + } else { $inventoryline->qty_stock = $obj->reel; } From 900caf5a443910fa4d3f98ff329b30115909c853 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 28 Apr 2022 12:12:20 +0200 Subject: [PATCH 583/752] Fix missing budget export --- htdocs/core/modules/modProjet.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 791442dab1c..b97aad1b149 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -222,7 +222,7 @@ class modProjet extends DolibarrModules 's.phone'=>'Text', 's.email'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 'p.rowid'=>"List:projet:ref::project", 'p.ref'=>"Text", 'p.title'=>"Text", 'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean', - 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', + 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', 'p.budget_amount'=>'Numeric', 'pt.rowid'=>'Numeric', 'pt.ref'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text", 'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)", 'ptt.note'=>"Text" ); @@ -235,7 +235,7 @@ class modProjet extends DolibarrModules 's.phone'=>'Phone', 's.email'=>'Email', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel', 'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime', - 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description" + 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.budget_amount'=>'Budget', 'p.description'=>"Description" ); // Add multicompany field if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) From b35b40649f575f1d4f90c56c63b7c55125443037 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Thu, 28 Apr 2022 15:42:49 +0400 Subject: [PATCH 584/752] CLOSE #20736 Allow extrafields SQL filters on REST API product lookup --- htdocs/product/class/api_products.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index e44aef221f6..c1a387167ec 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -173,9 +173,10 @@ class Products extends DolibarrApi * @param int $variant_filter Use this param to filter list (0 = all, 1=products without variants, 2=parent of variants, 3=variants only) * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0 * @param int $includestockdata Load also information about stock (slower) + * @param bool $allow_extrafields_sqlfilters Allow sqlfilters to contain extrafields filter (slower). * @return array Array of product objects */ - public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false, $includestockdata = 0) + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false, $includestockdata = 0, $allow_extrafields_sqlfilters = false) { global $db, $conf; @@ -192,6 +193,11 @@ class Products extends DolibarrApi if ($category > 0) { $sql .= ", ".$this->db->prefix()."categorie_product as c"; } + + if ($allow_extrafields_sqlfilters) { + $sql .= " LEFT JOIN llx_product_extrafields AS ef ON ef.fk_object = t.rowid"; + } + $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; if ($variant_filter == 1) { From 88bd28323cfe03bccccfdda7b7b6a4e35d6e5548 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Thu, 28 Apr 2022 16:46:42 +0400 Subject: [PATCH 585/752] FIX #20738 Inventory: Add missing for movement number / card. --- htdocs/product/inventory/inventory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 204c6539c29..dde5248a528 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1120,6 +1120,7 @@ if ($object->id > 0) { $totalExpectedValuation += $pmp_valuation; $totalRealValuation += $pmp_valuation_real; } + print ''; if ($obj->fk_movement > 0) { $stockmovment = new MouvementStock($db); $stockmovment->fetch($obj->fk_movement); From 68864840b64e25131fe513201dc8e509e03b5410 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 28 Apr 2022 13:25:50 +0000 Subject: [PATCH 586/752] Fixing style errors. --- htdocs/accountancy/class/lettering.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index a31a4675851..39c56d5e3d8 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -440,7 +440,7 @@ class Lettering extends BookKeeping $group_error++; break; } - if (!isset($lettering_code)) $lettering_code = (string)$line_infos['lettering_code']; + if (!isset($lettering_code)) $lettering_code = (string) $line_infos['lettering_code']; if (!empty($line_infos['lettering_code'])) $do_it = true; } elseif (!empty($line_infos['lettering_code'])) $do_it = false; } @@ -518,8 +518,8 @@ class Lettering extends BookKeeping " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab" . " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc" . " WHERE ab.doc_type = 'bank'" . - // " AND ab.subledger_account != ''" . - // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . + // " AND ab.subledger_account != ''" . + // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; @@ -540,8 +540,8 @@ class Lettering extends BookKeeping " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab" . " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe ON pe.$fk_element = ab.fk_doc" . " WHERE ab.doc_type = '" . $this->db->escape($doc_type) . "'" . - // " AND ab.subledger_account != ''" . - // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . + // " AND ab.subledger_account != ''" . + // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . " AND pe.$fk_payment_element IS NOT NULL"; if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; @@ -726,7 +726,7 @@ class Lettering extends BookKeeping $grouped_payments[] = $current_group; $current_group = array(); } - } while(!empty($payment_by_element) && $element_id == 0); + } while (!empty($payment_by_element) && $element_id == 0); if ($element_id == 0) { // Restore list when is the begin of recursive function From 5379db7c6bbfeb25259c5d173183da5de0354348 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 28 Apr 2022 15:49:08 +0200 Subject: [PATCH 587/752] Fix stickler-ci --- htdocs/accountancy/class/lettering.class.php | 98 ++++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index a31a4675851..1532768826d 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -249,22 +249,22 @@ class Lettering extends BookKeeping $error = 0; $lettre = 'AAA'; - $sql = "SELECT DISTINCT ab2.lettering_code" . - " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping As ab" . - " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc" . - " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu2 ON bu2.url_id = bu.url_id" . - " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.fk_doc = bu2.fk_bank" . - " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")" . - " AND ab.doc_type = 'bank'" . - " AND ab2.doc_type = 'bank'" . - " AND bu.type = 'company'" . - " AND bu2.type = 'company'" . - " AND ab.subledger_account != ''" . - " AND ab2.subledger_account != ''" . - " AND ab.lettering_code IS NULL" . - " AND ab2.lettering_code != ''" . - " ORDER BY ab2.lettering_code DESC" . - " LIMIT 1 "; + $sql = "SELECT DISTINCT ab2.lettering_code"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping As ab"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu2 ON bu2.url_id = bu.url_id"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.fk_doc = bu2.fk_bank"; + $sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")"; + $sql .= " AND ab.doc_type = 'bank'"; + $sql .= " AND ab2.doc_type = 'bank'"; + $sql .= " AND bu.type = 'company'"; + $sql .= " AND bu2.type = 'company'"; + $sql .= " AND ab.subledger_account != ''"; + $sql .= " AND ab2.subledger_account != ''"; + $sql .= " AND ab.lettering_code IS NULL"; + $sql .= " AND ab2.lettering_code != ''"; + $sql .= " ORDER BY ab2.lettering_code DESC"; + $sql .= " LIMIT 1 "; $result = $this->db->query($sql); if ($result) { @@ -514,13 +514,13 @@ class Lettering extends BookKeeping $payment_ids = array(); // Get all payment id from bank lines - $sql = "SELECT DISTINCT bu.url_id AS payment_id" . - " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab" . - " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc" . - " WHERE ab.doc_type = 'bank'" . - // " AND ab.subledger_account != ''" . - // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . - " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; + $sql = "SELECT DISTINCT bu.url_id AS payment_id"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc"; + $sql .= " WHERE ab.doc_type = 'bank'"; + // $sql .= " AND ab.subledger_account != ''"; + // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + $sql .= " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG); @@ -536,13 +536,13 @@ class Lettering extends BookKeeping $this->db->free($resql); // Get all payment id from payment lines - $sql = "SELECT DISTINCT pe.$fk_payment_element AS payment_id" . - " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab" . - " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe ON pe.$fk_element = ab.fk_doc" . - " WHERE ab.doc_type = '" . $this->db->escape($doc_type) . "'" . - // " AND ab.subledger_account != ''" . - // " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'" . - " AND pe.$fk_payment_element IS NOT NULL"; + $sql = "SELECT DISTINCT pe.$fk_payment_element AS payment_id"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe ON pe.$fk_element = ab.fk_doc"; + $sql .= " WHERE ab.doc_type = '" . $this->db->escape($doc_type) . "'"; + // $sql .= " AND ab.subledger_account != ''"; + // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + $sql .= " AND pe.$fk_payment_element IS NOT NULL"; if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG); @@ -569,14 +569,14 @@ class Lettering extends BookKeeping $lines = array(); // Get bank lines - $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit" . - " FROM " . MAIN_DB_PREFIX . "bank_url AS bu" . - " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = bu.fk_bank" . - " WHERE bu.url_id IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")" . - " AND bu.type = '" . $this->db->escape($bank_url_type) . "'" . - " AND ab.doc_type = 'bank'" . - " AND ab.subledger_account != ''" . - " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit"; + $sql .= " FROM " . MAIN_DB_PREFIX . "bank_url AS bu"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = bu.fk_bank"; + $sql .= " WHERE bu.url_id IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")"; + $sql .= " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; + $sql .= " AND ab.doc_type = 'bank'"; + $sql .= " AND ab.subledger_account != ''"; + $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; dol_syslog(__METHOD__ . " - Get bank lines", LOG_DEBUG); $resql = $this->db->query($sql); @@ -591,13 +591,13 @@ class Lettering extends BookKeeping $this->db->free($resql); // Get payment lines - $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit" . - " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe" . - " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = pe.$fk_element" . - " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")" . - " AND ab.doc_type = '" . $this->db->escape($doc_type) . "'" . - " AND ab.subledger_account != ''" . - " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit"; + $sql .= " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = pe.$fk_element"; + $sql .= " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")"; + $sql .= " AND ab.doc_type = '" . $this->db->escape($doc_type) . "'"; + $sql .= " AND ab.subledger_account != ''"; + $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG); $resql = $this->db->query($sql); @@ -646,10 +646,10 @@ class Lettering extends BookKeeping } // Get payment lines - $sql = "SELECT DISTINCT pe2.$fk_payment_element, pe2.$fk_element" . - " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe" . - " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe2 ON pe2.$fk_element = pe.$fk_element" . - " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_ids)) . ")"; + $sql = "SELECT DISTINCT pe2.$fk_payment_element, pe2.$fk_element"; + $sql .= " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe2 ON pe2.$fk_element = pe.$fk_element"; + $sql .= " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_ids)) . ")"; dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG); $resql = $this->db->query($sql); From 5fe448e86cb455bbe629a72e15b63c0a00d9a63a Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 28 Apr 2022 15:49:31 +0200 Subject: [PATCH 588/752] FIX : [inventory] Update PMP when qty stay the same --- htdocs/product/inventory/inventory.php | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index f7691193e24..48f9c83513f 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -186,25 +186,6 @@ if (empty($reshook)) { break; } - if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); - $resqlpmp = $db->query($sqlpmp); - if (! $resqlpmp) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; - $resqlpmp = $db->query($sqlpmp); - if (! $resqlpmp) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - } - } - // Update line with id of stock movement (and the start quantity if it has changed this last recording) $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet"; $sqlupdate .= " SET fk_movement = ".((int) $idstockmove); @@ -219,6 +200,26 @@ if (empty($reshook)) { break; } } + + if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity; + $resqlpmp = $db->query($sqlpmp); + if (! $resqlpmp) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + } + } $i++; } From 96e247bf8935caa8e4b841bccb40ac1bad3f53be Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 28 Apr 2022 13:55:54 +0000 Subject: [PATCH 589/752] Fixing style errors. --- htdocs/accountancy/class/lettering.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 2c2c07e7944..a32df04e79a 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -518,8 +518,8 @@ class Lettering extends BookKeeping $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc"; $sql .= " WHERE ab.doc_type = 'bank'"; - // $sql .= " AND ab.subledger_account != ''"; - // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + // $sql .= " AND ab.subledger_account != ''"; + // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; $sql .= " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; @@ -540,8 +540,8 @@ class Lettering extends BookKeeping $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe ON pe.$fk_element = ab.fk_doc"; $sql .= " WHERE ab.doc_type = '" . $this->db->escape($doc_type) . "'"; - // $sql .= " AND ab.subledger_account != ''"; - // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + // $sql .= " AND ab.subledger_account != ''"; + // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; $sql .= " AND pe.$fk_payment_element IS NOT NULL"; if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; From f2d81f97b9687796b342c295cc4a38a2add6662a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 28 Apr 2022 17:10:30 +0200 Subject: [PATCH 590/752] Comment function --- htdocs/accountancy/class/lettering.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index a32df04e79a..58443cfec8d 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -619,6 +619,13 @@ class Lettering extends BookKeeping return $groups; } + /** + * Linked payment by group + * + * @param array $payment_ids list of payment id + * @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice') + * @return array|int <0 if error otherwise all linked lines by block + */ public function getLinkedPaymentByGroup($payment_ids, $type) { global $langs; From 7752c5f1221316575b691a529ff049512aa5cb1c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 28 Apr 2022 17:24:10 +0200 Subject: [PATCH 591/752] Comment function --- htdocs/accountancy/class/lettering.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 58443cfec8d..a2718973185 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -685,10 +685,10 @@ class Lettering extends BookKeeping /** * Get payment ids grouped by payment id and element id in common * - * @param array &$payment_by_element List of payment ids by element id - * @param array &$element_by_payment List of element ids by payment id + * @param array $payment_by_element List of payment ids by element id + * @param array $element_by_payment List of element ids by payment id * @param int $element_id Element Id (used for recursive function) - * @param array &$current_group Current group (used for recursive function) + * @param array $current_group Current group (used for recursive function) * @return array List of payment ids grouped by payment id and element id in common */ public function getGroupElements(&$payment_by_element, &$element_by_payment, $element_id = 0, &$current_group = array()) From ebe68350d1d2770b0500560fdeda5fe00639745f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Apr 2022 17:34:04 +0200 Subject: [PATCH 592/752] IP for last and previous login is now saved inuser table --- htdocs/user/class/user.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f01820f93e9..8c61af9ccbb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -275,6 +275,8 @@ class User extends CommonObject public $datelastlogin; public $datepreviouslogin; + public $iplastlogin; + public $ippreviouslogin; public $datestartvalidity; public $dateendvalidity; @@ -2111,9 +2113,13 @@ class User extends CommonObject // phpcs:enable $now = dol_now(); + $userremoteip = getUserRemoteIP(); + $sql = "UPDATE ".$this->db->prefix()."user SET"; $sql .= " datepreviouslogin = datelastlogin,"; + $sql .= " ippreviouslogin = iplastlogin,"; $sql .= " datelastlogin = '".$this->db->idate($now)."',"; + $sql .= " iplastlogin = '".$this->db->escape($userremoteip)."',"; $sql .= " tms = tms"; // La date de derniere modif doit changer sauf pour la mise a jour de date de derniere connexion $sql .= " WHERE rowid = ".((int) $this->id); @@ -2122,6 +2128,8 @@ class User extends CommonObject if ($resql) { $this->datepreviouslogin = $this->datelastlogin; $this->datelastlogin = $now; + $this->ippreviouslogin = $this->iplastlogin; + $this->iplastlogin = $userremoteip; return 1; } else { $this->error = $this->db->lasterror().' sql='.$sql; @@ -3116,7 +3124,9 @@ class User extends CommonObject $this->datem = $now; $this->datelastlogin = $now; + $this->iplastlogin = '127.0.0.1'; $this->datepreviouslogin = $now; + $this->ippreviouslogin = '127.0.0.1'; $this->statut = 1; $this->entity = 1; From 93815404a27d5d474c578c97e496efdcfc8eb863 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Apr 2022 18:46:52 +0200 Subject: [PATCH 593/752] Fix phpcs --- htdocs/compta/localtax/card.php | 4 ++-- htdocs/compta/paiement_vat.php | 2 +- htdocs/compta/tva/card.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 45cb1f03bb8..9bd37eafa36 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -177,10 +177,10 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { // Type payment print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype", '', 0, 1, 0, 0, 1,'maxwidth500 widthcentpercentminusx'); + $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype", '', 0, 1, 0, 0, 1, 'maxwidth500 widthcentpercentminusx'); print "\n"; print ""; - + // Bank account print ''.$langs->trans("Account").''; print img_picto('', 'bank_account', 'pictofixedwidth'); diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index 2f7b775096d..28bc838c296 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -207,7 +207,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype", "int") : $tva->paiementtype, "paiementtype", '', 0, 1, 0, 0, 1,'maxwidth500 widthcentpercentminusx'); + $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype", "int") : $tva->paiementtype, "paiementtype", '', 0, 1, 0, 0, 1, 'maxwidth500 widthcentpercentminusx'); print "\n"; print ''; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 3ffb405f8ad..3a34d71c11d 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -490,7 +490,7 @@ if ($action == 'create') { // Type payment print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST("type_payment", 'int'), "type_payment", '', 0, 1, 0, 0, 1,'maxwidth500 widthcentpercentminusx'); + $form->select_types_paiements(GETPOST("type_payment", 'int'), "type_payment", '', 0, 1, 0, 0, 1, 'maxwidth500 widthcentpercentminusx'); print "\n"; print ""; From 559694dd4fa70a874f9851c8ef7b79fa517ad6ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Apr 2022 19:05:23 +0200 Subject: [PATCH 594/752] API doc --- htdocs/compta/facture/class/api_invoices.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 551edb05731..3623a36cbb9 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1724,8 +1724,8 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of template invoice - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @param int $id ID of template invoice + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses * @return array|mixed data without useless information * * @url GET templates/{id} From 3b98f74a56bfbb829050284e5c1e93b0ab0ed21b Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Thu, 28 Apr 2022 22:56:44 +0400 Subject: [PATCH 595/752] Fix typo and switch to old join style. --- htdocs/product/class/api_products.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c1a387167ec..262d83a0afc 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -195,7 +195,7 @@ class Products extends DolibarrApi } if ($allow_extrafields_sqlfilters) { - $sql .= " LEFT JOIN llx_product_extrafields AS ef ON ef.fk_object = t.rowid"; + $sql .= ", ".MAIN_DB_PREFIX."product_extrafields AS ef"; } $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; @@ -223,6 +223,11 @@ class Products extends DolibarrApi // Show only services $sql .= " AND t.fk_product_type = 1"; } + + if ($allow_extrafields_sqlfilters) { + $sql .= " AND ef.fk_object = t.rowid"; + } + // Add sql filters if ($sqlfilters) { $errormessage = ''; From a129b6d13260cc0c8ac77fa0fc4d9ce2e5183a57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Apr 2022 22:29:48 +0200 Subject: [PATCH 596/752] FIX phpcs --- htdocs/core/class/rssparser.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 2048a80bae6..93224b9f04d 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -230,7 +230,7 @@ class RssParser if (!empty($result['content'])) { $str = $result['content']; - } elseif (!empty($result['curl_error_msg'])){ + } elseif (!empty($result['curl_error_msg'])) { $this->error = 'Error retrieving URL '.$this->_urlRSS.' - '.$result['curl_error_msg']; return -1; } From 822a0a37f3aaf7e649233ef20249311174c5a1f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Apr 2022 22:28:32 +0200 Subject: [PATCH 597/752] Fix phpunit --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/user/class/user.class.php | 4 ++++ test/phpunit/UserTest.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0009cd00bcf..970426eb488 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2143,7 +2143,7 @@ DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined -RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. +RESTRICT_ON_IP=Allow API access to only certain client IPs (wildcard not allowed, use space between values). Empty means every clients can access. IPListExample=127.0.0.1 192.168.0.2 [::1] BaseOnSabeDavVersion=Based on the library SabreDAV version NotAPublicIp=Not a public IP diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8c61af9ccbb..6f10ada3267 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -437,6 +437,8 @@ class User extends CommonObject $sql .= " u.tms as datem,"; $sql .= " u.datelastlogin as datel,"; $sql .= " u.datepreviouslogin as datep,"; + $sql .= " u.iplastlogin,"; + $sql .= " u.ippreviouslogin,"; $sql .= " u.datelastpassvalidation,"; $sql .= " u.datestartvalidity,"; $sql .= " u.dateendvalidity,"; @@ -564,6 +566,8 @@ class User extends CommonObject $this->datem = $this->db->jdate($obj->datem); $this->datelastlogin = $this->db->jdate($obj->datel); $this->datepreviouslogin = $this->db->jdate($obj->datep); + $this->iplastlogin = $obj->iplastlogin; + $this->ippreviouslogin = $obj->ippreviouslogin; $this->datestartvalidity = $this->db->jdate($obj->datestartvalidity); $this->dateendvalidity = $this->db->jdate($obj->dateendvalidity); diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 699e9fd89f0..c6ccc3b01a0 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -204,7 +204,7 @@ class UserTest extends PHPUnit\Framework\TestCase $newlocalobject=new User($this->savdb); $newlocalobject->initAsSpecimen(); $this->changeProperties($newlocalobject); - $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin','trackid')), array()); // Actual, Expected + $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin','iplastlogin','ippreviouslogin','trackid')), array()); // Actual, Expected return $localobject; } From accb900d4f54fbf4f4b9fa2be89bfae4ee94be7d Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 29 Apr 2022 09:45:36 +0200 Subject: [PATCH 598/752] ajax load only one page of search results --- htdocs/takepos/ajax/ajax.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index a3bcc04b5c8..5e0b329676a 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -48,6 +48,8 @@ $category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'sup $action = GETPOST('action', 'aZ09'); $term = GETPOST('term', 'alpha'); $id = GETPOST('id', 'int'); +$search_start = GETPOST('search_start', 'int'); +$search_limit = GETPOST('search_limit', 'int'); if (empty($user->rights->takepos->run)) { accessforbidden(); @@ -232,6 +234,9 @@ if ($action == 'getProducts') { $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; + // load only one page of products + $sql.= ' LIMIT '. $search_start . ',' . $search_limit; + $resql = $db->query($sql); if ($resql) { $rows = array(); From 78f46bb98b13978e27e24811007158eb4ae0ee0e Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 29 Apr 2022 09:49:10 +0200 Subject: [PATCH 599/752] search next or previous page of products if asked --- htdocs/takepos/index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index b23907b64f1..eab5b12c3c1 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -372,6 +372,9 @@ function LoadProducts(position, issubcat) { function MoreProducts(moreorless) { console.log("MoreProducts"); + + if ($('#search_pagination').val() != '') return Search2('', moreorless); + var maxproduct = ; if (moreorless=="more"){ From fb076a92828e33bc3ec084650bf8157837061f92 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 29 Apr 2022 10:00:25 +0200 Subject: [PATCH 600/752] FIX pagination on search results --- htdocs/takepos/index.php | 49 ++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index eab5b12c3c1..d934765b846 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -559,12 +559,20 @@ function New() { * @param {int} keyCodeForEnter Key code for "enter" * return {void} */ -function Search2(keyCodeForEnter) { +function Search2(keyCodeForEnter, moreorless) { console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter); + var search_term = $('#search').val(); + var search_start = 0; + var search_limit = ; + if (moreorless != null) { + search_term = $('#search_pagination').val(); + search_start = $('#search_start_'+moreorless).val(); + } + var search = false; var eventKeyCode = window.event.keyCode; - if (typeof keyCodeForEnter === 'undefined' || eventKeyCode == keyCodeForEnter) { + if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) { search = true; } @@ -579,7 +587,8 @@ function Search2(keyCodeForEnter) { pageproducts = 0; jQuery(".wrapper2 .catwatermark").hide(); - $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + $('#search').val(), function (data) { + var nbsearchresults = 0; + $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { for (i = 0; i < ; i++) { if (typeof (data[i]) == "undefined") { $("#prodesc" + i).text(""); @@ -618,6 +627,7 @@ function Search2(keyCodeForEnter) { } $("#prodiv" + i).data("rowid", data[i]['rowid']); $("#prodiv" + i).data("iscat", 0); + nbsearchresults++; } }).always(function (data) { // If there is only 1 answer @@ -642,6 +652,24 @@ function Search2(keyCodeForEnter) { } else ClearSearch(); } + // memorize search_term and start for pagination + $("#search_pagination").val($("#search").val()); + if (search_start == 0) { + $("#prodiv span").hide(); + } + else { + $("#prodiv span").show(); + var search_start_less = Math.max(0, parseInt(search_start) - parseInt()); + $("#search_start_less").val(search_start_less); + } + if (nbsearchresults != ) { + $("#prodiv span").hide(); + } + else { + $("#prodiv span").show(); + var search_start_more = parseInt(search_start) + parseInt(); + $("#search_start_more").val(search_start_more); + } }); }, 500); // 500ms delay } @@ -918,7 +946,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
From a11b5b43998501dec9f1da1332bdba6f209590a5 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 29 Apr 2022 10:12:53 +0200 Subject: [PATCH 601/752] escape sql string for my Travais friend --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 5e0b329676a..e15963efb9a 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -235,7 +235,7 @@ if ($action == 'getProducts') { $sql .= $hookmanager->resPrint; // load only one page of products - $sql.= ' LIMIT '. $search_start . ',' . $search_limit; + $sql.= ' LIMIT '. $db->escape($search_start) . ',' . $db->escape($search_limit); $resql = $db->query($sql); if ($resql) { From 6d79d03cb2a275d4b41845752030e6be261ec9d0 Mon Sep 17 00:00:00 2001 From: melina Date: Fri, 29 Apr 2022 10:43:35 +0200 Subject: [PATCH 602/752] add comment to fix stickler --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 3ec334bd703..3af186813e2 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -54,7 +54,7 @@ if (empty($user->rights->takepos->run)) { } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$hookmanager->initHooks(array('takeposproductsearch')); +$hookmanager->initHooks(array('takeposproductsearch')); // new context for product search hooks /* * View From 726b899d30e4defe41113f79d765287254e19554 Mon Sep 17 00:00:00 2001 From: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:45:08 +0200 Subject: [PATCH 603/752] FIX: Delete an extrafield where type is double Found the bug on a propal's extrafield, it was impossible to delete a decimal extrafield. In updateExtraField() the $value stayed "" where it needed to be null. The same issue can be found in insertExtraFields(). --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 272d66e4855..aa88aeb825a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5999,7 +5999,7 @@ abstract class CommonObject $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } elseif ($value == '') { - $new_array_options[$key] = null; + $value = null; } //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); $new_array_options[$key] = $value; @@ -6365,7 +6365,7 @@ abstract class CommonObject $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } elseif ($value === '') { - $this->array_options["options_".$key] = null; + $value = null; } //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); $this->array_options["options_".$key] = $value; From 812b9adee735c64225f7e48e0110ad81b3d123ef Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 29 Apr 2022 10:58:04 +0200 Subject: [PATCH 604/752] still trying to please Travis... losing my time --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index e15963efb9a..380e205d53f 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -235,7 +235,7 @@ if ($action == 'getProducts') { $sql .= $hookmanager->resPrint; // load only one page of products - $sql.= ' LIMIT '. $db->escape($search_start) . ',' . $db->escape($search_limit); + $sql .= ' LIMIT '. $db->escape($search_start) . ',' . $db->escape($search_limit); $resql = $db->query($sql); if ($resql) { From d682cb3103f3feefb1394e810e8b8cc788eb0bdb Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 29 Apr 2022 11:09:32 +0200 Subject: [PATCH 605/752] please Travis --- htdocs/takepos/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 380e205d53f..20fb282b1cd 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -235,7 +235,7 @@ if ($action == 'getProducts') { $sql .= $hookmanager->resPrint; // load only one page of products - $sql .= ' LIMIT '. $db->escape($search_start) . ',' . $db->escape($search_limit); + $sql.= $db->plimit($search_limit, $search_start); $resql = $db->query($sql); if ($resql) { From d496ad65e618650b34cd2e82d33f8f79acfb5525 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 11:16:15 +0200 Subject: [PATCH 606/752] Enhance the feature of keyword detection for partnership --- htdocs/core/modules/modPartnership.class.php | 18 ++++++++++-------- .../install/mysql/migration/15.0.0-16.0.0.sql | 6 +++++- ...llx_c_partnership_type-partnership.key.sql} | 0 ... => llx_c_partnership_type-partnership.sql} | 1 + .../tables/llx_partnership-partnership.sql | 5 +++-- htdocs/langs/en_US/partnership.lang | 4 +++- .../core/modules/modMyModule.class.php | 2 ++ htdocs/partnership/class/partnership.class.php | 7 ++++--- 8 files changed, 28 insertions(+), 15 deletions(-) rename htdocs/install/mysql/tables/{llx_c_partnership_type.key.sql => llx_c_partnership_type-partnership.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_c_partnership_type.sql => llx_c_partnership_type-partnership.sql} (92%) diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 3bec23d0d37..c08cf66db06 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -219,19 +219,21 @@ class modPartnership extends DolibarrModules // Label of tables 'tablib'=>array("PartnershipType"), // Request to select fields - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'c_partnership_type as f WHERE f.entity = '.$conf->entity), + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.keyword, f.active FROM '.MAIN_DB_PREFIX.'c_partnership_type as f WHERE f.entity = '.((int) $conf->entity)), // Sort order 'tabsqlsort'=>array("label ASC"), // List of fields (result of select to show dictionary) - 'tabfield'=>array("code,label"), + 'tabfield'=>array("code,label,keyword"), // List of fields (list of fields to edit a record) - 'tabfieldvalue'=>array("code,label"), + 'tabfieldvalue'=>array("code,label,keyword"), // List of fields (list of fields for insert) - 'tabfieldinsert'=>array("code,label"), + 'tabfieldinsert'=>array("code,label,keyword"), // Name of columns with primary key (try to always name it 'rowid') 'tabrowid'=>array("rowid"), // Condition to show each dictionary - 'tabcond'=>array($conf->partnership->enabled) + 'tabcond'=>array($conf->partnership->enabled), + // Help tooltip for each fields of the dictionary + 'tabhelp'=>array(array('keyword'=>$langs->trans('KeywordToCheckInWebsite'))) ); // Boxes/Widgets @@ -428,7 +430,7 @@ class modPartnership extends DolibarrModules $sql = array(); // Document templates - $moduledir = 'partnership'; + $moduledir = dol_sanitizeFileName('partnership'); $myTmpObjects = array(); $myTmpObjects['Partnership'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0); @@ -437,8 +439,8 @@ class modPartnership extends DolibarrModules continue; } if ($myTmpObjectArray['includerefgeneration']) { - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/partnership/template_partnerships.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/partnership'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_partnerships.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir; $dest = $dirodt.'/template_partnerships.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 39560240475..7170ebb62f4 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -334,4 +334,8 @@ ALTER TABLE llx_actioncomm MODIFY COLUMN note mediumtext; DELETE FROM llx_boxes WHERE box_id IN (select rowid FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php')); DELETE FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php'); -ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); \ No newline at end of file +ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); + +ALTER TABLE llx_partnership ADD COLUMN url_to_check varchar(255); +ALTER TABLE llx_c_partnership_type ADD COLUMN keyword varchar(128); + diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql b/htdocs/install/mysql/tables/llx_c_partnership_type-partnership.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_c_partnership_type.key.sql rename to htdocs/install/mysql/tables/llx_c_partnership_type-partnership.key.sql diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.sql b/htdocs/install/mysql/tables/llx_c_partnership_type-partnership.sql similarity index 92% rename from htdocs/install/mysql/tables/llx_c_partnership_type.sql rename to htdocs/install/mysql/tables/llx_c_partnership_type-partnership.sql index 99841f967cb..fe4dd904662 100644 --- a/htdocs/install/mysql/tables/llx_c_partnership_type.sql +++ b/htdocs/install/mysql/tables/llx_c_partnership_type-partnership.sql @@ -31,6 +31,7 @@ create table llx_c_partnership_type entity integer DEFAULT 1 NOT NULL, code varchar(32) NOT NULL, label varchar(128) NOT NULL, + keyword varchar(128), -- a keyword to check into url of partner website or a dedicated url defined into partneship record active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_partnership-partnership.sql b/htdocs/install/mysql/tables/llx_partnership-partnership.sql index e3a5cb37e05..8f83e2e82e5 100644 --- a/htdocs/install/mysql/tables/llx_partnership-partnership.sql +++ b/htdocs/install/mysql/tables/llx_partnership-partnership.sql @@ -34,8 +34,9 @@ CREATE TABLE llx_partnership( note_private text, note_public text, last_main_doc varchar(255), - count_last_url_check_error integer DEFAULT '0', - last_check_backlink datetime NULL, + url_to_check varchar(255), -- url to check to find a specific keyword (defined into llx_c_partnership) to keep status of partnership valid + count_last_url_check_error integer DEFAULT '0', -- last result of check of keyword into url + last_check_backlink datetime NULL, -- date of last check of keyword into url import_key varchar(14), model_pdf varchar(255) ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index f542bfab670..9c11e1cda2e 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -59,6 +59,7 @@ BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? PartnershipType=Partnership type PartnershipRefApproved=Partnership %s approved +KeywordToCheckInWebsite=If you want to check that a given keyword is present into the website of each partner, define this keyword here # # Template Mail @@ -89,4 +90,5 @@ PartnershipDraft=Draft PartnershipAccepted=Accepted PartnershipRefused=Refused PartnershipCanceled=Canceled -PartnershipManagedFor=Partners are \ No newline at end of file +PartnershipManagedFor=Partners are + diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index b1caea730f9..d843687157a 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -222,6 +222,8 @@ class modMyModule extends DolibarrModules 'tabrowid'=>array("rowid", "rowid", "rowid"), // Condition to show each dictionary 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled) + // Help tooltip for each fields of the dictionary + 'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp'))) ); */ diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index b673856d124..7d7d6a65d14 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -119,9 +119,10 @@ class Partnership extends CommonObject 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Terminated'),), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,), - 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), + 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), + 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), // fk_member and fk_soc are added into constructor ); From 3e4cd251eabf9f7559c8f8dd933474b611685f6f Mon Sep 17 00:00:00 2001 From: GregM Date: Fri, 29 Apr 2022 11:45:50 +0200 Subject: [PATCH 607/752] add edit extrafields Massaction products --- htdocs/core/actions_massactions.inc.php | 70 +++++++++++++++++++++++++ htdocs/core/tpl/massactions_pre.tpl.php | 25 +++++++++ htdocs/langs/en_US/main.lang | 4 ++ htdocs/product/list.php | 1 + 4 files changed, 100 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c5ff1d8f82a..5f5703fc872 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1602,6 +1602,76 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == } } +if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' && $permissiontoadd){ + $db->begin(); + + /** @var CommonObject $objecttmp */ + $objecttmp = new $objectclass($db); + + $nbok = 0; + $e = new ExtraFields($db); + $e->fetch_name_optionals_label($objecttmp->table_element); + + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + + if ($result>0) { + + if (isset($e->attributes[$objecttmp->table_element]['type']) && is_array($e->attributes[$objecttmp->table_element]['type'])) { + foreach ($e->attributes[$objecttmp->table_element]['type'] as $key => $type){ + + //Permet de gérer les types d'extrafields + if (in_array($type, array('price', 'double'))) { + $value_arr = GETPOST("options_".$key, 'alpha'); + if(empty($value_arr)){ + continue; + } + $value_key = price2num($value_arr); + //var_dump($value_key);exit; + }else if (in_array($type, array('date'))) { + // Clean parameters + $value_key = dol_mktime(12, 0, 0, GETPOST("options_" . $key . "month", 'int'), GETPOST("options_" . $key . "day", 'int'), GETPOST("options_" . $key . "year", 'int')); + //var_dump($value_key);exit; + if(empty($value_key)){ + continue; + } + }else if (in_array($type, array('datetime'))) { + // Clean parameters + $value_key = dol_mktime(GETPOST("options_".$key."hour", 'int'), GETPOST("options_".$key."min", 'int'), GETPOST("options_".$key."sec", 'int'), GETPOST("options_".$key."month", 'int'), GETPOST("options_".$key."day", 'int'), GETPOST("options_".$key."year", 'int'), 'tzuserrel'); + if(empty($value_key)){ + continue; + } + } else { + $value_key = GETPOST("options_".$key); + if ((in_array($type, array('link')) && $key == '-1') || empty($value_key)) { + continue; + } + } + $objecttmp->array_options["options_".$key] = $value_key; + } + } + $objecttmp->insertExtraFields(); + + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDisabled", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("save"), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } + +} + // Approve for leave only if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) { $db->begin(); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index de034f652d3..40394cb99ff 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -211,6 +211,31 @@ if ($massaction == 'presend') { print dol_get_fiche_end(); } +if ($massaction == 'edit_extrafields') { + + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $elementtype = 'product'; + /** @var CommonObject $objecttmp */ + $extrafields = new ExtraFields($db); + + $extrafields->fetch_name_optionals_label($elementtype); + $extrafields_list = $extrafields->attributes[$elementtype]['label']; + + $formquestion = array(); + if (!empty($extrafields_list)) { + $myParamExtra = $object->showOptionals($extrafields, 'create'); + + $formquestion[] = array( + 'type' => 'other', + 'value' => $object->showOptionals($extrafields, 'create') + ); + + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmEditExtrafield"), $langs->trans("ConfirmEditExtrafieldQuestion", count($toselect)), "confirm_edit_value_extrafields", $formquestion, 1, 0, 200, 500, 1); + } else { + setEventMessage($langs->trans("noExtrafields")); + } +} + if ($massaction == 'preenable') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassEnabling"), $langs->trans("ConfirmMassEnablingQuestion", count($toselect)), "enable", null, 'yes', 0, 200, 500, 1); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c66895e58a4..c543fcf31e0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1169,3 +1169,7 @@ CanceledShown=Canceled shown Terminate=Terminate Terminated=Terminated AddLineOnPosition=Add line on position (at the end if empty) +ConfirmEditExtrafield = Modifier les champs supplémentaires en masse +ChangeValueExtrafield = Modifier la valeur du champ supplémentaire +ConfirmEditExtrafieldQuestion = Etes vous sur de modifier cet extrafield ? +ConfirmEditValueExtrafieldQuestion = Etes vous sur de modifier la valeur de cet extrafield ? diff --git a/htdocs/product/list.php b/htdocs/product/list.php index de5e4f278b7..7cd0a91c923 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -727,6 +727,7 @@ if ($resql) { // List of mass actions available $arrayofmassactions = array( 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + 'edit_extrafields'=>img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("Extrafields"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); From bdd9b2acf4557c9b86e2988afb4ca468dfe09e5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 11:50:55 +0200 Subject: [PATCH 608/752] Clean css --- htdocs/core/lib/usergroups.lib.php | 7 ++++-- htdocs/langs/en_US/admin.lang | 2 +- htdocs/takepos/css/pos.css.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 4 ++-- htdocs/theme/md/info-box.inc.php | 2 +- htdocs/theme/md/style.css.php | 38 +++++++++++++++--------------- 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index c963c74c8b6..9bc0a59cf86 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -367,6 +367,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) $url = 'https://www.dolistore.com/9-skins'; print ''; print $langs->trans('DownloadMoreSkins'); + print img_picto('', 'globe', 'class="paddingleft"'); print ''; print ''; } @@ -435,7 +436,9 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) $colorbacktitle1 = ''; $colortexttitle = ''; $colorbacklineimpair1 = ''; + $colorbacklineimpair2 = ''; $colorbacklinepair1 = ''; + $colorbacklinepair2 = ''; $colortextlink = ''; $colorbacklinepairhover = ''; $colorbacklinepairhover = ''; @@ -746,7 +749,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableLineOddColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEIMPAIR1) ? $conf->global->THEME_ELDY_LINEIMPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEIMPAIR1', '', 1, '', '', 'colorbacklinepair2').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEIMPAIR1) ? $conf->global->THEME_ELDY_LINEIMPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEIMPAIR1', '', 1, '', '', 'colorbacklineimpair2').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''); if ($color) { @@ -770,7 +773,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundTableLineEvenColor").''; print ''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEPAIR1) ? $conf->global->THEME_ELDY_LINEPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEPAIR1', '', 1, '', '', 'colorbacklineimpair2').' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_LINEPAIR1) ? $conf->global->THEME_ELDY_LINEPAIR1 : ''), array()), ''), 'THEME_ELDY_LINEPAIR1', '', 1, '', '', 'colorbacklinepair2').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''); if ($color) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 970426eb488..bbb46d83900 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1925,7 +1925,7 @@ ConfFileMustContainCustom=Installing or building an external module from applica HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over HighlightLinesColor=Highlight color of the line when the mouse passes over (use 'ffffff' for no highlight) HighlightLinesChecked=Highlight color of the line when it is checked (use 'ffffff' for no highlight) -UseBorderOnTable=Active border on tables +UseBorderOnTable=Show left-right borders on tables BtnActionColor=Color of the action button TextBtnActionColor=Text color of the action button TextTitleColor=Text color of Page title diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index ba85c111bcd..45130981876 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -311,7 +311,7 @@ table.postablelines tr td { .posinvoiceline td { height: 40px !important; - background-color: var(--colorbacklineimpair1); + background-color: var(--colorbacklineimpair2); } .postablelines td.linecolht { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 356c8f45d63..c2c4d12012b 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -13,7 +13,7 @@ --colorbacktitle1: rgb(); --colorbacktabcard1: rgb(); --colorbacktabactive: rgb(); - --colorbacklinepair1: rgb(); + --colorbacklineimpair1: rgb(); --colorbacklineimpair2: rgb(); --colorbacklinepair1: rgb(); --colorbacklinepair2: rgb(); diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 8e4df027809..2d33a716692 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -21,7 +21,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { display: block; position: relative; min-height: 90px; - /* background: #fff; */ + background: var(--colorbacklineimpair2); width: 100%; box-shadow: 1px 1px 15px rgba(192, 192, 192, 0.2); border-radius: 2px; @@ -88,7 +88,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { text-align: center; font-size: 2.8em; line-height: 90px; - background: rgba(0, 0, 0, 0.08) !important; + background: var(--colorbacktitle1) !important; } .info-box-module .info-box-icon { diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index 1ea21ac44d1..8ffd6fc3f93 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -133,7 +133,7 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { display: block; position: relative; min-height: 90px; - background: #fff; + background: var(--colorbacklineimpair2); width: 100%; /* box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); */ border-radius: 2px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f1a07efbb0c..5317d6085fa 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -359,7 +359,7 @@ body { color: rgb(); font-size: ; - line-height: 1.3; + line-height: 1.4; font-family: ; margin-top: 0; margin-bottom: 0; @@ -3968,10 +3968,10 @@ table.hidepaginationnext .paginationnext { /* Prepare to remove class pair - impair .noborder > tbody > tr:nth-child(even) td { - background: linear-gradient(to bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); + background: linear-gradient(to bottom, var(--colorbacklineimpai2) 85%, var(--colorbacklineimpair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklineimpair2) 85%, var(--colorbacklineimpair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklineimpair2) 85%, var(--colorbacklineimpair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair2) 85%, var(--colorbacklineimpair2) 100%); font-family: ; border: 0px; margin-bottom: 1px; @@ -3980,10 +3980,10 @@ table.hidepaginationnext .paginationnext { } .noborder > tbody > tr:nth-child(odd) td { - background: linear-gradient(to bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + background: linear-gradient(to bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); font-family: ; border: 0px; margin-bottom: 1px; @@ -4038,10 +4038,10 @@ ul.noborder li:nth-child(odd):not(.liste_titre) { } .impair, .nohover .impair:hover, tr.impair td.nohover { - background: var(--colorbacklineimpair1); + background: var(--colorbacklineimpair2); } #GanttChartDIV { - background-color: var(--colorbacklineimpair1); + background-color: var(--colorbacklineimpair2); } .oddeven, .evenodd, .pair, .nohover .pair:hover, tr.pair td.nohover, .tagtr.oddeven { @@ -4059,12 +4059,12 @@ table.dataTable tr.oddeven { /* For no hover style */ td.oddeven, table.nohover tr.impair, table.nohover tr.pair, table.nohover tr.impair td, table.nohover tr.pair td, tr.nohover td, form.nohover, form.nohover:hover { - background-color: var(--colorbacklineimpair1) !important; - background: var(--colorbacklineimpair1) !important; + background-color: var(--colorbacklineimpair2) !important; + background: var(--colorbacklineimpair2) !important; } td.evenodd, tr.nohoverpair td, #trlinefordates td { - background-color: var(--colorbacklinepair1) !important; - background: var(--colorbacklinepair1) !important; + background-color: var(--colorbacklinepair2) !important; + background: var(--colorbacklinepair2) !important; } .trforbreak td { font-weight: bold; @@ -4277,10 +4277,10 @@ div .tdtop { div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) { - background: linear-gradient(to bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); + background: linear-gradient(to bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); } .noborder > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .noborder .tagtr:nth-child(even):not(:last-of-type) .oddeven.tagtd:not(.liste_titre) From 708d3610a5a6c48e98e8682d674c13fae9d99536 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 13:04:29 +0200 Subject: [PATCH 609/752] Look and feel v16 --- htdocs/comm/propal/card.php | 6 +-- htdocs/commande/card.php | 6 +-- htdocs/core/class/html.form.class.php | 16 ++++--- htdocs/core/class/html.formprojet.class.php | 50 +++++++++++---------- htdocs/core/lib/functions.lib.php | 4 +- htdocs/projet/admin/project.php | 7 +-- 6 files changed, 48 insertions(+), 41 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f6989d90d59..c36c3e86663 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1650,13 +1650,13 @@ if ($action == 'create') { // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'paiment'); + print img_picto('', 'payment', 'class="pictofixedwidth"'); $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print ''; // Mode of payment print ''.$langs->trans('PaymentMode').''; - print img_picto('', 'bank').' '; + print img_picto('', 'bank', 'class="pictofixedwidth').' '; $form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); print ''; @@ -1752,7 +1752,7 @@ if ($action == 'create') { print ''; print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; print ''; - print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0); print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 53b6d40d6b0..d33ea387947 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1670,7 +1670,7 @@ if ($action == 'create' && $usercancreate) { // Terms of the settlement print ''.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'paiment'); + print img_picto('', 'payment', 'class="pictofixedwidth"'); $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); print ''; @@ -1759,10 +1759,10 @@ if ($action == 'create' && $usercancreate) { // Template to use by default print ''.$langs->trans('DefaultModel').''; print ''; - print img_picto('', 'pdf', 'class="pictofixedwidth"'); include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $liste = ModelePDFCommandes::liste_modeles($db); $preselected = $conf->global->COMMANDE_ADDON_PDF; + print img_picto('', 'pdf', 'class="pictofixedwidth"'); print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1); print ""; @@ -1771,7 +1771,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; print ''; - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code'); print ''; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f86fcd88030..749b4dddb13 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5872,6 +5872,7 @@ class Form } $out .= ''; + // Make select dynamic include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); @@ -7753,13 +7754,6 @@ class Form } } - // Add code for jquery to use multiselect - if ($addjscombo && $jsbeautify) { - // Enhance with select2 - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname, array(), 0, 0, 'resolve', $show_empty < 0 ? (string) $show_empty : '-1'); - } - $out .= ''; + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( // 'update' => array( // 'projectid' => 'id' // ) )); - - $out .= ''; } else { $out .= $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss); } if ($discard_closed > 0) { - if (class_exists('Form')) { - if (!is_object($form)) { - $form = new Form($this->db); - } + if (!empty($form)) { $out .= $form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden")); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 24557d1e90e..de31b0d632f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3730,7 +3730,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'briefcase-medical', 'bug', 'building', 'card', 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', 'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cubes', - 'multicurrency', + 'currency', 'multicurrency', 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice', 'edit', 'ellipsis-h', 'email', 'entity', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', @@ -3789,7 +3789,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'filter'=>'filter', 'list-alt'=>'list-alt', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table', - 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', + 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'currency'=>'dollar-sign', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'project-diagram', 'projectpub'=>'project-diagram', 'projecttask'=>'tasks', 'propal'=>'file-signature', diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index adef0826992..37a2bb246ce 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -766,6 +766,7 @@ $form = new Form($db); print '
'; print ''; print ''; +print ''; print ''; print ''; @@ -788,7 +789,7 @@ if (!$conf->use_javascript_ajax) { ); print $form->selectarray("activate_PROJECT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->PROJECT_USE_SEARCH_TO_SELECT); print '"; } print ''; @@ -799,7 +800,7 @@ print ''; print ''; print ''; @@ -818,7 +819,7 @@ print ''; print ''; print ''; print '
'; - print ''; + print ''; print "
'.$langs->trans("AllowToSelectProjectFromOtherCompany").''; print ' '; print $form->textwithpicto('', $langs->trans('AllowToLinkFromOtherCompany')); -print ''; +print ''; print '
'.$langs->trans("TimesheetPreventAfterFollowingMonths").''; print ' '; -print ''; +print ''; print '
'; From 147e61472c382549f4e2889b4390a25719be3534 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 13:10:28 +0200 Subject: [PATCH 610/752] Clean code: Remove all   entities. --- htdocs/adherents/list.php | 2 +- htdocs/comm/propal/card.php | 8 ++++---- htdocs/supplier_proposal/list.php | 4 ++-- htdocs/user/list.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1936d855a7e..b99d763b7b0 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -587,7 +587,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( - //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').' '.$langs->trans("SendByMail"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); if ($user->rights->adherent->creer) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c36c3e86663..07e041a8fd1 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1646,7 +1646,7 @@ if ($action == 'create') { print ''; // Validaty duration - print ''.$langs->trans("ValidityDuration").''.img_picto('', 'clock').'  '.$langs->trans("days").''; + print ''.$langs->trans("ValidityDuration").''.img_picto('', 'clock', 'class="paddingright"').' '.$langs->trans("days").''; // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; @@ -1656,7 +1656,7 @@ if ($action == 'create') { // Mode of payment print ''.$langs->trans('PaymentMode').''; - print img_picto('', 'bank', 'class="pictofixedwidth').' '; + print img_picto('', 'bank', 'class="pictofixedwidth"'); $form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); print ''; @@ -1679,7 +1679,7 @@ if ($action == 'create') { print ' ('.$langs->trans('AfterOrder').')'; } print ''; - print img_picto('', 'clock').' '; + print img_picto('', 'clock', 'class="pictofixedwidth"'); $form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; @@ -1741,7 +1741,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans("DefaultModel").''; print ''; - print img_picto('', 'pdf').' '; + print img_picto('', 'pdf', 'class="pictofixedwidth"'); $liste = ModelePDFPropales::liste_modeles($db); $preselected = (!empty($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT) ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : getDolGlobalString("PROPALE_ADDON_PDF")); print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index ad35c8f9914..c6411f9c169 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -573,10 +573,10 @@ if ($resql) { $arrayofmassactions = array( '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"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if ($user->rights->supplier_proposal->supprimer) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').' '.$langs->trans("Delete"); + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index cd87e286225..9cc1fa88953 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -551,7 +551,7 @@ if ($permissiontoadd) { if ($permissiontoadd) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } -//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').' '.$langs->trans("Delete"); +//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { $arrayofmassactions = array(); From 3780e83615294c888f897b5daf826d7f28a48a11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 13:20:14 +0200 Subject: [PATCH 611/752] Trans --- htdocs/langs/en_US/members.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 8646c40b98f..faa2e0d0fcd 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -15,7 +15,7 @@ ErrorMemberIsAlreadyLinkedToThisThirdParty=Another member (name: %s, logi ErrorUserPermissionAllowsToLinksToItselfOnly=For security reasons, you must be granted permissions to edit all users to be able to link a member to a user that is not yours. SetLinkToUser=Link to a Dolibarr user SetLinkToThirdParty=Link to a Dolibarr third party -MembersCards=Business cards for members +MembersCards=Generation of cards for members MembersList=List of members MembersListToValid=List of draft members (to be validated) MembersListValid=List of valid members @@ -163,7 +163,7 @@ MoreActionsOnSubscription=Complementary action suggested by default when recordi MoreActionBankDirect=Create a direct entry on bank account MoreActionBankViaInvoice=Create an invoice, and a payment on bank account MoreActionInvoiceOnly=Create an invoice with no payment -LinkToGeneratedPages=Generate visit cards +LinkToGeneratedPages=Generation of business cards or address sheets LinkToGeneratedPagesDesc=This screen allows you to generate PDF files with business cards for all your members or a particular member. DocForAllMembersCards=Generate business cards for all members DocForOneMemberCards=Generate business cards for a particular member From fed14db94a5cd9df24b12c5013d44cf47f79e6a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 13:22:46 +0200 Subject: [PATCH 612/752] css --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index de31b0d632f..51741179753 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3866,7 +3866,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'ecm'=>'infobox-action', 'eventorganization'=>'infobox-project', 'hrm'=>'infobox-adherent', 'group'=>'infobox-adherent', 'intervention'=>'infobox-contrat', 'incoterm'=>'infobox-supplier_proposal', - 'multicurrency'=>'infobox-bank_account', + 'currency'=>'infobox-bank_account', 'multicurrency'=>'infobox-bank_account', 'members'=>'infobox-adherent', 'member'=>'infobox-adherent', 'money-bill-alt'=>'infobox-bank_account', 'order'=>'infobox-commande', 'user'=>'infobox-adherent', 'users'=>'infobox-adherent', From 8ad57b3d7ab4c5193afa1d3bf4db84e125e6fcf9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 13:43:51 +0200 Subject: [PATCH 613/752] Fix td --- htdocs/admin/ihm.php | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 2c997d746d9..fdfd8bb8fae 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -485,18 +485,17 @@ if ($mode == 'other') { print ''; print ''; + print $langs->trans("Miscellaneous"); + print ''; + print ''; + print ''; // Max size of lists print ''; - print ''; print ''; // Max size of short lists on customer card print ''; - print ''; print ''; // show input border @@ -504,7 +503,6 @@ if ($mode == 'other') { print ''; - print ''; print ''; */ @@ -512,21 +510,18 @@ if ($mode == 'other') { print ''; - print ''; print ''; // DefaultWorkingDays print ''; - print ''; print ''; // DefaultWorkingHours print ''; - print ''; print ''; // Firstname/Name @@ -534,7 +529,6 @@ if ($mode == 'other') { $array = array(0 => $langs->trans("Firstname") . ' ' . $langs->trans("Lastname"), 1 => $langs->trans("Lastname") . ' ' . $langs->trans("Firstname")); print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0)); print ''; - print ''; print ''; // Hide unauthorized menus @@ -542,7 +536,6 @@ if ($mode == 'other') { //print $form->selectyesno('MAIN_MENU_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_MENU_HIDE_UNAUTHORIZED : 0, 1); print ajax_constantonoff("MAIN_MENU_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); print ''; - print ''; print ''; // Hide unauthorized button @@ -550,7 +543,6 @@ if ($mode == 'other') { //print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED : 0, 1); print ajax_constantonoff("MAIN_BUTTON_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); print ''; - print ''; print ''; // Hide version link @@ -559,7 +551,6 @@ if ($mode == 'other') { print ''; - print ''; print ''; */ @@ -569,7 +560,6 @@ if ($mode == 'other') { print ''; - print ''; print ''; // Hide wiki link on login page @@ -578,7 +568,6 @@ if ($mode == 'other') { print ajax_constantonoff("MAIN_HELP_DISABLELINK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); //print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK) ? $conf->global->MAIN_HELP_DISABLELINK : 0, 1); print ''; - print ''; print ''; // Disable javascript and ajax @@ -586,8 +575,6 @@ if ($mode == 'other') { print ajax_constantonoff("MAIN_DISABLE_JAVASCRIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); print ' ' . $langs->trans("DisableJavascriptNote") . ''; print ''; - print ''; print ''; print '
'; - print $langs->trans("Miscelaneous"); - print ''; - print '
' . $langs->trans("DefaultMaxSizeList") . ' 
' . $langs->trans("DefaultMaxSizeShortList") . ' 
'.$langs->trans("showInputBorder").''; print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1); print ' 
' . $langs->trans("WeekStartOnDay") . ''; print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0); print ' 
' . $langs->trans("DefaultWorkingDays") . ''; print ''; print ' 
' . $langs->trans("DefaultWorkingHours") . ''; print ''; print ' 
 
 
 
'.$langs->trans("HideVersionLink").''; print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1); print ' 
'; print ''; print ' 
 
'; - print '
' . "\n"; From 921aabfc54eb4610f26fc9c8dacc19cbabc54474 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 14:11:38 +0200 Subject: [PATCH 614/752] Look and feel v16 --- htdocs/core/class/html.formfile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1d3faca93cb..acb7d5b5f2a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -246,10 +246,10 @@ class FormFile $out .= ''.$options.''; } $out .= ''; - $out .= ' '; - $out .= ''; + $out .= ' '; + $out .= ''; + $out .= ''; $out .= ''; $out .= ''; } From 223db9bb76f66af8e2ce341699bde4c58910180a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 14:32:47 +0200 Subject: [PATCH 615/752] Fix: Not SetEventMessages inside a CRUD class. --- htdocs/compta/paiement/class/paiement.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index c5f40896a18..ae4064462e2 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -419,7 +419,8 @@ class Paiement extends CommonObject } if ($error) { - setEventMessages($discount->error, $discount->errors, 'errors'); + $this->error = $discount->error; + $this->errors = $discount->errors; $error++; } } @@ -460,7 +461,8 @@ class Paiement extends CommonObject $result = $invoice->generateDocument($invoice->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) { - setEventMessages($invoice->error, $invoice->errors, 'errors'); + $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } } From 8b248c75f29eff7a9ab61846bdc7f23ee5bf8c05 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 29 Apr 2022 15:10:15 +0200 Subject: [PATCH 616/752] Factor save --- htdocs/core/actions_massactions.inc.php | 58 +++++++------------------ 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5f5703fc872..ccf2fbec73e 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1602,56 +1602,29 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == } } -if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' && $permissiontoadd){ +if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' && $permissiontoadd) { $db->begin(); - /** @var CommonObject $objecttmp */ - $objecttmp = new $objectclass($db); - $nbok = 0; - $e = new ExtraFields($db); - $e->fetch_name_optionals_label($objecttmp->table_element); + $extrafieldKeyToUpdate = GETPOST('extrafield-key-yo-update'); // TODO A FAIRE coté formulaire : ajouter le select de l'extrafield a utiliser + $extrafieldKeyToUpdate = 'code_tva_achat'; // TODO A FAIRE coté formulaire : ajouter le select de l'extrafield a utiliser + + // TODO vérifier que $extrafieldKeyToUpdate correspond bien a un extrafield foreach ($toselect as $toselectid) { + /** @var CommonObject $objecttmp */ + $objecttmp = new $objectclass($db); $result = $objecttmp->fetch($toselectid); - if ($result>0) { - - if (isset($e->attributes[$objecttmp->table_element]['type']) && is_array($e->attributes[$objecttmp->table_element]['type'])) { - foreach ($e->attributes[$objecttmp->table_element]['type'] as $key => $type){ - - //Permet de gérer les types d'extrafields - if (in_array($type, array('price', 'double'))) { - $value_arr = GETPOST("options_".$key, 'alpha'); - if(empty($value_arr)){ - continue; - } - $value_key = price2num($value_arr); - //var_dump($value_key);exit; - }else if (in_array($type, array('date'))) { - // Clean parameters - $value_key = dol_mktime(12, 0, 0, GETPOST("options_" . $key . "month", 'int'), GETPOST("options_" . $key . "day", 'int'), GETPOST("options_" . $key . "year", 'int')); - //var_dump($value_key);exit; - if(empty($value_key)){ - continue; - } - }else if (in_array($type, array('datetime'))) { - // Clean parameters - $value_key = dol_mktime(GETPOST("options_".$key."hour", 'int'), GETPOST("options_".$key."min", 'int'), GETPOST("options_".$key."sec", 'int'), GETPOST("options_".$key."month", 'int'), GETPOST("options_".$key."day", 'int'), GETPOST("options_".$key."year", 'int'), 'tzuserrel'); - if(empty($value_key)){ - continue; - } - } else { - $value_key = GETPOST("options_".$key); - if ((in_array($type, array('link')) && $key == '-1') || empty($value_key)) { - continue; - } - } - $objecttmp->array_options["options_".$key] = $value_key; - } + // Fill array 'array_options' with data from add form + $e = new ExtraFields($db); + $ret = $e->setOptionalsFromPost(null, $objecttmp, $extrafieldKeyToUpdate); + if ($ret > 0) { + $objecttmp->insertExtraFields(); // TODO gérer l'erreur + } else { + $error++; + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); } - $objecttmp->insertExtraFields(); - } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; @@ -1669,7 +1642,6 @@ if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' } else { $db->rollback(); } - } // Approve for leave only From 02cf3fa36102ecebd890d5d9d12652d01d1aad0d Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 29 Apr 2022 15:38:12 +0200 Subject: [PATCH 617/752] end factoring --- htdocs/core/actions_massactions.inc.php | 12 +++++++----- htdocs/core/tpl/massactions_pre.tpl.php | 6 +++++- htdocs/product/list.php | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index ccf2fbec73e..6308c33d268 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1605,20 +1605,22 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' && $permissiontoadd) { $db->begin(); - $nbok = 0; + $objecttmp = new $objectclass($db); + $e = new ExtraFields($db);// fetch optionals attributes and labels + $e->fetch_name_optionals_label($objecttmp->table_element); - $extrafieldKeyToUpdate = GETPOST('extrafield-key-yo-update'); // TODO A FAIRE coté formulaire : ajouter le select de l'extrafield a utiliser - $extrafieldKeyToUpdate = 'code_tva_achat'; // TODO A FAIRE coté formulaire : ajouter le select de l'extrafield a utiliser + $nbok = 0; + $extrafieldKeyToUpdate = GETPOST('extrafield-key-to-update'); // TODO A FAIRE coté formulaire : ajouter le select de l'extrafield a utiliser // TODO vérifier que $extrafieldKeyToUpdate correspond bien a un extrafield foreach ($toselect as $toselectid) { /** @var CommonObject $objecttmp */ - $objecttmp = new $objectclass($db); + $objecttmp = new $objectclass($db); // to avoid ghost data $result = $objecttmp->fetch($toselectid); if ($result>0) { // Fill array 'array_options' with data from add form - $e = new ExtraFields($db); $ret = $e->setOptionalsFromPost(null, $objecttmp, $extrafieldKeyToUpdate); + if ($ret > 0) { $objecttmp->insertExtraFields(); // TODO gérer l'erreur } else { diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 40394cb99ff..8e364cd24e1 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -212,7 +212,6 @@ if ($massaction == 'presend') { } if ($massaction == 'edit_extrafields') { - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $elementtype = 'product'; /** @var CommonObject $objecttmp */ @@ -225,6 +224,11 @@ if ($massaction == 'edit_extrafields') { if (!empty($extrafields_list)) { $myParamExtra = $object->showOptionals($extrafields, 'create'); + $formquestion[] = array( + 'type' => 'other', + 'value' => $form->selectarray('extrafield-key-to-update', $extrafields_list, GETPOST('extrafield-key-to-update')) + ); + $formquestion[] = array( 'type' => 'other', 'value' => $object->showOptionals($extrafields, 'create') diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 7cd0a91c923..4824015c299 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -740,7 +740,7 @@ if ($resql) { $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus"); $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } - if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { + if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); From 3dd90ecf416d7e62e94b20110f66d9ef84228568 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Apr 2022 16:02:05 +0200 Subject: [PATCH 618/752] js escape --- htdocs/takepos/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index d934765b846..1b1608d53e7 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -946,7 +946,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {