src/ApplicationBundle/Resources/views/footer/footer_js_codecovers.html.twig line 1

Open in your IDE?
  1. {# <script src="{{ asset('condensed_assets/javascript.js',) }}"></script> #}
  2. {# {{  dump( constant('ApplicationBundle\\Constants\\GeneralConstant::NOTIFICATION_SERVER')) }}; #}
  3. <div class="modal fade" id="endTaskModal" tabindex="-1" aria-labelledby="endTaskModalLabel" aria-hidden="true">
  4.     <div class="modal-dialog">
  5.         <div class="modal-content">
  6.             <div class="modal-header">
  7.                 <h5 class="modal-title" id="endTaskModalLabel">Confirm Task Completion</h5>
  8.             </div>
  9.             <div class="modal-body">
  10.                 <p>Are you sure you want to end the current task?</p>
  11.                 
  12.                 <div class="form-check">
  13.                     <input class="form-check-input" type="radio" name="taskStatus" id="taskCompleted" value="completed" checked>
  14.                     <label class="form-check-label" for="taskCompleted">
  15.                         Completed
  16.                     </label>
  17.                 </div>
  18.                 <div class="form-check">
  19.                     <input class="form-check-input" type="radio" name="taskStatus" id="taskPending" value="pending">
  20.                     <label class="form-check-label" for="taskPending">
  21.                         Pending
  22.                     </label>
  23.                 </div>
  24.                 
  25.                 <div class="mb-3" id="feedbackInput" style="display: none;">
  26.                     <label for="taskFeedback" class="form-label">Feedback (optional):</label>
  27.                     <textarea id="taskFeedback" class="form-control" rows="3" placeholder="Enter feedback here..."></textarea>
  28.                 </div>
  29.             </div>
  30.             <div class="modal-footer">
  31.                 <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
  32.                 <button type="button" class="btn btn-danger" id="confirmEndTask">End Task</button>
  33.             </div>
  34.         </div>
  35.     </div>
  36. </div>
  37. <script>
  38.     var socketKeepAliveCall = {};
  39.     var lastActivityTs = 0;
  40.     var socket = '';
  41.     var socket_user_name = '{{ (session[UserConstants.USER_NAME] is defined)?session[UserConstants.USER_NAME]:'' }}';
  42.     var socket_user_id = '{{ (session[UserConstants.USER_APP_ID] is defined)?session[UserConstants.USER_APP_ID]:'' }}_{{ (session[UserConstants.USER_NAME] is defined)?session[UserConstants.USER_ID]:'' }}';
  43.     var socket_company_id = '{{ (session[UserConstants.USER_COMPANY_ID] is defined)?session[UserConstants.USER_COMPANY_ID]:'' }}';
  44.     var socket_app_id = '{{ (session[UserConstants.USER_APP_ID] is defined)?session[UserConstants.USER_APP_ID]:'' }}';
  45.     var socket_user_positions ={{ (session[UserConstants.USER_POSITION_LIST] is defined)?session[UserConstants.USER_POSITION_LIST]|json_encode()|raw:"\"[]\"" }};
  46.     var current_user_user_id = {{ session[UserConstants.USER_ID] is defined? session[UserConstants.USER_ID]:0 }};
  47.     var socket_user_session_token = '{{ session['token'] is defined? session['token']:'_GEN_' }}';
  48.     function check_filters_default() {
  49.         
  50.         $('.filter_this').hide()
  51.         $('.filter_with_this').each(function () {
  52.             if ($(this).attr('type') == 'checkbox' && $(this).prop('checked') == false)
  53.                 return;
  54.             if ($(this).attr('type') == 'radio' && $(this).is(':checked') == false)
  55.                 return;
  56.             var selector_name = '.filter_' + ($(this).attr('id')) + '_' + $(this).val();
  57.             $(selector_name).show()
  58.         })
  59.     }
  60.     function addCommas(nStr) {
  61.         nStr += '';
  62.         x = nStr.split('.');
  63.         x1 = x[0];
  64.         x2 = x.length > 1 ? '.' + x[1] : '';
  65.         var rgx = /(\d+)(\d{3})/;
  66.         while (rgx.test(x1)) {
  67.             x1 = x1.replace(rgx, '$1' + ',' + '$2');
  68.         }
  69.         return x1 + x2;
  70.     }
  71.     {% if session[UserConstants.USER_ID] is defined %}
  72.     var currentTaskId ={{ session[UserConstants.USER_CURRENT_TASK_ID] is defined? (session[UserConstants.USER_CURRENT_TASK_ID] is null?'0':session[UserConstants.USER_CURRENT_TASK_ID]): '0' }};
  73.     var currentPlanningItemId ={{ session[UserConstants.USER_CURRENT_PLANNING_ITEM_ID] is defined?
  74.     (session[UserConstants.USER_CURRENT_PLANNING_ITEM_ID] is null?'0':session[UserConstants.USER_CURRENT_PLANNING_ITEM_ID]): '0' }};
  75.     var currentLastStartTs = 0;
  76.     var bulkApproveFlag = 0;
  77.     var pendingApprovalTable={};
  78.     
  79.     function refreshPendingTaskDivOld() {
  80.         var pika_ind_id = '_NOPE_'
  81.         $.ajax({
  82.             url: BaseURL + "get_pending_approval_list_for_user",
  83.             type: 'POST',
  84.             dataType: 'json',
  85.             data: {},
  86.             error: function () {
  87.             },
  88.             success: function (res) {
  89.                 $('.pending_task_div .body').html('');
  90.                 if (res.total_pending_task_count == 0) {
  91.                     $('.pending_task_div .body').html(
  92.                         '<blockquote class="m-b-25"><p>Great! No Pending Tasks</p><footer><cite title="Source Title">The News Bee</cite></footer></blockquote>'
  93.                     )
  94.                     $('.pending_task_trigger .body .alert-callout').html('');
  95.                     $('.pending_task_trigger .body .alert-callout').html(
  96.                         '         <strong class="pull-right text-warning text-lg">' +
  97.                         '' + (res.total_pending_task_count) + '' +
  98.                         ' <i class="material-icons">playlist_add_check</i></strong> ' +
  99.                         '<strong class="text-xl number count-to-amount-specific" data-from="0" ' +
  100.                         'data-to="' + (res.total_pending_task_count) + '" ' +
  101.                         'data-speed="1000" data-fresh-interval="20">' + (res.total_pending_task_count) + ' </strong> <br> ' +
  102.                         '<span class="opacity-50">PENDING TASKS</span>'
  103.                     );
  104.                 } else {
  105.                         $('.pending_task_trigger .body .alert-callout').html('');
  106.                         $('.pending_task_trigger .body .alert-callout').html(
  107.                             '         <strong class="pull-right text-warning text-lg">' +
  108.                             '' + (res.total_pending_task_count) + '' +
  109.                             ' <i class="material-icons">playlist_add_check</i></strong> ' +
  110.                             '<strong class="text-xl number count-to-amount-specific" data-from="0" ' +
  111.                             'data-to="' + (res.total_pending_task_count) + '" ' +
  112.                             'data-speed="1000" data-fresh-interval="20">' + (res.total_pending_task_count) + ' </strong> <br> ' +
  113.                             '<span class="opacity-50">PENDING TASKS</span>'
  114.                         );
  115.                     
  116.                     for (var koko = 0; koko < res.applicable_entities.length; koko++) {
  117.                         var applicableEntityId = 1*res.applicable_entities[koko];
  118.                         var ind = 0;
  119.                         $('.pending_task_div .body').append('<h4>'+res.entity_list_details[applicableEntityId]['entity_alias']+'</h4>'+
  120.                             '<div class="table-responsive"><table class="table table-hover table-condensed dashboard-task-infos app_pending_for_'+applicableEntityId+'">' +
  121.                             '<thead><tr>' +
  122.                             '<th style="width: 5%;">#</th>' +
  123.                             '<th style="width: 20%;">Document</th>' +
  124.                             '<th style="width: 20%;">Created By</th>' +
  125.                             '<th style="width: 10%;">Status</th>' +
  126.                             '<th style="width: 15%;text-align: right;">Amount</th>' +
  127.                             '<th style="width: 10%;text-align: right;">Action</th>' +
  128.                             '</tr></thead><tbody></tbody></table> </div>'
  129.                         )
  130.                         
  131.                         var pending_approval_list = res.grouped_approval_list[applicableEntityId];
  132.                         for (var lipi = 0; lipi < pending_approval_list.length; lipi++) {
  133.                             var item = pending_approval_list[lipi];
  134.                             ind = ind + 1;
  135.                             $('.pending_task_div .body .dashboard-task-infos.app_pending_for_'+applicableEntityId+' tbody').append(
  136.                                 '<tr class="pending_row_' + item.entity + '_' + item.entityId + '">' +
  137.                                 '<td>' + ind + '</td>' +
  138.                                 '<td>' + item.documentHash + '</td>' +
  139.                                 '<td>' + item.createdBy + '</td>' +
  140.                                 '<td><span class="label bg-orange" style="background: orange;">'+(item.required==2?'Override':'Pending Approval')+'</span></td>' +
  141.                                 // '<td>' + item.entityAlias + '</td>' +
  142.                                 '<td style="text-align: right;">' + (item.amount == '' ? '' : addCommas((1 * item.amount).toFixed(2))) + '</td>' +
  143.                                 '<td style="text-align: right;">' +
  144.                                 '<div class="btn-group ">' +
  145.                                 '<button type="button"' +
  146.                                 'class="btn ink-reaction btn-sm btn-primary dropdown-toggle  waves-effect"' +
  147.                                 'data-toggle="dropdown">' +
  148.                                 'Action <i class="fa fa-caret-down"></i>' +
  149.                                 '</button>' +
  150.                                 '<ul class="dropdown-menu animation-expand"' +
  151.                                 'style=""' +
  152.                                 'role="menu">' +
  153.                                 '<li><a href="' + item.viewPathAbs + '"> View</a></li> ' +
  154.                                 '<li><a href="#" class="trigger_approval_btn"' +
  155.                                 'data-toggle="modal"' +
  156.                                 'data-entity="' + item.entity + '"' +
  157.                                 'data-entity-id="' + item.entityId + '"' +
  158.                                 'data-approval-id="' + item.approvalId + '"' +
  159.                                 'data-target="#approveDocument">Approve</a></li>' +
  160.                                 '</ul>' +
  161.                                 '</div>' +
  162.                                 '</td>' +
  163.                                 '</tr>');
  164.                         }
  165.                     }
  166.                     $('.count-to-amount-specific').countTo(
  167.                         {
  168.                             formatter: function (value, options) {
  169.                                 return abbreviateNumber(value.toFixed(0));
  170.                             }
  171.                         }
  172.                     );
  173.                 }
  174.             }
  175.         });
  176.     }
  177.     function refreshPendingTaskDiv() {
  178.         var pika_ind_id = '_NOPE_'
  179.         $.ajax({
  180.             url: BaseURL + "get_pending_approval_list_for_user",
  181.             type: 'POST',
  182.             dataType: 'json',
  183.             data: {
  184.                 entity: (typeof filterApprovalEntityId !== 'undefined' ? filterApprovalEntityId:null)
  185.             },
  186.             error: function () {
  187.             },
  188.             success: function (res) {
  189.                 
  190.                 $('.pending_task_div .body').html('');
  191.                 if (res.total_pending_task_count == 0) {
  192.                     $('.pending_task_div .body').html(
  193.                         '<blockquote class="m-b-25"><p>Great! No Pending Tasks</p><footer><cite title="Source Title">The News Bee</cite></footer></blockquote>'
  194.                     )
  195.                     $('.pending_task_trigger .body .alert-callout').html('');
  196.                     $('.pending_task_trigger .body .alert-callout').html(
  197.                         '         <strong class="pull-right text-warning text-lg">' +
  198.                         '' + (res.total_pending_task_count) + '' +
  199.                         ' <i class="material-icons">playlist_add_check</i></strong> ' +
  200.                         '<strong class="text-xl number count-to-amount-specific" data-from="0" ' +
  201.                         'data-to="' + (res.total_pending_task_count) + '" ' +
  202.                         'data-speed="1000" data-fresh-interval="20">' + (res.total_pending_task_count) + ' </strong> <br> ' +
  203.                         '<span class="opacity-50">PENDING TASKS</span>'
  204.                     );
  205.                 } else {
  206.                     $('.pending_task_trigger .body .alert-callout').html('');
  207.                     $('.pending_task_trigger .body .alert-callout').html(
  208.                         '         <strong class="pull-right text-warning text-lg">' +
  209.                         '' + (res.total_pending_task_count) + '' +
  210.                         ' <i class="material-icons">playlist_add_check</i></strong> ' +
  211.                         '<strong class="text-xl number count-to-amount-specific" data-from="0" ' +
  212.                         'data-to="' + (res.total_pending_task_count) + '" ' +
  213.                         'data-speed="1000" data-fresh-interval="20">' + (res.total_pending_task_count) + ' </strong> <br> ' +
  214.                         '<span class="opacity-50">PENDING TASKS</span>'
  215.                     );
  216.                     $('.pending_task_div .body').append(
  217.                         '<div class="table-responsive"><table class="table table-hover generic_document_list_table table-condensed dashboard-task-infos app_pending_for_all">' +
  218.                         '<thead><tr>' +
  219.                         '<th style="width: 5%;">&nbsp;</th>' +
  220.                         '<th style="width: 5%;">#</th>' +
  221.                         '<th style="width: 20%;">Type</th>' +
  222.                         '<th style="width: 20%;">Document</th>' +
  223.                         '<th style="width: 20%;">Note</th>' +
  224.                         '<th style="width: 20%;">Created By</th>' +
  225.                         '<th style="width: 10%;">Status</th>' +
  226.                         '<th style="width: 15%;text-align: right;">Amount</th>' +
  227.                         '<th style="width: 10%;text-align: right;">Action</th>' +
  228.                         '</tr></thead><tbody></tbody></table> </div>'
  229.                     )
  230.                     for (var koko = 0; koko < res.applicable_entities.length; koko++) {
  231.                         var applicableEntityId = 1*res.applicable_entities[koko];
  232.                         var ind = 0;
  233.                         var pending_approval_list = res.grouped_approval_list[applicableEntityId];
  234.                         for (var lipi = 0; lipi < pending_approval_list.length; lipi++) {
  235.                             var item = pending_approval_list[lipi];
  236.                             ind = ind + 1;
  237.                             $('.pending_task_div .body .dashboard-task-infos.app_pending_for_all tbody').append(
  238.                                 '<tr class="pending_row_' + item.entity + '_' + item.entityId + '">' +
  239.                                 '<td><label class="checkbox-inline checkbox-styled checkbox-datatable-selector "><input type="checkbox" value="1" ><span></span></label></td>' +
  240.                                 '<td>' + item.entity +'-'+item.entityId+ '</td>' +
  241.                                 '<td>'+res.entity_list_details[applicableEntityId]['entity_alias']+'</td>' +
  242.                                 '<td>' + item.documentHash + '</td>' +
  243.                                 '<td>' + item.note + '</td>' +
  244.                                 '<td>' + ((item.createdUserImage== '' || item.createdUserImage ==null)? '':'<button type="button" style="' +
  245.                                 'background-image:url({{ url('dashboard') }}' + item.createdUserImage + ')' +
  246.                                 '" class="btn name_icon btn-default btn-sm" data-employee-name="' + item.createdBy + '" > <span style="display:none;">' + item.createdBy + '</span>') +
  247.                                 '</button>' + '</td>' +
  248.                                 '<td>'+(item.required==2?'<button class="text_hover_icon btn btn-default btn-sm style-accent" data-text="Override" ><i class="fa fa-gavel"></i></button>':'<button class="text_hover_icon btn btn-default btn-sm style-warning" data-text="Pending" ><i class="fa fa-exclamation"></i></button>')+'</td>' +
  249.                                 '<td style="text-align: right;">' + (item.amount == '' ? '' : addCommas((1 * item.amount).toFixed(2))) + '</td>' +
  250.                                 '<td style="text-align: right;">' +
  251.                                 '<div class="btn-group ">' +
  252.                                 '<button type="button"' +
  253.                                 'class="btn ink-reaction btn-flat btn-sm dropdown-toggle  waves-effect"' +
  254.                                 'data-toggle="dropdown">' +
  255.                                 '<i class="fa fa-edit"></i> Action <i class="fa fa-caret-down"></i>' +
  256.                                 '</button>' +
  257.                                 '<ul class="dropdown-menu animation-expand"' +
  258.                                 'style=""' +
  259.                                 'role="menu">' +
  260.                                 '<li><a href="' + item.viewPathAbs + '"><i class="fa fa-eye"></i> View</a></li> ' +
  261.                                 '<li><a href="#" class="trigger_approval_btn trigger_approval_' + item.entity +'-'+item.entityId+ '"' +
  262.                                 'data-toggle="modal"' +
  263.                                 'data-entity="' + item.entity + '"' +
  264.                                 'data-entity-id="' + item.entityId + '"' +
  265.                                 'data-approval-id="' + item.approvalId + '"' +
  266.                                 'data-target="#approveDocument"><i class="fa fa-check"></i> Approve</a></li>' +
  267.                                 '</ul>' +
  268.                                 '</div>' +
  269.                                 '</td>' +
  270.                                 '</tr>');
  271.                         }
  272.                     }
  273.                     pendingApprovalTable = $('.app_pending_for_all')
  274.                         .DataTable({
  275.                             dom: 'Blfrtip',
  276.                             lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
  277.                             "buttons": {
  278.                                 dom: {
  279.                                     button: {
  280.                                         tag: 'button',
  281.                                         className: 'dt-gen-button btn btn-sm waves-effect bg-grey'
  282.                                     }
  283.                                 },
  284.                                 "buttons": [
  285.                                     {
  286.                                         "extend": 'selectAll',
  287.                                         "text": 'select all'
  288.                                     },
  289.                                     {
  290.                                         "text": '<i class="fa fa-check"></i> APPROVE SELECTED',
  291.                                         "attr": {
  292.                                             "id": 'bulk_approval_action',
  293.                                             "className": 'bg-blue',
  294.                                         }
  295.                                     }
  296.                                 ]
  297.                             },
  298.                             "select": {
  299.                                 style: 'multi',
  300.                                 selector: 'td:first-child .checkbox-inline>input:checkbox'
  301.                             },
  302.                             "order": [[1, "desc"]],
  303.                             'columnDefs': [
  304.                                 {
  305.                                     responsivePriority: 1,
  306.                                     targets: [0, 1, -1]
  307.                                 },
  308.                                 {
  309.                                     visible: false,
  310.                                     targets: [1]
  311.                                 },
  312.                                 {
  313.                                     responsivePriority: 2,
  314.                                     targets: [2, 3]
  315.                                 },
  316.                                 {
  317.                                     orderable: false,
  318.                                     targets: 0,
  319.                                 },
  320.                                 {
  321.                                     className: "trans_amount",
  322.                                     targets: [6]
  323.                                 },
  324.                                 {
  325.                                     className: "align_center",
  326.                                     targets: [1,2,3,4,5,7]
  327.                                 }
  328.                             ],
  329.                             
  330.                             drawCallback: function (settings) {
  331.                                 $('.text_hover_icon').each(function (ind, elem) {
  332.                                     $(elem).popover({
  333.                                         content: $(elem).data('text'),
  334.                                         trigger: 'hover',
  335.                                         placement: 'top',
  336.                                         container: 'body',
  337.                                         html: true
  338.                                     });
  339.                                 });
  340.                                 $('.name_icon').each(function (ind, elem) {
  341.                                     $(elem).popover({
  342.                                         content: $(elem).data('employeeName'),
  343.                                         trigger: 'hover',
  344.                                         placement: 'top',
  345.                                         container: 'body',
  346.                                         html: true
  347.                                     });
  348.                                 });
  349.                             },
  350.                             initComplete: function () {
  351.                                 this.api().columns().every(function (col_ind) {
  352.                                     var column = this;
  353.                                     var exclude_col = [0,1];
  354.                                     if (exclude_col.indexOf(col_ind) > -1) {
  355.                                     } else {
  356.                                         var search_cont = $('<div class="form-line"></div>').appendTo($(column.header()))
  357.                                         var search_box = $('<input type="text" class="form-control ">')
  358.                                             .appendTo(search_cont)
  359.                                             .bindWithDelay('keyup change', function () {
  360.                                                 var val = $.fn.dataTable.util.escapeRegex(
  361.                                                     $(this).val()
  362.                                                 );
  363.                                                 column
  364.                                                     .search(val ? val : '', true, false)
  365.                                                     .draw();
  366.                                             }, 1000);
  367.                                     }
  368.                                 });
  369.                             }
  370.                         });
  371.                     $('.count-to-amount-specific').countTo(
  372.                         {
  373.                             formatter: function (value, options) {
  374.                                 return abbreviateNumber(value.toFixed(0));
  375.                             }
  376.                         }
  377.                     );
  378.                 }
  379.             }
  380.         });
  381.     }
  382.     
  383.     function RefreshAppListOnMenu() {
  384.         $.post('{{ url('get_app_list_from_central_server') }}', {
  385.             appIds: {{ session[UserConstants.USER_APP_ID_LIST] is defined?(session[UserConstants.USER_APP_ID_LIST]|json_encode|raw ): '[]' }},
  386.         })
  387.             .done(function (data) {
  388.                 var dataArray = $.map(data, function (value, index) {
  389.                     return [value];
  390.                 });
  391.                 $('.this_is_company').remove()
  392.                 for (var koka = dataArray.length - 1; koka >= 0; koka--) {
  393.                     var currAppData = dataArray[koka]
  394.                     $('.company_list_here').after(
  395.                         '<li class="this_is_company"> ' +
  396.                         '<a href="{{ url('change_company_dashboard') }}/1"> <i class="fa fa-building"></i> ' +
  397.                         (currAppData['name'].length > 15 ? (currAppData['name'].slice(0, 15) + '...') : currAppData['name']) + '</a>' +
  398.                         ' </li>')
  399.                 }
  400.             })
  401.             .fail(function () {
  402.             });
  403.     }
  404.     function ListAvailableTaskOnMenu() {
  405.         
  406.         var query = '_EMPTY_';
  407.         var pika_ind_id = '_NOPE_'
  408.         $.ajax({
  409.             url: url_path("select_data_ajax"),
  410.             type: 'POST',
  411.             dataType: 'json',
  412.             data: {
  413.                 query: query,
  414.                 tableName: "planning_item",
  415.                 valueField: "id",
  416.                 textField: "item_alias",
  417.                 entity_group: 0,
  418.                 selectorId: pika_ind_id,
  419.                 isMultiple: 0,
  420.                 dataId: pika_ind_id,
  421.                 andConditions: [],
  422.                 andOrConditions: [
  423.                     {type: "like", field: "name", value: query},
  424.                 ],
  425.                 mustConditions: [
  426.                     {
  427.                         type: "in",
  428.                         field: "assigned_to",
  429.                         value: [{{ session[UserConstants.USER_EMPLOYEE_ID] is defined?session[UserConstants.USER_EMPLOYEE_ID]: '-1' }},-1]
  430.                     },
  431.                     {type: "!=", field: "has_child", value: 1},
  432.                 ],
  433.                 joinTableData: [
  434.                     {
  435.                         tableName: "project",
  436.                         joinFieldPrimary: "project_id",
  437.                         joinOn: 'project_id',
  438.                         tableJoinType: 'left join',
  439.                         selectFieldList: [
  440.                             'project_name'
  441.                         ]
  442.                     },
  443.                     {
  444.                         tableName: "task_log",
  445.                         joinFieldPrimary: "id",
  446.                         joinOn: 'planning_item_id',
  447.                         tableJoinType: 'left join',
  448.                         fieldJoinType: '=',
  449.                         selectPrefix: 'task_',
  450.                         joinAndConditions: [
  451.                             {type: "=", field: "working_status", value: 1},
  452.                             {type: "=", field: "user_id", value: {{ session[UserConstants.USER_ID] is defined?session[UserConstants.USER_ID]: '-1' }}},
  453.                         ],
  454.                         selectFieldList: [
  455.                             'id', 'actual_start_ts', 'working_status'
  456.                         ]
  457.                     },
  458.                 ],
  459.                 convertToObject: [
  460.                 ],
  461.                 skipDefaultCompanyId: 1
  462.             },
  463.             error: function () {
  464.             },
  465.             success: function (res) {
  466.                 $('.assigned_task_list_here').empty()
  467.                 var project_ids = [0]
  468.                 var div_by_project = {
  469.                     0: {
  470.                         project_name: 'General',
  471.                         divList: []
  472.                     }
  473.                 };
  474.                 console.log(res.data)
  475.                 
  476.                 for (var koka = 0; koka < res.data.length; koka++) {
  477.                     var currTaskData = res.data[koka]
  478.                     if (currTaskData['task_working_status'] == 1 && currTaskData['task_id'] == currentTaskId) {
  479.                         currentLastStartTs = currTaskData['task_actual_start_ts']
  480.                     }
  481.                     if (currTaskData['project_id'] == null || currTaskData['project_id'] == '')
  482.                         currTaskData['project_id'] = 0;
  483.                     
  484.                     if (typeof div_by_project[currTaskData['project_id']] !== 'undefined') {
  485.                     } else {
  486.                         project_ids.push(currTaskData['project_id'])
  487.                         div_by_project[currTaskData['project_id']] = {
  488.                             project_name: currTaskData['project_name'],
  489.                             divList: []
  490.                         }
  491.                     }
  492.                     div_by_project[currTaskData['project_id']]['divList'].push('<li class="this_is_task task_planning_item_id_' + currTaskData['id'] + '"> ' +
  493.                         '<a href="#" data-pid="' + currTaskData['id'] + '"> <i class="fa fa-building"></i> ' +
  494.                         (currTaskData['item_alias'].length > 150 ? (currTaskData['item_alias'].slice(0, 150) + '...') : currTaskData['item_alias']) + '' +
  495.                         '</a>' +
  496.                         ' </li>')
  497.                 }
  498.                 for (var koka = 0; koka < project_ids.length; koka++) {
  499.                     var prj_id = project_ids[koka];
  500.                     $('.assigned_task_list_here').append(
  501.                         '<li class="dropdown-header ">' + div_by_project[prj_id]['project_name'] + '</li>'
  502.                     );
  503.                     for (var loka = 0; loka < div_by_project[prj_id]['divList'].length; loka++) {
  504.                         $('.assigned_task_list_here').append(
  505.                             div_by_project[prj_id]['divList'][loka]
  506.                         );
  507.                     }
  508.                 }
  509.                 
  510.                 SetActiveTaskOnMenu(currentTaskId, currentPlanningItemId, currentLastStartTs);
  511.             }
  512.         });
  513.     }
  514.     function ChangeActiveTaskOnMenu(taskId, planningItemId) {
  515.         StartNewTaskOnMenu(taskId, planningItemId);
  516.     }
  517.     function SetActiveTaskOnMenu(taskId, planningItemId, actualStartTs) {
  518.         
  519.         actualStartTs = actualStartTs || 0;
  520.         $('.this_is_task').removeClass('active');
  521.         if (planningItemId != 0 && planningItemId != '') {
  522.             $('.task_planning_item_id_' + planningItemId).addClass('active');
  523.             $('.assigned_task_list_cont .profile-info').html($('.task_planning_item_id_' + planningItemId + ' a').text() + '' + '<small>' +
  524.                 '<b class="clock_update" data-start-ts="' + actualStartTs + '">00:00</b></small>')
  525.         } else {
  526.             $('.assigned_task_list_cont .profile-info').html('Select Task <small>Unselected</small>')
  527.         }
  528.     }
  529.     function newSubmenuClose ()
  530.     {
  531.         $('.offcanvas-pane').removeClass('active');
  532.         $('.offcanvas-pane').css({
  533.             '-webkit-transform': '',
  534.             '-ms-transform': '',
  535.             '-o-transform': '',
  536.             'transform': ''
  537.         });
  538.     }
  539.     function newSubmenuOpen (id) {
  540.         if( $('#offcanvas-menu').hasClass('active'))
  541.         {
  542.             newSubmenuClose();
  543.             return 0;
  544.         }
  545.         else
  546.         {
  547.             newSubmenuClose();
  548.         }
  549.         $('#offcanvas-menu').addClass('active');
  550.         var width =$('#offcanvas-menu').width();
  551.         if (width > $(document).width()) {
  552.             width = $(document).width() - 8;
  553.             $('#offcanvas-menu.active').css({'width': width});
  554.         }
  555.         var translate = 'translate(' + width + 'px, 0)';
  556.         $('#offcanvas-menu.active').css({
  557.             '-webkit-transform': translate,
  558.             '-ms-transform': translate,
  559.             '-o-transform': translate,
  560.             'transform': translate
  561.         });
  562.     };
  563.     
  564.     function EndCurrentTaskOnMenu() {
  565.     
  566.         $('#endTaskModal').modal('show');
  567.         $('input[name="taskStatus"]').on('change', function() {
  568.             if ($('#taskPending').is(':checked')) {
  569.                 $('#feedbackInput').show();
  570.             } else {
  571.                 $('#feedbackInput').hide();
  572.             }
  573.         });
  574.         
  575.         $('#confirmEndTask').off('click').on('click', function () {
  576.             var feedback = $('#taskFeedback').val().trim();
  577.             var taskStatus = $('input[name="taskStatus"]:checked').val();
  578.             if (taskStatus === 'completed') {
  579.                 feedback = 'Completed';
  580.             }
  581.             $('#endTaskModal').modal('hide');
  582.             executeEndTask(feedback, taskStatus);
  583.         });
  584.     }
  585.     
  586.     function executeEndTask(feedback, taskStatus) {
  587.         var curr_ts = moment().unix();
  588.         var this_user_id = {{ session[UserConstants.USER_ID] }};
  589.         var this_employee_id = {{ session[UserConstants.USER_EMPLOYEE_ID] }};
  590.         
  591.         // Determine the value for the `status` field
  592.         var statusValue = taskStatus === 'completed' ? 1 : 'NULL';
  593.         var feedbackSqlPart = taskStatus === 'pending' ? ', feedback="' + feedback.replace(/"/g, '\\"') + '"' : ', feedback="' + feedback.replace(/"/g, '\\"') + '"';
  594.         
  595.         $.ajax({
  596.             url: BaseURL + "insert_data_ajax_with_session",
  597.             type: 'POST',
  598.             dataType: 'json',
  599.             data: {
  600.                 entity_group: 0,
  601.                 dataToAdd: [
  602.                     {
  603.                         entityName: 'TaskLog',
  604.                         idField: 'id',
  605.                         returnRefIndex: 'id',
  606.                         findId: 0,
  607.                         noCreation: 1,
  608.                         preAdditionalSql: 'UPDATE task_log SET working_status=2, actual_end_ts=' + curr_ts + ', status=' + statusValue + feedbackSqlPart + ' WHERE working_status=1 AND user_id=' + this_user_id + ';',
  609.                         dataFields: [],
  610.                         additionalSql: '',
  611.                     }
  612.                 ]
  613.             },
  614.             error: function () {
  615.                 alert("Error while ending the task!");
  616.             },
  617.             success: function (res) {
  618.                 currentTaskId = 0;
  619.                 currentPlanningItemId = 0;
  620.                 SetActiveTaskOnMenu(currentTaskId, currentPlanningItemId);
  621.             }
  622.         });
  623.     }
  624.     function refreshTaskOnSession() {
  625.         $.ajax({
  626.             url: "{{ url('refresh_task_on_session') }}",
  627.             type: 'POST',
  628.             dataType: 'json',
  629.             data: {
  630.             },
  631.             error: function () {
  632.                 alert("Error while ending the task!");
  633.             },
  634.             success: function (res) {
  635.                 currentTaskId = res.currentTaskId;
  636.                 currentPlanningItemId = res.currentPlanningItemId;
  637.                 currentLastStartTs = res.taskActualStartTs
  638.                 SetActiveTaskOnMenu(currentTaskId, currentPlanningItemId,currentLastStartTs);
  639.             }
  640.         });
  641.     }
  642.     
  643.     function StartNewTaskOnMenu(taskId, planningItemId) {
  644.         
  645.         var curr_ts = moment().unix();
  646.         var this_user_id = {{ session[UserConstants.USER_ID] }};
  647.         
  648.         $.ajax({
  649.             url: BaseURL + "insert_data_ajax_with_session",
  650.             type: 'POST',
  651.             dataType: 'json',
  652.             data: {
  653.                 entity_group: 0,
  654.                 dataToAdd: [
  655.                     {
  656.                         entityName: 'TaskLog',
  657.                         idField: 'id',
  658.                         returnRefIndex: 'id',
  659.                         findId: 0,
  660.                         preAdditionalSql: 'UPDATE task_log set working_status=2, actual_end_ts=' + curr_ts + ' where working_status=1 and user_id= ' + this_user_id + ';;',
  661.                         dataFields: [
  662.                             {field: 'planningItemId', value: planningItemId, type: '_VALUE_'},
  663.                             {field: 'userId', value: this_user_id, type: '_VALUE_'},
  664.                             {field: 'workingStatus', value: 1, type: '_VALUE_'},
  665.                             {field: 'actualStartTs', value: curr_ts, type: '_VALUE_'},
  666.                         ],
  667.                         additionalSql: '',
  668.                     }
  669.                 ]
  670.             },
  671.             error: function () {
  672.             },
  673.             success: function (res) {
  674.                 if (typeof res.updatedDataList[0] !== 'undefined') {
  675.                     var relatedDataCamelcase = res.updatedDataList[0];
  676.                     if (relatedDataCamelcase['status'] !== 1) {
  677.                         currentTaskId = relatedDataCamelcase['id'];
  678.                         currentPlanningItemId = relatedDataCamelcase['planningItemId'];
  679.                         SetActiveTaskOnMenu(currentTaskId, currentPlanningItemId, relatedDataCamelcase['actualStartTs']);
  680.                     }
  681.                 }
  682.             }
  683.         });
  684.     }
  685.     
  686.     {% endif %}
  687. </script>
  688. {% if not include_html is defined %}
  689.     {% set include_html=1 %}
  690.     {% if  app.request.request.get('skipHTML') !='' %}
  691.         {% set include_html= 0 %}
  692.     {% endif %}
  693. {% endif %}
  694. {% if include_html!=1 %}
  695.     <script src="{{ absolute_url(path('dashboard')) }}condensed_assets/javascript_codecovers_minimal.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  696.     <script src="{{ absolute_url(path('dashboard')) }}js/jquery.editable.min.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  697.     <script src="{{ absolute_url(path('dashboard')) }}condensed_assets/moment_timezone.min.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  698.     <script>
  699.         var approveDocumentForwardUserListSelector = {};
  700.         $(document).ready(function () {
  701.             
  702.             if (typeof initiate_comment_box_snippet !== 'undefined') {
  703.                 initiate_comment_box_snippet();
  704.             }
  705.             
  706.             $('.modal').on('shown.bs.modal', function () {
  707.                 $(document).off('focusin.modal');
  708.             });
  709.             if (!window.isElectron) {
  710.                 $('#turn_off_button').hide();
  711.                 $('.close_window').hide();
  712.             }
  713.             $('input[type=radio][name=approvalAction]').change(function () {
  714.                 if (this.value == '3') {
  715.                     $("#forward_doc_div").show()
  716.                 } else {
  717.                     $("#forward_doc_div").hide()
  718.                 }
  719.             });
  720.             $('#forward_doc_check_label').click(function () {
  721.                 $('#forward_doc_check').prop("checked", true);
  722.                 $("#forward_doc_div").show()
  723.             });
  724.         });
  725.     </script>
  726. {% endif %}
  727. {% if include_html==1 %}
  728.     
  729.     <link rel="stylesheet" href="{{ absolute_url(path('dashboard')) }}js/adminbsb/plugins/sweetalert/sweetalert.css">
  730.     <script src="{{ absolute_url(path('dashboard')) }}condensed_assets/javascript_codecovers.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  731.     <script src="{{ absolute_url(path('dashboard')) }}condensed_assets/moment_timezone.min.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  732.     <script src="{{ absolute_url(path('dashboard')) }}condensed_assets/ifvisible.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  733.     <script src="{{ absolute_url(path('dashboard')) }}js/adminbsb/plugins/sweetalert/sweetalert.min.js"></script>
  734.     <script src="{{ absolute_url(path('dashboard')) }}js/jquery.editable.min.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  735.     <script src="{{ asset('jqueryui/jquery-ui.js') }}"></script>
  736.     {% if not new_calendar_version is defined %}
  737.         {% set new_calendar_version=0 %}
  738.     {% endif %}
  739.     {% if new_calendar_version==0 %}
  740.         <script src="{{ asset('js/fullcalendar.min.js') }}"></script>
  741.     {% endif %}
  742.     <style>
  743.         .noty_bar.noty_type_error .noty_message {
  744.             text-align: center;
  745.             padding: 18px 23px;
  746.             width: auto;
  747.             position: relative;
  748.             font-weight: bold;
  749.             font-size: 1.75rem;
  750.         }
  751.     </style>
  752.     <!--
  753.     <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" ></script>
  754.     <script src="https://unpkg.com/popper.js@1.12.6/dist/umd/popper.js" ></script>
  755.     <script src="https://unpkg.com/bootstrap-material-design@4.1.1/dist/js/bootstrap-material-design.js" ></script>
  756.     -->
  757.     <!--<script>$(document).ready(function() { $('body').bootstrapMaterialDesign(); });</script>-->
  758.     <script>
  759.         var generic_head_selectors = {}
  760.         var BUDDYBEE_COIN_BALANCE ={{ session['BUDDYBEE_COIN_BALANCE'] is defined? session['BUDDYBEE_COIN_BALANCE']:0 }};
  761.         {% if app.session.get('devAdminMode') ==1 %}
  762.         BUDDYBEE_COIN_BALANCE++;
  763.         {% endif %}
  764.         function generateFileSmallView(fileDataList, as_thick_box) {
  765.             fileDataList = fileDataList || [];
  766.             as_thick_box = as_thick_box || 0;
  767.             var str = '';
  768.             if (fileDataList.length != 0) {
  769.                 for (var hope = 0; hope < fileDataList.length; hope++) {
  770.                     if ((fileDataList[hope].fileType).indexOf('pdf') != -1 || (fileDataList[hope].fileName).indexOf('pdf') != -1) {
  771.                         str += ' <div class="box-selector sm_th col-md-3 col-sm-6" > <div class="inside"> ' +
  772.                             '<div class="img" href="' + fileDataList[hope].fullPath + '" style="' +
  773.                             'background:url(\' ' + fileDataList[hope].fullPath + '\');' +
  774.                             'height: 50px !important;' +
  775.                             'width: 100%;' +
  776.                             'background-position: center;' +
  777.                             'background-size: contain;' +
  778.                             'background-repeat: no-repeat;"> </div> <h6 class="title" style="height: 2rem;">' + (typeof fileDataList['skipName'] !== 'undefined' ? fileDataList[hope].fileName : '') + '</h6>' +
  779.                             '</div></div>'
  780.                     } else if ((fileDataList[hope].fileType).indexOf('image') != -1 || (fileDataList[hope].fileName).indexOf('jpeg') != -1
  781.                         || (fileDataList[hope].fileName).indexOf('png') != -1 || (fileDataList[hope].fileName).indexOf('jpg') != -1
  782.                     ) {
  783.                         str += ' <div class="box-selector sm_th col-md-3 col-sm-6" > <div class="inside"> ' +
  784.                             '<div class="img" href="' + fileDataList[hope].fullPath + '" style="' +
  785.                             "background:url(' " + fileDataList[hope].fullPath + "');" +
  786.                             'height: 50px !important;' +
  787.                             'width: 100%;' +
  788.                             'background-position: center;' +
  789.                             'background-size: contain;' +
  790.                             'background-repeat: no-repeat;"> </div> <h6 class="title" style="height: 2rem;">' + (typeof fileDataList['skipName'] !== 'undefined' ? fileDataList[hope].fileName : '') + '</h6>' +
  791.                             '</div></div>'
  792.                     } else
  793.                         str += ' <div class="box-selector sm_th col-md-3 col-sm-6" > <div class="inside"> ' +
  794.                             '<div class="img" href="' + fileDataList[hope].fullPath + '" style="' +
  795.                             "background:url('" + fileDataList[hope].fullPath + "');" +
  796.                             'height: 50px !important;' +
  797.                             'width: 100%;' +
  798.                             'background-position: center;' +
  799.                             'background-size: contain;' +
  800.                             'background-repeat: no-repeat;"> </div> <h6 class="title" style="height: 2rem;">' + (typeof fileDataList['skipName'] !== 'undefined' ? fileDataList[hope].fileName : '') + '</h6>' +
  801.                             '</div></div>'
  802.                 }
  803.             }
  804.             
  805.             return str;
  806.         }
  807.         function update_head_selectors(selectorHere, options, returnLatest) {
  808.             selectorHere = selectorHere || '.generic_head_selector';
  809.             returnLatest = returnLatest || 0;
  810.             options = options || {};
  811.             $(selectorHere).not('.selectized').each(function (ind, elem) {
  812.                 var childOnly = $(elem).hasClass('childOnly') ? 1 : 0;
  813.                 var idIndex = $(elem).attr('id');
  814.                 var isMultiple = $(elem).attr('multiple') ? 1 : 0;
  815.                 var toSetValues = $(elem).attr('data-select-values') ? ($(elem).attr('data-select-values').split(',')) : [];
  816.                 if (typeof options['markerHash'] !== "undefined") {
  817.                     if (!$(elem).attr('data-marker-hash'))
  818.                         $(elem).attr('data-marker-hash', options['markerHash'])
  819.                 }
  820.                 if (typeof options['renderText'] !== "undefined") {
  821.                     if (!$(elem).attr('data-render-text'))
  822.                         $(elem).attr('data-render-text', options['renderText'])
  823.                 }
  824.                 if (typeof options['markerHashStrictMatch'] !== "undefined") {
  825.                     if (!$(elem).attr('data-marker-hash-strict-match'))
  826.                         $(elem).attr('data-marker-hash-strict-match', options['markerHashStrictMatch'])
  827.                 }
  828.                 
  829.                 var the_awesome_selector = $(elem).selectize({
  830.                     placeholder: 'Select a Head',
  831.                     options: [],
  832.                     valueField: 'value',
  833.                     labelField: 'text',
  834.                     onChange: function (value) {
  835.                     },
  836.                     preload: 'focus',
  837.                     load: function (query, callback) {
  838.                         if (!query.length) query = '_EMPTY_';
  839.                         var pika_ind_id = $($(this)[0].$input["0"]).attr('data-id')
  840.                         $.ajax({
  841.                             url: BaseURL + "select_data_ajax",
  842.                             type: 'POST',
  843.                             dataType: 'json',
  844.                             data: {
  845.                                 query: query,
  846.                                 tableName: "acc_accounts_head",
  847.                                 valueField: "accounts_head_id",
  848.                                 // textField: "name",
  849.                                 textField: "rendered_text",
  850.                                 renderTextFormat: $($(this)[0].$input["0"]).attr('data-render-text') ? $($(this)[0].$input["0"]).attr('data-render-text') : "#__value__ - __name__  (__parent_table_name__)",     //--change--//
  851.                                 selectorId: $($(this)[0].$input["0"]).attr('id'),
  852.                                 isMultiple: $($(this)[0].$input["0"]).attr('multiple') ? 1 : 0,
  853.                                 lastChildrenOnly: $($(this)[0].$input["0"]).hasClass('childOnly') ? 1 : 0,
  854.                                 parentOnly: $($(this)[0].$input["0"]).hasClass('parentOnly') ? 1 : 0,
  855.                                 parentIdField: 'parent_id',
  856.                                 dataId: pika_ind_id,
  857.                                 marker_hash: $($(this)[0].$input["0"]).attr('data-marker-hash'),
  858.                                 headMarkers: $($(this)[0].$input["0"]).attr('data-marker-hash'),
  859.                                 headMarkersStrictMatch: $($(this)[0].$input["0"]).attr('data-marker-hash-strict-match'),
  860.                                 itemLimit: ($($(this)[0].$input["0"]).attr('data-item-limit') ? $($(this)[0].$input["0"]).attr('data-item-limit') : 25),
  861.                                 andOrConditions: [
  862.                                     {type: "like", field: "name", value: query},
  863.                                     {type: "=", field: "accounts_head_id", value: isNaN(query) ? '' : query},
  864.                                 ],
  865.                                 
  866.                                 andConditions: [
  867.                                     (
  868.                                         $($(this)[0].$input["0"]).attr('data-head-type') ? {
  869.                                                 type: "like",
  870.                                                 field: "type",
  871.                                                 value: $($(this)[0].$input["0"]).attr('data-head-type')
  872.                                             }
  873.                                             : undefined
  874.                                     ),
  875.                                     (
  876.                                         $($(this)[0].$input["0"]).attr('data-head-nature') ? {
  877.                                                 type: "like",
  878.                                                 field: "type",
  879.                                                 value: $($(this)[0].$input["0"]).attr('data-head-nature')
  880.                                             }
  881.                                             : undefined
  882.                                     ),
  883.                                 ],
  884.                                 mustConditions: [{
  885.                                 }
  886.                                 ],
  887.                                 joinTableData: [
  888.                                     {
  889.                                         tableName: "acc_accounts_head",
  890.                                         joinFieldPrimary: "parent_id",
  891.                                         joinOn: 'accounts_head_id',
  892.                                         tableJoinType: 'cross join',
  893.                                         fieldJoinType: '=',
  894.                                         joinAndConditions: [
  895.                                             (
  896.                                                 $($(this)[0].$input["0"]).attr('data-head-type') ? {
  897.                                                         type: "like",
  898.                                                         field: "type",
  899.                                                         value: $($(this)[0].$input["0"]).attr('data-head-type')
  900.                                                     }
  901.                                                     : undefined
  902.                                             ),
  903.                                             (
  904.                                                 $($(this)[0].$input["0"]).attr('data-head-nature') ? {
  905.                                                         type: "like",
  906.                                                         field: "type",
  907.                                                         value: $($(this)[0].$input["0"]).attr('data-head-nature')
  908.                                                     }
  909.                                                     : undefined
  910.                                             ),
  911.                                             // {type: "!=", field: "parent_id", value: 0},
  912.                                         ],
  913.                                         joinOrConditions: [
  914.                                             query.indexOf('#setValue') == -1 ? {
  915.                                                 type: "like",
  916.                                                 field: "name",
  917.                                                 value: query
  918.                                             } : undefined,
  919.                                             query.indexOf('#setValue') == -1 ? {
  920.                                                 type: "=",
  921.                                                 field: "accounts_head_id",
  922.                                                 value: isNaN(query) ? '' : query
  923.                                             } : undefined,
  924.                                         ],
  925.                                         selectPrefix: 'parent_table_',
  926.                                         selectFieldList: [
  927.                                             'name'
  928.                                         ]
  929.                                     },
  930.                                 ],
  931.                                 convertToObject: [
  932.                                 ],
  933.                             },
  934.                             error: function () {
  935.                             },
  936.                             success: function (res) {
  937.                                 if (typeof window[res.tableName + '_data_bank'] !== 'undefined') {
  938.                                     for (var chukapuka = 0; chukapuka < res.data.length; chukapuka++) {
  939.                                         if (typeof window[res.tableName + '_data_bank'][res.data[chukapuka]['value']] !== 'undefined') {
  940.                                         } else {
  941.                                             window[res.tableName + '_data_bank'][res.data[chukapuka]['value']] = res.data[chukapuka];
  942.                                         }
  943.                                     }
  944.                                 } else
  945.                                     window[res.tableName + '_data_bank'] = res.dataById;
  946.                                 callback(res.data);
  947.                                 
  948.                                 if (res.setValueArray.length != 0 && res.selectorId != '') {
  949.                                     if (res.isMultiple == 1)
  950.                                         $('#' + res.selectorId).selectize()[0].selectize.setValue(res.setValueArray)
  951.                                     else
  952.                                         $('#' + res.selectorId).selectize()[0].selectize.setValue(res.setValue)
  953.                                 }
  954.                             }
  955.                         });
  956.                     },
  957.                 })[0].selectize;
  958.                 if (toSetValues.length > 0)
  959.                     populateAndSetSelectByAjaxSelector(the_awesome_selector, toSetValues)
  960.                 if (returnLatest == 1)
  961.                     return the_awesome_selector;
  962.                 else
  963.                     generic_head_selectors[idIndex] = the_awesome_selector;
  964.             })
  965.         }
  966.         {# var BaseURL='{{ url('dashboard') }}'; #}
  967.         {% set foo = url('dashboard')|split(':') %}
  968.         //    console.log('{{ foo|length }}');
  969.         {% if foo|length ==3 %}
  970.         {% set url_wo_port=foo[0]~':'~foo[1] %}
  971.         {# //    console.log('{{ 'length 3' }}'); #}
  972.         {# //    console.log('{{ url_wo_port }}'); #}
  973.         {% elseif foo|length ==2 %}
  974.         {% set url_wo_port=foo[0]~':' %}
  975.         {% set bar=foo[1]|split('/') %}
  976.         {# //    console.log('{{ url_wo_port }}'); #}
  977.         {# //    console.log('{{ bar|json_encode()|raw() }}'); #}
  978.         {% for indu,gg in bar %}
  979.         {# //    console.log('index {{ indu }}') #}
  980.         {# //    console.log('will append {{ gg }}') #}
  981.         {% if indu <((bar|length)-1)  and indu!=0 %}
  982.         {% set url_wo_port=url_wo_port~'/'~gg %}
  983.         {# //    console.log('appended {{ gg }}') #}
  984.         {% endif %}
  985.         {# //    console.log('{{ url_wo_port }}'); #}
  986.         {% endfor %}
  987.         {% endif %}
  988.         //        var url_without_port=BaseURL.split(':')[0]+':'+BaseURL.split(':')[1]
  989.         {# var DATE_BAR_START="{{ session.userCompanyOpeningYear }}-01-01"
  990.         var DATE_BAR_END="{{ 'now' | date('Y-m-d') }}" #}
  991.     </script>
  992.     {# the one in constant is the forced one #}
  993.     {% if constant('ApplicationBundle\\Constants\\GeneralConstant::NOTIFICATION_ENABLED')==1 %}
  994.         {# now check softone #}
  995.         {% if notification_enabled==1 %}
  996.             {% if session[UserConstants.USER_ID] is defined %}
  997.                 {% if 'localhost:' in notification_server %}
  998.                     {% set notification_server_full = url_wo_port ~':'~ notification_server|split('localhost:')[1] %}
  999.                 {% else %}
  1000.                     {% if 'https://' in notification_server or 'http://' in notification_server %}
  1001.                         {% set notification_server_full =notification_server %}
  1002.                     {% else %}
  1003.                         {% set notification_server_full = 'https://'~notification_server %}
  1004.                     {% endif %}
  1005.                 {% endif %}
  1006.                 <script type="text/javascript">
  1007.                     function refreshKeepAliveCall() {
  1008.                         socketKeepAliveCall = setInterval(function () {
  1009.                             var nowTs = moment().unix(),
  1010.                                 differenceFromStartTime = meetingStartTime.diff(now), // 86400000;
  1011.                                 differenceFromEndTime = meetingEndTime.diff(now); // 86400000;
  1012.                             if (nowTs - lastActivityTs > 60) {
  1013.                                 clearInterval(socketKeepAliveCall);
  1014.                             } else {
  1015.                                 socket.emit('update_my_socket', {
  1016.                                     userId: socket_user_id,
  1017.                                     token: socket_user_session_token,
  1018.                                 });
  1019.                             }
  1020.                         }, 30000)
  1021.                     }
  1022.                     function initiateSocket() {
  1023.                         lastActivityTs = moment().unix();
  1024.                         $.getScript('{{ notification_server_full }}/socket.io/socket.io.js', function () {
  1025.                             if (io) {
  1026.                                 socket = io.connect('{{ notification_server_full }}');
  1027.                                 socket.emit('update_my_socket', {
  1028.                                     userId: socket_user_id,
  1029.                                     token: socket_user_session_token,
  1030.                                     user_status: '_ON_',
  1031.                                     force_broadcast: 1,
  1032.                                 });
  1033.                                 {% if 1 %}
  1034.                                 ifvisible.setIdleDuration(120);
  1035.                                 ifvisible.onEvery(30, function () {
  1036.                                     socket.emit('update_my_socket', {
  1037.                                         userId: socket_user_id,
  1038.                                         token: socket_user_session_token,
  1039.                                     });
  1040.                                 });
  1041.                                 
  1042.                                 ifvisible.idle(function () {
  1043.                                     document.body.style.opacity = 0.5;
  1044.                                     socket.emit('update_my_socket', {
  1045.                                         userId: socket_user_id,
  1046.                                         token: socket_user_session_token,
  1047.                                         user_status: '_AWAY_',
  1048.                                         force_broadcast: 1,
  1049.                                     });
  1050.                                 });
  1051.                                 ifvisible.wakeup(function () {
  1052.                                     document.body.style.opacity = 1;
  1053.                                     socket.emit('update_my_socket', {
  1054.                                         userId: socket_user_id,
  1055.                                         token: socket_user_session_token,
  1056.                                         user_status: '_ON_',
  1057.                                         force_broadcast: 1,
  1058.                                     });
  1059.                                 });
  1060.                                 {% endif %}
  1061.                                 
  1062.                                 if (typeof pageSocketInit !== 'undefined')
  1063.                                     pageSocketInit();
  1064.                                 socket.on('user_status_update', function (dataObj) {
  1065.                                 });
  1066.                                 socket.on('_SOCKET_NOTIFICATION_HERE_', function (dataObj) {
  1067.                                 });
  1068.                                 socket.on('refresh_attendance_status', function (dataObj) {
  1069.                                     console.log(dataObj);
  1070.                                     if($('#is_current_attendance_status').length) {
  1071.                                         listtable.ajax.reload();
  1072.                                         responsiveVoice.speak(dataObj.name + ' has just ' + (dataObj.currentStatus == 0 ? 'signed out of work.' : 'started Working.'), 'UK English Female');
  1073.                                     }
  1074.                                     if(dataObj.userId == current_user_user_id && dataObj.appId == socket_app_id)
  1075.                                         refreshTaskOnSession();
  1076.                                 });
  1077.                             }
  1078.                         });
  1079.                     }
  1080.                 </script>
  1081.                 <script type="text/javascript"
  1082.                         src="{{ notification_server_full }}/socket.io/socket.io.js"></script>
  1083.                 <script type="text/javascript">
  1084.                 </script>
  1085.                 <script src="{{ absolute_url(path('dashboard')) }}js/inno_notify.js?version={{ constant('ApplicationBundle\\Constants\\GeneralConstant::ENTITY_APP_VERSION') }}"></script>
  1086.             {% endif %}
  1087.         {% endif %}
  1088.     {% endif %}
  1089.     <script>
  1090.         {% set left_panel_style='' %}
  1091.         {% set curr_status_of_left_menu=1 %}
  1092.         {% set content_panel_style='' %}
  1093.         {% if session['HIDE_LEFT_PANEL'] is defined %}
  1094.         {% if session['HIDE_LEFT_PANEL'] ==1 %}
  1095.         {% set left_panel_style='display:none' %}
  1096.         {% set curr_status_of_left_menu=0 %}
  1097.         {% endif %}
  1098.         {% endif %}
  1099.         {# alert({{ curr_status_of_left_menu }}) #}
  1100.         var curr_status_of_left_menu = "{{ curr_status_of_left_menu is defined? curr_status_of_left_menu:1 }}";
  1101.         {% if session[UserConstants.USER_ID] is defined %}
  1102.         var product_name_display_type = "{{ session[UserConstants.PRODUCT_NAME_DISPLAY_TYPE] }}";
  1103.         {% endif %}
  1104.         var autoApproveEcoDoc = 0;
  1105.         $(document).ready(function () {
  1106.             $(document).on('focus', '.itemtable input[type="number"]', function (e) {
  1107.                 var theColIndex = $(this).data('colIndex');
  1108.                 $('.itemtable .col_title_' + theColIndex).addClass('expanded')
  1109.             });
  1110.             $(document).on('blur', '.itemtable input[type="number"]', function (e) {
  1111.                 var theColIndex = $(this).data('colIndex');
  1112.                 $('.itemtable .col_title_' + theColIndex).removeClass('expanded')
  1113.             });
  1114.             $('.nav-tabs li').not('.no-popover').each(function (ind, elem) {
  1115.                 $(elem).popover({
  1116.                     content: $(elem).find('a').html(),
  1117.                     trigger: 'hover',
  1118.                     placement: 'top',
  1119.                     container: 'body',
  1120.                     html: true
  1121.                 });
  1122.             });
  1123.             $('.change_app').click(function (ev) {
  1124.                 ev.preventDefault();
  1125.                 getUserCompanyList('_CENTRAL_')
  1126.             })
  1127.             {% set curr_route=app.request.attributes.get('_route') %}
  1128.             $('input.devAdminOnly').attr('readonly', false);
  1129.             update_head_selectors()
  1130.             $(document).on('change', 'input.autoUpdateDataGeneric, select.autoUpdateDataGeneric, textarea.autoUpdateDataGeneric', function () {
  1131.                 $.post('{{ url('update_inline_value') }}', {
  1132.                     entityName: typeof $(this).data('entityName') !== 'undefined' ? $(this).data('entityName') :
  1133.                         (typeof autoUpdateDataGenericEntityName !== 'undefined' ? autoUpdateDataGenericEntityName : ''),
  1134.                     entityBundle: typeof $(this).data('entityBundle') !== 'undefined' ? $(this).data('entityBundle') : (typeof autoUpdateDataGenericEntityBundle !== 'undefined' ? autoUpdateDataGenericEntityBundle : 'ApplicationBundle'),
  1135.                     setValue: $(this).val(),
  1136.                     setMethod: typeof $(this).data('setMethod') !== 'undefined' ? $(this).data('setMethod') : (typeof autoUpdateDataGenericEntitySetMethod !== 'undefined' ? autoUpdateDataGenericEntitySetMethod : ''),
  1137.                     createIfNotFound: typeof $(this).data('createIfNotFound') !== 'undefined' ? $(this).data('createIfNotFound') : (typeof autoUpdateDataGenericEntityCreateIfNotFound !== 'undefined' ? autoUpdateDataGenericEntityCreateIfNotFound : 0),
  1138.                     findField: typeof $(this).data('findField') !== 'undefined' ? $(this).data('findField') : (typeof autoUpdateDataGenericEntityFindField !== 'undefined' ? autoUpdateDataGenericEntityFindField : ''),
  1139.                     findValue: typeof $(this).data('findValue') !== 'undefined' ? $(this).data('findValue') : (typeof autoUpdateDataGenericEntityFindValue !== 'undefined' ? autoUpdateDataGenericEntityFindValue : ''),
  1140.                     fieldType: typeof $(this).data('fieldType') !== 'undefined' ? $(this).data('fieldType') : (typeof autoUpdateDataGenericEntityFieldType !== 'undefined' ? autoUpdateDataGenericEntityFieldType : ''),
  1141.                     modifyTransDateFlag: typeof $(this).data('modifyTransDate') !== 'undefined' ? $(this).data('modifyTransDate') : 0,
  1142.                     modifyTransDateFlag: typeof $(this).data('modifyTransDate') !== 'undefined' ? $(this).data('modifyTransDate') : 0,
  1143.                 })
  1144.                     .done(function (data) {
  1145.                     })
  1146.                     .fail(function () {
  1147.                     });
  1148.             });
  1149.             
  1150.             $('.inplaceEditForced').editable({
  1151.                 event: 'click',
  1152.                 callback: function (data) {
  1153.                     var pika = `
  1154.                    class="inplaceEdit"
  1155.                        data-set-method="setStockTransferDate"
  1156.                        data-entity-name="StockTransfer"
  1157.                        data-entity-bundle="ApplicationBundle"
  1158.                        data-find-value="1"
  1159.                        data-find-field="stockTransferId"
  1160.                        data-field-type="_DATE_"
  1161.                        data-modify-trans-date="1"
  1162.                        `
  1163.                     if (data.content) {
  1164.                         $.post('{{ url('update_inline_value') }}', {
  1165.                             entityName: typeof data.$el[0].dataset.entityName !== 'undefined' ? data.$el[0].dataset.entityName : 'EntityApplicantDetails',
  1166.                             entityBundle: typeof data.$el[0].dataset.entityBundle !== 'undefined' ? data.$el[0].dataset.entityBundle : 'Application',
  1167.                             setValue: data.$el[0].outerText,
  1168.                             setMethod: data.$el[0].dataset.setMethod,
  1169.                             findValue: data.$el[0].dataset.findValue,
  1170.                             findField: typeof data.$el[0].dataset.findField !== 'undefined' ? data.$el[0].dataset.findField : 'applicantId',
  1171.                             modifyTransDateFlag: typeof data.$el[0].dataset.modifyTransDate !== 'undefined' ? data.$el[0].dataset.modifyTransDate : 0,
  1172.                             fieldType: typeof data.$el[0].dataset.fieldType !== 'undefined' ? data.$el[0].dataset.fieldType : '_TEXT_',
  1173.                         })
  1174.                             .done(function (data) {
  1175.                                 if (data.success == true) {
  1176.                                     swal({
  1177.                                         title: "Sweet!",
  1178.                                         text: "Updated",
  1179.                                         imageUrl: BaseURL + "images/thumbs-up.png"
  1180.                                     });
  1181.                                 } else {
  1182.                                     swal({
  1183.                                         title: "Sorry!",
  1184.                                         text: "Your Action failed !",
  1185.                                         imageUrl: BaseURL + "images/Bee_Sad_Emote.png"
  1186.                                     });
  1187.                                 }
  1188.                             })
  1189.                             .fail(function () {
  1190.                             });
  1191.                     }
  1192.                 }
  1193.             });
  1194.             {% if app.session.get('devAdminMode') ==1 %}
  1195.             $('.inplaceEdit .fa.fa-edit').show();
  1196.             $('input.devAdminOnly').attr('readonly', true)
  1197.             {% if session[UserConstants.USER_ID] is defined %}
  1198.             $(document).on('click', '.company_selector a.dropdown-toggle', function () {
  1199.                 RefreshAppListOnMenu()
  1200.             })
  1201.             {% endif %}
  1202.             $('.inplaceEdit').editable({
  1203.                 event: 'click',
  1204.                 callback: function (data) {
  1205.                     var pika = `
  1206.                    class="inplaceEdit"
  1207.                        data-set-method="setStockTransferDate"
  1208.                        data-entity-name="StockTransfer"
  1209.                        data-entity-bundle="ApplicationBundle"
  1210.                        data-find-value="1"
  1211.                        data-find-field="stockTransferId"
  1212.                        data-field-type="_DATE_"
  1213.                        data-modify-trans-date="1"
  1214.                        `
  1215.                     if (data.content) {
  1216.                         $.post('{{ url('update_inline_value') }}', {
  1217.                             
  1218.                             entityName: typeof data.$el[0].dataset.entityName !== 'undefined' ? data.$el[0].dataset.entityName : 'EntityApplicantDetails',
  1219.                             entityBundle: typeof data.$el[0].dataset.entityBundle !== 'undefined' ? data.$el[0].dataset.entityBundle : 'Application',
  1220.                             setValue: data.$el[0].outerText,
  1221.                             setMethod: data.$el[0].dataset.setMethod,
  1222.                             findValue: data.$el[0].dataset.findValue,
  1223.                             findField: typeof data.$el[0].dataset.findField !== 'undefined' ? data.$el[0].dataset.findField : 'applicantId',
  1224.                             modifyTransDateFlag: typeof data.$el[0].dataset.modifyTransDate !== 'undefined' ? data.$el[0].dataset.modifyTransDate : 0,
  1225.                             fieldType: typeof data.$el[0].dataset.fieldType !== 'undefined' ? data.$el[0].dataset.fieldType : '_TEXT_',
  1226.                         })
  1227.                             .done(function (data) {
  1228.                                 if (data.success == true) {
  1229.                                     swal({
  1230.                                         title: "Sweet!",
  1231.                                         text: "Updated",
  1232.                                         imageUrl: BaseURL + "images/thumbs-up.png"
  1233.                                     });
  1234.                                 } else {
  1235.                                     swal({
  1236.                                         title: "Sorry!",
  1237.                                         text: "Your Action failed !",
  1238.                                         imageUrl: BaseURL + "images/Bee_Sad_Emote.png"
  1239.                                     });
  1240.                                 }
  1241.                             })
  1242.                             .fail(function () {
  1243.                             });
  1244.                     }
  1245.                 }
  1246.             });
  1247.             {% endif %}
  1248.             {% if constant('ApplicationBundle\\Constants\\GeneralConstant::NOTIFICATION_ENABLED')==1 %}
  1249.             {% if notification_enabled==1 %}
  1250.             {% if session[UserConstants.USER_ID] is defined %}
  1251.             initiateSocket()
  1252.             {% endif %}
  1253.             {% endif %}
  1254.             {% endif %}
  1255.             $('.btn-file input[type="file"]').not('.show_images').change(function () {
  1256.                 if (!$(this).parents('label').parent().find('.file_names_text').length)
  1257.                     $(this).parents('label').parent().append('<p style="font-weight: bold" class="file_names_text"></p>')
  1258.                 var fileNameList = [];
  1259.                 for (var jj = 0; jj < $(this)[0].files.length; jj++)
  1260.                     fileNameList.push($(this)[0].files[jj].name)
  1261.                 var fileNameText = '';
  1262.                 if (fileNameList.length != 0)
  1263.                     fileNameText = fileNameList.join(' , ')
  1264.                 if (!$(this).parents('label').parent().find('.file_names_text').length)
  1265.                     $(this).parents('label').parent().append('<p style="font-weight: bold" class="file_names_text">' + fileNameText + '</p>')
  1266.                 else
  1267.                     $(this).parents('label').parent().find('.file_names_text').text(fileNameText)
  1268.             });
  1269.             
  1270.             $('.btn-file input[type="file"].show_images').change(function (e) {
  1271.                 if (!$(this).parents('label').parent().find('.file_names_text').length)
  1272.                     $(this).parents('label').parent().append('<p style="font-weight: bold" class="file_names_text"></p>')
  1273.                 var fileNameList = [];
  1274.                 var fileDataList = [];
  1275.                 for (var jj = 0; jj < $(this)[0].files.length; jj++) {
  1276.                     fileNameList.push($(this)[0].files[jj].name);
  1277.                     fileDataList.push({
  1278.                         fullPath: URL.createObjectURL($(this)[0].files[jj]),
  1279.                         fileType: $(this)[0].files[jj].type,
  1280.                         fileName: $(this)[0].files[jj].name,
  1281.                     })
  1282.                 }
  1283.                 if (!$(this).parents('label').parent().find('.file_images_cont').length)
  1284.                     $(this).parents('label').parent().append('<div  style="font-weight: bold" class="row file_images_cont">' + generateFileSmallView(fileDataList, 0) + '</div>')
  1285.                 else
  1286.                     $(this).parents('label').parent().find('.file_images_cont').html(generateFileSmallView(fileDataList, 0))
  1287.             });
  1288.             
  1289.             {% if session[UserConstants.USER_ID] is defined %}
  1290.             
  1291.             if ($('.assigned_task_list_here').length)
  1292.                 ListAvailableTaskOnMenu();
  1293.             $(document).on('click', '.this_is_task a', function (e) {
  1294.                 e.preventDefault();
  1295.                 if ($(this).parent('li').hasClass('active')) {
  1296.                     EndCurrentTaskOnMenu()
  1297.                 } else
  1298.                     ChangeActiveTaskOnMenu(0, $(this).data('pid'))
  1299.             });
  1300.             
  1301.             function clock_update_on_menu() {
  1302.                 var gg_cur_ts = moment().unix();
  1303.                 $('.clock_update').each(function (invu, elem) {
  1304.                     var sec_diff = gg_cur_ts - 1 * $(elem).data('startTs');
  1305.                     var hour_here = Math.floor(sec_diff / 3600);
  1306.                     var min_here = Math.floor((sec_diff % 3600) / 60);
  1307.                     var sec_here = Math.floor((sec_diff % 60));
  1308.                     $(elem).text((hour_here.toString()).padStart(2, 0) + ':' + (min_here.toString()).padStart(2, 0) + ':' + (sec_here.toString()).padStart(2, 0))
  1309.                 })
  1310.             }
  1311.             setInterval(clock_update_on_menu, 1000);
  1312.             {% endif %}
  1313.             var CURRENT_ROUTE = '{{ curr_route }}';
  1314.             if ($('#approveDocument #approveDocumentForwardUserList').length) {
  1315.                 approveDocumentForwardUserListSelector = $('#approveDocument #approveDocumentForwardUserList').selectize({
  1316.                     placeholder: 'Select a user',
  1317.                     multiple: false,
  1318.                     options: [],
  1319.                     valueField: 'value',
  1320.                     labelField: 'text',
  1321.                     preload: 'focus',
  1322.                     searchField: ['text', 'value'],
  1323.                     load: function (query, callback) {
  1324.                         
  1325.                         if (!query.length) query = '_EMPTY_';
  1326.                         var pika_ind_id = $($(this)[0].$input["0"]).attr('data-id')
  1327.                         $.ajax({
  1328.                             url: BaseURL + "select_data_ajax",
  1329.                             type: 'POST',
  1330.                             dataType: 'json',
  1331.                             data: {
  1332.                                 //returnJson: 1,
  1333.                                 //sessionData: sessionData
  1334.                                 query: query,
  1335.                                 tableName: "sys_user",
  1336.                                 valueField: "user_id",
  1337.                                 textField: "rendered_text",
  1338.                                 entity_group: 0,
  1339.                                 selectorId: $($(this)[0].$input["0"]).attr('id'),
  1340.                                 isMultiple: 0,
  1341.                                 dataId: pika_ind_id,
  1342.                                 renderTextFormat: "# __value__ __name__",
  1343.                                 andConditions: [],
  1344.                                 andOrConditions: [
  1345.                                     {type: "like", field: "name", value: query},
  1346.                                 ],
  1347.                                 mustConditions: [
  1348.                                     {type: "=", field: "status", value: 1},
  1349.                                     {type: "in", field: "user_type", value: [1, 2, 5]},
  1350.                                 ],
  1351.                                 joinTableData: [
  1352.                                 ],
  1353.                                 convertToObject: [
  1354.                                 ],
  1355.                                 skipDefaultCompanyId: 1
  1356.                             },
  1357.                             error: function () {
  1358.                             },
  1359.                             success: function (res) {
  1360.                                 callback(res.data);
  1361.                                 if (res.setValueArray.length != 0 && res.selectorId != '') {
  1362.                                     if (res.isMultiple == 1)
  1363.                                         $('#' + res.selectorId).selectize()[0].selectize.setValue(res.setValueArray)
  1364.                                     else
  1365.                                         $('#' + res.selectorId).selectize()[0].selectize.setValue(res.setValue)
  1366.                                 }
  1367.                             }
  1368.                         });
  1369.                     },
  1370.                     onChange: function (value) {
  1371.                     }
  1372.                 })[0].selectize;
  1373.             }
  1374.             $(document).on('click', '.trigger_approval_btn', function () {
  1375.                 $('#approveDocument #approvalEntity').val($(this).data('entity'))
  1376.                 $('#approveDocument #approvalEntityId').val($(this).data('entityId'))
  1377.                 $('#approveDocument #approvalId').val($(this).data('approvalId'))
  1378.             })
  1379.             $('.approval_submit').click(function (e) {
  1380.                 e.preventDefault();
  1381.                 if ($('#approveDocument input[name="approvalAction"]:checked').length) {
  1382.                     $('#approval_form').submit()
  1383.                 } else {
  1384.                     alertify.alert("Select an Approval Action!")
  1385.                 }
  1386.             })
  1387.             
  1388.             {% if  app.request.query.get('autoApproveEcoDoc') !='' %}
  1389.             autoApproveEcoDoc = 1;
  1390.             $('.trigger_approval_btn').eq(0).trigger('click');
  1391.             $('#approveDocument #radio1').prop('checked', true)
  1392.             $('#approveDocument #approveDocumentApprovalHash').val('_eco_')
  1393.             $('.approval_submit').trigger('click');
  1394.             {% endif %}
  1395.             
  1396.             {% if curr_route=='applicant_dashboard' or  curr_route=='dashboard' %}
  1397.             var globLsDataStr = window.localStorage.getItem('lsData');
  1398.             var globLsData = {};
  1399.             if (globLsDataStr != 'null' && globLsDataStr != null)
  1400.                 globLsData = JSON.parse(globLsDataStr);
  1401.             {% endif %}
  1402.             if (typeof initiate_comment_box_snippet !== 'undefined') {
  1403.                 initiate_comment_box_snippet();
  1404.             }
  1405.             $('.modal').on('shown.bs.modal', function () {
  1406.                 $(document).off('focusin.modal');
  1407.             });
  1408.             $('a').each(function (index) {
  1409.                 var attr_href = $(this).attr('href');
  1410.                 if (typeof attr_href !== typeof undefined && attr_href !== false)
  1411.                     if (($(this).attr('href')).indexOf('print') != -1) {
  1412.                         $(this).attr('target', '_blank')
  1413.                     }
  1414.             });
  1415.             if (!window.isElectron) {
  1416.                 $('#turn_off_button').hide();
  1417.                 $('.close_window').hide();
  1418.             }
  1419.             if (window.isElectron) {
  1420.                 if (window.localStorage.getItem('full_screen_enabled') == null) {
  1421.                     openFullscreen();
  1422.                 }
  1423.                 window.ipcRenderer.on('update_message', function (event, text) {
  1424.                     alertify.alert(text);
  1425.                 })
  1426.                 $("a[target='_blank']").attr('target', '_self');
  1427.                 $("form[target='_blank']").attr('target', '_self');
  1428.             }
  1429.             $('#turn_off_button').click(function (e) {
  1430.                 e.preventDefault();
  1431. //            window.open('', '_self', '');
  1432.                 if (confirm('Are you sure to exit?') == true) {
  1433.                     if (window.isElectron) {
  1434.                         window.ipcRenderer.send('exit_app', 'hello')
  1435.                     }
  1436.                 }
  1437.             });
  1438.             $('.close_window').click(function (e) {
  1439.                 e.preventDefault();
  1440. //            window.open('', '_self', '');
  1441.                 if (window.isElectron) {
  1442.                     window.ipcRenderer.send('close_window', 'hello') //no need to exit app
  1443.                     //window.ipcRenderer.on('pong', function(event, msg){//    console.log(msg)} )
  1444.                 }
  1445.             });
  1446.             
  1447.             $(".leftMenuToggle").click(function () {
  1448. //            alert(curr_status_of_left_menu);
  1449. //            alert(curr_status_of_left_menu)
  1450.                 if (curr_status_of_left_menu == 0) {
  1451.                     $("section.content").css("margin-left", "265px");
  1452.                     $("#leftsidebar").show();
  1453.                     curr_status_of_left_menu = 1;
  1454.                 } else if (curr_status_of_left_menu == 1) {
  1455.                     $("section.content").css("margin-left", "59px");
  1456.                     $("#leftsidebar").hide();
  1457.                     curr_status_of_left_menu = 0;
  1458.                 }
  1459.                 jQuery.get(BaseURL + "change_left_panel_display_status", function (data) {
  1460. //                jQuery('.SelectedSupplierDetails').html(data.content);
  1461.                 
  1462.                 });
  1463.             })
  1464.             $('.dropdown-submenu a.expand_menu').on("click", function (e) {
  1465. //            alert("here")
  1466.                 $('.dropdown-submenu a.expand_menu').next('ul').hide();
  1467.                 $(this).next('ul').toggle();
  1468.                 e.stopPropagation();
  1469.                 e.preventDefault();
  1470.             });
  1471.         });
  1472.         {# var perSessionMinute={{ BuddybeeConstant.PER_SESSION_MINUTE }}; #}
  1473.         var system_notice ={% set sys_notice=''|getSystemNotice %}
  1474.                 {% set appValiditySeconds='_UNSET_' %}
  1475.                 {% if session['appValiditySeconds'] is defined %}
  1476.                 {% set appValiditySeconds=session['appValiditySeconds'] %}
  1477.                 {% endif %}
  1478.                 {% if appValiditySeconds!='_UNSET_' %}
  1479.                 {% if appValiditySeconds <= (30*24*3600) %}
  1480.                 {% set leftDays = appValiditySeconds/(24*3600) %}
  1481.                 {% set appIsValidTillTime=session['appIsValidTillTime'] %}
  1482.                 {% set mod_str ="Don't give up on us! We're still working to make your life easier. If you don't want to lose this precious service, make sure to pay your outstanding bill by "~(appIsValidTillTime|date('F d, Y'))~"!" %}
  1483.                 {% if leftDays <1 %}
  1484.                 {% set  mod_str=mod_str~' --- Time Left: '~((appValiditySeconds/60)|number_format(0,'.',','))~' minute(s)' %}
  1485.                 {% else %}
  1486.                 {% set mod_str=mod_str~' ---- Time Left: '~(leftDays|number_format(0,'.',','))~' day(s)' %}
  1487.                 {% endif %}
  1488.             noty({
  1489.                 text: "{{ mod_str }} ",
  1490.                 layout: 'bottom',
  1491.                 theme: 'defaultTheme', // or 'relax'
  1492. //                    theme: 'relax',
  1493.                 type: 'error',
  1494. //                    timeout: 100000,
  1495.                 timeout: false,
  1496.                 closeWith: ['click'],
  1497.                 animation: {
  1498.                     open: {height: 'toggle'}, // jQuery animate function property object
  1499.                     close: {height: 'toggle'}, // jQuery animate function property object
  1500.                     easing: 'swing', // easing
  1501.                     speed: 'slow' // opening & closing animation speed
  1502.                 },
  1503.                 callback: {
  1504.                     onShow: function () {
  1505.                     },
  1506.                     afterShow: function () {
  1507.                     },
  1508.                     onClose: function () {
  1509.                     },
  1510.                     afterClose: function () {
  1511.                     },
  1512.                     onCloseClick: function () {
  1513. //                window.location.href=data.viewlink
  1514.                         //alert('clicked')
  1515.                     },
  1516.                 }
  1517.             });
  1518.         {% endif %}
  1519.         {% endif %}
  1520.         {% for dt in  sys_notice %}
  1521.         {# endDate and startDate are strings or DateTime objects #}
  1522.         {% set difference = date(dt.countDownEnds).diff(date('')) %}
  1523.         {% set leftDays = difference.days %}
  1524.         {% set mod_str = dt.desc %}
  1525.         {% if leftDays == 1 %}
  1526.         {% set  mod_str=mod_str~' --- Time Left: 1 day' %}
  1527.         {% else %}
  1528.         {% set mod_str=mod_str~' ---- Time Left: '~leftDays~' days' %}
  1529.         {% endif %}
  1530.         noty({
  1531.             text: "{{ mod_str }} ",
  1532.             layout: 'bottom',
  1533. //                    theme: 'defaultTheme', // or 'relax'
  1534.             theme: 'relax',
  1535.             type: 'warning',
  1536. //                    timeout: 100000,
  1537.             timeout: false,
  1538.             closeWith: ['click'],
  1539.             animation: {
  1540.                 open: {height: 'toggle'}, // jQuery animate function property object
  1541.                 close: {height: 'toggle'}, // jQuery animate function property object
  1542.                 easing: 'swing', // easing
  1543.                 speed: 'slow' // opening & closing animation speed
  1544.             },
  1545.             callback: {
  1546.                 onShow: function () {
  1547.                 },
  1548.                 afterShow: function () {
  1549.                 },
  1550.                 onClose: function () {
  1551.                 },
  1552.                 afterClose: function () {
  1553.                 },
  1554.                 onCloseClick: function () {
  1555. //                window.location.href=data.viewlink
  1556.                     //alert('clicked')
  1557.                 },
  1558.             }
  1559.         });
  1560.         {% endfor %}
  1561.         $(document).ready(function () {
  1562.             $('input[type=radio][name=approvalAction]').change(function () {
  1563.                 if (this.value == '3') {
  1564.                     $("#forward_doc_div").show()
  1565.                 } else {
  1566.                     $("#forward_doc_div").hide()
  1567.                 }
  1568.             });
  1569.             $('#forward_doc_check_label').click(function () {
  1570.                 $('#forward_doc_check').prop("checked", true);
  1571.                 $("#forward_doc_div").show()
  1572.             });
  1573.             if ($('.pending_task_div').length) {
  1574.                 // alert('hello')
  1575.                 // //    console.log('HHHHHHHHHHHHHHHHHHHH________________________________________EEEEEEEEEEEEEEEEEEEEEEEEEEE________________')
  1576.                 refreshPendingTaskDiv()
  1577.             }
  1578.         });
  1579.     </script>
  1580.     <script>
  1581.         {% if new_calendar_version==0 %}
  1582.         var MenuCalendar = function () {
  1583.             // Create reference to this instance
  1584.             var o = this;
  1585.             // Initialize app when document is ready
  1586.         };
  1587.         var MP = MenuCalendar.prototype;
  1588.         // =========================================================================
  1589.         // INIT
  1590.         // =========================================================================
  1591.         MP.initialize = function () {
  1592.             this._enableEvents();
  1593.             this._initEventslist();
  1594.             this._initCalendar();
  1595.             this._displayDate();
  1596.         };
  1597.         // =========================================================================
  1598.         // EVENTS
  1599.         // =========================================================================
  1600.         // events
  1601.         MP._enableEvents = function () {
  1602. //        alert('pola')
  1603.             var o = this;
  1604.             $('#menu-calendar-prev').on('click', function (e) {
  1605. //            alert('lola')
  1606.                 o._handleCalendarPrevClick(e);
  1607.             });
  1608.             $('#menu-calendar-next').on('click', function (e) {
  1609.                 o._handleCalendarNextClick(e);
  1610.             });
  1611.             $('#menu-calendar-today').on('click', function (e) {
  1612.                 o._handleCalendarTodayClick(e);
  1613.             });
  1614.             $('.menu-calendar-holder .nav-tabs li').on('show.bs.tab', function (e) {
  1615.                 o._handleCalendarMode(e);
  1616.             });
  1617.         };
  1618.         // =========================================================================
  1619.         // CONTROLBAR
  1620.         // =========================================================================
  1621.         MP._handleCalendarPrevClick = function (e) {
  1622.             $('#menuCalendar').fullCalendar('prev');
  1623.             this._displayDate();
  1624.         };
  1625.         MP._handleCalendarNextClick = function (e) {
  1626.             $('#menuCalendar').fullCalendar('next');
  1627.             this._displayDate();
  1628.         };
  1629.         MP._handleCalendarTodayClick = function (e) {
  1630.             $('#menuCalendar').fullCalendar('today');
  1631.             this._displayDate();
  1632.         };
  1633.         MP._handleCalendarMode = function (e) {
  1634.             $('#menuCalendar').fullCalendar('changeView', $(e.currentTarget).data('mode'));
  1635.         };
  1636.         MP._displayDate = function () {
  1637.             var selectedDate = $('#menuCalendar').fullCalendar('getDate');
  1638.             $('.menu-calendar-selected-day').html(moment(selectedDate).format("dddd"));
  1639.             $('.menu-calendar-selected-date').html(moment(selectedDate).format("DD MMMM YYYY"));
  1640.             $('.menu-calendar-selected-year').html(moment(selectedDate).format("YYYY"));
  1641.         };
  1642.         // =========================================================================
  1643.         // TASKLIST
  1644.         // =========================================================================
  1645.         MP._initEventslist = function () {
  1646.             if (!$.isFunction($.fn.draggable)) {
  1647.                 return;
  1648.             }
  1649.             var o = this;
  1650.             $('.list-events li ').each(function () {
  1651.                 // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
  1652.                 // it doesn't need to have a start or end
  1653.                 var eventObject = {
  1654.                     title: $.trim($(this).text()), // use the element's text as the event title
  1655.                     className: $.trim($(this).data('className'))
  1656.                 };
  1657.                 // store the Event Object in the DOM element so we can get to it later
  1658.                 $(this).data('eventObject', eventObject);
  1659.                 // make the event draggable using jQuery UI
  1660.                 $(this).draggable({
  1661.                     zIndex: 999,
  1662.                     revert: true, // will cause the event to go back to its
  1663.                     revertDuration: 0, //  original position after the drag
  1664.                 });
  1665.             });
  1666.         };
  1667.         // =========================================================================
  1668.         // CALENDAR
  1669.         // =========================================================================
  1670.         MP._initCalendar = function (e) {
  1671.             if (!$.isFunction($.fn.fullCalendar)) {
  1672.                 return;
  1673.             }
  1674.             var date = new Date();
  1675.             var d = date.getDate();
  1676.             var m = date.getMonth();
  1677.             var y = date.getFullYear();
  1678.             $('#menuCalendar').fullCalendar({
  1679.                 schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
  1680.                 height: 700,
  1681.                 header: false,
  1682.                 editable: true,
  1683.                 eventStartEditable: true,
  1684.                 eventDurationEditable: true,
  1685.                 droppable: true,
  1686.                 drop: function (date, allDay) { // this function is called when something is dropped
  1687.                     // retrieve the dropped element's stored Event Object
  1688.                     var originalEventObject = $(this).data('eventObject');
  1689.                     // we need to copy it, so that multiple events don't have a reference to the same object
  1690.                     var copiedEventObject = $.extend({}, originalEventObject);
  1691.                     // assign it the date that was reported
  1692.                     copiedEventObject.start = date;
  1693.                     copiedEventObject.allDay = allDay;
  1694.                     copiedEventObject.className = originalEventObject.className;
  1695.                     // render the event on the calendar
  1696.                     // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
  1697.                     $('#menuCalendar').fullCalendar('renderEvent', copiedEventObject, true);
  1698.                     // is the "remove after drop" checkbox checked?
  1699.                     if ($('#drop-remove').is(':checked')) {
  1700.                         // if so, remove the element from the "Draggable Events" list
  1701.                         $(this).remove();
  1702.                     }
  1703.                 },
  1704.                 {% if session[UserConstants.USER_HOLIDAY_LIST_CURRENT_MONTH] is defined %}
  1705.                 {% set currMonthHolidayList=session[UserConstants.USER_HOLIDAY_LIST_CURRENT_MONTH]|jsonDecode() %}
  1706.                 {% else %}
  1707.                 {% set currMonthHolidayList=[] %}
  1708.                 {% endif %}
  1709.                 events: {{ currMonthHolidayList|json_encode()|raw }},
  1710.                 eventRender: function (event, element) {
  1711.                     element.find('#date-title').html(element.find('span.fc-event-title').text());
  1712.                 }
  1713.             });
  1714.         };
  1715.         window.MenuCalendar = new MenuCalendar;
  1716.         var menuCalendarRow = 0;
  1717.         $(document).ready(function () {
  1718.             window.MenuCalendar.initialize();
  1719.             $(document).on('click', '.menuCalendarTrigger', function () {
  1720.                 get_and_update_menu_calendar_according_to_holiday_calendar({% if session[UserConstants.USER_HOLIDAY_CALENDAR_ID] is defined %}
  1721.                         {{ session[UserConstants.USER_HOLIDAY_CALENDAR_ID] }}
  1722.                         {% else %}
  1723.                         {{ 0 }}
  1724.                         {% endif %})
  1725.                 get_and_update_time_details_for_attendance({% if session[UserConstants.USER_EMPLOYEE_ID] is defined %}
  1726.                         {{ session[UserConstants.USER_EMPLOYEE_ID] }}
  1727.                         {% else %}
  1728.                         {{ 0 }}
  1729.                         {% endif %})
  1730.             })
  1731.             function get_and_update_menu_calendar_according_to_holiday_calendar(calendarId) {
  1732.                 var to_get_calendar_id = 0;
  1733.                 if (calendarId !== undefined)
  1734.                     to_get_calendar_id = calendarId;
  1735.                 if (to_get_calendar_id == '' || to_get_calendar_id == 0) {
  1736.                     return;
  1737.                 }
  1738.                 jQuery.get(BaseURL + "get_holiday_details/" + to_get_calendar_id, function (data) {
  1739.                     //    console.log(data);
  1740.                     if (data.success == true) {
  1741.                         $('#menuCalendar').fullCalendar('removeEvents');
  1742.                         menuCalendarRow = 1;
  1743.                         var entry = data.holidayList;
  1744.                         for (var i = 0; i < entry.length; i++) {
  1745.                             var sdateStr = entry[i]['startDate'];
  1746.                             var edateStr = entry[i]['endDate'];
  1747.                             var sdate = new Date(sdateStr);
  1748.                             var edate = new Date(edateStr);
  1749.                             var title = entry[i]['title'];
  1750.                             var date = 0;
  1751.                             menuCalendarRow = menuCalendarRow + 1;
  1752.                             var originalEventObject = $(window.MenuCalendar).data('eventObject');
  1753.                             // we need to copy it, so that multiple events don't have a reference to the same object
  1754.                             var copiedEventObject = $.extend({}, originalEventObject);
  1755.                             // assign it the date that was reported
  1756.                             copiedEventObject.id = menuCalendarRow;
  1757.                             copiedEventObject.start = new Date(sdateStr);
  1758.                             copiedEventObject.end = new Date(edateStr + ' 00:00:00');
  1759.                             copiedEventObject.allDay = 1;
  1760.                             copiedEventObject.title = title;
  1761.                             $('#menuCalendar').fullCalendar('renderEvent', copiedEventObject, true);
  1762.                         }
  1763.                     }
  1764.                 });
  1765.             }
  1766.             function get_and_update_time_details_for_attendance(employee_id) {
  1767.                 employee_id = employee_id || 0;
  1768.                 if (employee_id == '' || employee_id == 0) {
  1769.                     return;
  1770.                 }
  1771.                 $.post(BaseURL + 'attendance_report', {
  1772.                     start_date: '{{ ''|date('F d, Y') }}',
  1773.                     end_date: '{{ ''|date('F d, Y') }}',
  1774.                     employes: employee_id,
  1775.                     returnJson: 1,
  1776.                     considerCurrTsIfNoOut: 1,
  1777.                 })
  1778.                     .done(function (data) {
  1779.                         console.log(data)
  1780.                         var sec_diff = 0;
  1781.                         var workSecNeededToClearStrike = 0;
  1782.                         if (typeof data.firstData.secForThis !== 'undefined')
  1783.                             sec_diff = 1 * data.firstData.secForThis;
  1784.                         if (typeof data.firstData.workSecNeededToClearStrike !== 'undefined')
  1785.                             workSecNeededToClearStrike = 1 * data.firstData.workSecNeededToClearStrike;
  1786.                         var hour_here = Math.floor(sec_diff / 3600);
  1787.                         var min_here = Math.floor((sec_diff % 3600) / 60);
  1788.                         var sec_here = Math.floor((sec_diff % 60));
  1789. //                    $(elem).text(hour_here.padStart(2, 0)+':'+min_here.padStart(2, 0))
  1790.                         $('.current_total_work_done').text((hour_here.toString()).padStart(2, 0) + ':' +
  1791.                             (min_here.toString()).padStart(2, 0)
  1792.                             + ':' + (sec_here.toString()).padStart(2, 0)
  1793.                         )
  1794.                         hour_here = Math.floor(workSecNeededToClearStrike / 3600);
  1795.                         min_here = Math.floor((workSecNeededToClearStrike % 3600) / 60);
  1796.                         sec_here = Math.floor((workSecNeededToClearStrike % 60));
  1797. //                    $(elem).text(hour_here.padStart(2, 0)+':'+min_here.padStart(2, 0))
  1798.                         $('.current_total_addtional_work_needed').text('+' + (hour_here.toString()).padStart(2, 0) + ':' +
  1799.                             (min_here.toString()).padStart(2, 0)
  1800.                             + ':' + (sec_here.toString()).padStart(2, 0)
  1801.                         )
  1802.                         //jQuery('.SelectedProductDetails').html(data.content);
  1803.                     })
  1804.                     .fail(function () {
  1805.                     });
  1806.             }
  1807.         });
  1808.         {% endif %}
  1809.     </script>
  1810. {% endif %}
  1811. </body>
  1812. {% include '@Application/modals/input_forms/selectEntityModal.html.twig' %}