Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16769 Rev 17002
Línea 20... Línea 20...
20
use LeadersLinked\Library\Functions;
20
use LeadersLinked\Library\Functions;
21
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
21
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
22
use LeadersLinked\Library\Image;
22
use LeadersLinked\Library\Image;
Línea 23... Línea 23...
23
 
23
 
24
use LeadersLinked\Mapper\CompanyLocationMapper;
24
use LeadersLinked\Mapper\CompanyLocationMapper;
25
use LeadersLinked\Form\CompanyProfileSocialNetworkForm;
25
use LeadersLinked\Form\CompanyProfile\ProfileSocialNetworkForm;
26
use LeadersLinked\Form\CompanyProfileLocationForm;
26
use LeadersLinked\Form\CompanyProfile\ProfileLocationForm;
27
use LeadersLinked\Form\CompanyProfileExtendedForm;
27
use LeadersLinked\Form\CompanyProfile\ProfileExtendedForm;
28
use LeadersLinked\Form\CompanyProfileImageForm;
28
use LeadersLinked\Form\CompanyProfile\ProfileImageForm;
29
use LeadersLinked\Form\CompanyProfileCoverForm;
29
use LeadersLinked\Form\CompanyProfile\ProfileCoverForm;
30
use LeadersLinked\Form\CompanyProfileHeaderForm;
30
use LeadersLinked\Form\CompanyProfile\ProfileHeaderForm;
31
use LeadersLinked\Form\CompanyProfileFooterForm;
31
use LeadersLinked\Form\CompanyProfile\ProfileFooterForm;
32
 
32
 
33
use LeadersLinked\Form\CompanyProfileIndustryForm;
33
use LeadersLinked\Form\CompanyProfile\ProfileIndustryForm;
34
use LeadersLinked\Form\CompanyProfileCompanySizeForm;
34
use LeadersLinked\Form\CompanyProfile\ProfileCompanySizeForm;
35
use LeadersLinked\Form\CompanyProfileFoundationYearForm;
35
use LeadersLinked\Form\CompanyProfile\ProfileFoundationYearForm;
36
use LeadersLinked\Form\CompanyProfileWebsiteForm;
36
use LeadersLinked\Form\CompanyProfile\ProfileWebsiteForm;
37
use LeadersLinked\Model\Location;
37
use LeadersLinked\Model\Location;
38
use LeadersLinked\Model\CompanyLocation;
38
use LeadersLinked\Model\CompanyLocation;
Línea 39... Línea 39...
39
use LeadersLinked\Model\CompanyUser;
39
use LeadersLinked\Model\CompanyUser;
Línea 43... Línea 43...
43
use LeadersLinked\Mapper\CompanyUserMapper;
43
use LeadersLinked\Mapper\CompanyUserMapper;
44
use LeadersLinked\Mapper\CompanyMapper;
44
use LeadersLinked\Mapper\CompanyMapper;
45
use LeadersLinked\Mapper\IndustryMapper;
45
use LeadersLinked\Mapper\IndustryMapper;
46
use LeadersLinked\Mapper\CompanySizeMapper;
46
use LeadersLinked\Mapper\CompanySizeMapper;
47
use LeadersLinked\Mapper\UserMapper;
47
use LeadersLinked\Mapper\UserMapper;
-
 
48
use LeadersLinked\Library\Storage;
Línea 48... Línea 49...
48
 
49
 
