Skip to content

Commit

Permalink
Merge pull request #18 from ConductionNL/dev-robert_unset
Browse files Browse the repository at this point in the history
Issues #376 and #406
  • Loading branch information
rubenvdlinde authored Feb 7, 2020
2 parents 831113f + 810e05c commit e184f8d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 38 deletions.
5 changes: 0 additions & 5 deletions api/src/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ public function setAction(Session $session, $slug = null, $value = null, Applica
$dateArray = explode(" ", $date);
$value = date('d-m-Y H:i', strtotime("$dateArray[1] $dateArray[2] $dateArray[3] $time GMT+0100"));
}
var_dump($variables);
$variables['request'] = $requestService->setPropertyOnSlug($variables['request'], $variables['requestType'], $slug, $value);

} // if not the we are asuming a "broad" form that wants to update anything in the reqoust, so we merge arrays
Expand Down Expand Up @@ -384,10 +383,6 @@ public function setAction(Session $session, $slug = null, $value = null, Applica
/*@todo translation*/
$this->addFlash('success', ucfirst($stageName) . ' is ingesteld');

// if($slug = "partner") {
var_dump($request->query->get('forceAssent'));
// die;
// }
// nog iets van uitleg
if ($request->query->get('forceAssent')) {

Expand Down
69 changes: 37 additions & 32 deletions api/src/Service/ApplicationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use GuzzleHttp\Client;
use Symfony\Component\Cache\Adapter\AdapterInterface as CacheInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\RequestStack;

Expand Down Expand Up @@ -35,40 +35,40 @@ public function __construct(ParameterBagInterface $params, CacheInterface $cache
$this->requestService= $requestService;

}

/*
* Get a single resource from a common ground componant
*/
public function getVariables()
{
$variables = [];

// Lets handle the loading of a product is we have one
$resource= $this->request->get('resource');
if($resource|| $resource = $this->request->query->get('resource')){
/*@todo dit zou de commonground service moeten zijn */
$variables['resource'] = $this->commonGroundService->getResource($resource);
}

// Lets handle a posible login
$bsn = $this->request->get('bsn');
if($bsn || $bsn = $this->request->query->get('bsn')){
$user = $this->commonGroundService->getResource('https://brp.zaakonline.nl/ingeschrevenpersonen/'.$bsn);
$this->session->set('user', $user);
}
$variables['user'] = $this->session->get('user');
// @todo iets met organisaties en applicaties
$variables['user'] = $this->session->get('user');

// @todo iets met organisaties en applicaties
$organization= $this->request->get('organization');
if($organization|| $organization= $this->request->query->get('organization')){
if($organization|| $organization= $this->request->query->get('organization')){
$this->session->set('organization', $organization);
}
else{
/*@todo param bag interface */
$this->session->set('organization', '000000');
}
$variables['organization'] = $this->session->get('organization');

// application
$application= $this->request->get('application');
if($application|| $application= $this->request->query->get('application')){
Expand All @@ -79,51 +79,56 @@ public function getVariables()
$this->session->set('application', '0000000');
}
$variables['application'] = $this->session->get('application');



// Let handle posible request creation
$requestType = $this->request->request->get('requestType');
if($requestType || $requestType= $this->request->query->get('requestType')){

$requestParent = $this->request->request->get('requestParent');
if(!$requestParent){ $requestParent = $this->request->query->get('requestParent');}

$requestType = $this->commonGroundService->getResource($requestType);
$request = $this->requestService->createFromRequestType($requestType, $requestParent);

// Validate current reqoust type
$requestType = $this->requestService->checkRequestType($request, $requestType);

$this->session->set('request', $request);
$this->session->set('requestType', $requestType);

/* @todo translation */
$this->flash->add('success', 'Verzoek voor '.$requestType['name'].' opgestart');

$this->session->set('requestType', $requestType);
if($request != null)
{
$this->session->set('request', $request);
/* @todo translation */
$this->flash->add('success', 'Verzoek voor ' . $requestType['name'] . ' opgestart');
}
else{
$this->flash->add('failure', 'Kon geen verzoek voor '. $requestType['name']. ' opstarten, omdat er al een verzoek voor '.$requestType['name'].' actief is');
}
}


// Lets handle the loading of a request
$request= $this->request->request->get('request');
if($request || $request = $this->request->query->get('request')){
$request = $this->commonGroundService->getResource($request);
$requestType = $this->commonGroundService->getResource($request['request_type']);

// Validate current reqoust type
$requestType = $this->requestService->checkRequestType($request, $requestType);

$this->session->set('request', $request);
$this->session->set('requestType', $requestType);

/* @todo translation */
$this->flash->add('success', 'Verzoek voor '.$requestType['name'].' ingeladen');
$this->flash->add('success', 'Verzoek voor '.$requestType['name'].' ingeladen');
}

$variables['request'] = $this->session->get('request');
$variables['requestType'] = $this->session->get('requestType');
$variables['requestType'] = $this->session->get('requestType');

return $variables;
}


}
11 changes: 10 additions & 1 deletion api/src/Service/RequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public function createFromRequestType($requestType, $requestParent = null ,$user
$request['status']='incomplete';
$request['properties']= [];

$requestTypeObject = $this->commonGroundService->getResource($request['request_type']);
if($requestTypeObject['unique'] == true)
{
$existingRequests = $this->commonGroundService->getResourceList('http://vrc.zaakonline.nl/requests', ['request_type'=>$request['request_type'], 'status[]'=>['incomplete','processed','submitted'], 'submitter'=>$this->session->get('bsn')]);
if(count($existingRequests) > 0)
{
//TODO: Throw error
return null;
}
}
if($user){
$request['submitter'] = $user['burgerservicenummer'];
//$request['submitters'] = [$user['burgerservicenummer']];
Expand Down Expand Up @@ -136,7 +146,6 @@ public function setPropertyOnSlug($request, $requestType, $slug, $value)
foreach ($requestType['properties'] as $property){
if($property['slug'] == $slug){
$typeProperty= $property;
var_dump($typeProperty['name']);
break;
}
}
Expand Down

0 comments on commit e184f8d

Please sign in to comment.