Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 852 Rev 854
Línea 232... Línea 232...
232
            ];
232
            ];
Línea 233... Línea 233...
233
 
233
 
234
 
234
 
235
            return new JsonModel($data);
235
            return new JsonModel($data);
236
        } else if ($request->isPost()) {
236
        } else if ($request->isPost()) {
Línea 237... Línea 237...
237
            $form = new JobDescriptionForm($this->adapter, $currentCompany ? $currentCompany->id : null );
237
            $form = new JobDescriptionForm($this->adapter, $currentCompany ? $currentCompany->id : null);
Línea 672... Línea 672...
672
        }
672
        }
Línea 673... Línea 673...
673
 
673
 
674
        return new JsonModel($data);
674
        return new JsonModel($data);
Línea 675... Línea -...
675
    }
-
 
676
 
675
    }
677
 
-
 
Línea 678... Línea 676...
678
    public function importAction()
676
 
679
    {
677
    public function importAction() {
680
 
678
 
681
        $currentUserPlugin = $this->plugin('currentUserPlugin');
679
        $currentUserPlugin = $this->plugin('currentUserPlugin');
682
        $currentUser = $currentUserPlugin->getUser();
680
        $currentUser = $currentUserPlugin->getUser();
683
        $currentCompany = $currentUserPlugin->getCompany();
681
        $currentCompany = $currentUserPlugin->getCompany();
684
        
682
 
685
        if(!$currentCompany) {
683
        if (!$currentCompany) {
686
            $data = [
684
            $data = [
687
                'success' => false,
685
                'success' => false,
688
                'data' => 'ERROR_UNAUTHORIZED'
686
                'data' => 'ERROR_UNAUTHORIZED'
689
            ];
687
            ];
690
            
688
 
691
            return new JsonModel($data);
689
            return new JsonModel($data);
692
        }
690
        }
693
        
691
 
694
        $request = $this->getRequest();
692
        $request = $this->getRequest();
695
        
693
 
696
        if($request->isPost()) {
694
        if ($request->isPost()) {
697
            
695
 
698
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
696
            $jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
699
            $jobDescriptionsDefault = $jobDescriptionMapper->fetchAllByDefault();
697
            $jobDescriptionsDefault = $jobDescriptionMapper->fetchAllByDefault();
700
            
-
 
701
            $new_records = 0;
698
 
702
            foreach($jobDescriptionsDefault as $jobDescriptionDefault)
699
            $new_records = 0;
703
            {
700
            foreach ($jobDescriptionsDefault as $jobDescriptionDefault) {
704
                if($jobDescriptionDefault->status == JobDescription::STATUS_INACTIVE) {
701
                if ($jobDescriptionDefault->status == JobDescription::STATUS_INACTIVE) {
705
                    continue;
702
                    continue;
706
                }
703
                }
707
                
704
 
708
                $jobDescription = $jobDescriptionMapper->fetchOneByCompanyId($currentCompany->id, $jobDescriptionDefault->id);
705
                $jobDescription = $jobDescriptionMapper->fetchOneByCompanyId($currentCompany->id, $jobDescriptionDefault->id);
709
                if(!$jobDescription) {
706
                if (!$jobDescription) {
710
                        
707
 
711
                    $jobDescription = new JobDescription();
708
                    $jobDescription = new JobDescription();
712
                    $jobDescription->company_id = $currentCompany->id;
709
                    $jobDescription->company_id = $currentCompany->id;
713
                    $jobDescription->job_description_id_default = $jobDescriptionDefault->id;
710
                    $jobDescription->job_description_id_default = $jobDescriptionDefault->id;
714
                    $jobDescription->name = $jobDescriptionDefault->name;
711
                    $jobDescription->name = $jobDescriptionDefault->name;
715
                    $jobDescription->functions = $jobDescriptionDefault->functions;
712
                    $jobDescription->functions = $jobDescriptionDefault->functions;
716
                    $jobDescription->objectives = $jobDescriptionDefault->objectives;
713
                    $jobDescription->objectives = $jobDescriptionDefault->objectives;
717
                    $jobDescription->status = JobDescription::STATUS_ACTIVE;
714
                    $jobDescription->status = JobDescription::STATUS_ACTIVE;
718
                        
715
 
719
                        
716
 
720
                    if($jobDescriptionMapper->insert($jobDescription)) {
717
                    if ($jobDescriptionMapper->insert($jobDescription)) {
721
                        $new_records++;
718
                        $new_records++;
722
                    } else {
719
                    } else {
723
                        $data = [
720
                        $data = [
724
                            'success' => false,
721
                            'success' => false,
725
                            'data' => 'ERROR_CANT_ADD_JOB_DESCRIPTION'
722
                            'data' => 'ERROR_CANT_ADD_JOB_DESCRIPTION'
726
                        ];
723
                        ];
727
                            
-
 
728
                        return new JsonModel($data);
-
 
729
                    }
-
 
730
                    
-
 
731
                    
724
 
732
                    
725
                        return new JsonModel($data);
733
                    
726
                    }
734
                }
727
                }
735
            }
728
            }
736
            
729
 
737
            if($new_records) {
730
            if ($new_records) {
738
                
731
 
739
                if(1 == $new_records) {
732
                if (1 == $new_records) {
740
                    $data = [
733
                    $data = [
741
                        'success' => true,
734
                        'success' => true,
742
                        'data' => 'LABEL_1_JOB_DESCRIPTION_IMPORTED'
735
                        'data' => 'LABEL_1_JOB_DESCRIPTION_IMPORTED'
743
                    ];
736
                    ];
744
                    
737
 
745
                    return new JsonModel($data);
738
                    return new JsonModel($data);
746
                } else {
739
                } else {
747
                    $data = [
740
                    $data = [
748
                        'success' => true,
741
                        'success' => true,
749
                        'data' =>  $new_records . ' LABEL_MULTI_JOB_DESCRIPTION_IMPORTED'
742
                        'data' => $new_records . ' LABEL_MULTI_JOB_DESCRIPTION_IMPORTED'
750
                    ];
743
                    ];
751
                    
-
 
752
                    return new JsonModel($data);
744
 
753
                }
745
                    return new JsonModel($data);
754
                
746
                }
755
            } else {
747
            } else {
756
                $data = [
748
                $data = [
757
                    'success' => true,
749
                    'success' => true,
758
                    'data' => 'LABEL_NO_JOB_DESCRIPTION_IMPORTED'
750
                    'data' => 'LABEL_NO_JOB_DESCRIPTION_IMPORTED'
759
                ];
751
                ];
760
                
-
 
761
                return new JsonModel($data);
-
 
762
            }
-
 
763
            
-
 
764
            
752
 
765
            
753
                return new JsonModel($data);
766
            
754
            }
767
        } else {
755
        } else {
768
            $data = [
756
            $data = [
769
                'success' => false,
757
                'success' => false,
770
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
758
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
771
            ];
759
            ];
772
            
760
 
773
            return new JsonModel($data);
761
            return new JsonModel($data);
774
        }
-
 
775
        
762
        }
Línea 776... Línea 763...
776
        return new JsonModel($data);
763
 
777
    
764
        return new JsonModel($data);
778
    }
765
    }
