Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17018 Rev 17291
Línea 52... Línea 52...
52
    /**
52
    /**
53
     *
53
     *
54
     * @var \Laminas\Db\Adapter\AdapterInterface
54
     * @var \Laminas\Db\Adapter\AdapterInterface
55
     */
55
     */
56
    private $adapter;
56
    private $adapter;
57
    
57
 
58
    /**
58
    /**
59
     *
59
     *
60
     * @var \LeadersLinked\Cache\CacheInterface
60
     * @var \LeadersLinked\Cache\CacheInterface
61
     */
61
     */
62
    private $cache;
62
    private $cache;
63
    
63
 
64
    
64
 
65
    /**
65
    /**
66
     *
66
     *
67
     * @var \Laminas\Log\LoggerInterface
67
     * @var \Laminas\Log\LoggerInterface
68
     */
68
     */
69
    private $logger;
69
    private $logger;
70
    
70
 
71
    /**
71
    /**
72
     *
72
     *
73
     * @var array
73
     * @var array
74
     */
74
     */
75
    private $config;
75
    private $config;
76
    
76
 
77
    
77
 
78
    /**
78
    /**
79
     *
79
     *
80
     * @var \Laminas\Mvc\I18n\Translator
80
     * @var \Laminas\Mvc\I18n\Translator
81
     */
81
     */
82
    private $translator;
82
    private $translator;
83
    
83
 
84
    
84
 
85
    /**
85
    /**
86
     *
86
     *
87
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
87
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
88
     * @param \LeadersLinked\Cache\CacheInterface $cache
88
     * @param \LeadersLinked\Cache\CacheInterface $cache
89
     * @param \Laminas\Log\LoggerInterface LoggerInterface $logger
89
     * @param \Laminas\Log\LoggerInterface LoggerInterface $logger
Línea 797... Línea 797...
797
    }
797
    }
Línea 798... Línea 798...
798
 
798
 
799
 
799
 
-
 
800
 
800
 
801
    /**
801
    /**
802
     * Maneja las operaciones de imagen para un perfil de empresa, incluyendo carga y eliminación.
802
     * Cambio de la imagen del image del perfil
803
     *
803
     * @return \Laminas\View\Model\JsonModel
804
     * @return \Laminas\View\Model\JsonModel
-
 
805
     */
804
     */
806
    public function imageAction()
805
    public function imageAction()
