Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 8522 | Rev 8524 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
 
3
use LeadersLinked\Model\UserExperience;
4
 
5
$acl = $this->viewModel()
6
    ->getRoot()
7
    ->getVariable('acl');
8
$currentUserHelper = $this->currentUserHelper();
9
$currentUser = $currentUserHelper->getUser();
10
$currentCompany = $currentUserHelper->getCompany();
5761 stevensc 11
$companyId = $currentCompany->uuid;
1 www 12
 
13
$roleName = $currentUserHelper->getUserTypeId();
14
 
5743 stevensc 15
$routeWebsite = $this->url('profile/website', ['id' => $currentCompany->uuid]);
16
$routeCompanySize = $this->url('profile/company-size', ['id' => $currentCompany->uuid]);
17
$routeIndustry = $this->url('profile/industry', ['id' => $currentCompany->uuid]);
18
$routeExtended = $this->url('profile/extended', ['id' => $currentCompany->uuid]);
19
$routeSocialNetworks = $this->url('profile/social-network', ['id' => $currentCompany->uuid]);
20
$routeLocationAdd = $this->url('profile/location', ['id' => $currentCompany->uuid, 'operation' => 'add']);
21
$routeFoundationYear = $this->url('profile/foundation_year', ['id' => $currentCompany->uuid, 'operation' => 'add']);
22
$routeImageUpload = $this->url('profile/image', ['id' => $currentCompany->uuid, 'operation' => 'upload']);
23
$routeCoverUpload = $this->url('profile/cover', ['id' => $currentCompany->uuid, 'operation' => 'upload']);
24
$routeFooterUpload = $this->url('profile/footer', ['id' => $currentCompany->uuid, 'operation' => 'upload']);
25
$routeHeaderUpload = $this->url('profile/header', ['id' => $currentCompany->uuid, 'operation' => 'upload']);
1 www 26
 
8523 stevensc 27
 
28
$this->inlineScript()->appendFile('https://maps.googleapis.com/maps/api/js?key=' . $google_map_key . '&libraries=places');
29
 
1 www 30
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
32
 
8064 stevensc 33
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
34
 
8523 stevensc 35
 
8064 stevensc 36
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.css'));
38
 
39
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));
40
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));
41
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));
42
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fas/theme.js'));
44
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.js'));
45
 
8523 stevensc 46
 
1 www 47
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
48
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
49
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
50
 
8523 stevensc 51
 
52
 
1 www 53
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
54
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
55
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.min.js'));
56
 
8523 stevensc 57
 
58
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.min.js'));
59
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
60
 
61
 
1 www 62
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
63
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
64
 
8064 stevensc 65
 
8523 stevensc 66
 
67
 
68
 
69
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
70
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
71
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
72
 