Línea 840... Línea 827...
840
    public function renderPDF($currentCompany, $jobDescription) {
827
    public function renderPDF($currentCompany, $jobDescription) {
Línea 841... Línea 828...
841
 
828
 
842
        //Generate New PDF
829
        //Generate New PDF
Línea 843... Línea 830...
843
        $pdf = new JobPDF();
830
        $pdf = new JobPDF();
844
 
831
 
Línea 845... Línea -...
845
        $pdf->header='';
-
 
846
        $pdf->footer='';
-
 
847
 
-
 
848
        
-
 
849
        if($currentCompany){
-
 
Línea -... Línea 832...
-
 
832
        $pdf->header = '';
-
 
833
        $pdf->footer = '';
-
 
834
 
850
        //get company Data
835
 
Línea 851... Línea 836...
851
        $companyMapper = CompanyMapper::getInstance($this->adapter);
836
        if ($currentCompany) {
852
        $company = $companyMapper->fetchOne($currentCompany->id);
-
 
Línea -... Línea 837...
-
 
837
            //get company Data
-
 
838
            $companyMapper = CompanyMapper::getInstance($this->adapter);
853
 
839
            $company = $companyMapper->fetchOne($currentCompany->id);
Línea 854... Línea 840...
854
        $target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
840
 
Línea 855... Línea 841...
855
 
841
            $target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;