Browse Source

CL-557 ajout des vues dans la migration

raphael 4 years ago
parent
commit
18ee789b5b

+ 1
- 0
.gitignore View File

@@ -12,3 +12,4 @@
12 12
 /.history/
13 13
 /.svn/
14 14
 config/.routes.yaml.swp
15
+public/uploads/

+ 2
- 0
config/doctrine/Category.Category.orm.xml View File

@@ -22,6 +22,8 @@
22 22
         <field name="metaOGTitle" column="meta_og_title" type="string" length="100" nullable="true" />
23 23
         <field name="metaOGDescription" column="meta_og_description" type="string" length="255" nullable="true" />
24 24
 
25
+        <field name="picture" column="picture" type="string" nullable="true"/>
26
+
25 27
 		 <many-to-one
26 28
             field="parent"
27 29
             target-entity="Logipro\CaptainLearning\Entity\Category\Category"

+ 2
- 7
config/doctrine/Company.orm.xml View File

@@ -26,6 +26,8 @@
26 26
 		<field name="type" column="type" type="captainEnumCompanyType" />
27 27
 		<field name="salariedNumber" column="salaried_number" type="captainEnumCompanySalariedNumberType" />
28 28
 
29
+        <field name="logo" column="logo" type="string" nullable="true"/>
30
+
29 31
         <many-to-one
30 32
             field="country"
31 33
             target-entity="Logipro\CaptainLearning\Entity\Country">
@@ -34,13 +36,6 @@
34 36
 
35 37
 		<one-to-one field="client" target-entity="Client" mapped-by="company" />
36 38
 
37
-        <field mapping="company_images"
38
-			name="imageLogo"
39
-			filename_property="imageName"
40
-			nullable="true"
41
-		/>
42
-        <field name="imageName" column="image_name" type="text" length="100" nullable="true"/>
43
-
44 39
         <many-to-many field="users" mapped-by="companies" target-entity="Logipro\CaptainLearning\Entity\User\User"/>
45 40
 
46 41
         <one-to-many

+ 12
- 12
config/doctrine/Estimate.orm.xml View File

@@ -16,20 +16,20 @@
16 16
 		<field name="dateCreate" column="date_create" type="datetime" nullable="false"/>
17 17
 		<field name="dateEdit" column="date_edit" type="datetime" nullable="true"/>
18 18
 		<field name="statut" column="statut" type="captainEnumEstimateStatutType" />
19
-		<field name="coment" column="coment" type="text" />
19
+		<field name="coment" column="coment" type="text" nullable="true"/>
20 20
 
21 21
 		<field name="clientCivility" column="client_civility" type="captainEnumUserCivilityType" />
22
-		<field name="clientName" column="client_name" type="text" length="100" />
23
-		<field name="clientFirstName" column="client_first_name" type="text" length="100" />
24
-		<field name="clientDenomination" column="client_denomination" type="text" length="100" />
25
-		<field name="clientAdress" column="client_adress" type="text" />
26
-		<field name="clientPostalCode" column="client_postal_code" type="text" length="5" />
27
-		<field name="clientCity" column="client_city" type="text" length="50" />
28
-		<field name="clientCountry" column="client_country" type="text" length="50" />
29
-		<field name="clientEmail" column="client_email" type="text" length="100" />
30
-		<field name="clientPhone" column="client_phone" type="text" length="20" />
31
-		<field name="reference" column="reference" type="text" length="20" />
32
-		<field name="object" column="object" type="text" length="100" />
22
+		<field name="clientName" column="client_name" type="text" length="100"  nullable="true"/>
23
+		<field name="clientFirstName" column="client_first_name" type="text" length="100"  nullable="true"/>
24
+		<field name="clientDenomination" column="client_denomination" type="text" length="100"  nullable="true"/>
25
+		<field name="clientAdress" column="client_adress" type="text"  nullable="true"/>
26
+		<field name="clientPostalCode" column="client_postal_code" type="text" length="5"  nullable="true"/>
27
+		<field name="clientCity" column="client_city" type="text" length="50"  nullable="true"/>
28
+		<field name="clientCountry" column="client_country" type="text" length="50"  nullable="true"/>
29
+		<field name="clientEmail" column="client_email" type="text" length="100"  nullable="true"/>
30
+		<field name="clientPhone" column="client_phone" type="text" length="20"  nullable="true"/>
31
+		<field name="reference" column="reference" type="text" length="20"  nullable="true"/>
32
+		<field name="object" column="object" type="text" length="100"  nullable="true"/>
33 33
 		
34 34
 		 <many-to-one
35 35
             field="trainingOrganization"

+ 2
- 2
config/doctrine/EstimateLine.orm.xml View File

@@ -16,8 +16,8 @@
16 16
 		<field name="quantity" column="quantity" type="text" length="170" nullable="false" />
17 17
 		<field name="price" column="price" type="decimal" scale="4" default="0.0000" nullable="true" />
