Debug Date of line of services mandatory

This commit is contained in:
Laurent Destailleur 2021-09-23 13:01:04 +02:00
parent 545b4c56d5
commit c39c823b66
3 changed files with 67 additions and 58 deletions

View File

@ -674,22 +674,21 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
$("#prod_entry_mode_predef").click(); $("#prod_entry_mode_predef").click();
<?php <?php
} }
?>
<?php if ($this->table_element_line != 'commande_fournisseurdet') { ?> if (in_array($this->table_element_line, array('propaldet', 'commandedet', 'facturedet'))) { ?>
$("#date_start, #date_end").focusout(function() $("#date_start, #date_end").focusout(function() {
{ let type = $(this).attr('type');
let type = $(this).attr('type'); let mandatoryP = $(this).attr('mandatoryperiod');
let mandatoryP = $(this).attr('mandatoryperiod'); if (type == 1 && mandatoryP == 1) {
if (type == 1 && mandatoryP == 1 ){ if ($(this).val() == '' && !$(this).hasClass('inputmandatory')) {
if ( $(this).val() == '' && !$(this).hasClass("error") ) { $(this).addClass('inputmandatory');
$(this).addClass('error');
}else{ }else{
$(this).removeClass('error'); $(this).removeClass('inputmandatory');
} }
} }
}); });
<?php } ?> <?php
} ?>
/* When changing predefined product, we reload list of supplier prices required for margin combo */ /* When changing predefined product, we reload list of supplier prices required for margin combo */
$("#idprod, #idprodfournprice").change(function() $("#idprod, #idprodfournprice").change(function()
{ {
@ -718,23 +717,23 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
function(data) { function(data) {
console.log("Load unit price end, we got value "+data.price_ht); console.log("Load unit price end, we got value "+data.price_ht);
$( '#date_start').removeAttr( "type" ); $('#date_start').removeAttr('type');
$( '#date_end' ).removeAttr( "type" ); $('#date_end').removeAttr('type');
$('#date_start').attr('type', data.type); $('#date_start').attr('type', data.type);
$('#date_end').attr('type', data.type); $('#date_end').attr('type', data.type);
$( '#date_start').removeAttr( "mandatoryperiod" ); $('#date_start').removeAttr('mandatoryperiod');
$( '#date_end' ).removeAttr( "mandatoryperiod" ); $('#date_end').removeAttr('mandatoryperiod');
$('#date_start').attr('mandatoryperiod', data.mandatory_period); $('#date_start').attr('mandatoryperiod', data.mandatory_period);
$('#date_end').attr('mandatoryperiod', data.mandatory_period); $('#date_end').attr('mandatoryperiod', data.mandatory_period);
// service and we setted mandatory_period to true // service and we setted mandatory_period to true
if (data.mandatory_period == 1 && data.type == 1 ) { if (data.mandatory_period == 1 && data.type == 1) {
jQuery("#date_start").addClass("error"); jQuery('#date_start').addClass('inputmandatory');
jQuery("#date_end").addClass("error"); jQuery('#date_end').addClass('inputmandatory');
}else{ }else{
jQuery("#date_start").removeClass("error"); jQuery('#date_start').removeClass('inputmandatory');
jQuery("#date_end").removeClass("error"); jQuery('#date_end').removeClass('inputmandatory');
} }
jQuery("#price_ht").val(data.price_ht); jQuery("#price_ht").val(data.price_ht);

View File

@ -468,16 +468,17 @@ jQuery(document).ready(function()
} }
}); });
$("#date_start, #date_end").focusout(function() <?php if (in_array($this->table_element_line, array('propaldet', 'commandedet', 'facturedet'))) { ?>
{ $("#date_start, #date_end").focusout(function() {
if ( $(this).val() == '' && !$(this).hasClass('inputmandatory') ) {
if ( $(this).val() == '' && !$(this).hasClass("error") ) { $(this).addClass('inputmandatory');
$(this).addClass('error'); } else {
}else{ $(this).removeClass('inputmandatory');
$(this).removeClass('error');
} }
}); });
<?php <?php
}
if (!empty($conf->margin->enabled)) { if (!empty($conf->margin->enabled)) {
?> ?>
/* Add rule to clear margin when we change some data, so when we change sell or buy price, margin will be recalculated after submitting form */ /* Add rule to clear margin when we change some data, so when we change sell or buy price, margin will be recalculated after submitting form */

View File

@ -132,7 +132,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
}
if (!empty($conf->product->enabled)) { if (!empty($conf->product->enabled)) {
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
} elseif (!empty($conf->service->enabled)) { } elseif (!empty($conf->service->enabled)) {
@ -1290,6 +1292,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("Duration").'</td><td>'; print '<tr><td>'.$langs->trans("Duration").'</td><td>';
print '<input name="duration_value" size="4" value="'.GETPOST('duration_value', 'int').'">'; print '<input name="duration_value" size="4" value="'.GETPOST('duration_value', 'int').'">';
print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOSTISSET('duration_value', 'alpha') : 'h'), 0, 1); print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOSTISSET('duration_value', 'alpha') : 'h'), 0, 1);
// Mandatory period
print ' &nbsp; &nbsp; &nbsp; ';
print '<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').'>';
print '<label for="mandatoryperiod">';
$htmltooltip = $langs->trans("mandatoryHelper");
print $form->textwithpicto($langs->trans("mandatoryperiod"), $htmltooltip, 1, 0);
print '</label>';
print '</td></tr>'; print '</td></tr>';
} }
@ -1429,6 +1440,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$defaultva = get_default_tva($mysoc, $mysoc); $defaultva = get_default_tva($mysoc, $mysoc);
print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -1452,14 +1464,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
print '</td></tr>'; print '</td></tr>';
if (!empty($conf->service->enabled)) {
if ($object->isService()) {
// Mandatory period
print '<tr><td class="titlefieldcreate">'.$langs->trans("mandatoryperiod").'</td>';
print '<td><input type="checkbox" name="mandatoryperiod" /> ';
print '</td></tr>';
}
}
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -1834,6 +1838,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("Duration").'</td><td>'; print '<tr><td>'.$langs->trans("Duration").'</td><td>';
print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> '; print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> ';
print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1); print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1);
// Mandatory period
print ' &nbsp; &nbsp; &nbsp; ';
print '<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').'>';
print '<label for="mandatoryperiod">';
$htmltooltip = $langs->trans("mandatoryHelper");
print $form->textwithpicto($langs->trans("mandatoryperiod"), $htmltooltip, 1, 0);
print '</label>';
print '</td></tr>'; print '</td></tr>';
} else { } else {
if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
@ -2050,13 +2063,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyExportCode").'</td>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyExportCode").'</td>';
print '<td><input name="accountancy_code_buy_export" class="maxwidth200" value="'.$object->accountancy_code_buy_export.'">'; print '<td><input name="accountancy_code_buy_export" class="maxwidth200" value="'.$object->accountancy_code_buy_export.'">';
print '</td></tr>'; print '</td></tr>';
if ($object->isService()) {
// Mandatory period
print '<tr><td class="titlefieldcreate">'.$langs->trans("mandatoryperiod").'</td>';
print '<td><input type="checkbox" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').' /> ';
print '</td></tr>';
}
} }
} }
print '</table>'; print '</table>';
@ -2322,21 +2328,23 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($object->isService()) { if ($object->isService()) {
// Duration // Duration
print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td>'.$object->duration_value.'&nbsp;'; print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td>';
print $object->duration_value;
if ($object->duration_value > 1) { if ($object->duration_value > 1) {
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
} elseif ($object->duration_value > 0) { } elseif ($object->duration_value > 0) {
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
} }
print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;"; print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? "&nbsp;".$langs->trans($dur[$object->duration_unit])."&nbsp;" : '');
print '</td></tr>';
// Mandatory period // Mandatory period
$htmltooltip = '<br>'.$langs->trans("mandatoryHelper"); if ($object->duration_value > 0) {
print '<tr><td class="titlefield">'.$langs->trans("mandatoryperiod"); print ' &nbsp; &nbsp; &nbsp; ';
print $form->textwithpicto('', $htmltooltip, 1, 0).'</td><td>'; }
print '<input type="checkbox" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').' disabled/> '; $htmltooltip = $langs->trans("mandatoryHelper");
print '<input type="checkbox" class="" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').' disabled>';
print $form->textwithpicto($langs->trans("mandatoryperiod"), $htmltooltip, 1, 0);
print '</td></tr>'; print '</td></tr>';
} else { } else {
if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
@ -2566,8 +2574,9 @@ if ($action != 'create' && $action != 'edit') {
print "\n</div>\n"; print "\n</div>\n";
} }
/* /*
* All the "Add to" areas * All the "Add to" areas if PRODUCT_ADD_FORM_ADD_TO is set
*/ */
if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) { if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) {