<script>

$('body').on('click', '#boq_edit_btn', function() {
  var no = $(this).closest('tr').children('td');
  $('#boq_name_edit').val(no.eq(2).text());
  $('#boq_work_order_no_edit').val(no.eq(3).text());
  $('#boq_file_link_edit').val(no.eq(10).text());
  $('#boq_id_edit').val(no.eq(1).text());
});

$('body').on('click', '#boq_status_btn', function() {
  var no = $(this).closest('tr').children('td');
  $('input[type=radio][name=status][value='+no.eq(9).text()+']').prop('checked',true);
  $('#boq_id_status').val(no.eq(1).text());
});

$('body').on('click', '#boq_delete_btn', function() {
  var no = $(this).closest('tr').children('td');
  $('#boq_delete_name').val(no.eq(2).text());
  $('#boq_delete_id').val(no.eq(1).text());
});

var boq_view_table = $('#boq_view_table').DataTable({
  "ajax":{
    url :"<?php echo base_url().'boq/select_boq' ?>", // json datasource
    type: "post", // type of method  , by default would be get
    data: function(d){
      d.work_id = work_id;
    }
  },
  "bProcessing": true,
  "deferRender": true,
  "bDeferRender": true,
  "scrollX" : true,
  buttons: [
    { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'} ,title: 'BOQ Details'},
    { 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>>",
  "lengthMenu": [
    [25, 50, 100, -1],
    [25, 50, 100, "All"] // change per page values here
  ],
  "columnDefs": [
    {
      "targets": [ 1,9,10 ],
      className: "hidden"
    }
  ],
  'order': false
});

function task_table(){
  var project_tasks_view_table = $('#project_tasks_view_table').dataTable({
    "scrollX" : true,
    buttons: [
      { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'},exportOptions: {columns:[1,2,3,4,5,6,7]} ,title: 'BOQ Tasks List'},
      { extend: 'pdf', className: 'btn purple btn-outline',exportOptions: {columns:[1,2,3,4,5,6,7]} },
      { extend: 'csv', className: 'btn purple btn-outline',exportOptions: {columns:[1,2,3,4,5,6,7]} },
    ],
    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": [
      [100, 250, 500, -1],
      [100, 250, 500, "All"] // change per page values here
    ],
    "columnDefs": [
      {
        "targets": [],
        className: "hidden"
      }
    ],
    "bInfo" : false,
    'order': false,
    'ordering':false,
    "pageLength":100
  });
};
// function task_table_append(argument) {
//   $.post("<?php echo base_url() ?>project_tasks/select_tasks_and_activities",{work_id:work_id},function (data) {
//     var obj=$.parseJSON(data);
//     $("#project_tasks_table_body").html('');
//     if(parseInt(obj.task_count)>0){
//       var content=obj.content;
//       $("#project_tasks_table_body").html(content);
//     }
//     $('#project_tasks_view_table').dataTable().fnDestroy();
//     task_table();
//   });
// };
</script>
