<?php
session_start();
extract($_REQUEST);
include ("../../php_crud/my_class.php");
$obj = new my_class();
extract($_REQUEST);

// $start_date1 = new DateTime($start_date);
// $end_date1 = new DateTime($end_date);
// $interval = new DateInterval('P1D');
// $end_date1->add($interval);

// $period = new DatePeriod($start_date1, $interval, $end_date1);
// print_r($_REQUEST);
// exit();
// $where="GWT.WELL_ID='$well_id''";
$from_date = strtoupper(date('d-M-y', strtotime($from_date)));
$to_date = strtoupper(date('d-M-y', strtotime($to_date)));
$where = "GWT.WELL_ID='$well_id'";
// print_r($where);

// $debugger=$obj->gw_auto_data_availability_debugger($where,$from_date,$to_date);
// print_r($debugger);
// exit()

?>


<div class="row-fluid" style="text-align:right;">
        <button type="button" class="btn btn-minier btn-purple"
            onclick="print_missing_date_list_details('<?php echo $well_id; ?>', '<?php echo $from_date; ?>', '<?php echo $to_date; ?>')"
            style="margin-top: 8px; margin-bottom:8px; padding: 4px !important;">
            <b style="font-size: 12px;"><i class="icon-print"></i>Print Data</b>
        </button>
</div>

<table id="ground_water_tbl" class="table table-striped table-bordered table-hover">
<thead>
			<tr style="font-family: 'Open Sans';">
				<td style="text-align: center; font-size: 13px;" class="table-header" rowspan="2">Sl</td>
				<td style="text-align: center; font-size: 13px;" class="table-header" rowspan="2">Well Id</td>
				<td style="text-align: center; font-size: 13px;" class="table-header" rowspan="2">Old Well Id</td>
				<td style="text-align: center; font-size: 13px;" class="table-header" rowspan="2">District</td>
				<td style="text-align: center; font-size: 13px;" class="table-header" rowspan="2">Upazila</td>
				<td style="text-align: center; font-size: 13px;" class="table-header" rowspan="2">Month & Year</td>
				<td style="text-align: center; font-size: 13px;" class="table-header" colspan="3">Number Of Missing Date</td>
				<td style="text-align: center; font-size: 13px;" class="table-header" rowspan="2">Penalty Amount</td>
				<!-- <td style="text-align: center;font-size:13px;" class="table-header" rowspan="2">Show Date</td> -->
			</tr>
			<tr style="font-family: 'Open Sans';">
				<td style="text-align: center; font-size: 13px;" class="table-header">Start Date</td>
				<td style="text-align: center; font-size: 13px;" class="table-header">End Date</td>
				<td style="text-align: center; font-size: 13px;" class="table-header">Missing date</td>
			</tr>
		</thead>
    <?php
    $i = 0;
		$total_amount=0;
		$total_missing_date=0;
    foreach ($obj->gw_auto_data_availability($where,$from_date,$to_date) as $val) {
        $i++;
        // print_r($val);
        $well_id = $val['IDENTIFIER'];
				$old_well_id = $val['OLD_ID'];
				$district_name = $val['DISTRICT_NAME'];
				$upazila_name = $val['UPZL_NAME'];
				$month = $val['MONTH'];
				$start_date = $val['START_DATE'];
				$end_date = $val['END_DATE'];
				$number_of_missing_date = $val['NUM_MISSING_DAYS'];
				$amount = $number_of_missing_date * 2000;
				$total_amount +=$amount;
				$total_missing_date+=$number_of_missing_date;
        ?>
        <tbody>

        </tbody>

				<tr>
					<td style="font-size: 14px; text-align: center; "><?php echo $i; ?></td>
					<td style="font-size: 14px; text-align: center; "><?php echo $well_id; ?></td>
					<td style="font-size: 14px; text-align: center; "><?php echo $old_well_id; ?></td>
					<td style="font-size: 14px; text-align: left; padding-left: 10px; "><?php echo $district_name; ?></td>
					<td style="font-size: 14px; text-align: left; padding-left: 10px; "><?php echo $upazila_name; ?></td>

					<td style="font-size: 14px; text-align: center; padding-left: 10px; "><?php echo $month; ?></td>

					<td style="font-size: 14px; text-align: center; padding-left: 10px; "><?php echo $start_date; ?></td>
					<td style="font-size: 14px; text-align: center; padding-left: 10px; "><?php echo $end_date; ?></td>
					<td style="font-size: 14px; text-align: center; padding-left: 10px; "><?php echo $number_of_missing_date; ?></td>
					<td style="font-size: 14px; text-align: right; padding-left: 10px; "><?php echo $amount; ?></td>

        </tr>
    <?php } ?>

		<tr>
			<td style=" text-align: right; font-weight: bold;" colspan="8">Total</td>
			<td style=" text-align: center; font-weight: bold;" ><?php echo $total_missing_date ?></td>
			<td style=" text-align: right; font-weight: bold;"><?php echo $total_amount ?></td>
		</tr>
</table>