807
    {
806
    {
808
        // Recuperar la información del usuario y la empresa actual
Línea -... Línea 809...
-
 
809
        $currentUserPlugin = $this->plugin('currentUserPlugin');
807
        $currentUserPlugin = $this->plugin('currentUserPlugin');
810
        $currentUser = $currentUserPlugin->getUser();
Línea 808... Línea -...
808
        $currentUser = $currentUserPlugin->getUser();
-
 
809
        $currentCompany = $currentUserPlugin->getCompany();
-
 
810
 
-
 
811
        $operation  = $this->params()->fromRoute('operation');
-
 
-
 
811
        $currentCompany = $currentUserPlugin->getCompany();
812
 
812
 
813
 
813
        // Determinar el tipo de operación (carga o eliminación)
-
 
814
        $operation  = $this->params()->fromRoute('operation');
-
 
815
 
814
 
816
        // Obtener el objeto de solicitud
815
 
817
        $request = $this->getRequest();
816
 
818
        if ($request->isPost()) {
817
        $request = $this->getRequest();
-
 
818
        if ($request->isPost()) {
819
 
-
 
820
            // Inicializar almacenamiento y rutas para imágenes de empresa y usuario
819
            $image = Image::getInstance($this->config);
821
            $storage = Storage::getInstance($this->config, $this->adapter);
820
            $target_company_path = $image->getStorage()->getPathCompany();
822
            $target_company_path = $storage->getPathCompany();
Línea 821... Línea -...
821
            $target_user_path = $image->getStorage()->getPathUser();
-
 
822
            
-
 
-
 
823
            $target_user_path = $storage->getPathUser();
823
            
824
 
824
            $companyMapper = CompanyMapper::getInstance($this->adapter);
825
            // Obtener los detalles de la empresa actual
Línea -... Línea 826...
-
 
826
            $companyMapper = CompanyMapper::getInstance($this->adapter);
825
            $company = $companyMapper->fetchOne($currentCompany->id);
827
            $company = $companyMapper->fetchOne($currentCompany->id);
Línea -... Línea 828...
-
 
828
 
826
 
829
            // Manejar la operación de eliminación
827
        
830
            if ($operation == 'delete') {
828
            
831
                $this->logger->info('Se borro la imagen de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
829
            if ($operation == 'delete') {
832
 
830
                $this->logger->info('Se borro la imagen de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
833
                // Verificar si la empresa tiene una imagen e intentar eliminarla
831
 
834
                if ($company->image) {
832
                if ($company->image) {
835
 
Línea -... Línea 836...
-
 
836
                    // Si la eliminación falla, devolver una respuesta de error
833
 
837
                    if (!$storage->deleteFile($target_company_path, $company->uuid, $company->image)) {
834
                    if (!$image->getStorage()->deleteFile($target_company_path, $company->uuid, $company->image)) {
838
                        return new JsonModel([
835
                        return new JsonModel([
839
                            'success'   => false,
836
                            'success'   => false,
840
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
837
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
841
                        ]);
838
                        ]);
842
                    }
839
                    }
843
                }
840
                }
844
 
-
 
845
                // Limpiar el campo de imagen en el registro de la empresa
841
 
846
                $company->image = '';
842
                $company->image = '';
847
                if (!$companyMapper->updateImage($company)) {
843
                if (!$companyMapper->updateImage($company)) {
848
                    return new JsonModel([
844
                    return new JsonModel([
849
                        'success'   => false,
845
                        'success'   => false,
850
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
846
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
851
                    ]);
847
                    ]);
852
                }
Línea -... Línea 853...
-
 
853
 
848
                }
854
                // Obtener el propietario de la empresa y actualizar su imagen si es necesario
849
                
855
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
850
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
856
                $companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
851
                $companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
-
 
852
                
857
 
853
                if($companyUser) {
-
 
-
 
858
                if ($companyUser) {
854
                    $userMapper = UserMapper::getInstance($this->adapter);
859
                    $userMapper = UserMapper::getInstance($this->adapter);
855
                    $user = $userMapper->fetchOne($companyUser->user_id);
860
                    $user = $userMapper->fetchOne($companyUser->user_id);
856
                    if($user) {
861
                    if ($user) {
-
 
862
 
857
 
863
                        // Eliminar la imagen del usuario si existe
858
                        if($user->image) {
864
                        if ($user->image) {
859
                            $image->getStorage()->deleteFile($target_user_path, $user->uuid, $user->image);
865
                            $storage->deleteFile($target_user_path, $user->uuid, $user->image);
860
                        }
866
                        }
861
                        
867
 
862
                        
868
                        // Limpiar el campo de imagen del usuario
863
                        
869
                        $user->image = '';
864
                        $user->image = '';
-
 
865
                        $userMapper->updateImage($user);
-
 
866
                        
870
                        $userMapper->updateImage($user);
-
 
871
 
867
                        if($company->name != $user->first_name) {
872
                        // Actualizar el nombre del usuario si difiere del nombre de la empresa
868
                            $user->first_name = $company->name;
873
                        if ($company->name != $user->first_name) {
Línea 869... Línea 874...
869
                            $user->last_name = '';
874
                            $user->first_name = $company->name;
Línea -... Línea 875...
-
 
875
                            $user->last_name = '';
870
                            $userMapper->updateFirstNameAndLastName($user);
876
                            $userMapper->updateFirstNameAndLastName($user);
Línea -... Línea 877...
-
 
877
                        }
871
                        }
878
                    }
872
                    }
879
                }
Línea 873... Línea 880...
873
                }
880
            } else {
874
                
881
                // Manejar la operación de carga de imagen
875
                
882
                $form = new ProfileImageForm($this->config);
876
            } else {
883
                $data     = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
877
                $form = new ProfileImageForm($this->config);
884
 
878
                $data     = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
-
 
879
 
-
 
880
                $form->setData($data);
-
 
881
 
-
 
Línea -... Línea 885...
-
 
885
                $form->setData($data);
-
 
886
 
-
 
887
                // Validar los datos del formulario
-
 
888
                if ($form->isValid()) {
Línea -... Línea 889...
-
 
889
 
882
                if ($form->isValid()) {
890
                    // Verificar errores de carga de archivos
Línea 883... Línea 891...
883
 
891
                    $files = $request->getFiles()->toArray();
884
                    $files = $request->getFiles()->toArray();
892
                    if (!empty($files['image']['error'])) {
885
                    if (!empty($files['image']['error'])) {
893
 
886
 
894
                        return new JsonModel([
887
                        return new JsonModel([
895
                            'success'   => false,
888
                            'success'   => false,
896
                            'data'   =>  'ERROR_UPLOAD_FILE'
889
                            'data'   =>  'ERROR_UPLOAD_FILE'
897
                        ]);
Línea 890... Línea -...
890
                        ]);
-
 
891
                    }
-
 
892
                    
-
 
893
                    $image = Image::getInstance($this->config);
-
 
894
                    $target_company_path = $image->getStorage()->getPathCompany();
-
 
Línea -... Línea 898...
-
 
898
                    }
-
 
899
 
-
 
900
                    // Inicializar el procesamiento de imágenes
-
 
901
                    $storage = Storage::getInstance($this->config, $this->adapter);
-
 
902
                    $target_company_path = $storage->getPathCompany();
-
 
903
                    $target_user_path = $storage->getPathUser();
-
 
904
 
-
 
905
                    // Eliminar la imagen existente de la empresa si está presente
-
 
906
                    if ($company->image) {
-
 
907
 
-
 
908
                        if (!$storage->deleteFile($target_company_path, $company->uuid, $company->image)) {
895
                    $target_user_path = $image->getStorage()->getPathUser();
909
                            return new JsonModel([
-
 
910
                                'success'   => false,
-
 
911
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
912
                            ]);
896
 
913
                        }
897
 
914
                    }
-
 
915
 
898
                    if ($company->image) {
916
 
899
 
917
                    // Obtener dimensiones objetivo para el redimensionamiento
900
                        if (!$image->getStorage()->deleteFile($target_company_path, $company->uuid, $company->image)) {
918
                    list($target_width_str, $target_height_str) = explode('x', $this->config['leaderslinked.image_sizes.company_image_size']);
Línea -... Línea 919...
-
 
919
                    $target_width = (int)$target_width_str;
901
                            return new JsonModel([
920
                    $target_height = (int)$target_height_str;
902
                                'success'   => false,
921
 
903
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
904
                            ]);
-
 
905
                        }
922
                    // Generar nombres de archivo únicos
906
                    }
-
 
907
 
923
                    $source    = $storage->getTmpFilename();
908
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_image_size']);
924
                    $filename           = 'company-image-' . uniqid() . '.png';
-
 
925
                    $target_filename    = $storage->composePathToFilename(Storage::TYPE_USER, $company->uuid, $filename);
909
                    $source             = $files['image']['tmp_name'];
926
 
910
                    $target_filename    = 'company-image-' . uniqid() . '.png';
927
                    // Subir y redimensionar la imagen
911
                    $crop_to_dimensions = true;
928
                    if (!$storage->uploadImageResize($source, $target_filename, $target_width, $target_height)) {
912
                    $unlink_source = false;
929
                        return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
913
 
930
                    }
914
                    if(!$image->uploadProcessChangeSize($source, $target_company_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
931
 
-
 
932
                    // Eliminar la imagen anterior si existe
-
 
933
                    if ($company->image) {
-
 
934
                        if (!$storage->deleteFile($target_company_path, $company->uuid, $company->image)) {
-
 
935
                            return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
915
                        return new JsonModel([
936
                        }
916
                            'success'   => false,
937
                    }
-
 
938
 
917
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
939
 
918
                        ]);
940
                    // Actualizar el perfil con la nueva imagen
919
                    }
941
                    $company->image = $target_filename;
920
 
942
                    if (!$companyMapper->updateImage($company)) {
921
 
-
 
922
                    $company->image = $target_filename;
943
                        return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
923
                    if (!$companyMapper->updateImage($company)) {
944
                    }
924
                        return new JsonModel([
-
 
925
                            'success'   => false,
-
 
926
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
927
                        ]);
-
 
928
                    }
-
 
929
                    
-
 
930
                    $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
945
 
931
                    $companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
-
 
932
                    
946
                    // Actualizar la imagen del propietario si es necesario
933
                    if($companyUser) {
-
 
934
                        $userMapper = UserMapper::getInstance($this->adapter);
947
                    $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
935
                        $user = $userMapper->fetchOne($companyUser->user_id);
-
 
936
                        if($user) {
948
                    $companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
937
     
949
 
938
                            if($user->image) {
950
                    if ($companyUser) {
939
                                $image->getStorage()->deleteFile($target_user_path, $user->uuid, $user->image);
-
 
940
                            }
951
                        $userMapper = UserMapper::getInstance($this->adapter);
941
                            
952
                        $user = $userMapper->fetchOne($companyUser->user_id);
942
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.user_image_size']);
-
 
943
                            $source             = $files['image']['tmp_name'];
953
 
944
                            $target_filename    = 'user-image-' . uniqid() . '.png';
954
                        $main_company_filename = 'comany-' . uniqid() . '.png';
-
 
955
                        $target_filename_main_company = $storage->composePathToFilename(Storage::TYPE_USER, $user->uuid, $main_company_filename);
-
 
956
 
-
 
957
                        if ($user) {
-
 
958
 
-
 
959
                            // Eliminar la imagen existente del usuario si está presente
-
 
960
                            if ($user->image) {
-
 
961
                                $storage->deleteFile($target_user_path, $user->uuid, $user->image);
945
                            $crop_to_dimensions = true;
962
                            }
946
                            $unlink_source = true;
963
 
947
                            
964
                            // Copiar la imagen del perfil para la imagen principal
948
                            if(!$image->uploadProcessChangeSize($source, $target_company_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
965
                            if (!$storage->copyFile($target_filename, $target_filename_main_company)) {
949
                                return new JsonModel([
966
                                return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
950
                                    'success'   => false,
967
                            }
951
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
968
 
952
                                ]);
-
 
Línea -... Línea 969...
-
 
969
                            // Eliminar la imagen principal anterior si existe
953
                            }
970
                            if ($currentUser->image) {
954
                            
971
                                if (!$storage->deleteFile($target_company_path, $user->uuid, $currentUser->image)) {
-
 
972
                                    return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
955
                            
973
                                }
956
                            
974
                            }
957
                            $user->image = $target_filename;
975
 
958
                            if(!$userMapper->updateImage($user)) {
976
                            // Actualizar la imagen principal del usuario
959
                                return new JsonModel([
977
                            $currentUser->image = $main_company_filename;
Línea 984... Línea 1002...
984
                        'success'   => false,
1002
                        'success'   => false,
985
                        'data'   => $messages
1003
                        'data'   => $messages
986
                    ]);
1004
                    ]);
987
                }
1005
                }
988
            }
1006
            }
989
            
1007
 
-
 
1008
            // Devolver la imagen actualizada de la empresa
990
            $storage = Storage::getInstance($this->config, $this->adapter);
1009
            $storage = Storage::getInstance($this->config, $this->adapter);
991
            
1010
 
992
            return new JsonModel([
1011
            return new JsonModel([
993
                'success'   => true,
1012
                'success'   => true,
994
                'data' => $storage->getCompanyImage($company->uuid)
1013
                'data' => $storage->getCompanyImage($company->uuid)
Línea 995... Línea 1014...
995
 
1014
 
996
            ]);
1015
            ]);
Línea 997... Línea -...
997
        }
-
 
-
 
1016
        }
998
 
1017
 
999
 
1018
        // Devolver error si el método de solicitud no está permitido
1000
        $data = [
1019
        $data = [
1001
            'success' => false,
1020
            'success' => false,
Línea 1002... Línea -...
1002
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
1003
        ];
1021
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1004
 
1022
        ];
Línea 1005... Línea 1023...
1005
 
1023
 
1006
        return new JsonModel($data);
1024
        return new JsonModel($data);
Línea 1022... Línea 1040...
1022
 
1040
 
1023
 
1041
 
1024
 
1042
 
1025
        $request = $this->getRequest();
1043
        $request = $this->getRequest();
1026
        if ($request->isPost()) {
1044
        if ($request->isPost()) {
Línea 1027... Línea 1045...
1027
            
1045
 
1028
            $image = Image::getInstance($this->config);
1046
            $image = Image::getInstance($this->config);
Línea 1029... Línea 1047...
1029
            $target_path = $image->getStorage()->getPathCompany();
1047
            $target_path = $image->getStorage()->getPathCompany();
Línea 1030... Línea 1048...
1030
 
1048
 
Línea 1031... Línea 1049...
1031
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1049
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1032
            $company = $companyMapper->fetchOne($currentCompany->id);
1050
            $company = $companyMapper->fetchOne($currentCompany->id);
Línea 1033... Línea 1051...
1033
 
1051
 
Línea 1086... Línea 1104...
1086
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_cover_size']);
1104
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_cover_size']);
1087
                    $source             = $files['cover']['tmp_name'];
1105
                    $source             = $files['cover']['tmp_name'];
1088
                    $target_filename    = 'company-cover-' . uniqid() . '.png';
1106
                    $target_filename    = 'company-cover-' . uniqid() . '.png';
1089
                    $crop_to_dimensions = false;
1107
                    $crop_to_dimensions = false;
1090
                    $unlink_source = true;
1108
                    $unlink_source = true;
1091
                    
1109
 
1092
                    if($image->uploadProcessChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
1110
                    if ($image->uploadProcessChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
1093
                        return new JsonModel([
1111
                        return new JsonModel([
1094
                            'success'   => false,
1112
                            'success'   => false,
1095
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1113
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1096
                        ]);
1114
                        ]);
1097
                    }
1115
                    }
Línea 1120... Línea 1138...
1120
                        'success'   => false,
1138
                        'success'   => false,
1121
                        'data'   => $messages
1139
                        'data'   => $messages
1122
                    ]);
1140
                    ]);
1123
                }
1141
                }
1124
            }
1142
            }
1125
            
1143
 
1126
            $storage = Storage::getInstance($this->config, $this->adapter);
1144
            $storage = Storage::getInstance($this->config, $this->adapter);
1127
            
1145
 
1128
            
1146
 
1129
            return new JsonModel([
1147
            return new JsonModel([
1130
                'success'   => true,
1148
                'success'   => true,
1131
                'data' => $storage->getCompanyCover($company)
1149
                'data' => $storage->getCompanyCover($company)
Línea 1132... Línea 1150...
1132
 
1150
 
Línea 1222... Línea 1240...
1222
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_header_pdf_size']);
1240
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_header_pdf_size']);
1223
                    $source             = $files['header']['tmp_name'];
1241
                    $source             = $files['header']['tmp_name'];
1224
                    $target_filename    = 'company-header-' . uniqid() . '.png';
1242
                    $target_filename    = 'company-header-' . uniqid() . '.png';
1225
                    $crop_to_dimensions = false;
1243
                    $crop_to_dimensions = false;
1226
                    $unlink_source = true;
1244
                    $unlink_source = true;
1227
                    
1245
 
1228
                    if($image->uploadProcessChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
1246
                    if ($image->uploadProcessChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
1229
                        return new JsonModel([
1247
                        return new JsonModel([
1230
                            'success'   => false,
1248
                            'success'   => false,
1231
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1249
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1232
                        ]);
1250
                        ]);
1233
                    }
1251
                    }
Línea 1254... Línea 1272...
1254
                        'success'   => false,
1272
                        'success'   => false,
1255
                        'data'   => $messages
1273
                        'data'   => $messages
1256
                    ]);
1274
                    ]);
1257
                }
1275
                }
1258
            }
