Skip to content

Commit

Permalink
refactor(InventoryModules) move duplicate code to function
Browse files Browse the repository at this point in the history
  • Loading branch information
joebordes committed Jun 1, 2021
1 parent 3d64484 commit b755093
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 112 deletions.
31 changes: 3 additions & 28 deletions modules/Invoice/EditView.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,34 +375,9 @@
$smarty->assign('AVAILABLE_PRODUCTS', 'true');
$smarty->assign('MODE', $focus->mode);
}

$cbMap = cbMap::getMapByName($currentModule.'InventoryDetails', 'MasterDetailLayout');
$smarty->assign('moreinfofields', '');
if ($cbMap!=null && isPermitted('InventoryDetails', 'EditView')=='yes') {
$cbMapFields = $cbMap->MasterDetailLayout();
$smarty->assign('moreinfofields', "'".implode("','", $cbMapFields['detailview']['fieldnames'])."'");
if (empty($associated_prod) && $isduplicate != 'true') { // creating
$product_Detail = $col_fields = array();
foreach ($cbMapFields['detailview']['fields'] as $mdfield) {
if ($mdfield['fieldinfo']['name']=='id') {
continue;
}
$col_fields[$mdfield['fieldinfo']['name']] = '';
$foutput = getOutputHtml(
$mdfield['fieldinfo']['uitype'],
$mdfield['fieldinfo']['name'],
$mdfield['fieldinfo']['label'],
100,
$col_fields,
0,
'InventoryDetails',
'edit',
$mdfield['fieldinfo']['typeofdata']
);
$product_Detail['moreinfo'][] = $foutput;
}
$associated_prod = $product_Detail;
}
if (empty($associated_prod) && $isduplicate != 'true') { // creating
include_once 'modules/cbMap/processmap/MasterDetailLayout.php';
$associated_prod = MasterDetailLayout::setCreateAsociatedProductsValue($currentModule, $smarty);
}

list($v1, $v2, $associated_prod, $customtemplatename) = cbEventHandler::do_filter('corebos.filter.inventory.itemrow.edit', array($currentModule, $focus, $associated_prod, ''));
Expand Down
31 changes: 3 additions & 28 deletions modules/PurchaseOrder/EditView.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,34 +215,9 @@
$smarty->assign('AVAILABLE_PRODUCTS', 'true');
$smarty->assign('MODE', $focus->mode);
}
$cbMap = cbMap::getMapByName($currentModule.'InventoryDetails', 'MasterDetailLayout');
$smarty->assign('moreinfofields', '');
if ($cbMap!=null && isPermitted('InventoryDetails', 'EditView')=='yes') {
$cbMapFields = $cbMap->MasterDetailLayout();
$smarty->assign('moreinfofields', "'".implode("','", $cbMapFields['detailview']['fieldnames'])."'");
if (empty($associated_prod) && $isduplicate != 'true') { // creating
$product_Detail = $col_fields = array();
foreach ($cbMapFields['detailview']['fields'] as $mdfield) {
if ($mdfield['fieldinfo']['name']=='id') {
continue;
}
$col_fields[$mdfield['fieldinfo']['name']] = '';
$foutput = getOutputHtml(
$mdfield['fieldinfo']['uitype'],
$mdfield['fieldinfo']['name'],
$mdfield['fieldinfo']['label'],
100,
$col_fields,
0,
'InventoryDetails',
'edit',
$mdfield['fieldinfo']['typeofdata']
);
$product_Detail['moreinfo'][] = $foutput;
}
$associated_prod = $product_Detail;
$smarty->assign('ASSOCIATEDPRODUCTS', $associated_prod);
}
if (empty($associated_prod) && $isduplicate != 'true') { // creating
include_once 'modules/cbMap/processmap/MasterDetailLayout.php';
$associated_prod = MasterDetailLayout::setCreateAsociatedProductsValue($currentModule, $smarty);
}

list($v1, $v2, $associated_prod, $customtemplatename) = cbEventHandler::do_filter('corebos.filter.inventory.itemrow.edit', array($currentModule, $focus, $associated_prod, ''));
Expand Down
31 changes: 3 additions & 28 deletions modules/Quotes/EditView.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,34 +246,9 @@
} else {
$smarty->assign('ROWCOUNT', '1');
}
$cbMap = cbMap::getMapByName($currentModule.'InventoryDetails', 'MasterDetailLayout');
$smarty->assign('moreinfofields', '');
if ($cbMap!=null && isPermitted('InventoryDetails', 'EditView')=='yes') {
$cbMapFields = $cbMap->MasterDetailLayout();
$smarty->assign('moreinfofields', "'".implode("','", $cbMapFields['detailview']['fieldnames'])."'");
if (empty($associated_prod) && $isduplicate != 'true') { // creating
$product_Detail = $col_fields = array();
foreach ($cbMapFields['detailview']['fields'] as $mdfield) {
if ($mdfield['fieldinfo']['name']=='id') {
continue;
}
$col_fields[$mdfield['fieldinfo']['name']] = '';
$foutput = getOutputHtml(
$mdfield['fieldinfo']['uitype'],
$mdfield['fieldinfo']['name'],
$mdfield['fieldinfo']['label'],
100,
$col_fields,
0,
'InventoryDetails',
'edit',
$mdfield['fieldinfo']['typeofdata']
);
$product_Detail['moreinfo'][] = $foutput;
}
$associated_prod = $product_Detail;
$smarty->assign('ASSOCIATEDPRODUCTS', $associated_prod);
}
if (empty($associated_prod) && $isduplicate != 'true') { // creating
include_once 'modules/cbMap/processmap/MasterDetailLayout.php';
$associated_prod = MasterDetailLayout::setCreateAsociatedProductsValue($currentModule, $smarty);
}

list($v1, $v2, $associated_prod, $customtemplatename) = cbEventHandler::do_filter('corebos.filter.inventory.itemrow.edit', array($currentModule, $focus, $associated_prod, ''));
Expand Down
31 changes: 3 additions & 28 deletions modules/SalesOrder/EditView.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,34 +342,9 @@
$smarty->assign('AVAILABLE_PRODUCTS', 'true');
$smarty->assign('MODE', $focus->mode);
}
$cbMap = cbMap::getMapByName($currentModule.'InventoryDetails', 'MasterDetailLayout');
$smarty->assign('moreinfofields', '');
if ($cbMap!=null && isPermitted('InventoryDetails', 'EditView')=='yes') {
$cbMapFields = $cbMap->MasterDetailLayout();
$smarty->assign('moreinfofields', "'".implode("','", $cbMapFields['detailview']['fieldnames'])."'");
if (empty($associated_prod) && $isduplicate != 'true') { // creating
$product_Detail = $col_fields = array();
foreach ($cbMapFields['detailview']['fields'] as $mdfield) {
if ($mdfield['fieldinfo']['name']=='id') {
continue;
}
$col_fields[$mdfield['fieldinfo']['name']] = '';
$foutput = getOutputHtml(
$mdfield['fieldinfo']['uitype'],
$mdfield['fieldinfo']['name'],
$mdfield['fieldinfo']['label'],
100,
$col_fields,
0,
'InventoryDetails',
'edit',
$mdfield['fieldinfo']['typeofdata']
);
$product_Detail['moreinfo'][] = $foutput;
}
$associated_prod = $product_Detail;
$smarty->assign('ASSOCIATEDPRODUCTS', $associated_prod);
}
if (empty($associated_prod) && $isduplicate != 'true') { // creating
include_once 'modules/cbMap/processmap/MasterDetailLayout.php';
$associated_prod = MasterDetailLayout::setCreateAsociatedProductsValue($currentModule, $smarty);
}

list($v1, $v2, $associated_prod, $customtemplatename) = cbEventHandler::do_filter('corebos.filter.inventory.itemrow.edit', array($currentModule, $focus, $associated_prod, ''));
Expand Down
31 changes: 31 additions & 0 deletions modules/cbMap/processmap/MasterDetailLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,36 @@ public function getRelatedFieldInfo($fieldname) {
}
return $this->relatedfieldsinfo[$module][$ret];
}

