|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* DefaultController controller de l'application GLSR. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP Version 5 |
|
6
|
|
|
* |
|
7
|
|
|
* @author Quétier Laurent <[email protected]> |
|
8
|
|
|
* @copyright 2014 Dev-Int GLSR |
|
9
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
10
|
|
|
* |
|
11
|
|
|
* @version since 1.0.0 |
|
12
|
|
|
* |
|
13
|
|
|
* @link https://github.com/Dev-Int/glsr |
|
14
|
|
|
*/ |
|
15
|
|
|
namespace AppBundle\Controller; |
|
16
|
|
|
|
|
17
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
18
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
19
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
|
20
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
|
21
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Default controller. |
|
25
|
|
|
* |
|
26
|
|
|
* @category Controller |
|
27
|
|
|
* |
|
28
|
|
|
* @Route("/") |
|
29
|
|
|
*/ |
|
30
|
|
|
class DefaultController extends Controller |
|
31
|
|
|
{ |
|
32
|
|
|
private $entities; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct() |
|
35
|
|
|
{ |
|
36
|
|
|
// Tableau des entitées |
|
37
|
|
|
$this->entities = array( |
|
38
|
|
|
'AppBundle:User', |
|
39
|
|
|
'AppBundle:Company', |
|
40
|
|
|
'AppBundle:Settings', |
|
41
|
|
|
'AppBundle:FamilyLog', |
|
42
|
|
|
'AppBundle:ZoneStorage', |
|
43
|
|
|
'AppBundle:UnitStorage', |
|
44
|
|
|
'AppBundle:Tva', |
|
45
|
|
|
'AppBundle:Supplier', |
|
46
|
|
|
'AppBundle:Article'); |
|
47
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @Route("/", name="_home") |
|
52
|
|
|
* @Method("GET") |
|
53
|
|
|
* @Template() |
|
54
|
|
|
*/ |
|
55
|
|
|
public function indexAction() |
|
56
|
|
|
{ |
|
57
|
|
|
/** |
|
58
|
|
|
* Test d'installation |
|
59
|
|
|
*/ |
|
60
|
|
|
$url = $this->testEntities(); |
|
61
|
|
|
if (empty($url)) { |
|
62
|
|
|
$url = $this->render('default/index.html.twig'); |
|
63
|
|
|
} else { |
|
64
|
|
|
$url = $this->redirectToRoute($url); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return $url; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Test des entités |
|
72
|
|
|
* |
|
73
|
|
|
* @return array |
|
|
|
|
|
|
74
|
|
|
*/ |
|
75
|
|
|
private function testEntities() |
|
76
|
|
|
{ |
|
77
|
|
|
$url = null; |
|
78
|
|
|
$etm = $this->getDoctrine()->getManager(); |
|
79
|
|
|
// vérifie que les Entitées ne sont pas vides |
|
80
|
|
|
$nbEntities = count($this->entities); |
|
81
|
|
|
for ($index = 0; $index < $nbEntities; $index++) { |
|
82
|
|
|
$entity = $etm->getRepository($this->entities[$index]); |
|
83
|
|
|
$entityData = $entity->find(1); |
|
84
|
|
|
|
|
85
|
|
|
if (empty($entityData)) { |
|
86
|
|
|
$message = 'gestock.install.none'; |
|
87
|
|
|
$url = 'gs_install'; |
|
88
|
|
|
break; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
if (isset($message)) { |
|
92
|
|
|
$this->addFlash('warning', $message); |
|
93
|
|
|
} |
|
94
|
|
|
return $url; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Récupère les FamilyLog de la requête post. |
|
99
|
|
|
* |
|
100
|
|
|
* @Route("/getfamilylog", name="getfamilylog") |
|
101
|
|
|
* @Method("POST") |
|
102
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getFamilyLogAction() |
|
105
|
|
|
{ |
|
106
|
|
|
$id = ''; |
|
|
|
|
|
|
107
|
|
|
$request = $this->getRequest(); |
|
|
|
|
|
|
108
|
|
|
$etm = $this->getDoctrine()->getManager(); |
|
109
|
|
|
if ($request->isXmlHttpRequest()) { |
|
110
|
|
|
$id = $request->get('id'); |
|
111
|
|
|
if ($id != '') { |
|
112
|
|
|
$supplier = $etm |
|
113
|
|
|
->getRepository('AppBundle:Supplier') |
|
114
|
|
|
->find($id); |
|
115
|
|
|
$familyLog['familylog'] = $supplier->getFamilyLog()->getId(); |
|
|
|
|
|
|
116
|
|
|
$response = new Response(); |
|
117
|
|
|
$data = json_encode($familyLog); |
|
118
|
|
|
$response->headers->set('Content-Type', 'application/json'); |
|
119
|
|
|
$response->setContent($data); |
|
120
|
|
|
return $response; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
return new Response('Error'); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.