Browse Source

Modification d'un document : problème chargement adresse document si différente de celle initiale de l'utilisateur #166

dev
Guillaume Bourgeois 4 years ago
parent
commit
4012084b08
1 changed files with 17 additions and 6 deletions
  1. +17
    -6
      backend/controllers/DocumentController.php

+ 17
- 6
backend/controllers/DocumentController.php View File

{ {
$model = $this->findModel($id); $model = $this->findModel($id);


$class = $this->getClass();
$model = $class::searchOne([
'id' => $id
]);

if(!$model) { if(!$model) {
throw new NotFoundHttpException('Le document n\'a pas été trouvé.'); throw new NotFoundHttpException('Le document n\'a pas été trouvé.');
} }
]); ]);


if ($user) { if ($user) {

$document = null ;
if(Document::isValidClass($classDocument)) {
$document = $classDocument::searchOne([
'id' => $idDocument,
'id_user' => $idUser
]) ;
}

if($document && $document->id_user == $user->id) {
$address = $document->address ;
}
else {
$address = $user->getFullAddress() ;
}

$json = [ $json = [
'return' => 'success', 'return' => 'success',
'address' => $user->getFullAddress()
'address' => $address
]; ];


if($classDocument == 'Invoice') { if($classDocument == 'Invoice') {

Loading…
Cancel
Save