// creating > empty($associated_prod) && $isduplicate != 'true'
public static function setCreateAsociatedProductsValue($module, &$smarty) {
$cbMap = cbMap::getMapByName($module.'InventoryDetails', 'MasterDetailLayout');
$smarty->assign('moreinfofields', '');
$product_Detail = array();
if ($cbMap!=null && isPermitted('InventoryDetails', 'EditView')=='yes') {
$cbMapFields = $cbMap->MasterDetailLayout();
$smarty->assign('moreinfofields', "'".implode("','", $cbMapFields['detailview']['fieldnames'])."'");
$col_fields = array();
foreach ($cbMapFields['detailview']['fields'] as $mdfield) {
if ($mdfield['fieldinfo']['name']=='id') {
continue;
}
$col_fields[$mdfield['fieldinfo']['name']] = '';
$foutput = getOutputHtml(
$mdfield['fieldinfo']['uitype'],
$mdfield['fieldinfo']['name'],
$mdfield['fieldinfo']['label'],
100,
$col_fields,
0,
'InventoryDetails',
'edit',
$mdfield['fieldinfo']['typeofdata']
);
$product_Detail['moreinfo'][] = $foutput;
}
}
return $product_Detail;
}
}
?>

0 comments on commit b755093

Please sign in to comment.