49
class ProfileController extends AbstractActionController
50
class ProfileController extends AbstractActionController
50
{
51
{
51
    /**
52
    /**
Línea 146... Línea 147...
146
            }
147
            }
Línea 147... Línea 148...
147
 
148
 
148
            $industryMapper = IndustryMapper::getInstance($this->adapter);
149
            $industryMapper = IndustryMapper::getInstance($this->adapter);
Línea 149... Línea 150...
149
            $companySizeMapper = CompanySizeMapper::getInstance($this->adapter);
150
            $companySizeMapper = CompanySizeMapper::getInstance($this->adapter);
150
 
151
 
151
            $formSocialNetwork = new CompanyProfileSocialNetworkForm();
152
            $formSocialNetwork = new ProfileSocialNetworkForm();
152
            $formLocation = new CompanyProfileLocationForm();
153
            $formLocation = new ProfileLocationForm();
153
            $formExtended = new CompanyProfileExtendedForm();
154
            $formExtended = new ProfileExtendedForm();
154
            $formFoundationYear = new CompanyProfileFoundationYearForm();
155
            $formFoundationYear = new ProfileFoundationYearForm();
155
            $formWebsite = new CompanyProfileWebsiteForm();
156
            $formWebsite = new ProfileWebsiteForm();
156
            $formImage = new CompanyProfileImageForm($this->config);
157
            $formImage = new ProfileImageForm($this->config);
157
            $formCover = new CompanyProfileCoverForm($this->config);
158
            $formCover = new ProfileCoverForm($this->config);
Línea 158... Línea 159...
158
            $formHeader = new CompanyProfileHeaderForm($this->config);
159
            $formHeader = new ProfileHeaderForm($this->config);
159
            $formFooter = new CompanyProfileFooterForm($this->config);
160
            $formFooter = new ProfileFooterForm($this->config);
Línea 160... Línea 161...
160
 
161
 
161
 
162
 
Línea 162... Línea 163...
162
 
163
 
Línea 310... Línea 311...
310
                ]
311
                ]
311
            ];
312
            ];
Línea 312... Línea 313...
312
 
313
 
313
            return new JsonModel($data);
314
            return new JsonModel($data);
314
        } else if ($request->isPost()) {
315
        } else if ($request->isPost()) {
315
            $form = new CompanyProfileExtendedForm();
316
            $form = new ProfileExtendedForm();
Línea 316... Línea 317...
316
            $dataPost = $request->getPost()->toArray();
317
            $dataPost = $request->getPost()->toArray();
Línea 317... Línea 318...
317
 
318
 
Línea 384... Línea 385...
384
 
385
 
385
            return new JsonModel($data);
386
            return new JsonModel($data);
Línea 386... Línea 387...
386
        } else if ($request->isPost()) {
387
        } else if ($request->isPost()) {
387
 
388
 
Línea 388... Línea 389...
388
 
389
 
Línea 389... Línea 390...
389
            $form = new CompanyProfileWebsiteForm();
390
            $form = new ProfileWebsiteForm();
Línea 462... Línea 463...
462
 
463
 
463
            return new JsonModel($data);
464
            return new JsonModel($data);
Línea 464... Línea 465...
464
        } else if ($request->isPost()) {
465
        } else if ($request->isPost()) {
465
 
466
 
Línea 466... Línea 467...
466
 
467
 
Línea 467... Línea 468...
467
            $form = new CompanyProfileFoundationYearForm();
468
            $form = new ProfileFoundationYearForm();
Línea 580... Línea 581...
580
                        'success'   => false,
581
                        'success'   => false,
581
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
582
                        'data' => 'ERROR_THERE_WAS_AN_ERROR'
582
                    ];
583
                    ];
583
                }
584
                }
584
            } else {
585
            } else {
585
                $form = new CompanyProfileLocationForm();
586
                $form = new ProfileLocationForm();
586
                $dataPost = $request->getPost()->toArray();
587
                $dataPost = $request->getPost()->toArray();
Línea 587... Línea 588...
587
 
588
 
Línea 744... Línea 745...
744
            ];
745
            ];
Línea 745... Línea 746...
745
 
746
 
746
            return new JsonModel($data);
747
            return new JsonModel($data);
Línea 747... Línea 748...
747
        } else if ($request->isPost()) {
748
        } else if ($request->isPost()) {
748
 
749
 
Línea 749... Línea 750...
749
            $form = new CompanyProfileSocialNetworkForm();
750
            $form = new ProfileSocialNetworkForm();
Línea 750... Línea 751...
750
            $dataPost = $request->getPost()->toArray();
751
            $dataPost = $request->getPost()->toArray();
Línea 813... Línea 814...
813
 
814
 
814
 
815
 
-
 
816
 
-
 
817
        $request = $this->getRequest();
-
 
818
        if ($request->isPost()) {
-
 
819
            $image = Image::getInstance($this->config);
-
 
820
            $target_company_path = $image->getStorage()->getPathCompany();
815
 
821
            $target_user_path = $image->getStorage()->getPathUser();
816
        $request = $this->getRequest();
822
            
Línea 817... Línea -...
817
        if ($request->isPost()) {
-
 
818
            $companyMapper = CompanyMapper::getInstance($this->adapter);
823
            
Línea 819... Línea 824...
819
            $company = $companyMapper->fetchOne($currentCompany->id);
824
            $companyMapper = CompanyMapper::getInstance($this->adapter);
820
 
825
            $company = $companyMapper->fetchOne($currentCompany->id);
Línea 821... Línea 826...
821
            $target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
826
 
Línea 822... Línea 827...
822
            
827
        
823
            
828
            
824
            if ($operation == 'delete') {
829
            if ($operation == 'delete') {
825
                $this->logger->info('Se borro la imagen de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
830
                $this->logger->info('Se borro la imagen de la empresa: ' . $company->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
826
 
831
 
827
                if ($company->image) {
832
                if ($company->image) {
Línea 847... Línea 852...
847
                
852
                
848
                if($companyUser) {
853
                if($companyUser) {
849
                    $userMapper = UserMapper::getInstance($this->adapter);
854
                    $userMapper = UserMapper::getInstance($this->adapter);
850
                    $user = $userMapper->fetchOne($companyUser->user_id);
855
                    $user = $userMapper->fetchOne($companyUser->user_id);
851
                    if($user) {
-
 
852
                        $user_path = $this->config['leaderslinked.fullpath.user'] . DIRECTORY_SEPARATOR . $user->uuid;
-
 
853
                        if(!file_exists($user_path)) {
-
 
854
                            mkdir($user_path, 0755, true);
-
 
855
                        }
856
                    if($user) {
856
                        
857
 
857
                        if($user->image) {
858
                        if($user->image) {
858
                            $filename = $user_path . DIRECTORY_SEPARATOR . $user->image;
-
 
859
                            if(file_exists($filename) && is_writable($filename)) {
-
 
860
                                @unlink($filename);
-
 
861
                            }
859
                            $image->getStorage()->deleteFile($target_user_path, $user->uuid, $user->image);
Línea 862... Línea 860...
862
                        }
860
                        }
Línea 874... Línea 872...
874
                    }
872
                    }
875
                }
873
                }
Línea 876... Línea 874...
876
                
874
                
877
                
875
                
878
            } else {
876
            } else {
Línea 879... Línea 877...
879
                $form = new CompanyProfileImageForm($this->config);
877
                $form = new ProfileImageForm($this->config);
Línea 880... Línea 878...
880
                $data     = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
878
                $data     = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
Línea 889... Línea 887...
889
                        return new JsonModel([
887
                        return new JsonModel([
890
                            'success'   => false,
888
                            'success'   => false,
891
                            'data'   =>  'ERROR_UPLOAD_FILE'
889
                            'data'   =>  'ERROR_UPLOAD_FILE'
892
                        ]);
890
                        ]);
893
                    }
891
                    }
-
 
892
                    
-
 
893
                    $image = Image::getInstance($this->config);
-
 
894
                    $target_company_path = $image->getStorage()->getPathCompany();
-
 
895
                    $target_user_path = $image->getStorage()->getPathUser();
Línea 894... Línea 896...
894
 
896
 
Línea 895... Línea 897...
895
 
897
 
896
                    if ($company->image) {
898
                    if ($company->image) {
897
 
899
 
898
                        if (!Image::delete($target_path, $company->image)) {
900
                        if (!$image->getStorage()->deleteFile($target_company_path, $company->uuid, $company->image)) {
899
                            return new JsonModel([
901
                            return new JsonModel([
900
                                'success'   => false,
902
                                'success'   => false,
Línea 905... Línea 907...
905
 
907
 
906
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_image_size']);
908
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_image_size']);
907
                    $source             = $files['image']['tmp_name'];
909
                    $source             = $files['image']['tmp_name'];
908
                    $target_filename    = 'company-image-' . uniqid() . '.png';
910
                    $target_filename    = 'company-image-' . uniqid() . '.png';
-
 
911
                    $crop_to_dimensions = true;
Línea 909... Línea 912...
909
                    $crop_to_dimensions = true;
912
                    $unlink_source = false;
910
 
913
 
911
                    if (!Image::uploadImage($source, $target_path, $target_filename, $target_width, $target_height, $crop_to_dimensions)) {
914
                    if(!$image->uploadImageChangeSize($source, $target_company_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
912
                        return new JsonModel([
915
                        return new JsonModel([
913
                            'success'   => false,
916
                            'success'   => false,
914
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
917
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
Línea 929... Línea 932...
929
                    
932
                    
930
                    if($companyUser) {
933
                    if($companyUser) {
931
                        $userMapper = UserMapper::getInstance($this->adapter);
934
                        $userMapper = UserMapper::getInstance($this->adapter);
932
                        $user = $userMapper->fetchOne($companyUser->user_id);
935
                        $user = $userMapper->fetchOne($companyUser->user_id);
933
                        if($user) {
-
 
-
 
936
                        if($user) {
934
                            $user_path = $this->config['leaderslinked.fullpath.user'] . DIRECTORY_SEPARATOR . $user->uuid;
937
     
935
                            if(!file_exists($user_path)) {
938
                            if($user->image) {
936
                                mkdir($user_path, 0755, true);
939
                                $image->getStorage()->deleteFile($target_user_path, $user->uuid, $user->image);
Línea -... Línea 940...
-
 
940
                            }
-
 
941
                            
-
 
942
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.user_image_size']);
937
                            }
943
                            $source             = $files['image']['tmp_name'];
938
                            
944
                            $target_filename    = 'user-image-' . uniqid() . '.png';
-
 
945
                            $crop_to_dimensions = true;
-
 
946
                            $unlink_source = true;
939
                            if($user->image) {
947
                            
940
                                $filename = $user_path . DIRECTORY_SEPARATOR . $user->image;
948
                            if(!$image->uploadImageChangeSize($source, $target_company_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
-
 
949
                                return new JsonModel([
941
                                if(file_exists($filename) && is_writable($filename)) {
950
                                    'success'   => false,
942
                                    @unlink($filename);
951
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
Línea -... Línea 952...
-
 
952
                                ]);
-
 
953
                            }
943
                                }
954
                            
944
                            }
955
                            
-
 
956
                            
945
                            
957
                            $user->image = $target_filename;
946
                            $user->image = $company->image;
958
                            if(!$userMapper->updateImage($user)) {
947
                            if($userMapper->updateImage($user)) {
959
                                return new JsonModel([
Línea 948... Línea 960...
948
                                $source = $target_path . DIRECTORY_SEPARATOR . $target_filename;
960
                                    'success'   => false,
Línea 949... Línea 961...
949
                                $dest = $user_path . DIRECTORY_SEPARATOR . $target_filename;
961
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
950
                                @copy($source, $dest);
962
                                ]);
Línea 972... Línea 984...
972
                        'success'   => false,
984
                        'success'   => false,
973
                        'data'   => $messages
985
                        'data'   => $messages
974
                    ]);
986
                    ]);
975
                }
987
                }
976
            }
988
            }
-
 
989
            
-
 
990
            $storage = Storage::getInstance($this->config);
-
 
991
            
977
            return new JsonModel([
992
            return new JsonModel([
978
                'success'   => true,
993
                'success'   => true,
979
                'data' => $this->url()->fromRoute('storage', ['type' => 'company', 'code' => $company->uuid, 'filename' => $company->image])
994
                'data' => $storage->getCompanyImage($company->uuid)
Línea 980... Línea 995...
980
 
995
 
981
            ]);
996
            ]);
Línea 1007... Línea 1022...
1007
 
1022
 
1008
 
1023
 
-
 
1024
 
-
 
1025
        $request = $this->getRequest();
-
 
1026
        if ($request->isPost()) {
Línea 1009... Línea 1027...
1009
 
1027
            
1010
        $request = $this->getRequest();
1028
            $image = Image::getInstance($this->config);
Línea 1011... Línea 1029...
1011
        if ($request->isPost()) {
1029
            $target_path = $image->getStorage()->getPathCompany();
Línea -... Línea 1030...
-
 
1030
 
Línea 1012... Línea 1031...
1012
 
1031
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1013
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1032
            $company = $companyMapper->fetchOne($currentCompany->id);
Línea 1014... Línea 1033...
1014
            $company = $companyMapper->fetchOne($currentCompany->id);
1033
 
1015
 
1034
            $target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
1016
            $target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
1035
 
1017
 
1036
 
1018
 
1037
            
1019
 
1038
 
Línea 1035... Línea 1054...
1035
                        'success'   => false,
1054
                        'success'   => false,
1036
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1055
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1037
                    ]);
1056
                    ]);
1038
                }
1057
                }
1039
            } else {
1058
            } else {
1040
                $form = new CompanyProfileCoverForm($this->config);
1059
                $form = new ProfileCoverForm($this->config);
1041
                $data     = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
1060
                $data     = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
Línea 1042... Línea 1061...
1042
 
1061
 
Línea 1043... Línea 1062...
1043
                $form->setData($data);
1062
                $form->setData($data);
Línea 1066... Línea 1085...
1066
 
1085
 
1067
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_cover_size']);
1086
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_cover_size']);
1068
                    $source             = $files['cover']['tmp_name'];
1087
                    $source             = $files['cover']['tmp_name'];
1069
                    $target_filename    = 'company-cover-' . uniqid() . '.png';
1088
                    $target_filename    = 'company-cover-' . uniqid() . '.png';
-
 
1089
                    $crop_to_dimensions = false;
1070
                    $crop_to_dimensions = false;
1090
                    $unlink_source = true;
1071
 
1091
                    
1072
                    if (!Image::uploadImage($source, $target_path, $target_filename, $target_width, $target_height, $crop_to_dimensions)) {
1092
                    if($image->uploadImageChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
1073
                        return new JsonModel([
1093
                        return new JsonModel([
1074
                            'success'   => false,
1094
                            'success'   => false,
1075
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1095
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1076
                        ]);
1096
                        ]);
Línea 1100... Línea 1120...
1100
                        'success'   => false,
1120
                        'success'   => false,
1101
                        'data'   => $messages
1121
                        'data'   => $messages
1102
                    ]);
1122
                    ]);
1103
                }
1123
                }
1104
            }
1124
            }
-
 
1125
            
-
 
1126
            $storage = Storage::getInstance($this->config);
-
 
1127
            
-
 
1128
            
1105
            return new JsonModel([
1129
            return new JsonModel([
1106
                'success'   => true,
1130
                'success'   => true,
1107
                'data' => $this->url()->fromRoute('storage', ['type' => 'company-cover', 'code' => $company->uuid, 'filename' => $company->cover])
1131
                'data' => $storage->getCompanyCover($company)
Línea 1108... Línea 1132...
1108
 
1132
 
1109
            ]);
1133
            ]);
Línea 1141... Línea 1165...
1141
        if ($request->isPost()) {
1165
        if ($request->isPost()) {
Línea 1142... Línea 1166...
1142
 
1166
 
1143
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1167
            $companyMapper = CompanyMapper::getInstance($this->adapter);
Línea -... Línea 1168...
-
 
1168
            $company = $companyMapper->fetchOne($currentCompany->id);
1144
            $company = $companyMapper->fetchOne($currentCompany->id);
1169
 
Línea 1145... Línea 1170...
1145
 
1170
            $image = Image::getInstance($this->config);
1146
            $target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
1171
            $target_path = $image->getStorage()->getPathCompany();
Línea 1147... Línea 1172...
1147
 
1172
 
1148
 
1173
 
1149
 
1174
 
1150
            if ($operation == 'delete') {
1175
            if ($operation == 'delete') {
1151
                if ($company->header) {
1176
                if ($company->header) {
1152
 
1177
 
Línea 1165... Línea 1190...
1165
                        'success'   => false,
1190
                        'success'   => false,
1166
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1191
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1167
                    ]);
1192
                    ]);
1168
                }
1193
                }
1169
            } else {
1194
            } else {
1170
                $form = new CompanyProfileHeaderForm($this->config);
1195
                $form = new ProfileHeaderForm($this->config);
1171
                $data   = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
1196
                $data   = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
Línea 1172... Línea 1197...
1172
 
1197
 
Línea 1173... Línea 1198...
1173
                $form->setData($data);
1198
                $form->setData($data);
Línea 1184... Línea 1209...
1184
                        ]);
1209
                        ]);
1185
                    }
1210
                    }
Línea 1186... Línea 1211...
1186
 
1211
 
Línea 1187... Línea 1212...
1187
                    if ($company->header) {
1212
                    if ($company->header) {
1188
 
1213
 
1189
                        if (!Image::delete($target_path, $company->header)) {
1214
                        if (!$image->getStorage()->deleteFile($target_path, $company->uuid, $company->header)) {
1190
                            return new JsonModel([
1215
                            return new JsonModel([
1191
                                'success'   => false,
1216
                                'success'   => false,
1192
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1217
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
Línea 1196... Línea 1221...
1196
 
1221
 
1197
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_header_pdf_size']);
1222
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_header_pdf_size']);
1198
                    $source             = $files['header']['tmp_name'];
1223
                    $source             = $files['header']['tmp_name'];
1199
                    $target_filename    = 'company-header-' . uniqid() . '.png';
1224
                    $target_filename    = 'company-header-' . uniqid() . '.png';
-
 
1225
                    $crop_to_dimensions = false;
1200
                    $crop_to_dimensions = false;
1226
                    $unlink_source = true;
1201
 
1227
                    
1202
                    if (!Image::uploadImage($source, $target_path, $target_filename, $target_width, $target_height, $crop_to_dimensions)) {
1228
                    if($image->uploadImageChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
1203
                        return new JsonModel([
1229
                        return new JsonModel([
1204
                            'success'   => false,
1230
                            'success'   => false,
1205
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1231
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1206
                        ]);
1232
                        ]);
Línea 1228... Línea 1254...
1228
                        'success'   => false,
1254
                        'success'   => false,
1229
                        'data'   => $messages
1255
                        'data'   => $messages
1230
                    ]);
1256
                    ]);
1231
                }
1257
                }
1232
            }
1258
            }
-
 
1259
            
-
 
1260
            $storage = Storage::getInstance($this->config);
-
 
1261
            $path = $storage->getPathCompany();
-
 
1262
            
1233
            return new JsonModel([
1263
            return new JsonModel([
1234
                'success'   => true,
1264
                'success'   => true,
1235
                'data' => $this->url()->fromRoute('storage', ['type' => 'company', 'code' => $company->uuid, 'filename' => $company->header])
1265
                'data' => $company->header ? $storage->getGenericImage($path, $company->uuid, $company->header) : '',
Línea 1236... Línea 1266...
1236
 
1266
 
1237
            ]);
1267
            ]);
Línea 1268... Línea 1298...
1268
        if ($request->isPost()) {
1298
        if ($request->isPost()) {
Línea 1269... Línea 1299...
1269
 
1299
 
1270
            $companyMapper = CompanyMapper::getInstance($this->adapter);
1300
            $companyMapper = CompanyMapper::getInstance($this->adapter);
Línea -... Línea 1301...
-
 
1301
            $company = $companyMapper->fetchOne($currentCompany->id);
1271
            $company = $companyMapper->fetchOne($currentCompany->id);
1302
 
Línea 1272... Línea 1303...
1272
 
1303
            $image = Image::getInstance($this->config);
1273
            $target_path = $this->config['leaderslinked.fullpath.company'] . DIRECTORY_SEPARATOR . $company->uuid;
1304
            $target_path = $image->getStorage()->getPathCompany();
Línea 1274... Línea 1305...
1274
 
1305
 
1275
 
1306
 
1276
 
1307
 
1277
            if ($operation == 'delete') {
1308
            if ($operation == 'delete') {
1278
                if ($company->footer) {
1309
                if ($company->footer) {
1279
 
1310
 
Línea 1292... Línea 1323...
1292
                        'success'   => false,
1323
                        'success'   => false,
1293
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1324
                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1294
                    ]);
1325
                    ]);
1295
                }
1326
                }
1296
            } else {
1327
            } else {
1297
                $form = new CompanyProfileFooterForm($this->config);
1328
                $form = new ProfileFooterForm($this->config);
1298
                $data   = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
1329
                $data   = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
Línea 1299... Línea 1330...
1299
 
1330
 
Línea 1300... Línea 1331...
1300
                $form->setData($data);
1331
                $form->setData($data);
Línea 1311... Línea 1342...
1311
                        ]);
1342
                        ]);
1312
                    }
1343
                    }
Línea 1313... Línea 1344...
1313
 
1344
 
Línea 1314... Línea 1345...
1314
                    if ($company->footer) {
1345
                    if ($company->footer) {
1315
 
1346
 
1316
                        if (!Image::delete($target_path, $company->footer)) {
1347
                        if (!$image->getStorage()->deleteFile($target_path, $company->uuid, $company->footer)) {
1317
                            return new JsonModel([
1348
                            return new JsonModel([
1318
                                'success'   => false,
1349
                                'success'   => false,
1319
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1350
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
Línea 1323... Línea 1354...
1323
 
1354
 
1324
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_footer_pdf_size']);
1355
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.company_footer_pdf_size']);
1325
                    $source             = $files['footer']['tmp_name'];
1356
                    $source             = $files['footer']['tmp_name'];
1326
                    $target_filename    = 'company-footer-' . uniqid() . '.png';
1357
                    $target_filename    = 'company-footer-' . uniqid() . '.png';
-
 
1358
                    $crop_to_dimensions = false;
1327
                    $crop_to_dimensions = false;
1359
                    $unlink_source = true;
1328
 
1360
                    
1329
                    if (!Image::uploadImage($source, $target_path, $target_filename, $target_width, $target_height, $crop_to_dimensions)) {
1361
                    if($image->uploadImageChangeSize($source, $target_path, $company->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) { 
1330
                        return new JsonModel([
1362
                        return new JsonModel([
1331
                            'success'   => false,
1363
                            'success'   => false,
1332
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1364
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1333
                        ]);
1365
                        ]);
Línea 1357... Línea 1389...
1357
                        'success'   => false,
1389
                        'success'   => false,
1358
                        'data'   => $messages
1390
                        'data'   => $messages
1359
                    ]);
1391
                    ]);
1360
                }
1392
                }
1361
            }
1393
            }
-
 
1394
            
-
 
1395
            $storage = Storage::getInstance($this->config);
-
 
1396
            $path = $storage->getPathCompany();
-
 
1397
            
1362
            return new JsonModel([
1398
            return new JsonModel([
1363
                'success'   => true,
1399
                'success'   => true,
1364
                'data' => $this->url()->fromRoute('storage', ['type' => 'company', 'code' => $company->uuid, 'filename' => $company->footer])
1400
                'data' => $company->footer ? $storage->getGenericImage($path, $company->uuid, $company->footer) : '',
Línea 1365... Línea 1401...
1365
 
1401
 
1366
            ]);
1402
            ]);
Línea 1422... Línea 1458...
1422
            return new JsonModel($data);
1458
            return new JsonModel($data);
1423
        } else if ($request->isPost()) {
1459
        } else if ($request->isPost()) {
Línea 1424... Línea 1460...
1424
 
1460
 
1425
 
1461
 
Línea 1426... Línea 1462...
1426
            
1462
            
Línea 1427... Línea 1463...
1427
            $form = new CompanyProfileIndustryForm($this->adapter);
1463
            $form = new ProfileIndustryForm($this->adapter);
Línea 1518... Línea 1554...
1518
 
1554
 
1519
            return new JsonModel($data);
1555
            return new JsonModel($data);
Línea 1520... Línea 1556...
1520
        } else if ($request->isPost()) {
1556
        } else if ($request->isPost()) {
1521
 
1557
 
Línea 1522... Línea 1558...
1522
 
1558
 
Línea 1523... Línea 1559...
1523
            $form = new CompanyProfileCompanySizeForm($this->adapter);
1559
            $form = new ProfileCompanySizeForm($this->adapter);