Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 8066 | Rev 8107 | 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
 
8064 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
 
35
 
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
 
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
 
8064 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
 
8064 stevensc 57
 
1 www 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
 
8064 stevensc 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
 
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
 
8064 stevensc 77
 
78
 
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');
83
 
84
 
85
 
86
            $.validator.setDefaults({
87
            debug: true,
88
            highlight: function(element) {
89
                $(element).addClass('is-invalid');
90
            },
91
            unhighlight: function(element) {
92
                $(element).removeClass('is-invalid');
93
            },
94
            errorElement: 'span',
95
            errorClass: 'error invalid-feedback',
96
            errorPlacement: function(error, element) {
97
                if(element.parent('.form-group').length) {
98
                    error.insertAfter(element);
99
                } else if(element.parent('.toggle').length) {
100
                    error.insertAfter(element.parent().parent());
101
                } else {
102
                    error.insertAfter(element.parent());
103
                }
104
            }
105
        });
106
 
107
 
108
        $.fn.showFormErrorValidator = function(fieldname, errors) {
109
            var field = $(fieldname);
110
            if(field) {
111
                $(field).addClass('is-invalid');
112
 
113
 
114
                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
115
                if(field.parent('.form-group').length) {
116
                    error.insertAfter(field);
117
                } else  if(field.parent('.toggle').length) {
118
                    error.insertAfter(field.parent().parent());
119
                } else {
120
                    error.insertAfter(field.parent());
121
                }
122
            }
123
        };
124
 
125
    var validatorExtended = $('#form-extended').validate({
126
        debug: true,
127
        onclick: false,
128
        onkeyup: false,
129
        onfocusout: false,
130
        ignore: [],
131
        rules: {
132
            'description': {
133
                updateCkeditor:function() {
134
                        CKEDITOR.instances.description.updateElement();
135
                },
136
                required: false,
137
            },
138
        },
6486 stevensc 139
 
8064 stevensc 140
        submitHandler: function(form)
141
        {
142
            NProgress.start();
143
            $.ajax({
144
                'dataType'  : 'json',
145
                'accept'    : 'application/json',
146
                'method'    : 'post',
147
                'url'       :  $('#form-extended').attr('action'),
148
                'data'      :  $('#form-extended').serialize()
149
            }).done(function(response) {
150
                if(response['success']) {
151
 
152
                    $('#overview-description').html(response['data']['description']);
153
                    $("#extended-box").modal('hide');
154
                } else {
155
                    validatorExtended.resetForm();
156
                    if(jQuery.type(response['data']) == 'string') {
157
                        $.fn.showError(response['data']);
158
                    } else  {
159
                        $.each(response['data'], function( fieldname, errors ) {
160
                            $.fn.showFormErrorValidator('#form-extended #' + fieldname, errors);
161
                        });
162
                    }
163
                }
164
            }).fail(function( jqXHR, textStatus, errorThrown) {
165
                $.fn.showError(textStatus);
166
            }).always(function() {
167
                NProgress.done();
168
            });
169
            return false;
170
        },
171
        invalidHandler: function(form, validator) {
172
 
173
        }
174
    });
175
 
176
 
177
    $('.btn-extended-edit').on("click", function(e){
178
        e.preventDefault();
179
 
180
        NProgress.start();
181
        $.ajax({
182
            'dataType'  : 'json',
183
            'accept'    : 'application/json',
184
            'method'    : 'get',
185
            'url'       : '$routeExtended',
186
        }).done(function(response) {
187
           if(response['success']) {
188
                CKEDITOR.instances.description.setData(response['data']['description']);
189
                validatorExtended.resetForm();
190
 
191
                $("#extended-box").modal('show');
192
            } else {
193
                $.fn.showError(response['data']);
194
            }
195
        }).fail(function( jqXHR, textStatus, errorThrown) {
196
            $.fn.showError(textStatus);
197
        }).always(function() {
198
            NProgress.done();
199
        });
200
        return false;
201
 
202
    });
203
 
204
    $('.btn-extended-close').on("click", function(e){
205
        e.preventDefault();
206
 
207
        $("#extended-box").modal('hide');
208
        return false;
209
    });
210
 
