Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 12114 | Rev 15371 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 12114 Rev 15150
Línea 16... Línea 16...
16
use LeadersLinked\Mapper\SurveyJobDescriptionMapper;
16
use LeadersLinked\Mapper\SurveyJobDescriptionMapper;
17
use LeadersLinked\Mapper\SurveyIndustryMapper;
17
use LeadersLinked\Mapper\SurveyIndustryMapper;
18
use LeadersLinked\Mapper\SurveySkillMapper;
18
use LeadersLinked\Mapper\SurveySkillMapper;
19
use LeadersLinked\Mapper\SurveyLocationMapper;
19
use LeadersLinked\Mapper\SurveyLocationMapper;
20
use LeadersLinked\Mapper\SurveyLanguageMapper;
20
use LeadersLinked\Mapper\SurveyLanguageMapper;
21
use LeadersLinked\Model\Location;
-
 
22
use LeadersLinked\Mapper\LocationMapper;
-
 
23
use LeadersLinked\Mapper\IndustryMapper;
21
use LeadersLinked\Mapper\IndustryMapper;
24
use LeadersLinked\Mapper\JobDescriptionMapper;
22
use LeadersLinked\Mapper\JobDescriptionMapper;
25
use LeadersLinked\Mapper\BehaviorMapper;
-
 
26
use LeadersLinked\Mapper\JobDescriptionBehaviorCompetencyMapper;
-
 
27
use LeadersLinked\Mapper\CompanyMapper;
-
 
28
use LeadersLinked\Mapper\LanguageMapper;
23
use LeadersLinked\Mapper\LanguageMapper;
29
use LeadersLinked\Model\Company;
-
 
30
use LeadersLinked\Mapper\SkillMapper;
24
use LeadersLinked\Mapper\SkillMapper;
31
use LeadersLinked\Form\SurveySegmentedForm;
-
 
32
use LeadersLinked\Form\SurveyForm;
25
use LeadersLinked\Form\SurveyForm;
33
use LeadersLinked\Model\Survey;
26
use LeadersLinked\Model\Survey;
34
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
27
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
35
use LeadersLinked\Model\SurveyJobDescription;
28
use LeadersLinked\Model\SurveyJobDescription;
36
use LeadersLinked\Model\SurveySkill;
29
use LeadersLinked\Model\SurveySkill;
Línea 127... Línea 120...
127
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
120
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
128
                    $order_direction = 'ASC';
121
                    $order_direction = 'ASC';
129
                }
122
                }
Línea 130... Línea 123...
130
 
123
 
131
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
-
 
132
                $allowAdd = $acl->isAllowed($currentUser->usertype_id, 'survey/add');
124
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
133
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'survey/edit');
125
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'survey/edit');
134
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'survey/delete');
-
 
135
                $allowSegment = $acl->isAllowed($currentUser->usertype_id, 'survey/segment');
126
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'survey/delete');
136
 
127
            
137
                $surveyMapper = SurveyMapper::getInstance($this->adapter);
128
                $surveyMapper = SurveyMapper::getInstance($this->adapter);
