From 67342486a65179f0585c0908d2fa9c7534731093 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 15 Mar 2014 02:18:39 +0100 Subject: [PATCH 01/16] Task 1074 : add link to source document on stock movement --- htdocs/commande/class/commande.class.php | 1 + htdocs/compta/facture/class/facture.class.php | 3 ++ htdocs/expedition/class/expedition.class.php | 2 + .../class/fournisseur.commande.class.php | 2 + .../fourn/class/fournisseur.facture.class.php | 1 + .../install/mysql/migration/3.5.0-3.6.0.sql | 6 ++- .../stock/class/mouvementstock.class.php | 46 ++++++++++++++++++- htdocs/product/stock/mouvement.php | 14 +++++- 8 files changed, 71 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5566ce4d90d..814c58b92f3 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -253,6 +253,7 @@ class Commande extends CommonOrder if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We decrement stock of product (and sub-products) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr",$num)); if ($result < 0) { $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ec86fbcbaec..07470503ec2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1329,6 +1329,7 @@ class Facture extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We decrease stock for product if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value @@ -1794,6 +1795,7 @@ class Facture extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We decrease stock for product if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); @@ -1916,6 +1918,7 @@ class Facture extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We decrease stock for product if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr",$this->ref)); // we use 0 for price, to not change the weighted average value diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 914ec871951..c7d3843dd0f 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -580,6 +580,7 @@ class Expedition extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); + $mouvS->origin = &$this; // We decrement stock of product (and sub-products) // We use warehouse selected for each line $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); @@ -902,6 +903,7 @@ class Expedition extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); + $mouvS->origin = &$this; // We decrement stock of product (and sub-products) // We use warehouse selected for each line $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ed9cd323597..ecf163da81d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -635,6 +635,7 @@ class CommandeFournisseur extends CommonOrder if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We decrement stock of product (and sub-products) $up_ht_disc=$this->lines[$i]->subprice; if (! empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc=price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); @@ -1288,6 +1289,7 @@ class CommandeFournisseur extends CommonOrder if ($product > 0) { // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) + $mouv->origin = &$this; $result=$mouv->reception($user, $product, $entrepot, $qty, $price, $comment); if ($result < 0) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index cefceac2047..7e7cc14a92c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -906,6 +906,7 @@ class FactureFournisseur extends CommonInvoice if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We increase stock for product $up_ht_disc=$this->lines[$i]->pu_ht; if (! empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc=price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index eef2d5eedce..0fb148e0f40 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -1060,4 +1060,8 @@ CREATE TABLE llx_payment_salary ( fk_bank integer, fk_user_creat integer, fk_user_modif integer -)ENGINE=innodb; \ No newline at end of file +)ENGINE=innodb; + +--New 1074 : Stock mouvement link to origin +ALTER TABLE llx_stock_mouvement ADD fk_origin INT NOT NULL ; +ALTER TABLE llx_stock_mouvement ADD origintype VARCHAR( 32 ) NOT NULL ; \ No newline at end of file diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 143b9a8466c..3c398018805 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -94,12 +94,23 @@ class MouvementStock if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after { + if(!empty($this->origin)) { + $origintype = $this->origin->element; + $fk_origin = $this->origin->id; + } else { + $origintype = ''; + $fk_origin = 0; + } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement"; - $sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, label, price)"; + $sql.= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, label, price, fk_origin, origintype)"; $sql.= " VALUES ('".$this->db->idate($now)."', ".$fk_product.", ".$entrepot_id.", ".$qty.", ".$type.","; $sql.= " ".$user->id.","; $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".price2num($price)."')"; + $sql.= " '".price2num($price)."',"; + $sql.= " '".$fk_origin."',"; + $sql.= " '".$origintype."'"; + $sql.= ")"; dol_syslog(get_class($this)."::_create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -469,5 +480,36 @@ class MouvementStock } + function get_origin($fk_origin, $origintype) { + switch ($origintype) { + case 'commande': + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $origin = new Commande($this->db); + break; + case 'shipping': + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $origin = new Expedition($this->db); + break; + case 'facture': + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $origin = new Facture($this->db); + break; + case 'order_supplier': + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $origin = new CommandeFournisseur($this->db); + break; + case 'invoice_supplier': + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $origin = new FactureFournisseur($this->db); + break; + + default: + return ''; + break; + } + + $origin->fetch($fk_origin); + return $origin->getNomUrl(1); + } } ?> diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 5b7b56d6720..ee3f0b65639 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -120,7 +120,7 @@ $formproduct=new FormProduct($db); $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type,"; $sql.= " e.label as stock, e.rowid as entrepot_id,"; -$sql.= " m.rowid as mid, m.value, m.datem, m.fk_user_author, m.label,"; +$sql.= " m.rowid as mid, m.value, m.datem, m.fk_user_author, m.label, m.fk_origin, m.origintype,"; $sql.= " u.login"; $sql.= " FROM (".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product as p,"; @@ -418,6 +418,7 @@ if ($resql) //print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"], "m.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"], "m.datem","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("LabelMovement"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ProductRef"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ProductLabel"),$_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible @@ -440,6 +441,10 @@ if ($resql) print ''; print ''; print ''; + // Origin of movement + print ''; + print '  '; + print ''; // Product Ref print ''; print ''; @@ -470,6 +475,11 @@ if ($resql) $objp = $db->fetch_object($resql); $arrayofuniqueproduct[$objp->rowid]=$objp->produit; + if(!empty($objp->fk_origin)) { + $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); + } else { + $origin = ''; + } $var=!$var; print ""; @@ -479,6 +489,8 @@ if ($resql) print ''.dol_print_date($db->jdate($objp->datem),'dayhour').''; // Label of movement print ''.$objp->label.''; + // Origin of movement + print ''.$origin.''; // Product ref print ''; $productstatic->id=$objp->rowid; From eb86abff94406ec08766462f57ba2209341d2876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 05:47:17 +0100 Subject: [PATCH 02/16] Database: factorized jdate() --- htdocs/core/db/DoliDB.class.php | 19 +++++++++++++++++-- htdocs/core/db/mssql.class.php | 17 ----------------- htdocs/core/db/mysql.class.php | 17 ----------------- htdocs/core/db/mysqli.class.php | 17 ----------------- htdocs/core/db/pgsql.class.php | 17 ----------------- htdocs/core/db/sqlite.class.php | 18 ------------------ 6 files changed, 17 insertions(+), 88 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 6f5a75b35ab..7d6afd22457 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -64,8 +64,6 @@ abstract class DoliDB implements Database public $ok; public $error; - - /** * Define sort criteria of request * @@ -94,5 +92,22 @@ abstract class DoliDB implements Database return ''; } } + + /** + * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) + * 19700101020000 -> 3600 with TZ+1 and gmt=0 + * 19700101020000 -> 7200 whaterver is TZ if gmt=1 + * + * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) + * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ + * @return date Date TMS + */ + function jdate($string, $gm=false) + { + $string=preg_replace('/([^0-9])/i','',$string); + $tmp=$string.'000000'; + $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); + return $date; + } } diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 0e1b1a2ca0c..ae8e6ea5ce6 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -553,23 +553,6 @@ class DoliDBMssql extends DoliDB return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 46b16113a26..bd6c2794b17 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -531,23 +531,6 @@ class DoliDBMysql extends DoliDB return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index ece1ff86532..f530656cc7f 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -541,23 +541,6 @@ class DoliDBMysqli extends DoliDB return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index aa31f5616c8..7b2961e623c 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -752,23 +752,6 @@ class DoliDBPgsql extends DoliDB return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 36f583011e4..67dc9593042 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -674,24 +674,6 @@ class DoliDBSqlite extends DoliDB return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - - /** * Format a SQL IF * From 64fbefdb7cb6df9fcebcf0ea46fc83575c8524a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 05:54:13 +0100 Subject: [PATCH 03/16] Database: factorized ifsql() --- htdocs/core/db/DoliDB.class.php | 13 +++++++++++++ htdocs/core/db/mssql.class.php | 14 -------------- htdocs/core/db/mysql.class.php | 14 -------------- htdocs/core/db/mysqli.class.php | 13 ------------- htdocs/core/db/sqlite.class.php | 14 -------------- 5 files changed, 13 insertions(+), 55 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 7d6afd22457..c7e08e69a6e 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -64,6 +64,19 @@ abstract class DoliDB implements Database public $ok; public $error; + /** + * Format a SQL IF + * + * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL') + * @param string $resok resultat si test egal + * @param string $resko resultat si test non egal + * @return string SQL string + */ + function ifsql($test,$resok,$resko) + { + return 'IF('.$test.','.$resok.','.$resko.')'; + } + /** * Define sort criteria of request * diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index ae8e6ea5ce6..5d3f9b449ce 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -553,20 +553,6 @@ class DoliDBMssql extends DoliDB return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); } - /** - * Format a SQL IF - * - * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL') - * @param string $resok resultat si test egal - * @param string $resko resultat si test non egal - * @return string SQL string - */ - function ifsql($test,$resok,$resko) - { - return 'IF('.$test.','.$resok.','.$resko.')'; - } - - /** * Return last request executed with query() * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index bd6c2794b17..4ce71647c4a 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -531,20 +531,6 @@ class DoliDBMysql extends DoliDB return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Format a SQL IF - * - * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL') - * @param string $resok resultat si test egal - * @param string $resko resultat si test non egal - * @return string SQL string - */ - function ifsql($test,$resok,$resko) - { - return 'IF('.$test.','.$resok.','.$resko.')'; - } - - /** * Return last request executed with query() * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index f530656cc7f..4daefe3a397 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -541,19 +541,6 @@ class DoliDBMysqli extends DoliDB return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Format a SQL IF - * - * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL') - * @param string $resok resultat si test egal - * @param string $resko resultat si test non egal - * @return string SQL string - */ - function ifsql($test,$resok,$resko) - { - return 'IF('.$test.','.$resok.','.$resko.')'; - } - /** * Return last request executed with query() diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 67dc9593042..f3c52762b0a 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -674,20 +674,6 @@ class DoliDBSqlite extends DoliDB return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Format a SQL IF - * - * @param string $test Test string (example: 'cd.statut=0', 'field IS NULL') - * @param string $resok resultat si test egal - * @param string $resko resultat si test non egal - * @return string SQL string - */ - function ifsql($test,$resok,$resko) - { - return 'IF('.$test.','.$resok.','.$resko.')'; - } - - /** * Renvoie la derniere requete soumise par la methode query() * From 0ab6fcaacadce50c4bb9866beab29fb94daf730c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 06:04:16 +0100 Subject: [PATCH 04/16] Database: factorized idate() --- htdocs/core/db/DoliDB.class.php | 12 ++++++++++++ htdocs/core/db/mysql.class.php | 13 ------------- htdocs/core/db/mysqli.class.php | 13 ------------- htdocs/core/db/sqlite.class.php | 12 ------------ 4 files changed, 12 insertions(+), 38 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index c7e08e69a6e..0caba62bf2d 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -77,6 +77,18 @@ abstract class DoliDB implements Database return 'IF('.$test.','.$resok.','.$resko.')'; } + /** + * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. + * Function to use to build INSERT, UPDATE or WHERE predica + * + * @param string $param Date TMS to convert + * @return string Date in a string YYYYMMDDHHMMSS + */ + function idate($param) + { + return dol_print_date($param,"%Y%m%d%H%M%S"); + } + /** * Define sort criteria of request * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 4ce71647c4a..d1d86711513 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -518,19 +518,6 @@ class DoliDBMysql extends DoliDB return addslashes($stringtoencode); } - - /** - * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. - * Function to use to build INSERT, UPDATE or WHERE predica - * - * @param string $param Date TMS to convert - * @return string Date in a string YYYYMMDDHHMMSS - */ - function idate($param) - { - return dol_print_date($param,"%Y%m%d%H%M%S"); - } - /** * Return last request executed with query() * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 4daefe3a397..f4d8d6f6a44 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -529,19 +529,6 @@ class DoliDBMysqli extends DoliDB return addslashes($stringtoencode); } - /** - * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. - * Function to use to build INSERT, UPDATE or WHERE predica - * - * @param string $param Date TMS to convert - * @return string Date in a string YYYYMMDDHHMMSS - */ - function idate($param) - { - return dol_print_date($param,"%Y%m%d%H%M%S"); - } - - /** * Return last request executed with query() * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index f3c52762b0a..4695bb15807 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -662,18 +662,6 @@ class DoliDBSqlite extends DoliDB return $this->db->quote($stringtoencode); } - /** - * Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field. - * Function to use to build INSERT, UPDATE or WHERE predica - * - * @param string $param Date TMS to convert - * @return string Date in a string YYYYMMDDHHMMSS - */ - function idate($param) - { - return dol_print_date($param,"%Y%m%d%H%M%S"); - } - /** * Renvoie la derniere requete soumise par la methode query() * From 739a5661563725cb7eaae3b7d75c0b3b3438c819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 06:07:46 +0100 Subject: [PATCH 05/16] Database: factorized lasterrno() --- htdocs/core/db/DoliDB.class.php | 10 ++++++++++ htdocs/core/db/mssql.class.php | 10 ---------- htdocs/core/db/mysql.class.php | 10 ---------- htdocs/core/db/mysqli.class.php | 10 ---------- htdocs/core/db/pgsql.class.php | 10 ---------- htdocs/core/db/sqlite.class.php | 10 ---------- 6 files changed, 10 insertions(+), 50 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 0caba62bf2d..a246bb6f15c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -89,6 +89,16 @@ abstract class DoliDB implements Database return dol_print_date($param,"%Y%m%d%H%M%S"); } + /** + * Return last error code + * + * @return string lasterrno + */ + function lasterrno() + { + return $this->lasterrno; + } + /** * Define sort criteria of request * diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 5d3f9b449ce..6f215e9d6f0 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -583,16 +583,6 @@ class DoliDBMssql extends DoliDB return $this->lasterror; } - /** - * Return last error code - * - * @return string lasterrno - */ - function lasterrno() - { - return $this->lasterrno; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index d1d86711513..7ebb8f84c16 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -548,16 +548,6 @@ class DoliDBMysql extends DoliDB return $this->lasterror; } - /** - * Return last error code - * - * @return string lasterrno - */ - function lasterrno() - { - return $this->lasterrno; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index f4d8d6f6a44..f7bb2c3515b 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -559,16 +559,6 @@ class DoliDBMysqli extends DoliDB return $this->lasterror; } - /** - * Renvoie le code derniere erreur - * - * @return string lasterrno - */ - function lasterrno() - { - return $this->lasterrno; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 7b2961e623c..5ee421b9a50 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -796,16 +796,6 @@ class DoliDBPgsql extends DoliDB return $this->lasterror; } - /** - * Renvoie le code derniere erreur - * - * @return string lasterrno - */ - function lasterrno() - { - return $this->lasterrno; - } - /** * Renvoie le code erreur generique de l'operation precedente. * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 4695bb15807..aae07cce299 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -692,16 +692,6 @@ class DoliDBSqlite extends DoliDB return $this->lasterror; } - /** - * Return last error code - * - * @return string lasterrno - */ - function lasterrno() - { - return $this->lasterrno; - } - /** * Renvoie le code erreur generique de l'operation precedente. * From f91e2ec7b2e6f712c265b4bea05ef1a95b162ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 06:17:12 +0100 Subject: [PATCH 06/16] Database: factorized begin() --- htdocs/core/db/DoliDB.class.php | 26 ++++++++++++++++++++++++++ htdocs/core/db/mysql.class.php | 27 --------------------------- htdocs/core/db/mysqli.class.php | 27 --------------------------- htdocs/core/db/sqlite.class.php | 27 --------------------------- 4 files changed, 26 insertions(+), 81 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index a246bb6f15c..054e2d8f0bc 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -99,6 +99,32 @@ abstract class DoliDB implements Database return $this->lasterrno; } + /** + * Start transaction + * + * @return int 1 if transaction successfuly opened or already opened, 0 if error + */ + function begin() + { + if (! $this->transaction_opened) + { + $ret=$this->query("BEGIN"); + if ($ret) + { + $this->transaction_opened++; + dol_syslog("BEGIN Transaction",LOG_DEBUG); + dol_syslog('',0,1); + } + return $ret; + } + else + { + $this->transaction_opened++; + dol_syslog('',0,1); + return 1; + } + } + /** * Define sort criteria of request * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 7ebb8f84c16..fc6a59726cb 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -287,33 +287,6 @@ class DoliDBMysql extends DoliDB return false; } - - /** - * Start transaction - * - * @return int 1 if transaction successfuly opened or already opened, 0 if error - */ - function begin() - { - if (! $this->transaction_opened) - { - $ret=$this->query("BEGIN"); - if ($ret) - { - $this->transaction_opened++; - dol_syslog("BEGIN Transaction",LOG_DEBUG); - dol_syslog('',0,1); - } - return $ret; - } - else - { - $this->transaction_opened++; - dol_syslog('',0,1); - return 1; - } - } - /** * Validate a database transaction * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index f7bb2c3515b..a8545532aba 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -291,33 +291,6 @@ class DoliDBMysqli extends DoliDB return false; } - - /** - * Start transaction - * - * @return int 1 if transaction successfuly opened or already opened, 0 if error - */ - function begin() - { - if (! $this->transaction_opened) - { - $ret=$this->query("BEGIN"); - if ($ret) - { - $this->transaction_opened++; - dol_syslog("BEGIN Transaction",LOG_DEBUG); - dol_syslog('',0,1); - } - return $ret; - } - else - { - $this->transaction_opened++; - dol_syslog('',0,1); - return 1; - } - } - /** * Validate a database transaction * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index aae07cce299..0bcc3308c1d 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -415,33 +415,6 @@ class DoliDBSqlite extends DoliDB return false; } - - /** - * Start transaction - * - * @return int 1 if transaction successfuly opened or already opened, 0 if error - */ - function begin() - { - if (! $this->transaction_opened) - { - $ret=$this->query("BEGIN"); - if ($ret) - { - $this->transaction_opened++; - dol_syslog("BEGIN Transaction",LOG_DEBUG); - dol_syslog('',0,1); - } - return $ret; - } - else - { - $this->transaction_opened++; - dol_syslog('',0,1); - return 1; - } - } - /** * Validate a database transaction * From 73d957f15881607cd208251a3851b74ab1329316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 06:31:38 +0100 Subject: [PATCH 07/16] Database: factorized common properties --- htdocs/core/db/DoliDB.class.php | 4 ++-- htdocs/core/db/mssql.class.php | 26 +------------------------- htdocs/core/db/mysql.class.php | 30 +----------------------------- htdocs/core/db/mysqli.class.php | 30 +----------------------------- htdocs/core/db/pgsql.class.php | 24 +----------------------- htdocs/core/db/sqlite.class.php | 30 +----------------------------- 6 files changed, 7 insertions(+), 137 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 054e2d8f0bc..2da6ad6cdda 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -35,9 +35,9 @@ abstract class DoliDB implements Database //! Database label static $label; //! Charset used to force charset when creating database - public $forcecharset; + public $forcecharset='utf8'; //! Collate used to force collate when creating database - public $forcecollate; + public $forcecollate='utf8_general_ci'; //! Min database version static $versionmin; //! Resultset of last query diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 6f215e9d6f0..2b7f28a7b60 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -30,8 +30,6 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; */ class DoliDBMssql extends DoliDB { - //! Database handler - var $db; //! Database type public $type='mssql'; //! Database label @@ -42,30 +40,8 @@ class DoliDBMssql extends DoliDB var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value //! Version min database static $versionmin=array(2000); - //! Resultset of last request + //! Resultset of last query private $_results; - //! 1 si connecte, 0 sinon - var $connected; - //! 1 si base selectionne, 0 sinon - var $database_selected; - //! Nom base selectionnee - var $database_name; - //! Nom user base - var $database_user; - //! >=1 if a transaction is opened, 0 otherwise - var $transaction_opened; - //! Derniere requete executee - var $lastquery; - //! Derniere requete executee avec echec - var $lastqueryerror; - //! Message erreur mysql - var $lasterror; - //! Message erreur mysql - var $lasterrno; - - var $ok; - var $error; - /** * Constructor. diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index fc6a59726cb..9bea3e609d2 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -31,42 +31,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; */ class DoliDBMysql extends DoliDB { - //! Database handler - var $db; //! Database type public $type='mysql'; //! Database label static $label='MySQL'; - //! Charset used to force charset when creating database - var $forcecharset='utf8'; // latin1, utf8. Can't be static as it may be forced with a dynamic value - //! Collate used to force collate when creating database - var $forcecollate='utf8_general_ci'; // latin1_swedish_ci, utf8_general_ci. Can't be static as it may be forced with a dynamic value //! Version min database static $versionmin=array(4,1,0); - //! Resultset of last request + //! Resultset of last query private $_results; - //! 1 if connected, 0 else - var $connected; - //! 1 if database selected, 0 else - var $database_selected; - //! Database name selected - var $database_name; - //! Nom user base - var $database_user; - //! >=1 if a transaction is opened, 0 otherwise - var $transaction_opened; - //! Last executed request - var $lastquery; - //! Last failed executed request - var $lastqueryerror; - //! Message erreur mysql - var $lasterror; - //! Message erreur mysql - var $lasterrno; - - var $ok; - var $error; - /** * Constructor. diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index a8545532aba..73525be4d5b 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -31,42 +31,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; */ class DoliDBMysqli extends DoliDB { - //! Database handler - var $db; //! Database type public $type='mysqli'; //! Database label static $label='MySQL'; - //! Charset used to force charset when creating database - var $forcecharset='utf8'; // latin1, utf8. Can't be static as it may be forced with a dynamic value - //! Collate used to force collate when creating database - var $forcecollate='utf8_general_ci'; // latin1_swedish_ci, utf8_general_ci. Can't be static as it may be forced with a dynamic value //! Version min database static $versionmin=array(4,1,0); - //! Resultset of last request + //! Resultset of last query private $_results; - //! 1 if connected, 0 else - var $connected; - //! 1 if database selected, 0 else - var $database_selected; - //! Database name selected - var $database_name; - //! Nom user base - var $database_user; - //! >=1 if a transaction is opened, 0 otherwise - var $transaction_opened; - //! Last executed request - var $lastquery; - //! Last failed executed request - var $lastqueryerror; - //! Message erreur mysql - var $lasterror; - //! Message erreur mysql - var $lasterrno; - - var $ok; - var $error; - /** * Constructor. diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 5ee421b9a50..44e8b3dc274 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -34,8 +34,6 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; */ class DoliDBPgsql extends DoliDB { - //! Database handler - var $db; //! Database type public $type='pgsql'; // Name of manager //! Database label @@ -46,29 +44,9 @@ class DoliDBPgsql extends DoliDB var $forcecollate=''; // Can't be static as it may be forced with a dynamic value //! Version min database static $versionmin=array(8,4,0); // Version min database - - //! Resultset of last request + //! Resultset of last query private $_results; - var $connected; // 1 si connecte, 0 sinon - var $database_selected; // 1 si base selectionne, 0 sinon - var $database_name; //! Nom base selectionnee - var $database_user; //! Nom user base - //! >=1 if a transaction is opened, 0 otherwise - var $transaction_opened; - var $lastquery; - // Saved last error - var $lastqueryerror; - var $lasterror; - var $lasterrno; - - var $unescapeslashquot=0; // By default we do not force the unescape of \'. This is used only to process sql with mysql escaped data. - var $standard_conforming_strings=1; // Database has option standard_conforming_strings to on - - var $ok; - var $error; - - /** * Constructor. * This create an opened connexion to a database server and eventually to a database diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 0bcc3308c1d..ab6582affc5 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -31,42 +31,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; */ class DoliDBSqlite extends DoliDB { - //! Database handler - var $db; //! Database type public $type='sqlite'; //! Database label static $label='PDO Sqlite'; - //! Charset used to force charset when creating database - var $forcecharset='utf8'; // latin1, utf8. Can't be static as it may be forced with a dynamic value - //! Collate used to force collate when creating database - var $forcecollate='utf8_general_ci'; // latin1_swedish_ci, utf8_general_ci. Can't be static as it may be forced with a dynamic value //! Version min database static $versionmin=array(3,0,0); - //! Resultset of last request + //! Resultset of last query private $_results; - //! 1 if connected, 0 else - var $connected; - //! 1 if database selected, 0 else - var $database_selected; - //! Database name selected - var $database_name; - //! Nom user base - var $database_user; - //! >=1 if a transaction is opened, 0 otherwise - var $transaction_opened; - //! Last executed request - var $lastquery; - //! Last failed executed request - var $lastqueryerror; - //! Message erreur mysql - var $lasterror; - //! Message erreur mysql - var $lasterrno; - - var $ok; - var $error; - /** * Constructor. From 3f6b175879dee3dff45556d58d61a96730ca6dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 06:40:13 +0100 Subject: [PATCH 08/16] Database: factorized getVersionArray() --- htdocs/core/db/DoliDB.class.php | 10 ++++++++++ htdocs/core/db/mssql.class.php | 11 ----------- htdocs/core/db/mysql.class.php | 10 ---------- htdocs/core/db/mysqli.class.php | 10 ---------- htdocs/core/db/pgsql.class.php | 10 ---------- htdocs/core/db/sqlite.class.php | 10 ---------- 6 files changed, 10 insertions(+), 51 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 2da6ad6cdda..5fae6dab374 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -125,6 +125,16 @@ abstract class DoliDB implements Database } } + /** + * Return version of database server into an array + * + * @return array Version array + */ + function getVersionArray() + { + return explode('.',$this->getVersion()); + } + /** * Define sort criteria of request * diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 2b7f28a7b60..7459b4c0019 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -195,17 +195,6 @@ class DoliDBMssql extends DoliDB return $version['computed']; } - - /** - * Return version of database server into an array - * - * @return array Version array - */ - function getVersionArray() - { - return explode('.',$this->getVersion()); - } - /** * Return version of database client driver * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 9bea3e609d2..2bf0474157f 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -221,16 +221,6 @@ class DoliDBMysql extends DoliDB return mysql_get_server_info($this->db); } - /** - * Return version of database server into an array - * - * @return array Version array - */ - function getVersionArray() - { - return explode('.',$this->getVersion()); - } - /** * Return version of database client driver * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 73525be4d5b..bf9808a39e2 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -225,16 +225,6 @@ class DoliDBMysqli extends DoliDB return mysqli_get_server_info($this->db); } - /** - * Return version of database server into an array - * - * @return array Version array - */ - function getVersionArray() - { - return explode('.',$this->getVersion()); - } - /** * Return version of database client driver * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 44e8b3dc274..a284756caed 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -428,16 +428,6 @@ class DoliDBPgsql extends DoliDB return ''; } - /** - * Return version of database server into an array - * - * @return array Version array - */ - function getVersionArray() - { - return explode('.',$this->getVersion()); - } - /** * Return version of database client driver * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index ab6582affc5..a631fad8220 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -345,16 +345,6 @@ class DoliDBSqlite extends DoliDB return $row[0]; } - /** - * Return version of database server into an array - * - * @return array Version array - */ - function getVersionArray() - { - return explode('.',$this->getVersion()); - } - /** * Return version of database client driver * From 32bef2bf2f121d31951a12728c5c5d5afba6de15 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 15 Mar 2014 07:01:02 +0100 Subject: [PATCH 09/16] Missing text attribute on input field --- htdocs/install/etape4.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/etape4.php b/htdocs/install/etape4.php index 1b88070e750..d8231a60501 100644 --- a/htdocs/install/etape4.php +++ b/htdocs/install/etape4.php @@ -74,7 +74,7 @@ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db- if ($db->ok == 1) { print ''.$langs->trans("DolibarrAdminLogin").' :'; - print ''; + print ''; print ''.$langs->trans("Password").' :'; print ''; print ''.$langs->trans("PasswordAgain").' :'; From e4e78bdd3e2f2ee02371efd4455b8877085bc48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 06:45:17 +0100 Subject: [PATCH 10/16] Database: factorized getLabel() --- htdocs/core/db/DoliDB.class.php | 10 ++++++++++ htdocs/core/db/mssql.class.php | 10 ---------- htdocs/core/db/mysql.class.php | 10 ---------- htdocs/core/db/mysqli.class.php | 10 ---------- htdocs/core/db/pgsql.class.php | 10 ---------- htdocs/core/db/sqlite.class.php | 9 --------- 6 files changed, 10 insertions(+), 49 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 5fae6dab374..3413e381547 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -135,6 +135,16 @@ abstract class DoliDB implements Database return explode('.',$this->getVersion()); } + /** + * Return label of manager + * + * @return string Label + */ + function getLabel() + { + return $this->label; + } + /** * Define sort criteria of request * diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 7459b4c0019..f96423b1a66 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -173,16 +173,6 @@ class DoliDBMssql extends DoliDB return $this->db; } - /** - * Return label of manager - * - * @return string Label - */ - function getLabel() - { - return $this->label; - } - /** * Return version of database server * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 2bf0474157f..4f06fb772b8 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -201,16 +201,6 @@ class DoliDBMysql extends DoliDB return $this->db; } - /** - * Return label of manager - * - * @return string Label - */ - function getLabel() - { - return $this->label; - } - /** * Return version of database server * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index bf9808a39e2..33cea437afe 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -205,16 +205,6 @@ class DoliDBMysqli extends DoliDB return $this->db; } - /** - * Return label of manager - * - * @return string Label - */ - function getLabel() - { - return $this->label; - } - /** * Return version of database server * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index a284756caed..bb14ebade32 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -402,16 +402,6 @@ class DoliDBPgsql extends DoliDB return $this->db; } - /** - * Return label of manager - * - * @return string Label - */ - function getLabel() - { - return $this->label; - } - /** * Return version of database server * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index a631fad8220..f4cf57bb9be 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -323,15 +323,6 @@ class DoliDBSqlite extends DoliDB return $this->db; } - /** - * Return label of manager - * - * @return string Label - */ - function getLabel() - { - return $this->label; - } /** * Return version of database server From f894df1d9e00fd7ec324c9c63f24f16c3151176a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 06:48:39 +0100 Subject: [PATCH 11/16] Database: factorized lastquerry() --- htdocs/core/db/DoliDB.class.php | 10 ++++++++++ htdocs/core/db/mssql.class.php | 10 ---------- htdocs/core/db/mysql.class.php | 10 ---------- htdocs/core/db/mysqli.class.php | 10 ---------- htdocs/core/db/pgsql.class.php | 11 ----------- htdocs/core/db/sqlite.class.php | 10 ---------- 6 files changed, 10 insertions(+), 51 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 3413e381547..2fcf08bd826 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -145,6 +145,16 @@ abstract class DoliDB implements Database return $this->label; } + /** + * Return last request executed with query() + * + * @return string Last query + */ + function lastquery() + { + return $this->lastquery; + } + /** * Define sort criteria of request * diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index f96423b1a66..5def132ab22 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -508,16 +508,6 @@ class DoliDBMssql extends DoliDB return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); } - /** - * Return last request executed with query() - * - * @return string Last query - */ - function lastquery() - { - return $this->lastquery; - } - /** * Return last query in error * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 4f06fb772b8..553483b3994 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -443,16 +443,6 @@ class DoliDBMysql extends DoliDB return addslashes($stringtoencode); } - /** - * Return last request executed with query() - * - * @return string Last query - */ - function lastquery() - { - return $this->lastquery; - } - /** * Return last query in error * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 33cea437afe..d53334fd1fc 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -454,16 +454,6 @@ class DoliDBMysqli extends DoliDB return addslashes($stringtoencode); } - /** - * Return last request executed with query() - * - * @return string Last query - */ - function lastquery() - { - return $this->lastquery; - } - /** * Renvoie la derniere requete en erreur * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index bb14ebade32..645b79e3c00 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -723,17 +723,6 @@ class DoliDBPgsql extends DoliDB return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } - - /** - * Renvoie la derniere requete soumise par la methode query() - * - * @return lastquery - */ - function lastquery() - { - return $this->lastquery; - } - /** * Renvoie la derniere requete en erreur * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index f4cf57bb9be..afd7ed88be8 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -588,16 +588,6 @@ class DoliDBSqlite extends DoliDB return $this->db->quote($stringtoencode); } - /** - * Renvoie la derniere requete soumise par la methode query() - * - * @return lastquery - */ - function lastquery() - { - return $this->lastquery; - } - /** * Return last query in error * From 7df97b7cfbdc3dcb4cd2110ce290744af33d30dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 07:11:45 +0100 Subject: [PATCH 12/16] Database: factorized lasterror() --- htdocs/core/db/DoliDB.class.php | 10 ++++++++++ htdocs/core/db/mssql.class.php | 10 ---------- htdocs/core/db/mysql.class.php | 10 ---------- htdocs/core/db/mysqli.class.php | 10 ---------- htdocs/core/db/pgsql.class.php | 10 ---------- htdocs/core/db/sqlite.class.php | 10 ---------- 6 files changed, 10 insertions(+), 50 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 2fcf08bd826..4b742029526 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -184,6 +184,16 @@ abstract class DoliDB implements Database } } + /** + * Return last error label + * + * @return string lasterror + */ + function lasterror() + { + return $this->lasterror; + } + /** * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) * 19700101020000 -> 3600 with TZ+1 and gmt=0 diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 5def132ab22..7d96d421183 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -518,16 +518,6 @@ class DoliDBMssql extends DoliDB return $this->lastqueryerror; } - /** - * Return last error label - * - * @return string lasterror - */ - function lasterror() - { - return $this->lasterror; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 553483b3994..733c6a32cdc 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -453,16 +453,6 @@ class DoliDBMysql extends DoliDB return $this->lastqueryerror; } - /** - * Return last error label - * - * @return string lasterror - */ - function lasterror() - { - return $this->lasterror; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index d53334fd1fc..636c0f24f02 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -464,16 +464,6 @@ class DoliDBMysqli extends DoliDB return $this->lastqueryerror; } - /** - * Renvoie le libelle derniere erreur - * - * @return string lasterror - */ - function lasterror() - { - return $this->lasterror; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 645b79e3c00..f70d4da652b 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -733,16 +733,6 @@ class DoliDBPgsql extends DoliDB return $this->lastqueryerror; } - /** - * Renvoie le libelle derniere erreur - * - * @return string lasterror - */ - function lasterror() - { - return $this->lasterror; - } - /** * Renvoie le code erreur generique de l'operation precedente. * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index afd7ed88be8..f1d2a3d6203 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -598,16 +598,6 @@ class DoliDBSqlite extends DoliDB return $this->lastqueryerror; } - /** - * Return last error label - * - * @return string lasterror - */ - function lasterror() - { - return $this->lasterror; - } - /** * Renvoie le code erreur generique de l'operation precedente. * From a23f6d6a85d6da0e0a3d507b70e342bf28e1bdfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 07:20:00 +0100 Subject: [PATCH 13/16] Database: factorized lastqueryerror() --- htdocs/core/db/DoliDB.class.php | 10 ++++++++++ htdocs/core/db/mssql.class.php | 10 ---------- htdocs/core/db/mysql.class.php | 10 ---------- htdocs/core/db/mysqli.class.php | 10 ---------- htdocs/core/db/pgsql.class.php | 10 ---------- htdocs/core/db/sqlite.class.php | 10 ---------- 6 files changed, 10 insertions(+), 50 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 4b742029526..f85aa4ca78a 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -210,5 +210,15 @@ abstract class DoliDB implements Database $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); return $date; } + + /** + * Return last query in error + * + * @return string lastqueryerror + */ + function lastqueryerror() + { + return $this->lastqueryerror; + } } diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 7d96d421183..239582a6595 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -508,16 +508,6 @@ class DoliDBMssql extends DoliDB return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); } - /** - * Return last query in error - * - * @return string lastqueryerror - */ - function lastqueryerror() - { - return $this->lastqueryerror; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 733c6a32cdc..582adbb343a 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -443,16 +443,6 @@ class DoliDBMysql extends DoliDB return addslashes($stringtoencode); } - /** - * Return last query in error - * - * @return string lastqueryerror - */ - function lastqueryerror() - { - return $this->lastqueryerror; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 636c0f24f02..66fa531bf09 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -454,16 +454,6 @@ class DoliDBMysqli extends DoliDB return addslashes($stringtoencode); } - /** - * Renvoie la derniere requete en erreur - * - * @return string lastqueryerror - */ - function lastqueryerror() - { - return $this->lastqueryerror; - } - /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index f70d4da652b..5dcc5767014 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -723,16 +723,6 @@ class DoliDBPgsql extends DoliDB return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } - /** - * Renvoie la derniere requete en erreur - * - * @return string lastqueryerror - */ - function lastqueryerror() - { - return $this->lastqueryerror; - } - /** * Renvoie le code erreur generique de l'operation precedente. * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index f1d2a3d6203..fe3ac4718a9 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -588,16 +588,6 @@ class DoliDBSqlite extends DoliDB return $this->db->quote($stringtoencode); } - /** - * Return last query in error - * - * @return string lastqueryerror - */ - function lastqueryerror() - { - return $this->lastqueryerror; - } - /** * Renvoie le code erreur generique de l'operation precedente. * From 4aa692c2a75a9b87304978cde250fed4840b12c9 Mon Sep 17 00:00:00 2001 From: jean Date: Sat, 15 Mar 2014 11:31:20 +0100 Subject: [PATCH 14/16] correction Magazin -> Magasin --- htdocs/langs/fr_FR/dict.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/dict.lang b/htdocs/langs/fr_FR/dict.lang index 3a1c7e95ea2..3dcc560d30a 100644 --- a/htdocs/langs/fr_FR/dict.lang +++ b/htdocs/langs/fr_FR/dict.lang @@ -301,7 +301,7 @@ DemandReasonTypeSRC_CAMP_EMAIL=Campagne EMailing DemandReasonTypeSRC_CAMP_PHO=Campagne Téléphonique DemandReasonTypeSRC_CAMP_FAX=Campagne Fax DemandReasonTypeSRC_COMM=Contact commercial -DemandReasonTypeSRC_SHOP=Contact en magazin +DemandReasonTypeSRC_SHOP=Contact en magasin DemandReasonTypeSRC_WOM=Bouche à oreille DemandReasonTypeSRC_PARTNER=Partenaire DemandReasonTypeSRC_EMPLOYEE=Employé From 3a21d99edf08b6d2a98f0353bbe6ab707af3a68c Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sat, 15 Mar 2014 12:01:13 +0100 Subject: [PATCH 15/16] Add feature : import line from origin invoice in the new credit note --- htdocs/compta/facture.php | 40 +++++++++++++++++++++++++++++++---- htdocs/langs/fr_FR/bills.lang | 1 + 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index d08feba9b14..4995ab7eab0 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -643,8 +643,37 @@ else if ($action == 'add' && $user->rights->facture->creer) { $id = $object->create($user); + if(GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) { + + $facture_source = new Facture($db); // fetch origin object + if($facture_source->fetch($object->fk_facture_source)>0) { + + foreach($facture_source->lines as $line) { + + $line->fk_facture = $object->id; + + $line->subprice =-$line->subprice; // invert price for object + $line->pa_ht = -$line->pa_ht; + $line->total_ht=-$line->total_ht; + $line->total_tva=-$line->total_tva; + $line->total_ttc=-$line->total_ttc; + $line->total_localtax1=-$line->total_localtax1; + $line->total_localtax2=-$line->total_localtax2; + + $line->insert(); + + $object->lines[] = $line; // insert new line in current object + } + + $object->update_price(1); + } + + } + // Add predefined lines - for($i = 1; $i <= $NBLINES; $i ++) { + /* + TODO delete + for($i = 1; $i <= $NBLINES; $i ++) { if ($_POST ['idprod' . $i]) { $product = new Product($db); $product->fetch($_POST ['idprod' . $i]); @@ -652,7 +681,7 @@ else if ($action == 'add' && $user->rights->facture->creer) { $endday = dol_mktime(12, 0, 0, $_POST ['date_end' . $i . 'month'], $_POST ['date_end' . $i . 'day'], $_POST ['date_end' . $i . 'year']); $result = $object->addline($product->description, $product->price, $_POST ['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST ['idprod' . $i], $_POST ['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); } - } + }*/ } } @@ -2000,12 +2029,12 @@ if ($action == 'create') if (empty($origin) && $socid > 0) { // Credit note - print ''; + print ''; print ''; - print ''; + print ''; print '