1 www 211
	var validatorIndustry = $('#form-industry').validate({
212
        debug: true,
213
        onclick: false,
214
        onkeyup: false,
215
        onfocusout: false,
216
        ignore: [],
217
        rules: {
218
            'industry_id': {
219
                required: true,
220
            },
221
        },
222
 
223
        submitHandler: function(form)
224
        {
225
            NProgress.start();
226
            $.ajax({
227
                'dataType'  : 'json',
228
                'accept'    : 'application/json',
229
                'method'    : 'post',
230
                'url'       :  $('#form-industry').attr('action'),
231
                'data'      :  $('#form-industry').serialize()
232
            }).done(function(response) {
233
                if(response['success']) {
234
 
235
                    $('#overview-industry').html(response['data']);
236
                    $("#industry-box").modal('hide');
237
                } else {
238
                    validatorIndustry.resetForm();
239
                    if(jQuery.type(response['data']) == 'string') {
240
                        $.fn.showError(response['data']);
241
                    } else  {
242
                        $.each(response['data'], function( fieldname, errors ) {
243
                            $.fn.showFormErrorValidator('#form-industry #' + fieldname, errors);
244
                        });
245
                    }
246
                }
247
            }).fail(function( jqXHR, textStatus, errorThrown) {
248
                $.fn.showError(textStatus);
249
            }).always(function() {
250
                NProgress.done();
251
            });
252
            return false;
253
        },
254
        invalidHandler: function(form, validator) {
255
 
256
        }
257
    });
258
 
259
 
260
    $('.btn-industry-edit').on("click", function(e){
261
        e.preventDefault();
262
 
263
        NProgress.start();
264
        $.ajax({
265
            'dataType'  : 'json',
266
            'accept'    : 'application/json',
267
            'method'    : 'get',
268
            'url'       : '$routeIndustry',
269
        }).done(function(response) {
270
           if(response['success']) {
271
				$('#form-industry #industry_id').val(response['data']['industry_id']).trigger('change');
272
 
273
                validatorIndustry.resetForm();
274
 
275
                $("#industry-box").modal('show');
276
            } else {
277
                $.fn.showError(response['data']);
278
            }
279
        }).fail(function( jqXHR, textStatus, errorThrown) {
280
            $.fn.showError(textStatus);
281
        }).always(function() {
282
            NProgress.done();
283
        });
284
        return false;
285
 
286
    });
287
 
288
    $('.btn-industry-close').on("click", function(e){
289
        e.preventDefault();
290
 
291
        $("#industry-box").modal('hide');
292
        return false;
8067 stevensc 293
    });
1 www 294
 
8064 stevensc 295
    CKEDITOR.replace('description');
296
 
1 www 297
});
298
 
8064 stevensc 299
 
1 www 300
JS;
301
$this->inlineScript()->captureEnd();
302
 
6005 stevensc 303
$jsonLocations = json_encode($locations);
8064 stevensc 304
 
5743 stevensc 305
$js = <<<JS
306
const urlVars = {
307
    routeWebsite: "$routeWebsite",
308
    routeCompanySize: "$routeCompanySize",
309
    routeIndustry: "$routeIndustry",
310
    routeExtended: "$routeExtended",
311
    routeSocialNetworks: "$routeSocialNetworks",
312
    routeLocationAdd: "$routeLocationAdd",
313
    routeFoundationYear: "$routeFoundationYear",
314
    routeImageUpload: "$routeImageUpload",
315
    routeCoverUpload: "$routeCoverUpload",
316
    routeFooterUpload: "$routeFooterUpload",
5757 stevensc 317
    routeHeaderUpload: "$routeHeaderUpload",
318
    cover: "$cover",
5795 stevensc 319
    companyId: "$companyId",
5925 stevensc 320
    followers: "$follower",
5988 stevensc 321
    image: "$image",
6002 stevensc 322
    overview: "$overview",
6025 stevensc 323
    locations: JSON.parse('$jsonLocations'),
6026 stevensc 324
    industry: "$industry",
6027 stevensc 325
    companySize: "$company_size",
6050 stevensc 326
    companyName: "$company_name",
327
    foundationYear: "$foundation_year",
6055 stevensc 328
    website: "$website",
6059 stevensc 329
    header: "$header",
8064 stevensc 330
    footer: "$footer"
5743 stevensc 331
}
332
JS;
333
 
334
$this->inlineScript()->appendScript($js);
6448 stevensc 335
$this->headLink()->appendStylesheet('/react-bundles/profile/main.css');
5743 stevensc 336
$this->inlineScript()->appendFile('/react-bundles/profile/profileBundle.js');
1 www 337
?>
338
 
777 geraldo 339
<style>
5743 stevensc 340
    .user-profile-ov {
341
        position: relative;
342
    }
777 geraldo 343
 
5743 stevensc 344
    .user-profile-ov .add-dp {
345
        position: absolute;
346
        top: 30%;
347
        right: 10%;
348
    }