1 www 73
$this->inlineScript()->captureStart();
74
echo <<<JS
75
jQuery( document ).ready(function( $ ) {
76
 
8523 stevensc 77
 
78
 
8064 stevensc 79
    $.validator.addMethod('greaterThan', function (value, element, param) {
80
        var otherElement = $(param);
81
        return parseInt(value, 10) > parseInt(otherElement.val(), 10);
82
    }, 'ERROR_INVALID_MINIMUM');
8523 stevensc 83
 
84
 
85
    $.validator.addMethod('checkLocation', function (value, element, param) {
86
        var otherElement = $(param);
87
        return $.trim(otherElement.val()).length > 0;
88
    }, 'ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY');
89
 
90
    var autocompleteLocation = new google.maps.places.Autocomplete(
91
        (document.getElementById('location_search')),
92
        {types: ['(cities)']}
93
    );
94
 
95
 
96
 
97
 
98
 
99
    $.fn.fillInAddressLocation = function() {
100
        console.log('fillInAddressLocation');
101
 
102
        var place = autocompleteLocation.getPlace();
103
        if (!place.geometry) {
104
            $.fn.showError('ERROR_PLACED_AUTOCOMPLETE_DOES_NOT_CONTAIN_GEOMETRY')
105
            return;
106
        } else {
107
        address1 = '';
108
        address2 = '';
109
        city1 = '';
110
        city2 = '';
111
        state = '';
112
        country = '';
113
        postal_code = '';
114
 
115
        formatted_address = place.formatted_address;
116
        latitude = place.geometry.location.lat();
117
        longitude = place.geometry.location.lng();
118
        var arrAddress = place.address_components;
119
 
120
        $.each(arrAddress, function(i, address_component) {
121
            if (address_component.types[0] == "route") {
122
                address1 = address_component.long_name;
123
            }
124
            if (address_component.types[0] == "sublocality") {
125
                address2 = address_component.long_name;
126
            }
127
            if (address_component.types[0] == "locality") {
128
                city1 = address_component.long_name;
129
            }
130
            if (address_component.types[0] == "administrative_area_level_2") {
131
                city2 = address_component.long_name;
132
            }
133
            if (address_component.types[0] == "administrative_area_level_1") {
134
                state = address_component.long_name;
135
            }
136
            if (address_component.types[0] == "country") {
137
                country = address_component.long_name;
138
            }
139
            if (address_component.types[0] == "postal_code") {
140
                postal_code = address_component.long_name;
141
            }
142
        });
143
 
144
        $('#form-location #formatted_address').val(formatted_address);
145
        $('#form-location #address1').val(address1);
146
        $('#form-location #address2').val(address2);
147
        $('#form-location #city1').val(city1);
148
        $('#form-location #city2').val(city2);
149
        $('#form-location #state').val(state);
150
        $('#form-location #country').val(country);
151
        $('#form-location #postal_code').val(postal_code);
152
        $('#form-location #latitude').val(latitude);
153
        $('#form-location #longitude').val(longitude);
154
 
155
        }
156
    }
157
    $.fn.renderLocation = function(data) {
158
        $('#locations-records').empty();
159
        if(Array.isArray(data)) {
160
            max = data.length;
161
            for(i = 0; i < max; i++)
162
            {
163
                var location = data[i];
164
                s = '<p>' + location['formatted_address'];
165
                if(location['is_main'] == 'y') {
166
                    s = s + ' (LABEL_MAIN_LOCATION) ';
167
                }
168
                s = s + ' <a href="#" title="" data-link="' + location['link_edit'] + '" class="btn-location-edit"><i class="fa fa-pencil"></i></a>&nbsp; ';
169
                s = s + ' <a href="#" title="" data-link="' + location['link_delete'] + '" class="btn-location-delete"><i class="fa fa-trash"></i></a>';
170
                s = s + ' </p>';
171
 
172
                if(i < (max - 1)) {
173
                    s = s + '<hr/>';
174
                }
175
                $('#locations-records').append(s);
176
            }
177
        }
178
    }
179
 
180
 
8064 stevensc 181
 
182
            $.validator.setDefaults({
183
            debug: true,
184
            highlight: function(element) {
185
                $(element).addClass('is-invalid');
186
            },
187
            unhighlight: function(element) {
188
                $(element).removeClass('is-invalid');
189
            },
190
            errorElement: 'span',
191
            errorClass: 'error invalid-feedback',
192
            errorPlacement: function(error, element) {
193
                if(element.parent('.form-group').length) {
194
                    error.insertAfter(element);
195
                } else if(element.parent('.toggle').length) {
196
                    error.insertAfter(element.parent().parent());
197
                } else {
198
                    error.insertAfter(element.parent());
199
                }
200
            }
201
        });
202
 
203
 
204
        $.fn.showFormErrorValidator = function(fieldname, errors) {
205
            var field = $(fieldname);
206
            if(field) {
207
                $(field).addClass('is-invalid');
208
 
209
 
210
                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
211
                if(field.parent('.form-group').length) {
212
                    error.insertAfter(field);
213
                } else  if(field.parent('.toggle').length) {
214
                    error.insertAfter(field.parent().parent());
215
                } else {
216
                    error.insertAfter(field.parent());
217
                }
218
            }
219
        };
8523 stevensc 220
 
8064 stevensc 221
 
8523 stevensc 222
 
223
 
224
    var validatorLocation = $('#form-location').validate({
225
        debug: true,
226
        onclick: false,
227
        onkeyup: false,
228
        onfocusout: false,
229
        ignore: [],
230
        rules: {
231
            'location_search': {
232
                required: true,
233
                checkLocation: '#form-location #latitude'
234
            }
235
        },
236
        submitHandler: function(form)
237
        {
238
            NProgress.start();
239
            $.ajax({
240
                'dataType'  : 'json',
241
                'accept'    : 'application/json',
242
                'method'    : 'post',
243
                'url'       :  $('#form-location').attr('action'),
244
                'data'      :  $('#form-location').serialize(),
245
            }).done(function(response) {
246
                if(response['success']) {
247
                    $.fn.renderLocation(response['data']);
248
 
249
                    $("#location-box").modal('hide');
250
                } else {
251
                    validatorLocation.resetForm();
252
                    $.fn.showError(response['data']);
253
                }
254
            }).fail(function( jqXHR, textStatus, errorThrown) {
255
                $.fn.showError(textStatus);
256
            }).always(function() {
257
                NProgress.done();
258
            });
259
            return false;
260
        },
261
        invalidHandler: function(form, validator) {
262
 
263
        }
264
    });
265
 
266
    $('.btn-location-add').on("click", function(e){
267
        e.preventDefault();
268
 
269
        $('#form-location').attr('action', '$routeLocationAdd');
270
        $('#form-location #location_search').val('');
271
        $('#form-location #formatted_address').val('');
272
        $('#form-location #address1').val('');
273
        $('#form-location #address2').val('');
274
        $('#form-location #country').val('');
275
        $('#form-location #state').val('');
276
        $('#form-location #city1').val('');
277
        $('#form-location #city2').val('');
278
        $('#form-location #postal_code').val('');
279
        $('#form-location #latitude').val('');
280
        $('#form-location #longitude').val('');
281
        validatorLocation.resetForm();
282
 
283
        $("#location-box").modal('show');
284
    });
285
 
286
    $('body').on('click', 'a.btn-location-edit', function(e) {
287
        e.preventDefault();
288
 
289
        var url = $(this).data('link');
290
 
291
        NProgress.start();
292
        $.ajax({
293
            'dataType'  : 'json',
294
            'accept'    : 'application/json',
295
            'method'    : 'get',
296
            'url'       : url,
297
        }).done(function(response) {
298
           if(response['success']) {
299
                $('#form-location').attr('action', url);
300
                $('#form-location #location_search').val(response['data']['formatted_address']);
301
                $('#form-location #formatted_address').val(response['data']['formatted_address']);
302
                $('#form-location #address1').val(response['data']['address1']);
303
                $('#form-location #address2').val(response['data']['address2']);
304
                $('#form-location #country').val(response['data']['country']);
305
                $('#form-location #state').val(response['data']['state']);
306
                $('#form-location #city1').val(response['data']['city1']);
307
                $('#form-location #city2').val(response['data']['city2']);
308
                $('#form-location #postal_code').val(response['data']['postal_code']);
309
                $('#form-location #latitude').val(response['data']['latitude']);
310
                $('#form-location #longitude').val(response['data']['longitude']);
311
 
312
                if(response['data']['is_main'] == 'y') {
313
                    $('#form-location #is_main').bootstrapToggle('on')
314
                } else {
315
                    $('#form-location #is_main').bootstrapToggle('off')
316
                }
317
 
318
                validatorLocation.resetForm();
319
 
320
                $("#location-box").modal('show');
321
            } else {
322
                $.fn.showError(response['data']);
323
            }
324
        }).fail(function( jqXHR, textStatus, errorThrown) {
325
            $.fn.showError(textStatus);
326
        }).always(function() {
327
            NProgress.done();
328
        });
329
        return false;
330
 
331
 
332
    });
333
 
334
    $('body').on('click', 'a.btn-location-delete', function(e) {
335
        e.preventDefault();
336
 
337
        var url = $(this).data('link');
338
 
339
        NProgress.start();
340
        $.ajax({
341
            'dataType'  : 'json',
342
            'accept'    : 'application/json',
343
            'method'    : 'post',
344
            'url'       : url,
345
        }).done(function(response) {
346
           if(response['success']) {
347
                $.fn.renderLocation(response['data']);
348
            } else {
349
                $.fn.showError(response['data']);
350
            }
351
        }).fail(function( jqXHR, textStatus, errorThrown) {
352
            $.fn.showError(textStatus);
353
        }).always(function() {
354
            NProgress.done();
355
        });
356
        return false;
357
 
358
 
359
    });
360
 
361
 
362
    $('.btn-location-close').on("click", function(e){
363
        e.preventDefault();
364
 
365
        $("#location-box").modal('hide');
366
        return false;
367
    });
368
 
369
    var validatorSocialNetwork = $('#form-social-network').validate({
370
        debug: true,
371
        onclick: false,
372
        onkeyup: false,
373
        ignore: [],
374
        rules: {
375
            'facebook': {
376
                required: false,
377
                maxlength: 250,
378
                url: true,
379
            },
380
            'twitter': {
381
                required: false,
382
                maxlength: 250,
383
                url: true,
384
            },
385
            'instagram': {
386
                required: false,
387
                maxlength: 250,
388
                url: true,
389
            },
390
        },
391
 
392
        submitHandler: function(form)
393
        {
394
            NProgress.start();
395
            $.ajax({
396
                'dataType'  : 'json',
397
                'accept'    : 'application/json',
398
                'method'    : 'post',
399
                'url'       :  $('#form-social-network').attr('action'),
400
                'data'      :  $('#form-social-network').serialize()
401
            }).done(function(response) {
402
                if(response['success']) {
403
 
404
					$('#social-networks').empty();
405
                    var s = $.trim(response['data']['facebook']);
406
                    if(s.length > 32) {
407
                        s = s.substring(0, 31) + '...'
408
                    }
409
                    $('#social-networks').append('<li><a href="' + response['data']['facebook'] + '" target="_blank" title="">' +
410
                        '<i class="fa fa-facebook-square"></i> ' + s + '</a></li>');
411
 
412
                    var s = $.trim(response['data']['twitter']);
413
                    if(s.length > 32) {
414
                        s = s.substring(0, 31) + '...'
415
                    }
416
                    $('#social-networks').append('<li><a href="' + response['data']['twitter'] + '" target="_blank" title="">' +
417
                        '<i class="fa fa-twitter"></i> ' + s + '</a></li>');
418
 
419
                    var s = $.trim(response['data']['instagram']);
420
                    if(s.length > 32) {
421
                        s = s.substring(0, 31) + '...'
422
                    }
423
                    $('#social-networks').append('<li><a href="' + response['data']['instagram'] + '" target="_blank" title="">' +
424
                        '<i class="fa fa-instagram"></i> ' + s + '</a></li>');
425
 
426
                    $("#social-networks-box").modal('hide');
427
                } else {
428
                    validatorSocialNetwork.resetForm();
429
                    if(jQuery.type(response['data']) == 'string') {
430
                        $.fn.showError(response['data']);
431
                    } else  {
432
                        $.each(response['data'], function( fieldname, errors ) {
433
                            $.fn.showFormErrorValidator('#form-social-network #' + fieldname, errors);
434
                        });
435
                    }
436
                }
437
            }).fail(function( jqXHR, textStatus, errorThrown) {
438
                $.fn.showError(textStatus);
439
            }).always(function() {
440
                NProgress.done();
441
            });
442
            return false;
443
        },
444
        invalidHandler: function(form, validator) {
445
 
446
        }
447
    });
448
 
449
 
450
 
451
    $('.btn-social-network-edit').on("click", function(e){
452
        e.preventDefault();
453
 
454
        NProgress.start();
455
        $.ajax({
456
            'dataType'  : 'json',
457
            'accept'    : 'application/json',
458
            'method'    : 'get',
459
            'url'       : '$routeSocialNetworks',
460
        }).done(function(response) {
461
           if(response['success']) {
462
                $('#form-social-network #facebook').val(response['data']['facebook']);
463
                $('#form-social-network #twitter').val(response['data']['twitter']);
464
                $('#form-social-network #instagram').val(response['data']['instagram']);
465
                validatorSocialNetwork.resetForm();
466
 
467
                $("#social-networks-box").modal('show');
468
            } else {
469
                $.fn.showError(response['data']);
470
            }
471
        }).fail(function( jqXHR, textStatus, errorThrown) {
472
            $.fn.showError(textStatus);
473
        }).always(function() {
474
            NProgress.done();
475
        });
476
        return false;
477
 
478
    });
479
 
480
    $('.btn-social-network-close').on("click", function(e){
481
        e.preventDefault();
482
 
483
        $("#social-networks-box").modal('hide');
484
        return false;
485
    });
486
 
487
 
8064 stevensc 488
    var validatorExtended = $('#form-extended').validate({
489
        debug: true,
490
        onclick: false,
491
        onkeyup: false,
492
        onfocusout: false,
493
        ignore: [],
494
        rules: {
495
            'description': {
496
                updateCkeditor:function() {
497
                        CKEDITOR.instances.description.updateElement();
498
                },
499
                required: false,
500
            },
501
        },
6486 stevensc 502
 
8064 stevensc 503
        submitHandler: function(form)
504
        {
505
            NProgress.start();
506
            $.ajax({
507
                'dataType'  : 'json',
508
                'accept'    : 'application/json',
509
                'method'    : 'post',
510
                'url'       :  $('#form-extended').attr('action'),
511
                'data'      :  $('#form-extended').serialize()
512
            }).done(function(response) {
513
                if(response['success']) {
514
 
515
                    $('#overview-description').html(response['data']['description']);
516
                    $("#extended-box").modal('hide');
517
                } else {
518
                    validatorExtended.resetForm();
519
                    if(jQuery.type(response['data']) == 'string') {
520
                        $.fn.showError(response['data']);
521
                    } else  {
522
                        $.each(response['data'], function( fieldname, errors ) {
523
                            $.fn.showFormErrorValidator('#form-extended #' + fieldname, errors);
524
                        });
525
                    }
526
                }
527
            }).fail(function( jqXHR, textStatus, errorThrown) {
528
                $.fn.showError(textStatus);
529
            }).always(function() {
530
                NProgress.done();
531
            });
532
            return false;
533
        },
534
        invalidHandler: function(form, validator) {
535
 
536
        }
537
    });
538
 
539
 
540
    $('.btn-extended-edit').on("click", function(e){
541
        e.preventDefault();
542
 
543
        NProgress.start();
544
        $.ajax({
545
            'dataType'  : 'json',
546
            'accept'    : 'application/json',
547
            'method'    : 'get',
548
            'url'       : '$routeExtended',
549
        }).done(function(response) {
550
           if(response['success']) {
551
                CKEDITOR.instances.description.setData(response['data']['description']);
552
                validatorExtended.resetForm();
553
 
554
                $("#extended-box").modal('show');
555
            } else {
556
                $.fn.showError(response['data']);
557
            }
558
        }).fail(function( jqXHR, textStatus, errorThrown) {
559
            $.fn.showError(textStatus);
560
        }).always(function() {
561
            NProgress.done();
562
        });
563
        return false;
564
 
565
    });
566
 
567
    $('.btn-extended-close').on("click", function(e){
568
        e.preventDefault();
569
 
570
        $("#extended-box").modal('hide');
571
        return false;
572
    });
8523 stevensc 573
 
574
	var validatorIndustry = $('#form-industry').validate({
575
        debug: true,
576
        onclick: false,
577
        onkeyup: false,
578
        onfocusout: false,
579
        ignore: [],
580
        rules: {
581
            'industry_id': {
582
                required: true,
583
            },
584
        },
585
 
586
        submitHandler: function(form)
587
        {
588
            NProgress.start();
589
            $.ajax({
590
                'dataType'  : 'json',
591
                'accept'    : 'application/json',
592
                'method'    : 'post',
593
                'url'       :  $('#form-industry').attr('action'),
594
                'data'      :  $('#form-industry').serialize()
595
            }).done(function(response) {
596
                if(response['success']) {
597
 
598
                    $('#overview-industry').html(response['data']);
599
                    $("#industry-box").modal('hide');
600
                } else {
601
                    validatorIndustry.resetForm();
602
                    if(jQuery.type(response['data']) == 'string') {
603
                        $.fn.showError(response['data']);
604
                    } else  {
605
                        $.each(response['data'], function( fieldname, errors ) {
606
                            $.fn.showFormErrorValidator('#form-industry #' + fieldname, errors);
607
                        });
608
                    }
609
                }
610
            }).fail(function( jqXHR, textStatus, errorThrown) {
611
                $.fn.showError(textStatus);
612
            }).always(function() {
613
                NProgress.done();
614
            });
615
            return false;
616
        },
617
        invalidHandler: function(form, validator) {
618
 
619
        }
620
    });
621
 
622
 
623
    $('.btn-industry-edit').on("click", function(e){
624
        e.preventDefault();
625
 
626
        NProgress.start();
627
        $.ajax({
628
            'dataType'  : 'json',
629
            'accept'    : 'application/json',
630
            'method'    : 'get',
631
            'url'       : '$routeIndustry',
632
        }).done(function(response) {
633
           if(response['success']) {
634
				$('#form-industry #industry_id').val(response['data']['industry_id']).trigger('change');
635
 
636
                validatorIndustry.resetForm();
637
 
638
                $("#industry-box").modal('show');
639
            } else {
640
                $.fn.showError(response['data']);
641
            }
642
        }).fail(function( jqXHR, textStatus, errorThrown) {
643
            $.fn.showError(textStatus);
644
        }).always(function() {
645
            NProgress.done();
646
        });
647
        return false;
648
 
649
    });
1 www 650
 
8523 stevensc 651
    $('.btn-industry-close').on("click", function(e){
652
        e.preventDefault();
653
 
654
        $("#industry-box").modal('hide');
655
        return false;
656
    });
657
 
658
 
659
 
660
 
661
    var validatorImage = $('#form-image').validate({
662
        debug: true,
663
        onclick: false,
664
        onkeyup: false,
665
        onfocusout: false,
666
        ignore: [],
667
        rules: {
668
           'image': {
669
                required: true,
670
                extension: 'jpg|jpeg|png',
671
                accept: 'image/jpeg,image/png'
672
            },
673
        },
674
 
675
        submitHandler: function(form)
676
        {
677
            var formdata = false;
678
            if (window.FormData){
679
                formdata = new FormData(form); //form[0]);
680
            }
681
 
682
            NProgress.start();
683
            $.ajax({
684
                'dataType'  : 'json',
685
                'accept'    : 'application/json',
686
                'method'    : 'post',
687
                'url'       :  $('#form-image').attr('action'),
688
                'data'      : formdata ? formdata : $('#form-image').serialize(),
689
                'processData': false,
690
                'contentType': false,
691
            }).done(function(response) {
692
                if(response['success']) {
693
				    $('#company-img').attr('src',response['data']);
694
                    $("#image-box").modal('hide');
695
                } else {
696
                    validatorImage.resetForm();
697
                    if(jQuery.type(response['data']) == 'string') {
698
                        $.fn.showError(response['data']);
699
                    } else  {
700
                        $.each(response['data'], function( fieldname, errors ) {
701
                            console.log('#form-image #' + fieldname);
702
 
703
                            $.fn.showFormErrorValidator('#form-image #' + fieldname, errors);
704
                        });
705
                    }
706
                }
707
            }).fail(function( jqXHR, textStatus, errorThrown) {
708
                $.fn.showError(textStatus);
709
            }).always(function() {
710
                NProgress.done();
711
            });
712
            return false;
713
        },
714
        invalidHandler: function(form, validator) {
715
 
716
        }
717
    });
718
 
719
    $('.btn-image-open').on("click", function(e){
720
        e.preventDefault();
721
        $('#form-image #image').fileinput('reset');
722
        $('#form-image #image').val('');
723
        validatorImage.resetForm();
724
        $("#image-box").modal('show');
725
        return false;
726
    });
727
 
728
    $('.btn-image-close').on("click", function(e){
729
        e.preventDefault();
730
 
731
        $("#image-box").modal('hide');
732
        return false;
733
    });
734
 
735
 
736
    var validatorCover = $('#form-header').validate({
737
        debug: true,
738
        onclick: false,
739
        onkeyup: false,
740
        onfocusout: false,
741
        ignore: [],
742
        rules: {
743
           'header': {
744
                required: true,
745
                extension: 'jpg|jpeg|png',
746
                accept: 'image/jpeg,image/png'
747
            },
748
        },
749
 
750
        submitHandler: function(form)
751
        {
752
            var formdata = false;
753
            if (window.FormData){
754
                formdata = new FormData(form); //form[0]);
755
            }
756
 
757
            NProgress.start();
758
            $.ajax({
759
                'dataType'  : 'json',
760
                'accept'    : 'application/json',
761
                'method'    : 'post',
762
                'url'       :  $('#form-header').attr('action'),
763
                'data'      : formdata ? formdata : $('#form-header').serialize(),
764
                'processData': false,
765
                'contentType': false,
766
            }).done(function(response) {
767
                if(response['success']) {
768
                    $('#user-header-img').attr('src',response['data']);
769
                    $("#image-header-box").modal('hide');
770
                    location.reload();
771
                } else {
772
                    validatorCover.resetForm();
773
                    if(jQuery.type(response['data']) == 'string') {
774
                        $.fn.showError(response['data']);
775
                    } else  {
776
                        $.each(response['data'], function( fieldname, errors ) {
777
                            $.fn.showFormErrorValidator('#form-header #' + fieldname, errors);
778
                        });
779
                    }
780
                }
781
            }).fail(function( jqXHR, textStatus, errorThrown) {
782
                $.fn.showError(textStatus);
783
            }).always(function() {
784
                NProgress.done();
785
            });
786
            return false;
787
        },
788
        invalidHandler: function(form, validator) {
789
 
790
        }
791
    });
792
 
793
    $('.btn-image-explorer').on("click", function(e){
794
        e.preventDefault();
795
        $('#form-image #image').click();
796
        return false;
797
    });
798
 
799
    var validatorCover = $('#form-cover').validate({
800
        debug: true,
801
        onclick: false,
802
        onkeyup: false,
803
        onfocusout: false,
804
        ignore: [],
805
        rules: {
806
           'cover': {
807
                required: true,
808
                extension: 'jpg|jpeg|png',
809
                accept: 'image/jpeg,image/png'
810
            },
811
        },
812
 
813
        submitHandler: function(form)
814
        {
815
            var formdata = false;
816
            if (window.FormData){
817
                formdata = new FormData(form); //form[0]);
818
            }
819
 
820
            NProgress.start();
821
            $.ajax({
822
                'dataType'  : 'json',
823
                'accept'    : 'application/json',
824
                'method'    : 'post',
825
                'url'       :  $('#form-cover').attr('action'),
826
                'data'      : formdata ? formdata : $('#form-cover').serialize(),
827
                'processData': false,
828
                'contentType': false,
829
            }).done(function(response) {
830
                if(response['success']) {
831
				    $('#user-cover-img').attr('src',response['data']);
832
                    $("#cover-box").modal('hide');
833
                } else {
834
                    validatorCover.resetForm();
835
                    if(jQuery.type(response['data']) == 'string') {
836
                        $.fn.showError(response['data']);
837
                    } else  {
838
                        $.each(response['data'], function( fieldname, errors ) {
839
                            $.fn.showFormErrorValidator('#form-cover #' + fieldname, errors);
840
                        });
841
                    }
842
                }
843
            }).fail(function( jqXHR, textStatus, errorThrown) {
844
                $.fn.showError(textStatus);
845
            }).always(function() {
846
                NProgress.done();
847
            });
848
            return false;
849
        },
850
        invalidHandler: function(form, validator) {
851
 
852
        }
853
    });
854
 
855
 
856
    $('.btn-cover-open').on("click", function(e){
857
        e.preventDefault();
858
        $('#form-cover #cover').fileinput('reset');
859
        $('#form-cover #cover').val('');
860
        validatorCover.resetForm();
861
        $("#cover-box").modal('show');
862
        return false;
863
    });
864
 
865
    $('.btn-cover-close').on("click", function(e){
866
        e.preventDefault();
867
 
868
        $("#cover-box").modal('hide');
869
        return false;
870
    });
871
 
872
    $('.btn-cover-explorer').on("click", function(e){
873
        e.preventDefault();
874
 
875
        $('#form-cover #cover').click();
876
        return false;
877
    });
878
 
879
    $("#form-cover #cover").fileinput({
880
        theme: 'fas',
881
        language: 'es',
882
        showUpload: false,
883
        dropZoneEnabled: false,
884
        maxFileCount: 1,
885
        allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif'],
886
        mainClass: "input-group",
887
        msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $image_size_cover',
888
    });
889
 
890
    $("#form-image #image").fileinput({
891
        theme: 'fas',
892
        language: 'es',
893
        showUpload: false,
894
        dropZoneEnabled: false,
895
        maxFileCount: 1,
896
        allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif'],
897
        mainClass: "input-group",
898
        msgPlaceholder: 'LABEL_RECOMMENDED_SIZE $image_size_profile',
899
    });
900
 
901
   $('#form-skill #skills').select2({
902
        theme: 'bootstrap4',
903
        width: '100%',
904
        placeholder: 'LABEL_SELECT_ONE_SKILLS'
905
    });
906
    $('#form-language #languages').select2({
907
        theme: 'bootstrap4',
908
        width: '100%',
909
        placeholder: 'LABEL_SELECT_ONE_LANGUAGE'
910
    });
911
 
912
 
8064 stevensc 913
    CKEDITOR.replace('description');
8523 stevensc 914
 
915
    autocompleteLocation.addListener('place_changed', $.fn.fillInAddressLocation);
916
 
917
    $('#form-location #is_main').bootstrapToggle({'on' : 'LABEL_MAIN_LOCATION',  'off' : 'LABEL_SECONDARY_LOCATION', 'width' : '160px', 'height' : '40px'});
8064 stevensc 918
 
1 www 919
});
920
 
