forked from Wavyzz/dolibarr
Debug v19
This commit is contained in:
@@ -363,8 +363,6 @@ class FormAdmin
|
||||
public function select_timezone($selected, $htmlname)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
print '<option value="-1"> </option>';
|
||||
|
||||
@@ -474,4 +472,41 @@ class FormAdmin
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to shwo the combo select to chose a type of field (varchar, int, email, ...)
|
||||
*
|
||||
* @param string $htmlname Name of HTML select component
|
||||
* @param string $type Type preselected
|
||||
* @param string $typewecanchangeinto Array of possible switch combination from 1 type to another one. This will grey not possible combinations.
|
||||
* @return string The combo HTML select component
|
||||
*/
|
||||
public function selectTypeOfFields($htmlname, $type, $typewecanchangeinto = array())
|
||||
{
|
||||
global $type2label; // TODO Remove this
|
||||
|
||||
$out = '';
|
||||
|
||||
$out .= '<select class="flat type" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
foreach ($type2label as $key => $val) {
|
||||
$selected = '';
|
||||
if ($key == $type) {
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
|
||||
// Set $valhtml with the picto for the type
|
||||
$valhtml = ($key ? getPictoForType($key) : '').$val;
|
||||
|
||||
if (empty($typewecanchangeinto) || in_array($key, $typewecanchangeinto[$type])) {
|
||||
$out .= '<option value="'.$key.'"'.$selected.' data-html="'.dol_escape_htmltag($valhtml).'">'.($val ? $val : ' ').'</option>';
|
||||
} else {
|
||||
$out .= '<option value="'.$key.'" disabled="disabled"'.$selected.' data-html="'.dol_escape_htmltag($valhtml).'">'.($val ? $val : ' ').'</option>';
|
||||
}
|
||||
}
|
||||
$out .= '</select>';
|
||||
$out .= ajax_combobox('type');
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,14 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
|
||||
$type = 'double'; // html modulebuilder type is a text type in database
|
||||
} elseif (in_array($type, array('link', 'sellist', 'duration'))) {
|
||||
$type = 'integer';
|
||||
} elseif ($type == 'mail') {
|
||||
$type = 'varchar(128)';
|
||||
} elseif ($type == 'phone') {
|
||||
$type = 'varchar(20)';
|
||||
} elseif ($type == 'ip') {
|
||||
$type = 'varchar(32)';
|
||||
}
|
||||
|
||||
$texttoinsert .= "\t".$key." ".$type;
|
||||
if ($key == 'rowid') {
|
||||
$texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
|
||||
|
||||
@@ -974,7 +974,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
|
||||
$sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";
|
||||
$sql .= " AND entity IN (0, ".$conf->entity.")";
|
||||
$sql .= " AND entity IN (0, ".((int) $conf->entity).")";
|
||||
|
||||
dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@@ -158,20 +158,12 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php<br>Contact:con
|
||||
<!-- Type -->
|
||||
<tr><td class="fieldrequired"><?php echo $langs->trans("Type"); ?></td><td class="valeur">
|
||||
<?php
|
||||
print '<select id="type" class="flat type" name="type">';
|
||||
foreach ($type2label as $key => $val) {
|
||||
$selected = '';
|
||||
if ($key == GETPOST('type', 'alpha')) {
|
||||
$selected = ' selected="selected"';
|
||||
// Combo with list of fields
|
||||
if (empty($formadmin)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
$formadmin = new FormAdmin($db);
|
||||
}
|
||||
|
||||
// Set $valhtml with the picto for the type
|
||||
$valhtml = ($key ? getPictoForType($key) : '').$val;
|
||||
|
||||
print '<option value="'.$key.'"'.$selected.' data-html="'.dol_escape_htmltag($valhtml).'">'.($val ? $val : ' ').'</option>';
|
||||
}
|
||||
print '</select>';
|
||||
print ajax_combobox('type');
|
||||
print $formadmin->selectTypeOfFields('type', GETPOST('type', 'alpha'));
|
||||
?>
|
||||
</td></tr>
|
||||
<!-- Size -->
|
||||
|
||||
@@ -216,24 +216,12 @@ if ($size <= 255 && in_array($type, array('text', 'html'))) {
|
||||
}*/
|
||||
|
||||
if (in_array($type, array_keys($typewecanchangeinto))) {
|
||||
print '<select id="type" class="flat type" name="type">';
|
||||
foreach ($type2label as $key => $val) {
|
||||
$selected = '';
|
||||
if ($key == (GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : $type)) {
|
||||
$selected = ' selected="selected"';
|
||||
// Combo with list of fields
|
||||
if (empty($formadmin)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
$formadmin = new FormAdmin($db);
|
||||
}
|
||||
|
||||
// Set $valhtml with the picto for the type
|
||||
$valhtml = ($key ? getPictoForType($key) : '').$val;
|
||||
|
||||
if (in_array($key, $typewecanchangeinto[$type])) {
|
||||
print '<option value="'.$key.'"'.$selected.' data-html="'.dol_escape_htmltag($valhtml).'">'.$val.'</option>';
|
||||
} else {
|
||||
print '<option value="'.$key.'" disabled="disabled"'.$selected.' data-html="'.dol_escape_htmltag($valhtml).'">'.$val.'</option>';
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
print ajax_combobox('type');
|
||||
print $formadmin->selectTypeOfFields('type', GETPOST('type', 'alpha') ? GETPOST('type', 'alpha') : $type, $typewecanchangeinto);
|
||||
} else {
|
||||
print getPictoForType($type).$type2label[$type];
|
||||
print '<input type="hidden" name="type" id="type" value="'.$type.'">';
|
||||
|
||||
@@ -149,7 +149,7 @@ CSSListClass=CSS for list
|
||||
NotEditable=Not editable
|
||||
ForeignKey=Foreign key
|
||||
ForeignKeyDesc=If the value of this field must be guaranted to exists into another table. Enter here a value matching syntax: tablename.parentfieldtocheck
|
||||
TypeOfFieldsHelp=Example:<br>varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]]<br><br>'1' means we add a + button after the combo to create the record<br>'filter' is an Universal Filter syntax condition, example: '((status:=:1) AND (fk_user:=:__USER_ID__) AND (entity:IN:(__SHARED_ENTITIES__))'
|
||||
TypeOfFieldsHelp=Example:<br>varchar(99)<br>email<br>phone<br>ip<br>url<br>password<br>double(24,8)<br>real<br>text<br>html<br>date<br>datetime<br>timestamp<br>integer<br>integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]]<br><br>'1' means we add a + button after the combo to create the record<br>'filter' is an Universal Filter syntax condition, example: '((status:=:1) AND (fk_user:=:__USER_ID__) AND (entity:IN:(__SHARED_ENTITIES__))'
|
||||
TypeOfFieldsHelpIntro=This is the type of the field/attribute.
|
||||
AsciiToHtmlConverter=Ascii to HTML converter
|
||||
AsciiToPdfConverter=Ascii to PDF converter
|
||||
|
||||
@@ -350,21 +350,9 @@ if ($dirins && $action == 'initmodule' && $modulename) {
|
||||
'500000'=>$idmodule
|
||||
);
|
||||
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) {
|
||||
$arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) {
|
||||
$arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
|
||||
$arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) {
|
||||
$arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) {
|
||||
$arrayreplacement['modulefamily'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
|
||||
}
|
||||
|
||||
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
||||
//var_dump($result);
|
||||
@@ -1031,7 +1019,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
||||
setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors');
|
||||
} else {
|
||||
/**
|
||||
* 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
* 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'ip', 'url', 'password')
|
||||
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'picto' is code of a picto to show before value in forms
|
||||
@@ -1521,21 +1509,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
||||
'---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '')
|
||||
);
|
||||
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) {
|
||||
$arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) {
|
||||
$arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
|
||||
$arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) {
|
||||
$arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
|
||||
}
|
||||
if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) {
|
||||
$arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
|
||||
}
|
||||
|
||||
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
||||
//var_dump($result);
|
||||
@@ -3884,7 +3860,34 @@ if ($module == 'initmodule') {
|
||||
if ($key == 'propname' || $key == 'proplabel') {
|
||||
print '<td class="titlefieldcreate fieldrequired">'.$attribute.'</td><td class="valuefieldcreate maxwidth50"><input class="maxwidth200" id="'.$key.'" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"></td>';
|
||||
} elseif ($key == 'proptype') {
|
||||
print '<td class="titlefieldcreate fieldrequired">'.$attribute.'</td><td class="valuefieldcreate maxwidth50"><div style="position: relative;"><input class="maxwidth200" id="'.$key.'" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"><div id="suggestions"></div><div></td>';
|
||||
print '<td class="titlefieldcreate fieldrequired">'.$attribute.'</td><td class="valuefieldcreate maxwidth50">';
|
||||
print '<input class="maxwidth200" id="'.$key.'" list="datalist'.$key.'" type="text" name="'.$key.'" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'">';
|
||||
//print '<div id="suggestions"></div>';
|
||||
print '<datalist id="datalist'.$key.'">';
|
||||
print '<option>varchar(128)</option>';
|
||||
print '<option>email</option>';
|
||||
print '<option>phone</option>';
|
||||
print '<option>ip</option>';
|
||||
print '<option>url</option>';
|
||||
print '<option>password</option>';
|
||||
print '<option>text</option>';
|
||||
print '<option>html</option>';
|
||||
print '<option>date</option>';
|
||||
print '<option>datetime</option>';
|
||||
print '<option>integer</option>';
|
||||
print '<option>double(28,4)</option>';
|
||||
print '<option>real</option>';
|
||||
print '<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
|
||||
// Combo with list of fields
|
||||
/*
|
||||
if (empty($formadmin)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
$formadmin = new FormAdmin($db);
|
||||
}
|
||||
print $formadmin->selectTypeOfFields($key, GETPOST($key, 'alpha'));
|
||||
*/
|
||||
print '</datalist>';
|
||||
print '</td>';
|
||||
//} elseif ($key == 'propvalidate') {
|
||||
// print '<td class="titlefieldcreate">'.$attribute.'</td><td class="valuefieldcreate maxwidth50"><input type="number" step="1" min="0" max="1" class="text maxwidth100" value="'.dol_escape_htmltag(GETPOST($key, 'alpha')).'"></td>';
|
||||
} elseif ($key == 'propvisible') {
|
||||
@@ -3923,70 +3926,12 @@ if ($module == 'initmodule') {
|
||||
window.location.href = url;
|
||||
}
|
||||
$(document).ready(function() {
|
||||
// Tableau de suggestions statiques
|
||||
var suggestions = ["VARCHAR", "DOUBLE", "REAL", "TEXT", "HTML", "DATETIME", "TIMESTAMP", "INTEGER", "INTEGER:CLASSNAME:RELATIVEPATH/TO/CLASSFILE.CLASS.PHP[:1[:FILTER]]"];
|
||||
|
||||
function showSuggestions() {
|
||||
var inputText = $("#proptype").val().toLowerCase();
|
||||
var suggestionsDiv = $("#suggestions");
|
||||
|
||||
var filteredSuggestions = suggestions.filter(function(suggestion) {
|
||||
return suggestion.toLowerCase().indexOf(inputText) !== -1;
|
||||
});
|
||||
|
||||
//get suggestion on div
|
||||
suggestionsDiv.empty();
|
||||
for (var i = 0; i < filteredSuggestions.length; i++) {
|
||||
var suggestion = filteredSuggestions[i];
|
||||
var suggestionItem = $("<div>").text(suggestion).css({ cursor: "pointer", padding: "5px" });
|
||||
suggestionsDiv.append(suggestionItem);
|
||||
}
|
||||
|
||||
|
||||
if (inputText === "" || filteredSuggestions.length === 0) {
|
||||
suggestionsDiv.hide();
|
||||
} else {
|
||||
suggestionsDiv.show();
|
||||
}
|
||||
}
|
||||
|
||||
$("#proptype").on("input", showSuggestions);
|
||||
|
||||
$("#suggestions").on("click", "div", function() {
|
||||
var selectedValue = $(this).text();
|
||||
$("#proptype").val(selectedValue);
|
||||
$("#suggestions").hide();
|
||||
});
|
||||
// when we click outside the input
|
||||
$(document).on("click", function(event) {
|
||||
if (!$(event.target).closest("#proptype, #suggestions").length) {
|
||||
$("#suggestions").hide();
|
||||
}
|
||||
});
|
||||
// when we delete the content input
|
||||
$("#proptype").on("keyup", function() {
|
||||
if ($(this).val() === "") {
|
||||
$("#suggestions").hide();
|
||||
}
|
||||
});
|
||||
|
||||
$("#proplabel").on("keyup", function() {
|
||||
console.log("key up on label");
|
||||
s = cleanString($("#proplabel").val());
|
||||
$("#propname").val(s);
|
||||
});
|
||||
|
||||
// when hover in suggestion
|
||||
$("#suggestions").on("mouseenter", "div", function() {
|
||||
console.log("enter suggestion");
|
||||
$(this).css("background-color", "#e0e0e0");
|
||||
});
|
||||
|
||||
$("#suggestions").on("mouseleave", "div", function() {
|
||||
console.log("leave suggestion");
|
||||
$(this).css("background-color", "#fff");
|
||||
});
|
||||
|
||||
function cleanString( stringtoclean )
|
||||
{
|
||||
// allow "a-z", "A-Z", "0-9" and "_"
|
||||
@@ -4001,7 +3946,7 @@ if ($module == 'initmodule') {
|
||||
if (stringtoclean.length > 28) {
|
||||
stringtoclean = stringtoclean.substring(0, 27);
|
||||
}
|
||||
return stringtoclean
|
||||
return stringtoclean;
|
||||
}
|
||||
|
||||
});';
|
||||
|
||||
Reference in New Issue
Block a user