Fix error management in POS.

This commit is contained in:
Laurent Destailleur 2017-06-13 19:46:27 +02:00
parent c088ccea32
commit fc5dfcda65
4 changed files with 30 additions and 18 deletions

View File

@ -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 '<body>'."\n";
if (!empty($error))
{
print $error;
print '</body></html>';
exit;
dol_htmloutput_events();
}
print '<div class="conteneur">'."\n";

View File

@ -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;

View File

@ -79,10 +79,11 @@ print '</form>';
/*print $langs->trans("CashDeskBankCash").': '.$bankcashLink.'<br>';
print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'<br>';
print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'<br>';*/
print '<div class="clearboth">';
if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK))
{
print $langs->trans("CashDeskWarehouse").': '.$warehouseLink;
}
print '</li></ul>';
print '</div></li></ul>';
print '</div>';
print "\n".'<!-- menu.tpl.php end -->'."\n";

View File

@ -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);