1276
            }
1259
            
1277
 
1260
            $storage = Storage::getInstance($this->config, $this->adapter);
1278
            $storage = Storage::getInstance($this->config, $this->adapter);
1261
            $path = $storage->getPathCompany();
1279
            $path = $storage->getPathCompany();
1262
            
1280
 
1263
            return new JsonModel([
1281
            return new JsonModel([
1264
                'success'   => true,
1282
                'success'   => true,
1265
                'data' => $company->header ? $storage->getGenericImage($path, $company->uuid, $company->header) : '',
1283
                'data' => $company->header ? $storage->getGenericImage($path, $company->uuid, $company->header) : '',
Línea 1266... Línea 1284...
1266
 
1284
 
Línea 1355... Línea 1373...
1355
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_footer_pdf_size']);
1373
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_footer_pdf_size']);
1356
                    $source             = $files['footer']['tmp_name'];
1374
                    $source             = $files['footer']['tmp_name'];
1357
                    $target_filename    = 'company-footer-' . uniqid() . '.png';
1375
                    $target_filename    = 'company-footer-' . uniqid() . '.png';
1358
                    $crop_to_dimensions = false;
1376
                    $crop_to_dimensions = false;
1359
                    $unlink_source = true;
1377
                    $unlink_source = true;
1360
                    
1378
 
1361
                    if($image->uploadProcessChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) { 
1379
                    if ($image->uploadProcessChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
1362
                        return new JsonModel([
1380
                        return new JsonModel([
1363
                            'success'   => false,
1381
                            'success'   => false,
1364
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1382
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1365
                        ]);
1383
                        ]);
1366
                    }
1384
                    }
Línea 1389... Línea 1407...
1389
                        'success'   => false,
1407
                        'success'   => false,
1390
                        'data'   => $messages
1408
                        'data'   => $messages
1391
                    ]);
1409
                    ]);
