task #10501: Can use point of sale with different bank accounts

This commit is contained in:
Juanjo Menent 2011-07-29 10:49:58 +00:00
parent 9a07e42f59
commit 3279c3a4bf
14 changed files with 157 additions and 153 deletions

View File

@ -65,7 +65,7 @@ print '<div class="menu_bloc">';
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_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 $langs->trans("CashDeskThirdParty").': '.$companyLink.'<br>';

View File

@ -14,8 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require('../main.inc.php');

View File

@ -15,15 +15,14 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/bank/bankid_fr.php
* \ingroup banque
* \brief Fiche creation compte bancaire
* \version $Id: bankid_fr.php,v 1.27 2011/07/29 20:47:35 eldy Exp $
* \version $Id: bankid_fr.php,v 1.28 2011/07/31 22:23:20 eldy Exp $
*/
require("./pre.inc.php");
@ -386,5 +385,5 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
$db->close();
llxFooter('$Date: 2011/07/29 20:47:35 $ - $Revision: 1.27 $');
llxFooter('$Date: 2011/07/31 22:23:20 $ - $Revision: 1.28 $');
?>

View File

@ -15,15 +15,14 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/bank/fiche.php
* \ingroup banque
* \brief Page to create/view a bank account
* \version $Id: fiche.php,v 1.77 2011/07/29 20:47:35 eldy Exp $
* \version $Id: fiche.php,v 1.78 2011/07/31 22:23:16 eldy Exp $
*/
require("./pre.inc.php");
@ -608,5 +607,5 @@ else
$db->close();
llxFooter('$Date: 2011/07/29 20:47:35 $ - $Revision: 1.77 $');
llxFooter('$Date: 2011/07/31 22:23:16 $ - $Revision: 1.78 $');
?>

View File

@ -1,5 +1,5 @@
--
-- $Id: 3.0.0-3.1.0.sql,v 1.84 2011/07/29 19:59:10 eldy Exp $
-- $Id: 3.0.0-3.1.0.sql,v 1.83 2011/07/28 22:22:32 eldy Exp $
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
@ -131,9 +131,6 @@ ALTER TABLE llx_usergroup_user ADD CONSTRAINT fk_usergroup_user_fk_user FOR
-- V4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
ALTER TABLE llx_usergroup_user ADD CONSTRAINT fk_usergroup_user_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);
-- V4.1 DELETE FROM llx_product_fournisseur where fk_product NOT IN (SELECT rowid from llx_product);
ALTER TABLE llx_product_fournisseur ADD CONSTRAINT fk_product_fournisseur_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_commande ADD COLUMN ref_int varchar(30) AFTER ref_ext;
ALTER TABLE llx_facture ADD COLUMN ref_int varchar(30) AFTER ref_ext;
ALTER TABLE llx_societe ADD COLUMN ref_int varchar(60) AFTER ref_ext;
@ -483,4 +480,3 @@ ALTER TABLE llx_don ADD phone_mobile varchar(24) after email;
ALTER TABLE llx_don ADD phone varchar(24) after email;
ALTER TABLE llx_user ADD civilite varchar(6) after entity;

View File

@ -1,6 +1,6 @@
-- ============================================================================
-- Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
--
-- This program is free software; you can redistribute it and/or modify
@ -17,7 +17,7 @@
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id: llx_product_fournisseur.key.sql,v 1.3 2011/07/29 19:59:33 eldy Exp $
-- $Id: llx_product_fournisseur.key.sql,v 1.2 2011/07/29 06:58:52 tiaris Exp $
-- ============================================================================
@ -26,4 +26,4 @@ ALTER TABLE llx_product_fournisseur ADD UNIQUE INDEX uk_product_fournisseur_ref
ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_product (fk_product, entity);
ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_soc (fk_soc, entity);
ALTER TABLE llx_product_fournisseur ADD CONSTRAINT fk_product_fournisseur_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_product_fournisseur ADD CONSTRAINT fk_product_fournisseur_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);

View File

@ -32,6 +32,4 @@ NoVAT=Sense IVA per aquesta venda
Change=Canvi
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
BankToPay=Compte de cobrament
ShowCompany=Veure empresa
ShowStock=Veure magatzem
BankToPay=Compte de cobrament

View File

@ -32,6 +32,4 @@ NoVAT=No VAT for this sale
Change=Excess received
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
BankToPay=Charge Account
ShowCompany=Show company
ShowStock=Show warehouse
BankToPay=Charge Account

View File

