Skip to content

Commit

Permalink
Fix error management in POS.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jun 13, 2017
1 parent c088cce commit fc5dfcd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
6 changes: 3 additions & 3 deletions htdocs/cashdesk/affIndex.php
Expand Up @@ -27,6 +27,8 @@
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 )
{
Expand Down Expand Up @@ -54,9 +56,7 @@

if (!empty($error))
{
print $error;
print '</body></html>';
exit;
dol_htmloutput_events();
}

print '<div class="conteneur">'."\n";
Expand Down
8 changes: 8 additions & 0 deletions htdocs/cashdesk/css/style.css
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion htdocs/cashdesk/tpl/menu.tpl.php
Expand Up @@ -79,10 +79,11 @@
/*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";
31 changes: 17 additions & 14 deletions htdocs/cashdesk/validation_verif.php
Expand Up @@ -32,7 +32,6 @@
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');
Expand All @@ -45,14 +44,14 @@

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='';
Expand All @@ -68,15 +67,15 @@
// To force rule only for POS with mercure
//...
}

$num=$invoice->getNextNumRef($company);

// Restore save values
if (! empty($sav_FACTURE_ADDON))
{
$conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON;
}

$obj_facturation->numInvoice($num);

$obj_facturation->getSetPaymentMode($_POST['hdnChoix']);
Expand Down Expand Up @@ -129,7 +128,7 @@
exit;
}

switch ( $obj_facturation->getSetPaymentMode() )
switch ($obj_facturation->getSetPaymentMode() )
{
case 'DIF':
$mode_reglement_id = 0;
Expand Down Expand Up @@ -159,7 +158,6 @@
$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;


Expand Down Expand Up @@ -255,14 +253,15 @@
}
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);
Expand All @@ -287,7 +286,8 @@
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++;
}
}
}
Expand Down Expand Up @@ -331,15 +331,18 @@
}
else
{
$error++;
setEventMessages($invoice->error, $invoice->errors, 'errors');
$error++;
}
}
else
{
$error++;
setEventMessages($invoice->error, $invoice->errors, 'errors');
$error++;
}
}


if (! $error)
{
$db->commit();
Expand All @@ -348,14 +351,14 @@
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);

Expand Down

0 comments on commit fc5dfcd

Please sign in to comment.