Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2024-10-01 15:01:18 +02:00
commit 6b2fa56d52
7 changed files with 80 additions and 58 deletions

View File

@ -106,6 +106,7 @@ if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.form_index.action.value="updateedit";
document.form_index.submit();
});

View File

@ -426,6 +426,7 @@ if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.form_index.action.value="updateedit";
document.form_index.submit();
});

View File

@ -1365,6 +1365,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
print '<script type="text/javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.formprod.action.value="create";
document.formprod.submit();
});

View File

@ -238,9 +238,22 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
accessforbidden('', 0);
}
if (!empty($conf->use_javascript_ajax)) {
print '<script type="text/javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.formresource.action.value="create";
document.formresource.submit();
});
});';
print '</script>'."\n";
}
// Create/Edit object
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">';
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST" name="formresource">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="'.($action == "create" ? "add" : "update").'">';
@ -250,56 +263,10 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("ResourceFormLabel_ref").'</td>';
print '<td><input class="minwidth200" name="ref" value="'.($ref ?: $object->ref).'" autofocus="autofocus"></td></tr>';
// Address
print '<tr><td class="tdtop">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
print dol_escape_htmltag($object->address, 0, 1);
print '</textarea>';
print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
print '</td></tr>';
// Zip
print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
print $formresource->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
print '</td>';
print '</tr>';
// Town
print '<tr>';
print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
print $formresource->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
print '</td></tr>';
// Origin country
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
print $form->select_country($object->country_id);
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>';
// State
if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) {
print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
} else {
print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
}
if ($object->country_id) {
print img_picto('', 'state', 'class="pictofixedwidth"');
print $formresource->select_state($object->state_id, $object->country_code);
} else {
print $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
}
print '</td></tr>';
}
// Type
print '<tr><td>'.$langs->trans("ResourceType").'</td>';
print '<td>';
$formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2);
$formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2, 0, 0, 0, 1, 'minwidth200');
print '</td></tr>';
// Description
@ -310,6 +277,53 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
$doleditor->Create();
print '</td></tr>';
// Address
print '<tr><td class="tdtop">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
print dol_escape_htmltag(GETPOSTISSET('address') ? GETPOST('address') : $object->address, 0, 1);
print '</textarea>';
print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
print '</td></tr>';
// Zip
print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
print $formresource->select_ziptown(GETPOSTISSET('zipcode') ? GETPOST('zipcode') : $object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
print '</td>';
print '</tr>';
// Town
print '<tr>';
print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
print $formresource->select_ziptown(GETPOSTISSET('town') ? GETPOST('town') : $object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
print '</td></tr>';
// Origin country
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
print $form->select_country(GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id, 'country_id');
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>';
// State
$countryid = GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id;
if (!getDolGlobalString('SOCIETE_DISABLE_STATE') && $countryid > 0) {
if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) {
print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
} else {
print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
}
if ($country_id > 0) {
print img_picto('', 'state', 'class="pictofixedwidth"');
print $formresource->select_state($countryid, $country_id);
} else {
print '<span class="opacitymedium">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</span>';
}
print '</td></tr>';
}
// Phone
print '<td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
print '<td>';
@ -328,7 +342,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
print '<tr><td>'.$form->editfieldkey('MaxUsers', 'max_users', '', $object, 0).'</td>';
print '<td>';
print img_picto('', 'object_user', 'class="pictofixedwidth"');
print '<input type="number" name="max_users" id="max_users" value="'.(GETPOSTISSET('max_users') ? GETPOSTINT('max_users') : $object->max_users).'"></td>';
print '<input type="text" class="width75 right" name="max_users" id="max_users" value="'.(GETPOSTISSET('max_users') ? GETPOST('max_users', 'int') : $object->max_users).'"></td>';
print '</tr>';
// URL

View File

@ -51,17 +51,17 @@ class Dolresource extends CommonObject
public $picto = 'resource';
/**
* @var string description
* @var string Description
*/
public $description;
/**
* @var string telephone number
* @var string Phone number
*/
public $phone;
/**
* @var int Maximum users
* @var int|null Maximum users
*/
public $max_users;
@ -375,9 +375,6 @@ class Dolresource extends CommonObject
if (isset($this->email)) {
$this->email = trim($this->email);
}
if (!is_numeric($this->max_users)) {
$this->max_users = 0;
}
if (isset($this->url)) {
$this->url = trim($this->url);
}

View File

@ -175,9 +175,11 @@ class FormResource
* @param int $empty 1=peut etre vide, 0 sinon
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param int $usejscombo 1=Use jscombo, 0=No js combo
* @param string $morecss Add more css
* @return void
*/
public function select_types_resource($selected = '', $htmlname = 'type_resource', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0)
public function select_types_resource($selected = '', $htmlname = 'type_resource', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $usejscombo = 0, $morecss = 'minwidth100')
{
// phpcs:enable
global $langs, $user;
@ -193,7 +195,7 @@ class FormResource
}
$resourcestat->loadCacheCodeTypeResource();
print '<select id="select'.$htmlname.'" class="flat maxwidthonsmartphone select_'.$htmlname.'" name="'.$htmlname.'">';
print '<select id="select'.$htmlname.'" class="flat maxwidthonsmartphone select_'.$htmlname.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) {
print '<option value="">&nbsp;</option>';
}
@ -237,6 +239,10 @@ class FormResource
}
}
print '</select>';
if ($usejscombo) {
print ajax_combobox("select".$htmlname);
}
if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}

View File

@ -1294,6 +1294,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
}
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.formsoc.action.value="create";
document.formsoc.submit();
});
@ -1303,7 +1304,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc" autocomplete="off">'; // Chrome ignor autocomplete
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc" autocomplete="off">'; // Chrome ignores autocomplete
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -2237,6 +2238,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
}
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.formsoc.action.value="edit";
document.formsoc.submit();
});