Skip to content

Commit

Permalink
add custom user fields
Browse files Browse the repository at this point in the history
fix bugs
  • Loading branch information
JBinggi committed Feb 9, 2020
1 parent 88a4246 commit 5db5117
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
6 changes: 3 additions & 3 deletions data/data_simple.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- add type fields
--
INSERT INTO `core_form_field` (`Field_ID`, `type`, `label`, `fieldkey`, `tab`, `form`, `class`, `url_view`, `url_list`, `show_widget_left`, `allow_clear`, `readonly`, `tbl_cached_name`, `tbl_class`, `tbl_permission`) VALUES
(NULL, 'select', 'Type', 'supplier_idfs', 'history-base', 'articlehistory-single', 'col-md-2', '', '/contact/api/list/0', 0, 1, 0, 'entitytag-single', 'OnePlace\\Contact\\Model\\ContactTable','add-OnePlace\\Contact\\Controller\\ContactController'),
(NULL, 'datetime', 'Date', 'date', 'history-base', 'articlehistory-single', 'col-md-2', '', '', 0, 1, 0, '', '', ''),
(NULL, 'currency', 'Price', 'price', 'history-base', 'articlehistory-single', 'col-md-2', '', '', 0, 1, 0, '', '', ''),
(NULL, 'select', 'Supplier', 'supplier_idfs', 'history-base', 'articlehistory-single', 'col-md-3', '', '/contact/api/list/0', 0, 1, 0, 'entitytag-single', 'OnePlace\\Contact\\Model\\ContactTable','add-OnePlace\\Contact\\Controller\\ContactController'),
(NULL, 'datetime', 'Date', 'date', 'history-base', 'articlehistory-single', 'col-md-1', '', '', 0, 1, 0, '', '', ''),
(NULL, 'currency', 'Price', 'price', 'history-base', 'articlehistory-single', 'col-md-1', '', '', 0, 1, 0, '', '', ''),
(NULL, 'number', 'Amount', 'amount', 'history-base', 'articlehistory-single', 'col-md-1', '', '', 0, 1, 0, '', '', '');

4 changes: 2 additions & 2 deletions data/structure_simple.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ALTER TABLE `article_history` ADD `supplier_idfs` INT(11) NOT NULL DEFAULT '0' AFTER `article_idfs`,
ADD `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `supplier_idfs`;
ADD `price` FLOAT NOT NULL DEFAULT 0 AFTER `date`;
ADD `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `supplier_idfs`,
ADD `price` FLOAT NOT NULL DEFAULT 0 AFTER `date`,
ADD `amount` FLOAT NOT NULL DEFAULT 0 AFTER `price`;

22 changes: 17 additions & 5 deletions src/Controller/HistoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,27 @@ public function __construct(AdapterInterface $oDbAdapter,HistoryTable $oTableGat

public function attachHistoryForm($oItem = false) {
$oForm = CoreEntityController::$aCoreTables['core-form']->select(['form_key'=>'articlehistory-single']);
$aFields = [
'history-base' => CoreEntityController::$aCoreTables['core-form-field']->select(['form' => 'articlehistory-single']),
];

$aFields = [];
$aUserFields = CoreEntityController::$oSession->oUser->getMyFormFields();
if(array_key_exists('articlehistory-single',$aUserFields)) {
$aFieldsTmp = $aUserFields['articlehistory-single'];
if(count($aFieldsTmp) > 0) {
# add all contact-base fields
foreach($aFieldsTmp as $oField) {
if($oField->tab == 'history-base') {
$aFields[] = $oField;
}
}
}
}

$aFieldsByTab = ['history-base'=>$aFields];
# Try to get adress table
try {
$oHistoryTbl = CoreEntityController::$oServiceManager->get(HistoryTable::class);
} catch(\RuntimeException $e) {
//echo '<div class="alert alert-danger"><b>Error:</b> Could not load address table</div>';
echo '<div class="alert alert-danger"><b>Error:</b> Could not load address table</div>';
return [];
}

Expand Down Expand Up @@ -90,7 +102,7 @@ public function attachHistoryForm($oItem = false) {
'article_history'=> [
'oHistories'=>$aHistories,
'oForm'=>$oForm,
'aFormFields'=>$aFields,
'aFormFields'=>$aFieldsByTab,
]
]
];
Expand Down

0 comments on commit 5db5117

Please sign in to comment.