vendor\uvdesk\support-center-bundle\Resources\views\Knowledgebase\ticket.html.twig line 1

Open in your IDE?
  1. {% extends "@UVDeskSupportCenter/Templates/layout.html.twig" %}
  2. {% block title %}{% trans %}Create Ticket{% endtrans %}{% endblock %}
  3. {% block ogtitle %}{% trans %}Create Ticket{% endtrans %}{% endblock %}
  4. {% block twtitle %}{% trans %}Create Ticket{% endtrans %}{% endblock %}
  5. {% block metaDescription %}{% trans %}create.ticket.metaDescription{% endtrans %}{% endblock %}
  6. {% block metaKeywords %}{% trans %}create.ticket.metaKeywords{% endtrans %}{% endblock %}
  7. {% set recaptchaDetail = recaptcha_service.getRecaptchaDetails() %}
  8. {% block body %}
  9.     <style>
  10.         .uv-field{
  11.             padding: 5px 10px;
  12.         }
  13.         .grammarly-fix-message-container {
  14.             overflow: visible !important;
  15.         }
  16.         .grammarly-fix-message {
  17.             max-width: 158%;
  18.         }
  19.         .uv-field-success-icon {
  20.             display: none !important;
  21.         }
  22.         .mce-path {
  23.               display: none !important;
  24.         }
  25.         
  26.         .uv-element-block label.uv-field-label.required::after {
  27.             content: "*";
  28.             color: #FC6868;
  29.             font-weight: 700;
  30.             display: inline-block;
  31.         }
  32.     </style>
  33.     {% set isTicketViewPage = (app.user.id is defined ? true : false) %}
  34.     
  35.     <div class="uv-paper-article uv-paper-form">
  36.         <div class="uv-paper-section">
  37.             <section>
  38.                 <h1>{{ 'Create Ticket Request'|trans }}</h1>
  39.                 <div class="uv-form">
  40.                     <form action="{{ path('helpdesk_customer_create_ticket') }}" method="post" id="create-ticket-form" enctype="multipart/form-data">
  41.                         {% if not isTicketViewPage %}
  42.                             <!-- Field -->
  43.                             <div class="uv-element-block">
  44.                                 <label class="uv-field-label required">{{ 'Name'|trans }}</label>
  45.                                 <div class="uv-field-block">
  46.                                     <input name="name" class="uv-field create-ticket" type="text" value="{{ post.name is defined ? post.name : '' }}">
  47.                                 </div>
  48.                                 <span class="uv-field-info">{{ 'Enter your name'|trans }}</span>
  49.                             </div>
  50.                             <!-- //Field -->
  51.                             <!-- Field -->
  52.                             <div class="uv-element-block">
  53.                                 <label class="uv-field-label required">{{ 'Email'|trans }}</label>
  54.                                 <div class="uv-field-block">
  55.                                     <input name="from" class="uv-field create-ticket" type="text" value="{{ post.from is defined ? post.from : '' }}">
  56.                                 </div>
  57.                                 <span class="uv-field-info">{{ 'Enter your email'|trans }}</span>
  58.                             </div>
  59.                             <!-- //Field -->
  60.                         {% endif %}
  61.                         <!-- Field -->
  62.                         <div class="uv-element-block">
  63.                             <label class="uv-field-label required">{{ 'Type'|trans }}</label>
  64.                             <div class="uv-field-block">
  65.                                 <select name="type" class="uv-select create-ticket" id="type">
  66.                                     <option value="">{{ 'Select type'|trans }}</option>
  67.                                     {% for type in ticket_service.getTypes() %}
  68.                                         <option value="{{ type.id }}" {{ post.type is defined and post.type == type.id ? 'selected' : '' }}>{{ type.name }}</option>
  69.                                     {% endfor %}
  70.                                 </select>
  71.                             </div>
  72.                             <span class="uv-field-info">{{ 'Choose ticket type'|trans }}</span>
  73.                         </div>
  74.                         <!-- //Field -->
  75.                         <!-- Field -->
  76.                         <div class="uv-element-block">
  77.                             <label class="uv-field-label required">{{ 'Subject'|trans }}</label>
  78.                             <div class="uv-field-block">
  79.                                 <input name="subject" class="uv-field create-ticket" type="text" value="{{ post.subject is defined ? post.subject : '' }}">
  80.                             </div>
  81.                             <span class="uv-field-info">{{ 'Ticket subject'|trans }}</span>
  82.                         </div>
  83.                         <!-- //Field -->
  84.                         <!-- Field -->
  85.                         <div class="uv-element-block">
  86.                             <label class="uv-field-label required">{{ 'Message'|trans }}</label>
  87.                             <div class="uv-field-block grammarly-fix-message-container">
  88.                                 <textarea name="reply" id="create-reply" class="uv-field create-ticket grammarly-fix-message" type="text">{{ post.reply is defined ? post.reply : '' }}</textarea>
  89.                             </div>
  90.                             <span class="uv-field-info">{{ 'Ticket query message'|trans }}</span>
  91.                         </div>
  92.                         <!-- //Field -->
  93.                         <!-- Field -->
  94.                         <div class="uv-element-block attachment-block uv-no-error-success-icon" id="uv-attachment-option">
  95.                             <label>
  96.                                 <span class="uv-file-label">{{ 'Add Attachment'|trans }}</span>
  97.                             </label>
  98.                         </div>
  99.                         <!-- //Field -->
  100.                         {% if recaptchaDetail and recaptchaDetail.isActive == true %}
  101.                             <div class="clearfix"></div>
  102.                             <div class="g-recaptcha" data-sitekey="{{ recaptchaDetail.siteKey }}"></div>
  103.                             <div class="clearfix"></div>
  104.                         {% else %}
  105.                             <!-- Recaptcha will not support -->
  106.                         {% endif %}
  107.                         {# CustomFields #}
  108.                         {% set CustomerCustomFields = ticket_service.getCustomerCreateTicketCustomFieldSnippet() %}
  109.                         {% set removeMe = [] %}
  110.                         {% if CustomerCustomFields %}
  111.                             <div class="custom-fields clearfix">
  112.                                 {% for key, customField in CustomerCustomFields %}
  113.                                     <div class="uv-element-block input-group {{ customField.customFieldsDependency|length ? 'dependent' : '' }} {% for customFieldCustomFieldsDependency in customField.customFieldsDependency %} dependency{{customFieldCustomFieldsDependency.id}}{% endfor %}" style="position: relative; {{ customField.customFieldsDependency|length ? 'display: none;' : '' }}">
  114.                                         <label class="uv-field-label" for="for{{customField.name~customField.id}}">{{ customField.name }}</label>
  115.                                         {% if customField.fieldType == 'text' %}
  116.                                             <div class="uv-field-block">
  117.                                                 <input type="{{ customField['validation']['fieldtype'] is defined ? customField['validation']['fieldtype'] :'text' }}" name="customFields[{{customField.id}}]" class="uv-field create-ticket" value="" {{ customField.required ? "required" : "" }} id="for{{customField.name~customField.id}}" placeholder="{{customField.placeholder}}">
  118.                                             </div>
  119.                                         {% elseif customField.fieldType in ['date', 'time', 'datetime'] %}
  120.                                             <div class="uv-field-block">
  121.                                                 <input class="uv-field form-control create-ticket uv-date-picker {% if customField.fieldType == 'time' %}time{% else %}calendar{% endif %} uv-header-{{ customField.fieldType }}" type="text" name="customFields[{{customField.id}}]" {{ customField.required ? "required" : "" }} id="for{{customField.name~customField.id}}" value="">
  122.                                             </div>
  123.                                         {% elseif customField.fieldType == 'textarea' %}
  124.                                             <div class="uv-field-block">
  125.                                                 <textarea name="customFields[{{customField.id}}]" class="uv-field create-ticket" {{ customField.required ? "required" : "" }} id="for{{customField.name~customField.id}}"></textarea>
  126.                                             </div>
  127.                                         {% elseif customField.fieldType in ['file'] %}
  128.                                             <div class="uv-field-block">
  129.                                                 <input type="file" name="customFields[{{customField.id}}]" class="uv-field create-ticket" {{ customField.required ? "required" : "" }} id="for{{customField.name~customField.id}}">
  130.                                             </div>
  131.                                         {% elseif customField.fieldType in ['select'] %}
  132.                                             {% if customField.customFieldValues is not empty %}
  133.                                                 <div class="uv-field-block">
  134.                                                     <select name="customFields[{{customField.id}}]" class="uv-select create-ticket" id="for{{customField.name~customField.id}}" {{ customField.required ? "required" : "" }}>
  135.                                                         <option value="">{{ 'Select option' }}</option>
  136.                                                         {% for customFieldValues in customField.customFieldValues %}
  137.                                                             <option value="{{customFieldValues.id}}">{{customFieldValues.name}}</option>
  138.                                                         {% endfor %}
  139.                                                     </select>
  140.                                                 </div>
  141.                                             {% else %}
  142.                                                 <!--Hide this beacause choices aren't available-->
  143.                                                 {% set removeMe = removeMe|merge(["for"~customField.name~customField.id]) %}
  144.                                             {% endif %}
  145.                                         {% elseif customField.fieldType in ['checkbox'] %}
  146.                                             {% if customField.customFieldValues is not empty %}
  147.                                                 {% for customFieldValues in customField.customFieldValues %}
  148.                                                     <div class="uv-split-field">
  149.                                                         <label>
  150.                                                             <div class="uv-checkbox">
  151.                                                                 <input type="checkbox" name="customFields[{{customField.id}}][]" value="{{customFieldValues.id}}" id="for{{customFieldValues.name~customFieldValues.id}}" class="create-ticket"/>
  152.                                                                 <span class="uv-checkbox-view"></span>
  153.                                                             </div>
  154.                                                             <span class="uv-radio-label" for="for{{customFieldValues.name~customFieldValues.id}}">{{ customFieldValues.name }}</span>
  155.                                                         </label>
  156.                                                     </div>
  157.                                                 {% endfor %}
  158.                                             {% else %}
  159.                                                 <!--Hide this beacause choices aren't available-->
  160.                                                 {% set removeMe = removeMe|merge(["for"~customField.name~customField.id]) %}
  161.                                             {% endif %}
  162.                                         {% elseif customField.fieldType in ['radio'] %}
  163.                                             {% if customField.customFieldValues is not empty %}
  164.                                                 {% for customFieldValues in customField.customFieldValues %}
  165.                                                     <div class="uv-split-field">
  166.                                                         <label>
  167.                                                             <div class="uv-radio">
  168.                                                                 <input type="radio" name="customFields[{{customField.id}}]" value="{{customFieldValues.id}}" id="for{{customFieldValues.name~customFieldValues.id}}" class="create-ticket"/>
  169.                                                                 <span class="uv-radio-view"></span>
  170.                                                             </div>
  171.                                                             <span class="uv-radio-label" for="for{{customFieldValues.name~customFieldValues.id}}">{{ customFieldValues.name }}</span>
  172.                                                         </label>
  173.                                                     </div>
  174.                                                 {% endfor %}
  175.                                             {% else %}
  176.                                                 <!--Hide this beacause choices aren't available-->
  177.                                                 {% set removeMe = removeMe|merge(["for"~customField.name~customField.id]) %}
  178.                                             {% endif %}
  179.                                         {% endif %}
  180.                                         {% if formErrors['customFields['~customField.id~']'] is defined %}
  181.                                             <div class="text-danger">{{formErrors['customFields['~customField.id~']']}}</div>
  182.                                         {% endif %}
  183.                                     </div>
  184.                                 {% endfor %}
  185.                             </div>
  186.                         {% endif %}
  187.                         <div class="uv-element-block">
  188.                             <button type="submit" id="create-ticket-btn" class="uv-btn">{{ 'Create Ticket'|trans }}</button>
  189.                         </div>
  190.                     </form>
  191.                 </div>
  192.             </section>
  193.         </div>
  194.     </div>
  195.         {% if user_service.isfileExists('apps/uvdesk/form-component') %}
  196.             {{ include('@_uvdesk_extension_uvdesk_form_component/CustomFields/customFieldValidation.html.twig') }} 
  197.         {% endif %}
  198. {% endblock %}
  199. {% block footer %}
  200.     
  201.     {% set isTicketViewPage = (app.user.id is defined ? true : false) %}
  202.     {{ parent() }}
  203.     {% if recaptchaDetail and recaptchaDetail.isActive == true %}
  204.         <script src='https://www.google.com/recaptcha/api.js'></script>
  205.     {% endif %}
  206.     {{ include("@UVDeskSupportCenter/Templates/tinyMCE.html.twig") }}
  207.     {{ include('@UVDeskCoreFramework/Templates/attachment.html.twig') }}
  208.     <script type="text/javascript">
  209.     {% if user_service.isfileExists('apps/uvdesk/form-component') == false %}
  210.     customFieldValidation = {};
  211.     {% endif %}
  212.         $(function () {
  213.         sfTinyMce.init({
  214.             height: '155px',
  215.             selector : '#create-reply',
  216.             images_upload_url: "",
  217.             setup: function(editor) {
  218.             },
  219.             plugins: [
  220.             ],
  221.             toolbar: '| undo redo | bold italic forecolor ',
  222.         });
  223.             {% if(removeMe is defined) %}
  224.                 $.each({{ removeMe | json_encode |raw }}, function(key, value){
  225.                     $('label[for="' + value + '"]').parent().hide();
  226.                 });
  227.             {% endif %}
  228.             $('.uv-header-date').datetimepicker({
  229.                 format: 'YYYY-MM-DD',
  230.             });
  231.             $('.uv-header-time').datetimepicker({
  232.                 format: 'LT',
  233.             });
  234.             $('.uv-header-datetime').datetimepicker({
  235.                 format: 'YYYY-MM-DD H:m:s'
  236.             });
  237.             var CreateTicketModel = Backbone.Model.extend({
  238.                 idAttribute : "id",
  239.                 defaults : {
  240.                     path : "",
  241.                 },
  242.                 validation: _.extend(customFieldValidation, {
  243.                     {% if not isTicketViewPage %}
  244.                         'name' : {
  245.                             required : true,
  246.                             msg : '{{ "This field is mandatory"|trans }}'
  247.                         },
  248.                         'from' :
  249.                         [{
  250.                             required : true,
  251.                             msg : '{{ "This field is mandatory"|trans }}'
  252.                         },{
  253.                             pattern : 'email',
  254.                             msg : '{{ "Email address is invalid"|trans }}'
  255.                         }],
  256.                     {% endif %}
  257.                     'type' : {
  258.                         required : true,
  259.                         msg : '{{ "This field is mandatory"|trans }}'
  260.                     },
  261.                     'subject' : {
  262.                         required : true,
  263.                         msg : '{{ "This field is mandatory"|trans }}'
  264.                     },
  265.                     'reply' : {
  266.                         fn: function(value) {
  267.                             if(!tinyMCE.get("uv-edit-create-thread"))
  268.                                 return false;
  269.                             var html = tinyMCE.get("uv-edit-create-thread").getContent();
  270.                             if(app.appView.stripHTML(html) != '') {
  271.                                 return false;
  272.                             }
  273.                             return true;
  274.                         },
  275.                         msg : '{{ "This field is mandatory"|trans }}'
  276.                     },
  277.                     {% if recaptchaDetail and recaptchaDetail.isActive == true %}
  278.                         'g-recaptcha-response' : {
  279.                             fn: function(value) {
  280.                                 if(grecaptcha.getResponse().length > 0)
  281.                                     return false;
  282.                                 else
  283.                                     return true;
  284.                             },
  285.                             msg : '{{ "Please select CAPTCHA"|trans }}'
  286.                         }
  287.                     {% endif %}
  288.                 }),
  289.                 urlRoot : "{{ path('helpdesk_customer_create_ticket') }}"
  290.             });
  291.             var CreateTicketForm = Backbone.View.extend({
  292.                 initialize : function() {
  293.                     Backbone.Validation.bind(this);
  294.                     var jsonContext = JSON.parse('{{ errors is defined ? errors|raw : "{}"  }}');
  295.                     for (var field in jsonContext) {
  296.                         Backbone.Validation.callbacks.invalid(this, field, jsonContext[field], 'input');
  297.                     }
  298.                 },
  299.                 events : {
  300.                     'click #create-ticket-btn' : "saveTicket",
  301.                     'change #type' : "updateCustomFields",
  302.                     'blur input:not(input[type=file]), textarea, select, checkbox': 'formChanegd',
  303.                     'change input[type=file]': 'formChanegd',
  304.                 },
  305.                 formChanegd: function(e) {
  306.                     this.model.set(Backbone.$(e.currentTarget).attr('name'), Backbone.$(e.currentTarget).val())
  307.                     this.model.isValid([Backbone.$(e.currentTarget).attr('name')])
  308.                 },
  309.                 saveTicket : function (e) {
  310.                     e.preventDefault();
  311.                     var currentElement = Backbone.$(e.currentTarget);
  312.                     var data = currentElement.closest('form').serializeObject();
  313.                     this.model.set(data);
  314.                     if(this.model.isValid(true)) {
  315.                         $('#create-ticket-form').submit();
  316.                         $('form').find('#create-ticket-btn').attr('disabled', 'disabled');
  317.                     }
  318.                 },
  319.                 updateCustomFields : function (e) {
  320.                     var dependentFields = e.currentTarget.value;
  321.                     this.$('.dependent').hide();
  322.                     this.$('.dependency' + dependentFields).show();
  323.                 }
  324.             });
  325.             var createticketForm = new CreateTicketForm({
  326.                 el : $("#create-ticket-form"),
  327.                 model : new CreateTicketModel()
  328.             });
  329.         });
  330.     </script>
  331. {% endblock %}