Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 6700 Rev 6705
Línea 718... Línea 718...
718
        $currentCompany = $currentUserPlugin->getCompany();
718
        $currentCompany = $currentUserPlugin->getCompany();
719
        $currentUser = $currentUserPlugin->getUser();
719
        $currentUser = $currentUserPlugin->getUser();
Línea 720... Línea 720...
720
 
720
 
721
        $request = $this->getRequest();
721
        $request = $this->getRequest();
722
        $uuid = $this->params()->fromRoute('id');
722
        $uuid = $this->params()->fromRoute('id');
Línea 723... Línea 723...
723
       
723
 
724
 
724
 
725
        if (!$uuid) {
725
        if (!$uuid) {
726
            $data = [
726
            $data = [
727
                'success' => false,
727
                'success' => false,
Línea 728... Línea 728...
728
                'data' => 'ERROR_INVALID_PARAMETER'
728
                'data' => 'ERROR_INVALID_PARAMETER'
729
            ];
729
            ];
730
 
-
 
Línea 731... Línea 730...
731
            return new JsonModel($data);
730
 
732
        }
731
            return new JsonModel($data);
Línea 733... Línea 732...
733
       
732
        }
Línea 749... Línea 748...
749
                'success' => false,
748
                'success' => false,
750
                'data' => 'ERROR_UNAUTHORIZED'
749
                'data' => 'ERROR_UNAUTHORIZED'
751
            ]);
750
            ]);
752
        }
751
        }
Línea -... Línea 752...
-
 
752
 
753
 
753
 
