New: show thirdparty barcode on main tab.

This commit is contained in:
Laurent Destailleur 2011-12-07 15:06:29 +01:00
parent 740c24e991
commit 66856fee75
7 changed files with 143 additions and 99 deletions

View File

@ -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.

View File

@ -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
*

View File

@ -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 ='<!-- url barcode = '.$url.' -->';
$out.='<img src="'.$url.'">';
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)
{

View File

@ -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='<!-- url barcode = '.$url.' -->';
$out.='<img src="'.$url.'">';
return $out;
}
/**
* Retourne tableau de toutes les photos du produit
*

View File

@ -1029,7 +1029,7 @@ else
print '<td valign="middle" align="center" width="25%" rowspan="'.$nblignes.'">';
if ($showphoto) print $object->show_photos($conf->product->dir_output,1,1,0,0,0,80);
if ($showphoto && $showbarcode) print '<br><br>';
if ($showbarcode) print $object->show_barcode();
if ($showbarcode) print $form->showbarcode($object);
print '</td>';
}
@ -1037,9 +1037,6 @@ else
if ($showbarcode)
{
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formbarcode.class.php");
$formbarcode = new FormBarCode($db);
// Barcode type
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
@ -1050,10 +1047,13 @@ else
print '</td><td colspan="2">';
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:'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>';
}
print '</td></tr>'."\n";

View File

@ -74,7 +74,13 @@ class Societe extends CommonObject
var $fax;
var $email;
var $url;
var $barcode;
//! 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)
// 4 identifiants professionnels (leur utilisation depend du pays)
var $siren; // IdProf1 - Deprecated
@ -142,13 +148,13 @@ class Societe extends CommonObject
/**
* Constructor
*
* @param DoliDB $DB Database handler
* @param DoliDB $db Database handler
*/
public function Societe($DB)
public function Societe($db)
{
global $conf;
$this->db = $DB;
$this->db = $db;
$this->client = 0;
$this->prospect = 0;
@ -176,7 +182,7 @@ class Societe extends CommonObject
global $langs,$conf;
$error=0;
// Clean parameters
if (empty($this->status)) $this->status=0;
$this->name=$this->name?trim($this->name):trim($this->nom);
@ -2357,7 +2363,7 @@ class Societe extends CommonObject
/**
* Create a third party into database from a member object
*
*
* @param member Object member
* @param socname Name of third party to force
* @return int <0 if KO, id of created account if OK

View File

@ -1193,11 +1193,6 @@ else
}
}
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$object->status);
print '</td></tr>';
// Barcode
if ($conf->global->MAIN_MODULE_BARCODE)
{
@ -1205,6 +1200,11 @@ else
print '</td></tr>';
}
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$object->status);
print '</td></tr>';
// Address
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
print $object->address;
@ -1442,6 +1442,9 @@ else
dol_htmloutput_errors($error,$errors);
$showlogo=$object->logo;
$showbarcode=($conf->barcode->enabled && $user->rights->barcode->lire);
print '<table class="border" width="100%">';
// Ref
@ -1460,84 +1463,89 @@ else
print '</td>';
print '</tr>';
// Logo
// Logo+barcode
$rowspan=4;
if (! empty($conf->global->SOCIETE_USEPREFIX)) $rowspan++;
if ($object->client) $rowspan++;
if ($conf->fournisseur->enabled && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) $rowspan++;
if ($conf->global->MAIN_MODULE_BARCODE) $rowspan++;
if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++;
$showlogo='';
if ($object->logo)
$htmllogobar='';
if ($showlogo || $showbarcode)
{
$showlogo.='<td rowspan="'.$rowspan.'" style="text-align: center;" width="25%">';
$showlogo.=$form->showphoto('societe',$object,50);
$showlogo.='</td>';
$htmllogobar.='<td rowspan="'.$rowspan.'" style="text-align: center;" width="25%">';
if ($showlogo) $htmllogobar.=$form->showphoto('societe',$object,50);
if ($showlogo && $showbarcode) $htmllogobar.='<br><br>';
if ($showbarcode) $htmllogobar.=$form->showbarcode($object,50);
$htmllogobar.='</td>';
}
// Prefix
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="'.(2+($object->logo?0:1)).'">'.$object->prefix_comm.'</td>';
print $showlogo; $showlogo='';
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">'.$object->prefix_comm.'</td>';
print $htmllogobar; $htmllogobar='';
print '</tr>';
}
// Customer code
if ($object->client)
{
print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td colspan="'.(2+($object->logo?0:1)).'">';
print $langs->trans('CustomerCode').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">';
print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td>';
print $showlogo; $showlogo='';
print $htmllogobar; $htmllogobar='';
print '</tr>';
}
// Supplier code
if ($conf->fournisseur->enabled && $object->fournisseur && ! empty($user->rights->fournisseur->lire))
{
print '<tr><td>';
print $langs->trans('SupplierCode').'</td><td colspan="'.(2+($object->logo?0:1)).'">';
print $langs->trans('SupplierCode').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">';
print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td>';
print $showlogo; $showlogo='';
print $htmllogobar; $htmllogobar='';
print '</tr>';
}
// Status
print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td colspan="'.(2+($object->logo?0:1)).'">';
print $object->getLibStatut(2);
print '</td>';
print $showlogo; $showlogo='';
print '</tr>';
// Barcode
if ($conf->global->MAIN_MODULE_BARCODE)
{
print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="'.(2+($object->logo?0:1)).'">'.$object->barcode.'</td></tr>';
print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">'.$object->barcode.'</td></tr>';
}
// Status
print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">';
print $object->getLibStatut(2);
print '</td>';
print $htmllogobar; $htmllogobar='';
print '</tr>';
// Address
print "<tr><td valign=\"top\">".$langs->trans('Address').'</td><td colspan="'.(2+($object->logo?0:1)).'">';
print "<tr><td valign=\"top\">".$langs->trans('Address').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">';
dol_print_address($object->address,'gmap','thirdparty',$object->id);
print "</td></tr>";
// Zip / Town
print '<tr><td width="25%">'.$langs->trans('Zip').' / '.$langs->trans("Town").'</td><td colspan="'.(2+($object->logo?0:1)).'">';
print '<tr><td width="25%">'.$langs->trans('Zip').' / '.$langs->trans("Town").'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">';
print $object->cp.($object->cp && $object->ville?" / ":"").$object->ville;
print "</td>";
print '</tr>';
// Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="'.(2+($object->logo?0:1)).'" nowrap="nowrap">';
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'" nowrap="nowrap">';
$img=picto_from_langcode($object->pays_code);
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->pays,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->pays;
print '</td></tr>';
// State
if (empty($conf->global->SOCIETE_DISABLE_STATE)) print '<tr><td>'.$langs->trans('State').'</td><td colspan="'.(2+($object->logo?0:1)).'">'.$object->state.'</td>';
if (empty($conf->global->SOCIETE_DISABLE_STATE)) print '<tr><td>'.$langs->trans('State').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">'.$object->state.'</td>';
print '<tr><td>'.$langs->trans('Phone').'</td><td style="min-width: 25%;">'.dol_print_phone($object->tel,$object->pays_code,0,$object->id,'AC_TEL').'</td>';
print '<td>'.$langs->trans('Fax').'</td><td style="min-width: 25%;">'.dol_print_phone($object->fax,$object->pays_code,0,$object->id,'AC_FAX').'</td></tr>';