<?php
        session_cache_expire(1440);
        session_start();
        session_name("insys");
        include "include/config.php";
        include "include/functions.php";
        include "class/UctVw.php";
        $ssql="SELECT ftattendance_no, fdattendance_date
                    FROM txattendance_hdr
                WHERE ftnotes<>''
                ORDER BY fdattendance_date ";
        $rs=mysql_query($ssql);
        $ssql1=array();
         mysql_query("BEGIN");
        while($r=mysql_fetch_assoc($rs)) {

            $fttrans_no=getAutoNumber("hrd007","txovertime_hdr","ftovertime_no",CDateRev($r['fdattendance_date']));
            $ssql="INSERT INTO txovertime_hdr
                    (
                        ftovertime_no,ftattendance_no, fdovertime_date, ftdivision_code,
                        ftdepartment_code, ftposition_code,
                        ftshift_code, ftnotes, fnstatus,ftdesciption
                    )
                     SELECT '{$fttrans_no}' AS ftovertime_no, ftattendance_no, fdattendance_date AS fdovertime_date, ftdivision_code,
                        ftdepartment_code, ftposition_code,
                        ftshift_code, ftnotes, fnstatus,ftdesciption
                    FROM txattendance_hdr
                    WHERE ftattendance_no='{$r['ftattendance_no']}'";
             $ssql1[]=$ssql;

            mysql_query($ssql);
            $ssql="INSERT INTO txovertime_det
                    (
                        ftovertime_no, fnindex, ftemployee_code, ftshift_code,
                        fnemployee_status, fdovertime_enter_time, fdovertime_exit_date,
                        fdovertime_exit_time, ftovertime_hours, ftnotes
                    )
                    SELECT '{$fttrans_no}' as ftovertime_no, fnindex, ftemployee_code, ftshift_code,
                        fnemployee_status, fdworking_enter_time as fdovertime_enter_time, fdworking_exit_date as fdovertime_exit_date,
                        fdworking_exit_time as fdovertime_exit_time, ftworking_hours as ftovertime_hours, ftnotes
                    from txattendance_det
                     WHERE ftattendance_no='{$r['ftattendance_no']}'";
             $ssql1[]=$ssql;

            mysql_query($ssql);
        }
          mysql_query("COMMIT");
          pr($ssql1);