18 18
 		<field name="tva" column="tva" type="decimal" scale="2" default="0.00" />
19
-		<field name="designation" column="designation" type="text" nullable="false" />
20
-		<field name="reference" column="reference" type="text" length="170" nullable="false" />
19
+		<field name="designation" column="designation" type="text" nullable="true" />
20
+		<field name="reference" column="reference" type="text" length="170" nullable="true" />
21 21
 		<field name="orderLine" column="order_line" type="integer" nullable="true" />
22 22
 		
23 23
 		 <many-to-one

+ 2
- 2
config/doctrine/Record.orm.xml View File

@@ -22,7 +22,6 @@
22 22
             <join-column nullable="true" name="ref_client" referenced-column-name="client_id"/>
23 23
         </many-to-one>
24 24
 
25
-
26 25
 		<many-to-many field="persons" inversed-by="records" target-entity="Logipro\CaptainLearning\Entity\Person">
27 26
             <join-table name="cpt_map_list_person">
28 27
                 <join-columns>
@@ -34,8 +33,9 @@
34 33
             </join-table>
35 34
         </many-to-many>
36 35
 
36
+
37 37
 		<many-to-many field="trainings" inversed-by="records" target-entity="Logipro\CaptainLearning\Entity\Training\Training">
38
-            <join-table name="cpt_map_list_training">
38
+            <join-table name="cpt_map_record_training">
39 39
                 <join-columns>
40 40
                     <join-column name="ref_record" referenced-column-name="record_id" />
41 41
                 </join-columns>

+ 7
- 10
config/doctrine/Training.Training.orm.xml View File

@@ -46,16 +46,13 @@
46 46
 		<field name="maximalPlaceNumber" column="maximal_place_number" type="integer" default="0"/>
47 47
 		<field name="videoUrl" column="video_url" type="text" length="255" nullable="true"/>
48 48
 		
49
-		<field mapping="cover"
50
-			name="coverFile"
51
-			filename_property="image"
52
-			nullable="true"
53
-		/>
54
-		<field mapping="logo"
55
-			name="logoFile"
56
-			filename_property="image"
57
-			nullable="true"
58
-		/>
49
+		<field name="logo" column="logo" type="string" nullable="true"/>
50
+		<field name="cover" column="cover" type="string" nullable="true"/>
51
+		<field name="pictureOne" column="picture_one" type="string" nullable="true"/>
52
+		<field name="pictureTwo" column="picture_two" type="string" nullable="true"/>
53
+		<field name="pictureTree" column="picture_tree" type="string" nullable="true"/>
54
+		<field name="pictureFour" column="picture_four" type="string" nullable="true"/>
55
+		<field name="pictureFive" column="picture_five" type="string" nullable="true"/>
59 56
 
60 57
 		<field name="priceOnRequest" column="price_on_request" type="boolean" />
61 58
 		<field name="eligibleCPF" column="eligibl_cpf" type="boolean" />

+ 6
- 1
config/doctrine/TrainingOrganization.orm.xml View File

@@ -34,7 +34,12 @@
34 34
         <field name="acceptSubrogation" column="accept_subrogation" type="boolean" default="0"/>
35 35
         <field name="description" column="description" type="text" nullable="true"/>
36 36
         
37
-       
37
+        <field name="cover" column="cover" type="string" nullable="true"/>
38
+        <field name="logo" column="logo" type="string" nullable="true"/>
39
+        <field name="kbis" column="kbis" type="string" nullable="true"/>
40
+        <field name="identity" column="identity" type="string" nullable="true"/>
41
+        <field name="banner" column="banner" type="string" nullable="true"/>
42
+
38 43
         <one-to-one field="company" target-entity="Company">
39 44
             <join-column nullable="false" name="ref_company" referenced-column-name="company_id" />
40 45
         </one-to-one>

+ 1
- 1
config/packages/vich_uploader.yaml View File

@@ -8,7 +8,7 @@ vich_uploader:
8 8
       - { path: '%kernel.project_dir%/config/vich_uploader', namespace_prefix: 'Logipro\CaptainLearning' }
9 9
 
10 10
   mappings:
11
-    user_images:
11
+    pictures:
12 12
       uri_prefix:         '%app.url.upload_public%'
13 13
       upload_destination: '%app.path.upload_dir%'
14 14
 

+ 4
- 0
config/routes.yaml View File

@@ -162,3 +162,7 @@ admin_category_edit:
162 162
 admin_training:
163 163
   path: /admin/training
164 164
   controller: \Logipro\CaptainLearning\Controller\BackOffice\Admin\TrainingController::drawList
165
+
166
+drawUpload:
167
+  path: /view/{name}
168
+  controller: \Logipro\CaptainLearning\Controller\Common\FileController::drawFile

+ 2
- 2
config/services.yaml View File

