add color on date dield and warning on line

This commit is contained in:
jpb 2021-07-20 11:23:35 +02:00
parent 97287af987
commit e11afb7da0
6 changed files with 67 additions and 3 deletions

View File

@ -678,10 +678,10 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
/* When changing predefined product, we reload list of supplier prices required for margin combo */
$("#idprod, #idprodfournprice").change(function()
{
console.log("Call method change() 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
setColorToDateSelector($(this).val());
jQuery('#trlinefordates').show();
<?php
@ -703,6 +703,21 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
{ 'id': $(this).val(), 'socid': <?php print $object->socid; ?> },
function(data) {
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
if (data.mandatory_period == 1 && data.type == 1 ) {
console.log("we are good to color date input");
jQuery("#date_start").css("background-color","#f2cf87");
jQuery("#date_end").css("background-color","#f2cf87");
}else{
jQuery("#date_start").css("background-color","#FFF");
jQuery("#date_end").css("background-color","#FFF");
}
jQuery("#price_ht").val(data.price_ht);
<?php
if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) {
@ -984,6 +999,10 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show();
jQuery("#fournprice_predef").hide();
}
function setColorToDateSelector(val){
console.log("from function "+val);
}
function setforpredef() {
console.log("Call setforpredef. We hide some fields and show dates");
jQuery("#select_type").val(-1);

View File

@ -333,9 +333,19 @@ $coldisplay++;
if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
}
if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");';
}
$res = $line->fetch_product();
// on doit fetch le product là !!! pour connaître le type
if ($res > 0 ){
if ($line->product->isMandatoryPeriod() && $line->product->isService()) {
print 'jQuery("#date_start").css("background-color","#f2cf87");';
}
}
}
if (!$line->date_end) {
if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
@ -344,6 +354,14 @@ $coldisplay++;
if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");';
}
$res = $line->fetch_product();
// on doit fetch le product là !!! pour connaître le type
if ($res > 0 ){
if ($line->product->isMandatoryperiod() && $line->product->isService()) {
print 'jQuery("#date_end").css("background-color","#f2cf87");';
}
}
}
print '</script>'
?>

View File

@ -180,7 +180,22 @@ if (($line->info_bits & 2) == 2) {
} else {
if ($line->date_start || $line->date_end) {
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
// show warning under line
// we need to fetch product associated to line for some test
$res = $line->fetch_product();
if ($res > 0 ){
if ($line->product->isService() && $line->product->isMandatoryPeriod()){
print '<br><div class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSet").'</div>';
}
}
}
//print get_date_range($line->date_start, $line->date_end, $format);
}

View File

@ -400,3 +400,4 @@ DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison
PMPValue=Prix moyen pondéré (PMP)
PMPValueShort=PMP
mandatoryperiod=Période obligatoires
mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires

View File

@ -91,7 +91,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
$outtype = $object->type;
$outqty = 1;
$outdiscount = 0;
$mandatory_period = $object->mandatory_period;
$found = false;
$price_level = 1;
@ -203,6 +203,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
'tva_tx' => $outtva_tx,
'qty' => $outqty,
'discount' => $outdiscount,
'mandatory_period' => $mandatory_period,
'array_options'=>$object->array_options);
}

View File

@ -5642,6 +5642,16 @@ class Product extends CommonObject
return ($this->type == Product::TYPE_SERVICE ? true : false);
}
/**
* Return if object have a constraint on mandatory_period
*
* @return boolean True if mandatory_period setted to 1
*/
public function isMandatoryPeriod()
{
return ($this->mandatory_period == 1 ? true : false);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Get a barcode from the module to generate barcode values.