Línea 138... Línea 129...
138
                $paginator = $surveyMapper->fetchAllDataTableByCompanyId($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
129
                $paginator = $surveyMapper->fetchAllDataTableByCompanyId($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
139
 
130
 
140
                $items = [];
-
 
141
                $records = $paginator->getCurrentItems();
-
 
142
              
-
 
143
                foreach ($records as $record) {
-
 
Línea -... Línea 131...
-
 
131
                $items = [];
-
 
132
                $records = $paginator->getCurrentItems();
-
 
133
 
-
 
134
                $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
-
 
135
                
-
 
136
                $forms = [];
-
 
137
                
-
 
138
                foreach ($records as $record) {
-
 
139
                   
-
 
140
                    if(isset($forms[$record->form_id])) {
-
 
141
                        
-
 
142
                        $surveyForm = $forms[$record->form_id]; 
-
 
143
                    } else {
-
 
144
                        $surveyForm = $surveyFormMapper->fetchOne($record->form_id);
-
 
145
                        $forms[$record->form_id] = $surveyForm;
-
 
146
                    }
-
 
147
                    
-
 
148
                    $dtSinceDate = \DateTime::createFromFormat('Y-m-d', $record->since_date);
-
 
149
                    $dtLastDate = \DateTime::createFromFormat('Y-m-d', $record->last_date);
144
                    $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
150
                    
145
                    $surveyForm = $surveyFormMapper->fetchOne($record->form_id);
151
                    
146
 
152
                    
147
                    $item = [
153
                    $item = [
-
 
154
                        'id' => $record->id,
-
 
155
                        'name' => $record->name,
148
                        'id' => $record->id,
156
                        'form' => $surveyForm->name,
149
                        'name' => $record->name,
157
                        'since_date' => $dtSinceDate->format('d/m/Y'),
150
                        'form' => $surveyForm->name,
158
                        'last_date' => $dtLastDate->format('d/m/Y'),
151
                        'status' => $record->status,
159
                        'status' => $record->status,
152
                        'actions' => [
-
 
153
                            'link_edit' => $this->url()->fromRoute('survey/edit', ['id' => $record->uuid]),
160
                        'actions' => [
154
                            'link_delete' => $this->url()->fromRoute('survey/delete', ['id' => $record->uuid]),
161
                            'link_edit' => $allowEdit ? $this->url()->fromRoute('survey/edit', ['id' => $record->uuid]) : '',
Línea 155... Línea 162...
155
                            'link_segment' => $this->url()->fromRoute('survey/segment', ['id' => $record->uuid])
162
                            'link_delete' => $allowDelete  ? $this->url()->fromRoute('survey/delete', ['id' => $record->uuid]) : '',
156
                        ]
163
                        ]
Línea 197... Línea 204...
197
            
204
            
Línea 198... Línea 205...
198
            $form = new SurveyForm($this->adapter, $currentCompany->id);
205
            $form = new SurveyForm($this->adapter, $currentCompany->id);
199
            
206
            
200
            $dataPost = $request->getPost()->toArray();
-
 
201
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : SurveyForm::STATUS_INACTIVE;           
-
 
202
            $actual_date = time();
-
 
203
            $actual_dt = date('Y-m-d', $actual_date);
-
 
204
            $since_date = strtotime($dataPost['since_date']);
-
 
205
            // return new JsonModel([
-
 
206
            //     'success' => false,
-
 
207
            //     'data' => [
-
 
208
            //         'actual_date' => $actual_dt,
-
 
209
            //         'since_date'  => $dataPost['since_date']
-
 
210
            //     ]
-
 
211
            // ]);
-
 
212
            
-
 
213
            if($dataPost['since_date'] > $dataPost['last_date']){
-
 
214
                return new JsonModel([
-
 
215
                    'success' => false,
-
 
216
                    'data' => 'ERROR_UNAUTHORIZED'
-
 
217
                ]);
-
 
218
            }
-
 
219
 
-
 
220
            if($actual_dt > $dataPost['since_date']){
-
 
221
                return new JsonModel([
-
 
222
                    'success' => false,
-
 
223
                    'data' => 'ERROR_UNAUTHORIZED'
-
 
Línea 224... Línea 207...
224
                ]);   
207
            $dataPost = $request->getPost()->toArray();
Línea 225... Línea 208...
225
            }
208
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : SurveyForm::STATUS_INACTIVE;           
226
 
209
 
Línea 247... Línea 230...
247
                //$result = $surveyMapper->insert($survey);
230
                //$result = $surveyMapper->insert($survey);
Línea 248... Línea 231...
248
 
231
 
249
                if($surveyMapper->insert($survey)) {
232
                if($surveyMapper->insert($survey)) {
Línea 250... Línea -...
250
                    $survey = $surveyMapper->fetchOne($survey->id);
-
 
251
 
-
 
252
                    $jobDescription = new SurveyJobDescription();
-
 
253
                    $skill = new SurveySkill();
-
 
254
                    $industry = new SurveyIndustry();
-
 
255
                    $language = new SurveyLanguage();
233
                    $survey = $surveyMapper->fetchOne($survey->id);
256
 
-
 
257
                    if(!empty($dataPost['location_search'])){ 
234
 
258
 
-
 
259
                        $surveyLocationMapper = SurveyLocationMapper::getInstance($this->adapter);
-
 
260
    
-
 
261
                        $ok = true;
235
                    if(!empty($dataPost['location_search'])){ 
262
 
236
                                                $record = new SurveyLocation();
263
                        $formatted_address = $dataPost['formatted_address'];
237
                        $record->formatted_address = $dataPost['formatted_address'];
264
                        $city1 = $dataPost['city1'];
238
                        $record->city1 = $dataPost['city1'];
265
                        $city2 = $dataPost['city2'];
239
                        $record->city2 = $dataPost['city2'];
266
                        $address1 = $dataPost['address1'];
240
                        $record->address1 = $dataPost['address1'];
267
                        $address2 = $dataPost['address2'];
241
                        $record->address2 = $dataPost['address2'];
268
                        $country = $dataPost['country'];
242
                        $record->country = $dataPost['country'];
269
                        $latitude = $dataPost['latitude'];
243
                        $record->latitude = $dataPost['latitude'];
270
                        $longitude = $dataPost['longitude'];
244
                        $record->longitude = $dataPost['longitude'];
271
                        $postal_code = $dataPost['postal_code'];
-
 
272
                        $state = $dataPost['state'];
-
 
273
 
-
 
274
                        
-
 
275
                        $record = new SurveyLocation();
-
 
276
                        $record->formatted_address = $formatted_address; 
-
 
277
                        $record->city1 = $city1;
-
 
278
                        $record->city2 = $city2;
-
 
279
                        $record->address1 = $address1;
-
 
280
                        $record->address2 = $address2;
-
 
281
                        $record->country = $country;
-
 
282
                        $record->latitude = $latitude;
-
 
283
                        $record->longitude = $longitude;
-
 
284
                        $record->postal_code = $postal_code;
245
                        $record->postal_code = $dataPost['postal_code'];
285
                        $record->state = $state;
-
 
286
                        $record->survey_id = $survey->id;
-
 
287
                        $result = $surveyLocationMapper->insert($record);
-
 
288
                        $ok = $ok && $result;
-
 
289
                           //}
246
                        $record->state = $dataPost['state'];
-
 
247
                        $record->survey_id = $survey->id;
290
                          if($ok){
248
                        
291
    
249
                        $surveyLocationMapper = SurveyLocationMapper::getInstance($this->adapter);
Línea 292... Línea 250...
292
                        }
250
                        $surveyLocationMapper->insert($record);
293
                    }
-
 
294
 
-
 
295
                    if(!empty($dataPost['job_description_id'])){ 
-
 
296
 
251
                    }
297
                       // print_r($dataPost['job_description_id']);
252
 
Línea 298... Línea -...
298
 
-
 
299
                        $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
-
 
300
                        $surveyJobDescriptionMapper = SurveyJobDescriptionMapper::getInstance($this->adapter);
253
                    if(!empty($dataPost['job_description_id'])){ 
301
 
-
 
302
                        $ok = true;
254
                        $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
303
 
-
 
304
                        foreach($dataPost['job_description_id'] as $jobDescriptionUuid) {
-
 
305
                        
255
                        $surveyJobDescriptionMapper = SurveyJobDescriptionMapper::getInstance($this->adapter);
306
                           // echo '$jobDescriptionUuid = ' . $jobDescriptionUuid ; 
-
 
307
 
-
 
308
 
-
 
309
                            $jobDescription = $jobDescriptionMapper->fetchOneByUuid($jobDescriptionUuid);
-
 
310
 
256
 
311
                           // print_r($jobDescription);
257
                        foreach($dataPost['job_description_id'] as $jobDescriptionUuid) 
312
                            //print_r($currentCompany);
258
                        {
313
 
259
                            $jobDescription = $jobDescriptionMapper->fetchOneByUuid($jobDescriptionUuid);
Línea 314... Línea -...
314
                            if($jobDescription && $jobDescription->company_id == $currentCompany->id) {
-
 
315
                                $record = new SurveyJobDescription();
-
 
316
                                $record->job_description_id = $jobDescription->id;
260
                            if($jobDescription && $jobDescription->company_id == $currentCompany->id) {
317
                                $record->survey_id = $survey->id;
-
 
318
 
261
                                $record = new SurveyJobDescription();
319
                            
262
                                $record->job_description_id = $jobDescription->id;
320
 
-
 
321
                                $result = $surveyJobDescriptionMapper->insert($record);
-
 
322
                                $ok = $ok && $result;
-
 
323
                            }
-
 
324
                        }
263
                                $record->survey_id = $survey->id;
325
                    
-
 
326
                        if($ok){
-
 
327
 
-
 
328
                        }
-
 
329
                    }
-
 
330
 
-
 
331
                    $data = [
-
 
332
                        'success' => true,
264
 
333
                        'data' => 'LABEL_RECORD_ADDED'
-
 
334
                    ];
-
 
335
                    //      return new JsonModel($data); 
-
 
336
 
265
                                $surveyJobDescriptionMapper->insert($record);
337
                    if(!empty($dataPost['skill_id'])){ 
266
                            }
Línea 338... Línea -...
338
 
-
 
339
                        // print_r($dataPost['skill_id']);
-
 
340
 
267
                        }
341
                         $skillMapper = SkillMapper::getInstance($this->adapter);
-
 
342
                         $surveySkillMapper = SurveySkillMapper::getInstance($this->adapter);
268
                    }
343
 
-
 
344
                         $ok = true;
-
 
345
 
269
                    if(!empty($dataPost['skill_id'])){ 
Línea 346... Línea 270...
346
                         foreach($dataPost['skill_id'] as $skillUuid) {
270
                         $skillMapper = SkillMapper::getInstance($this->adapter);
347
 
-
 
348
                            // echo '$jobCategoryUuid = ' . $jobCategoryUuid ; 
-
 
349
 
-
 
350
 
271
                         $surveySkillMapper = SurveySkillMapper::getInstance($this->adapter);
351
                             $skill = $skillMapper->fetchOneByUuid($skillUuid);
272
 
352
 
273
                         foreach($dataPost['skill_id'] as $skillUuid) 
Línea 353... Línea -...
353
                            // print_r($skill);
-
 
354
                            //print_r($currentCompany);
274
                         {
355
 
-
 
356
                            //if($skill && $skill->company_id == $currentCompany->id) {
275
                             $skill = $skillMapper->fetchOneByUuid($skillUuid);
357
                                $record = new SurveySkill();
-
 
358
                                $record->skill_id = $skill->id;
-
 
359
                                $record->survey_id = $survey->id;
-
 
360
 
-
 
361
 
276
 
362
                                $result = $surveySkillMapper->insert($record);
277
                             if($skill) {
Línea 363... Línea -...
363
                                $ok = $ok && $result;
-
 
364
                            // }
-
 
365
                         }
-
 
366
                     
-
 
367
                         if($ok){
-
 
368
 
-
 
369
                         }
278
                                $record = new SurveySkill();
370
                     }
-
 
371
 
-
 
372
                    $data = [
-
 
373
                        'success' => true,
279
                                $record->skill_id = $skill->id;
374
                        'data' => 'test'
280
                                $record->survey_id = $survey->id;
Línea 375... Línea -...
375
                    ];
-
 
376
                    //      return new JsonModel($data); exit;
-
 
377
 
281
 
378
                    if(!empty($dataPost['industry_id'])){ 
-
 
379
 
282
                                $surveySkillMapper->insert($record);
380
                        // print_r($dataPost['industry_id']);
-
 
381
 
-
 
382
                         $industryMapper = IndustryMapper::getInstance($this->adapter);
283
                            }
383
                         $surveyIndustryMapper = SurveyIndustryMapper::getInstance($this->adapter);
-
 
384
 
284
                         }
385
                         $ok = true;
-
 
386
 
-
 
387
                         foreach($dataPost['industry_id'] as $industryUuid) {
-
 
388
 
285
                     }
389
                            // echo '$industryUuid = ' . $industryUuid ; 
286
 
390
 
287
                    if(!empty($dataPost['industry_id'])){ 
Línea 391... Línea -...
391
 
-
 
392
                             $industry = $industryMapper->fetchOneByUuid($industryUuid);
-
 
393
 
288
                         $industryMapper = IndustryMapper::getInstance($this->adapter);
394
                            // print_r($industry);
-
 
395
                             //print_r($currentCompany);
289
                         $surveyIndustryMapper = SurveyIndustryMapper::getInstance($this->adapter);
396
 
-
 
397
                             //if($industry && $industry->company_id == $currentCompany->id) {
-
 
398
                                 $record = new SurveyIndustry();
-
 
399
                                 $record->industry_id = $industry->id;
-
 
400
                                 $record->survey_id = $survey->id;
290
 
401
 
291
                         foreach($dataPost['industry_id'] as $industryUuid) 
Línea 402... Línea -...
402
                            
-
 
403
 
-
 
404
                                 $result = $surveyIndustryMapper->insert($record);
-
 
405
                                 $ok = $ok && $result;
-
 
406
                             //}
-
 
407
                         }
-
 
408
                     
292
                         {
409
                         if($ok){
-
 
-
 
293
                             $industry = $industryMapper->fetchOneByUuid($industryUuid);
410
 
294
                             if($industry) {
Línea 411... Línea -...
411
                         }
-
 
412
                     }
-
 
413
 
295
                                 $record = new SurveyIndustry();
-
 
296
                                 $record->industry_id = $industry->id;
Línea -... Línea 297...
-
 
297
                                 $record->survey_id = $survey->id;
-
 
298
 
414
                    $data = [
299
                                 $surveyIndustryMapper->insert($record);
415
                        'success' => true,
300
                             }
416
                        'data' => 'test industry'
301
                         }
Línea 417... Línea -...
417
                    ];
-
 
418
                    // return new JsonModel($data); exit;
302
                     }
419
                
-
 
420
                    if(!empty($dataPost['language_id'])){ 
303
 
421
 
-
 
422
                        $surveyLanguageMapper = SurveyLanguageMapper::getInstance($this->adapter);
-
 
423
 
-
 
424
                        $ok = true;
304
                    if(!empty($dataPost['language_id'])){ 
425
 
305
                        $languageMapper = LanguageMapper::getInstance($this->adapter);
Línea 426... Línea 306...
426
                        foreach($dataPost['language_id'] as $language_id) {
306
                        $surveyLanguageMapper = SurveyLanguageMapper::getInstance($this->adapter);
427
 
307
 
428
                                $record = new SurveyLanguage();
308
                        foreach($dataPost['language_id'] as $language_id) 
429
                                $record->language_id = $language_id;
309
                        {
Línea 476... Línea 356...
476
        }
356
        }
Línea 477... Línea 357...
477
 
357
 
478
        return new JsonModel($data);
358
        return new JsonModel($data);
Línea -... Línea 359...
-
 
359
    }
479
    }
360
 
480
 
361
    /*
481
    public function segmentAction() {
362
    public function segmentAction() {
482
        $request = $this->getRequest();
363
        $request = $this->getRequest();
483
        $currentUserPlugin = $this->plugin('currentUserPlugin');
364
        $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 525... Línea 406...
525
 
406
 
526
 
407
 
Línea 527... Línea -...
527
            if ($form->isValid()) {
-
 
528
                $dataPost = (array) $form->getData();
-
 
529
                
-
 
530
                /*
-
 
531
 
-
 
532
                $location = new Location();
-
 
533
                $hydrator->hydrate($dataPost, $location);
-
 
534
                
-
 
535
                $locationMapper= LocationMapper::getInstance($this->adapter);
-
 
536
                $resultLocation = $locationMapper->insert($location);
-
 
537
 
-
 
538
                if (!$resultLocation) {
-
 
539
                    return new JsonModel([
-
 
540
                        'success'   => false,
-
 
541
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'                       
-
 
542
                    ]);
-
 
543
                }
-
 
544
                */
-
 
545
                
-
 
546
                $jobDescription = new SurveyJobDescription();
-
 
547
                $skill = new SurveySkill();
-
 
548
                $industry = new SurveyIndustry();
408
            if ($form->isValid()) {
549
                $language = new SurveyLanguage();
-
 
550
 
-
 
551
                if(!empty($dataPost['job_description_id'])){ 
-
 
552
                    
409
                $dataPost = (array) $form->getData();
553
                   // print_r($dataPost['job_description_id']);
410
                
Línea 554... Línea -...
554
                    
-
 
555
                    $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
-
 
556
                    $surveyJobDescriptionMapper = SurveyJobDescriptionMapper::getInstance($this->adapter);
411
                if(!empty($dataPost['job_description_id'])){ 
557
                    
-
 
558
                    $ok = true;
412
                    $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
559
                    
-
 
560
                    foreach($dataPost['job_description_id'] as $jobDescriptionUuid) {
-
 
561
                       
413
                    $surveyJobDescriptionMapper = SurveyJobDescriptionMapper::getInstance($this->adapter);
562
                       // echo '$jobDescriptionUuid = ' . $jobDescriptionUuid ; 
-
 
563
                        
-
 
564
                        
-
 
565
                        $jobDescription = $jobDescriptionMapper->fetchOneByUuid($jobDescriptionUuid);
-
 
566
                        
414
                    
567
                       // print_r($jobDescription);
415
                    foreach($dataPost['job_description_id'] as $jobDescriptionUuid) 
568
                        //print_r($currentCompany);
416
                    {
569
                        
417
                        $jobDescription = $jobDescriptionMapper->fetchOneByUuid($jobDescriptionUuid);
570
                        if($jobDescription && $jobDescription->company_id == $currentCompany->id) {
-
 
571
                            $record = new SurveyJobDescription();
418
                        if($jobDescription && $jobDescription->company_id == $currentCompany->id) {
572
                            $record->job_description_id = $jobDescription->id;
-
 
573
                            $record->survey_id = $survey->id;
419
                            $record = new SurveyJobDescription();
574
                            
-
 
575
             
420
                            $record->job_description_id = $jobDescription->id;
576
                            
421
                            $record->survey_id = $survey->id;
577
                            $result = $surveyJobDescriptionMapper->insert($record);
-
 
578
                            $ok = $ok && $result;
-
 
579
                        }
-
 
580
                    }
-
 
581
 
422
                                   
Línea 582... Línea -...
582
                    if($ok){
-
 
583
                        
-
 
584
                    }
-
 
585
                }
-
 
586
                
-
 
Línea 587... Línea 423...
587
                $data = [
423
                            $surveyJobDescriptionMapper->insert($record);
588
                    'success' => true,
-
 
589
                    'data' => 'LABEL_RECORD_ADDED'
-
 
590
                ];
-
 
591
              //  return new JsonModel($data); 
424
                        }
592
 
425
                    }
Línea 593... Línea -...
593
                if(!empty($dataPost['skill_id'])){ 
-
 
594
                    
-
 
595
                    // print_r($dataPost['skill_id']);
426
                }
596
                     
-
 
597
                     $skillMapper = SkillMapper::getInstance($this->adapter);
427
                
598
                     $surveySkillMapper = SurveySkillMapper::getInstance($this->adapter);
-
 
599
                     
-
 
600
                     $ok = true;
428
 
Línea 601... Línea 429...
601
                     
429
                if(!empty($dataPost['skill_id'])){ 
602
                     foreach($dataPost['skill_id'] as $skillUuid) {
-
 
603
                        
-
 
604
                        // echo '$jobCategoryUuid = ' . $jobCategoryUuid ; 
-
 
605
                         
430
                     $skillMapper = SkillMapper::getInstance($this->adapter);
606
                         
431
                     $surveySkillMapper = SurveySkillMapper::getInstance($this->adapter);
607
                         $skill = $skillMapper->fetchOneByUuid($skillUuid);
432
                     
Línea 608... Línea -...
608
                         
-
 
609
                        // print_r($skill);
433
                     foreach($dataPost['skill_id'] as $skillUuid) 
610
                        //print_r($currentCompany);
-
 
611
                         
434
                     {
612
                        //if($skill && $skill->company_id == $currentCompany->id) {
-
 
613
                            $record = new SurveySkill();
-
 
614
                            $record->skill_id = $skill->id;
-
 
615
                            $record->survey_id = $survey->id;
-
 
616
                            
435
                         $skill = $skillMapper->fetchOneByUuid($skillUuid);
617
                                          
436
                         
Línea 618... Línea -...
618
                            $result = $surveySkillMapper->insert($record);
-
 
619
                            $ok = $ok && $result;
-
 
620
                        // }
-
 
621
                     }
-
 
622
  
-
 
623
                     if($ok){
-
 
624
                         
437
                         if($skill) {
625
                     }
-
 
626
                 }
-
 
Línea 627... Línea 438...
627
                 
438
                            $record = new SurveySkill();
628
                $data = [
439
                            $record->skill_id = $skill->id;
Línea 629... Línea 440...
629
                    'success' => true,
440
                            $record->survey_id = $survey->id;
Línea 630... Línea 441...
630
                    'data' => 'test'
441
                            
631
                ];
-
 
632
              //  return new JsonModel($data); exit;
442
                            $surveySkillMapper->insert($record);
633
                
-
 
634
                if(!empty($dataPost['industry_id'])){ 
-
 
635
                    
443
                         }
636
                    // print_r($dataPost['industry_id']);
-
 
637
                     
444
                     }
638
                     $industryMapper = IndustryMapper::getInstance($this->adapter);
-
 
639
                     $surveyIndustryMapper = SurveyIndustryMapper::getInstance($this->adapter);
-
 
640
                     
-
 
641
                     $ok = true;
445
                 }
642
                     
446
                 
643
                     foreach($dataPost['industry_id'] as $industryUuid) {
447
                if(!empty($dataPost['industry_id'])){ 
Línea 644... Línea -...
644
                        
-
 
645
                        // echo '$industryUuid = ' . $industryUuid ; 
-
 
646
                         
448
                     
647
                         
-
 
648
                         $industry = $industryMapper->fetchOneByUuid($industryUuid);
449
                     $industryMapper = IndustryMapper::getInstance($this->adapter);
649
                         
-
 
650
                        // print_r($industry);
-
 
651
                         //print_r($currentCompany);
-
 
652
                         
-
 
653
                         //if($industry && $industry->company_id == $currentCompany->id) {
450
                     $surveyIndustryMapper = SurveyIndustryMapper::getInstance($this->adapter);
654
                             $record = new SurveyIndustry();
451
                     
Línea 655... Línea -...
655
                             $record->industry_id = $industry->id;
-
 
656
                             $record->survey_id = $survey->id;
-
 
657
                             
-
 
658
              
-
 
659
                             
-
 
Línea 660... Línea 452...
660
                             $result = $surveyIndustryMapper->insert($record);
452
                     $ok = true;
661
                             $ok = $ok && $result;
-
 
-
 
453
                     
662
                         //}
454
                     foreach($dataPost['industry_id'] as $industryUuid)
Línea -... Línea 455...
-
 
455
                     {
663
                     }
456
                         $industry = $industryMapper->fetchOneByUuid($industryUuid);
664
  
-
 
665
                     if($ok){
457
                         if($industry) {
666
                         
-
 
-
 
458
                             $record = new SurveyIndustry();
667
                     }
459
                             $record->industry_id = $industry->id;
668
                 }
460
                             $record->survey_id = $survey->id;
669
                 
461
                             
Línea 670... Línea -...
670
                $data = [
-
 
671
                    'success' => true,
462
                             $surveyIndustryMapper->insert($record);
672
                    'data' => 'test industry'
-
 
673
                ];
463
                          }
674
               // return new JsonModel($data); exit;
-
 
675
            
-
 
676
                if(!empty($dataPost['language_id'])){ 
-
 
677
                    
464
                     }
678
                    $surveyLanguageMapper = SurveyLanguageMapper::getInstance($this->adapter);
465
                 }
Línea 679... Línea 466...
679
                    
466
                 
680
                    $ok = true;
467
            
Línea 724... Línea 511...
724
            return new JsonModel($data);
511
            return new JsonModel($data);
725
        }
512
        }
Línea 726... Línea 513...
726
 
513
 
Línea 727... Línea 514...
727
       return new JsonModel($data);
514
       return new JsonModel($data);
Línea 728... Línea 515...
728
        
515
        
729
    }
516
    }*/
730
 
517
 
731
    public function editAction() {
518
    public function editAction() {
Línea 785... Línea 572...
785
                }
572
                }
Línea 786... Línea 573...
786
               
573
               
787
                $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
574
                $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
788
                $surveyForm = $surveyFormMapper->fetchOneByUuid($dataPost['form_id']);
575
                $surveyForm = $surveyFormMapper->fetchOneByUuid($dataPost['form_id']);
-
 
576
                $survey->form_id = $surveyForm->id;
789
                $survey->form_id = $surveyForm->id;
577
                
790
                $result = $surveyMapper->update($survey);
578
                $result = $surveyMapper->update($survey);
791
                if($result){
-
 
792
                    $survey = $surveyMapper->fetchOne($survey->id);
-
 
793
 
579
                if($result){
794
                    $jobDescription = new SurveyJobDescription();
580
                    $jobDescription = new SurveyJobDescription();
795
                    $skill = new SurveySkill();
581
                    $skill = new SurveySkill();
796
                    $industry = new SurveyIndustry();
582
                    $industry = new SurveyIndustry();
Línea 797... Línea 583...
797
                    $language = new SurveyLanguage();
583
                    $language = new SurveyLanguage();
Línea 798... Línea 584...
798
 
584
 
799
                    if(!empty($dataPost['location_search'])){ 
-
 
800
 
585
                    if(!empty($dataPost['location_search'])){ 
Línea -... Línea 586...
-
 
586
 
801
                        $surveyLocationMapper = SurveyLocationMapper::getInstance($this->adapter);
587
                        $surveyLocationMapper = SurveyLocationMapper::getInstance($this->adapter);
802
    
588
                        $surveyLocation = $surveyLocationMapper->fetchOneBySurveyId($survey->id);
803
                        $ok = true;
589
 
804
 
590
                        if($surveyLocation) {
805
                        $formatted_address = $dataPost['formatted_address'];
591
                            $surveyLocation->formatted_address = $dataPost['formatted_address'];
806
                        $city1 = $dataPost['city1'];
592
                            $surveyLocation->city1 = $dataPost['city1'];
807
                        $city2 = $dataPost['city2'];
593
                            $surveyLocation->city2 = $dataPost['city2'];
808
                        $address1 = $dataPost['address1'];
594
                            $surveyLocation->address1 = $dataPost['address1'];
809
                        $address2 = $dataPost['address2'];
595
                            $surveyLocation->address2 = $dataPost['address2'];
810
                        $country = $dataPost['country'];
596
                            $surveyLocation->country = $dataPost['country'];
811
                        $latitude = $dataPost['latitude'];
-
 
812
                        $longitude = $dataPost['longitude'];
-
 
-
 
597
                            $surveyLocation->latitude = $dataPost['latitude'];
-
 
598
                            $surveyLocation->longitude = $dataPost['longitude'];
813
                        $postal_code = $dataPost['postal_code'];
599
                            $surveyLocation->postal_code = $dataPost['postal_code'];
814
                        $state = $dataPost['state'];
600
                            $surveyLocation->state = $dataPost['state'];
815
 
601
                            $surveyLocationMapper->update($surveyLocation);
816
                        
602
                        } else {
817
                        $record = new SurveyLocation();
603
                            $surveyLocation = new SurveyLocation();
818
                        $record->formatted_address = $formatted_address; 
604
                            $surveyLocation->formatted_address = $dataPost['formatted_address'];
819
                        $record->city1 = $city1;
605
                            $surveyLocation->city1 = $dataPost['city1'];
820
                        $record->city2 = $city2;
606
                            $surveyLocation->city2 = $dataPost['city2'];
821
                        $record->address1 = $address1;
607
                            $surveyLocation->address1 = $dataPost['address1'];
822
                        $record->address2 = $address2;
608
                            $surveyLocation->address2 = $dataPost['address2'];
823
                        $record->country = $country;
609
                            $surveyLocation->country = $dataPost['country'];
824
                        $record->latitude = $latitude;
610
                            $surveyLocation->latitude = $dataPost['latitude'];
825
                        $record->longitude = $longitude;
611
                            $surveyLocation->longitude = $dataPost['longitude'];
826
                        $record->postal_code = $postal_code;
-
 
827
                        $record->state = $state;
-
 
828
                        $record->survey_id = $survey->id;
-
 
829
                        $result = $surveyLocationMapper->update($record);
-
 
830
                        $ok = $ok && $result;
612
                            $surveyLocation->postal_code = $dataPost['postal_code'];
831
                           //}
613
                            $surveyLocation->state = $dataPost['state'];
Línea 832... Línea 614...
832
                          if($ok){
614
                            $surveyLocation->survey_id = $survey->id;
833
    
-
 
834
                        }
-
 
835
                    }
-
 
836
 
615
                            $surveyLocationMapper->insert($surveyLocation);
837
                    if(!empty($dataPost['job_description_id'])){ 
616
                        }
Línea 838... Línea -...
838
 
-
 
839
                       // print_r($dataPost['job_description_id']);
-
 
840
 
-
 
841
                        $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
617
                    }
Línea 842... Línea 618...
842
                        $surveyJobDescriptionMapper = SurveyJobDescriptionMapper::getInstance($this->adapter);
618
 
Línea 843... Línea -...
843
 
-
 
844
                        $ok = true;
-
 
845
 
-
 
846
 
619
                    if(!empty($dataPost['job_description_id'])){ 
847
                        $surveyJobDescriptionMapper->deleteBySurevy($survey->id);
-
 
848
 
-
 
849
                        foreach($dataPost['job_description_id'] as $jobDescriptionUuid) {
-
 
850
                        
-
 
851
                           // echo '$jobDescriptionUuid = ' . $jobDescriptionUuid ; 
620
                        $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
852
 
621
                        $surveyJobDescriptionMapper = SurveyJobDescriptionMapper::getInstance($this->adapter);
853
 
622
 
854
                            $jobDescription = $jobDescriptionMapper->fetchOneByUuid($jobDescriptionUuid);
623
                        $surveyJobDescriptionMapper->deleteBySurveyId($survey->id);
Línea 855... Línea -...
855
 
-
 
856
                           // print_r($jobDescription);
-
 
857
                            //print_r($currentCompany);
624
 
858
 
-
 
859
                            if($jobDescription && $jobDescription->company_id == $currentCompany->id) {
625
                        foreach($dataPost['job_description_id'] as $jobDescriptionUuid) {
860
                                $record = new SurveyJobDescription();
626
                        
861
                                $record->job_description_id = $jobDescription->id;
-
 
862
                                $record->survey_id = $survey->id;
-
 
Línea 863... Línea -...
863
 
-
 
864
                            
627
                            $jobDescription = $jobDescriptionMapper->fetchOneByUuid($jobDescriptionUuid);
Línea 865... Línea -...
865
 
-
 
866
                                $result = $surveyJobDescriptionMapper->insert($record);
-
 
867
                                $ok = $ok && $result;
-
 
868
                            }
-
 
869
                        }
-
 
Línea 870... Línea 628...
870
                    
628
                            if($jobDescription && $jobDescription->company_id == $currentCompany->id) {
871
                        if($ok){
-
 
872
 
-
 
873
                        }
-
 
874
                    }
629
                                $record = new SurveyJobDescription();
875
 
630
                                $record->job_description_id = $jobDescription->id;
Línea 876... Línea -...
876
                    $data = [
-
 
Línea 877... Línea 631...
877
                        'success' => true,
631
                                $record->survey_id = $survey->id;
Línea 878... Línea 632...
878
                        'data' => 'LABEL_RECORD_ADDED'
632
 
879
                    ];
-
 
880
                    //      return new JsonModel($data); 
-
 
881
 
-
 
882
                    if(!empty($dataPost['skill_id'])){ 
-
 
883
 
633
                                $surveyJobDescriptionMapper->insert($record);
884
                        // print_r($dataPost['skill_id']);
-
 
885
 
634
                            }
886
                         $skillMapper = SkillMapper::getInstance($this->adapter);
-
 
887
                         $surveySkillMapper = SurveySkillMapper::getInstance($this->adapter);
-
 
888
 
-
 
889
                         $ok = true;
635
                        }
890
                         
636
 
891
                        $surveySkillMapper->deleteBySurevy($survey->id);
637
                    }
Línea 892... Línea -...
892
                         
-
 
893
 
638
 
894
                         foreach($dataPost['skill_id'] as $skillUuid) {
-
 
895
 
639
 
896
                            // echo '$jobCategoryUuid = ' . $jobCategoryUuid ; 
-
 
897
 
-
 
898
 
-
 
899
                             $skill = $skillMapper->fetchOneByUuid($skillUuid);
-
 
900
                        
640
                    if(!empty($dataPost['skill_id'])){ 
901
                            // print_r($skill);
641
                         $skillMapper = SkillMapper::getInstance($this->adapter);
902
                            //print_r($currentCompany);
-
 
Línea 903... Línea 642...
903
 
642
                         $surveySkillMapper = SurveySkillMapper::getInstance($this->adapter);
904
                            //if($skill && $skill->company_id == $currentCompany->id) {
-
 
905
                                $record = new SurveySkill();
-
 
906
                                $record->skill_id = $skill->id;
-
 
907
                                $record->survey_id = $survey->id;
643
 
908
 
644
                         
Línea 909... Línea -...
909
 
-
 
910
                                $result = $surveySkillMapper->insert($record);
-
 
911
                                $ok = $ok && $result;
645
                         $surveySkillMapper->deleteBySurveyId($survey->id);
Línea 912... Línea 646...
912
                            // }
646
                         
913
                         }
-
 
914
                     
-
 
915
                         if($ok){
-
 
916
 
-
 
917
                         }
647
 
Línea 918... Línea 648...
918
                    }
648
                         foreach($dataPost['skill_id'] as $skillUuid) {
919
                    //      return new JsonModel($data); exit;
-
 
920
 
-
 
921
                    if(!empty($dataPost['industry_id'])){ 
-
 
922
 
649
                             $skill = $skillMapper->fetchOneByUuid($skillUuid);
923
                        // print_r($dataPost['industry_id']);
650
                             if($skill) {
924
 
651
                                $record = new SurveySkill();
Línea 925... Línea -...
925
                         $industryMapper = IndustryMapper::getInstance($this->adapter);
-
 
926
                         $surveyIndustryMapper = SurveyIndustryMapper::getInstance($this->adapter);
-
 
927
 
652
                                $record->skill_id = $skill->id;
928
                         $ok = true;
-
 
929
 
-
 
930
                         $surveyIndustryMapper->deleteBySurevy($survey->id);
-
 
931
 
653
                                $record->survey_id = $survey->id;
932
                         foreach($dataPost['industry_id'] as $industryUuid) {
654
 
933
 
-
 
934
                            // echo '$industryUuid = ' . $industryUuid ; 
655
                                $surveySkillMapper->insert($record);
935
 
656
                            }
Línea 936... Línea -...
936
 
-
 
937
                             $industry = $industryMapper->fetchOneByUuid($industryUuid);
657
                         }
938
 
658
                    }
Línea 939... Línea 659...
939
                            // print_r($industry);
659
 
-
 
660
                    if(!empty($dataPost['industry_id'])){ 
Línea 940... Línea 661...
940
                             //print_r($currentCompany);
661
                         $industryMapper = IndustryMapper::getInstance($this->adapter);
941
 
662
                         $surveyIndustryMapper = SurveyIndustryMapper::getInstance($this->adapter);
942
                             //if($industry && $industry->company_id == $currentCompany->id) {
663
 
943
                                 $record = new SurveyIndustry();
-
 
-
 
664
                         $surveyIndustryMapper->deleteBySurveyId($survey->id);
944
                                 $record->industry_id = $industry->id;
665
 
945
                                 $record->survey_id = $survey->id;
-
 
-
 
666
                         foreach($dataPost['industry_id'] as $industryUuid) {
946
 
667
                             $industry = $industryMapper->fetchOneByUuid($industryUuid);
947
                            
668
 
948
 
669
                             if($industry) {
Línea 949... Línea 670...
949
                                 $result = $surveyIndustryMapper->insert($record);
670
                                 $record = new SurveyIndustry();
950
                                 $ok = $ok && $result;
-
 
951
                             //}
671
                                 $record->industry_id = $industry->id;
952
                         }
-
 
953
                     
-
 
954
                         if($ok){
-
 
955
 
672
                                 $record->survey_id = $survey->id;
956
                         }
673
 
957
                    }
674
                                 $surveyIndustryMapper->insert($record);
958
 
675
                                 
959
                    // return new JsonModel($data); exit;
-
 
960
                
-
 
Línea 961... Línea 676...
961
                    if(!empty($dataPost['language_id'])){ 
676
                             }
962
 
677
                         }
963
                        $surveyLanguageMapper = SurveyLanguageMapper::getInstance($this->adapter);
678
                    }
964
 
679
 
965
                        $ok = true;
-
 
966
 
-
 
967
                        $surveyLanguageMapper->deleteBySurevy($survey->id);
680
 
968
 
681
                    if(!empty($dataPost['language_id'])){ 
969
                        foreach($dataPost['language_id'] as $language_id) {
682
 
970
 
683
                        $surveyLanguageMapper = SurveyLanguageMapper::getInstance($this->adapter);
971
                                $record = new SurveyLanguage();
684
                        $surveyLanguageMapper->deleteBySurveyId($survey->id);
Línea 1079... Línea 792...
1079
                array_push($industryMaster, $industrym->uuid);
792
                array_push($industryMaster, $industrym->uuid);
1080
            }
793
            }
Línea 1081... Línea 794...
1081
            
794
            
1082
 
795
 
Línea 1083... Línea -...
1083
            $surveyLocationMapper = SurveyLocationMapper::getInstance($this->adapter);
-
 
1084
            $location  = $surveyLocationMapper->fetchAllbySurveyId($survey->id);
-
 
1085
            
-
 
1086
            //  return new JsonModel([
-
 
Línea 1087... Línea -...
1087
            //      'success' => false,
-
 
Línea 1088... Línea 796...
1088
            //      'data' => $location
796
            $surveyLocationMapper = SurveyLocationMapper::getInstance($this->adapter);
1089
            //  ]);
797
            $surveyLocation  = $surveyLocationMapper->fetchOneBySurveyId($survey->id);
1090
 
-
 
1091
           
-
 
1092
          
-
 
1093
            $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
-
 
-
 
798
            
1094
            $surveyForm = $surveyFormMapper->fetchOne($survey->form_id);
799
 
1095
            // return new JsonModel([
800
          
1096
            //     'success' => false,
801
            $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
1097
            //     'data' => $SurveyJobDescriptionA
802
            $surveyForm = $surveyFormMapper->fetchOne($survey->form_id);
1098
            // ]);
803
 
Línea 1108... Línea 813...
1108
                    'status' => $survey->status, 
813
                    'status' => $survey->status, 
1109
                    'lenguage_id' => $lenguage,
814
                    'lenguage_id' => $lenguage,
1110
                    'skill_id' => $skillMaster,
815
                    'skill_id' => $skillMaster,
1111
                    'job_description_id' => $SurveyJobDescriptionMaster,
816
                    'job_description_id' => $SurveyJobDescriptionMaster,
1112
                    'industry_id' => $industryMaster,
817
                    'industry_id' => $industryMaster,
-
 
818
                  
-
 
819
                    
-
 
820
                    'formatted_address' => $surveyLocation  ? $surveyLocation->formatted_address : '',
1113
                    //'location' => $location->city1,
821
                    'city1' => $surveyLocation  ? $surveyLocation ->city1 : '',
-
 
822
                    'city2' => $surveyLocation  ? $surveyLocation ->city2 : '',
-
 
823
                    'address1' => $surveyLocation  ? $surveyLocation ->address1: '',
-
 
824
                    'address2' => $surveyLocation  ? $surveyLocation ->address2 : '',
-
 
825
                    'country' => $surveyLocation  ? $surveyLocation ->country : '',
-
 
826
                    'latitude' => $surveyLocation  ? $surveyLocation ->latitude : '',
-
 
827
                    'longitude' => $surveyLocation  ? $surveyLocation ->longitude : '',
-
 
828
                    'postal_code' => $surveyLocation  ? $surveyLocation ->postal_code : '',
-
 
829
                    'state' => $surveyLocation  ? $surveyLocation ->state : '',
-
 
830
  
-
 
831
 
1114
                ]
832
                ]
1115
            ];
833
            ];
Línea 1116... Línea 834...
1116
 
834
 
1117
            return new JsonModel($data);
835
            return new JsonModel($data);
Línea 1165... Línea 883...
1165
 
883
 
Línea 1166... Línea 884...
1166
        if ($request->isPost()) {
884
        if ($request->isPost()) {
1167
 
885
 
1168
            $result = $surveyMapper->delete($survey->id);
886
            $result = $surveyMapper->delete($survey->id);
Línea 1169... Línea 887...
1169
            if ($result) {
887
            if ($result) {
1170
                //$this->logger->info('Se borro la encuesta ' . $survey->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
888
                $this->logger->info('Se borro la encuesta ' . $survey->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1171
 
889
 
1172
                $data = [
890
                $data = [