change class css and behavior js

This commit is contained in:
jpb 2021-07-20 13:56:30 +02:00
parent e11afb7da0
commit 367e839239
6 changed files with 32 additions and 19 deletions

View File

@ -674,6 +674,15 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
<?php <?php
} }
?> ?>
$("#date_start, #date_end").focusout(function()
{
if ( $(this).val() == '' && !$(this).hasClass("error") ) {
$(this).addClass('error');
}else{
$(this).removeClass('error');
}
});
/* 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()
@ -681,7 +690,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
console.log("Call method change() 1 after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(this).val()); console.log("Call method change() 1 after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(this).val());
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
setColorToDateSelector($(this).val());
jQuery('#trlinefordates').show(); jQuery('#trlinefordates').show();
<?php <?php
@ -705,17 +713,16 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
console.log("Load unit price end, we got value "+data.price_ht); console.log("Load unit price end, we got value "+data.price_ht);
console.log(data);
console.log(jQuery("#date_start").val());
console.log(jQuery("#date_end").val());
// 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 ) {
console.log("we are good to color date input"); console.log("we are good to color date input");
jQuery("#date_start").css("background-color","#f2cf87");
jQuery("#date_end").css("background-color","#f2cf87"); jQuery("#date_start").addClass("error");
jQuery("#date_end").addClass("error");
}else{ }else{
jQuery("#date_start").css("background-color","#FFF"); jQuery("#date_start").removeClass("error");
jQuery("#date_end").css("background-color","#FFF"); jQuery("#date_end").removeClass("error");
} }
jQuery("#price_ht").val(data.price_ht); jQuery("#price_ht").val(data.price_ht);
@ -733,6 +740,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?> if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
{ {
var editor = CKEDITOR.instances['dp_desc'];
var editor = CKEDITOR.instances['dp_desc']; var editor = CKEDITOR.instances['dp_desc'];
if (editor) { if (editor) {
editor.setData(proddesc); editor.setData(proddesc);
@ -999,9 +1007,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show();
jQuery("#fournprice_predef").hide(); jQuery("#fournprice_predef").hide();
} }
function setColorToDateSelector(val){
console.log("from function "+val);
}
function setforpredef() { function setforpredef() {
console.log("Call setforpredef. We hide some fields and show dates"); console.log("Call setforpredef. We hide some fields and show dates");

View File

@ -340,10 +340,9 @@ $coldisplay++;
} }
$res = $line->fetch_product(); $res = $line->fetch_product();
// on doit fetch le product là !!! pour connaître le type
if ($res > 0 ){ if ($res > 0 ){
if ($line->product->isMandatoryPeriod() && $line->product->isService()) { if ($line->product->isMandatoryPeriod() && $line->product->isService()) {
print 'jQuery("#date_start").css("background-color","#f2cf87");'; print 'jQuery("#date_start").addClass("error");';
} }
} }
} }
@ -359,7 +358,7 @@ $coldisplay++;
// on doit fetch le product là !!! pour connaître le type // on doit fetch le product là !!! pour connaître le type
if ($res > 0 ){ if ($res > 0 ){
if ($line->product->isMandatoryperiod() && $line->product->isService()) { if ($line->product->isMandatoryperiod() && $line->product->isService()) {
print 'jQuery("#date_end").css("background-color","#f2cf87");'; print 'jQuery("#date_end").addClass("error");';
} }
} }
} }
@ -469,6 +468,15 @@ jQuery(document).ready(function()
} }
}); });
$("#date_start, #date_end").focusout(function()
{
if ( $(this).val() == '' && !$(this).hasClass("error") ) {
$(this).addClass('error');
}else{
$(this).removeClass('error');
}
});
<?php <?php
if (!empty($conf->margin->enabled)) { if (!empty($conf->margin->enabled)) {
?> ?>

View File

@ -182,13 +182,13 @@ if (($line->info_bits & 2) == 2) {
print '<br><div class="clearboth nowraponall opacitymedium">'.get_date_range($line->date_start, $line->date_end, $format).'</div>'; print '<br><div class="clearboth nowraponall opacitymedium">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
} }
if ((!$line->date_start && !$line->date_end) || (!$line->date_start || !$line->date_end) ){ // pas de date if (!$line->date_start || !$line->date_end){
// show warning under line // show warning under line
// we need to fetch product associated to line for some test // we need to fetch product associated to line for some test
$res = $line->fetch_product(); $res = $line->fetch_product();
if ($res > 0 ){ if ($res > 0 ){
if ($line->product->isService() && $line->product->isMandatoryPeriod()){ if ($line->product->isService() && $line->product->isMandatoryPeriod()){
print '<br><div class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSet").'</div>'; print '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSet").'</span></div>';
} }
} }
} }

View File

@ -36,5 +36,5 @@
-- v15 -- v15
ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0 AFTER fk_project; ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0;

View File

@ -399,5 +399,5 @@ ProductSupplierExtraFields=Attributs supplémentaires (Prix fournisseur)
DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison
PMPValue=Prix moyen pondéré (PMP) PMPValue=Prix moyen pondéré (PMP)
PMPValueShort=PMP PMPValueShort=PMP
mandatoryperiod=Période obligatoires mandatoryperiod=Périodes obligatoires
mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires

View File

@ -234,7 +234,7 @@ input.button.massactionconfirmed {
margin: 4px; margin: 4px;
} }
input:invalid, select:invalid { input:invalid, select:invalid , input.error{
border-color: #ea1212; border-color: #ea1212;
} }