diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 51bac0047f9b6..6a06fa470e3dd 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -194,7 +194,7 @@ $oldyear--; print '
Text
. this.dataProcessor.writer.setRules( \'p\', { indent : false, @@ -242,15 +247,13 @@ public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $ }); }, /* This is to remove the tab Link on image popup. Does not work, so commented */ - /* - dialogDefinition: function (event) { + /* dialogDefinition: function (event) { var dialogName = event.data.name; var dialogDefinition = event.data.definition; if (dialogName == \'image\') { dialogDefinition.removeContents(\'Link\'); } - } - */ + } */ }, disableNativeSpellChecker: '.(getDolGlobalString('CKEDITOR_NATIVE_SPELLCHECKER') ? 'false' : 'true'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bf9d62b664338..1584500188b04 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11062,7 +11062,8 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, */ function printCommonFooter($zone = 'private') { - global $conf, $hookmanager, $user, $debugbar; + global $conf, $hookmanager, $user, $langs; + global $debugbar; global $action; global $micro_start_time; @@ -11110,6 +11111,7 @@ function printCommonFooter($zone = 'private') $relativepathstring = preg_replace('/^\//', '', $relativepathstring); $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); //$tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + if (!empty($user->default_values[$relativepathstring]['focus'])) { foreach ($user->default_values[$relativepathstring]['focus'] as $defkey => $defval) { $qualified = 0; @@ -11132,10 +11134,11 @@ function printCommonFooter($zone = 'private') } if ($qualified) { + print 'console.log("set the focus by executing jQuery(...).focus();")'."\n"; foreach ($defval as $paramkey => $paramval) { // Set focus on field print 'jQuery("input[name=\''.$paramkey.'\']").focus();'."\n"; - print 'jQuery("textarea[name=\''.$paramkey.'\']").focus();'."\n"; + print 'jQuery("textarea[name=\''.$paramkey.'\']").focus();'."\n"; // TODO KO with ckeditor print 'jQuery("select[name=\''.$paramkey.'\']").focus();'."\n"; // Not really useful, but we keep it in case of. } } @@ -11163,19 +11166,72 @@ function printCommonFooter($zone = 'private') } if ($qualified) { + print 'console.log("set the js code to manage fields that are set as mandatory");'."\n"; + foreach ($defval as $paramkey => $paramval) { - // Add property 'required' on input - print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; - print 'jQuery("textarea[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; - print '// required on a select works only if key is "", so we add the required attributes but also we reset the key -1 or 0 to an empty string'."\n"; - print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; - print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'-1\']").prop(\'value\', \'\');'."\n"; - print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'0\']").prop(\'value\', \'\');'."\n"; + // Solution 1: Add handler on submit to check if mandatory fields are empty + print 'var form = $(\'#'.dol_escape_js($paramkey).'\').closest("form");'."\n"; + print "form.on('submit', function(event) { + var submitter = event.originalEvent.submitter; + if (submitter) { + var buttonName = $(submitter).attr('name'); + if (buttonName == 'cancel') { + console.log('We click on cancel button so we accept submit with no need to check mandatory fields'); + return true; + } + } + console.log('We did not click on cancel button but on something else, we check that field #".dol_escape_js($paramkey)." is not empty'); + + var tmpvalue = jQuery('#".dol_escape_js($paramkey)."').val(); + let tmptypefield = jQuery('#".dol_escape_js($paramkey)."').prop('nodeName').toLowerCase(); // Get the tag name (div, section, footer...) + + if (tmptypefield == 'textarea') { + // We must instead check the content of ckeditor + var tmpeditor = CKEDITOR.instances['".dol_escape_js($paramkey)."']; + if (tmpeditor) { + tmpvalue = tmpeditor.getData(); + console.log('For textarea tmpvalue is '+tmpvalue); + } + } + + let tmpvalueisempty = false; + if (tmpvalue === null || tmpvalue === undefined || tmpvalue === '') { + tmpvalueisempty = true; + } + if (tmpvalue === '0' && tmptypefield == 'select') { + tmpvalueisempty = true; + } + if (tmpvalueisempty) { + console.log('field has type '+tmptypefield+' and is empty, we cancel the submit'); + event.preventDefault(); // Stop submission of form to allow custom code to decide. + event.stopPropagation(); // Stop other handlers. + alert('".dol_escape_js($langs->trans("ErrorFieldRequired", $paramkey).' ('.$langs->trans("CustomMandatoryFieldRule").')')."'); + return false; + } + console.log('field has type '+tmptypefield+' and is defined to '+tmpvalue); + return true; + }); + \n"; + + // Solution 2: Add property 'required' on input + // so browser will check value and try to focus on it when submitting the form. + //print 'setTimeout(function() {'; // If we want to wait that ckeditor beuatifier has finished its job. + //print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; + //print 'jQuery("textarea[id=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; + //print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";*/ + //print '// required on a select works only if key is "", so we add the required attributes but also we reset the key -1 or 0 to an empty string'."\n"; + //print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'-1\']").prop(\'value\', \'\');'."\n"; + //print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'0\']").prop(\'value\', \'\');'."\n"; // Add 'field required' class on closest td for all input elements : input, textarea and select - print 'jQuery(":input[name=\'' . $paramkey . '\']").closest("tr").find("td:first").addClass("fieldrequired");' . "\n"; + //print '}, 500);'; // 500 milliseconds delay + + // Now set the class "fieldrequired" + print 'jQuery(\':input[name="' . dol_escape_js($paramkey) . '"]\').closest("tr").find("td:first").addClass("fieldrequired");'."\n"; } - // If we submit the cancel button we remove the required attributes + + + // If we submit using the cancel button, we remove the required attributes print 'jQuery("input[name=\'cancel\']").click(function() { console.log("We click on cancel button so removed all required attribute"); jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');}); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 9c4d9a872b42e..fa7c86a86ddb3 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -760,8 +760,8 @@ if ($lines[$i]->fk_product > 0) { // line without lot if ($lines[$i]->entrepot_id == 0) { - // single warehouse shipment line - $stockLocation = 0; + // single warehouse shipment line or line in several warehouses context but with warehouse not defined + $stockLocation = "entl".$line_id; $qty = "qtyl".$line_id; $line->id = $line_id; $line->entrepot_id = GETPOSTINT((string) $stockLocation); diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index 576ced1ee8b27..aa869240a4281 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -219,6 +219,6 @@ UPDATE llx_c_type_contact SET element = 'stocktransfer' WHERE element = 'StockTr UPDATE llx_c_units SET scale = 1 WHERE code = 'S'; -UPDATE llx_c_tva SET taux = 3, note = 'Νήσων υπερμειωμένος Φ.Π.Α.' WHERE fk_pays = 102 AND taux = 16; +UPDATE llx_c_tva SET taux = 3 WHERE fk_pays = 102 AND taux = 16; UPDATE llx_menu SET url = CONCAT(url, '&mode=init') WHERE fk_mainmenu = 'ticket' AND titre = 'NewTicket' AND url LIKE '/ticket/card.php?action=create%' AND url NOT LIKE '%mode=init%'; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index f217b1989857f..4bc2475f6fe87 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -222,7 +222,7 @@ ErrorUserNotAssignedToTask=User must be assigned to task to be able to enter tim ErrorTaskAlreadyAssigned=Task already assigned to user ErrorModuleFileSeemsToHaveAWrongFormat=The module package seems to have a wrong format. ErrorModuleFileSeemsToHaveAWrongFormat2=At least one mandatory directory must exists into zip of module: %s or %s -ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (%s) does not match expected name syntax: %s +ErrorFilenameDosNotMatchDolibarrPackageRules=The file name of the module package (%s) does not match the expected name syntax: %s ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s. ErrorNoWarehouseDefined=Error, no warehouses defined. ErrorBadLinkSourceSetButBadValueForRef=The link you use is not valid. A 'source' for payment is defined, but value for 'ref' is not valid. @@ -422,4 +422,4 @@ OperNotDefined=Payment method not defined ErrorThisContactXIsAlreadyDefinedAsThisType=%s is already defined as contact for this type. ErrorThisGroupIsAlreadyDefinedAsThisType=The contacts with this group are already defined as contact for this type. EmptyMessageNotAllowedError=Empty message is not allowed -ErrorIsNotInError=%s is not in error \ No newline at end of file +ErrorIsNotInError=%s is not in error diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index bedc6a60e081a..f8e6f2ccede71 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -45,6 +45,7 @@ NoError=No error Error=Error Errors=Errors ErrorFieldRequired=Field '%s' is required +CustomMandatoryFieldRule=Custom "Mandatory field" rule ErrorFieldFormat=Field '%s' has a bad value ErrorFileDoesNotExists=File %s does not exist ErrorFailedToOpenFile=Failed to open file %s diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 8bf690d5f6273..eafcfbd81441f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1437,7 +1437,7 @@ } // Label - print '