@@ -2,8 +2,8 @@ parameters:
2 2
   # Config pour envoyer des emails
3 3
   app.notifications.email_sender: captain@logipro.com
4 4
   app.path.upload_dir: '%kernel.project_dir%/public/uploads'
5
-  app.path.upload_temp_dir: '%kernel.project_dir%/public/uploads/tmp'
6
-  app.url.upload_public: '%env(APP_URL_PREFIX)%/uploads'
5
+  app.path.upload_temp_dir: '%kernel.project_dir%/var/uploads'
6
+  app.url.upload_public: '%env(APP_URL_PREFIX)%/view'
7 7
 
8 8
 services:
9 9
   # default configuration for services in *this* file

+ 6
- 0
config/vich_uploader/Entity.Company.xml View File

@@ -0,0 +1,6 @@
1
+<vich_uploader class="Logipro\CaptainLearning\Entity\Company">
2
+	<field mapping="pictures"
3
+		name="logoFile"
4
+		filename_property="logo"
5
+		/>
6
+</vich_uploader>

+ 1
- 1
config/vich_uploader/Entity.User.User.xml View File

@@ -1,5 +1,5 @@
1 1
 <vich_uploader class="Logipro\CaptainLearning\Entity\User\User">
2
-	<field mapping="user_images"
2
+	<field mapping="pictures"
3 3
 		name="fotoFile"
4 4
 		filename_property="foto"
5 5
 		/>

+ 165
- 32
src/CaptainLearning/Command/MigrateCommand.php View File

@@ -17,6 +17,7 @@ use Logipro\CaptainLearning\Entity\Type\EnumSessionPlanType;
17 17
 use Logipro\CaptainLearning\Entity\Type\EnumPersonStatutType;
18 18
 use Logipro\CaptainLearning\Entity\Type\EnumTrainingTypeType;
19 19
 use Logipro\CaptainLearning\Entity\Type\EnumUserCivilityType;
20
+use Logipro\CaptainLearning\Entity\Type\EnumEstimateStatutType;
20 21
 use Logipro\CaptainLearning\Entity\Type\EnumTrainingStatutType;
21 22
 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
22 23
 use Logipro\CaptainLearning\Entity\Type\EnumTrainingCertificationType;
@@ -211,6 +212,18 @@ class MigrateCommand extends ContainerAwareCommand
211 212
 		$result = $this->oldconnection->query($query);
212 213
 		while ($row = $result->fetch())
213 214
 		{
215
+			// corrige les références erronées
216
+			$refSession = $row['ref_session'];
217
+			if (!$this->testDistRef('session',$refSession))
218
+			{
219
+				$refSession = null;
220
+			}
221
+			$refEstimate = $row['ref_devis'];
222
+			if (!$this->testDistRef('estimate',$refEstimate))
223
+			{
224
+				continue;
225
+			}
226
+			
214 227
 			// ajoute le devis
215 228
 			$newCountry = array(
216 229
 				"estimateLine_id" => $row['id_ligne_devis'],
@@ -219,8 +232,8 @@ class MigrateCommand extends ContainerAwareCommand
219 232
 				"tva" => $row['tva'],
220 233
 				"designation" => $row['designation'],
221 234
 				"reference" =>$row['reference'],
222
-				"ref_session" => $this->setValueIfEqual(null,$row['ref_session']),
223
-				"ref_estimate" => $row['ref_devis'],
235
+				"ref_session" => $this->setValueIfEqual(null,$refSession),
236
+				"ref_estimate" => $refEstimate,
224 237
 				"order_line" => $row['ordre'],
225 238
 			);
226 239
 
@@ -228,6 +241,19 @@ class MigrateCommand extends ContainerAwareCommand
228 241
 		}
229 242
 	}
230 243
 
244
+	private function getEnumValue($options,$value,$defaultValue)
245
+	{
246
+		if (!isset($options[$value]))
247
+		{
248
+			if (!$defaultValue)
249
+			{
250
+				return reset($options);
251
+			}
252
+			return $defaultValue;
253
+		}
254
+		return $options[$value];
255
+	}
256
+
231 257
 	protected function migrateEstimate()
232 258
 	{
233 259
 		$newTableName = 'cpt_estimate';
@@ -244,18 +270,49 @@ class MigrateCommand extends ContainerAwareCommand
244 270
 			"F" => EnumUserCivilityType::CIVILITY_MS,
245 271
 		);
246 272
 
273
+		$statut = array(
274
+			'DEMANDE_EN_ATTENTE' => EnumEstimateStatutType::STATUT_WAITING,
275
+			'DEMANDE_REFUSEE' => EnumEstimateStatutType::STATUT_REFUSED,
276
+			'DEVIS_A_EMETTRE' => EnumEstimateStatutType::STATUT_FOR_EMIT,
277
+			'DEVIS_EMIS' => EnumEstimateStatutType::STATUT_EMIT,
278
+			'PAIEMENT_EN_COURS' => EnumEstimateStatutType::STATUT_PAYMENT,
279
+			'PAIEMENT_SUCCES' => EnumEstimateStatutType::STATUT_PAYMENT_SUCCES,
280
+			'PAIEMENT_ECHEC' => EnumEstimateStatutType::STATUT_PAYMENT_FAIL
281
+		);
282
+
247 283
 		$query = 'SELECT * FROM ' . $oldTableName;
