';
print ' '; // ancre
@@ -1865,7 +1775,7 @@ else
/*
* Show mail form
*/
- if ($_GET['action'] == 'presend')
+ if ($action == 'presend')
{
$ref = dol_sanitizeFileName($fac->ref);
$file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($fac->id,2).$ref.'.pdf';
diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php
index c03e72e44b7..56692542365 100644
--- a/htdocs/fourn/paiement/fiche.php
+++ b/htdocs/fourn/paiement/fiche.php
@@ -35,18 +35,38 @@ $langs->load('companies');
$langs->load("suppliers");
$mesg='';
+$action=GETPOST('action');
+$id=GETPOST('id');
/*
* Actions
*/
-if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer)
+if ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
+{
+ $db->begin();
+ $paiement = new PaiementFourn($db);
+ $paiement->fetch($id);
+ $result = $paiement->update_note(GETPOST('note'));
+ if ($result > 0)
+ {
+ $db->commit();
+ $action='';
+ }
+ else
+ {
+ $mesg=''.$paiement->error.'
';
+ $db->rollback();
+ }
+}
+
+if ($action == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer)
{
$db->begin();
$paiement = new PaiementFourn($db);
- $paiement->fetch($_GET['id']);
+ $paiement->fetch($id);
$result = $paiement->delete();
if ($result > 0)
{
@@ -61,12 +81,12 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
}
}
-if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider)
+if ($action == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider)
{
$db->begin();
$paiement = new PaiementFourn($db);
- $paiement->id = $_GET['id'];
+ $paiement->fetch($id);
if ($paiement->valide() >= 0)
{
$db->commit();
@@ -80,6 +100,37 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
}
}
+if ($action == 'setnum' && !empty($_POST['num']))
+{
+ $paiement = new PaiementFourn($db);
+ $paiement->fetch($id);
+ $res = $paiement->update_num($_POST['num']);
+ if ($res === 0)
+ {
+ $mesg = ''.$langs->trans('PaymentNumberUpdateSucceeded').'
';
+ }
+ else
+ {
+ $mesg = ''.$langs->trans('PaymentNumberUpdateFailed').'
';
+ }
+}
+
+if ($action == 'setdate' && !empty($_POST['dateday']))
+{
+ $paiement = new PaiementFourn($db);
+ $paiement->fetch($id);
+ $datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']);
+ $res = $paiement->update_date($datepaye);
+ if ($res === 0)
+ {
+ $mesg = ''.$langs->trans('PaymentDateUpdateSucceeded').'
';
+ }
+ else
+ {
+ $mesg = ''.$langs->trans('PaymentDateUpdateFailed').'
';
+ }
+}
+
/*
* View
@@ -91,12 +142,12 @@ $html = new Form($db);
$h=0;
-$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$_GET['id'];
+$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$id;
$head[$h][1] = $langs->trans('Card');
$hselected = $h;
$h++;
-$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$_GET['id'];
+$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$id;
$head[$h][1] = $langs->trans('Info');
$h++;
@@ -104,14 +155,13 @@ $h++;
dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment');
$paiement = new PaiementFourn($db);
-$result=$paiement->fetch($_GET['id']);
+$result=$paiement->fetch($id);
if ($result > 0)
{
-
/*
* Confirmation de la suppression du paiement
*/
- if ($_GET['action'] == 'delete')
+ if ($action == 'delete')
{
$ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
if ($ret == 'html') print ' ';
@@ -120,102 +170,31 @@ if ($result > 0)
/*
* Confirmation de la validation du paiement
*/
- if ($_GET['action'] == 'valide')
+ if ($action == 'valide')
{
$ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
if ($ret == 'html') print ' ';
}
- if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num']))
- {
- $res = $paiement->update_num($_POST['new_num']);
- if ($res === 0) {
- $mesg = ''.$langs->trans('PaymentNumberUpdateSucceeded').'
';
- } else {
- $mesg = ''.$langs->trans('PaymentNumberUpdateFailed').'
';
- }
- }
-
- if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday']))
- {
- $datepaye = dol_mktime(12, 0 , 0,
- $_POST['remonth'],
- $_POST['reday'],
- $_POST['reyear']);
- $res = $paiement->update_date($datepaye);
- if ($res === 0) {
- $mesg = ''.$langs->trans('PaymentDateUpdateSucceeded').'
';
- } else {
- $mesg = ''.$langs->trans('PaymentDateUpdateFailed').'
';
- }
- }
-
-
print '';
print '';
print ''.$langs->trans('Ref').' '.$paiement->id.' ';
- //switch through edition options for date (only available when statut is -not 1- (=validated))
- if (empty($_GET['action']) || $_GET['action']!='edit_date')
- {
- print '';
- print '';
- print ' ';
- print ''.dol_print_date($paiement->date,'day').' ';
- }
- else
- {
- print '';
- print ''.$langs->trans('Date').' ';
- print '';
- print '';
- print ' ';
- print ' ';
- }
+ // Date payment
+ print ''.$html->editfieldkey("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).' ';
+ print $html->editfieldval("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'day');
+ print ' ';
- print ''.$langs->trans('Type').' '.$paiement->type_libelle.' ';
+ // Payment mode
+ print ''.$langs->trans('PaymentMode').' '.$paiement->type_libelle.' ';
- //switch through edition options for number (only available when statut is -not 1- (=validated))
- if (empty($_GET['action']) || $_GET['action'] != 'edit_num')
- {
- print '';
- print '';
- print ' ';
- print ''.$paiement->numero.' ';
- }
- else
- {
- print '';
- print ''.$langs->trans('Numero').' ';
- print '';
- print ' ';
- print ' ';
- }
+ // Payment numero
+ print ''.$html->editfieldkey("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).' ';
+ print $html->editfieldval("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string');
+ print ' ';
+
+ // Amount
print ''.$langs->trans('Amount').' '.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).' ';
if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
@@ -223,7 +202,10 @@ if ($result > 0)
print ''.$langs->trans('Status').' '.$paiement->getLibStatut(4).' ';
}
- print ''.$langs->trans('Note').' '.nl2br($paiement->note).' ';
+ // Note
+ print ''.$html->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer).' ';
+ print $html->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer,'text');
+ print ' ';
// Bank account
if ($conf->banque->enabled)
@@ -244,7 +226,7 @@ if ($result > 0)
print '
';
- if ($mesg) print ' '.$mesg;
+ dol_htmloutput_mesg($mesg);
print ' ';
diff --git a/htdocs/fourn/product/liste.php b/htdocs/fourn/product/liste.php
index aa9da42af53..d8ffeaf3f14 100644
--- a/htdocs/fourn/product/liste.php
+++ b/htdocs/fourn/product/liste.php
@@ -88,17 +88,15 @@ if ($fourn_id)
}
$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type,";
-$sql .= " pf.fk_soc, pf.ref_fourn,";
-$sql .= " ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
+$sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
$sql .= " s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if ($catid)
{
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
}
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = pf.fk_soc";
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk_product_fournisseur = pf.rowid";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid";
if ($_POST["mode"] == 'search')
{
@@ -118,7 +116,7 @@ else
}
if ($sRefSupplier)
{
- $sql .= " AND pf.ref_fourn like '%".$sRefSupplier."%'";
+ $sql .= " AND ppf.ref_fourn like '%".$sRefSupplier."%'";
}
if ($snom)
{
@@ -128,11 +126,10 @@ else
{
$sql .= " AND cp.fk_categorie = ".$catid;
}
-
}
if ($fourn_id > 0)
{
- $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
+ $sql .= " AND ppf.fk_soc = ".$fourn_id;
}
$sql .= " ORDER BY ".$sortfield." ".$sortorder;
$sql .= $db->plimit($limit + 1 ,$offset);
diff --git a/htdocs/includes/dolibarr_changes.txt b/htdocs/includes/dolibarr_changes.txt
index 9e0164ecdf8..d3caf076520 100644
--- a/htdocs/includes/dolibarr_changes.txt
+++ b/htdocs/includes/dolibarr_changes.txt
@@ -106,13 +106,6 @@ $pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
define('DOL_URL_ROOT', $pos);
-/*
-$conf->syslog->enabled=1;
-define('SYSLOG_FILE','c:/log/dolibarr/dolibarr.log');
-require_once("../../../../../../lib/functions.lib.php");
-dol_syslog("eee".$conf->fckeditor->dir_output);
-*/
-
// SECURITY: You must explicitelly enable this "connector". (Set it to "true").
$Config['Enabled'] = true ;
diff --git a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php
index 26c189a2456..088247a7af0 100644
--- a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -451,14 +451,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures
try
{
$listlines = $odfHandler->setSegment('lines');
- //var_dump($object->lines);exit;
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
foreach($tmparray as $key => $val)
{
- try {
- $listlines->setVars($key, $val);
+ try
+ {
+ $listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
{
diff --git a/htdocs/includes/modules/modSyslog.class.php b/htdocs/includes/modules/modSyslog.class.php
index 3ba470b055f..1a362f43079 100644
--- a/htdocs/includes/modules/modSyslog.class.php
+++ b/htdocs/includes/modules/modSyslog.class.php
@@ -28,7 +28,7 @@ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
/**
* \class modSyslog
- * \brief Classe de description et activation du module Syslog
+ * \brief Class to enable/disable module Logs
*/
class modSyslog extends DolibarrModules
{
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index 062ce74d612..e2bfa1307c9 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -200,9 +200,10 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile))
}
-// Forcage du log pour les install et mises a jour
+// Force usage of log file for install and upgrades
$conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
+if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1);
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
@@ -212,10 +213,7 @@ if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant alrea
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
-if (! defined('SYSLOG_FILE_NO_ERROR'))
-{
- define('SYSLOG_FILE_NO_ERROR',1);
-}
+if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1);
// Removed magic_quotes
if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6
@@ -285,9 +283,10 @@ function conf($dolibarr_main_document_root)
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
- // Forcage du log pour les install et mises a jour
+ // Force usage of log file for install and upgrades
$conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
+ if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1);
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
@@ -297,10 +296,7 @@ function conf($dolibarr_main_document_root)
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
- if (! defined('SYSLOG_FILE_NO_ERROR'))
- {
- define('SYSLOG_FILE_NO_ERROR',1);
- }
+ if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1);
return 1;
}
diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
index 7b42303d9ba..653a2203341 100755
--- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
+++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
@@ -48,3 +48,20 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active)
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (220, 'CAP5', 'Format Canadian P5', '140', '215', 'mm', 1);
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (225, 'CAP6', 'Format Canadian P6', '107', '140', 'mm', 1);
+
+
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_product integer after tms;
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_soc integer after fk_product;
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN ref_fourn varchar(30) after fk_soc;
+ALTER TABLE llx_product_fournisseur_price ADD COLUMN entity integer DEFAULT 1 NOT NULL;
+
+UPDATE llx_product_fournisseur_price as a, llx_product_fournisseur as b SET a.fk_product = b.fk_product, a.fk_soc = b.fk_soc, a.ref_fourn = b.ref_fourn, a.entity = b.entity WHERE a.fk_product_fournisseur = b.rowid AND (a.fk_product IS NULL OR a.fk_soc IS NULL OR a.fk_product = 0 OR a.fk_soc = 0);
+
+ALTER TABLE llx_product_fournisseur_price DROP INDEX uk_product_fournisseur_price_ref;
+ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, quantity, entity);
+ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity);
+ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity);
+ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
+
+ALTER TABLE llx_product_fournisseur_price DROP FOREIGN KEY fk_product_fournisseur_price_fk_product_fournisseur;
+
diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur.key.sql b/htdocs/install/mysql/tables/llx_product_fournisseur.key.sql
deleted file mode 100644
index 6f1f25a8640..00000000000
--- a/htdocs/install/mysql/tables/llx_product_fournisseur.key.sql
+++ /dev/null
@@ -1,27 +0,0 @@
--- ============================================================================
--- Copyright (C) 2002-2004 Rodolphe Quiedeville
--- Copyright (C) 2004-2011 Laurent Destailleur
--- Copyright (C) 2005-2009 Regis Houssin
---
--- This program is free software; you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation; either version 2 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- 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, see .
---
--- ============================================================================
-
-
-ALTER TABLE llx_product_fournisseur ADD UNIQUE INDEX uk_product_fournisseur_ref (ref_fourn, fk_soc, entity);
-
-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);
diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur.sql b/htdocs/install/mysql/tables/llx_product_fournisseur.sql
deleted file mode 100644
index 733ab67a082..00000000000
--- a/htdocs/install/mysql/tables/llx_product_fournisseur.sql
+++ /dev/null
@@ -1,39 +0,0 @@
--- ============================================================================
--- Copyright (C) 2003 Rodolphe Quiedeville
--- Copyright (C) 2009 Laurent Destailleur
--- Copyright (C) 2009 Regis Houssin
---
--- This program is free software; you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation; either version 2 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- 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, see .
---
--- ============================================================================
-
-create table llx_product_fournisseur
-(
- rowid integer AUTO_INCREMENT PRIMARY KEY,
- datec datetime,
- tms timestamp,
- fk_product integer,
- fk_soc integer,
- ref_fourn varchar(30),
- entity integer DEFAULT 1 NOT NULL, -- multi company id
- fk_user_author integer
-)ENGINE=innodb;
-
---
--- List of codes for the field entity
---
--- 1 : first company product
--- 2 : second company product
--- 3 : etc...
---
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql
index 67ddb3cd150..a625efcfbbc 100644
--- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql
+++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql
@@ -19,9 +19,16 @@
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_user (fk_user);
-ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_product_fournisseur (fk_product_fournisseur);
+--ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_product_fournisseur (fk_product_fournisseur);
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
-ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product_fournisseur FOREIGN KEY (fk_product_fournisseur) REFERENCES llx_product_fournisseur (rowid);
+--ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product_fournisseur FOREIGN KEY (fk_product_fournisseur) REFERENCES llx_product_fournisseur (rowid);
+-- Added to remove table llx_product_fournisseur
+ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, quantity, entity);
+
+ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity);
+ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity);
+
+ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
index 0d49d733a28..42f9f836471 100644
--- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
+++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql
@@ -22,11 +22,14 @@ create table llx_product_fournisseur_price
rowid integer AUTO_INCREMENT PRIMARY KEY,
datec datetime,
tms timestamp,
- fk_product_fournisseur integer NOT NULL,
+ fk_product_fournisseur integer NOT NULL, -- deprecated
+ fk_product integer,
+ fk_soc integer,
+ ref_fourn varchar(30),
fk_availability integer,
price double(24,8) DEFAULT 0,
quantity double,
unitprice double(24,8) DEFAULT 0,
- fk_user integer
-
+ fk_user integer,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
)ENGINE=innodb;
diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang
index b870106be2e..ac81dba9a25 100644
--- a/htdocs/langs/ca_ES/admin.lang
+++ b/htdocs/langs/ca_ES/admin.lang
@@ -339,7 +339,7 @@ Module30Desc=Gestió de factures i abonaments de clients. Gestió factures de pr
Module40Name=Proveïdors
Module40Desc=Gestió de proveïdors
Module42Name=Syslog
-Module42Desc=Utilització de logs (syslog)
+Module42Desc=Generació de logs (arxius, syslog,...)
Module49Name=Editors
Module49Desc=Gestió d'editors
Module50Name=Productes
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index b25406bcfcf..2af977d0d17 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -338,8 +338,8 @@ Module30Name=Invoices
Module30Desc=Invoices and credit note's management for customers. Invoice's management for suppliers
Module40Name=Suppliers
Module40Desc=Supplier's management and buying (orders and invoices)
-Module42Name=Syslog
-Module42Desc=Logging facilities (syslog)
+Module42Name=Logs
+Module42Desc=Logging facilities (file, syslog, ...)
Module49Name=Editors
Module49Desc=Editor's management
Module50Name=Products
@@ -1112,15 +1112,15 @@ UseEcoTaxeAbility=Support Eco-Taxe (WEEE)
SetDefaultBarcodeTypeProducts=Default barcode type to use for products
SetDefaultBarcodeTypeThirdParties=Default barcode type to use for third parties
##### Syslog #####
-SyslogSetup=Syslog module setup
-SyslogOutput=Log output
+SyslogSetup=Logs module setup
+SyslogOutput=Logs outputs
SyslogSyslog=Syslog
SyslogFacility=Facility
SyslogLevel=Level
SyslogSimpleFile=File
SyslogFilename=File name and path
YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file.
-ErrorUnknownSyslogConstant=Constant %s is not a known syslog constant
+ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant
##### Donations #####
DonationsSetup=Donation module setup
DonationsReceiptModel=Template of donation receipt
diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang
index 6402e08c8d6..3d1abf13eed 100644
--- a/htdocs/langs/es_ES/admin.lang
+++ b/htdocs/langs/es_ES/admin.lang
@@ -339,7 +339,7 @@ Module30Desc=Gestión de facturas y abonos a clientes. Gestión facturas de prov
Module40Name=Proveedores
Module40Desc=Gestión de proveedores
Module42Name=Syslog
-Module42Desc=Utilización de logs (syslog)
+Module42Desc=Generación de logs (archivos, syslog,...)
Module49Name=Editores
Module49Desc=Gestión de editores
Module50Name=Productos
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index af60ee973ac..b0957345e4b 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -49,7 +49,7 @@ ConfirmAjax= Utiliser les popups de confirmation Ajax
UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante). Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine.
ActivityStateToSelectCompany= Ajouter une option de filtrage lors des recherches pour afficher/masquer les tiers en exercice ou ayant cessés d'exercer
SearchFilter=Options des filtres de recherche
-NumberOfKeyToSearch=Nb caractères déclenchant la recherche: %s
+NumberOfKeyToSearch=Nb carac. déclenchant recherche: %s
ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers
NotAvailableWhenAjaxDisabled= Non disponible quand Ajax désactivé
JavascriptDisabled= Javascript désactivé
@@ -128,7 +128,7 @@ SystemTools= Outils Système
SystemToolsArea= Espace outils systèmes
SystemToolsAreaDesc= Cet espace offre des fonctions d'administration diverses. Utilisez le menu pour choisir la fonctionnalité recherchée.
PurgeAreaDesc= Cette page vous permet d'effacer tous les fichiers construits ou stockés par Dolibarr (fichiers temporaires ou tous les fichiers du répertoire %s ). L'utilisation de cette fonction n'est pas nécessaire. Elle est fournie pour les utilisateurs qui hébergent Dolibarr chez un hébergeur qui n'offre pas les permissions de supprimer les fichiers sauvegardés par le serveur Web.
-PurgeDeleteLogFile= Effacer le fichier log %s défini pour le module Syslog (pas de risque de perte de données)
+PurgeDeleteLogFile= Effacer le fichier log %s défini pour le module 'Logs et traces' (pas de risque de perte de données)
PurgeDeleteTemporaryFiles= Effacer tous les fichiers temporaires (pas de risque de perte de données)
PurgeDeleteAllFilesInDocumentsDir= Effacer tous les fichiers du répertoire %s . Les fichiers temporaires mais aussi les fichiers dumps de sauvegardes de bases, les fichiers joints aux éléments (tiers, factures, ...) ou fichiers stockés dans le module GED seront irrémédiablement effacés.
PurgeRunNow= Lancer la purge maintenant
@@ -339,8 +339,8 @@ Module30Name= Factures et avoirs
Module30Desc= Gestion des factures et avoirs clients. Gestion des factures fournisseurs
Module40Name= Fournisseurs
Module40Desc= Gestion des fournisseurs et achats (commandes et factures)
-Module42Name= Syslog
-Module42Desc= Utilisation de logs (syslog)
+Module42Name= Logs et traces
+Module42Desc= Génération de logs (fichiers, syslog, ...)
Module49Name= Éditeurs
Module49Desc= Gestion des éditeurs
Module50Name= Produits
@@ -1120,7 +1120,7 @@ UseEcoTaxeAbility= Prise en charge des éco-taxes (DEEE)
SetDefaultBarcodeTypeProducts= Type de code-barres utilisé par défaut pour les produits
SetDefaultBarcodeTypeThirdParties= Type de code-barres utilisé par défaut pour les tiers
##### Syslog #####
-SyslogSetup= Configuration du module Syslog
+SyslogSetup= Configuration du module Logs et traces
SyslogOutput= Sortie des log
SyslogSyslog= Syslog
SyslogFacility= Facility
diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php
index 8f4695ab885..9987d260112 100644
--- a/htdocs/lib/fourn.lib.php
+++ b/htdocs/lib/fourn.lib.php
@@ -19,9 +19,16 @@
/**
* \file htdocs/lib/fourn.lib.php
- * \brief Ensemble de fonctions de base pour le module fournisseur
+ * \brief Functions used by supplier invoice module
+ * \ingroup supplier
*/
+/**
+ * Initialize the array of tabs for supplier invoice
+ *
+ * @param Facture $object Invoice object
+ * @return array Array of head tabs
+ */
function facturefourn_prepare_head($object)
{
global $langs, $conf;
@@ -29,7 +36,7 @@ function facturefourn_prepare_head($object)
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id;
- $head[$h][1] = $langs->trans('Card');
+ $head[$h][1] = $langs->trans('CardBill');
$head[$h][2] = 'card';
$h++;
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index bb6923f8697..3553d36b442 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -371,20 +371,22 @@ function dol_escape_htmltag($stringtoescape,$keepb=0)
}
/**
- * Write log message in a file or to syslog process
- * Pour fichier: fichier defined by SYSLOG_FILE
- * Pour syslog: facility defined by SYSLOG_FACILITY
+ * Write log message into outputs. Possible outputs can be:
+ * A file if SYSLOG_FILE_ON defined: file name is then defined by SYSLOG_FILE
+ * Syslog if SYSLOG_SYSLOG_ON defined: facility is then defined by SYSLOG_FACILITY
* Warning, les fonctions syslog sont buggues sous Windows et generent des
* fautes de protection memoire. Pour resoudre, utiliser le loggage fichier,
* au lieu du loggage syslog (configuration du module).
- * Si SYSLOG_FILE_NO_ERROR defini, on ne gere pas erreur ecriture log
- * This function works only if syslog module is enabled.
- * This must must not use any call to other function calling dol_syslog (avoid infinite loop).
- * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr
- * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
+ * Note: If SYSLOG_FILE_NO_ERROR defined, we never output error message when writing to log fails.
*
- * @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR
- * @param int $level Log level
+ * This function works only if syslog module is enabled.
+ * This must not use any call to other function calling dol_syslog (avoid infinite loop).
+ *
+ * @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR
+ * @param int $level Log level
+ * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr
+ * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
+ * @return void
*/
function dol_syslog($message, $level=LOG_INFO)
{
@@ -421,8 +423,8 @@ function dol_syslog($message, $level=LOG_INFO)
if (is_object($user) && $user->id) $login=$user->login;
$message=sprintf("%-8s",$login)." ".$message;
- // Check if log is to a file (SYSLOG_FILE defined) or to syslog
- if (defined("SYSLOG_FILE") && SYSLOG_FILE)
+ // Check if log is to a file (SYSLOG_FILE_ON defined)
+ if (defined("SYSLOG_FILE_ON") && constant("SYSLOG_FILE_ON"))
{
$filelog=SYSLOG_FILE;
$filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
@@ -458,36 +460,48 @@ function dol_syslog($message, $level=LOG_INFO)
}
elseif (! defined("SYSLOG_FILE_NO_ERROR"))
{
- // Do not use call to functions that make call to dol_syslog, so no call to langs.
+ // Do not use here a call to functions that make call to dol_syslog so making call to langs. A simple print is enough.
print "Error, failed to open file ".$filelog."\n";
}
}
- else
+
+ // Check if log is to syslog (SYSLOG_SYSLOG_ON defined)
+ if (defined("SYSLOG_SYSLOG_ON") && constant("SYSLOG_SYSLOG_ON"))
{
if (function_exists('openlog')) // This function does not exists on some ISP (Ex: Free in France)
{
$facility = LOG_USER;
-
- if (defined("SYSLOG_FACILITY") && SYSLOG_FACILITY)
+ if (defined("SYSLOG_FACILITY") && constant("SYSLOG_FACILITY"))
{
// Exemple: SYSLOG_FACILITY vaut LOG_USER qui vaut 8. On a besoin de 8 dans $facility.
$facility = constant("SYSLOG_FACILITY");
}
openlog("dolibarr", LOG_PID | LOG_PERROR, (int) $facility); // (int) is required to avoid error parameter 3 expected to be long
-
- if (! $level)
- {
- syslog(LOG_ERR, $message);
- }
- else
- {
- syslog($level, $message);
- }
-
+ if (! $level) syslog(LOG_ERR, $message);
+ else syslog($level, $message);
closelog();
}
}
+
+ // Check if log is to syslog (SYSLOG_FIREPHP_ON defined)
+ if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON"))
+ {
+ try
+ {
+ // Warning FirePHPCore must be into PHP include path. It is not possible to use into require_once() a constant from
+ // database or config file because we must be able to log data before database or config file read.
+ set_include_path('/usr/share/php/');
+ require_once('FirePHPCore/FirePHP.class.php');
+ restore_include_path();
+ ob_start();
+ $firephp = FirePHP::getInstance(true);
+ $firephp->log($message);
+ }
+ catch(Exception $e)
+ {
+ }
+ }
}
}
@@ -609,18 +623,19 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$enc
* Output date in a string format according to outputlangs (or langs if not defined).
* Return charset is always UTF-8, except if encodetoouput is defined. In this cas charset is output charset
*
- * @param time GM Timestamps date (or deprecated strings 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS')
- * @param format Output date format
- * "%d %b %Y",
- * "%d/%m/%Y %H:%M",
- * "%d/%m/%Y %H:%M:%S",
- * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext"
- * @param tzoutput true=output or 'gmt' => string is for Greenwich location
- * false or 'tzserver' => output string is for local PHP server TZ usage
- * 'tzuser' => output string is for local browser TZ usage
- * @param outputlangs Object lang that contains language for text translation.
- * @param encodetooutput false=no convert into output pagecode
- * @return string Formated date or '' if time is null
+ * @param timestamp $time GM Timestamps date (or deprecated strings 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS')
+ * @param string $format Output date format
+ * "%d %b %Y",
+ * "%d/%m/%Y %H:%M",
+ * "%d/%m/%Y %H:%M:%S",
+ * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext"
+ * @param string $tzoutput true=output or 'gmt' => string is for Greenwich location
+ * false or 'tzserver' => output string is for local PHP server TZ usage
+ * 'tzuser' => output string is for local browser TZ usage
+ * @param Tranlsate $outputlangs Object lang that contains language for text translation.
+ * @param boolean $encodetooutput false=no convert into output pagecode
+ * @return string Formated date or '' if time is null
+ *
* @see dol_mktime, dol_stringtotime, dol_getdate
*/
function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$encodetooutput=false)
@@ -756,15 +771,16 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
/**
* Convert a string date into a GM Timestamps date
*
- * @param string Date in a string
- * YYYYMMDD
+ * @param string $string Date in a string
+ * YYYYMMDD
* YYYYMMDDHHMMSS
* YYYY-MM-DDTHH:MM:SSZ (RFC3339)
* DD/MM/YY or DD/MM/YYYY (this format should not be used anymore)
* DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (this format should not be used anymore)
* 19700101020000 -> 7200
- * @param gm 1=Input date is GM date, 0=Input date is local date
- * @return date Date
+ * @param int $gm 1=Input date is GM date, 0=Input date is local date
+ * @return date Date
+ *
* @see dol_print_date, dol_mktime, dol_getdate
*/
function dol_stringtotime($string, $gm=1)
@@ -808,30 +824,30 @@ function dol_stringtotime($string, $gm=1)
* Return an array with date info
* PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
*
- * @param timestamp Timestamp
- * @param fast Fast mode
- * @return array Array of informations
- * If no fast mode:
- * 'seconds' => $secs,
- * 'minutes' => $min,
- * 'hours' => $hour,
- * 'mday' => $day,
- * 'wday' => $dow,
- * 'mon' => $month,
- * 'year' => $year,
- * 'yday' => floor($secsInYear/$_day_power),
- * 'weekday' => gmdate('l',$_day_power*(3+$dow)),
- * 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
- * If fast mode:
- * 'seconds' => $secs,
- * 'minutes' => $min,
- * 'hours' => $hour,
- * 'mday' => $day,
- * 'mon' => $month,
- * 'year' => $year,
- * 'yday' => floor($secsInYear/$_day_power),
- * 'leap' => $leaf,
- * 'ndays' => $ndays
+ * @param timestamp $timestamp Timestamp
+ * @param boolean $fast Fast mode
+ * @return array Array of informations
+ * If no fast mode:
+ * 'seconds' => $secs,
+ * 'minutes' => $min,
+ * 'hours' => $hour,
+ * 'mday' => $day,
+ * 'wday' => $dow,
+ * 'mon' => $month,
+ * 'year' => $year,
+ * 'yday' => floor($secsInYear/$_day_power),
+ * 'weekday' => gmdate('l',$_day_power*(3+$dow)),
+ * 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
+ * If fast mode:
+ * 'seconds' => $secs,
+ * 'minutes' => $min,
+ * 'hours' => $hour,
+ * 'mday' => $day,
+ * 'mon' => $month,
+ * 'year' => $year,
+ * 'yday' => floor($secsInYear/$_day_power),
+ * 'leap' => $leaf,
+ * 'ndays' => $ndays
*/
function dol_getdate($timestamp,$fast=false)
{
@@ -1069,13 +1085,13 @@ function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$s
/**
* Format phone numbers according to country
*
- * @param phone Phone number to format
- * @param country Country to use for formatting
- * @param cid Id of contact if known
- * @param socid Id of third party if known
- * @param addlink 0=no link to create action
- * @param separ separation between numbers for a better visibility example : xx.xx.xx.xx.xx
- * @return string Formated phone number
+ * @param string $phone Phone number to format
+ * @param string $country Country code to use for formatting
+ * @param int $cid Id of contact if known
+ * @param int $socid Id of third party if known
+ * @param int $addlink 0=no link to create action
+ * @param string $separ separation between numbers for a better visibility example : xx.xx.xx.xx.xx
+ * @return string Formated phone number
*/
function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=" ")
{
@@ -1148,9 +1164,9 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=
/**
* Return an IP formated to be shown on screen
*
- * @param ip IP
- * @param mode 1=return only country/flag,2=return only IP
- * @return string Formated IP, with country if GeoIP module is enabled
+ * @param string $ip IP
+ * @param int $mode 1=return only country/flag,2=return only IP
+ * @return string Formated IP, with country if GeoIP module is enabled
*/
function dol_print_ip($ip,$mode=0)
{
@@ -1188,7 +1204,7 @@ function dol_print_ip($ip,$mode=0)
* Return country code for current user.
* If software is used inside a local network, detection may fails (we need a public ip)
*
- * @return string country code (fr, es, it, us, ...)
+ * @return string Country code (fr, es, it, us, ...)
*/
function dol_user_country()
{
@@ -1213,11 +1229,11 @@ function dol_user_country()
/**
* Format address string
*
- * @param address Address
- * @param htmlid Html ID
- * @param mode thirdparty|contact|member|other
- * @param id Id of object
- * @param address Address string
+ * @param string $address Address
+ * @param int $htmlid Html ID
+ * @param int $mode thirdparty|contact|member|other
+ * @param int $id Id of object
+ * @return void
*/
function dol_print_address($address, $htmlid='gmap', $mode, $id)
{
@@ -1308,13 +1324,13 @@ function dol_strlen($string,$stringencoding='UTF-8')
}
/**
- * Make a substring. Works even in mbstring module not enabled
+ * Make a substring. Works even in mbstring module is not enabled.
*
- * @param $string
- * @param $start
- * @param $length
- * @param $stringencoding
- * @return string
+ * @param string $string String to scan
+ * @param string $start Start position
+ * @param int $length Length
+ * @param string $stringencoding Page code used for input string encoding
+ * @return string substring
*/
function dol_substr($string,$start,$length,$stringencoding='')
{
@@ -2747,6 +2763,7 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath
* @param totalnboflines Total number of records/lines for all pages (if known)
* @param picto Icon to use before title (should be a 32x32 transparent png file)
* @param pictoisfullpath 1=Icon name is a full absolute url of image
+ * @return void
*/
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0)
{
@@ -2846,11 +2863,12 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
/**
* Fonction servant a afficher les fleches de navigation dans les pages de listes
*
- * @param page Numero of page
- * @param file Lien
- * @param options Autres parametres d'url a propager dans les liens ("" par defaut)
- * @param nextpage Faut-il une page suivante
- * @param betweenarrows HTML Content to show between arrows
+ * @param int $page Numero of page
+ * @param string $file Lien
+ * @param string $options Autres parametres d'url a propager dans les liens ("" par defaut)
+ * @param int $nextpage Faut-il une page suivante
+ * @param string $betweenarrows HTML Content to show between arrows
+ * @return void
*/
function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrows='')
{
@@ -2871,10 +2889,10 @@ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrow
* Fonction qui retourne un taux de tva formate pour visualisation
* Utilisee dans les pdf et les pages html
*
- * @param rate Rate value to format (19.6 19,6 19.6% 19,6%,...)
- * @param addpercent Add a percent % sign in output
- * @param info_bits Miscellanous information on vat
- * @return string Chaine avec montant formate (19,6 ou 19,6% ou 8.5% *)
+ * @param float $rate Rate value to format (19.6 19,6 19.6% 19,6%,...)
+ * @param boolean $addpercent Add a percent % sign in output
+ * @param int $info_bits Miscellanous information on vat
+ * @return string Chaine avec montant formate (19,6 ou 19,6% ou 8.5% *)
*/
function vatrate($rate,$addpercent=false,$info_bits=0)
{
@@ -2900,14 +2918,15 @@ function vatrate($rate,$addpercent=false,$info_bits=0)
* Fonction qui formate un montant pour visualisation
* Fonction utilisee dans les pdf et les pages html
*
- * @param amount Montant a formater
- * @param html Type de formatage, html ou pas (par defaut)
- * @param outlangs Objet langs pour formatage text
- * @param trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage
- * @param rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
- * @param forcerounding Force the number of decimal
- * @return string Chaine avec montant formate
- * @see price2num Revert function of price
+ * @param float $amount Montant a formater
+ * @param string $html Type de formatage, html ou pas (par defaut)
+ * @param Translate $outlangs Objet langs pour formatage text
+ * @param int $trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage
+ * @param int $rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
+ * @param int $forcerounding Force the number of decimal
+ * @return string Chaine avec montant formate
+ *
+ * @see price2num Revert function of price
*/
function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1)
{
@@ -2974,14 +2993,15 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
* an amount typed by a user.
* Function to use on each input amount before any numeric test or database insert
*
- * @param amount Amount to convert/clean
- * @param rounding ''=No rounding
+ * @param float $amount Amount to convert/clean
+ * @param string $rounding ''=No rounding
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
* 'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN)
- * @param alreadysqlnb Put 1 if you know that content is already universal format number
- * @return string Amount with universal numeric format (Example: '99.99999')
- * @see price Opposite function of price2num
+ * @param int $alreadysqlnb Put 1 if you know that content is already universal format number
+ * @return string Amount with universal numeric format (Example: '99.99999')
+ *
+ * @see price Opposite function of price2num
*/
function price2num($amount,$rounding='',$alreadysqlnb=0)
{
@@ -3059,10 +3079,10 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
/**
* Return localtaxe rate for a particular tva
*
- * @param tva Vat taxe
- * @param local Local taxe to search and return
- * @param societe_acheteuse Object of buying third party
- * @return int 0 if not found, localtax if found
+ * @param float $tva Vat taxe
+ * @param int $local Local taxe to search and return
+ * @param Societe $societe_acheteuse Object of buying third party
+ * @return int 0 if not found, localtax if found
*/
function get_localtax($tva, $local, $societe_acheteuse="")
{
@@ -3081,7 +3101,7 @@ function get_localtax($tva, $local, $societe_acheteuse="")
$sql = "SELECT t.localtax1, t.localtax2";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'";
- $sql .= " AND t.taux =".$tva." AND t.active = 1";
+ $sql .= " AND t.taux = ".$tva." AND t.active = 1";
$sql .= " ORDER BY t.localtax1 ASC, t.localtax2 ASC";
$resql=$db->query($sql);
@@ -3099,9 +3119,9 @@ function get_localtax($tva, $local, $societe_acheteuse="")
* Return vat rate of a product in a particular selling country or default country
* vat if product is unknown
*
- * @param idprod Id of product or 0 if not a predefined product
- * @param countrycode Country code (FR, US, IT, ...)
- * @return int <0 if KO, Vat rate if OK
+ * @param int $idprod Id of product or 0 if not a predefined product
+ * @param string $countrycode Country code (FR, US, IT, ...)
+ * @return int <0 if KO, Vat rate if OK
* TODO May be this should be better as a method of product class
*/
function get_product_vat_for_country($idprod, $countrycode)
@@ -3689,9 +3709,9 @@ function dol_microtime_float()
/**
* Return if a text is a html content
*
- * @param msg Content to check
- * @param option 0=Full detection, 1=Fast check
- * @return boolean true/false
+ * @param string $msg Content to check
+ * @param int $option 0=Full detection, 1=Fast check
+ * @return boolean true/false
*/
function dol_textishtml($msg,$option=0)
{
@@ -3726,9 +3746,10 @@ function dol_textishtml($msg,$option=0)
* There is two type of substitions:
* - From $substitutionarray (oldval=>newval)
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
- * @param chaine Source string in which we must do substitution
- * @param substitutionarray Array with key->val to substitute
- * @return string Output string after subsitutions
+ *
+ * @param string $chaine Source string in which we must do substitution
+ * @param array $substitutionarray Array with key->val to substitute
+ * @return string Output string after subsitutions
*/
function make_substitutions($chaine,$substitutionarray)
{
@@ -3745,9 +3766,10 @@ function make_substitutions($chaine,$substitutionarray)
/**
* Complete the $substitutionarray with more entries
*
- * @param substitutionarray Array substitution old value => new value value
- * @param outputlangs If we want substitution from special constants, we provide a language
- * @param object If we want substitution from special constants, we provide data in a source object
+ * @param array $substitutionarray Array substitution old value => new value value
+ * @param Translate $outputlangs If we want substitution from special constants, we provide a language
+ * @param Object $object If we want substitution from special constants, we provide data in a source object
+ * @return void
*/
function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='')
{
@@ -3785,10 +3807,11 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='
* @param date_end End date
* @param format Output format
* @param outputlangs Output language
+ * @return void
*/
function print_date_range($date_start,$date_end,$format = '',$outputlangs='')
{
- print get_date_range($date_start,$date_end,$format,$outputlangs);
+ print get_date_range($date_start,$date_end,$format,$outputlangs);
}
/**
@@ -3798,6 +3821,7 @@ function print_date_range($date_start,$date_end,$format = '',$outputlangs='')
* @param date_end End date
* @param format Output format
* @param outputlangs Output language
+ * @return string String
*/
function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
{
@@ -3827,11 +3851,12 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
/**
* Get formated messages to output (Used to show messages on html output).
*
- * @param mesgstring Message string
- * @param mesgarray Messages array
- * @param style Style of message output ('ok' or 'error')
- * @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
- * @return string Return html output
+ * @param string $mesgstring Message string
+ * @param array $mesgarray Messages array
+ * @param string $style Style of message output ('ok' or 'error')
+ * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
+ * @return string Return html output
+ *
* @see dol_print_error
* @see dol_htmloutput_errors
*/
@@ -3924,10 +3949,11 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
/**
* Get formated error messages to output (Used to show messages on html output).
*
- * @param mesgstring Error message
- * @param mesgarray Error messages array
- * @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
- * @return html Return html output
+ * @param string $mesgstring Error message
+ * @param array $mesgarray Error messages array
+ * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
+ * @return string Return html output
+ *
* @see dol_print_error
* @see dol_htmloutput_mesg
*/
@@ -3939,10 +3965,12 @@ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
/**
* Print formated messages to output (Used to show messages on html output).
*
- * @param mesgstring Message
- * @param mesgarray Messages array
- * @param style Which style to use ('ok', 'error')
- * @param keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
+ * @param string $mesgstring Message
+ * @param array $mesgarray Messages array
+ * @param string $style Which style to use ('ok', 'error')
+ * @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
+ * @return void
+ *
* @see dol_print_error
* @see dol_htmloutput_errors
*/
@@ -3988,9 +4016,11 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
/**
* Print formated error messages to output (Used to show messages on html output).
*
- * @param mesgstring Error message
- * @param mesgarray Error messages array
- * @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
+ * @param string $mesgstring Error message
+ * @param array $mesgarray Error messages array
+ * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
+ * @return void
+ *
* @see dol_print_error
* @see dol_htmloutput_mesg
*/
@@ -4036,8 +4066,8 @@ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensiti
/**
* Check if a string is in UTF8
*
- * @param $str String to check
- * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary)
+ * @param string $str String to check
+ * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary)
*/
function utf8_check($str)
{
@@ -4064,8 +4094,8 @@ function utf8_check($str)
* Return an UTF-8 string encoded into OS filesystem encoding. This function is used to define
* value to pass to filesystem PHP functions.
*
- * @param string $str String to encode (UTF-8)
- * @return string Encoded string (UTF-8, ISO-8859-1)
+ * @param string $str String to encode (UTF-8)
+ * @return string Encoded string (UTF-8, ISO-8859-1)
*/
function dol_osencode($str)
{
@@ -4084,12 +4114,12 @@ function dol_osencode($str)
/**
* Return an id or code from a code or id. Store Code-Id in a cache.
*
- * @param db Database handler
- * @param key Code to get Id
- * @param tablename Table name without prefix
- * @param fieldkey Field for code
- * @param fieldid Field for id
- * @return int Id of code
+ * @param DoliDB $db Database handler
+ * @param string $key Code to get Id
+ * @param string $tablename Table name without prefix
+ * @param string $fieldkey Field for code
+ * @param string $fieldid Field for id
+ * @return int Id of code
*/
function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
{
@@ -4127,8 +4157,8 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
/**
* Verify if condition in string is ok or not
*
- * @param string $strRights
- * @return boolean true or false
+ * @param string $strRights String with condition to check
+ * @return boolean true or false
*/
function verifCond($strRights)
{
@@ -4156,6 +4186,7 @@ function verifCond($strRights)
* This function is called by verifCond()
*
* @param string $s
+ * @return void
*/
function dol_eval($s)
{
@@ -4172,8 +4203,8 @@ function dol_eval($s)
/**
* Return img flag of country for a language code or country code
*
- * @param codelang Language code (en_IN, fr_CA...) or Country code (IN, FR)
- * @return string HTML img string with flag.
+ * @param string $codelang Language code (en_IN, fr_CA...) or Country code (IN, FR)
+ * @return string HTML img string with flag.
*/
function picto_from_langcode($codelang)
{
diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php
index 971438d3beb..7dd7ed08c28 100644
--- a/htdocs/lib/functions2.lib.php
+++ b/htdocs/lib/functions2.lib.php
@@ -981,19 +981,15 @@ function dol_print_reduction($reduction=0,$langs)
/**
- * Return OS version
+ * Return OS version.
+ * Note that PHP_OS returns only OS (not version) and OS PHP was built on, not
+ * necessarly OS PHP runs on.
*
* @return string OS version
*/
function version_os()
{
- // Get version of OS
- ob_start();
- phpinfo();
- $chaine = ob_get_contents();
- ob_end_clean();
- preg_match('/System <\/td>([^<]*)<\/td>/i',$chaine,$reg);
- $osversion=$reg[1];
+ $osversion=php_uname();
return $osversion;
}
diff --git a/htdocs/lib/invoice.lib.php b/htdocs/lib/invoice.lib.php
index 39f1d508e73..22b0b276571 100644
--- a/htdocs/lib/invoice.lib.php
+++ b/htdocs/lib/invoice.lib.php
@@ -18,10 +18,16 @@
/**
* \file htdocs/lib/invoice.lib.php
- * \brief Ensemble de fonctions de base pour le module factures
+ * \brief Functions used by invoice module
* \ingroup invoice
*/
+/**
+ * Initialize the array of tabs for customer invoice
+ *
+ * @param Facture $object Invoice object
+ * @return array Array of head tabs
+ */
function facture_prepare_head($object)
{
global $langs, $conf;
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 39183b07f48..54ccf671c4b 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -28,7 +28,7 @@
* \brief File that defines environment for Dolibarr pages only (variables not required by scripts)
*/
-@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
+//@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
// For optionnal tuning. Enabled if environment variable DOL_TUNING is defined.
// A call first. Is the equivalent function dol_microtime_float not yet loaded.
diff --git a/htdocs/paybox/lib/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php
index 5efad6cfce9..b00e62e0db6 100755
--- a/htdocs/paybox/lib/paybox.lib.php
+++ b/htdocs/paybox/lib/paybox.lib.php
@@ -21,6 +21,16 @@
* \ingroup paybox
* \brief Library for common paybox functions
*/
+
+
+
+/**
+ * Show header
+ *
+ * @param string $title Title of page
+ * @param string $head Head string to add int head section
+ * @return void
+ */
function llxHeaderPaybox($title, $head = "")
{
global $user, $conf, $langs;
@@ -50,6 +60,11 @@ function llxHeaderPaybox($title, $head = "")
print ''."\n";
}
+/**
+ * Show footer
+ *
+ * @return void
+ */
function llxFooterPayBox()
{
print "\n";
@@ -60,13 +75,13 @@ function llxFooterPayBox()
/**
* Create a redirect form to paybox form
*
- * @param $PRICE
- * @param $CURRENCY
- * @param $EMAIL
- * @param $urlok
- * @param $urlko
- * @param $TAG
- * @return int 1 if OK, -1 if ERROR
+ * @param int $PRICE Price
+ * @param string $CURRENCY Currency
+ * @param string $EMAIL EMail
+ * @param string $urlok Url to go back if payment is OK
+ * @param string $urlko Url to go back if payment is KO
+ * @param string $TAG Tag
+ * @return int 1 if OK, -1 if ERROR
*/
function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
{
@@ -231,8 +246,9 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
/**
* Show footer of company in HTML pages
*
- * @param $fromcompany
- * @param $langs
+ * @param Societe $fromcompany Third party
+ * @param Translate $langs Output language
+ * @return void
*/
function html_print_paybox_footer($fromcompany,$langs)
{
diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php
index 95439c7f9e6..6c7c086f897 100755
--- a/htdocs/paypal/lib/paypal.lib.php
+++ b/htdocs/paypal/lib/paypal.lib.php
@@ -23,7 +23,13 @@
*/
-
+/**
+ * Show header
+ *
+ * @param string $title
+ * @param string $head
+ * @return void
+ */
function llxHeaderPaypal($title, $head = "")
{
global $user, $conf, $langs;
@@ -53,6 +59,11 @@ function llxHeaderPaypal($title, $head = "")
print ''."\n";
}
+/**
+ * Show footer
+ *
+ * @return void
+ */
function llxFooterPaypal()
{
print "\n";
@@ -63,8 +74,9 @@ function llxFooterPaypal()
/**
* Show footer of company in HTML pages
*
- * @param $fromcompany
- * @param $langs
+ * @param Societe $fromcompany Third party
+ * @param Translate $langs Output language
+ * @return void
*/
function html_print_paypal_footer($fromcompany,$langs)
{
@@ -128,6 +140,7 @@ function html_print_paypal_footer($fromcompany,$langs)
/**
* Define head array for tabs of paypal tools setup pages
+ *
* @return Array of head
*/
function paypaladmin_prepare_head()
@@ -250,12 +263,13 @@ function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f
/**
* Send redirect to paypal to browser
*
- * @param $paymentAmount
- * @param $currencyCodeType
- * @param $paymentType
- * @param $returnURL
- * @param $cancelURL
- * @param $tag
+ * @param float $paymentAmount Amount
+ * @param string $currencyCodeType Currency code
+ * @param string $paymentType Payment type
+ * @param string $returnURL Url to use if payment is OK
+ * @param string $cancelURL Url to use if payment is KO
+ * @param string $tag Tag
+ * @return void
*/
function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$returnURL,$cancelURL,$tag)
{
@@ -295,8 +309,24 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re
}
dol_syslog("expresscheckout redirect with CallSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $landingPage, $solutionType, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
- $resArray = CallSetExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage,
- $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum);
+ $resArray = CallSetExpressCheckout(
+ $paymentAmount,
+ $currencyCodeType,
+ $paymentType,
+ $returnURL,
+ $cancelURL,
+ $tag,
+ $solutionType,
+ $landingPage,
+ $shipToName,
+ $shipToStreet,
+ $shipToCity,
+ $shipToState,
+ $shipToCountryCode,
+ $shipToZip,
+ $shipToStreet2,
+ $phoneNum
+ );
/* For direct payment with credit card
{
//$resArray = DirectPayment (...);
@@ -349,8 +379,7 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re
' phoneNum: the phoneNum entered on the merchant's site
'--------------------------------------------------------------------------------------------------------------------------------------------
*/
-function CallSetExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage,
-$shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum)
+function CallSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum)
{
//------------------------------------------------------------------------------------------------------------------------------------
// Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
@@ -402,17 +431,12 @@ $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $ship
return $resArray;
}
-/*
- '-------------------------------------------------------------------------------------------
- ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call.
- '
- ' Inputs:
- ' None
- ' Returns:
- ' The NVP Collection object of the GetExpressCheckoutDetails Call Response.
- '-------------------------------------------------------------------------------------------
+/**
+ * Prepares the parameters for the GetExpressCheckoutDetails API Call.
+ *
+ * @return array The NVP Collection object of the GetExpressCheckoutDetails Call Response.
*/
-function GetDetails( $token )
+function GetDetails($token)
{
//'--------------------------------------------------------------
//' At this point, the buyer has completed authorizing the payment
@@ -450,12 +474,12 @@ function GetDetails( $token )
}
-/*
- '-------------------------------------------------------------------------------------------------------------------------------------------
- ' Purpose: Validate payment
- '--------------------------------------------------------------------------------------------------------------------------------------------
+/**
+ * Validate payment
+ *
+ * @return void
*/
-function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag )
+function ConfirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
{
/* Gather the information to make the final call to
finalize the PayPal payment. The variable nvpstr
@@ -486,36 +510,26 @@ function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $ipa
return $resArray;
}
-/*
- '-------------------------------------------------------------------------------------------------------------------------------------------
- ' Purpose: This function makes a DoDirectPayment API call
- '
- ' Inputs:
- ' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
- ' paymentAmount: total value of the shopping cart
- ' currencyCode: currency code value the PayPal API
- ' firstName: first name as it appears on credit card
- ' lastName: last name as it appears on credit card
- ' street: buyer's street address line as it appears on credit card
- ' city: buyer's city
- ' state: buyer's state
- ' countryCode: buyer's country code
- ' zip: buyer's zip
- ' creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... )
- ' creditCardNumber: buyers credit card number without any spaces, dashes or any other characters
- ' expDate: credit card expiration date
- ' cvv2: Card Verification Value
- '
- '-------------------------------------------------------------------------------------------
- '
- ' Returns:
- ' The NVP Collection object of the DoDirectPayment Call Response.
- '--------------------------------------------------------------------------------------------------------------------------------------------
+/**
+ * This function makes a DoDirectPayment API call
+ *
+ * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
+ * paymentAmount: total value of the shopping cart
+ * currencyCode: currency code value the PayPal API
+ * firstName: first name as it appears on credit card
+ * lastName: last name as it appears on credit card
+ * street: buyer's street address line as it appears on credit card
+ * city: buyer's city
+ * state: buyer's state
+ * countryCode: buyer's country code
+ * zip: buyer's zip
+ * creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... )
+ * creditCardNumber: buyers credit card number without any spaces, dashes or any other characters
+ * expDate: credit card expiration date
+ * cvv2: Card Verification Value
+ * @return array The NVP Collection object of the DoDirectPayment Call Response.
*/
-
-function DirectPayment( $paymentType, $paymentAmount, $creditCardType, $creditCardNumber,
-$expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip,
-$countryCode, $currencyCode, $tag )
+function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $tag)
{
//declaring of global variables
global $conf, $langs;
@@ -547,9 +561,10 @@ $countryCode, $currencyCode, $tag )
/**
* hash_call: Function to perform the API call to PayPal using API signature
- * @param methodName is name of API method.
- * @param nvpStr is nvp string.
- * @return array returns an associtive array containing the response from the server.
+ *
+ * @param string $methodName is name of API method.
+ * @param string $nvpStr is nvp string.
+ * @return array returns an associtive array containing the response from the server.
*/
function hash_call($methodName,$nvpStr)
{
@@ -606,8 +621,8 @@ function hash_call($methodName,$nvpStr)
{
dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS);
//curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10
- curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
- if ($PROXY_USER) curl_setopt ($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS);
+ curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
+ if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS);
}
//NVPRequest for submitting to server
@@ -650,7 +665,9 @@ function hash_call($methodName,$nvpStr)
}
/**
- * Get API errors
+ * Get API errors
+ *
+ * @return array Array of errors
*/
function GetApiError()
{
@@ -672,12 +689,13 @@ function GetApiError()
}
-/*'----------------------------------------------------------------------------------
+/**
* This function will take NVPString and convert it to an Associative Array and it will decode the response.
* It is usefull to search for a particular key and displaying arrays.
- * @nvpstr is NVPString.
- * @nvpArray is Associative Array.
- ----------------------------------------------------------------------------------
+ *
+ * @param string $nvpstr NVPString
+ * @return array nvpArray = Associative Array
+ * ----------------------------------------------------------------------------------
*/
function deformatNVP($nvpstr)
{
diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php
index 85f44e0e627..1f39bc3981f 100644
--- a/htdocs/product/admin/produit.php
+++ b/htdocs/product/admin/produit.php
@@ -5,7 +5,7 @@
* Copyright (C) 2007 Auguria SARL
* Copyright (C) 2005-2010 Regis Houssin
* Copyright (C) 2011 Juanjo Menent
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -33,12 +33,16 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
$langs->load("admin");
// Security check
-if (!$user->admin)
-accessforbidden();
+if (! $user->admin) accessforbidden();
$action = GETPOST("action");
$value = GETPOST("value");
+
+/*
+ * Actions
+ */
+
if ($action == 'nbprod')
{
$res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", $value,'chaine',0,'',$conf->entity);
@@ -50,7 +54,7 @@ else if ($action == 'multiprix_num')
if ($action == 'multiprix')
{
$multiprix = GETPOST("activate_multiprix");
-
+
$res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $multiprix,'chaine',0,'',$conf->entity);
$res =dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "5",'chaine',0,'',$conf->entity);
}
@@ -81,7 +85,6 @@ else if ($action == 'set')
$res = dolibarr_set_const($db, "PRODUIT_USE_ECOTAXE", $ecotaxe,'chaine',0,'',$conf->entity);
}*/
-
if($action)
{
if (! $res > 0) $error++;
@@ -190,7 +193,12 @@ if (! $conf->use_javascript_ajax)
else
{
print '';
- print $html->selectyesno("activate_usesearchtoselectproduct",$conf->global->PRODUIT_USE_SEARCH_TO_SELECT,1);
+ $arrval=array('0'=>$langs->trans("No"),
+ '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
+ '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
+ '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
+ );
+ print $html->selectarray("activate_usesearchtoselectproduct",$arrval,$conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
print ' ';
print ' ';
print " ";
diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php
index 3a04e75c43e..2038024887d 100755
--- a/htdocs/product/canvas/product/actions_card_product.class.php
+++ b/htdocs/product/canvas/product/actions_card_product.class.php
@@ -79,7 +79,7 @@ class ActionsCardProduct extends Product
$tmpobject = new Product($this->db);
if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref);
- $this->object = $object;
+ $this->object = $tmpobject;
//parent::assign_values($action);
diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php
index 42003219528..984edc8002f 100755
--- a/htdocs/product/canvas/service/actions_card_service.class.php
+++ b/htdocs/product/canvas/service/actions_card_service.class.php
@@ -78,7 +78,7 @@ class ActionsCardService extends Product
$tmpobject = new Product($this->db);
if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref);
- $this->object = $object;
+ $this->object = $tmpobject;
//parent::assign_values($action);
@@ -310,7 +310,7 @@ class ActionsCardService extends Product
if ($_GET["fourn_id"] > 0)
{
$fourn_id = $_GET["fourn_id"];
- $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
+ $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
}
$sql.= " WHERE p.entity = ".$conf->entity;
if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
@@ -335,7 +335,7 @@ class ActionsCardService extends Product
}
if ($fourn_id > 0)
{
- $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
+ $sql.= " AND p.rowid = pfp.fk_product AND pfp.fk_soc = ".$fourn_id;
}
// Insert categ filter
if ($search_categ)
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index ec4cc4b49aa..277fd8a85ab 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -37,7 +37,7 @@ class Product extends CommonObject
public $element='product';
public $table_element='product';
public $fk_element='fk_product';
- public $childtables=array('propaldet','commandedet','facturedet','contratdet','product_fournisseur');
+ public $childtables=array('propaldet','commandedet','facturedet','contratdet','product_fournisseur_price');
protected $isnolinkedbythird = 1; // No field fk_soc
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
@@ -45,7 +45,8 @@ class Product extends CommonObject
var $id ;
//! Ref
var $ref;
- var $libelle;
+ var $libelle; // TODO deprecated
+ var $label;
var $description;
//! Prix de vente
var $price; // Price without tax
@@ -68,14 +69,14 @@ class Product extends CommonObject
var $localtax2_tx;
//! Type 0 for regular product, 1 for service (Advanced feature: 2 for assembly kit, 3 for stock kit)
var $type;
- var $typestring;
//! Stock
var $stock_reel;
//! Average price value for product entry into stock (PMP)
var $pmp;
-
+ //! Stock alert
var $seuil_stock_alerte;
+
//! Duree de validite du service
var $duration_value;
//! Unite de duree
@@ -124,6 +125,10 @@ class Product extends CommonObject
//! Canevas a utiliser si le produit n'est pas un produit generique
var $canvas;
+ var $import_key;
+ var $date_creation;
+ var $date_modification;
+
//! Id du fournisseur
var $product_fourn_id;
@@ -184,9 +189,9 @@ 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 User making insert
+ * @param int $notrigger Disable triggers
+ * @return int Id of product/service if OK or number of error < 0
*/
function create($user,$notrigger=0)
{
@@ -251,6 +256,7 @@ class Product extends CommonObject
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);
+ $now=dol_now();
$this->db->begin();
@@ -283,7 +289,7 @@ class Product extends CommonObject
$sql.= ", canvas";
$sql.= ", finished";
$sql.= ") VALUES (";
- $sql.= $this->db->idate(mktime());
+ $sql.= $this->db->idate($now);
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->ref."'";
$sql.= ", ".price2num($price_min_ht);
@@ -353,7 +359,8 @@ class Product extends CommonObject
else
{
// Product already exists with this ref
- $langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
+ $langs->load("products");
+ $this->error = $langs->transnoentitiesnoconv("ErrorProductAlreadyExists",$this->ref);
}
}
else
@@ -387,9 +394,9 @@ class Product extends CommonObject
/**
* Update a record into database
*
- * @param id Id of product
- * @param user Object user making update
- * @return int 1 if OK, -1 if ref already exists, -2 if other error
+ * @param int $id Id of product
+ * @param User $user Object user making update
+ * @return int 1 if OK, -1 if ref already exists, -2 if other error
*/
function update($id, $user)
{
@@ -512,11 +519,11 @@ class Product extends CommonObject
$this->db->begin();
// Delete supplier prices log
- if (! $error)
+ /*if (! $error)
{
$sql = 'DELETE pfpl';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price_log as pfpl, '.MAIN_DB_PREFIX.'product_fournisseur as pf';
- $sql.= ' WHERE pfpl.fk_product_fournisseur = pf.rowid';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price_log as pfpl, '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
+ $sql.= ' WHERE pfpl.fk_product_fournisseur = pfp.rowid';
$sql.= ' AND pf.fk_product = '.$id;
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
$result = $this->db->query($sql);
@@ -526,15 +533,14 @@ class Product extends CommonObject
$this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
}
- }
+ }*/
// Delete supplier prices
if (! $error)
{
$sql = 'DELETE pfp';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp, '.MAIN_DB_PREFIX.'product_fournisseur as pf';
- $sql.= ' WHERE pfp.fk_product_fournisseur = pf.rowid';
- $sql.= ' AND pf.fk_product = '.$id;
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
+ $sql.= ' WHERE pfp.fk_product = '.$id;
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result)
@@ -564,25 +570,23 @@ class Product extends CommonObject
}
}
+ // Removed extrafields
+ //$result=$this->deleteExtraFields($this);
+ //if ($result < 0) $error++;
+
if (! $error)
{
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
- $hookmanager->callHooks(array('product_extrafields'));
+ $hookmanager->callHooks(array('product'));
$parameters=array(); $action='delete';
- $reshook=$hookmanager->executeHooks('deleteExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ $reshook=$hookmanager->executeHooks('deleteProduct',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($hookmanager->error))
{
$error++;
$this->error=$hookmanager->error;
}
- else if (empty($reshook))
- {
- // TODO
- //$result=$this->deleteExtraFields($this);
- //if ($result < 0) $error++;
- }
}
// Delete product
@@ -812,10 +816,9 @@ class Product extends CommonObject
{
$result = 0;
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity,";
- $sql.= " pf.fk_product, pf.ref_fourn";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product_fournisseur as pf";
- $sql.= " WHERE pf.rowid = pfp.fk_product_fournisseur";
- $sql.= " AND pfp.rowid = ".$prodfournprice;
+ $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
+ $sql.= " WHERE pfp.rowid = ".$prodfournprice;
$sql.= " AND pfp.quantity <= ".$qty;
dol_syslog("Product::get_buyprice sql=".$sql);
@@ -834,13 +837,12 @@ class Product extends CommonObject
else
{
// On refait le meme select sur la ref et l'id du produit
- $sql = "SELECT pfp.price as price, pfp.quantity as quantity, pf.fk_soc,";
- $sql.= " pf.fk_product, pf.ref_fourn";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product_fournisseur as pf";
- $sql.= " WHERE pf.rowid = pfp.fk_product_fournisseur";
- $sql.= " AND pf.ref_fourn = '".$fourn_ref."'";
- $sql.= " AND pf.fk_product = ".$product_id;
- $sql.= " AND quantity <= ".$qty;
+ $sql = "SELECT pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,";
+ $sql.= " pfp.fk_product, pfp.ref_fourn";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
+ $sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'";
+ $sql.= " AND pfp.fk_product = ".$product_id;
+ $sql.= " AND pfp.quantity <= ".$qty;
$sql.= " ORDER BY pfp.quantity DESC";
$sql.= " LIMIT 1";
@@ -997,21 +999,21 @@ class Product extends CommonObject
/**
* Load a product in memory from database
*
- * @param id Id of product/service to load
- * @param ref Ref of product/service to load
- * @return int <0 if KO, >0 if OK
+ * @param int $id Id of product/service to load
+ * @param string $ref Ref of product/service to load
+ * @param string $ref_ext Ref ext of product/service to load
+ * @return int <0 if KO, >0 if OK
*/
- function fetch($id='',$ref='')
+ function fetch($id='',$ref='',$ref_ext='')
{
include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php');
- global $langs;
- global $conf;
+ global $langs, $conf;
- dol_syslog("Product::fetch id=$id ref=$ref");
+ dol_syslog("Product::fetch id=$id ref=$ref ref_ext=$ref_ext");
// Check parameters
- if (! $id && ! $ref)
+ if (! $id && ! $ref && ! $ref_ext)
{
$this->error=$langs->trans('ErrorWrongParameters');
dol_print_error("Product::fetch ".$this->error, LOG_ERR);
@@ -1023,10 +1025,11 @@ class Product extends CommonObject
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
- $sql.= " import_key";
+ $sql.= " datec, tms, import_key";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
if ($id) $sql.= " WHERE rowid = '".$id."'";
else if ($ref) $sql.= " WHERE ref = '".$this->db->escape($ref)."'";
+ else if ($ref_ext) $sql.= " WHERE ref_ext = '".$this->db->escape($ref_ext)."'";
dol_syslog("Product::fetch sql=".$sql);
$resql = $this->db->query($sql);
@@ -1042,6 +1045,11 @@ class Product extends CommonObject
$this->label = $object->label;
$this->description = $object->description;
$this->note = $object->note;
+
+ $this->type = $object->fk_product_type;
+ $this->status = $object->tosell;
+ $this->status_buy = $object->tobuy;
+
$this->customcode = $object->customcode;
$this->country_id = $object->fk_country;
$this->country_code = getCountry($this->country_id,2,$this->db);
@@ -1057,14 +1065,10 @@ class Product extends CommonObject
$this->localtax1_tx = $object->localtax1_tx;
$this->localtax2_tx = $object->localtax2_tx;
- $this->type = $object->fk_product_type;
- $this->status = $object->tosell;
- $this->status_buy = $object->tobuy;
$this->finished = $object->finished;
$this->duration = $object->duration;
$this->duration_value = substr($object->duration,0,dol_strlen($object->duration)-1);
$this->duration_unit = substr($object->duration,-1);
- $this->seuil_stock_alerte = $object->seuil_stock_alerte;
$this->canvas = $object->canvas;
$this->weight = $object->weight;
$this->weight_units = $object->weight_units;
@@ -1080,9 +1084,12 @@ class Product extends CommonObject
$this->accountancy_code_buy = $object->accountancy_code_buy;
$this->accountancy_code_sell= $object->accountancy_code_sell;
+ $this->seuil_stock_alerte = $object->seuil_stock_alerte;
$this->stock_reel = $object->stock;
$this->pmp = $object->pmp;
+ $this->date_creation = $object->datec;
+ $this->date_modification = $object->tms;
$this->import_key = $object->import_key;
$this->db->free($resql);
@@ -1751,74 +1758,99 @@ class Product extends CommonObject
/**
- * Add a supplier reference for the product
+ * Add a supplier price for the product.
+ * Note: Duplicate ref is accepted for different quantity only or for different companies.
*
- * @param user User that make link
- * @param id_fourn Supplier id
- * @param ref_fourn Supplier ref
- * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK
+ * @param User $user User that make link
+ * @param int $id_fourn Supplier id
+ * @param string $ref_fourn Supplier ref
+ * @param float $quantity Quantity minimum for price
+ * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK
*/
- function add_fournisseur($user, $id_fourn, $ref_fourn)
+ function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity)
{
global $conf;
- $sql = "SELECT rowid, fk_product";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
+ $now=dol_now();
+
+ if ($ref_fourn)
+ {
+ $sql = "SELECT rowid, fk_product";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
+ $sql.= " WHERE fk_soc = ".$id_fourn;
+ $sql.= " AND ref_fourn = '".$ref_fourn."'";
+ $sql.= " AND fk_product != ".$this->id;
+ $sql.= " AND entity = ".$conf->entity;
+
+ dol_syslog(get_class($this)."::add_fournisseur sql=".$sql);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ if ($obj)
+ {
+ // If the supplier ref already exists but for another product (duplicate ref is accepted for different quantity only or different companies)
+ $this->product_id_already_linked = $obj->fk_product;
+ return -3;
+ }
+ $this->db->free($resql);
+ }
+ }
+
+ $sql = "SELECT rowid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE fk_soc = ".$id_fourn;
- $sql.= " AND ref_fourn = '".$ref_fourn."'";
+ if ($ref_fourn) $sql.= " AND ref_fourn = '".$ref_fourn."'";
+ else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)";
+ $sql.= " AND quantity = '".$quantity."'";
+ $sql.= " AND fk_product = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
- dol_syslog("Product::add_fournisseur sql=".$sql);
+ dol_syslog(get_class($this)."::add_fournisseur sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
- $obj = $this->db->fetch_object($resql);
+ $obj = $this->db->fetch_object($resql);
- // The reference supplier does not exist, we create it for this product.
+ // The reference supplier does not exist, we create it for this product.
if (! $obj)
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur (";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
$sql.= "datec";
$sql.= ", entity";
$sql.= ", fk_product";
$sql.= ", fk_soc";
$sql.= ", ref_fourn";
- $sql.= ", fk_user_author";
+ $sql.= ", quantity";
+ $sql.= ", fk_user";
$sql.= ") VALUES (";
- $sql.= $this->db->idate(mktime());
+ $sql.= "'".$this->db->idate($now)."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".$this->id;
$sql.= ", ".$id_fourn;
$sql.= ", '".$ref_fourn."'";
+ $sql.= ", ".$quantity;
$sql.= ", ".$user->id;
$sql.= ")";
dol_syslog("Product::add_fournisseur sql=".$sql);
if ($this->db->query($sql))
{
- $this->product_fourn_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur");
+ $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");
return 1;
}
else
{
$this->error=$this->db->lasterror();
- dol_syslog("Product::add_fournisseur ".$this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::add_fournisseur ".$this->error, LOG_ERR);
return -1;
}
}
- // If the supplier ref already exists for this product
- else if ($obj->fk_product == $this->id)
- {
- $this->product_fourn_id = $obj->rowid;
-
- return 0;
- }
- // If the supplier ref already exists but for another product
+ // If the supplier price already exists for this product and quantity
else
{
- $this->product_id_already_linked = $obj->fk_product;
-
- return -3;
+ $this->product_fourn_price_id = $obj->rowid;
+ return 0;
}
}
else
@@ -1840,8 +1872,8 @@ class Product extends CommonObject
$list = array();
- $sql = "SELECT fk_soc";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as p";
+ $sql = "SELECT p.fk_soc";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p";
$sql.= " WHERE p.fk_product = ".$this->id;
$sql.= " AND p.entity = ".$conf->entity;
@@ -1913,16 +1945,16 @@ class Product extends CommonObject
/**
* Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre
*
- * @param fromId Id produit source
- * @param toId Id produit cible
- * @return int < 0 si erreur, > 0 si ok
+ * @param int $fromId Id produit source
+ * @param int $toId Id produit cible
+ * @return int < 0 si erreur, > 0 si ok
*/
function clone_fournisseurs($fromId, $toId)
{
$this->db->begin();
// les fournisseurs
- $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur ("
+ /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur ("
. " datec, fk_product, fk_soc, ref_fourn, fk_user_author )"
. " SELECT '".$this->db->idate(mktime())."', ".$toId.", fk_soc, ref_fourn, fk_user_author"
. " FROM ".MAIN_DB_PREFIX."product_fournisseur"
@@ -1932,7 +1964,7 @@ class Product extends CommonObject
{
$this->db->rollback();
return -1;
- }
+ }*/
// les prix de fournisseurs.
$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("
@@ -1941,13 +1973,17 @@ class Product extends CommonObject
. " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"
. " WHERE fk_product = ".$fromId;
- if ( ! $this->db->query($sql ) )
+ $resql=$this->db->query($sql);
+ if (! $resql)
{
$this->db->rollback();
return -1;
}
- $this->db->commit();
- return 1;
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
}
/**
@@ -2905,5 +2941,30 @@ class Product extends CommonObject
}
}
+ /**
+ * Initialise an instance with random values.
+ * Used to build previews or test instances.
+ * id must be 0 if object instance is a specimen.
+ *
+ * @return void
+ */
+ function initAsSpecimen()
+ {
+ global $user,$langs,$conf,$mysoc;
+
+ $now=dol_now();
+
+ // Initialize parameters
+ $this->id=0;
+ $this->ref = 'PRODUCT_SPEC';
+ $this->libelle = 'PRODUCT SPECIMEN';
+ $this->description = 'PRODUCT SPECIMEN '.dol_print_date($now,'dayhourlog');
+ $this->specimen=1;
+ $this->country_id=1;
+ $this->tosell=1;
+ $this->tobuy=1;
+ $this->type=0;
+ $this->note='This is a comment (private)';
+ }
}
?>
\ No newline at end of file
diff --git a/htdocs/product/composition/fiche.php b/htdocs/product/composition/fiche.php
index d3707e569bd..f5a254e650f 100644
--- a/htdocs/product/composition/fiche.php
+++ b/htdocs/product/composition/fiche.php
@@ -123,7 +123,7 @@ if ($cancel == $langs->trans("Cancel"))
*/
// action recherche des produits par mot-cle et/ou par categorie
-if($action == 'search' )
+if ($action == 'search')
{
$current_lang = $langs->getDefaultLang();
@@ -174,9 +174,9 @@ dol_fiche_head($head, 'subproduct', $titre, 0, $picto);
if ($id || $ref)
{
- if ( $result )
+ if ($result)
{
- if ($action <> 'edit' &&$action <> 'search' && $action <> 're-edit')
+ if ($action <> 'edit' && $action <> 'search' && $action <> 're-edit')
{
/*
* En mode visu
@@ -209,7 +209,7 @@ if ($id || $ref)
// List of subproducts
$prods_arbo = $product->get_arbo_each_prod();
- if(count($prods_arbo) > 0)
+ if (count($prods_arbo) > 0)
{
print '';
print ''.$langs->trans("ProductAssociationList").' ';
@@ -236,7 +236,7 @@ if ($id || $ref)
// Number of parent products
print ' '.$langs->trans("ParentProductsNumber").' '.count($prodsfather).' ';
- if(count($prodsfather) > 0)
+ if (count($prodsfather) > 0)
{
print '';
print ''.$langs->trans("ProductParentList").' ';
@@ -321,7 +321,7 @@ if ($id || $ref)
// Number of parent products
print ' '.$langs->trans("ParentProductsNumber").' '.count($prodsfather).' ';
- if(count($prodsfather) > 0)
+ if (count($prodsfather) > 0)
{
print '';
print ''.$langs->trans("ProductParentList").' ';
@@ -375,7 +375,7 @@ if ($id || $ref)
print '