|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* DefaultController controller de l'application. |
|
5
|
|
|
* |
|
6
|
|
|
* PHP Version 7 |
|
7
|
|
|
* |
|
8
|
|
|
* @author Quétier Laurent <[email protected]> |
|
9
|
|
|
* @copyright 2018 Dev-Int GLSR |
|
10
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
11
|
|
|
* |
|
12
|
|
|
* @version GIT: $Id$ |
|
13
|
|
|
* |
|
14
|
|
|
* @link https://github.com/Dev-Int/glsr |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace App\Controller; |
|
18
|
|
|
|
|
19
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
20
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
21
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
22
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Description of DefaultController |
|
26
|
|
|
* |
|
27
|
|
|
* @category Controller |
|
28
|
|
|
*/ |
|
29
|
|
|
class DefaultController extends Controller |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @Route("/", name="home") |
|
33
|
|
|
*/ |
|
34
|
|
|
public function indexAction() |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->render('default/index.html.twig'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get FamilyLog. |
|
41
|
|
|
* |
|
42
|
|
|
* @Route("/getfamilylog", name="getfamilylog", methods="POST") |
|
43
|
|
|
* |
|
44
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request Post request |
|
45
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getFamilyLogAction(Request $request) |
|
48
|
|
|
{ |
|
49
|
|
|
$return = new Response('Error'); |
|
50
|
|
|
$etm = $this->getDoctrine()->getManager(); |
|
51
|
|
|
if ($request->isXmlHttpRequest()) { |
|
52
|
|
|
$familyLog = array(); |
|
53
|
|
|
$id = $request->get('id'); |
|
54
|
|
|
if ($id != '') { |
|
55
|
|
|
$supplier = $etm |
|
56
|
|
|
->getRepository('App:Settings\Supplier') |
|
57
|
|
|
->find($id); |
|
58
|
|
|
// Add directs parents of $familyLog |
|
59
|
|
|
$familyLog['familylog'] = $supplier->getFamilyLog()->getId(); |
|
60
|
|
|
$response = new Response(); |
|
61
|
|
|
$data = json_encode($familyLog); |
|
62
|
|
|
$response->headers->set('Content-Type', 'application/json'); |
|
63
|
|
|
$response->setContent($data); |
|
64
|
|
|
$return = $response; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
return $return; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|