17 import(
'lib.pkp.classes.controllers.grid.GridHandler');
20 import(
'controllers.grid.catalogEntry.MarketsGridCellProvider');
21 import(
'controllers.grid.catalogEntry.MarketsGridRow');
24 import(
'lib.pkp.classes.linkAction.request.AjaxModal');
40 parent::__construct();
42 array(ROLE_ID_MANAGER),
43 array(
'fetchGrid',
'fetchRow',
'addMarket',
'editMarket',
44 'updateMarket',
'deleteMarket'));
64 $this->_submission = $submission;
80 $this->_publication = $publication;
96 $this->_publicationFormat = $publicationFormat;
108 function authorize($request, &$args, $roleAssignments) {
109 import(
'lib.pkp.classes.security.authorization.PublicationAccessPolicy');
111 return parent::authorize($request, $args, $roleAssignments);
118 parent::initialize($request, $args);
125 $representationId =
null;
128 $marketId = (int) $request->getUserVar(
'marketId');
130 if ($marketId !=
'') {
134 $representationId = $market->getPublicationFormatId();
137 $representationId = (int) $request->getUserVar(
'representationId');
140 $publicationFormat = $publicationFormatDao->getById($representationId, $this->
getPublication()->getId());
142 if ($publicationFormat) {
145 fatalError(
'The publication format is not assigned to authorized submission!');
150 LOCALE_COMPONENT_APP_SUBMISSION,
151 LOCALE_COMPONENT_PKP_SUBMISSION,
152 LOCALE_COMPONENT_PKP_USER,
153 LOCALE_COMPONENT_APP_DEFAULT,
154 LOCALE_COMPONENT_PKP_DEFAULT
158 $this->
setTitle(
'grid.catalogEntry.markets');
161 $router = $request->getRouter();
167 $router->url($request,
null,
null,
'addMarket',
null, $actionArgs),
168 __(
'grid.action.addMarket'),
171 __(
'grid.action.addMarket'),
181 'grid.catalogEntry.marketTerritory',
190 'grid.catalogEntry.representatives',
199 'submission.publicationFormat.price',
235 function loadData($request, $filter =
null) {
238 $data = $marketDao->getByPublicationFormatId($publicationFormat->getId());
239 return $data->toArray();
263 $marketId = (int) $request->getUserVar(
'marketId');
270 import(
'controllers.grid.catalogEntry.form.MarketForm');
272 $marketForm->initData();
274 return new JSONMessage(
true, $marketForm->fetch($request));
285 $marketId = $request->getUserVar(
'marketId');
292 import(
'controllers.grid.catalogEntry.form.MarketForm');
294 $marketForm->readInputData();
295 if ($marketForm->validate()) {
296 $marketId = $marketForm->execute();
298 if(!isset($market)) {
302 $notificationContent = __(
'notification.addedMarket');
305 $notificationContent = __(
'notification.editedMarket');
309 $currentUser = $request->getUser();
311 $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => $notificationContent));
315 $row->setGridId($this->
getId());
316 $row->setId($marketId);
317 $row->setData($market);
318 $row->initialize($request);
324 return new JSONMessage(
true, $marketForm->fetch($request));
337 $marketId = $request->getUserVar(
'marketId');
341 if ($market !=
null) {
343 $result = $marketDao->deleteObject($market);
346 $currentUser = $request->getUser();
348 $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => __(
'notification.removedMarket')));
351 return new JSONMessage(
false, __(
'manager.setup.errorDeletingItem'));