8064 stevensc 921
 
1 www 922
JS;
923
$this->inlineScript()->captureEnd();
924
 
6005 stevensc 925
$jsonLocations = json_encode($locations);
8064 stevensc 926
 
5743 stevensc 927
$js = <<<JS
928
const urlVars = {
929
    routeWebsite: "$routeWebsite",
930
    routeCompanySize: "$routeCompanySize",
931
    routeIndustry: "$routeIndustry",
932
    routeExtended: "$routeExtended",
933
    routeSocialNetworks: "$routeSocialNetworks",
934
    routeLocationAdd: "$routeLocationAdd",
935
    routeFoundationYear: "$routeFoundationYear",
936
    routeImageUpload: "$routeImageUpload",
937
    routeCoverUpload: "$routeCoverUpload",
938
    routeFooterUpload: "$routeFooterUpload",
5757 stevensc 939
    routeHeaderUpload: "$routeHeaderUpload",
940
    cover: "$cover",
5795 stevensc 941
    companyId: "$companyId",
5925 stevensc 942
    followers: "$follower",
5988 stevensc 943
    image: "$image",
6002 stevensc 944
    overview: "$overview",
6025 stevensc 945
    locations: JSON.parse('$jsonLocations'),
6026 stevensc 946
    industry: "$industry",
6027 stevensc 947
    companySize: "$company_size",
6050 stevensc 948
    companyName: "$company_name",
949
    foundationYear: "$foundation_year",
6055 stevensc 950
    website: "$website",
6059 stevensc 951
    header: "$header",
8064 stevensc 952
    footer: "$footer"
5743 stevensc 953
}
954
JS;
955
 
