Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 8524 | Rev 8767 | 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
 
8525 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
 
8525 stevensc 53
 
1 www 54
$this->inlineScript()->captureStart();
55
echo <<<JS
56
jQuery( document ).ready(function( $ ) {
57
 
8525 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');
8523 stevensc 67
            },
8525 stevensc 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());
8523 stevensc 78
                } else {
8525 stevensc 79
                    error.insertAfter(element.parent());
8523 stevensc 80
                }
81
            }
82
        });
8525 stevensc 83
 
84
 
85
        $.fn.showFormErrorValidator = function(fieldname, errors) {
86
            var field = $(fieldname);
87
            if(field) {
88
                $(field).addClass('is-invalid');
89
 
8523 stevensc 90
 
8525 stevensc 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
        };
8523 stevensc 101
 
8525 stevensc 102
    var validatorExtended = $('#form-extended').validate({
8523 stevensc 103
        debug: true,
104
        onclick: false,
105
        onkeyup: false,
106
        onfocusout: false,
107
        ignore: [],
108
        rules: {
8525 stevensc 109
            'description': {
110
                updateCkeditor:function() {
111
                        CKEDITOR.instances.description.updateElement();
112
                },
113
                required: false,
8523 stevensc 114
            },
115
        },
116
 
117
        submitHandler: function(form)
118
        {
119
            NProgress.start();
120
            $.ajax({
121
                'dataType'  : 'json',
122
                'accept'    : 'application/json',
123
                'method'    : 'post',
8525 stevensc 124
                'url'       :  $('#form-extended').attr('action'),
125
                'data'      :  $('#form-extended').serialize()
8523 stevensc 126
            }).done(function(response) {
127
                if(response['success']) {
128
 
8525 stevensc 129
                    $('#overview-description').html(response['data']['description']);
130
                    $("#extended-box").modal('hide');
8523 stevensc 131
                } else {
8525 stevensc 132
                    validatorExtended.resetForm();
8523 stevensc 133
                    if(jQuery.type(response['data']) == 'string') {
134
                        $.fn.showError(response['data']);
135
                    } else  {
136
                        $.each(response['data'], function( fieldname, errors ) {
8525 stevensc 137
                            $.fn.showFormErrorValidator('#form-extended #' + fieldname, errors);
8523 stevensc 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
 
8525 stevensc 154
    $('.btn-extended-edit').on("click", function(e){
8523 stevensc 155
        e.preventDefault();
156
 
157
        NProgress.start();
158
        $.ajax({
159
            'dataType'  : 'json',
160
            'accept'    : 'application/json',
161
            'method'    : 'get',
8525 stevensc 162
            'url'       : '$routeExtended',
8523 stevensc 163
        }).done(function(response) {
164
           if(response['success']) {
8525 stevensc 165
                CKEDITOR.instances.description.setData(response['data']['description']);
166
                validatorExtended.resetForm();
8523 stevensc 167
 
8525 stevensc 168
                $("#extended-box").modal('show');
8523 stevensc 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
    });
1 www 180
 
8525 stevensc 181
    $('.btn-extended-close').on("click", function(e){
8523 stevensc 182
        e.preventDefault();
183
 
8525 stevensc 184
        $("#extended-box").modal('hide');
8523 stevensc 185
        return false;
186
    });
187
 
8525 stevensc 188
    CKEDITOR.replace('description');
189
 
1 www 190
});
191
 
8525 stevensc 192
 
1 www 193
JS;
194
$this->inlineScript()->captureEnd();
195
 
6005 stevensc 196
$jsonLocations = json_encode($locations);
8525 stevensc 197
 
5743 stevensc 198
$js = <<<JS
199
const urlVars = {
200
    routeWebsite: "$routeWebsite",
201
    routeCompanySize: "$routeCompanySize",
202
    routeIndustry: "$routeIndustry",
203
    routeExtended: "$routeExtended",
204
    routeSocialNetworks: "$routeSocialNetworks",
205
    routeLocationAdd: "$routeLocationAdd",
206
    routeFoundationYear: "$routeFoundationYear",
207
    routeImageUpload: "$routeImageUpload",
208
    routeCoverUpload: "$routeCoverUpload",
209
    routeFooterUpload: "$routeFooterUpload",
5757 stevensc 210
    routeHeaderUpload: "$routeHeaderUpload",
211
    cover: "$cover",
5795 stevensc 212
    companyId: "$companyId",
5925 stevensc 213
    followers: "$follower",
5988 stevensc 214
    image: "$image",
6002 stevensc 215
    overview: "$overview",
6025 stevensc 216
    locations: JSON.parse('$jsonLocations'),
6026 stevensc 217
    industry: "$industry",
6027 stevensc 218
    companySize: "$company_size",
6050 stevensc 219
    companyName: "$company_name",
220
    foundationYear: "$foundation_year",
6055 stevensc 221
    website: "$website",
6059 stevensc 222
    header: "$header",
8525 stevensc 223
    footer: "$footer"
5743 stevensc 224
}
225
JS;
226
 
227
$this->inlineScript()->appendScript($js);
6448 stevensc 228
$this->headLink()->appendStylesheet('/react-bundles/profile/main.css');
5743 stevensc 229
$this->inlineScript()->appendFile('/react-bundles/profile/profileBundle.js');
1 www 230
?>
231
 
777 geraldo 232
<style>
5743 stevensc 233
    .user-profile-ov {
234
        position: relative;
235
    }
777 geraldo 236
 
5743 stevensc 237
    .user-profile-ov .add-dp {
238
        position: absolute;
239
        top: 30%;
240
        right: 10%;
241
    }
779 geraldo 242
 
5743 stevensc 243
    .user-profile-ov .add-dp i {
244
        font-size: 14px;
245
        border: 2px solid #fff;
246
        background: #e44d3a;
247
        padding: 11px;
248
        color: #ffff
249
    }
777 geraldo 250
</style>
251
 
1 www 252
<!-- Content Header (Page header) -->
5743 stevensc 253
<div id="profile">
5800 stevensc 254
</div>
8525 stevensc 255
 
256
<div class="modal" tabindex="-1" role="dialog" id="extended-box">
8523 stevensc 257
    <div class="modal-dialog" role="document">
258
        <?php
8525 stevensc 259
        $form = $this->formExtended;
8523 stevensc 260
        $form->setAttributes([
261
            'method' => 'post',
8525 stevensc 262
            'action' => $routeExtended,
263
            'name' => 'form-extended',
264
            'id' => 'form-extended'
8523 stevensc 265
        ]);
266
        $form->prepare();
267
        echo $this->form()->openTag($form);
268
        ?>
269
        <div class="modal-content">
270
            <div class="modal-header">
271
                <h3 class="modal-title">LABEL_CHANGE</h3>
272
            </div>
273
            <div class="modal-body">
274
                <div class="form-group">
275
                    <?php
8525 stevensc 276
                    $element = $form->get('description');
8523 stevensc 277
                    $element->setAttributes(['class' => 'form-control']);
8525 stevensc 278
                    $element->setOptions(['label' => 'LABEL_OVERVIEW']);
8523 stevensc 279
                    echo $this->formLabel($element);
8525 stevensc 280
                    echo $this->formTextArea($element);
8523 stevensc 281
                    ?>
282
                </div>
283
            </div>
284
            <div class="modal-footer">
285
                <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
8525 stevensc 286
                <button type="button" class="btn btn-default btn-extended-close">LABEL_CANCEL</button>
8523 stevensc 287
            </div>
288
            <?php echo $this->form()->closeTag($form); ?>
289
        </div>
290
    </div>
6060 stevensc 291
</div>