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.     {% elseif user_service.isfileExists('apps/uvdesk/custom-fields') %}
  198.         {{ include('@_uvdesk_extension_uvdesk_custom_fields/CustomFields/customFieldValidation.html.twig') }} 
  199.     {% endif %}
  200. {% endblock %}
  201. {% block footer %}
  202.     
  203.     {% set isTicketViewPage = (app.user.id is defined ? true : false) %}
  204.     {{ parent() }}
  205.     {% if recaptchaDetail and recaptchaDetail.isActive == true %}
  206.         <script src='https://www.google.com/recaptcha/api.js'></script>
  207.     {% endif %}
  208.     {{ include("@UVDeskSupportCenter/Templates/tinyMCE.html.twig") }}
  209.     {{ include('@UVDeskCoreFramework/Templates/attachment.html.twig') }}
  210.     <script type="text/javascript">
  211.     {% if user_service.isfileExists('apps/uvdesk/form-component') == false %}
  212.     customFieldValidation = {};
  213.     {% endif %}
  214.         $(function () {
  215.         sfTinyMce.init({
  216.             height: '155px',
  217.             selector : '#create-reply',
  218.             images_upload_url: "",
  219.             setup: function(editor) {
  220.             },
  221.             plugins: [
  222.             ],
  223.             toolbar: '| undo redo | bold italic forecolor ',
  224.         });
  225.             {% if(removeMe is defined) %}
  226.                 $.each({{ removeMe | json_encode |raw }}, function(key, value){
  227.                     $('label[for="' + value + '"]').parent().hide();
  228.                 });
  229.             {% endif %}
  230.             $('.uv-header-date').datetimepicker({
  231.                 format: 'YYYY-MM-DD',
  232.             });
  233.             $('.uv-header-time').datetimepicker({
  234.                 format: 'LT',
  235.             });
  236.             $('.uv-header-datetime').datetimepicker({
  237.                 format: 'YYYY-MM-DD H:m:s'
  238.             });
  239.             var CreateTicketModel = Backbone.Model.extend({
  240.                 idAttribute : "id",
  241.                 defaults : {
  242.                     path : "",
  243.                 },
  244.                 validation: _.extend(customFieldValidation, {
  245.                     {% if not isTicketViewPage %}
  246.                         'name' : {
  247.                             required : true,
  248.                             msg : '{{ "This field is mandatory"|trans }}'
  249.                         },
  250.                         'from' :
  251.                         [{
  252.                             required : true,
  253.                             msg : '{{ "This field is mandatory"|trans }}'
  254.                         },{
  255.                             pattern : 'email',
  256.                             msg : '{{ "Email address is invalid"|trans }}'
  257.                         }],
  258.                     {% endif %}
  259.                     'type' : {
  260.                         required : true,
  261.                         msg : '{{ "This field is mandatory"|trans }}'
  262.                     },
  263.                     'subject' : {
  264.                         required : true,
  265.                         msg : '{{ "This field is mandatory"|trans }}'
  266.                     },
  267.                     'reply' : {
  268.                         fn: function(value) {
  269.                             if(!tinyMCE.get("uv-edit-create-thread"))
  270.                                 return false;
  271.                             var html = tinyMCE.get("uv-edit-create-thread").getContent();
  272.                             if(app.appView.stripHTML(html) != '') {
  273.                                 return false;
  274.                             }
  275.                             return true;
  276.                         },
  277.                         msg : '{{ "This field is mandatory"|trans }}'
  278.                     },
  279.                     {% if recaptchaDetail and recaptchaDetail.isActive == true %}
  280.                         'g-recaptcha-response' : {
  281.                             fn: function(value) {
  282.                                 if(grecaptcha.getResponse().length > 0)
  283.                                     return false;
  284.                                 else
  285.                                     return true;
  286.                             },
  287.                             msg : '{{ "Please select CAPTCHA"|trans }}'
  288.                         }
  289.                     {% endif %}
  290.                 }),
  291.                 urlRoot : "{{ path('helpdesk_customer_create_ticket') }}"
  292.             });
  293.             var CreateTicketForm = Backbone.View.extend({
  294.                 initialize : function() {
  295.                     Backbone.Validation.bind(this);
  296.                     var jsonContext = JSON.parse('{{ errors is defined ? errors|raw : "{}"  }}');
  297.                     for (var field in jsonContext) {
  298.                         Backbone.Validation.callbacks.invalid(this, field, jsonContext[field], 'input');
  299.                     }
  300.                 },
  301.                 events : {
  302.                     'click #create-ticket-btn' : "saveTicket",
  303.                     'change #type' : "updateCustomFields",
  304.                     'blur input:not(input[type=file]), textarea, select, checkbox': 'formChanegd',
  305.                     'change input[type=file]': 'formChanegd',
  306.                 },
  307.                 formChanegd: function(e) {
  308.                     this.model.set(Backbone.$(e.currentTarget).attr('name'), Backbone.$(e.currentTarget).val())
  309.                     this.model.isValid([Backbone.$(e.currentTarget).attr('name')])
  310.                 },
  311.                 saveTicket : function (e) {
  312.                     e.preventDefault();
  313.                     var currentElement = Backbone.$(e.currentTarget);
  314.                     var data = currentElement.closest('form').serializeObject();
  315.                     this.model.set(data);
  316.                     if(this.model.isValid(true)) {
  317.                         $('#create-ticket-form').submit();
  318.                         $('form').find('#create-ticket-btn').attr('disabled', 'disabled');
  319.                     }
  320.                 },
  321.                 updateCustomFields : function (e) {
  322.                     var dependentFields = e.currentTarget.value;
  323.                     this.$('.dependent').hide();
  324.                     this.$('.dependency' + dependentFields).show();
  325.                 }
  326.             });
  327.             var createticketForm = new CreateTicketForm({
  328.                 el : $("#create-ticket-form"),
  329.                 model : new CreateTicketModel()
  330.             });
  331.         });
  332.     </script>
  333. {% endblock %}