
<!--begin::Base Scripts -->
<script src="<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/vendors/base/vendors.bundle.js" type="text/javascript"></script>
<script src="<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/demo/default/base/scripts.bundle.js" type="text/javascript"></script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<!-- <script type="text/javascript" src="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.13.1/b-2.3.2/b-colvis-2.3.2/b-html5-2.3.2/b-print-2.3.2/fc-4.2.1/fh-3.3.1/kt-2.8.0/r-2.4.0/rg-1.3.0/sc-2.0.7/datatables.min.js"></script> -->

<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.20/b-1.6.1/b-colvis-1.6.1/b-flash-1.6.1/b-html5-1.6.1/b-print-1.6.1/fc-3.3.0/fh-3.1.6/kt-2.5.1/r-2.2.3/rg-1.1.1/sc-2.0.1/sp-1.0.1/datatables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.15/sorting/datetime-moment.js"></script>
<!-- <script type="text/javascript" src="https://cdn.datatables.net/fixedcolumns/3.2.1/js/dataTables.fixedColumns.min.js"></script> -->

<!--end::Base Scripts -->
<script>
$.fn.dataTable.moment('DD-MM-YYYY');

$('.company-branch-select2').select2();

function format_project_dropdown(project){
  if (!project.id) {
    return project.text;
  }
  var optiondata = $(project.element);
  var status='';
  if($(optiondata).data('work-status')!='' && $(optiondata).data('work-status')!=undefined && $(optiondata).data('work-status')!=null){
    if($(optiondata).data('work-status')==1){
      status = '<span class="m-badge m-badge--success m-badge--wide"> Completed </span>';
    }else if($(optiondata).data('work-status')==3){
      status = '<span class="m-badge m-badge--warning m-badge--wide"> Freeze </span>';
    }else{
      status = '<span class="m-badge m-badge--metal m-badge--wide"> Ongoing </span>';
    }
  }
  var $project = $(
    '<label>'+project.text+'  '+status+'</label>'
  );
  return $project;
};

<?php if ($this->session->flashdata('flashdata_msg') != "")
{?>
  toastr.options = {
    "closeButton": false,
    "debug": false,
    "newestOnTop": false,
    "progressBar": true,
    "positionClass": "toast-top-full-width",
    "preventDuplicates": false,
    "onclick": null,
    "showDuration": "300",
    "hideDuration": "1000",
    "timeOut": "5000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
  };

  toastr.<?php echo $this->session->flashdata('flashdata_type')?>("<?php echo $this->session->flashdata('flashdata_msg')?>","<?php echo $this->session->flashdata('flashdata_title')?>");

  <?php } ?>
</script>

