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