779 geraldo 349
 
5743 stevensc 350
    .user-profile-ov .add-dp i {
351
        font-size: 14px;
352
        border: 2px solid #fff;
353
        background: #e44d3a;
354
        padding: 11px;
355
        color: #ffff
356
    }
777 geraldo 357
</style>
358
 
1 www 359
<!-- Content Header (Page header) -->
5743 stevensc 360
<div id="profile">
5800 stevensc 361
</div>
8064 stevensc 362
<div class="modal" tabindex="-1" role="dialog" id="extended-box">
363
    <div class="modal-dialog" role="document">
364
        <?php
365
        $form = $this->formExtended;
366
        $form->setAttributes([
367
            'method' => 'post',
368
            'action' => $routeExtended,
369
            'name' => 'form-extended',
370
            'id' => 'form-extended'
371
        ]);
372
        $form->prepare();
373
        echo $this->form()->openTag($form);
374
        ?>
375
        <div class="modal-content">
376
            <div class="modal-header">
377
                <h3 class="modal-title">LABEL_CHANGE</h3>
378
            </div>
379
            <div class="modal-body">
380
                <div class="form-group">
381
                    <?php
382
                    $element = $form->get('description');
383
                    $element->setAttributes(['class' => 'form-control']);
384
                    $element->setOptions(['label' => 'LABEL_OVERVIEW']);
385
                    echo $this->formLabel($element);
386
                    echo $this->formTextArea($element);
387
                    ?>
388
                </div>
389
            </div>
390
            <div class="modal-footer">
391
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
392
                <button type="button" class="btn btn-default btn-extended-close">LABEL_CANCEL</button>
393
            </div>
394
            <?php echo $this->form()->closeTag($form); ?>
395
        </div>
396
    </div>
397
</div>
1 www 398
<div class="modal" tabindex="-1" role="dialog" id="industry-box">
5743 stevensc 399
    <div class="modal-dialog" role="document">
400
        <?php
401
        $form = $this->formIndustry;
402
        $form->setAttributes([
403
            'method' => 'post',
404
            'action' => $routeIndustry,
405
            'name' => 'form-industry',
406
            'id' => 'form-industry'
407
        ]);
408
        $form->prepare();
409
        echo $this->form()->openTag($form);
410
        ?>
411
        <div class="modal-content">
412
            <div class="modal-header">
413
                <h3 class="modal-title">LABEL_CHANGE</h3>
770 geraldo 414
            </div>
5743 stevensc 415
            <div class="modal-body">
416
                <div class="form-group">
417
                    <?php
418
                    $element = $form->get('industry_id');
419
                    $element->setAttributes(['class' => 'form-control']);
420
                    $element->setOptions(['label' => 'LABEL_INDUSTRY']);
421
                    echo $this->formLabel($element);
422
                    echo $this->formSelect($element);
423
                    ?>
424
                </div>
425
            </div>
426
            <div class="modal-footer">
427
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
428
                <button type="button" class="btn btn-default btn-industry-close">LABEL_CANCEL</button>
429
            </div>
430
            <?php echo $this->form()->closeTag($form); ?>
431
        </div>
432
    </div>
1 www 433
</div>
434
<div class="modal" tabindex="-1" role="dialog" id="company-size-box">
5743 stevensc 435
    <div class="modal-dialog" role="document">
436
        <?php
437
        $form = $this->formCompanySize;
438
        $form->setAttributes([
439
            'method' => 'post',
440
            'action' => $routeCompanySize,
441
            'name' => 'form-company-size',
442
            'id' => 'form-company-size'
443
        ]);
444
        $form->prepare();
445
        echo $this->form()->openTag($form);
446
        ?>
447
        <div class="modal-content">
448
            <div class="modal-header">
449
                <h3 class="modal-title">LABEL_CHANGE</h3>
770 geraldo 450
            </div>
5743 stevensc 451
            <div class="modal-body">
452
                <div class="form-group">
453
                    <?php
454
                    $element = $form->get('company_size_id');
455
                    $element->setAttributes(['class' => 'form-control']);
456
                    $element->setOptions(['label' => 'LABEL_COMPANY_SIZE']);
457
                    echo $this->formLabel($element);
458
                    echo $this->formSelect($element);
459
                    ?>
460
                </div>
461
            </div>
462
            <div class="modal-footer">
463
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
464
                <button type="button" class="btn btn-default btn-company-size-close">LABEL_CANCEL</button>
465
            </div>
466
            <?php echo $this->form()->closeTag($form); ?>
467
        </div>
468
    </div>
6060 stevensc 469
</div>