New: Add a public url as a property for products/services.

This commit is contained in:
Laurent Destailleur 2014-03-14 13:51:46 +01:00
parent aab4800f87
commit 4154f07dfd
7 changed files with 34 additions and 10 deletions

View File

@ -33,6 +33,7 @@ For users:
- New: Status "validated" for project are renamed into "opened".
- New: Add barcode fields into user database.
- New: Add manager name (ceo, director, president...) into main company information page.
- New: Add field url as product properties.
- Fix: Project Task numbering customs rule works.
TODO

View File

@ -6,7 +6,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Christophe Battarel <contact@altairis.fr>
* Copyright (C) 2014 Cédric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
*
* 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
@ -153,15 +153,15 @@ class modProduct extends DolibarrModules
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r]=array(array("produit","export"));
$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.pmp'=>'PMPValue'));
if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode'));
if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'SuppliersPrices'));
$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Number",'p.surface'=>"Number",'p.volume'=>"Number",'p.weight'=>"Number",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date');
$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Number",'p.surface'=>"Number",'p.volume'=>"Number",'p.weight'=>"Number",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date');
if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.pmp'=>'Number'));
if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text'));
if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Number'));
$this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_sell'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.customcode'=>'product','p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.tosell'=>"product",'p.tobuy'=>"product",'p.datec'=>"product",'p.tms'=>"product");
$this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.url'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_sell'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.customcode'=>'product','p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.tosell'=>"product",'p.tobuy'=>"product",'p.datec'=>"product",'p.tms'=>"product");
if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product'));
if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product'));
if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'product','pf.ref_fourn'=>'product','pf.unitprice'=>'product'));
@ -218,7 +218,7 @@ class modProduct extends DolibarrModules
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields');
$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation*');
$this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation*');
// Add extra fields
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity = ".$conf->entity;
$resql=$this->db->query($sql);

View File

@ -996,6 +996,8 @@ ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_customer_price_fk_soc F
ALTER TABLE llx_user ADD COLUMN barcode varchar(255) DEFAULT NULL;
ALTER TABLE llx_user ADD COLUMN fk_barcode_type integer DEFAULT 0;
ALTER TABLE llx_product ADD COLUMN url varchar(255);
create table llx_product_customer_price_log
(
rowid integer AUTO_INCREMENT PRIMARY KEY,

View File

@ -54,6 +54,7 @@ create table llx_product
fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module)
duration varchar(6),
seuil_stock_alerte integer DEFAULT 0,
url varchar(255),
barcode varchar(255) DEFAULT NULL,
fk_barcode_type integer DEFAULT 0,
accountancy_code_sell varchar(15), -- Selling accountancy code

View File

@ -667,6 +667,7 @@ OriginFileName=Original filename
SetDemandReason=Set source
ViewPrivateNote=View notes
XMoreLines=%s line(s) hidden
PublicUrl=Public URL
# Week day
Monday=Monday

View File

@ -610,7 +610,8 @@ class Product extends CommonObject
$sql.= ", volume_units = " . ($this->volume_units!='' ? "'".$this->volume_units."'" : 'null');
$sql.= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->seuil_stock_alerte."'" : "null");
$sql.= ", description = '" . $this->db->escape($this->description) ."'";
$sql.= ", customcode = '" . $this->db->escape($this->customcode) ."'";
$sql.= ", url = " . ($this->url?"'".$this->db->escape($this->url)."'":'');
$sql.= ", customcode = '" . $this->db->escape($this->customcode) ."'";
$sql.= ", fk_country = " . ($this->country_id > 0 ? $this->country_id : 'null');
$sql.= ", note = '" . $this->db->escape($this->note) ."'";
$sql.= ", duration = '" . $this->duration_value . $this->duration_unit ."'";
@ -1277,7 +1278,7 @@ class Product extends CommonObject
return -1;
}
$sql = "SELECT rowid, ref, label, description, note, customcode, fk_country, price, price_ttc,";
$sql = "SELECT rowid, ref, label, description, url, note, customcode, fk_country, price, price_ttc,";
$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell,";
$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,";
@ -1305,6 +1306,7 @@ class Product extends CommonObject
$this->libelle = $obj->label; // TODO deprecated
$this->label = $obj->label;
$this->description = $obj->description;
$this->url = $obj->url;
$this->note = $obj->note;
$this->type = $obj->fk_product_type;

View File

@ -203,8 +203,9 @@ if (empty($reshook))
$object->barcode_type = GETPOST('fk_barcode_type');
$object->barcode = GETPOST('barcode');
$object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url');
$object->note = dol_htmlcleanlastbr(GETPOST('note'));
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
@ -278,6 +279,7 @@ if (empty($reshook))
$object->ref = $ref;
$object->libelle = GETPOST('libelle');
$object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url');
$object->note = dol_htmlcleanlastbr(GETPOST('note'));
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
@ -805,11 +807,16 @@ else
// Description (used in invoice, propal...)
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
$doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 90);
$doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor->Create();
print "</td></tr>";
// Public URL
print '<tr><td valign="top">'.$langs->trans("PublicUrl").'</td><td colspan="3">';
print '<input type="text" name="url" size="90" value="'.GETPOST('url').'">';
print '</td></tr>';
// Stock min level
if ($type != 1 && ! empty($conf->stock->enabled))
{
@ -1057,13 +1064,18 @@ else
// Description (used in invoice, propal...)
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
// We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
// We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
$doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor->Create();
print "</td></tr>";
print "\n";
// Public Url
print '<tr><td valign="top">'.$langs->trans("PublicUrl").'</td><td colspan="3">';
print '<input type="text" name="url" size="80" value="'.$object->url.'">';
print '</td></tr>';
// Stock
if ($object->isproduct() && ! empty($conf->stock->enabled))
{
@ -1322,6 +1334,11 @@ else
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">'.(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)).'</td></tr>';
// Public URL
print '<tr><td valign="top">'.$langs->trans("PublicUrl").'</td><td colspan="2">';
print dol_print_url($object->url);
print '</td></tr>';
// Nature
if($object->type!=1)
{