task #10501: Can use point of sale with different bank accounts
This commit is contained in:
parent
96c978e0b2
commit
fad38c753a
@ -65,7 +65,7 @@ print '<div class="menu_bloc">';
|
|||||||
print '<ul class="menu">';
|
print '<ul class="menu">';
|
||||||
print '<li class="menu_choix1"><a href="affIndex.php?menu=facturation&id=NOUV"><span>'.$langs->trans("NewSell").'</span></a></li>';
|
print '<li class="menu_choix1"><a href="affIndex.php?menu=facturation&id=NOUV"><span>'.$langs->trans("NewSell").'</span></a></li>';
|
||||||
|
|
||||||
print '<li class="menu_choix2"><a href="deconnexion.php"><span>'.$langs->trans("BackOffice").'</span></a></li>';
|
print '<li class="menu_choix2"><a href=".."><span>'.$langs->trans("BackOffice").'</span></a></li>';
|
||||||
|
|
||||||
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").': '.$companyLink.'<br>';
|
print $langs->trans("CashDeskThirdParty").': '.$companyLink.'<br>';
|
||||||
|
|||||||
@ -1246,9 +1246,9 @@ ClickToDialDesc=Aquest mòdul permet afegir una icona després del número de te
|
|||||||
CashDesk=TPV
|
CashDesk=TPV
|
||||||
CashDeskSetup=Mòdul de configuració Terminal Punt de Venda
|
CashDeskSetup=Mòdul de configuració Terminal Punt de Venda
|
||||||
CashDeskThirdPartyForSell=Tercer genéric a utilitzar per a les vendes
|
CashDeskThirdPartyForSell=Tercer genéric a utilitzar per a les vendes
|
||||||
CashDeskBankAccountForSell=Compte a utilitzar per als cobraments en efectiu (caixa)
|
CashDeskBankAccountForSell=Compte per defecte a utilitzar per als cobraments en efectiu (caixa)
|
||||||
CashDeskBankAccountForCheque=Compte a utilitzar per als cobraments amb xecs
|
CashDeskBankAccountForCheque=Compte per defecte a utilitzar per als cobraments amb xecs
|
||||||
CashDeskBankAccountForCB=Compte a utilitzar per als cobraments amb targeta de crèdit
|
CashDeskBankAccountForCB=Compte per defecte a utilitzar per als cobraments amb targeta de crèdit
|
||||||
CashDeskIdWareHouse=Magatzem a ultilitzar per a les vendes
|
CashDeskIdWareHouse=Magatzem a ultilitzar per a les vendes
|
||||||
##### Bookmark #####
|
##### Bookmark #####
|
||||||
BookmarkSetup=Configuració del mòdul Bookmark
|
BookmarkSetup=Configuració del mòdul Bookmark
|
||||||
|
|||||||
@ -33,5 +33,3 @@ Change=Canvi
|
|||||||
CalTip=Feu clic per veure el calendari
|
CalTip=Feu clic per veure el calendari
|
||||||
CashDeskSetupStock=La configuració decrementa l'estoc en la creació de factures, però no ha indicat magatzem.<br>Canvieu la configuració del mòdul estoc, o esculli un magatzem
|
CashDeskSetupStock=La configuració decrementa l'estoc en la creació de factures, però no ha indicat magatzem.<br>Canvieu la configuració del mòdul estoc, o esculli un magatzem
|
||||||
BankToPay=Compte de cobrament
|
BankToPay=Compte de cobrament
|
||||||
ShowCompany=Veure empresa
|
|
||||||
ShowStock=Veure magatzem
|
|
||||||
@ -33,5 +33,3 @@ Change=Excess received
|
|||||||
CalTip=Click to view the calendar
|
CalTip=Click to view the calendar
|
||||||
CashDeskSetupStock=You ask to decrease stock on invoice creation but warehouse for this is was not defined<br>Change stock module setup, or choose a warehouse
|
CashDeskSetupStock=You ask to decrease stock on invoice creation but warehouse for this is was not defined<br>Change stock module setup, or choose a warehouse
|
||||||
BankToPay=Charge Account
|
BankToPay=Charge Account
|
||||||
ShowCompany=Show company
|
|
||||||
ShowStock=Show warehouse
|
|
||||||
@ -1246,9 +1246,9 @@ ClickToDialDesc=Este módulo permite agregar un icono después del número de te
|
|||||||
CashDesk=TPV
|
CashDesk=TPV
|
||||||
CashDeskSetup=Configuración del módulo Terminal Punto de Venta
|
CashDeskSetup=Configuración del módulo Terminal Punto de Venta
|
||||||
CashDeskThirdPartyForSell=Tercero genérico a usar para la venta
|
CashDeskThirdPartyForSell=Tercero genérico a usar para la venta
|
||||||
CashDeskBankAccountForSell=Cuenta a utilizar para los cobros en efectivo (caja)
|
CashDeskBankAccountForSell=Cuenta por defecto a utilizar para los cobros en efectivo (caja)
|
||||||
CashDeskBankAccountForCheque=Cuenta a utilizar para los cobros con cheques
|
CashDeskBankAccountForCheque=Cuenta por defecto a utilizar para los cobros con cheques
|
||||||
CashDeskBankAccountForCB=Cuenta a utilizar para los cobros con tarjeta de crédito
|
CashDeskBankAccountForCB=Cuenta por defecto a utilizar para los cobros con tarjeta de crédito
|
||||||
CashDeskIdWareHouse=Almacén a utilizar para las ventas
|
CashDeskIdWareHouse=Almacén a utilizar para las ventas
|
||||||
##### Bookmark #####
|
##### Bookmark #####
|
||||||
BookmarkSetup=Configuración del módulo Marcadores
|
BookmarkSetup=Configuración del módulo Marcadores
|
||||||
|
|||||||
@ -33,5 +33,3 @@ Change=Cambio
|
|||||||
CalTip=Haga clic para ver el calendario
|
CalTip=Haga clic para ver el calendario
|
||||||
CashDeskSetupStock=La configuración decrementa el stock en la creación de facturas, pero no ha indicado almacén.<br>Cambie la configuración del módulo stock, o escoja un almacén
|
CashDeskSetupStock=La configuración decrementa el stock en la creación de facturas, pero no ha indicado almacén.<br>Cambie la configuración del módulo stock, o escoja un almacén
|
||||||
BankToPay=Cuenta de cobro
|
BankToPay=Cuenta de cobro
|
||||||
ShowCompany=Ver empresa
|
|
||||||
ShowStock=Ver almacén
|
|
||||||
@ -33,5 +33,3 @@ Change=Rendu
|
|||||||
CalTip=Cliquez pour afficher le calendrier
|
CalTip=Cliquez pour afficher le calendrier
|
||||||
CashDeskSetupStock=La configuration du module stock demande une réduction du stock sur facturation, mais vous n'avez pas spécifiez d'entrepôt. Vous devez modifier la configuration du module stock ou choisir un entrepôt.
|
CashDeskSetupStock=La configuration du module stock demande une réduction du stock sur facturation, mais vous n'avez pas spécifiez d'entrepôt. Vous devez modifier la configuration du module stock ou choisir un entrepôt.
|
||||||
BankToPay=Compte à créditer
|
BankToPay=Compte à créditer
|
||||||
ShowCompany=Voir société
|
|
||||||
ShowStock=Voir entrepôt
|
|
||||||
@ -17,14 +17,15 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/product/class/product.class.php
|
* \file htdocs/product/class/product.class.php
|
||||||
* \ingroup produit
|
* \ingroup produit
|
||||||
* \brief Fichier de la classe des produits predefinis
|
* \brief Fichier de la classe des produits predefinis
|
||||||
* \version $Id: product.class.php,v 1.48 2011/07/31 23:24:03 eldy Exp $
|
* \version $Id: product.class.php,v 1.46 2011/07/29 06:59:36 tiaris Exp $
|
||||||
*/
|
*/
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||||
|
|
||||||
@ -190,15 +191,14 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert product into database
|
* Insert product into database
|
||||||
* @param user User making insert
|
* @param user User making insert
|
||||||
* @param notrigger Disable triggers
|
* @return int id of product/service if OK or number of error < 0
|
||||||
* @return int Id of product/service if OK or number of error < 0
|
|
||||||
*/
|
*/
|
||||||
function create($user,$notrigger=0)
|
function create($user)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf ;
|
||||||
|
|
||||||
$error=0;
|
$this->errno = 0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->ref = dol_string_nospecial(trim($this->ref));
|
$this->ref = dol_string_nospecial(trim($this->ref));
|
||||||
@ -250,149 +250,172 @@ class Product extends CommonObject
|
|||||||
$this->error='ErrorWrongParameters';
|
$this->error='ErrorWrongParameters';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (empty($this->ref))
|
|
||||||
{
|
|
||||||
$this->error='ErrorWrongParameters';
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_syslog("Product::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG);
|
dol_syslog("Product::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG);
|
||||||
|
|
||||||
|
if ($this->ref)
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
$sql = "SELECT count(*) as nb";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
|
||||||
$sql.= " WHERE ref = '" .$this->ref."'";
|
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$this->db->begin();
|
||||||
if ($obj->nb == 0)
|
|
||||||
|
$sql = "SELECT count(*)";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
|
$sql.= " WHERE ref = '" .$this->ref."'";
|
||||||
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
// Produit non deja existant
|
$row = $this->db->fetch_array($result);
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product (";
|
if ($row[0] == 0)
|
||||||
$sql.= "datec";
|
|
||||||
$sql.= ", entity";
|
|
||||||
$sql.= ", ref";
|
|
||||||
$sql.= ", price_min";
|
|
||||||
$sql.= ", price_min_ttc";
|
|
||||||
$sql.= ", label";
|
|
||||||
$sql.= ", fk_user_author";
|
|
||||||
$sql.= ", fk_product_type";
|
|
||||||
$sql.= ", price";
|
|
||||||
$sql.= ", price_ttc";
|
|
||||||
$sql.= ", price_base_type";
|
|
||||||
$sql.= ", tobuy";
|
|
||||||
$sql.= ", tosell";
|
|
||||||
$sql.= ", canvas";
|
|
||||||
$sql.= ", finished";
|
|
||||||
$sql.= ", hidden";
|
|
||||||
$sql.= ") VALUES (";
|
|
||||||
$sql.= $this->db->idate(mktime());
|
|
||||||
$sql.= ", ".$conf->entity;
|
|
||||||
$sql.= ", '".$this->ref."'";
|
|
||||||
$sql.= ", ".price2num($price_min_ht);
|
|
||||||
$sql.= ", ".price2num($price_min_ttc);
|
|
||||||
$sql.= ", ".($this->libelle?"'".$this->db->escape($this->libelle)."'":"null");
|
|
||||||
$sql.= ", ".$user->id;
|
|
||||||
$sql.= ", ".$this->type;
|
|
||||||
$sql.= ", ".price2num($price_ht);
|
|
||||||
$sql.= ", ".price2num($price_ttc);
|
|
||||||
$sql.= ", '".$this->price_base_type."'";
|
|
||||||
$sql.= ", ".$this->status;
|
|
||||||
$sql.= ", ".$this->status_buy;
|
|
||||||
$sql.= ", '".$this->canvas."'";
|
|
||||||
$sql.= ", ".$this->finished;
|
|
||||||
$sql.= ", ".$this->hidden;
|
|
||||||
$sql.= ")";
|
|
||||||
|
|
||||||
dol_syslog("Product::Create sql=".$sql);
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
if ( $result )
|
|
||||||
{
|
{
|
||||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."product");
|
// Produit non deja existant
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product (";
|
||||||
|
$sql.= "datec";
|
||||||
|
$sql.= ", entity";
|
||||||
|
$sql.= ", ref";
|
||||||
|
$sql.= ", price_min";
|
||||||
|
$sql.= ", price_min_ttc";
|
||||||
|
$sql.= ", label";
|
||||||
|
$sql.= ", fk_user_author";
|
||||||
|
$sql.= ", fk_product_type";
|
||||||
|
$sql.= ", price";
|
||||||
|
$sql.= ", price_ttc";
|
||||||
|
$sql.= ", price_base_type";
|
||||||
|
$sql.= ", canvas";
|
||||||
|
$sql.= ", finished";
|
||||||
|
$sql.= ", hidden";
|
||||||
|
$sql.= ") VALUES (";
|
||||||
|
$sql.= $this->db->idate(mktime());
|
||||||
|
$sql.= ", ".$conf->entity;
|
||||||
|
$sql.= ", '".$this->ref."'";
|
||||||
|
$sql.= ", ".price2num($price_min_ht);
|
||||||
|
$sql.= ", ".price2num($price_min_ttc);
|
||||||
|
$sql.= ", ".($this->libelle?"'".$this->db->escape($this->libelle)."'":"null");
|
||||||
|
$sql.= ", ".$user->id;
|
||||||
|
$sql.= ", ".$this->type;
|
||||||
|
$sql.= ", ".price2num($price_ht);
|
||||||
|
$sql.= ", ".price2num($price_ttc);
|
||||||
|
$sql.= ", '".$this->price_base_type."'";
|
||||||
|
$sql.= ", '".$this->canvas."'";
|
||||||
|
$sql.= ", ".$this->finished;
|
||||||
|
$sql.= ", ".$this->hidden;
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
if ($id > 0)
|
dol_syslog("Product::Create sql=".$sql);
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ( $result )
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."product");
|
||||||
$this->price = $price_ht;
|
|
||||||
$this->price_ttc = $price_ttc;
|
|
||||||
$this->price_min = $price_min_ht;
|
|
||||||
$this->price_min_ttc = $price_min_ttc;
|
|
||||||
|
|
||||||
$result = $this->_log_price($user);
|
if ($id > 0)
|
||||||
if ($result > 0)
|
|
||||||
{
|
{
|
||||||
if ( $this->update($id, $user) > 0)
|
$this->id = $id;
|
||||||
|
$this->price = $price_ht;
|
||||||
|
$this->price_ttc = $price_ttc;
|
||||||
|
$this->price_min = $price_min_ht;
|
||||||
|
$this->price_min_ttc = $price_min_ttc;
|
||||||
|
|
||||||
|
$result = $this->_log_price($user);
|
||||||
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
if ($this->catid > 0)
|
if ( $this->update($id, $user) > 0)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/categories/class/categorie.class.php");
|
if ($this->catid > 0)
|
||||||
$cat = new Categorie($this->db, $this->catid);
|
{
|
||||||
$cat->add_type($this,"product");
|
require_once(DOL_DOCUMENT_ROOT ."/categories/class/categorie.class.php");
|
||||||
|
$cat = new Categorie($this->db, $this->catid);
|
||||||
|
$cat->add_type($this,"product");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_setErrNo("Create",260,$this->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$this->error=$this->db->error();
|
||||||
$this->error='ErrorFailedToUpdateRecord';
|
$this->_setErrNo("Create",264,$this->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$this->_setErrNo("Create",259);
|
||||||
$this->error=$this->db->lasterror();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$this->error=$this->db->error();
|
||||||
$this->error='ErrorFailedToGetInsertedId';
|
$this->_setErrNo("Create",258,$this->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
// Le produit existe deja
|
||||||
$this->error=$this->db->lasterror();
|
$this->error='ErrorProductAlreadyExists';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Product already exists with this ref
|
$this->_setErrNo("Create",263);
|
||||||
$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* END COMMIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($this->errno === 0)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('PRODUCT_CREATE',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$this->_setErrNo("Create",262);
|
||||||
$this->error=$this->db->lasterror();
|
|
||||||
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error && ! $notrigger)
|
return -1;
|
||||||
{
|
|
||||||
// Appel des triggers
|
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
|
||||||
$interface=new Interfaces($this->db);
|
|
||||||
$result=$interface->run_triggers('PRODUCT_CREATE',$this,$user,$langs,$conf);
|
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// Fin appel triggers
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
$this->db->commit();
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
return -$error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Positionne le numero d'erreur
|
||||||
|
* @param func Nom de la fonction
|
||||||
|
* @param num Numero de l'erreur
|
||||||
|
* @param error string
|
||||||
|
*/
|
||||||
|
function _setErrNo($func, $num, $error='')
|
||||||
|
{
|
||||||
|
$this->errno = $num;
|
||||||
|
dol_syslog(get_class($this)."::".$func." - ERRNO(".$this->errno.")".($error?' - '.$error:''), LOG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne le texte de l'erreur
|
||||||
|
*/
|
||||||
|
function error()
|
||||||
|
{
|
||||||
|
$errs[257] = "ErrorProductAlreadyExists";
|
||||||
|
$errs[262] = "ErrorProductBadRefOrLabel";
|
||||||
|
|
||||||
|
return $errs[$this->errno];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a record into database
|
* Update a record into database
|
||||||
* @param id Id of product
|
* @param id Id of product
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user