Skip to content

Commit

Permalink
Can export BOMs
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 27, 2019
1 parent 83a5cfb commit afa3ed4
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 98 deletions.
2 changes: 1 addition & 1 deletion htdocs/bom/class/bom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ class BOMLine extends CommonObject
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
'rowid' => array('type'=>'integer', 'label'=>'LineID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1,),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/commonfieldsinexport.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
dol_print_error('', 'include of file commonfieldsinexport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set');
exit;
}
if (empty($keyforalias)) $keyforalias = 't';

dol_include_once($keyforclassfile);
if (class_exists($keyforclass))
Expand All @@ -15,7 +16,7 @@
// Add common fields
foreach($tmpobject->fields as $keyfield => $valuefield)
{
$fieldname = 't' . '.' . $keyfield;
$fieldname = $keyforalias . '.' . $keyfield;
$fieldlabel = ucfirst($valuefield['label']);
$typeFilter = "Text";
$typefield=preg_replace('/\(.*$/', '', $valuefield['type']); // double(24,8) -> double
Expand Down
21 changes: 13 additions & 8 deletions htdocs/core/modules/modBom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,26 @@ public function __construct($db)
$r=1;

/* BEGIN MODULEBUILDER EXPORT BILLOFMATERIALS */
/*
$langs->load("mrp@mrp");
$langs->load("mrp");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='BomLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_label[$r]='BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='bom';
$keyforclass = 'Bom'; $keyforclassfile='/mymobule/class/bom.class.php'; $keyforelement='bom';
$keyforclass = 'BOM'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bom';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='bom'; $keyforaliasextra='extra'; $keyforelement='bom';
$keyforclass = 'BOMLine'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bomline'; $keyforalias='tl';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
unset($this->export_fields_array[$r]['tl.fk_bom']);
$keyforselect ='bom_bom'; $keyforaliasextra='extra'; $keyforelement='bom';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$keyforselect ='bom_bomline'; $keyforaliasextra='extraline'; $keyforelement='bomline';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_dependencies_array[$r]=array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bom as t';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bom_bom as t';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('bom').')';
$r++; */
$r++;
/* END MODULEBUILDER EXPORT BILLOFMATERIALS */
}

Expand Down
22 changes: 0 additions & 22 deletions htdocs/core/modules/modDav.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,6 @@ public function __construct($db)
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
END MODULEBUILDER LEFTMENU MYOBJECT */


// Exports
$r=1;

/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
/*
$langs->load("dav@dav");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@dav';
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
/* END MODULEBUILDER EXPORT MYOBJECT */
}

/**
Expand Down
22 changes: 0 additions & 22 deletions htdocs/core/modules/modEmailCollector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,28 +252,6 @@ public function __construct($db)
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
END MODULEBUILDER LEFTMENU MYOBJECT */


// Exports
$r=1;

/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
/*
$langs->load("dav@dav");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@dav';
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
/* END MODULEBUILDER EXPORT MYOBJECT */
}

/**
Expand Down
22 changes: 0 additions & 22 deletions htdocs/core/modules/modTakePos.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,6 @@ public function __construct($db)
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
END MODULEBUILDER LEFTMENU MYOBJECT */


// Exports
$r=1;

/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
/*
$langs->load("cashdesk");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@takepos';
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
/* END MODULEBUILDER EXPORT MYOBJECT */
}

/**
Expand Down
1 change: 0 additions & 1 deletion htdocs/core/modules/modWebsite.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ public function __construct($db)
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
//$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra';
//include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'website_page as t, '.MAIN_DB_PREFIX.'website as p';
$this->export_sql_end[$r] .=' WHERE t.fk_website = p.rowid';
Expand Down
18 changes: 0 additions & 18 deletions htdocs/core/modules/modZapier.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,24 +316,6 @@ public function __construct($db)
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
);
*/
// Exports
$r=1;
/* EXPORT */
/*
$langs->load("zapier@zapier");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@zapier';
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
}

/**
Expand Down
8 changes: 6 additions & 2 deletions htdocs/exports/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
'expensereport_line'=> 'trip',
'holiday' => 'holiday',
'contract_line' => 'contract',
'translation' => 'generic'
'translation' => 'generic',
'bomm' => 'bom',
'bomline' => 'bom'
);

// Translation code
Expand Down Expand Up @@ -120,7 +122,9 @@
'holiday' => 'TitreRequestCP',
'contract' => 'Contract',
'contract_line'=> 'ContractLine',
'translation' => 'Translation'
'translation' => 'Translation',
'bom' => 'BOM',
'bomline' => 'BOMLine'
);

$array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array();
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/main.lang
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ InformationToHelpDiagnose=This information can be useful for diagnostic purposes
MoreInformation=More information
TechnicalInformation=Technical information
TechnicalID=Technical ID
LineID=Line ID
NotePublic=Note (public)
NotePrivate=Note (private)
PrecisionUnitIsLimitedToXDecimals=Dolibarr was setup to limit precision of unit prices to <b>%s</b> decimals.
Expand Down
3 changes: 3 additions & 0 deletions htdocs/langs/en_US/mrp.lang
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to u
ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders)
StatusMOProduced=Produced
QtyFrozen=Frozen Qty
QuantityFrozen=Frozen Quantity
QuantityConsumedInvariable=When this flag is set, the quantity consumed is always the value defined and is not relative to the quantity produced.
DisableStockChange=Disable stock change
DisableStockChangeHelp=When this flag is set, there is no stock change on this product, whatever is the quantity produced
BomAndBomLines=Bills Of Material and lines
BOMLine=Line of BOM
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,16 @@ public function __construct($db)
$this->export_icon[$r]='myobject@mymodule';
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
//$keyforclass = 'MyObjectLine'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobjectline'; $keyforalias='tl';
//include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
//$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline';
//include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('myobjectline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
//$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'myobject_line as tl ON tl.fk_myobject = t.rowid';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
Expand Down

0 comments on commit afa3ed4

Please sign in to comment.