vendor/uvdesk/core-framework/Resources/views/profile.html.twig line 1

Open in your IDE?
  1. {% extends "@UVDeskCoreFramework//Templates//layout.html.twig" %}
  2. {% block title %}
  3.     {{ 'Profile'|trans }}
  4. {% endblock %}
  5. {% set recaptchaDetail = recaptcha_service.getRecaptchaDetails() %}
  6. {% block templateCSS %}
  7.     <style>
  8.         span.uv-app-list-flag-active {
  9.         font-size: 15px;
  10.         color: #FFFFFF;
  11.         background-color: #2ED04C;
  12.         display: inline-block;
  13.         padding: 0px 7px 1px 7px;
  14.         margin-bottom: 2px;
  15.         border-radius: 3px;
  16.         }
  17.         span.uv-app-list-flag-inactive {
  18.         font-size: 15px;
  19.         color: #FFFFFF;
  20.         background-color: #FF5656;
  21.         display: inline-block;
  22.         padding: 0px 7px 1px 7px;
  23.         margin-bottom: 2px;
  24.         border-radius: 3px;
  25.         }
  26.         .token-list {
  27.             padding-left: 20px;
  28.         }
  29.         .add-token {
  30.             position: absolute;
  31.             right: 10px;
  32.         }
  33.         .token-item .uv-hr {
  34.             margin: 25px 0 15px -20px;
  35.         }
  36.         .token-name {
  37.             margin-right: 5px;
  38.         }
  39.         .mar-right-5 {
  40.             margin-right: 5px;
  41.         }
  42.     </style>  
  43. {% endblock %}
  44. {% block pageContent %}
  45.     <div class="uv-inner-section">
  46.         {# Append Panel Aside #}
  47.         {% set asideTemplate = 'Webkul\\UVDesk\\CoreFrameworkBundle\\Dashboard\\AsideTemplate' %}
  48.         {% set asideSidebarReference = 'Webkul\\UVDesk\\CoreFrameworkBundle\\UIComponents\\Dashboard\\Panel\\Sidebars\\Account' %}
  49.         {{ uvdesk_extensibles.getRegisteredComponent(asideTemplate).renderSidebar(asideSidebarReference) | raw }}
  50.         <div class="uv-view {% if app.request.cookies and app.request.cookies.get('uv-asideView') %}uv-aside-view{% endif %}">
  51.             <h1>Profile</h1>
  52.             {%  set agentDetails = user_service.getAgentDetailById(user.id) %}
  53.            
  54.             <div class="uv-tabs">
  55.                 <ul>
  56.                     <li for="profile" class="uv-tab-active">Edit Profile</li>
  57.                     {% if user_service.isAccessAuthorized('ROLE_ADMIN') %}
  58.                         <li for="recaptcha" class="uv-tab">{{ 'reCAPTCHA Setting'|trans }}</li>
  59.                     {% endif %}
  60.                 </ul>
  61.             </div>
  62.             {% for message in app.flashes('warning') %}
  63.                 <div class="flash-notice">
  64.                     {{ message }}
  65.                 </div>
  66.             {% endfor %}
  67.             {% for message in app.flashes('success') %}
  68.                 <div class="flash-notice">
  69.                     {{ message }}
  70.                 </div>
  71.             {% endfor %}
  72.             <!--Form-->
  73.             <form method="post" action="" id="user-form" enctype="multipart/form-data">
  74.                 <div class="uv-tab-view uv-tab-view-active" id="profile">
  75.                     <!-- Profile image -->
  76.                      <div class="uv-image-upload-wrapper">
  77.                         {% set isHaveImage =  agentDetails and agentDetails.profileImagePath ? 1 : 0 %}
  78.                         <div class="uv-image-upload-brick {% if isHaveImage %}uv-on-drop-shadow{% endif %}" {% if isHaveImage %}style="border-color: transparent;"{% endif %}>
  79.                             <input type="file" name="user_form[profileImage]" id="uv-upload-profile">
  80.                             <div class="uv-image-upload-placeholder">
  81.                                 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48px" height="32px">
  82.                                 <path fill-rule="evenodd" d="M28.026,26.003 L19.964,26.003 L19.964,17.962 L13.964,17.962 L23.995,8.050 L34.025,17.962 L28.026,17.962 L28.026,26.003 ZM33.557,3.421 C30.806,1.146 27.619,0.008 23.995,0.008 C21.182,0.008 18.588,0.756 16.214,2.252 C13.838,3.749 11.996,5.712 10.683,8.143 C7.683,8.456 5.152,9.749 3.090,12.024 C1.027,14.300 -0.004,16.965 -0.004,20.019 C-0.004,23.324 1.168,26.144 3.512,28.481 C5.855,30.819 8.682,31.988 11.996,31.988 L37.963,31.988 C40.712,31.988 43.072,31.006 45.040,29.042 C47.009,27.079 47.993,24.726 47.993,21.983 C47.993,19.364 47.087,17.106 45.275,15.203 C43.461,13.302 41.275,12.258 38.713,12.071 C38.024,8.580 36.306,5.698 33.557,3.421 Z"></path>
  83.                                 </svg>
  84.                             </div>
  85.                             <img id="dynamic-image-upload" {% if isHaveImage %}src="{{ app.request.scheme ~'://' ~ app.request.httpHost ~ asset('') }}{{ agentDetails.profileImagePath }}"{% endif %}>
  86.                         </div>
  87.                         <div class="uv-image-info-brick">
  88.                             <span class="uv-field-info">{{ 'Upload a Profile Image (100px x 100px)<br> in PNG or JPG Format'|trans|raw }}</span>
  89.                         </div>
  90.                     </div>
  91.                     <!-- Field -->
  92.                     <div class="uv-element-block">
  93.                         <label class="uv-field-label">{{ 'First Name'|trans }}</label>
  94.                         <div class="uv-field-block">
  95.                             <input type="text" name="user_form[firstName]"  class="uv-field" value="{{ user.firstName ?: agentDetails.firstName }}" />
  96.                         </div>
  97.                     </div>
  98.                     <!-- Field -->
  99.                     <div class="uv-element-block">
  100.                         <label class="uv-field-label">{{ 'Last Name'|trans }}</label>
  101.                         <div class="uv-field-block">
  102.                             <input type="text" name="user_form[lastName]" class="uv-field" value="{{ user.lastName ?:agentDetails.lastName }}" />
  103.                         </div>
  104.                     </div>
  105.                     <!-- Field -->
  106.                     <div class="uv-element-block">
  107.                         <label class="uv-field-label">{{ 'Email'|trans }}</label>
  108.                         <div class="uv-field-block">
  109.                             <input type="text" name="user_form[email]" class="uv-field" value="{{ user.email}}" />
  110.                         </div>
  111.                     </div>
  112.                     <!-- Field -->
  113.                     <div class="uv-element-block">
  114.                         <label class="uv-field-label">{{ 'Contact Number'|trans }}</label>
  115.                         <div class="uv-field-block">
  116.                             <input type="text" name="user_form[contactNumber]" class="uv-field" value="{{ agentDetails.contactNumber ?: agentDetails.contactNumber }}" />
  117.                         </div>
  118.                     </div>
  119.                    
  120.                     <div class="uv-element-block">
  121.                         <label class="uv-field-label">{{ 'Timezone'|trans }}</label>
  122.                         <div class="uv-field-block">
  123.                             <select name="user_form[timezone]" class="uv-select">
  124.                                 {% for timezone in uvdesk_service.getTimezones() %}
  125.                                     <option value="{{ timezone }}" {% if user.timezone == timezone %}selected{% endif %}>{{ timezone }}</option>
  126.                                 {% endfor %}
  127.                             </select>
  128.                         </div>
  129.                         <span class="uv-field-info">{{ "Choose your default timezone"|trans }}</span>
  130.                     </div>
  131.                     <div class="uv-element-block">
  132.                         <label class="uv-field-label">{{ 'Time Format'|trans }}</label>
  133.                         <div class="uv-field-block">
  134.                             <select name="user_form[timeformat]" class="uv-select">
  135.                                 {% for key, timeformat in uvdesk_service.getTimeFormats() %}   
  136.                                     <option value="{{ key }}" {% if user.timeformat == key %}selected{% endif %}>{{ timeformat }}</option>
  137.                                 {% endfor %}
  138.                             </select>
  139.                         </div>
  140.                         <span class="uv-field-info">{{ "Choose your default timezone"|trans }}</span>
  141.                     </div>
  142.                     <!-- Field -->
  143.                     <div class="uv-element-block">
  144.                         <label class="uv-field-label">{{ 'Signature'|trans }}</label>
  145.                         <div class="uv-field-block" style="max-width: 900px;">
  146.                             <textarea name="user_form[signature]" id="user-signature" class="uv-field uv-signature-editor" style="width: 100%;">{{ agentDetails.signature ?: agentDetails.signature }}</textarea>
  147.                         </div>
  148.                         <span class="uv-field-info">{{ 'User signature will be append at the bottom of ticket reply box'|trans }}</span>
  149.                     </div>
  150.                     <!-- Field -->
  151.                     <div class="uv-element-block">
  152.                         <label class="uv-field-label">{{ 'Password'|trans }}</label>
  153.                         <div class="uv-field-block">
  154.                             <input type="password" name="user_form[password][first]" class="uv-field"  />
  155.                             <span class="uv-field-info">{{ 'Password will remain same if you are not entering something in this field'|trans }}</span>
  156.                         </div>
  157.                     </div>
  158.                     <!-- Field -->
  159.                     <div class="uv-element-block">
  160.                         <label class="uv-field-label">{{ 'Confirm Password'|trans }}</label>
  161.                         <div class="uv-field-block">
  162.                             <input type="password" name="user_form[password][second]" class="uv-field"  />
  163.                         </div>
  164.                     </div>
  165.                     <!-- CSRF token Field -->
  166.                     <input type="hidden" name="user_form[_token]" value="{{ uvdesk_service.generateCsrfToken('user_form') }}"/>
  167.                     <!-- //CSRF token Field -->
  168.                 </div>
  169.                 {% if user_service.isAccessAuthorized('ROLE_ADMIN') %}
  170.                     <!--Tab View Recaptcha-->
  171.                     <div class="uv-tab-view" id="recaptcha">
  172.                         <div class="uv-element-block">
  173.                             <label class="uv-field-label">{{ 'reCAPTCHA Site Key'|trans }}</label>
  174.                             <div class="uv-field-block">
  175.                                 <input name="user_form[recaptcha_site_key]" class="uv-field grammarly-fix-broadcast" value="{{ recaptchaDetail ? recaptchaDetail.siteKey : '' }}">
  176.                             </div>
  177.                         </div>
  178.                         <div class="uv-element-block">
  179.                             <label class="uv-field-label">{{ 'reCAPTCHA Secret key'|trans }}</label>
  180.                             <div class="uv-field-block">
  181.                                 <input name="user_form[recaptcha_secret_key]" class="uv-field grammarly-fix-broadcast" value="{{ recaptchaDetail ? recaptchaDetail.secretKey : ''}}">
  182.                             </div>
  183.                         </div>
  184.                         <div class="uv-element-block">
  185.                             <label class="uv-field-label">{{'reCAPTCHA Status'|trans}}</label>
  186.                             <div class="uv-element-block">
  187.                                 <label>
  188.                                     <div class="uv-checkbox">
  189.                                         <input type="checkbox" name="user_form[recaptcha_status]" value="{{ recaptchaDetail is not empty and recaptchaDetail.isActive ? 1 : 0 }}" {{ recaptchaDetail is not empty and recaptchaDetail.isActive ? 'checked' : '' }}>
  190.                                         <span class="uv-checkbox-view"></span>
  191.                                     </div>
  192.                                     <span class="uv-checkbox-label">{{'reCAPTCHA is Active'|trans}}</span>
  193.                                 </label>
  194.                             </div>
  195.                         </div>
  196.                     </div>
  197.                     <!--//Tab View Recaptcha-->
  198.                 {% endif %}
  199.                 <div class="uv-pop-up-overlay" id="confirm-password">
  200.                     <div class="uv-pop-up-box uv-pop-up-slim">
  201.                         <span class="uv-pop-up-close"></span>
  202.                         <p>{{ 'Enter your current Password to continue'|trans }}</p>
  203.                         <div class="uv-element-block">
  204.                             <input type="password" name="user_form[oldPassword]" class="uv-field uv-margin-0">
  205.                         </div>
  206.                         <div class="uv-pop-up-actions">
  207.                             <a href="#" class="uv-btn proceed">{{ 'Continue'|trans }}</a>
  208.                         </div>
  209.                     </div>
  210.                 </div>
  211.                 <!--Tab View Recaptcha-->
  212.                 <input class="uv-btn" id="uv-save-profile" href="#" value="{{ 'Save Changes'|trans }}" type="submit">
  213.                 
  214.             </form>
  215.             
  216.         </div>
  217.     </div>
  218.     
  219. {% endblock %}
  220. {% block footer %}
  221.     {{ parent() }}
  222.     {{ include("@UVDeskCoreFramework/Templates/tinyMCE.html.twig") }}
  223.     <script type="text/javascript">
  224.         $(function () {
  225.             var UserModel = Backbone.Model.extend({
  226.                 validation: {
  227.                     'user_form[firstName]': {
  228.                         required: true,
  229.                         msg: '{{ "This field is mandatory"|trans }}'
  230.                     },
  231.                     'user_form[lastName]': function(value) {
  232.                         if(value != undefined && value !== '') {
  233.                             [{
  234.                                 pattern: /^[A-Za-z][A-Za-z]*[\sA-Za-z]*$/,
  235.                                 msg: 'This field must have characters only'
  236.                             },{
  237.                                 maxLength:40,
  238.                                 msg:'Maximum character length is 40'
  239.                             }]
  240.                         }
  241.                     },
  242.                     'user_form[email]': [{
  243.                         required: true,
  244.                         msg: '{{ "This field is mandatory"|trans }}'
  245.                     },{
  246.                         pattern: 'email',
  247.                         msg: '{{ "Email address is invalid"|trans }}'
  248.                     }],
  249.                     'user_form[contactNumber]': function(value) {
  250.                         if(value != undefined && value !== '') {
  251.                             if(!value.match('^\\s*(?:\\+?(\\d{1,3}))?[-. (]*(\\d{3})[-. )]*(\\d{3})[-. ]*(\\d{4})(?: *x(\\d+))?\\s*$'))
  252.                                 return '{{ "Contact number is invalid"|trans }}';
  253.                         }
  254.                     },
  255.                     'user_form[password][first]' : function(value) { 
  256.                         if(value != undefined && value !== '') {
  257.                              if(value.length < 8)
  258.                             return '{{ "Password must contains 8 Characters"|trans }}';
  259.                         }                      
  260.                     },
  261.                     'user_form[password][second]': {
  262.                         equalTo: 'user_form[password][first]',
  263.                         msg: '{{ "The passwords does not match"|trans }}'
  264.                     }
  265.                 }
  266.             });
  267.             var UserForm = Backbone.View.extend({
  268.                 events : {
  269.                     'click #uv-save-profile' : "saveUser",
  270.                     'blur input, textarea': 'formChanged',
  271.                     'click a.select': 'selectAll',
  272.                     'click a.deselect': 'deselectAll',
  273.                     'click #confirm-password .proceed': 'confirmChange',
  274.                 },
  275.               
  276.                 initialize : function() {
  277.                     Backbone.Validation.bind(this);
  278.                     var jsonContext = JSON.parse('{{ errors|raw }}');
  279.                     for (var field in jsonContext) {
  280.                         if(field == 'first') {
  281.                             Backbone.Validation.callbacks.invalid(this, "user_form[password][" + field + "]", jsonContext[field], 'input');
  282.                         } else {
  283.                             Backbone.Validation.callbacks.invalid(this, "user_form[" + field + "]", jsonContext[field], 'input');
  284.                         }
  285.                     }
  286.                     $('#notifications .uv-scroll-plank .uv-scroll-block').each(function() {
  287.                         if(!$(this).find('.uv-element-block').length) {
  288.                             $(this).parents('.uv-scroll-plank').remove()
  289.                         }
  290.                     })
  291.                 },
  292.                 confirmChange: function(e) {
  293.                     var target = $('#confirm-password input[name="user_form[oldPassword]"]');
  294.                     var oldPass = target.val();
  295.                     var that = this;
  296.                     if(oldPass && oldPass.length > 7) {
  297.                         $('#confirm-password .uv-pop-up-close,#uv-save-profile').trigger('click');
  298.                         target.next('.uv-field-message').remove();
  299.                     } else {                    
  300.                         target.addClass('uv-field-error');
  301.                         if(!(target.next() && target.next().hasClass('uv-field-message')) ) {
  302.                             target.after('<span class="uv-field-message">'+ '{{ "Password must contains 8 Characters"|trans }}'+ '</span>');
  303.                         }
  304.                     }
  305.                 },
  306.                 formChanged: function(e) {
  307.                     var fieldName = Backbone.$(e.currentTarget).attr('name');
  308.                     if(fieldName == 'user_form[password][second]') {
  309.                         if($("input[name='user_form[password][first]']").val().length) {
  310.                             this.model.set(fieldName, Backbone.$(e.currentTarget).val())
  311.                             this.model.isValid([fieldName])
  312.                         } else {
  313.                             if($("input[name='user_form[password][second]']").val().length) {
  314.                                 this.model.set(fieldName, Backbone.$(e.currentTarget).val())
  315.                                 this.model.isValid([fieldName])
  316.                             } else {
  317.                                 Backbone.Validation.callbacks.valid(this, fieldName, 'input');
  318.                             }
  319.                         }
  320.                     } else {
  321.                         this.model.set(fieldName, Backbone.$(e.currentTarget).val())
  322.                         this.model.isValid([fieldName])
  323.                         if(fieldName == 'user_form[password][first]' && !$("input[name='user_form[password][second]']").val().length) {
  324.                             Backbone.Validation.callbacks.valid(this, 'user_form[password][second]', 'input');
  325.                         }
  326.                     }
  327.                 },
  328.                 saveUser : function (e) {
  329.                     e.preventDefault();
  330.                     
  331.                     // Update TinyMCE content to textarea before serializing
  332.                     if (typeof tinymce !== 'undefined') {
  333.                         var signatureEditor = tinymce.get('user-signature');
  334.                         if (signatureEditor) {
  335.                             signatureEditor.save();
  336.                         }
  337.                     }
  338.                     
  339.                     var data = this.$el.serializeObject();
  340.                     this.model.set(data);
  341.                     if (this.model.isValid(true)) {
  342.                         this.$el.find('.uv-btn').attr('disabled', 'disabled');
  343.                         this.$el.submit();
  344.                     }
  345.                 },
  346.                 selectAll: function (e) {
  347.                     e.preventDefault();
  348.                     this.$(e.currentTarget).parents('.uv-scroll-plank')
  349.                             .find('input')
  350.                             .prop('checked', true)
  351.                 },
  352.                 deselectAll: function (e) {
  353.                     e.preventDefault();
  354.                     this.$(e.currentTarget).parents('.uv-scroll-plank')
  355.                             .find('input')
  356.                             .prop('checked', false);
  357.                 },
  358.             });
  359.             userForm = new UserForm({
  360.                 el : $("#user-form"),
  361.                 model : new UserModel()
  362.             });
  363.             
  364.             // Initialize TinyMCE for Signature field
  365.             if (typeof sfTinyMce !== 'undefined') {
  366.                 // Override sendFile function for profile context
  367.                 var originalSendFile = window.sendFile;
  368.                 window.sendFile = function(files) {
  369.                     var data = new FormData();
  370.                     var nonEmptyFlag;
  371.                     $.each(files, function(key, file){
  372.                         var patt = new RegExp("(image/)(?!tif)");
  373.                         if(file.type && patt.test(file.type)) {
  374.                             data.append("attachments[]", file);
  375.                             nonEmptyFlag = true;
  376.                         }
  377.                     });
  378.                     if(nonEmptyFlag) {
  379.                         return $.ajax({
  380.                             data: data,
  381.                             type: "POST",
  382.                             enctype: 'multipart/form-data',
  383.                             url: "{{ path('ajax_file_upload') }}",
  384.                             processData: false,
  385.                             contentType: false,
  386.                             cache: false,
  387.                         });
  388.                     } else {
  389.                         if(typeof app !== 'undefined' && app.appView) {
  390.                             app.appView.renderResponseAlert({'alertClass': 'danger', 'alertMessage': '{{ "Warning! Select valid image file."|trans }}' });
  391.                         }
  392.                     }
  393.                 };
  394.                 
  395.                 sfTinyMce.init({
  396.                     selector: '#user-signature',
  397.                     height: 450,
  398.                     width: '100%',
  399.                     menubar: false,
  400.                     toolbar: 'undo redo | bold italic underline | fontselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright | bullist numlist | image | removeformat',
  401.                     plugins: 'textcolor paste image imagetools lists',
  402.                     paste_data_images: true,
  403.                     image_advtab: true,
  404.                     content_style: 'body { font-family:Poppins,sans-serif; font-size:14px }',
  405.                     font_formats: 'Poppins=Poppins, sans-serif; Arial=Arial, sans-serif; Verdana=Verdana, sans-serif; Times New Roman=Times New Roman, serif; Courier New=Courier New, monospace;',
  406.                     setup: function(editor) {
  407.                         sfTinyMce.initImageUpload(editor);
  408.                     }
  409.                 });
  410.             }
  411.         });
  412.     </script>
  413. {% endblock %}