<?php
$all_options = get_option( 'covid_options' );
wp_enqueue_style( 'covid' );
wp_enqueue_style('jquery.datatables');
wp_enqueue_script('jquery.datatables');
wp_enqueue_script('papaparse');
$getFData=new stdClass();$getFData->cases=0;$getFData->deaths=0;$getFData->recovered=0;$getFData->todayCases=0;$getFData->todayDeaths=0;$getFData->active=0;if(is_array($data)){foreach($data as $key=>$value){$getFData->cases+=$value->cases;$getFData->deaths+=$value->deaths;$getFData->recovered+=$value->recovered;$getFData->todayCases+=$value->todayCases;$getFData->todayDeaths+=$value->todayDeaths;$getFData->active+=$value->active;}}else {$getFData->cases+=$data->cases;$getFData->deaths+=$data->deaths;$getFData->recovered+=$data->recovered;$getFData->todayCases+=isset($data->todayCases)?$data->todayCases:0;$getFData->todayDeaths+=isset($data->todayDeaths)?$data->todayDeaths:0;$getFData->active+=isset($data->active)?$data->active:0;}
?>
<script type="text/javascript">
function format ( d ) {
return '<p><b>Details</b></p> ' +
'<p>' + d['Details'] + '</p>';
}

jQuery(function($) {
	function removeTrailingLine(long_string) {
		var x = long_string;
		if(x.split(/\r?\n/).pop().length == 0) {
			return x.substring(0, x.lastIndexOf("\n"));
		} else {
			return x;
		}
	}
var auth_tracker_path = '//corvid.life/api/v2/library/auth.csv';
$.get(auth_tracker_path, function(data, status){
var objJson = Papa.parse(removeTrailingLine(data), { "header": true});
var csvJson = JSON.stringify(objJson.data, null, 2);

 var table = $('#auth').DataTable( { 
     "order": [],
     data: eval(csvJson),
        "columns": [
            {
                "class":          "details-control vaccines-td cell100",
                "orderable":      false,
                "data":           null,
                "defaultContent": ""
            },
            { "data": "Name", "title": "Name", "class": "vaccines-td cell100", "width": "110px" },
            { "data": "Vaccine Type", "title": "Vaccine Type", "class": "vaccines-td cell100", "width": "200px" },
            { "data": "Details", "title": "Details", "class": "vaccines-td cell100", "visible": false }, 
            { "data": "Primary Developers", "title": "Primary Developers", "class": "vaccines-td cell100", "width": "200px" },
            { "data": "Country of Origin", "title": "Country of Origin", "class": "vaccines-td cell100" },
            { "data": "Authorization/Approval", "title": "Authorization/Approval","class": "vaccines-td cell100" },
        ],
  });
    $('#auth tbody').on('click', 'td.details-control', function () {
        var tr = $(this).closest('tr');
        var row = table.row( tr );
 
        if ( row.child.isShown() ) {
            row.child.hide();
            tr.removeClass('shown');
        }
        else {
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
        }
    } );
});

});
</script>
<div class="table-responsive table100 ver1 <?php echo $all_options['cov_theme']; ?> <?php if ((isset($all_options['cov_rtl']) ? $all_options['cov_rtl'] : null) == 'on') echo 'rtl_enable'; ?>" style="font-family:<?php echo $all_options['cov_font']; ?>">
<table class="display" id="auth" style="width:100%">
</table>
</div>