1392
                }
1410
                }
1393
            }
1411
            }
1394
            
1412
 
1395
            $storage = Storage::getInstance($this->config, $this->adapter);
1413
            $storage = Storage::getInstance($this->config, $this->adapter);
1396
            $path = $storage->getPathCompany();
1414
            $path = $storage->getPathCompany();
1397
            
1415
 
1398
            return new JsonModel([
1416
            return new JsonModel([
1399
                'success'   => true,
1417
                'success'   => true,
1400
                'data' => $company->footer ? $storage->getGenericImage($path, $company->uuid, $company->footer) : '',
1418
                'data' => $company->footer ? $storage->getGenericImage($path, $company->uuid, $company->footer) : '',
Línea 1401... Línea 1419...
1401
 
1419
 
Línea 1434... Línea 1452...
1434
            $company = $companyMapper->fetchOne($currentCompany->id);
1452
            $company = $companyMapper->fetchOne($currentCompany->id);
Línea 1435... Línea 1453...
1435
 
1453
 
1436
            $industries = [];
1454
            $industries = [];
1437
            $industryMapper = IndustryMapper::getInstance($this->adapter);
1455
            $industryMapper = IndustryMapper::getInstance($this->adapter);
1438
            $records = $industryMapper->fetchAllActive();
1456
            $records = $industryMapper->fetchAllActive();
1439
            
1457
 
1440
            foreach ($records as $record)
-
 
1441
            {
1458
            foreach ($records as $record) {
1442
                $industries[$record->uuid] = $record->name;
1459
                $industries[$record->uuid] = $record->name;
1443
            }
1460
            }
1444
            
1461
 
1445
            $industry = $industryMapper->fetchOne($company->industry_id);
1462
            $industry = $industryMapper->fetchOne($company->industry_id);
1446
            
1463
 
1447
            
1464
 
Línea 1448... Línea 1465...
1448
            
1465
 
1449
 
1466
 
1450
            $data = [
1467
            $data = [
1451
                'success' => true,
1468
                'success' => true,
Línea 1457... Línea 1474...
1457
 
1474
 
1458
            return new JsonModel($data);
1475
            return new JsonModel($data);
Línea 1459... Línea 1476...
1459
        } else if ($request->isPost()) {
1476
        } else if ($request->isPost()) {
1460
 
1477
 
1461
 
1478
 
Línea 1462... Línea 1479...
1462
            
1479
 
Línea 1486... Línea 1503...
1486
                    'success'   => true,
1503
                    'success'   => true,
1487
                    'data' =>  $industry->name,
1504
                    'data' =>  $industry->name,
Línea 1488... Línea 1505...
1488
 
1505
 
1489
                ]);
1506
                ]);
1490
            } else {
1507
            } else {
1491
            
1508
 
1492
                $messages = [];
1509
                $messages = [];
1493
                $form_messages = (array) $form->getMessages();
1510
                $form_messages = (array) $form->getMessages();
1494
                foreach ($form_messages  as $fieldname => $field_messages) {
1511
                foreach ($form_messages  as $fieldname => $field_messages) {
1495
                    $messages[$fieldname] = array_values($field_messages);
1512
                    $messages[$fieldname] = array_values($field_messages);
Línea 1530... Línea 1547...
1530
        if ($request->isGet()) {
1547
        if ($request->isGet()) {
1531
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1548
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1532
            $company = $companyMapper->fetchOne($currentCompany->id);
1549
            $company = $companyMapper->fetchOne($currentCompany->id);
Línea 1533... Línea 1550...
1533
 
1550
 
1534
            $companySizes = [];
1551
            $companySizes = [];
1535
            
1552
 
1536
            $companySizeMapper = CompanySizeMapper::getInstance($this->adapter);
1553
            $companySizeMapper = CompanySizeMapper::getInstance($this->adapter);
1537
            $records = $companySizeMapper->fetchAllActive();
1554
            $records = $companySizeMapper->fetchAllActive();
1538
            
1555
 
1539
            foreach($records as $record)
-
 
1540
            {
1556
            foreach ($records as $record) {
1541
                $companySizes[$record->uuid] = $record->name . ' (' . $record->minimum_no_of_employee . '-' . $record->maximum_no_of_employee . ')';
1557
                $companySizes[$record->uuid] = $record->name . ' (' . $record->minimum_no_of_employee . '-' . $record->maximum_no_of_employee . ')';
1542
            }
1558
            }
1543
            
1559
 
1544
            
1560
 
Línea 1545... Línea 1561...
1545
            $companySize = $companySizeMapper->fetchOne($company->company_size_id);
1561
            $companySize = $companySizeMapper->fetchOne($company->company_size_id);
1546
 
1562
 
1547
            $data = [
1563
            $data = [
Línea 1604... Línea 1620...
1604
        ];
1620
        ];
Línea 1605... Línea 1621...
1605
 
1621
 
1606
 
1622
 
-
 
1623
        return new JsonModel($data);
-
 
1624
    }
-
 
1625
 
-
 
1626
    private function _createSimpleErrorResponse($errorMessageKey)
-
 
1627
    {
-
 
1628
        return new JsonModel([
-
 
1629
            'success' => false,
-
 
1630
            'data'    => $errorMessageKey
1607
        return new JsonModel($data);
1631
        ]);