Skip to content

Commit

Permalink
Merge branch '20.0' of [email protected]:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 1, 2024
2 parents 94154af + 075d0de commit 6b2fa56
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 33 deletions.
1 change: 1 addition & 0 deletions htdocs/admin/accountant.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
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();
});
Expand Down
1 change: 1 addition & 0 deletions htdocs/admin/company.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@
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();
});
Expand Down
1 change: 1 addition & 0 deletions htdocs/product/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@
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();
});
Expand Down
62 changes: 38 additions & 24 deletions htdocs/resource/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,22 @@
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").'">';

Expand All @@ -250,66 +263,67 @@
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>';

// Type
print '<tr><td>'.$langs->trans("ResourceType").'</td>';
print '<td>';
$formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2, 0, 0, 0, 1, 'minwidth200');
print '</td></tr>';

// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('description', ($description ?: $object->description), '', 200, 'dolibarr_notes');
$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($object->address, 0, 1);
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($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
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($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
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($object->country_id);
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
if (!getDolGlobalString('SOCIETE_DISABLE_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 ($object->country_id) {
if ($country_id > 0) {
print img_picto('', 'state', 'class="pictofixedwidth"');
print $formresource->select_state($object->state_id, $object->country_code);
print $formresource->select_state($countryid, $country_id);
} else {
print $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
print '<span class="opacitymedium">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</span>';
}
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);
print '</td></tr>';

// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('description', ($description ?: $object->description), '', 200, 'dolibarr_notes');
$doleditor->Create();
print '</td></tr>';

// Phone
print '<td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
print '<td>';
Expand All @@ -328,7 +342,7 @@
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
Expand Down
9 changes: 3 additions & 6 deletions htdocs/resource/class/dolresource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -375,9 +375,6 @@ public function update($user = null, int $notrigger = 0)
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);
}
Expand Down
10 changes: 8 additions & 2 deletions htdocs/resource/class/html.formresource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ public function select_resource_list($selected = 0, $htmlname = 'fk_resource', a
* @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;
Expand All @@ -193,7 +195,7 @@ public function select_types_resource($selected = '', $htmlname = 'type_resource
}

$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>';
}
Expand Down Expand Up @@ -237,6 +239,10 @@ public function select_types_resource($selected = '', $htmlname = 'type_resource
}
}
print '</select>';
if ($usejscombo) {
print ajax_combobox("select".$htmlname);
}

if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
Expand Down
4 changes: 3 additions & 1 deletion htdocs/societe/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ function init_supplier_categ() {
}
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.formsoc.action.value="create";
document.formsoc.submit();
});
Expand All @@ -1303,7 +1304,7 @@ function init_supplier_categ() {

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().'">';
Expand Down Expand Up @@ -2237,6 +2238,7 @@ function init_supplier_categ() {
}
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.formsoc.action.value="edit";
document.formsoc.submit();
});
Expand Down

0 comments on commit 6b2fa56

Please sign in to comment.