<script>
// Quick Sidebar Functions
$('body').on('click', '#m_quick_sidebar_close', function() {
  $("#m_quick_sidebar").removeClass('m-quick-sidebar--on');
})
$('body').on('click', '#m_quick_sidebar_toggle', function() {
  $("#m_quick_sidebar").addClass('m-quick-sidebar--on');
  $(".m-quick-sidebar__content").removeClass('m--hide');
})
$(document).mouseup(function (e) {
  // Close Quick Sidebar When click Outside
  if ($(e.target).closest("#m_quick_sidebar").length === 0) {
    $("#m_quick_sidebar").removeClass('m-quick-sidebar--on');
  }
});
$('body').on('click', '#m_quick_sidebar_toggle', function() {

  $(".quick_sidebar_tab_subcontract_profile_bills").removeClass('active show')
  $(".quick_sidebar_tab_subcontract_profile_payments").removeClass('active show')
  $(".quick_sidebar_tab_subcontract_profile_overview").addClass('active show');
  $("#quick_sidebar_header").removeClass("m-portlet--focus m-portlet--success");
  var type = $(this).attr('data-type');
  var id = $(this).attr('data-id');
  if(type=='subcontract_profile'){
    $("#quick_sidebar_title").text("Subcontract Profile");
    $("#quick_sidebar_header").addClass("m-portlet--success");
    $.post("<?php echo base_url() ?>subcontracts/get_profile",{contract_id:id},function(data) {
      var obj = $.parseJSON(data);
      var i=0;
      $("#quick_sidebar_body").html(obj.profile_data);
      var subcontract_table1 = $('#subcontract_bills_view_table').DataTable({
        "ajax":{
          url :"<?php echo base_url().'subcontracts/select_subcontract_bills/' ?>", // json datasource
          type: "post", // type of method  , by default would be get
          data: function(d){
            d.contract_id = id;
          }
        },
        "bProcessing": true,
        "deferRender": true,
        "bDeferRender": true,
        "scrollX" : true,
        buttons: [
          { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'},title: 'Subcontract Bills' },
          { extend: 'csv', className: 'btn purple btn-outline ' },
          { extend: 'colvis', className: 'btn dark btn-outline', text: 'Columns'}
        ],
        dom:"<'row'<'col-sm-6 text-left'B><'col-sm-6 text-right'f>>\n\t\t\t<'row'<'col-sm-12'tr>>\n\t\t\t<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>", // horizobtal scrollable datatable
        "lengthMenu": [
          [25, 50, 100, -1],
          [25, 50, 100, "All"] // change per page values here
        ],
        "columnDefs": [
          {
            "targets": [ 3,4,5,6,23,24,25,26 ],
            className: "hidden"
          }
        ],
        'order': false
      });
      var subcontract_table2 = $('#subcontract_payments_view_table').DataTable({
        "ajax":{
          url :"<?php echo base_url().'accounts/select_account_transactions/subcontract_transactions' ?>", // json datasource
          type: "post", // type of method  , by default would be get
          data: function(d){
            d.contract_id = id;
          }
        },
        "bProcessing": true,
        "deferRender": true,
        "bDeferRender": true,
        "scrollX" : true,
        buttons: [
          { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'},title: 'Subcontract Payments' },
          { extend: 'csv', className: 'btn purple btn-outline ' },
          { extend: 'colvis', className: 'btn dark btn-outline', text: 'Columns'}
        ],
        dom:"<'row'<'col-sm-6 text-left'B><'col-sm-6 text-right'f>>\n\t\t\t<'row'<'col-sm-12'tr>>\n\t\t\t<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>", // horizobtal scrollable datatable
        "lengthMenu": [
          [25, 50, 100, -1],
          [25, 50, 100, "All"] // change per page values here
        ],
        "columnDefs": [
          {
            "targets": [ 3,4,5,6,19],
            className: "hidden"
          }
        ],
        'order': false
      });
      $('body').on('click', '.quick_sidebar_tabs', function() {
        var table_no = $(this).attr('data-table-no');
        if(table_no!=''){
          eval(table_no).ajax.reload();
        }
      })
    })
  }else if(type=='bill_profile'){
    var bill_type = $(this).attr('data-bill-type');
    $("#quick_sidebar_header").addClass("m-portlet--focus");
    $("#quick_sidebar_title").text("Bill Details");
    $.post("<?php echo base_url() ?>bills/get_profile",{bill_id:id},function(data) {
      var obj = $.parseJSON(data);
      var i=0;
      $("#quick_sidebar_body").html(obj.profile_data);
      var bill_table1 = $('#bill_transactions_view_table').DataTable({
        "ajax":{
          url :"<?php echo base_url().'accounts/select_account_transactions/' ?>"+bill_type, // json datasource
          type: "post", // type of method  , by default would be get
          data: function(d){
            d.bill_id = id;
          }
        },
        "bProcessing": true,
        "deferRender": true,
        "bDeferRender": true,
        "scrollX" : true,
        buttons: [
          { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'} ,title: 'Bill Transactions'},
          { extend: 'csv', className: 'btn purple btn-outline ' },
          { extend: 'colvis', className: 'btn dark btn-outline', text: 'Columns'}
        ],
        dom:"<'row'<'col-sm-6 text-left'B><'col-sm-6 text-right'f>>\n\t\t\t<'row'<'col-sm-12'tr>>\n\t\t\t<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>", // horizobtal scrollable datatable
        "lengthMenu": [
          [25, 50, 100, -1],
          [25, 50, 100, "All"] // change per page values here
        ],
        "columnDefs": [
          {
            "targets": [ 4,5,6,7,19],
            className: "hidden"
          }
        ],
        'order': false
      });
      $('body').on('click', '.quick_sidebar_tabs', function() {
        var table_no = $(this).attr('data-table-no');
        if(table_no!=''){
          eval(table_no).ajax.reload();
        }
      })

    })
  }

})
</script>
<script>
$("#notifications_div").load("<?php echo base_url()?>notifications");

$(".m-scrollable").css({
            "overflow": "auto",
            "overflowy": "scroll",
            "overflowx": "auto",
            "overflow-x": "auto",
            "overflow-y": "hidden"
        });
</script>
<style>
/* Datatable Hide Column */
.hidden{
  display: none;
}
.text-wrap{
  white-space:normal;
}
.width-100{
  width:100px !important;
}
.width-150{
  width:150px !important;
}
.width-200{
  width:200px !important;
}
.width-300{
  width:300px !important;
}
.width-400{
  width:400px !important;
}
.width-500{
  width:500px !important;
}
</style>