956
$this->inlineScript()->appendScript($js);
6448 stevensc 957
$this->headLink()->appendStylesheet('/react-bundles/profile/main.css');
5743 stevensc 958
$this->inlineScript()->appendFile('/react-bundles/profile/profileBundle.js');
1 www 959
?>
960
 
777 geraldo 961
<style>
5743 stevensc 962
    .user-profile-ov {
963
        position: relative;
964
    }
777 geraldo 965
 
5743 stevensc 966
    .user-profile-ov .add-dp {
967
        position: absolute;
968
        top: 30%;
969
        right: 10%;
970
    }
779 geraldo 971
 
5743 stevensc 972
    .user-profile-ov .add-dp i {
973
        font-size: 14px;
974
        border: 2px solid #fff;
975
        background: #e44d3a;
976
        padding: 11px;
977
        color: #ffff
978
    }
777 geraldo 979
</style>
980
 
1 www 981
<!-- Content Header (Page header) -->
5743 stevensc 982
<div id="profile">
5800 stevensc 983
</div>
8064 stevensc 984
<div class="modal" tabindex="-1" role="dialog" id="extended-box">
985
    <div class="modal-dialog" role="document">
986
        <?php
987
        $form = $this->formExtended;
988
        $form->setAttributes([
989
            'method' => 'post',
990
            'action' => $routeExtended,
991
            'name' => 'form-extended',
992
            'id' => 'form-extended'
993
        ]);
