<?php

include('../include/session.php');

$table_name = $_SESSION['db_prefix']."_time_record";
//$record_query = "SELECT date, emp_id, status, clock_in, clock_out  FROM $table_name WHERE date >= '2013-01-01' AND date <= '2013-06-30' ";
//$record_query = "SELECT date, emp_id, status, clock_in, clock_out  FROM $table_name WHERE date >= '2013-07-01' AND date <= '2013-12-31' ";
$record_query = "SELECT date, emp_id, status, clock_in, clock_out  FROM $table_name WHERE date >= '2014-01-01' AND date <= '2014-06-30' ";
//$record_query = "SELECT date, emp_id, status, clock_in, clock_out  FROM $table_name WHERE date >= '2014-07-01' AND date <= '2014-12-31' ";
//$record_query = "SELECT date, emp_id, status, clock_in, clock_out  FROM $table_name WHERE date >= '2015-01-01' AND date <= '2015-06-30' ";
//$record_query = "SELECT date, emp_id, status, clock_in, clock_out  FROM $table_name WHERE date >= '2015-07-01' AND date <= '2015-12-31' ";
//$record_query = "SELECT date, emp_id, status, clock_in, clock_out  FROM $table_name WHERE date >= '2016-01-01' AND date < '2016-06-30' ";



$record_result = mySQL_query($record_query);
$record_num = mysql_num_rows($record_result);
echo '<br>*****'.$record_num;

$i=0;
while ($i<$record_num) {
$date = mysql_result($record_result, $i, "date");
$emp_id = mysql_result($record_result, $i, "emp_id");
$status = mysql_result($record_result, $i, "status");
$clock_in = mysql_result($record_result, $i, "clock_in");
$clock_out = mysql_result($record_result, $i, "clock_out");

$table_name = $_SESSION['db_prefix']."_time_sheet";
$sheet_query = "INSERT INTO $table_name (attendance_date, emp_id, attendance_status, check_in_min, check_out_min) VALUES ('".$date."', '".$emp_id."', '".$status."', '".$clock_in."', '".$clock_out."') ";
echo '<br>*****'.$sheet_query;
execsql($sheet_query);

$i++;
}



?>
