diff --git a/ChangeLog b/ChangeLog
index 09f19a0890d..fc8b21bc25a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.2 compared to 3.1 *****
For users:
+- New: show thirdparty barcode on main tab.
- New: Can input note (private and public) during note and expenses creation.
- New: Print ticket show invoice ref into POS module.
- New: Can edit customer discounts from invoice create and edit card.
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 9af3ec03256..bbb52cb840e 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -82,7 +82,7 @@ abstract class CommonObject
global $user,$conf,$langs;
$error=0;
-
+
dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source");
// Check parameters
@@ -203,7 +203,7 @@ abstract class CommonObject
global $user,$langs,$conf;
$error=0;
-
+
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql.= " WHERE rowid =".$rowid;
@@ -510,6 +510,54 @@ abstract class CommonObject
return $result;
}
+
+ /**
+ * Load data for barcode
+ *
+ * @return int <0 if KO, >=0 if OK
+ */
+ function fetch_barcode()
+ {
+ global $conf;
+
+ dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type);
+
+ $idtype=$this->barcode_type;
+ if (! $idtype)
+ {
+ if ($this->element == 'product') $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
+ else if ($this->element == 'societe') $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY;
+ else dol_print_error('','Call fetch_barcode with barcode_type not defined and cant be guessed');
+ }
+
+ if ($idtype > 0)
+ {
+ if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) // If data not already loaded
+ {
+ $sql = "SELECT rowid, code, libelle as label, coder";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
+ $sql.= " WHERE rowid = ".$idtype;
+ dol_syslog(get_class($this).'::fetch_barcode sql='.$sql);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $this->barcode_type = $obj->rowid;
+ $this->barcode_type_code = $obj->code;
+ $this->barcode_type_label = $obj->label;
+ $this->barcode_type_coder = $obj->coder;
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+ }
+ else return 0;
+ }
+
/**
* Charge le projet d'id $this->fk_project dans this->projet
*
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 7953349e9a8..12435ea1070 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1365,7 +1365,7 @@ class Form
{
global $langs,$conf;
global $price_level, $status, $finished;
-
+
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
{
// mode=2 means suppliers products
@@ -3659,13 +3659,39 @@ class Form
}
+ /**
+ * Return HTML code to output a barcode
+ *
+ * @param Object &$object Object containing data to retrieve file name
+ * @param int $width Width of photo
+ * @return string HTML code to output barcode
+ */
+ function showbarcode(&$object,$width=100)
+ {
+ global $conf;
+
+ if (empty($object->barcode)) return '';
+
+ // Complete object if not complete
+ if (empty($object->barcode_type_code) || empty($object->barcode_type_coder))
+ {
+ $object->fetch_barcode();
+ }
+
+ // Barcode image
+ $url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($object->barcode_type_coder).'&code='.urlencode($object->barcode).'&encoding='.urlencode($object->barcode_type_code);
+ $out ='';
+ $out.='';
+ return $out;
+ }
+
/**
* Return HTML code to output a photo
*
- * @param modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
- * @param object Object containing data to retrieve file name
- * @param width Width of photo
- * @return string HTML code to output photo
+ * @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
+ * @param Object $object Object containing data to retrieve file name
+ * @param int $width Width of photo
+ * @return string HTML code to output photo
*/
function showphoto($modulepart,$object,$width=100)
{
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index c85b1af7357..fda5c9bd9d8 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -105,12 +105,12 @@ class Product extends CommonObject
var $accountancy_code_buy;
var $accountancy_code_sell;
- //! Codes barres
- var $barcode;
- var $barcode_type;
- var $barcode_type_code;
- var $barcode_type_label;
- var $barcode_type_coder;
+ //! barcode
+ var $barcode; // value
+ var $barcode_type; // id
+ var $barcode_type_code; // code (loaded by fetch_barcode)
+ var $barcode_type_label; // label (loaded by fetch_barcode)
+ var $barcode_type_coder; // coder (loaded by fetch_barcode)
var $stats_propale=array();
var $stats_commande=array();
@@ -1100,35 +1100,6 @@ class Product extends CommonObject
// multilangs
if ($conf->global->MAIN_MULTILANGS) $this->getMultiLangs();
- // Barcode
- if ($conf->global->MAIN_MODULE_BARCODE)
- {
- if ($this->barcode_type == 0)
- {
- $this->barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
- }
-
- if ($this->barcode_type > 0)
- {
- $sql = "SELECT code, libelle, coder";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
- $sql.= " WHERE rowid = ".$this->barcode_type;
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $result = $this->db->fetch_array($resql);
- $this->barcode_type_code = $result["code"];
- $this->barcode_type_label = $result["libelle"];
- $this->barcode_type_coder = $result["coder"];
- }
- else
- {
- dol_print_error($this->db);
- return -1;
- }
- }
- }
-
// Load multiprices array
if ($conf->global->PRODUIT_MULTIPRICES)
{
@@ -2547,7 +2518,7 @@ class Product extends CommonObject
/**
- * Show photos of a product (nbmax maximum)
+ * Show photos of a product (nbmax maximum), into several columns
* TODO Move this into html.formproduct.class.php
*
* @param sdir Directory to scan
@@ -2715,22 +2686,6 @@ class Product extends CommonObject
}
- /**
- * Show barcode of a product (nbmax maximum)
- *
- * @return string Html code to show barcode.
- * TODO Move this into html.formproduct.class.php
- */
- function show_barcode()
- {
- // Barcode image
- $url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($this->barcode_type_coder).'&code='.urlencode($this->barcode).'&encoding='.urlencode($this->barcode_type_code);
- $out='';
- $out.='
';
- return $out;
- }
-
-
/**
* Retourne tableau de toutes les photos du produit
*
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 0ef422de0fe..66f6bf0afb7 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -1029,7 +1029,7 @@ else
print '
| '; @@ -1050,10 +1047,13 @@ else print ' | ';
if ($_GET['action'] == 'editbarcodetype')
{
+ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formbarcode.class.php");
+ $formbarcode = new FormBarCode($db);
$formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'barcodetype_id');
}
else
{
+ $object->fetch_barcode();
print $object->barcode_type_label?$object->barcode_type_label:' '.$langs->trans("SetDefaultBarcodeType").' ';
}
print ' | ||
| '.$langs->trans("Status").' | '; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$object->status); - print ' | ||
| '.$langs->trans("Status").' | '; + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$object->status); + print ' | ||
| '.$langs->trans('Address').' | |||