diff --git a/src/app/action/models/ActionModelAbstract.php b/src/app/action/models/ActionModelAbstract.php index 95d4ce732766c7639cd7d1ce8e6866417f495823..2e38aa72f863e47fc77c7f8830ed9ef87b8d49d9 100755 --- a/src/app/action/models/ActionModelAbstract.php +++ b/src/app/action/models/ActionModelAbstract.php @@ -236,25 +236,6 @@ abstract class ActionModelAbstract return $action[0]['action_page']; } - public static function getDefaultActionByGroupBasketId(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['groupId', 'basketId']); - ValidatorModel::stringType($aArgs, ['groupId', 'basketId']); - - $action = DatabaseModel::select([ - 'select' => ['id_action'], - 'table' => ['actions_groupbaskets'], - 'where' => ['group_id = ?', 'basket_id = ?', 'default_action_list = ?'], - 'data' => [$aArgs['groupId'], $aArgs['basketId'], 'Y'] - ]); - - if (empty($action[0])) { - return ''; - } - - return $action[0]['id_action']; - } - public static function getForBasketPage(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['basketId', 'groupId']); diff --git a/src/app/resource/controllers/ResourceListController.php b/src/app/resource/controllers/ResourceListController.php index 82e95865f0993ccafec8b2ed21c7335b0d199acd..9f73c4614bf3aacd031553c89ff2c063c15686f1 100644 --- a/src/app/resource/controllers/ResourceListController.php +++ b/src/app/resource/controllers/ResourceListController.php @@ -206,7 +206,14 @@ class ResourceListController } } - return $response->withJson(['resources' => $formattedResources, 'count' => $count, 'basketLabel' => $basket['basket_name'], 'allResources' => $allResources]); + $defaultAction = ActionGroupBasketModel::get([ + 'select' => ['id_action'], + 'where' => ['basket_id = ?', 'group_id = ?', 'default_action_list = ?'], + 'data' => [$basket['basket_id'], $group['group_id'], 'Y'] + ]); + $defaultAction = ActionModel::getById(['select' => ['id', 'label_action', 'component'], 'id' => [$defaultAction[0]['id_action']]]); + + return $response->withJson(['resources' => $formattedResources, 'count' => $count, 'basketLabel' => $basket['basket_name'], 'allResources' => $allResources, 'defaultAction' => $defaultAction]); } public function getFilters(Request $request, Response $response, array $aArgs) @@ -602,10 +609,8 @@ class ResourceListController $resourcesInBasket[] = $resource['res_id']; } - foreach ($body['resources'] as $resId) { - if (!in_array($resId, $resourcesInBasket)) { - return $response->withStatus(403)->withJson(['errors' => 'Resources out of perimeter']); - } + if (!empty(array_diff($body['resources'], $resourcesInBasket))) { + return $response->withStatus(403)->withJson(['errors' => 'Resources out of perimeter']); } $resourcesForAction = []; @@ -667,10 +672,8 @@ class ResourceListController $resourcesInBasket[] = $resource['res_id']; } - foreach ($body['resources'] as $resId) { - if (!in_array($resId, $resourcesInBasket)) { - return $response->withStatus(403)->withJson(['errors' => 'Resources out of perimeter']); - } + if (!empty(array_diff($body['resources'], $resourcesInBasket))) { + return $response->withStatus(403)->withJson(['errors' => 'Resources out of perimeter']); } $locked = 0; @@ -731,10 +734,8 @@ class ResourceListController $resourcesInBasket[] = $resource['res_id']; } - foreach ($body['resources'] as $resId) { - if (!in_array($resId, $resourcesInBasket)) { - return $response->withStatus(403)->withJson(['errors' => 'Resources out of perimeter']); - } + if (!empty(array_diff($body['resources'], $resourcesInBasket))) { + return $response->withStatus(403)->withJson(['errors' => 'Resources out of perimeter']); } $resourcesToUnlock = []; diff --git a/src/app/signatureBook/controllers/SignatureBookController.php b/src/app/signatureBook/controllers/SignatureBookController.php index 8ae671091a144800572ef956f5c23d139ec17579..6cd223376113c93ec16507f83a4f4579039fad6c 100755 --- a/src/app/signatureBook/controllers/SignatureBookController.php +++ b/src/app/signatureBook/controllers/SignatureBookController.php @@ -16,6 +16,7 @@ namespace SignatureBook\controllers; use Action\models\ActionModel; use Attachment\models\AttachmentModel; +use Basket\models\ActionGroupBasketModel; use Basket\models\BasketModel; use Contact\models\ContactModel; use Convert\controllers\ConvertPdfController; @@ -67,11 +68,17 @@ class SignatureBookController } } + $defaultAction = ActionGroupBasketModel::get([ + 'select' => ['id_action'], + 'where' => ['basket_id = ?', 'group_id = ?', 'default_action_list = ?'], + 'data' => [$aArgs['basketId'], $aArgs['groupId'], 'Y'] + ]); + $actionLabel = (_ID_TO_DISPLAY == 'res_id' ? $documents[0]['res_id'] : $documents[0]['alt_id']); $actionLabel .= " : {$documents[0]['title']}"; $currentAction = [ - 'id' => ActionModel::getDefaultActionByGroupBasketId(['groupId' => $aArgs['groupId'], 'basketId' => $aArgs['basketId']]), - 'actionLabel' => $actionLabel + 'id' => $defaultAction[0]['id_action'], + 'actionLabel' => $actionLabel ]; $listInstances = ListInstanceModel::get([ 'select' => ['COUNT(*)'],