248 284
 		$result = $this->oldconnection->query($query);
249 285
 		while ($row = $result->fetch())
250 286
 		{
287
+			$row['ref_formation_intra'];
288
+
289
+			// corrige les références erronées
290
+			$refTraining = $row['ref_formation_intra'];
291
+			if (!$this->testDistRef('training',$refTraining))
292
+			{
293
+				$refTraining = null;
294
+			}
295
+
296
+			$refClient = $row['ref_client'];
297
+			if (!$this->testDistRef('client',$refClient))
298
+			{
299
+				continue;
300
+			}
301
+
302
+			$refTrainingOrganization = $row['ref_organisme_formation'];
303
+			if (!$this->testDistRef('training_organization',$refTrainingOrganization))
304
+			{
305
+				continue;
306
+			}
307
+
251 308
 			// ajoute le devis
252 309
 			$newEstimate = array(
253 310
 				"estimate_id" => $row['id_devis'],
254 311
 				"date_create" => $row['date_creation'],
255 312
 				"date_edit" => $this->setValueIfEqual(null,$row['date_modification'],"0000-00-00 00:00:00"),
256
-				"statut" => $row['statut'],
313
+				"statut" => $this->getEnumValue($statut,$row['statut'],EnumEstimateStatutType::STATUT_WAITING),
257 314
 				"coment" => $row['commentaire'],
258
-				"client_civility" => $civilities[$row['client_genre']],
315
+				"client_civility" => $this->getEnumValue($civilities,$row['client_genre'],EnumUserCivilityType::CIVILITY_NA),
259 316
 				"client_name" => $row['client_nom'],
260 317
 				"client_first_name" => $row['client_prenom'],
261 318
 				"client_denomination" => $row['client_denomination'],
@@ -267,9 +324,9 @@ class MigrateCommand extends ContainerAwareCommand
267 324
 				"client_phone" => $row['client_tel'],
268 325
 				"reference" => $row['reference'],
269 326
 				"object" => $row['objet'],
270
-				"ref_training_organization" => $row['ref_organisme_formation'],
271
-				"ref_client" => $row['ref_client'],
272
-				"ref_training" => $row['ref_formation_intra'],
327
+				"ref_training_organization" => $refTrainingOrganization,
328
+				"ref_client" => $refClient,
329
+				"ref_training" => $refTraining,
273 330
 			);
274 331
 			$this->insertData($newTableName,$newEstimate);
275 332
 		}
@@ -304,6 +361,12 @@ class MigrateCommand extends ContainerAwareCommand
304 361
 		$result = $this->oldconnection->query($query);
305 362
 		while ($row = $result->fetch())
306 363
 		{
364
+			$refFormation = $row['ref_formation'];
365
+			if (!$this->testDistRef('training',$refFormation))
366
+			{
367
+				continue;
368
+			}
369
+
307 370
 			// ajoute le nouveau pays
308 371
 			$newCountry = array(
309 372
 				"session_id" => $row['id_session'],
@@ -313,19 +376,31 @@ class MigrateCommand extends ContainerAwareCommand
313 376
 				"date_end_subscribe" => $this->setValueIfEqual(null,$row['date_cloture_inscription'],"0000-00-00 00:00:00"),
314 377
 				"minimal_place_number" => $this->setValueIfEqual(0,$row['nombre_place_min']),
315 378
 				"maximal_place_number" => $this->setValueIfEqual(0,$row['nombre_place_max']),
316
-				"statut" => $statut[$row['statut']],
379
+				"statut" => $this->getEnumValue($statut,$row['statut'],EnumTrainingStatutType::STATUT_NOT_PUBLISHED),
317 380
 				"price" => $row['prix_ht'],
318 381
 				"duration" => $row['duree'],
319 382
 				"staggering" => $row['etalement'],
320 383
 				"code" => $row['code'],
321 384
 				"ref_place" => $this->setValueIfEqual(null,$row['ref_lieu']),
322
-				"ref_training" => $row['ref_formation'],
385
+				"ref_training" => $refFormation,
323 386
 			);
324 387
 
325 388
 			$this->insertData($newTableName,$newCountry);
326 389
 		}
327 390
 	}
328 391
 
392
+	protected function testDistRef($symfonyObject,$ref)
393
+	{
394
+		$query = "SELECT 1 FROM cpt_" . $symfonyObject . " WHERE " . $symfonyObject . "_id=" . (int)$ref;
395
+		$result = $this->connection->query($query);
396
+		$row = $result->fetch();
397
+		if (!$row)
398
+		{
399
+			return false;
400
+		}
401
+		return true;
402
+	}
403
+
329 404
 	protected function migrateSessionPlan()
