New: More import options. Products categories
This commit is contained in:
parent
7aec227694
commit
425ebae802
@ -63,13 +63,24 @@ class Categorie
|
||||
* Load category into memory from database
|
||||
*
|
||||
* @param int $id Id of category
|
||||
* @param strin $label Label of category
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
function fetch($id,$label='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT rowid, fk_parent, entity, label, description, fk_soc, visible, type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
if ($id)
|
||||
{
|
||||
$sql.= " WHERE rowid = '".$id."'";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ($label) $sql.= " WHERE label = '".$this->db->escape($label)."' AND entity=".$conf->entity;;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -178,6 +178,57 @@ class modCategorie extends DolibarrModules
|
||||
|
||||
$this->import_regex_array[$r]=array('ca.type'=>'^[0|1|2|3]');
|
||||
$this->import_examplevalues_array[$r]=array('ca.label'=>"Supplier Category",'ca.type'=>"1",'ca.description'=>"Imported category");
|
||||
|
||||
if (! empty($conf->product->enabled))
|
||||
{
|
||||
//Products
|
||||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]="CatSupList"; // Translation key
|
||||
$this->import_icon[$r]=$this->picto;
|
||||
$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('cp'=>MAIN_DB_PREFIX.'categorie_product');
|
||||
$this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*"
|
||||
);
|
||||
|
||||
$this->import_convertvalue_array[$r]=array(
|
||||
'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
|
||||
'cp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product')
|
||||
);
|
||||
$this->import_examplevalues_array[$r]=array('cp.fk_categorie'=>"Imported category",'cp.fk_product'=>"PREF123456");
|
||||
}
|
||||
|
||||
//Customers
|
||||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]="Clientes por categoría"; // Translation key
|
||||
$this->import_icon[$r]=$this->picto;
|
||||
$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('co'=>MAIN_DB_PREFIX.'categorie_societe');
|
||||
$this->import_fields_array[$r]=array('co.fk_categorie'=>"Categorie*",'co.fk_societe'=>"Tercero*"
|
||||
);
|
||||
|
||||
$this->import_convertvalue_array[$r]=array(
|
||||
'co.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
|
||||
'co.fk_societe'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty')
|
||||
);
|
||||
$this->import_examplevalues_array[$r]=array('co.fk_categorie'=>"Nombre categoría",'co.fk_societe'=>"Nombre cliente");
|
||||
|
||||
// Suppliers
|
||||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]="Proveedores por categoría"; // Translation key
|
||||
$this->import_icon[$r]=$this->picto;
|
||||
$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('co'=>MAIN_DB_PREFIX.'categorie_fournisseur');
|
||||
$this->import_fields_array[$r]=array('co.fk_categorie'=>"Categorie*",'co.fk_societe'=>"Tercero*"
|
||||
);
|
||||
|
||||
$this->import_convertvalue_array[$r]=array(
|
||||
'co.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
|
||||
'co.fk_societe'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty')
|
||||
);
|
||||
$this->import_examplevalues_array[$r]=array('co.fk_categorie'=>"Nombre categoria",'co.fk_societe'=>"Nombre proveedor");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -772,6 +772,7 @@ ALTER TABLE llx_entrepot ADD COLUMN import_key varchar(14) AFTER fk_user_author;
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN import_key varchar(14) AFTER fk_user;
|
||||
ALTER TABLE llx_product_stock ADD COLUMN import_key varchar(14) AFTER pmp;
|
||||
ALTER TABLE llx_societe_rib ADD COLUMN import_key varchar(14) AFTER adresse_proprio;
|
||||
ALTER TABLE llx_categorie_product ADD COLUMN import_key varchar(14) AFTER fk_product;
|
||||
|
||||
-- Export filter
|
||||
ALTER TABLE llx_export_model ADD COLUMN filter text AFTER field;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2005 Brice Davoleau <e1davole@iu-vannes.fr>
|
||||
-- Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||
-- Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||
-- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
--
|
||||
-- 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
|
||||
@ -20,5 +21,6 @@
|
||||
create table llx_categorie_product
|
||||
(
|
||||
fk_categorie integer NOT NULL,
|
||||
fk_product integer NOT NULL
|
||||
fk_product integer NOT NULL,
|
||||
import_key varchar(14)
|
||||
)ENGINE=innodb;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user