994
        $form->prepare();
995
        echo $this->form()->openTag($form);
996
        ?>
997
        <div class="modal-content">
998
            <div class="modal-header">
999
                <h3 class="modal-title">LABEL_CHANGE</h3>
1000
            </div>
1001
            <div class="modal-body">
1002
                <div class="form-group">
1003
                    <?php
1004
                    $element = $form->get('description');
1005
                    $element->setAttributes(['class' => 'form-control']);
1006
                    $element->setOptions(['label' => 'LABEL_OVERVIEW']);
1007
                    echo $this->formLabel($element);
1008
                    echo $this->formTextArea($element);
1009
                    ?>
1010
                </div>
1011
            </div>
1012
            <div class="modal-footer">
1013
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1014
                <button type="button" class="btn btn-default btn-extended-close">LABEL_CANCEL</button>
1015
            </div>
1016
            <?php echo $this->form()->closeTag($form); ?>
1017
        </div>
1018
    </div>
8523 stevensc 1019
</div>
1020
<div class="modal" tabindex="-1" role="dialog" id="foundation-year-box">
1021
    <div class="modal-dialog" role="document">
1022
        <?php
1023
        $form = $this->formFoundationYear;
1024
        $form->setAttributes([
1025
            'method' => 'post',
1026
            'action' => $routeFoundationYear,
1027
            'name' => 'form-foundation-year',
1028
            'id' => 'form-foundation-year'
1029
        ]);