754
        if ($request->isPost()) {
-
 
755
           
754
        if ($request->isPost()) {
756
            $form = new SurveyForm($this->adapter, $currentCompany->id);
-
 
757
            // return new JsonModel([
-
 
758
            //     'success' => false,
-
 
759
            //     'data' => 'ddd'
-
 
760
            // ]);
755
            $form = new SurveyForm($this->adapter, $currentCompany->id);
761
            $dataPost = $request->getPost()->toArray();
756
            $dataPost = $request->getPost()->toArray();
762
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : SurveyForm::STATUS_INACTIVE;
757
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : SurveyForm::STATUS_INACTIVE;
763
           
758
 
Línea 764... Línea 759...
764
            $form->setData($dataPost);
759
            $form->setData($dataPost);
765
 
760
 
766
            if ($form->isValid()) {
-
 
-
 
761
            if ($form->isValid()) {
-
 
762
                $dataPost = (array) $form->getData();
-
 
763
                return new JsonModel([
-
 
764
                    'success' => false,
767
                $dataPost = (array) $form->getData();
765
                    'data' => $dataPost
768
                
766
                ]);
Línea 769... Línea 767...
769
                $hydrator = new ObjectPropertyHydrator();
767
                $hydrator = new ObjectPropertyHydrator();
770
                $hydrator->hydrate($dataPost, $survey);
768
                $hydrator->hydrate($dataPost, $survey);
Línea 775... Línea 773...
775
               
773
               
776
                $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
774
                $surveyFormMapper = SurveyFormMapper::getInstance($this->adapter);
777
                $surveyForm = $surveyFormMapper->fetchOneByUuid($dataPost['form_id']);
775
                $surveyForm = $surveyFormMapper->fetchOneByUuid($dataPost['form_id']);
Línea 778... Línea 776...
778
                $survey->form_id = $surveyForm->id;
776
                $survey->form_id = $surveyForm->id;
-
 
777
               
-
 
778
                if($surveyMapper->update($survey)){
-
 
779
                    $survey = $surveyMapper->fetchOne($survey->id);
-
 
780
 
-
 
781
                    $jobDescription = new SurveyJobDescription();
-
 
782
                    $skill = new SurveySkill();
-
 
783
                    $industry = new SurveyIndustry();
-
 
784
                    $language = new SurveyLanguage();
-
 
785
 
-
 
786
                    if(!empty($dataPost['location_search'])){ 
-
 
787
 
-
 
788
                        $surveyLocationMapper = SurveyLocationMapper::getInstance($this->adapter);
-
 
789
    
-
 
790
                        $ok = true;
-
 
791
 
-
 
792
                        $formatted_address = $dataPost['formatted_address'];
-
 
793
                        $city1 = $dataPost['city1'];
-
 
794
                        $city2 = $dataPost['city2'];
-
 
795
                        $address1 = $dataPost['address1'];
-
 
796
                        $address2 = $dataPost['address2'];
-
 
797
                        $country = $dataPost['country'];
-
 
798
                        $latitude = $dataPost['latitude'];
-
 
799
                        $longitude = $dataPost['longitude'];
-
 
800
                        $postal_code = $dataPost['postal_code'];
-
 
801
                        $state = $dataPost['state'];
-
 
802
 
-
 
803
                        
-
 
804
                        $record = new SurveyLocation();
-
 
805
                        $record->formatted_address = $formatted_address; 
-
 
806
                        $record->city1 = $city1;
-
 
807
                        $record->city2 = $city2;
-
 
808
                        $record->address1 = $address1;
-
 
809
                        $record->address2 = $address2;
-
 
810
                        $record->country = $country;
-
 
811
                        $record->latitude = $latitude;
-
 
812
                        $record->longitude = $longitude;
-
 
813
                        $record->postal_code = $postal_code;
-
 
814
                        $record->state = $state;
-
 
815
                        $record->survey_id = $survey->id;
-
 
816
                        $result = $surveyLocationMapper->update($record);
-
 
817
                        $ok = $ok && $result;
-
 
818
                           //}
-
 
819
                          if($ok){
-
 
820
    
-
 
821
                        }
-
 
822
                    }
-
 
823
 
-
 
824
                    if(!empty($dataPost['job_description_id'])){ 
-
 
825
 
-
 
826
                       // print_r($dataPost['job_description_id']);
-
 
827
 
-
 
828
                        $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
-
 
829
                        $surveyJobDescriptionMapper = SurveyJobDescriptionMapper::getInstance($this->adapter);
-
 
830
 
-
 
831
                        $ok = true;
-
 
832
 
-
 
833
                        foreach($dataPost['job_description_id'] as $jobDescriptionUuid) {
-
 
834
                        
-
 
835
                           // echo '$jobDescriptionUuid = ' . $jobDescriptionUuid ; 
-
 
836
 
-
 
837
 
-
 
838
                            $jobDescription = $jobDescriptionMapper->fetchOneByUuid($jobDescriptionUuid);
-
 
839
 
-
 
840
                           // print_r($jobDescription);
-
 
841
                            //print_r($currentCompany);
-
 
842
 
-
 
843
                            if($jobDescription && $jobDescription->company_id == $currentCompany->id) {
-
 
844
                                $record = new SurveyJobDescription();
-
 
845
                                $record->job_description_id = $jobDescription->id;
-
 
846
                                $record->survey_id = $survey->id;
-
 
847
 
-
 
848
                            
-
 
849
 
-
 
850
                                $result = $surveyJobDescriptionMapper->update($record);
-
 
851
                                $ok = $ok && $result;
-
 
852
                            }
-
 
853
                        }
-
 
854
                    
-
 
855
                        if($ok){
-
 
856
 
-
 
857
                        }
-
 
858
                    }
-
 
859
 
-
 
860
                    $data = [
-
 
861
                        'success' => true,
-
 
862
                        'data' => 'LABEL_RECORD_ADDED'
-
 
863
                    ];
-
 
864
                    //      return new JsonModel($data); 
-
 
865
 
-
 
866
                    if(!empty($dataPost['skill_id'])){ 
-
 
867
 
-
 
868
                        // print_r($dataPost['skill_id']);
-
 
869
 
-
 
870
                         $skillMapper = SkillMapper::getInstance($this->adapter);
-
 
871
                         $surveySkillMapper = SurveySkillMapper::getInstance($this->adapter);
-
 
872
 
-
 
873
                         $ok = true;
-
 
874
 
-
 
875
                         foreach($dataPost['skill_id'] as $skillUuid) {
-
 
876
 
-
 
877
                            // echo '$jobCategoryUuid = ' . $jobCategoryUuid ; 
-
 
878
 
-
 
879
 
-
 
880
                             $skill = $skillMapper->fetchOneByUuid($skillUuid);
-
 
881
 
-
 
882
                            // print_r($skill);
-
 
883
                            //print_r($currentCompany);
-
 
884
 
-
 
885
                            //if($skill && $skill->company_id == $currentCompany->id) {
-
 
886
                                $record = new SurveySkill();
-
 
887
                                $record->skill_id = $skill->id;
-
 
888
                                $record->survey_id = $survey->id;
-
 
889
 
-
 
890
 
-
 
891
                                $result = $surveySkillMapper->update($record);
-
 
892
                                $ok = $ok && $result;
-
 
893
                            // }
-
 
894
                         }
-
 
895
                     
-
 
896
                         if($ok){
-
 
897
 
-
 
898
                         }
-
 
899
                     }
-
 
900
 
-
 
901
                    $data = [
-
 
902
                        'success' => true,
-
 
903
                        'data' => 'test'
-
 
904
                    ];
-
 
905
                    //      return new JsonModel($data); exit;
-
 
906
 
-
 
907
                    if(!empty($dataPost['industry_id'])){ 
-
 
908
 
-
 
909
                        // print_r($dataPost['industry_id']);
-
 
910
 
-
 
911
                         $industryMapper = IndustryMapper::getInstance($this->adapter);
-
 
912
                         $surveyIndustryMapper = SurveyIndustryMapper::getInstance($this->adapter);
-
 
913
 
-
 
914
                         $ok = true;
-
 
915
 
-
 
916
                         foreach($dataPost['industry_id'] as $industryUuid) {
-
 
917
 
-
 
918
                            // echo '$industryUuid = ' . $industryUuid ; 
-
 
919
 
-
 
920
 
-
 
921
                             $industry = $industryMapper->fetchOneByUuid($industryUuid);
-
 
922
 
-
 
923
                            // print_r($industry);
-
 
924
                             //print_r($currentCompany);
-
 
925
 
-
 
926
                             //if($industry && $industry->company_id == $currentCompany->id) {
-
 
927
                                 $record = new SurveyIndustry();
-
 
928
                                 $record->industry_id = $industry->id;
-
 
929
                                 $record->survey_id = $survey->id;
-
 
930
 
-
 
931
                            
-
 
932
 
-
 
933
                                 $result = $surveyIndustryMapper->update($record);
-
 
934
                                 $ok = $ok && $result;
-
 
935
                             //}
-
 
936
                         }
-
 
937
                     
-
 
938
                         if($ok){
-
 
939
 
-
 
940
                         }
-
 
941
                     }
-
 
942
 
-
 
943
                    $data = [
-
 
944
                        'success' => true,
-
 
945
                        'data' => 'test industry'
-
 
946
                    ];
-
 
947
                    // return new JsonModel($data); exit;
-
 
948
                
-
 
949
                    if(!empty($dataPost['language_id'])){ 
-
 
950
 
-
 
951
                        $surveyLanguageMapper = SurveyLanguageMapper::getInstance($this->adapter);
-
 
952
 
-
 
953
                        $ok = true;
-
 
954
 
-
 
955
                        foreach($dataPost['language_id'] as $language_id) {
-
 
956
 
-
 
957
                                $record = new SurveyLanguage();
-
 
958
                                $record->language_id = $language_id;
-
 
959
                                $record->survey_id = $survey->id;
-
 
960
 
-
 
961
 
-
 
962
                                $result = $surveyLanguageMapper->update($record);
-
 
963
                                $ok = $ok && $result;
-
 
964
                           //}
-
 
965
                        }
-
 
966
                          if($ok){
-
 
967
 
-
 
968
                        }
-
 
969
                     }
-
 
970
                }
-
 
971
 
Línea 779... Línea 972...
779
               
972
            return new JsonModel($data);
780
                $result = $surveyMapper->update($survey);
973
               
781
 
974
 
782
                if ($result) {
975
                if ($result) {