From fc5dfcda6512c267575196b11ef6a1a9199f3ab3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jun 2017 19:46:27 +0200 Subject: [PATCH] Fix error management in POS. --- htdocs/cashdesk/affIndex.php | 6 +++--- htdocs/cashdesk/css/style.css | 8 +++++++ htdocs/cashdesk/tpl/menu.tpl.php | 3 ++- htdocs/cashdesk/validation_verif.php | 31 +++++++++++++++------------- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php index b5432b94eec..a2e467a35e3 100644 --- a/htdocs/cashdesk/affIndex.php +++ b/htdocs/cashdesk/affIndex.php @@ -27,6 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php'; require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/keypad.php'; +$error=GETPOST('error'); + // Test if already logged if ( $_SESSION['uid'] <= 0 ) { @@ -54,9 +56,7 @@ print ''."\n"; if (!empty($error)) { - print $error; - print ''; - exit; + dol_htmloutput_events(); } print '
'."\n"; diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css index ab8d660fcf1..216f53e946b 100644 --- a/htdocs/cashdesk/css/style.css +++ b/htdocs/cashdesk/css/style.css @@ -106,6 +106,14 @@ p { padding-right: 5px; } +/* Force values for small screen 570 */ +@media only screen and (max-width: 570px) +{ + .menu_choix0 { + max-width: 180px; + } +} + .menu_choix0 a { font-weight: normal; text-decoration: none; diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php index 85de5ad9ab5..fd9bcbca77c 100644 --- a/htdocs/cashdesk/tpl/menu.tpl.php +++ b/htdocs/cashdesk/tpl/menu.tpl.php @@ -79,10 +79,11 @@ print ''; /*print $langs->trans("CashDeskBankCash").': '.$bankcashLink.'
'; print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'
'; print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'
';*/ +print '
'; if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { print $langs->trans("CashDeskWarehouse").': '.$warehouseLink; } -print ''; +print '
'; print '
'; print "\n".''."\n"; diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index ae5d7185f40..1b870d30f73 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -32,7 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $obj_facturation = unserialize($_SESSION['serObjFacturation']); -unset ($_SESSION['serObjFacturation']); $action =GETPOST('action','aZ09'); $bankaccountid=GETPOST('cashdeskbank'); @@ -45,14 +44,14 @@ switch ($action) case 'valide_achat': $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - + $company=new Societe($db); $company->fetch($thirdpartyid); $invoice=new Facture($db); $invoice->date=dol_now(); $invoice->type= Facture::TYPE_STANDARD; - + // To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here // and restore values just after $sav_FACTURE_ADDON=''; @@ -68,7 +67,7 @@ switch ($action) // To force rule only for POS with mercure //... } - + $num=$invoice->getNextNumRef($company); // Restore save values @@ -76,7 +75,7 @@ switch ($action) { $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; } - + $obj_facturation->numInvoice($num); $obj_facturation->getSetPaymentMode($_POST['hdnChoix']); @@ -129,7 +128,7 @@ switch ($action) exit; } - switch ( $obj_facturation->getSetPaymentMode() ) + switch ($obj_facturation->getSetPaymentMode() ) { case 'DIF': $mode_reglement_id = 0; @@ -159,7 +158,6 @@ switch ($action) $note .= $_POST['txtaNotes']; dol_syslog("obj_facturation->getSetPaymentMode()=".$obj_facturation->getSetPaymentMode()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id); - $error=0; @@ -255,14 +253,15 @@ switch ($action) } else { - $error++; + setEventMessage($invoice->error, $invoice->errors, 'errors'); + $error++; } $id = $invoice->id; } else { - $resultcreate=$invoice->create($user,0,0); + $resultcreate=$invoice->create($user,0,0); if ($resultcreate > 0) { $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0); @@ -287,7 +286,8 @@ switch ($action) if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref)); else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref)); if ($result < 0) { - $error++; + setEventMessages($mouvP->error, $mouvP->errors, 'errors'); + $error++; } } } @@ -331,15 +331,18 @@ switch ($action) } else { - $error++; + setEventMessages($invoice->error, $invoice->errors, 'errors'); + $error++; } } else { - $error++; + setEventMessages($invoice->error, $invoice->errors, 'errors'); + $error++; } } + if (! $error) { $db->commit(); @@ -348,14 +351,14 @@ switch ($action) else { $db->rollback(); - $redirection = 'affIndex.php?facid='.$id.'&mesg=ErrorFailedToCreateInvoice'; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr + $redirection = 'affIndex.php?facid='.$id.'&error=1&mesg=ErrorFailedToCreateInvoice'; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr } break; // End of case: valide_facture } - +unset ($_SESSION['serObjFacturation']); $_SESSION['serObjFacturation'] = serialize($obj_facturation);