1030
        $form->prepare();
1031
        echo $this->form()->openTag($form);
1032
        ?>
1033
        <div class="modal-content">
1034
            <div class="modal-header">
1035
                <h3 class="modal-title">LABEL_CHANGE</h3>
1036
            </div>
1037
            <div class="modal-body">
1038
                <div class="form-group">
1039
                    <?php
1040
                    $element = $form->get('foundation_year');
1041
                    $element->setAttributes(['class' => 'form-control']);
1042
                    $element->setOptions(['label' => 'LABEL_FOUNDATION_YEAR']);
1043
                    echo $this->formLabel($element);
1044
                    echo $this->formText($element);
1045
                    ?>
1046
                </div>
1047
            </div>
1048
            <div class="modal-footer">
1049
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1050
                <button type="button" class="btn btn-default btn-fondation-year-close">LABEL_CANCEL</button>
1051
            </div>
1052
            <?php echo $this->form()->closeTag($form); ?>
1053
        </div>
1054
    </div>
1055
</div>
1056
<div class="modal" tabindex="-1" role="dialog" id="industry-box">
1057
    <div class="modal-dialog" role="document">
1058
        <?php
1059
        $form = $this->formIndustry;
1060
        $form->setAttributes([
1061
            'method' => 'post',
1062
            'action' => $routeIndustry,
1063
            'name' => 'form-industry',
1064
            'id' => 'form-industry'
1065
        ]);