330 405
 	{
331 406
 		$newTableName = 'cpt_sessionplan';
@@ -346,6 +421,13 @@ class MigrateCommand extends ContainerAwareCommand
346 421
 		$result = $this->oldconnection->query($query);
347 422
 		while ($row = $result->fetch())
348 423
 		{
424
+			// corrige les références erronées
425
+			$refEntreprise = $row['ref_entreprise'];
426
+			if (!$this->testDistRef('company',$refEntreprise))
427
+			{
428
+				$refEntreprise = null;
429
+			}
430
+
349 431
 			if ($row['date_debut'] == "0000-00-00 00:00:00")
350 432
 			{
351 433
 				continue;
@@ -358,10 +440,10 @@ class MigrateCommand extends ContainerAwareCommand
358 440
 				"date_end" => $row['date_fin'],
359 441
 				"duration" => $row['duree'],
360 442
 				"date_create" => $this->setValueIfEqual(date("Y-m-d h:i:s"),$row['date_creation'],"0000-00-00 00:00:00"),
361
-				"type" => $types[$row['type']],
443
+				"type" => $this->getEnumValue($types,$row['type'],EnumSessionPlanType::TYPE_USER_WISH),
362 444
 				"description" => $row['description'],
363 445
 				"ref_session" => $this->setValueIfEqual(null,$row['ref_session']),
364
-				"ref_company" => $this->setValueIfEqual(null,$row['ref_entreprise']),
446
+				"ref_company" => $this->setValueIfEqual(null,$refEntreprise),
365 447
 				"ref_training" => $this->setValueIfEqual(null,$row['ref_formation']),
366 448
 				"ref_user" => $this->setValueIfEqual(null,$row['ref_utilisateur']),
367 449
 			);
@@ -373,8 +455,13 @@ class MigrateCommand extends ContainerAwareCommand
373 455
 		$result = $this->oldconnection->query($query);
374 456
 		while ($row = $result->fetch())
375 457
 		{
458
+			$refSessionPlan = $row['ref_session_plan'];
459
+			if (!$this->testDistRef('sessionplan',$refSessionPlan))
460
+			{
461
+				continue;
462
+			}
376 463
 			$data = array(
377
-				"ref_session_plan" => $row['ref_session_plan'],
464
+				"ref_session_plan" => $refSessionPlan,
378 465
 				"ref_person" => $row['ref_personne'],
379 466
 			);
380 467
 
@@ -416,7 +503,7 @@ class MigrateCommand extends ContainerAwareCommand
416 503
 				"ref_client" => $refClient,
417 504
 				"size" => $row['taille'],
418 505
 				"name" => $row['nom'],
419
-				"type" => $types[$row['type']],
506
+				"type" => $this->getEnumValue($types,$row['type'],EnumRecordType::TYPE_OTHER),
420 507
 			);
421 508
 
422 509
 			$this->insertData($newTableName,$newCountry);
@@ -428,10 +515,10 @@ class MigrateCommand extends ContainerAwareCommand
428 515
 		{
429 516
 			$data = array(
430 517
 				"ref_training" => $row['ref_formation'],
431
-				"ref_list" => $row['ref_liste'],
518
+				"ref_record" => $row['ref_liste'],
432 519
 			);
433 520
 
434
-			$this->insertData('cpt_map_list_training',$data);
521
+			$this->insertData('cpt_map_record_training',$data);
435 522
 		}
436 523
 
437 524
 		$query = 'SELECT * FROM cpt_map_liste_personne';
@@ -493,14 +580,14 @@ class MigrateCommand extends ContainerAwareCommand
493 580
 			// ajoute le nouveau pays
494 581
 			$newCountry = array(
495 582
 				"person_id" => $row['id_personne'],
496
-				"civility" => $civilities[$row['civilite']],
583
+				"civility" => $this->getEnumValue($civilities,$row['civilite'],EnumUserCivilityType::CIVILITY_NA),
497 584
 				"name" => $row['nom'],
498 585
 				"first_name" => $row['prenom'],
499 586
 				"email" => $row['email'],
500 587
 				"address" => $row['adresse'],
501 588
 				"postal_code" => $row['code_postal'],
502 589
 				"city" => $row['ville'],
503
-				"statut" => $statuts[$row['statut']],
590
+				"statut" => $this->getEnumValue($statuts,$row['statut'],EnumPersonStatutType::TYPE_DEMAND),
504 591
 				"date_create" => $this->setValueIfEqual(date("Y-m-d h:i:s"),$row['date_creation'],"0000-00-00 00:00:00"),
505 592
 				"ref_user" => $refUser,
506 593
 				"ref_company" => $row['ref_entreprise'],
@@ -566,14 +653,27 @@ class MigrateCommand extends ContainerAwareCommand
566 653
 			"QUALIFIANTE" => EnumTrainingCertificationType::CERTIFICATION_QUALIFYING
567 654
 		);
568 655
 
569
-		$query = 'SELECT * FROM ' . $oldTableName;
656
+		$query = 'SELECT *,cover.vue_file as cover,logo.vue_file as logo FROM ' . $oldTableName . 
657
+		' left outer join vue as logo on ' . $oldTableName . '.vue_logo=logo.id_vue'.
658
+		' left outer join vue as cover on ' . $oldTableName . '.vue_couverture=cover.id_vue';
570 659
 		$result = $this->oldconnection->query($query);
571 660
 		while ($row = $result->fetch())
572 661
 		{
662
+			$refFormation = $row['id_formation'];
663
+			$queryMap = 'SELECT vue.vue_file as vue_file FROM cpt_map_vue_formation 
664
+			inner join vue on vue.id_vue=cpt_map_vue_formation.ref_vue
665
+			WHERE ref_formation=' . $refFormation . ' ORDER BY ordre ASC';
666
+			$resultMap = $this->oldconnection->query($queryMap);
667
+			$pictures = array();
668
+			while ($rowMap = $resultMap->fetch())
669
+			{
670
+				$pictures[] = $rowMap["vue_file"];
671
+			}
672
+
573 673
 			// ajoute le nouveau pays
574 674
 			$newCountry = array(
575 675
 				"training_id" => $row['id_formation'],
576
-				"statut" => $statut[$row['statut']],
676
+				"statut" => $this->getEnumValue($statut,$row['statut'],EnumTrainingStatutType::STATUT_NOT_PUBLISHED),
577 677
 				"code" => $row['code'],
578 678
 				"name" => $row['nom'],
579 679
 				"hook" => $row['accroche'],
@@ -593,9 +693,9 @@ class MigrateCommand extends ContainerAwareCommand
593 693
 				"acquired_evaluation" => $row['evaluation_acquis'],
594 694
 				"level" => $row['niveau'],
595 695
 				"border_modalities" => $row['modalites_encadrement'],
596
-				"type" => $type[$row['type']],
597
-				"optionnal_type" => $type[$row['type_optionnel']],
598
-				"certification" => $certification[$row['certification']],
696
+				"type" => $this->getEnumValue($type,$row['type'],EnumTrainingTypeType::TYPE_NA),
697
+				"optionnal_type" => $this->getEnumValue($type,$row['type_optionnel'],EnumTrainingTypeType::TYPE_NA),
698
+				"certification" => $this->getEnumValue($certification,$row['certification'],EnumTrainingCertificationType::CERTIFICATION_NONE),
599 699
 				"date_create" => $row['date_creation'],
600 700
 				"date_edit" => $this->setValueIfEqual(null,$row['date_modification'],'0000-00-00 00:00:00'),
601 701
 				"date_es" => $this->setValueIfEqual(null,$row['date_synchronisation_elasticsearch'],'0000-00-00 00:00:00'),
@@ -608,8 +708,21 @@ class MigrateCommand extends ContainerAwareCommand
608 708
 				"ref_category" => $this->setValueIfEqual(null,$row['ref_categorie']),
609 709
 				"ref_buisness_category" => $this->setValueIfEqual(null,$row['ref_categorie_metier']),
610 710
 				"ref_place" => $this->setValueIfEqual(null,$row['ref_lieu']),
611
-				"ref_training_organization" => $row['ref_organisme_formation']
711
+				"ref_training_organization" => $row['ref_organisme_formation'],
712
+
713
+				"logo" => $row['logo'],
714
+				"cover" => $row['cover'],
715
+
716
+				"picture_one" => @$pictures[0],
717
+				"picture_two" => @$pictures[1],
718
+				"picture_tree" => @$pictures[2],
719
+				"picture_four" => @$pictures[3],
720
+				"picture_five" => @$pictures[4],
612 721
 			);
722
+
723
+			
724
+
725
+
613 726
 			$this->insertData($newTableName,$newCountry);
614 727
 		}
615 728
 	}
@@ -684,7 +797,7 @@ class MigrateCommand extends ContainerAwareCommand
684 797
 		);
