Fix: $error var must use type int and be increased when error found.
Using $error as boolean at some place was source of error.
This commit is contained in:
parent
872e764c94
commit
a51e18a5a7
@ -568,7 +568,7 @@ else if ($action == 'setnote_private' && $user->rights->commande->creer)
|
|||||||
else if ($action == 'addline' && $user->rights->commande->creer)
|
else if ($action == 'addline' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
$langs->load('errors');
|
$langs->load('errors');
|
||||||
$error = false;
|
$error = 0;
|
||||||
|
|
||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
if (GETPOST('addline_libre')
|
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))
|
if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0))
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
|
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
if (empty($idprod) && GETPOST('type') < 0)
|
if (empty($idprod) && GETPOST('type') < 0)
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
|
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 ''
|
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');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
if ($qty == '')
|
if ($qty == '')
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
|
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
if (empty($idprod) && empty($product_desc))
|
if (empty($idprod) && empty($product_desc))
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
|
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod)))
|
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod)))
|
||||||
|
|||||||
@ -60,18 +60,18 @@ $cp = new Holiday($db);
|
|||||||
if ($action == "add")
|
if ($action == "add")
|
||||||
{
|
{
|
||||||
$message = '';
|
$message = '';
|
||||||
$error = false;
|
$error = 0;
|
||||||
|
|
||||||
// Option du groupe de validation
|
// Option du groupe de validation
|
||||||
/*if (!$cp->updateConfCP('userGroup',$_POST['userGroup']))
|
/*if (!$cp->updateConfCP('userGroup',$_POST['userGroup']))
|
||||||
{
|
{
|
||||||
$error = true;
|
$error++;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Option du délai pour faire une demande de congés payés
|
// Option du délai pour faire une demande de congés payés
|
||||||
if (!$cp->updateConfCP('delayForRequest',$_POST['delayForRequest']))
|
if (!$cp->updateConfCP('delayForRequest',$_POST['delayForRequest']))
|
||||||
{
|
{
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option du nombre de jours à ajouter chaque mois
|
// Option du nombre de jours à ajouter chaque mois
|
||||||
@ -79,67 +79,69 @@ if ($action == "add")
|
|||||||
|
|
||||||
if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth))
|
if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth))
|
||||||
{
|
{
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option du nombre de jours pour un mariage
|
// Option du nombre de jours pour un mariage
|
||||||
$OptMariageCP = price2num($_POST['OptMariage'],5);
|
$OptMariageCP = price2num($_POST['OptMariage'],5);
|
||||||
|
|
||||||
if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) {
|
if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option du nombre de jours pour un décés d'un proche
|
// Option du nombre de jours pour un décés d'un proche
|
||||||
$OptDecesProcheCP = price2num($_POST['OptDecesProche'],5);
|
$OptDecesProcheCP = price2num($_POST['OptDecesProche'],5);
|
||||||
|
|
||||||
if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) {
|
if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option du nombre de jours pour un mariage d'un enfant
|
// Option du nombre de jours pour un mariage d'un enfant
|
||||||
$OptMariageProcheCP = price2num($_POST['OptMariageProche'],5);
|
$OptMariageProcheCP = price2num($_POST['OptMariageProche'],5);
|
||||||
|
|
||||||
if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) {
|
if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option du nombre de jours pour un décés d'un parent
|
// Option du nombre de jours pour un décés d'un parent
|
||||||
$OptDecesParentsCP = price2num($_POST['OptDecesParents'],5);
|
$OptDecesParentsCP = price2num($_POST['OptDecesParents'],5);
|
||||||
|
|
||||||
if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) {
|
if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option pour avertir le valideur si délai de demande incorrect
|
// Option pour avertir le valideur si délai de demande incorrect
|
||||||
if(isset($_POST['AlertValidatorDelay'])) {
|
if(isset($_POST['AlertValidatorDelay'])) {
|
||||||
if(!$cp->updateConfCP('AlertValidatorDelay','1')) {
|
if(!$cp->updateConfCP('AlertValidatorDelay','1')) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!$cp->updateConfCP('AlertValidatorDelay','0')) {
|
if(!$cp->updateConfCP('AlertValidatorDelay','0')) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option pour avertir le valideur si solde des congés de l'utilisateur inccorect
|
// Option pour avertir le valideur si solde des congés de l'utilisateur inccorect
|
||||||
if(isset($_POST['AlertValidatorSolde'])) {
|
if(isset($_POST['AlertValidatorSolde'])) {
|
||||||
if(!$cp->updateConfCP('AlertValidatorSolde','1')) {
|
if(!$cp->updateConfCP('AlertValidatorSolde','1')) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!$cp->updateConfCP('AlertValidatorSolde','0')) {
|
if(!$cp->updateConfCP('AlertValidatorSolde','0')) {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option du nombre de jours à déduire pour 1 jour de congés
|
// Option du nombre de jours à déduire pour 1 jour de congés
|
||||||
$nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],2);
|
$nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],2);
|
||||||
|
|
||||||
if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) {
|
if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted))
|
||||||
$error = true;
|
{
|
||||||
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error) {
|
if ($error)
|
||||||
|
{
|
||||||
$message = '<div class="error">'.$langs->trans('ErrorUpdateConfCP').'</div>';
|
$message = '<div class="error">'.$langs->trans('ErrorUpdateConfCP').'</div>';
|
||||||
} else {
|
} else {
|
||||||
$message = '<div class="ok">'.$langs->trans('UpdateConfCPOK').'</div>';
|
$message = '<div class="ok">'.$langs->trans('UpdateConfCPOK').'</div>';
|
||||||
@ -151,8 +153,8 @@ if ($action == "add")
|
|||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
$num = $db->num_rows($sql);
|
$num = $db->num_rows($sql);
|
||||||
|
if($num < 1)
|
||||||
if($num < 1) {
|
{
|
||||||
$cp->createCPusers();
|
$cp->createCPusers();
|
||||||
$message.= '<br /><div class="warning">'.$langs->trans('AddCPforUsers').'</div>';
|
$message.= '<br /><div class="warning">'.$langs->trans('AddCPforUsers').'</div>';
|
||||||
}
|
}
|
||||||
@ -202,7 +204,7 @@ elseif ($action == 'create_event')
|
|||||||
}
|
}
|
||||||
elseif($action == 'event' && isset($_POST['update_event']))
|
elseif($action == 'event' && isset($_POST['update_event']))
|
||||||
{
|
{
|
||||||
$error = false;
|
$error = 0;
|
||||||
|
|
||||||
$eventId = array_keys($_POST['update_event']);
|
$eventId = array_keys($_POST['update_event']);
|
||||||
$eventId = $eventId[0];
|
$eventId = $eventId[0];
|
||||||
@ -213,16 +215,18 @@ elseif($action == 'event' && isset($_POST['update_event']))
|
|||||||
$eventValue = $optValue;
|
$eventValue = $optValue;
|
||||||
$eventValue = $eventValue[$eventId];
|
$eventValue = $eventValue[$eventId];
|
||||||
|
|
||||||
if(!empty($eventName)) {
|
if (!empty($eventName))
|
||||||
|
{
|
||||||
$eventName = trim($eventName);
|
$eventName = trim($eventName);
|
||||||
} else {
|
} else {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($eventValue)) {
|
if (!empty($eventValue))
|
||||||
|
{
|
||||||
$eventValue = price2num($eventValue,2);
|
$eventValue = price2num($eventValue,2);
|
||||||
} else {
|
} else {
|
||||||
$error = true;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
|
|||||||
@ -91,21 +91,24 @@ if ($action == 'update' && isset($_POST['update_cp']))
|
|||||||
}
|
}
|
||||||
elseif($action == 'add_event')
|
elseif($action == 'add_event')
|
||||||
{
|
{
|
||||||
$error = false;
|
$error = 0;
|
||||||
|
|
||||||
if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) {
|
if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) {
|
||||||
$event = $_POST['list_event'];
|
$event = $_POST['list_event'];
|
||||||
} else { $error = true;
|
} else { $error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) {
|
if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) {
|
||||||
$userCP = $_POST['userCP'];
|
$userCP = $_POST['userCP'];
|
||||||
} else { $error = true;
|
} else { $erro++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($error) {
|
if ($error)
|
||||||
|
{
|
||||||
$message = '<div class="error">'.$langs->trans('ErrorAddEventToUserCP').'</div>';
|
$message = '<div class="error">'.$langs->trans('ErrorAddEventToUserCP').'</div>';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$nb_holiday = $holiday->getCPforUser($userCP);
|
$nb_holiday = $holiday->getCPforUser($userCP);
|
||||||
$add_holiday = $holiday->getValueEventCp($event);
|
$add_holiday = $holiday->getValueEventCp($event);
|
||||||
$new_holiday = $nb_holiday + $add_holiday;
|
$new_holiday = $nb_holiday + $add_holiday;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user