1066
        $form->prepare();
1067
        echo $this->form()->openTag($form);
1068
        ?>
1069
        <div class="modal-content">
1070
            <div class="modal-header">
1071
                <h3 class="modal-title">LABEL_CHANGE</h3>
1072
            </div>
1073
            <div class="modal-body">
1074
                <div class="form-group">
1075
                    <?php
1076
                    $element = $form->get('industry_id');
1077
                    $element->setAttributes(['class' => 'form-control']);
1078
                    $element->setOptions(['label' => 'LABEL_INDUSTRY']);
1079
                    echo $this->formLabel($element);
1080
                    echo $this->formSelect($element);
1081
                    ?>
1082
                </div>
1083
            </div>
1084
            <div class="modal-footer">
1085
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1086
                <button type="button" class="btn btn-default btn-industry-close">LABEL_CANCEL</button>
1087
            </div>
1088
            <?php echo $this->form()->closeTag($form); ?>
1089
        </div>
1090
    </div>
1091
</div>
1092
<div class="modal" tabindex="-1" role="dialog" id="company-size-box">
1093
    <div class="modal-dialog" role="document">
1094
        <?php
1095
        $form = $this->formCompanySize;
1096
        $form->setAttributes([
1097
            'method' => 'post',
1098
            'action' => $routeCompanySize,
1099
            'name' => 'form-company-size',
1100
            'id' => 'form-company-size'
1101
        ]);
1102
        $form->prepare();
1103
        echo $this->form()->openTag($form);
1104
        ?>
1105
        <div class="modal-content">
1106
            <div class="modal-header">
1107
                <h3 class="modal-title">LABEL_CHANGE</h3>
1108
            </div>
1109
            <div class="modal-body">
1110
                <div class="form-group">
1111
                    <?php
1112
                    $element = $form->get('company_size_id');
1113
                    $element->setAttributes(['class' => 'form-control']);
1114
                    $element->setOptions(['label' => 'LABEL_COMPANY_SIZE']);
1115
                    echo $this->formLabel($element);
1116
                    echo $this->formSelect($element);
1117
                    ?>
1118
                </div>
1119
            </div>
1120
            <div class="modal-footer">
1121
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1122
                <button type="button" class="btn btn-default btn-company-size-close">LABEL_CANCEL</button>
1123
            </div>
1124
            <?php echo $this->form()->closeTag($form); ?>
1125
        </div>
1126
    </div>
1127
</div>
1128
<div class="modal" tabindex="-1" role="dialog" id="location-box">
1129
    <div class="modal-dialog" role="document">
1130
        <?php
1131
        $form = $this->formLocation;
1132
        $form->setAttributes([
1133
            'method' => 'post',
1134
            'action' => '',
1135
            'name' => 'form-location',
1136
            'id' => 'form-location'
1137
        ]);
1138
        $form->prepare();
