16 import(
'lib.pkp.classes.form.Form');
29 parent::__construct(
'controllers/grid/catalogEntry/form/representativeForm.tpl');
36 $this,
'isSupplier',
'required',
'grid.catalogEntry.roleRequired',
37 function($isSupplier) use ($form) {
39 $agentRole = $request->getUserVar(
'agentRole');
40 $supplierRole = $request->getUserVar(
'supplierRole');
42 return (!$isSupplier && $onixDao->codeExistsInList($agentRole,
'List69')) || ($isSupplier && $onixDao->codeExistsInList($supplierRole,
'List93'));
65 $this->_representative = $representative;
81 $this->_monograph = $monograph;
94 if ($representative) {
96 'representativeId' => $representative->getId(),
97 'role' => $representative->getRole(),
98 'representativeIdType' => $representative->getRepresentativeIdType(),
99 'representativeIdValue' => $representative->getRepresentativeIdValue(),
100 'name' => $representative->getName(),
101 'phone' => $representative->getPhone(),
102 'email' => $representative->getEmail(),
103 'url' =>$representative->getUrl(),
104 'isSupplier' => $representative->getIsSupplier(),
112 public function fetch($request, $template =
null, $display =
false) {
116 $templateMgr->assign(
'submissionId', $monograph->getId());
119 $templateMgr->assign(array(
120 'idTypeCodes' => $onixCodelistItemDao->getCodes(
'List92'),
121 'agentRoleCodes' => $onixCodelistItemDao->getCodes(
'List69'),
122 'supplierRoleCodes' => $onixCodelistItemDao->getCodes(
'List93'),
123 'isSupplier' =>
true,
126 if ($representative) $templateMgr->assign(array(
127 'representativeId' => $representative->getId(),
128 'role' => $representative->getRole(),
129 'representativeIdType' => $representative->getRepresentativeIdType(),
130 'representativeIdValue' => $representative->getRepresentativeIdValue(),
131 'name' => $representative->getName(),
132 'phone' => $representative->getPhone(),
133 'email' => $representative->getEmail(),
134 'url' => $representative->getUrl(),
135 'isSupplier' => $representative->getIsSupplier() ?
true :
false,
137 else $templateMgr->assign(
'representativeIdType',
'06');
139 return parent::fetch($request, $template, $display);
151 'representativeIdType',
152 'representativeIdValue',
165 parent::execute(...$functionArgs);
170 if (!$representative) {
172 $representative = $representativeDao->newDataObject();
173 $representative->setMonographId($monograph->getId());
174 $existingRepresentative =
false;
177 $existingRepresentative =
true;
179 if ($representativeDao->getById($representative->getId(), $monograph->getId()) ==
null)
fatalError(
'Invalid representative!');
182 if ($this->
getData(
'isSupplier')) {
183 $representative->setRole($this->
getData(
'supplierRole'));
185 $representative->setRole($this->
getData(
'agentRole'));
188 $representative->setRepresentativeIdType($this->
getData(
'representativeIdType'));
189 $representative->setRepresentativeIdValue($this->
getData(
'representativeIdValue'));
190 $representative->setName($this->
getData(
'name'));
191 $representative->setPhone($this->
getData(
'phone'));
192 $representative->setEmail($this->
getData(
'email'));
193 $representative->setUrl($this->
getData(
'url'));
194 $representative->setIsSupplier($this->
getData(
'isSupplier') ?
true :
false);
196 if ($existingRepresentative) {
197 $representativeDao->updateObject($representative);
198 $representativeId = $representative->getId();
200 $representativeId = $representativeDao->insertObject($representative);
203 return $representativeId;