A lot of fix on point of sale module
This commit is contained in:
parent
8c2705707a
commit
3cb6df16fd
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -49,12 +49,14 @@ $langs->load("@cashdesk");
|
|||||||
if ($_POST["action"] == 'set')
|
if ($_POST["action"] == 'set')
|
||||||
{
|
{
|
||||||
if ($_POST["CASHDESK_ID_THIRDPARTY"] < 0) $_POST["CASHDESK_ID_THIRDPARTY"]='';
|
if ($_POST["CASHDESK_ID_THIRDPARTY"] < 0) $_POST["CASHDESK_ID_THIRDPARTY"]='';
|
||||||
if ($_POST["CASHDESK_ID_WAREHOUSE"] < 0) $_POST["CASHDESK_ID_WAREHOUSE"]='';
|
|
||||||
if ($_POST["CASHDESK_ID_BANKACCOUNT"] < 0) $_POST["CASHDESK_ID_BANKACCOUNT"]='';
|
if ($_POST["CASHDESK_ID_BANKACCOUNT"] < 0) $_POST["CASHDESK_ID_BANKACCOUNT"]='';
|
||||||
|
// if ($_POST["CASHDESK_ID_WAREHOUSE"] < 0) $_POST["CASHDESK_ID_WAREHOUSE"]='';
|
||||||
|
|
||||||
dolibarr_set_const($db,"CASHDESK_ID_THIRDPARTY",$_POST["CASHDESK_ID_THIRDPARTY"],'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db,"CASHDESK_ID_THIRDPARTY",$_POST["CASHDESK_ID_THIRDPARTY"],'chaine',0,'',$conf->entity);
|
||||||
dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT",$_POST["CASHDESK_ID_BANKACCOUNT"],'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CASH",$_POST["CASHDESK_ID_BANKACCOUNT_CASH"],'chaine',0,'',$conf->entity);
|
||||||
dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",$_POST["CASHDESK_ID_WAREHOUSE"],'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CHEQUE",$_POST["CASHDESK_ID_BANKACCOUNT_CHEQUE"],'chaine',0,'',$conf->entity);
|
||||||
|
dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CB",$_POST["CASHDESK_ID_BANKACCOUNT_CB"],'chaine',0,'',$conf->entity);
|
||||||
|
// dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",$_POST["CASHDESK_ID_WAREHOUSE"],'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
dol_syslog("admin/cashdesk: level ".$_POST["level"]);
|
dol_syslog("admin/cashdesk: level ".$_POST["level"]);
|
||||||
}
|
}
|
||||||
@ -96,9 +98,22 @@ if ($conf->global->MAIN_MODULE_BANQUE)
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT,'CASHDESK_ID_BANKACCOUNT',0,"courant=2",1);
|
$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH,'CASHDESK_ID_BANKACCOUNT_CASH',0,"courant=2",1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
|
||||||
|
print '<td colspan="2">';
|
||||||
|
$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE,'CASHDESK_ID_BANKACCOUNT_CHEQUE',0,"courant=1",1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
|
||||||
|
print '<td colspan="2">';
|
||||||
|
$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB,'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if ($conf->global->MAIN_MODULE_STOCK)
|
if ($conf->global->MAIN_MODULE_STOCK)
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
@ -107,7 +122,7 @@ if ($conf->global->MAIN_MODULE_STOCK)
|
|||||||
$formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1);
|
$formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,11 @@ $conf_url_racine = $dolibarr_main_url_root.'/cashdesk';
|
|||||||
// Identifiant unique correspondant au tiers generique pour la vente
|
// Identifiant unique correspondant au tiers generique pour la vente
|
||||||
$conf_fksoc = $conf->global->CASHDESK_ID_THIRDPARTY;
|
$conf_fksoc = $conf->global->CASHDESK_ID_THIRDPARTY;
|
||||||
// Identifiant unique correspondant au compte caisse / liquide
|
// Identifiant unique correspondant au compte caisse / liquide
|
||||||
$conf_fkaccount = $conf->global->CASHDESK_ID_BANKACCOUNT > 0?$conf->global->CASHDESK_ID_BANKACCOUNT:$_SESSION["CASHDESK_ID_BANKACCOUNT"];
|
$conf_fkaccount_cash = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0?$conf->global->CASHDESK_ID_BANKACCOUNT_CASH:$_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"];
|
||||||
|
// Identifiant unique correspondant au compte cheque
|
||||||
|
$conf_fkaccount_cheque = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0?$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE:$_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"];
|
||||||
|
// Identifiant unique correspondant au compte cb
|
||||||
|
$conf_fkaccount_cb = $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0?$conf->global->CASHDESK_ID_BANKACCOUNT_CB:$_SESSION["CASHDESK_ID_BANKACCOUNT_CB"];
|
||||||
// Identifiant unique correspondant a l'entrepot associe a la caisse
|
// Identifiant unique correspondant a l'entrepot associe a la caisse
|
||||||
$conf_fkentrepot = $conf->global->CASHDESK_ID_WAREHOUSE > 0?$conf->global->CASHDESK_ID_WAREHOUSE:$_SESSION["CASHDESK_ID_WAREHOUSE"];
|
$conf_fkentrepot = $conf->global->CASHDESK_ID_WAREHOUSE > 0?$conf->global->CASHDESK_ID_WAREHOUSE:$_SESSION["CASHDESK_ID_WAREHOUSE"];
|
||||||
|
|
||||||
|
|||||||
@ -27,9 +27,10 @@ $company->fetch($conf->global->CASHDESK_ID_THIRDPARTY);
|
|||||||
$bank=new Account($db);
|
$bank=new Account($db);
|
||||||
$bank->fetch($conf->global->CASHDESK_ID_BANKACCOUNT);
|
$bank->fetch($conf->global->CASHDESK_ID_BANKACCOUNT);
|
||||||
$warehouse=new Entrepot($db);
|
$warehouse=new Entrepot($db);
|
||||||
$warehouse->fetch($conf->global->CASHDESK_ID_WAREHOUSE);
|
//$warehouse->fetch($conf->global->CASHDESK_ID_WAREHOUSE);
|
||||||
|
|
||||||
$langs->load("@cashdesk");
|
$langs->load("@cashdesk");
|
||||||
|
$langs->load("main");
|
||||||
|
|
||||||
$logout='<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png">';
|
$logout='<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png">';
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ print '<li class="menu_choix2"><a href=".."><span>'.$langs->trans("BackOffice").
|
|||||||
print '<li class="menu_choix0">'.$langs->trans("User").' : '.$_SESSION['prenom'].' '.$_SESSION['nom'].' <a href="deconnexion.php">'.$logout.'</a><br>';
|
print '<li class="menu_choix0">'.$langs->trans("User").' : '.$_SESSION['prenom'].' '.$_SESSION['nom'].' <a href="deconnexion.php">'.$logout.'</a><br>';
|
||||||
print $langs->trans("CashDeskThirdParty").' : '.$company->getNomUrl(1).'<br>';
|
print $langs->trans("CashDeskThirdParty").' : '.$company->getNomUrl(1).'<br>';
|
||||||
print $langs->trans("CashDeskBank").' : '.$bank->getNomUrl(1).'<br>';
|
print $langs->trans("CashDeskBank").' : '.$bank->getNomUrl(1).'<br>';
|
||||||
if ($conf->stock->enabled)
|
if ($conf->stock->enabled && $warehouse->id) // Disabled because warehouse->fetch disabled before
|
||||||
{
|
{
|
||||||
print $langs->trans("CashDeskWarehouse").' : '.$warehouse->getNomUrl(1);
|
print $langs->trans("CashDeskWarehouse").' : '.$warehouse->getNomUrl(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,9 @@
|
|||||||
require ('../master.inc.php');
|
require ('../master.inc.php');
|
||||||
require (DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php');
|
require (DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php');
|
||||||
require (DOL_DOCUMENT_ROOT.'/cashdesk/classes/Facturation.class.php');
|
require (DOL_DOCUMENT_ROOT.'/cashdesk/classes/Facturation.class.php');
|
||||||
require (DOL_DOCUMENT_ROOT.'/Facture.class.php');
|
require (DOL_DOCUMENT_ROOT.'/facture.class.php');
|
||||||
|
require (DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php');
|
||||||
|
require (DOL_DOCUMENT_ROOT.'/paiement.class.php');
|
||||||
|
|
||||||
$obj_facturation = unserialize ($_SESSION['serObjFacturation']);
|
$obj_facturation = unserialize ($_SESSION['serObjFacturation']);
|
||||||
unset ($_SESSION['serObjFacturation']);
|
unset ($_SESSION['serObjFacturation']);
|
||||||
@ -85,16 +87,21 @@ switch ( $_GET['action'] )
|
|||||||
$heure = date ('H:i:s');
|
$heure = date ('H:i:s');
|
||||||
|
|
||||||
$note = '';
|
$note = '';
|
||||||
|
if (! is_object($obj_facturation))
|
||||||
|
{
|
||||||
|
dol_print_error('','Empty context');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
switch ( $obj_facturation->mode_reglement() )
|
switch ( $obj_facturation->mode_reglement() )
|
||||||
{
|
{
|
||||||
case 'DIF':
|
case 'DIF':
|
||||||
$mode_reglement_id = 0;
|
$mode_reglement_id = 0;
|
||||||
//$cond_reglement_id = dol_getIdFromCode($db,'RECEP','cond_reglement','code','rowid')
|
//$cond_reglement_id = dol_getIdFromCode($sql,'RECEP','cond_reglement','code','rowid')
|
||||||
$cond_reglement_id = 0;
|
$cond_reglement_id = 0;
|
||||||
break;
|
break;
|
||||||
case 'ESP':
|
case 'ESP':
|
||||||
$mode_reglement_id = dol_getIdFromCode($db,$obj_facturation->mode_reglement(),'c_paiement');
|
$mode_reglement_id = dol_getIdFromCode($sql,'LIQ','c_paiement');
|
||||||
$cond_reglement_id = 0;
|
$cond_reglement_id = 0;
|
||||||
$note .= $langs->trans("Cash")."\n";
|
$note .= $langs->trans("Cash")."\n";
|
||||||
$note .= $langs->trans("Received").' : '.$obj_facturation->montant_encaisse()." ".$conf->monnaie."\n";
|
$note .= $langs->trans("Received").' : '.$obj_facturation->montant_encaisse()." ".$conf->monnaie."\n";
|
||||||
@ -103,19 +110,23 @@ switch ( $_GET['action'] )
|
|||||||
$note .= '--------------------------------------'."\n\n";
|
$note .= '--------------------------------------'."\n\n";
|
||||||
break;
|
break;
|
||||||
case 'CB':
|
case 'CB':
|
||||||
$mode_reglement_id = dol_getIdFromCode($db,$obj_facturation->mode_reglement(),'c_paiement');
|
$mode_reglement_id = dol_getIdFromCode($sql,'CB','c_paiement');
|
||||||
$cond_reglement_id = 0;
|
$cond_reglement_id = 0;
|
||||||
break;
|
break;
|
||||||
case 'CHQ':
|
case 'CHQ':
|
||||||
$mode_reglement_id = dol_getIdFromCode($db,$obj_facturation->mode_reglement(),'c_paiement');
|
$mode_reglement_id = dol_getIdFromCode($sql,'CHQ','c_paiement');
|
||||||
$cond_reglement_id = 0;
|
$cond_reglement_id = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (empty($mode_reglement_id)) $mode_reglement_id=0; // If mode_reglement_id not found
|
||||||
// ... on termine la note
|
if (empty($cond_reglement_id)) $cond_reglement_id=0; // If cond_reglement_id not found
|
||||||
$note .= $_POST['txtaNotes'];
|
$note .= $_POST['txtaNotes'];
|
||||||
|
dol_syslog("obj_facturation->mode_reglement()=".$obj_facturation->mode_reglement()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id);
|
||||||
|
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
$now=dol_now('tzserver');
|
||||||
|
|
||||||
|
|
||||||
$sql->begin();
|
$sql->begin();
|
||||||
|
|
||||||
@ -123,7 +134,6 @@ switch ( $_GET['action'] )
|
|||||||
$user->fetch();
|
$user->fetch();
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
$now=dol_now('tzserver');
|
|
||||||
$invoice=new Facture($sql,$conf_fksoc);
|
$invoice=new Facture($sql,$conf_fksoc);
|
||||||
|
|
||||||
|
|
||||||
@ -182,60 +192,6 @@ switch ( $_GET['action'] )
|
|||||||
$invoiceline->total_ttc=$tab_liste[$i]['total_ttc'];
|
$invoiceline->total_ttc=$tab_liste[$i]['total_ttc'];
|
||||||
$invoiceline->total_tva=($tab_liste[$i]['total_ttc']-$tab_liste[$i]['total_ht']);
|
$invoiceline->total_tva=($tab_liste[$i]['total_ttc']-$tab_liste[$i]['total_ht']);
|
||||||
$invoice->lignes[]=$invoiceline;
|
$invoice->lignes[]=$invoiceline;
|
||||||
|
|
||||||
// Calcul du montant de la TVA
|
|
||||||
/* $montant_tva = $tab_liste[$i]['total_ttc'] - $tab_liste[$i]['total_ht'];
|
|
||||||
// Calcul de la position de l'article dans la liste
|
|
||||||
$reel = $tab_liste[$i]['reel'];
|
|
||||||
$qte = $tab_liste[$i]['qte'];
|
|
||||||
$stock = $reel - $qte;
|
|
||||||
$position = $i + 1;
|
|
||||||
|
|
||||||
// Ajout d'une entree dans le detail de la facture
|
|
||||||
$sql->query (
|
|
||||||
'INSERT INTO '.MAIN_DB_PREFIX.'facturedet (
|
|
||||||
fk_facture,
|
|
||||||
fk_product,
|
|
||||||
description,
|
|
||||||
tva_taux,
|
|
||||||
qty,
|
|
||||||
remise_percent,
|
|
||||||
remise,
|
|
||||||
fk_remise_except,
|
|
||||||
subprice,
|
|
||||||
price,
|
|
||||||
total_ht,
|
|
||||||
total_tva,
|
|
||||||
total_ttc,
|
|
||||||
date_start,
|
|
||||||
date_end,
|
|
||||||
info_bits,
|
|
||||||
fk_code_ventilation,
|
|
||||||
fk_export_compta,
|
|
||||||
rang
|
|
||||||
)
|
|
||||||
|
|
||||||
VALUES (
|
|
||||||
'.$id.",
|
|
||||||
".$tab_liste[$i]['fk_article'].",
|
|
||||||
'".$tab_article['label']."',
|
|
||||||
".$tab_tva['taux'].",
|
|
||||||
".$tab_liste[$i]['qte'].",
|
|
||||||
".$tab_liste[$i]['remise_percent'].",
|
|
||||||
".$tab_liste[$i]['remise'].",
|
|
||||||
0,
|
|
||||||
".$tab_article['price'].",
|
|
||||||
".$tab_article['price'].",
|
|
||||||
".$tab_liste[$i]['total_ht'].",
|
|
||||||
".$montant_tva.",
|
|
||||||
".$tab_liste[$i]['total_ttc'].",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
".$position.")");
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice->socid=$conf_fksoc;
|
$invoice->socid=$conf_fksoc;
|
||||||
@ -266,122 +222,97 @@ switch ( $_GET['action'] )
|
|||||||
$id = $invoice->id;
|
$id = $invoice->id;
|
||||||
|
|
||||||
// Add the payment
|
// Add the payment
|
||||||
// TODO Manage ESP, CHQ...
|
$payment=new Paiement($db);
|
||||||
|
$payment->datepaye=$now;
|
||||||
|
$payment->bank_account=$conf_fkaccount;
|
||||||
|
$payment->amounts[$invoice->id]=$obj_facturation->prix_total_ttc();
|
||||||
|
$payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->num_facture();
|
||||||
|
$payment->paiementid=$invoice->mode_reglement_id;
|
||||||
|
$payment->num_paiement='';
|
||||||
|
|
||||||
// Ajout d'une operation sur le compte de caisse, uniquement si le paiement est en especes
|
$paiement_id = $payment->create($user);
|
||||||
if ( $obj_facturation->mode_reglement() == 'ESP' )
|
if ($paiement_id > 0)
|
||||||
{
|
{
|
||||||
$sql->query (
|
// Ajout d'une ecriture sur le compte bancaire
|
||||||
"INSERT INTO ".MAIN_DB_PREFIX."bank (
|
if ($conf->banque->enabled)
|
||||||
datec,
|
{
|
||||||
datev,
|
$bankaccountid=0;
|
||||||
dateo,
|
if ( $obj_facturation->mode_reglement() == 'ESP' )
|
||||||
amount,
|
{
|
||||||
label,
|
$bankaccountid=$conf_fkaccount_cash;
|
||||||
fk_account,
|
}
|
||||||
fk_user_author,
|
if ( $obj_facturation->mode_reglement() == 'CHQ' )
|
||||||
fk_type,
|
{
|
||||||
rappro,
|
$bankaccountid=$conf_fkaccount_cheque;
|
||||||
fk_bordereau
|
}
|
||||||
)
|
if ( $obj_facturation->mode_reglement() == 'CB' )
|
||||||
|
{
|
||||||
|
$bankaccountid=$conf_fkaccount_cb;
|
||||||
|
}
|
||||||
|
|
||||||
VALUES (
|
if ($bankaccountid > 0)
|
||||||
'".$date." ".$heure."',
|
{
|
||||||
'".$date."',
|
// Insertion dans llx_bank
|
||||||
'".$date."',
|
$label = "(CustomerInvoicePayment)";
|
||||||
".$obj_facturation->prix_total_ttc().",
|
$acc = new Account($db, $bankaccountid);
|
||||||
'Paiement caisse facture ".$obj_facturation->num_facture()."',
|
|
||||||
".$conf_fkaccount.",
|
|
||||||
".$_SESSION['uid'].",
|
|
||||||
'ESP',
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
)
|
|
||||||
");
|
|
||||||
|
|
||||||
|
$bank_line_id = $acc->addline($payment->datepaye,
|
||||||
|
$payment->paiementid, // Payment mode id or code ("CHQ or VIR for example")
|
||||||
|
$label,
|
||||||
|
$obj_facturation->prix_total_ttc(),
|
||||||
|
$payment->num_paiement,
|
||||||
|
'',
|
||||||
|
$user,
|
||||||
|
'',
|
||||||
|
'');
|
||||||
|
|
||||||
|
// Mise a jour fk_bank dans llx_paiement.
|
||||||
|
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||||
|
if ($bank_line_id > 0)
|
||||||
|
{
|
||||||
|
$payment->update_fk_bank($bank_line_id);
|
||||||
|
// Mise a jour liens (pour chaque facture concernees par le paiement)
|
||||||
|
foreach ($payment->amounts as $key => $value)
|
||||||
|
{
|
||||||
|
$facid = $key;
|
||||||
|
$fac = new Facture($db);
|
||||||
|
$fac->fetch($facid);
|
||||||
|
$fac->fetch_client();
|
||||||
|
$acc->add_url_line($bank_line_id,
|
||||||
|
$paiement_id,
|
||||||
|
DOL_URL_ROOT.'/compta/paiement/fiche.php?id=',
|
||||||
|
'(paiement)',
|
||||||
|
'payment');
|
||||||
|
$acc->add_url_line($bank_line_id,
|
||||||
|
$fac->client->id,
|
||||||
|
DOL_URL_ROOT.'/compta/fiche.php?socid=',
|
||||||
|
$fac->client->nom,
|
||||||
|
'company');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Recuperation de l'id de l'operation nouvellement creee
|
else
|
||||||
$resql=$sql->query (
|
|
||||||
"SELECT rowid
|
|
||||||
FROM ".MAIN_DB_PREFIX."bank
|
|
||||||
WHERE 1
|
|
||||||
ORDER BY rowid DESC");
|
|
||||||
$ret=array();
|
|
||||||
$tab = $sql->fetch_array($resql);
|
|
||||||
foreach ( $tab as $cle => $valeur )
|
|
||||||
{
|
{
|
||||||
$ret[$cle] = $valeur;
|
$error++;
|
||||||
}
|
}
|
||||||
$tab_id_operation = $tab;
|
|
||||||
$id_op = $tab_id_operation['rowid'];
|
|
||||||
|
|
||||||
// Ajout d'un nouveau paiement
|
|
||||||
$request="INSERT INTO ".MAIN_DB_PREFIX."paiement (
|
|
||||||
fk_facture,
|
|
||||||
datec,
|
|
||||||
datep,
|
|
||||||
amount,
|
|
||||||
fk_paiement,
|
|
||||||
num_paiement,
|
|
||||||
note,
|
|
||||||
fk_bank,
|
|
||||||
fk_user_creat,
|
|
||||||
fk_user_modif,
|
|
||||||
statut,
|
|
||||||
fk_export_compta
|
|
||||||
)
|
|
||||||
|
|
||||||
VALUES (
|
|
||||||
".$id.",
|
|
||||||
'".$date." ".$heure."',
|
|
||||||
'".$date." 12:00:00',
|
|
||||||
".$obj_facturation->prix_total_ttc().",
|
|
||||||
".$mode_reglement.",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
$id_op,
|
|
||||||
".$_SESSION['uid'].",
|
|
||||||
NULL,
|
|
||||||
1,
|
|
||||||
0
|
|
||||||
)";
|
|
||||||
$sql->query ($request);
|
|
||||||
// Recuperation de l'id du paiement nouvellement cr<63>
|
|
||||||
$resql=$sql->query (
|
|
||||||
"SELECT rowid
|
|
||||||
FROM ".MAIN_DB_PREFIX."paiement
|
|
||||||
WHERE 1
|
|
||||||
ORDER BY rowid DESC");
|
|
||||||
$ret=array();
|
|
||||||
$tab = $sql->fetch_array($resql);
|
|
||||||
foreach ( $tab as $cle => $valeur )
|
|
||||||
{
|
|
||||||
$ret[$cle] = $valeur;
|
|
||||||
}
|
|
||||||
$tab_id_paiement = $tab;
|
|
||||||
$id_paiement = $tab_id_paiement['rowid'];
|
|
||||||
|
|
||||||
|
|
||||||
$sql->query (
|
|
||||||
"INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (
|
|
||||||
fk_paiement,
|
|
||||||
fk_facture,
|
|
||||||
amount
|
|
||||||
)
|
|
||||||
|
|
||||||
VALUES (
|
|
||||||
".$id_paiement.",
|
|
||||||
".$id.",
|
|
||||||
".$obj_facturation->prix_total_ttc()."
|
|
||||||
)
|
|
||||||
");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->commit();
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql->commit();
|
||||||
$redirection = 'affIndex.php?menu=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
|
$redirection = 'affIndex.php?menu=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql->rollback();
|
||||||
|
$redirection = 'affIndex.php?facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// End of case: valide_facture
|
// End of case: valide_facture
|
||||||
|
|||||||
@ -59,7 +59,7 @@ if ($_POST['action'] == 'add_paiement' || $_POST['action'] == 'confirm_paiement'
|
|||||||
$_POST['reyear']);
|
$_POST['reyear']);
|
||||||
$paiement_id = 0;
|
$paiement_id = 0;
|
||||||
|
|
||||||
// Verifie si des paiements sont sup<EFBFBD>rieurs au montant facture
|
// Verifie si des paiements sont superieurs au montant facture
|
||||||
foreach ($_POST as $key => $value)
|
foreach ($_POST as $key => $value)
|
||||||
{
|
{
|
||||||
if (substr($key,0,7) == 'amount_')
|
if (substr($key,0,7) == 'amount_')
|
||||||
@ -93,8 +93,8 @@ if ($_POST['action'] == 'add_paiement' || $_POST['action'] == 'confirm_paiement'
|
|||||||
// d'un paiement
|
// d'un paiement
|
||||||
if (! $_POST['accountid'])
|
if (! $_POST['accountid'])
|
||||||
{
|
{
|
||||||
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
|
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,9 +155,9 @@ if ($_POST['action'] == 'confirm_paiement' && $_POST['confirm'] == 'yes')
|
|||||||
// Insertion dans llx_bank
|
// Insertion dans llx_bank
|
||||||
$label = "(CustomerInvoicePayment)";
|
$label = "(CustomerInvoicePayment)";
|
||||||
$acc = new Account($db, $_POST['accountid']);
|
$acc = new Account($db, $_POST['accountid']);
|
||||||
//paiementid contient "CHQ ou VIR par exemple"
|
|
||||||
$bank_line_id = $acc->addline($paiement->datepaye,
|
$bank_line_id = $acc->addline($paiement->datepaye,
|
||||||
$paiement->paiementid,
|
$paiement->paiementid, // Payment mode id or code ("CHQ or VIR for example")
|
||||||
$label,
|
$label,
|
||||||
$totalpaiement,
|
$totalpaiement,
|
||||||
$paiement->num_paiement,
|
$paiement->num_paiement,
|
||||||
@ -167,7 +167,7 @@ if ($_POST['action'] == 'confirm_paiement' && $_POST['confirm'] == 'yes')
|
|||||||
$_POST['chqbank']);
|
$_POST['chqbank']);
|
||||||
|
|
||||||
// Mise a jour fk_bank dans llx_paiement.
|
// Mise a jour fk_bank dans llx_paiement.
|
||||||
// On connait ainsi le paiement qui a g<EFBFBD>n<EFBFBD>r<EFBFBD> l'<27>criture bancaire
|
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||||
if ($bank_line_id > 0)
|
if ($bank_line_id > 0)
|
||||||
{
|
{
|
||||||
$paiement->update_fk_bank($bank_line_id);
|
$paiement->update_fk_bank($bank_line_id);
|
||||||
|
|||||||
@ -56,8 +56,7 @@ class modCashDesk extends DolibarrModules
|
|||||||
$this->description = "CashDesk module";
|
$this->description = "CashDesk module";
|
||||||
|
|
||||||
$this->revision = explode(' ','$Revision$');
|
$this->revision = explode(' ','$Revision$');
|
||||||
$this->version = 'experimental';
|
$this->version = 'dolibarr';
|
||||||
//$this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version
|
|
||||||
|
|
||||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||||
$this->special = 0;
|
$this->special = 0;
|
||||||
|
|||||||
@ -1093,7 +1093,9 @@ ClickToDialDesc=This module allows to add an icon after the phone number of Doli
|
|||||||
CashDesk=Point of sales
|
CashDesk=Point of sales
|
||||||
CashDeskSetup=Point of sales module setup
|
CashDeskSetup=Point of sales module setup
|
||||||
CashDeskThirdPartyForSell=Generic third party to use for sells
|
CashDeskThirdPartyForSell=Generic third party to use for sells
|
||||||
CashDeskBankAccountForSell=Cash account to use for sells
|
CashDeskBankAccountForSell=Account to use to receive cash payments
|
||||||
|
CashDeskBankAccountForCheque = Account to use to receive payments by cheque
|
||||||
|
CashDeskBankAccountForCB = Account to use to receive cash payments by credit cards
|
||||||
CashDeskIdWareHouse=Warehouse to use for sells
|
CashDeskIdWareHouse=Warehouse to use for sells
|
||||||
##### Bookmark #####
|
##### Bookmark #####
|
||||||
BookmarkSetup=Bookmark module setup
|
BookmarkSetup=Bookmark module setup
|
||||||
|
|||||||
@ -1093,7 +1093,9 @@ ClickToDialDesc = Ce module permet d'ajouter un petit picto a coté des numéros
|
|||||||
CashDesk=Caisse enregistreuse
|
CashDesk=Caisse enregistreuse
|
||||||
CashDeskSetup = Configuration du module Caisse enregistreuse
|
CashDeskSetup = Configuration du module Caisse enregistreuse
|
||||||
CashDeskThirdPartyForSell = Tiers générique à utiliser pour les ventes
|
CashDeskThirdPartyForSell = Tiers générique à utiliser pour les ventes
|
||||||
CashDeskBankAccountForSell = Compte caisse à utiliser pour les ventes
|
CashDeskBankAccountForSell = Compte à utiliser pour l'encaissement en liquide (cash)
|
||||||
|
CashDeskBankAccountForCheque = Compte à utiliser pour l'encaissement en chèque
|
||||||
|
CashDeskBankAccountForCB = Compte à utiliser pour l'encaissement par carte de crédit
|
||||||
CashDeskIdWareHouse = Entrepot à utiliser pour les ventes
|
CashDeskIdWareHouse = Entrepot à utiliser pour les ventes
|
||||||
##### Bookmark ##### = undefined
|
##### Bookmark ##### = undefined
|
||||||
BookmarkSetup = Configuration du module Bookmark
|
BookmarkSetup = Configuration du module Bookmark
|
||||||
|
|||||||
@ -3124,8 +3124,7 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$db->lasterror();
|
dol_syslog("dol_getIdFromCode error=".$db->lasterror(),LOG_ERR);
|
||||||
dol_syslog("dol_getIdFromCode error=".$this->error,LOG_ERR);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user