1139
        echo $this->form()->openTag($form);
1140
 
1141
        $fieldnames = [
1142
            'formatted_address',
1143
            'address1',
1144
            'address2',
1145
            'country',
1146
            'state',
1147
            'city1',
1148
            'city2',
1149
            'postal_code',
1150
            'latitude',
1151
            'longitude',
1152
        ];
1153
 
1154
        foreach ($fieldnames as $fieldname) {
1155
 
1156
            $element = $form->get($fieldname);
1157
            echo $this->formHidden($element);
1158
        }
1159
        ?>
1160
        <div class="modal-content">
1161
            <div class="modal-header">
1162
                <h3 class="modal-title">LABEL_CHANGE</h3>
1163
            </div>
1164
            <div class="modal-body">
1165
                <div class="form-group datefm">
1166
                    <?php
1167
                    $element = $form->get('location_search');
1168
                    $element->setAttributes(['class' => 'form-control']);
1169
                    $element->setOptions(['label' => 'LABEL_LOCATION']);
1170
                    echo $this->formLabel($element);
1171
                    echo $this->formText($element);
1172
                    ?>
1173
                    <i class="fa fa-map-marker"></i>
1174
                </div>
1175
                <div class="form-group">
1176
                    <?php
1177
                    $element = $form->get('is_main');
1178
                    echo $this->formCheckbox($element);
1179
                    ?>
1180
                </div>
1181
            </div>
1182
            <div class="modal-footer">
1183
                <button type="submit" class="btn btn-primary ">LABEL_SAVE</button>
1184
                <button type="button" class="btn btn-default btn-location-close">LABEL_CANCEL</button>
1185
            </div>
1186
            <?php echo $this->form()->closeTag($form); ?>
1187
        </div>
1188
    </div>
1189
</div>
1190
<div class="modal" tabindex="-1" role="dialog" id="social-networks-box">
1191
    <div class="modal-dialog" role="document">
1192
        <?php
1193
        $form = $this->formSocialNetwork;
1194
        $form->setAttributes([
1195
            'method' => 'post',
1196
            'action' => $routeSocialNetworks,
1197
            'name' => 'form-social-network',
1198
            'id' => 'form-social-network'
1199
        ]);
1200
        $form->prepare();
1201
        echo $this->form()->openTag($form);
1202
        ?>
1203
        <div class="modal-content">
1204
            <div class="modal-header">
1205
                <h3 class="modal-title">LABEL_CHANGE</h3>
1206
            </div>
1207
            <div class="modal-body">
1208
                <div class="form-group">
1209
                    <?php
1210
                    $element = $form->get('facebook');
1211
                    $element->setAttributes(['class' => 'form-control']);
1212
                    $element->setOptions(['label' => 'LABEL_FACEBOOK']);
1213
                    echo $this->formLabel($element);
1214
                    echo $this->formText($element);
1215
                    ?>
1216
                </div>
1217
                <div class="form-group">
1218
                    <?php
1219
                    $element = $form->get('twitter');
1220
                    $element->setAttributes(['class' => 'form-control']);
1221
                    $element->setOptions(['label' => 'LABEL_TWITTER']);
1222
                    echo $this->formLabel($element);
1223
                    echo $this->formText($element);
1224
                    ?>
1225
                </div>
1226
                <div class="form-group">
1227
                    <?php
1228
                    $element = $form->get('instagram');
1229
                    $element->setAttributes(['class' => 'form-control']);
1230
                    $element->setOptions(['label' => 'LABEL_INSTAGRAM']);
1231
                    echo $this->formLabel($element);
1232
                    echo $this->formText($element);
1233
                    ?>
1234
                </div>
1235
                <div class="form-group">
1236
                </div>
1237
                <div class="modal-footer">
1238
                    <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1239
                    <button type="button" class="btn btn-default btn-social-network-close">LABEL_CANCEL</button>
1240
                </div>
1241
            </div>
1242
            <?php echo $this->form()->closeTag($form); ?>
1243
        </div>
1244
    </div>
1245
</div>
1246
<div class="modal" tabindex="-1" role="dialog" id="image-box">
1247
    <div class="modal-dialog" role="document">
1248
        <?php
1249
        $form = $this->formImage;
1250
        $form->setAttributes([
1251
            'method' => 'post',
1252
            'action' => $routeImageUpload,
1253
            'name' => 'form-image',
1254
            'id' => 'form-image',
1255
            'enctype' => 'multipart/form-data'
1256
        ]);
1257
        $form->prepare();
1258
        echo $this->form()->openTag($form);
1259
        ?>
1260
        <div class="modal-content">
1261
            <div class="modal-header">
1262
                <h3 class="modal-title">LABEL_CHANGE</h3>
1263
            </div>
1264
            <div class="modal-body">
1265
                <div class="form-group">
1266
                    <div class="file-loading">
1267
                        <?php
1268
                        $element = $form->get('image');
1269
                        $element->setAttributes(['class' => 'form-control', 'accept' => 'image/jpeg,image/png']);
1270
                        $element->setOptions(['label' => 'LABEL_IMAGE']);
1271
                        echo $this->formLabel($element);
1272
                        echo $this->formFile($element);
1273
                        ?>
1274
                    </div>
1275
                </div>
1276
            </div>
1277
            <div class="modal-footer">
1278
                <button type="submit" class="btn btn-primary">LABEL_UPLOAD</button>
1279
                <button type="button" class="btn btn-default btn-image-close">LABEL_CANCEL</button>
1280
            </div>
1281
            <?php echo $this->form()->closeTag($form); ?>
1282
        </div>
1283
    </div>
6060 stevensc 1284
</div>