@ -32,6 +32,4 @@ NoVAT=Sin IVA en esta venta
Change=Cambio
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
BankToPay=Cuenta de cobro
ShowCompany=Ver empresa
ShowStock=Ver almacén
BankToPay=Cuenta de cobro

View File

@ -32,6 +32,4 @@ NoVAT=Pas de TVA pour cette vente
Change=Rendu
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.
BankToPay=Compte à créditer
ShowCompany=Voir société
ShowStock=Voir entrepôt
BankToPay=Compte à créditer

View File

@ -25,7 +25,7 @@
* \file htdocs/product/class/product.class.php
* \ingroup produit
* \brief Fichier de la classe des produits predefinis
* \version $Id: product.class.php,v 1.47 2011/07/29 20:47:35 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");
@ -191,15 +191,14 @@ class Product extends CommonObject
/**
* Insert product into database
* @param user User making insert
* @param notrigger Disable triggers
* @return int Id of product/service if OK or number of error < 0
* @param user User making insert
* @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
$this->ref = dol_string_nospecial(trim($this->ref));
@ -251,149 +250,172 @@ class Product extends CommonObject
$this->error='ErrorWrongParameters';
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);
$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)
if ($this->ref)
{
$obj = $this->db->fetch_object($result);
if ($obj->nb == 0)
$this->db->begin();
$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
$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.= ", 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 )
$row = $this->db->fetch_array($result);
if ($row[0] == 0)
{
$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;
$this->price = $price_ht;
$this->price_ttc = $price_ttc;
$this->price_min = $price_min_ht;
$this->price_min_ttc = $price_min_ttc;
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."product");
$result = $this->_log_price($user);
if ($result > 0)
if ($id > 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");
$cat = new Categorie($this->db, $this->catid);
$cat->add_type($this,"product");
if ($this->catid > 0)
{
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
{
$error++;
$this->error='ErrorFailedToUpdateRecord';
$this->error=$this->db->error();
$this->_setErrNo("Create",264,$this->error);
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
$this->_setErrNo("Create",259);
}
}
else
{
$error++;
$this->error='ErrorFailedToGetInsertedId';
$this->error=$this->db->error();
$this->_setErrNo("Create",258,$this->error);
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
// Le produit existe deja
$this->error='ErrorProductAlreadyExists';
}
}
else
{
// Product already exists with this ref
$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
$this->_setErrNo("Create",263);
}
/*
* 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
{
$error++;
$this->error=$this->db->lasterror();
$this->_setErrNo("Create",262);
return -2;
}
if (! $error && ! $notrigger)
{
// 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;
}
return -1;
}
/**
* 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
* @param id Id of product
@ -2139,7 +2161,7 @@ class Product extends CommonObject
$prods[$this->db->escape($rec['label'])][$keyChild] = $valueChild;
}
}
return $prods;
}
else

View File

@ -18,15 +18,14 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/product/fiche.php
* \ingroup product
* \brief Page to show product
* \version $Id: fiche.php,v 1.373 2011/07/29 20:47:35 eldy Exp $
* \version $Id: fiche.php,v 1.374 2011/07/31 23:19:26 eldy Exp $
*/
require("../main.inc.php");
@ -1646,6 +1645,6 @@ if ($product->id && $action == '' && $product->status)
$db->close();
llxFooter('$Date: 2011/07/29 20:47:35 $ - $Revision: 1.373 $');
llxFooter('$Date: 2011/07/31 23:19:26 $ - $Revision: 1.374 $');
?>

View File

@ -13,15 +13,14 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* \files htdocs/societe/class/companybankaccount.class.php
* \ingroup societe
* \brief File of class to manage bank accounts description of third parties
* \version $Id: companybankaccount.class.php,v 1.10 2011/07/29 20:47:35 eldy Exp $
* \version $Id: companybankaccount.class.php,v 1.11 2011/07/31 23:22:58 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/compta/bank/class/account.class.php");

View File

@ -15,15 +15,14 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/societe/rib.php
* \ingroup societe
* \brief BAN tab for companies
* \version $Id: rib.php,v 1.36 2011/07/29 20:47:34 eldy Exp $
* \version $Id: rib.php,v 1.37 2011/07/31 23:22:56 eldy Exp $
*/
require("../main.inc.php");
@ -272,5 +271,5 @@ if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer
$db->close();
llxFooter('$Date: 2011/07/29 20:47:34 $ - $Revision: 1.36 $');
llxFooter('$Date: 2011/07/31 23:22:56 $ - $Revision: 1.37 $');
?>