diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 4a00c1a661bd6337d8cd643e3db585f30230d02f..43fe619bd1a6d74bc5ebd3729450e8cb64a1cfc8 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -568,7 +568,7 @@ else if ($action == 'setnote_private' && $user->rights->commande->creer) else if ($action == 'addline' && $user->rights->commande->creer) { $langs->load('errors'); - $error = false; + $error = 0; // Set if we used free entry or predefined product if (GETPOST('addline_libre') @@ -617,27 +617,27 @@ else if ($action == 'addline' && $user->rights->commande->creer) if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error = true; + $error++; } if (empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error = true; + $error++; } if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error = true; + $error++; } if ($qty == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error = true; + $error++; } if (empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error = true; + $error++; } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php index 174adbdf7255476385e15a1c27cc650dfc519025..2b265711fa13451164ff493db431313f450b5442 100644 --- a/htdocs/holiday/admin/holiday.php +++ b/htdocs/holiday/admin/holiday.php @@ -60,18 +60,18 @@ $cp = new Holiday($db); if ($action == "add") { $message = ''; - $error = false; + $error = 0; // Option du groupe de validation /*if (!$cp->updateConfCP('userGroup',$_POST['userGroup'])) { - $error = true; + $error++; }*/ // Option du délai pour faire une demande de congés payés if (!$cp->updateConfCP('delayForRequest',$_POST['delayForRequest'])) { - $error = true; + $error++; } // Option du nombre de jours à ajouter chaque mois @@ -79,67 +79,69 @@ if ($action == "add") if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth)) { - $error = true; + $error++; } // Option du nombre de jours pour un mariage $OptMariageCP = price2num($_POST['OptMariage'],5); if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un décés d'un proche $OptDecesProcheCP = price2num($_POST['OptDecesProche'],5); if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un mariage d'un enfant $OptMariageProcheCP = price2num($_POST['OptMariageProche'],5); if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un décés d'un parent $OptDecesParentsCP = price2num($_POST['OptDecesParents'],5); if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) { - $error = true; + $error++; } // Option pour avertir le valideur si délai de demande incorrect if(isset($_POST['AlertValidatorDelay'])) { if(!$cp->updateConfCP('AlertValidatorDelay','1')) { - $error = true; + $error++; } } else { if(!$cp->updateConfCP('AlertValidatorDelay','0')) { - $error = true; + $error++; } } // Option pour avertir le valideur si solde des congés de l'utilisateur inccorect if(isset($_POST['AlertValidatorSolde'])) { if(!$cp->updateConfCP('AlertValidatorSolde','1')) { - $error = true; + $error++; } } else { if(!$cp->updateConfCP('AlertValidatorSolde','0')) { - $error = true; + $error++; } } // Option du nombre de jours à déduire pour 1 jour de congés $nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],2); - if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) { - $error = true; + if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) + { + $error++; } - if ($error) { + if ($error) + { $message = '<div class="error">'.$langs->trans('ErrorUpdateConfCP').'</div>'; } else { $message = '<div class="ok">'.$langs->trans('UpdateConfCPOK').'</div>'; @@ -151,8 +153,8 @@ if ($action == "add") $result = $db->query($sql); $num = $db->num_rows($sql); - - if($num < 1) { + if($num < 1) + { $cp->createCPusers(); $message.= '<br /><div class="warning">'.$langs->trans('AddCPforUsers').'</div>'; } @@ -202,7 +204,7 @@ elseif ($action == 'create_event') } elseif($action == 'event' && isset($_POST['update_event'])) { - $error = false; + $error = 0; $eventId = array_keys($_POST['update_event']); $eventId = $eventId[0]; @@ -213,19 +215,21 @@ elseif($action == 'event' && isset($_POST['update_event'])) $eventValue = $optValue; $eventValue = $eventValue[$eventId]; - if(!empty($eventName)) { + if (!empty($eventName)) + { $eventName = trim($eventName); } else { - $error = true; + $error++; } - if(!empty($eventValue)) { + if (!empty($eventValue)) + { $eventValue = price2num($eventValue,2); } else { - $error = true; + $error++; } - if(!$error) + if (!$error) { // Mise à jour des congés de l'utilisateur $update = $cp->updateEventCP($eventId,$eventName,$eventValue); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 1cf37e77d6f375bdf7ae0021e235e76f4badd3d5..f167422f503dc83028f6adef1c881aac21a82eac 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -82,7 +82,7 @@ if ($action == 'update' && isset($_POST['update_cp'])) $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. dol_syslog('define_holiday update lastUpdate entry sql='.$sql); - $result = $db->query($sql); + $result = $db->query($sql); $mesg='<div class="ok">'.$langs->trans('UpdateConfCPOK').'</div>'; @@ -91,21 +91,24 @@ if ($action == 'update' && isset($_POST['update_cp'])) } elseif($action == 'add_event') { - $error = false; + $error = 0; if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) { $event = $_POST['list_event']; - } else { $error = true; + } else { $error++; } if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) { $userCP = $_POST['userCP']; - } else { $error = true; + } else { $erro++; } - if($error) { + if ($error) + { $message = '<div class="error">'.$langs->trans('ErrorAddEventToUserCP').'</div>'; - } else { + } + else + { $nb_holiday = $holiday->getCPforUser($userCP); $add_holiday = $holiday->getValueEventCp($event); $new_holiday = $nb_holiday + $add_holiday;