mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
FIX Selection of country - state in resource
This commit is contained in:
parent
de99be3a10
commit
075d0dee3c
|
|
@ -105,6 +105,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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -424,6 +424,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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1325,6 +1325,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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -237,9 +237,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").'">';
|
||||
|
||||
|
|
@ -249,56 +262,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
|
||||
|
|
@ -309,6 +276,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>';
|
||||
|
|
@ -327,7 +341,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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,9 +174,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;
|
||||
|
|
@ -192,7 +194,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=""> </option>';
|
||||
}
|
||||
|
|
@ -236,6 +238,10 @@ class FormResource
|
|||
}
|
||||
}
|
||||
print '</select>';
|
||||
if ($usejscombo) {
|
||||
print ajax_combobox("select".$htmlname);
|
||||
}
|
||||
|
||||
if ($user->admin && !$noadmininfo) {
|
||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1193,6 +1193,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();
|
||||
});
|
||||
|
|
@ -1202,7 +1203,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().'">';
|
||||
|
|
@ -2036,6 +2037,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();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user