685 798
 
686 799
 		$query = 'SELECT * FROM ' . $oldTableName .
687
-		'left outer join vue on mod_utilisateur.ref_vue=vue.id_vue';
800
+		' left outer join vue on mod_utilisateur.vue_photo=vue.id_vue';
688 801
 		$result = $this->oldconnection->query($query);
689 802
 		while ($row = $result->fetch())
690 803
 		{
@@ -692,7 +805,7 @@ class MigrateCommand extends ContainerAwareCommand
692 805
 			$newUser = array(
693 806
 				"user_id" => $row['id_utilisateur'],
694 807
 				"email" => $row['mail'],
695
-				"civility" => $civilities[$row['civilite']],
808
+				"civility" => $this->getEnumValue($civilities,$row['civilite'],EnumUserCivilityType::CIVILITY_NA),
696 809
 				"name" => $row['nom_utilisateur'],
697 810
 				"first_name" => $row['prenom'],
698 811
 				"role" => EnumRoleType::ROLE_USER,
@@ -787,7 +900,9 @@ class MigrateCommand extends ContainerAwareCommand
787 900
 			return;
788 901
 		}
789 902
 
790
-		$query = 'SELECT * FROM ' . $oldTableName;
903
+		$query = 'SELECT * FROM ' . $oldTableName . 
904
+		' left outer join vue on ' . $oldTableName . '.vue_logo=vue.id_vue';
905
+		
791 906
 		$result = $this->oldconnection->query($query);
792 907
 		while ($row = $result->fetch())
793 908
 		{
@@ -805,9 +920,10 @@ class MigrateCommand extends ContainerAwareCommand
805 920
 				"submit_tva" => $row['soumis_tva'],
806 921
 				"intra_community_tva" => $row['tva_intracommunautaire'],
807 922
 				"date_create" => $row['date_creation_fiche'],
808
-				"type" => $types[$row['type_societe']],
923
+				"type" => $this->getEnumValue($types,$row['type_societe'],EnumCompanyType::TYPE_COMPANY),
809 924
 				"salaried_number" => $row['nombre_salarie'],
810 925
 				"ref_country" => $row['ref_pays'],
926
+				"logo" => $row['vue_file']
811 927
 			);
812 928
 
813 929
 			/* @FIXME pour les vues
@@ -864,14 +980,20 @@ class MigrateCommand extends ContainerAwareCommand
864 980
 			return;
865 981
 		}
866 982
 
867
-		$query = 'SELECT * FROM ' . $oldTableName;
983
+		$query = 'SELECT *,cover.vue_file as cover,logo.vue_file as logo,kbis.vue_file as kbis,identite.vue_file as identite,banner.vue_file as banner FROM ' . $oldTableName . 
984
+		' left outer join vue as cover on ' . $oldTableName . '.vue_couverture=cover.id_vue'.
985
+		' left outer join vue as logo on ' . $oldTableName . '.vue_logo=logo.id_vue'.
986
+		' left outer join vue as kbis on ' . $oldTableName . '.vue_kbis=kbis.id_vue'.
987
+		' left outer join vue as identite on ' . $oldTableName . '.vue_identite=identite.id_vue'.
988
+		' left outer join vue as banner on ' . $oldTableName . '.vue_banniere=banner.id_vue';
989
+
868 990
 		$result = $this->oldconnection->query($query);
869 991
 		while ($row = $result->fetch())
870 992
 		{
871 993
 			// ajoute le nouvel of
872 994
 			$newTrainingOrganization = array(
873 995
 				"training_organization_id" => $row['id_organisme_formation'],
874
-				"valid" => $typesValid[$row['valide']],
996
+				"valid" => $this->getEnumValue($typesValid,$row['valide'],EnumTrainingOrganizationValidType::VALID_WAITING),
875 997
 				"number" => $row['numero'],
876 998
 				"number_quality_agreement" => $row['numero_agrement_qualite'],
877 999
 				//"date_quality_agreement" => $dateAgreement,
@@ -892,7 +1014,15 @@ class MigrateCommand extends ContainerAwareCommand
892 1014
 				"stripe_publishable_key" => $row['stripe_publishable_key'],
893 1015
 				"is_datadocked" => $row['est_datadock'],
894 1016
 				"accept_subrogation" => $row['accept_paiement_subrogation'],
895
-				"description" => $row['description']
1017
+				"description" => $row['description'],
1018
+
1019
+				"cover" => $row['cover'],
1020
+				"logo" => $row['logo'],
1021
+				"kbis" => $row['kbis'],
1022
+				"identity" => $row['identite'],
1023
+				"banner" => $row['banner']
1024
+
1025
+
896 1026
 			);
897 1027
 
898 1028
 			$dateAgreement = $row['date_agrement_qualite'];
@@ -982,7 +1112,9 @@ class MigrateCommand extends ContainerAwareCommand
982 1112
 		$newTableName = 'cpt_category';
983 1113
 		$oldTableName = 'cpt_categorie';
984 1114
 
985
-		$query = "SELECT * FROM $oldTableName WHERE ref_categorie=" . (int)$refCategory;
1115
+		$query = "SELECT * FROM $oldTableName " . 
1116
+		' left outer join vue on ' . $oldTableName . '.vue_image=vue.id_vue' .
1117
+		" WHERE ref_categorie=" . (int)$refCategory;
986 1118
 		$result = $this->oldconnection->query($query);
987 1119
 
988 1120
 		$classifications = array(
@@ -999,7 +1131,7 @@ class MigrateCommand extends ContainerAwareCommand
999 1131
 				"category_id" => $idCategorie,
1000 1132
 				"name" => $row["nom"],
1001 1133
 				"level" => $row["niveau"],
1002
-				"type_classification" => $classifications[$row["type_classification"]],
1134
+				"type_classification" => $this->getEnumValue($classifications,$row["type_classification"],EnumCategoryType::TYPE_CATEGORY),
1003 1135
 				"keywords" => $row["mots_cles"],
1004 1136
 				"buisness_code" => $row["code_metier"],
1005 1137
 				"meta_title" => $row["meta_title"],
@@ -1007,6 +1139,7 @@ class MigrateCommand extends ContainerAwareCommand
1007 1139
 				"meta_og_title" => $row["meta_og_title"],
1008 1140
 				"meta_og_description" => $row["meta_og_description"],
1009 1141
 				"ref_category" => $this->setValueIfEqual(null,$row["ref_categorie"],0),
1142
+				"picture" => $row['vue_file'],
1010 1143
 			);
1011 1144
 
1012 1145
 			$this->insertData($newTableName,$newCategory);

+ 23
- 0
src/CaptainLearning/Controller/Common/FileController.php View File

@@ -0,0 +1,23 @@
1
+<?php
2
+namespace Logipro\CaptainLearning\Controller\Common;
3
+
4
+use Symfony\Component\HttpFoundation\Request;
5
+use Symfony\Component\HttpFoundation\Response;
6
+use Logipro\CaptainLearning\Controller\AppController;
7
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
+use Symfony\Component\HttpFoundation\ResponseHeaderBag;
9
+
10
+class FileController extends AppController
11
+{
12
+	public function drawFile($name,Request $request)
13
+	{
14
+		$path = $this->getParameter('app.path.upload_dir') . "/" . $name;
15
+		if (file_exists($path))
16
+		{
17
+			return $this->file($path,$name,ResponseHeaderBag::DISPOSITION_INLINE);
18
+		}
19
+		return new Response();
20
+		
21
+	}
22
+}
23
+?>

+ 2
- 0
src/CaptainLearning/Entity/Category/Category.php View File

@@ -38,6 +38,8 @@ class Category extends AbstractEntity
38 38
     private $metaOGTitle = '';
39 39
     private $metaOGDescription = '';
40 40
 
41
+    private $picture;
42
+
41 43
     public function __construct()
42 44
     {
43 45
         $this->children = new ArrayCollection();

+ 2
- 2
src/CaptainLearning/Entity/Company.php View File

@@ -100,8 +100,8 @@ class Company extends AbstractEntity
100 100
 	 */
101 101
 	protected $client;
102 102
 
103
-	protected $imageLogo;
104
-	protected $imageName;
103
+	protected $logo;
104
+	protected $logoFile;
105 105
 
106 106
 	/**
107 107
 	 * 

+ 8
- 9
src/CaptainLearning/Entity/Training/Training.php View File

@@ -201,15 +201,14 @@ class Training extends AbstractEntity
201 201
      */
202 202
     protected $videoUrl;
203 203
 
204
-    /**
205
-     * couverture
206
-     */
207
-    protected $coverFile;
208
-
209
-    /**
210
-     * logo
211
-     */
212
-    protected $logoFile;
204
+    protected $cover;
205
+    protected $logo;
206
+
207
+    protected $pictureOne;
208
+    protected $pictureTwo;
209
+    protected $pictureTree;
210
+    protected $pictureFour;
211
+    protected $pictureFive;
213 212
 
214 213
     /**
215 214
      * prix sur demande

+ 6
- 0
src/CaptainLearning/Entity/TrainingOrganization.php View File

@@ -141,6 +141,12 @@ class TrainingOrganization extends AbstractEntity
141 141
 	 * @var Company
142 142
 	 */
143 143
 	protected $company;
144
+
145
+	protected $cover;
146
+	protected $logo;
147
+	protected $kbis;
148
+	protected $identity;
149
+	protected $banner;
144 150
 	
145 151
 	public function __construct()
146 152
 	{

+ 2
- 2
translations/messages.fr.xlf View File

@@ -1129,8 +1129,8 @@
1129 1129
 				<source>label_profil_welcome</source>
1130 1130
 				<target>Bonjour matelot</target>
1131 1131
 			</trans-unit>
1132
-			<trans-unit id="abel_profil_welcome_widget_content">
1133
-				<source>abel_profil_welcome_widget_content</source>
1132
+			<trans-unit id="label_profil_welcome_widget_content">
1133
+				<source>label_profil_welcome_widget_content</source>
1134 1134
 				<target>C'est ici que vous allez pouvoir :</target>
1135 1135
 			</trans-unit>
1136 1136
 			<trans-unit id="label_profil_welcome_to_profil_action">

Loading…
Cancel
Save