diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index a78c9efba7d..f514625989b 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -106,6 +106,7 @@ if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; + } + + // Create/Edit object - print '
'; + print ''; print ''; print ''; @@ -250,56 +263,10 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { print ''.$langs->trans("ResourceFormLabel_ref").''; print ''; - // Address - print ''.$form->editfieldkey('Address', 'address', '', $object, 0).''; - print ''; - print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); - print ''; - - // Zip - print ''.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; - print $formresource->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100'); - print ''; - print ''; - - // Town - print ''; - print ''.$form->editfieldkey('Town', 'town', '', $object, 0).''; - print $formresource->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); - print ''; - - // Origin country - print ''.$langs->trans("CountryOrigin").''; - print $form->select_country($object->country_id); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print ''; - - // State - if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) { - if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) { - print ''.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; - } else { - print ''.$form->editfieldkey('State', 'state_id', '', $object, 0).''; - } - - 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 ''; - } - // Type print ''.$langs->trans("ResourceType").''; print ''; - $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 ''; // Description @@ -310,6 +277,53 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { $doleditor->Create(); print ''; + // Address + print ''.$form->editfieldkey('Address', 'address', '', $object, 0).''; + print ''; + print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print ''; + + // Zip + print ''.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; + print $formresource->select_ziptown(GETPOSTISSET('zipcode') ? GETPOST('zipcode') : $object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100'); + print ''; + print ''; + + // Town + print ''; + print ''.$form->editfieldkey('Town', 'town', '', $object, 0).''; + 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 ''; + + // Origin country + print ''.$langs->trans("CountryOrigin").''; + 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 ''; + + // 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 ''.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; + } else { + print ''.$form->editfieldkey('State', 'state_id', '', $object, 0).''; + } + + if ($country_id > 0) { + print img_picto('', 'state', 'class="pictofixedwidth"'); + print $formresource->select_state($countryid, $country_id); + } else { + print ''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + } + print ''; + } + // Phone print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; print ''; @@ -328,7 +342,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { print ''.$form->editfieldkey('MaxUsers', 'max_users', '', $object, 0).''; print ''; print img_picto('', 'object_user', 'class="pictofixedwidth"'); - print ''; + print ''; print ''; // URL diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index d7edfe1a4b4..cf357d047cf 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -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); } diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 17cf011a2df..8940235d42b 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -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 ''; if ($empty) { print ''; } @@ -237,6 +239,10 @@ class FormResource } } print ''; + if ($usejscombo) { + print ajax_combobox("select".$htmlname); + } + if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ec4f64e8905..b5a2377e3a9 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -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 ''; // Chrome ignor autocomplete + print ''; // Chrome ignores autocomplete print ''; print ''; @@ -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(); });