Proyectos de Subversion LeadersLinked - Backend

Rev

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