

<?php 
ini_set('max_execution_time', 0); //300 seconds = 5 minutes 
date_default_timezone_set("Asia/Bangkok");
// echo $_SESSION['company_id'];
include('../include/connectDB.php'); 
include('../include/connectDB_Bill.php'); 
include('INSERT_LOG.php'); 

$currentdate = date('Y-m-d');

$yearY = date("Y"); 
$yearM = date("m"); 
$yearD = date("d");
$htime = date("H:i:sa"); 
$current_time = $yearD.'.'.$yearM.'.'.($yearY+543);
$s_trime = $yearY.$yearM.$yearD;
$DateStart=date($s_trime);
$strtime = strtotime($DateStart);
$caltime=strtotime("-2 Month",$strtime);
$ResultDate=date("Y-m-d", $caltime);
$yearY = substr(date("$ResultDate"), 0,-6); 
$yearM = substr(date("$ResultDate"), 5,-3); 
$yearD = substr(date("$ResultDate"), -2); 
$s_trime = $yearD.'.'.$yearM.'.'.($yearY+543);  
// $s_trime = "20.05.2564"; 
?>


<?php

$sql_del = "delete from FLEET_VEHICLE_SPEC";
    $stm_del = sqlsrv_prepare ($ConnYS, $sql_del);
        if (!$stm_del) {
            throw new Exception("sql_del  plan#". $sql_del); 
        }
        if (!sqlsrv_execute($stm_del)) {
            throw new Exception("sql_del นำเข้า plan ไม่สำเหร็จ#" . $sql_del);
        }

sqlsrv_commit($ConnYS);

$sql1 = " SELECT
            VID
            ,VHC_CODE
            ,VHC_OWNED_DATE
            ,VHC_AGE
            ,VHC_BRID
            ,VHC_GROUPID
            ,VHC_TYPEID
            ,VHC_FEATUREID
            ,VHC_PLATE_ALP
            ,VHC_PLATE
            ,VHC_PLATE_PROVINCE
            ,VHC_MAKE
            ,VHC_SERIES
            ,VHC_HP
            ,VHC_PLUNGER_QTY
            ,VHC_ENGINE_MANU
            ,VHC_ENGINE_NO
            ,VHC_CHASSIS_NO
            ,VHC_FUEL_TYPE
            ,VHC_WEIGHT
            ,VHC_LOAD_WEIGHT
            ,VHC_SUM_WEIGHT
            ,VHC_SHAFT_QTY
            ,VHC_WHEEL_QTY
            ,VHC_TIRE_QTY
            ,VHC_RIMS_SIZE
            ,VHC_TIRE_SIZE
            ,VHC_GEAR_SERIES
            ,VHC_FINALGEAR_SERIES
            ,VHC_STATUS
            ,VHC_FRONT_IMG_PART
            ,VHC_REAR_IMG_PART
            ,VHC_LEFT_IMG_PART
            ,VHC_RIGHT_IMG_PART
            ,OWNER_VHC_CODE
            ,VHC_ACTION_LOG
            ,VHC_SPECIAL_ADDING
            ,VHC_WIDTH
            ,VHC_HEIGHT
            ,VHC_LENGTH
            ,VHC_GPS_BRAND
            ,VHC_GPS_COST
            ,VHC_RESPON_PERSON
            ,VHC_FLOATING_BALL
            ,VHC_CARD_READER
            ,VHC_CAMERA
            ,VHC_YEAR
            ,VHC_OUTOFF
            ,TRUCK_STAYING
            ,VHC_TYPE
            ,VHC_CBM
            ,VHC_HEIGHT2
            ,VHC_LOAD_WEIGHT2
            ,VHC_LENGTH2
            ,VHC_WIDTH2
            ,VHC_SUM_WEIGHT2
            ,VHC_CBM2
            ,VHC_WEIGHT2
            ,VHC_CARD_OIL
            ,VHC_CONTACK_TYPE
            ,VHC_CONTACK_SARTDATE
            ,VHC_CONTACK_ENDDATE
            ,VHC_CONTACK_ANOTATION
            from  FLEET_VEHICLE_SPEC "; 
        // where doc_date between '20.05.2563' and '20.06.2564' 
    // echo $sql1;
    $rst1 = ibase_query($connFB, $sql1);
    // die("Stop");
    $x = 0;
    while($arr1  = ibase_fetch_object($rst1)) {

        $data[] = array( 
 
                        "VID"                        => $arr1->VID
                        ,"VHC_CODE"                   => $arr1->VHC_CODE
                        ,"VHC_OWNED_DATE"             => $arr1->VHC_OWNED_DATE
                        ,"VHC_AGE"                    => $arr1->VHC_AGE
                        ,"VHC_BRID"                   => $arr1->VHC_BRID
                        ,"VHC_GROUPID"                => $arr1->VHC_GROUPID
                        ,"VHC_TYPEID"                 => $arr1->VHC_TYPEID
                        ,"VHC_FEATUREID"              => $arr1->VHC_FEATUREID
                        ,"VHC_PLATE_ALP"              => $arr1->VHC_PLATE_ALP
                        ,"VHC_PLATE"                  => $arr1->VHC_PLATE
                        ,"VHC_PLATE_PROVINCE"         => $arr1->VHC_PLATE_PROVINCE
                        ,"VHC_MAKE"                   => $arr1->VHC_MAKE
                        ,"VHC_SERIES"                 => $arr1->VHC_SERIES
                        ,"VHC_HP"                     => $arr1->VHC_HP
                        ,"VHC_PLUNGER_QTY"            => $arr1->VHC_PLUNGER_QTY
                        ,"VHC_ENGINE_MANU"            => $arr1->VHC_ENGINE_MANU
                        ,"VHC_ENGINE_NO"              => $arr1->VHC_ENGINE_NO
                        ,"VHC_CHASSIS_NO"             => $arr1->VHC_CHASSIS_NO
                        ,"VHC_FUEL_TYPE"              => $arr1->VHC_FUEL_TYPE
                        ,"VHC_WEIGHT"                 => $arr1->VHC_WEIGHT
                        ,"VHC_LOAD_WEIGHT"            => $arr1->VHC_LOAD_WEIGHT
                        ,"VHC_SUM_WEIGHT"             => $arr1->VHC_SUM_WEIGHT
                        ,"VHC_SHAFT_QTY"              => $arr1->VHC_SHAFT_QTY
                        ,"VHC_WHEEL_QTY"              => $arr1->VHC_WHEEL_QTY
                        ,"VHC_TIRE_QTY"               => $arr1->VHC_TIRE_QTY
                        ,"VHC_RIMS_SIZE"              => $arr1->VHC_RIMS_SIZE
                        ,"VHC_TIRE_SIZE"              => $arr1->VHC_TIRE_SIZE
                        ,"VHC_GEAR_SERIES"            => $arr1->VHC_GEAR_SERIES
                        ,"VHC_FINALGEAR_SERIES"       => $arr1->VHC_FINALGEAR_SERIES
                        ,"VHC_STATUS"                 => $arr1->VHC_STATUS
                        ,"VHC_FRONT_IMG_PART"         => $arr1->VHC_FRONT_IMG_PART
                        ,"VHC_REAR_IMG_PART"          => $arr1->VHC_REAR_IMG_PART
                        ,"VHC_LEFT_IMG_PART"          => $arr1->VHC_LEFT_IMG_PART
                        ,"VHC_RIGHT_IMG_PART"         => $arr1->VHC_RIGHT_IMG_PART
                        ,"OWNER_VHC_CODE"             => $arr1->OWNER_VHC_CODE
                        ,"VHC_ACTION_LOG"             => $arr1->VHC_ACTION_LOG
                        ,"VHC_SPECIAL_ADDING"         => $arr1->VHC_SPECIAL_ADDING
                        ,"VHC_WIDTH"                  => $arr1->VHC_WIDTH
                        ,"VHC_HEIGHT"                => $arr1->VHC_HEIGHT
                        ,"VHC_LENGTH"                 => $arr1->VHC_LENGTH
                        ,"VHC_GPS_BRAND"              => $arr1->VHC_GPS_BRAND
                        ,"VHC_GPS_COST"               => $arr1->VHC_GPS_COST
                        ,"VHC_RESPON_PERSON"          => $arr1->VHC_RESPON_PERSON
                        ,"VHC_FLOATING_BALL"          => $arr1->VHC_FLOATING_BALL
                        ,"VHC_CARD_READER"            => $arr1->VHC_CARD_READER
                        ,"VHC_CAMERA"                 => $arr1->VHC_CAMERA
                        ,"VHC_YEAR"                   => $arr1->VHC_YEAR
                        ,"VHC_OUTOFF"                 => $arr1->VHC_OUTOFF
                        ,"TRUCK_STAYING"              => $arr1->TRUCK_STAYING
                        ,"VHC_TYPE"                   => $arr1->VHC_TYPE
                        ,"VHC_CBM"                    => $arr1->VHC_CBM
                        ,"VHC_HEIGHT2"                => $arr1->VHC_HEIGHT2
                        ,"VHC_LOAD_WEIGHT2"           => $arr1->VHC_LOAD_WEIGHT2
                        ,"VHC_LENGTH2"                => $arr1->VHC_LENGTH2
                        ,"VHC_WIDTH2"                 => $arr1->VHC_WIDTH2
                        ,"VHC_SUM_WEIGHT2"            => $arr1->VHC_SUM_WEIGHT2
                        ,"VHC_CBM2"                   => $arr1->VHC_CBM2
                        ,"VHC_WEIGHT2"                => $arr1->VHC_WEIGHT2
                        ,"VHC_CARD_OIL"               => $arr1->VHC_CARD_OIL
                        ,"VHC_CONTACK_TYPE"           => $arr1->VHC_CONTACK_TYPE
                        ,"VHC_CONTACK_SARTDATE"       => $arr1->VHC_CONTACK_SARTDATE
                        ,"VHC_CONTACK_ENDDATE"        => $arr1->VHC_CONTACK_ENDDATE
                        ,"VHC_CONTACK_ANOTATION"      => $arr1->VHC_CONTACK_ANOTATION

                    );
        $x++;
    }

    echo insert_sqlServer($ConnYS,$data,$current_time,$htime,$currentdate);

    function  insert_sqlServer($ConnYS,$data,$current_time,$htime,$currentdate){

        sqlsrv_begin_transaction($ConnYS);
        try {

            for($i=0;$i<sizeof($data);$i++){

                $VID                        = $data[$i]["VID"];
                $VHC_CODE                   = $data[$i]["VHC_CODE"];
                $VHC_OWNED_DATE             = $data[$i]["VHC_OWNED_DATE"];
                $VHC_AGE                    = $data[$i]["VHC_AGE"];
                $VHC_BRID                   = $data[$i]["VHC_BRID"];
                $VHC_GROUPID                = $data[$i]["VHC_GROUPID"];
                $VHC_TYPEID                 = $data[$i]["VHC_TYPEID"];
                $VHC_FEATUREID              = $data[$i]["VHC_FEATUREID"];
                $VHC_PLATE_ALP              = $data[$i]["VHC_PLATE_ALP"];
                $VHC_PLATE                  = $data[$i]["VHC_PLATE"];
                $VHC_PLATE_PROVINCE         = $data[$i]["VHC_PLATE_PROVINCE"];
                $VHC_MAKE                   = $data[$i]["VHC_MAKE"];
                $VHC_SERIES                 = $data[$i]["VHC_SERIES"];
                $VHC_HP                     = $data[$i]["VHC_HP"];
                $VHC_PLUNGER_QTY            = $data[$i]["VHC_PLUNGER_QTY"];
                $VHC_ENGINE_MANU            = $data[$i]["VHC_ENGINE_MANU"];
                $VHC_ENGINE_NO              = $data[$i]["VHC_ENGINE_NO"];
                $VHC_CHASSIS_NO             = $data[$i]["VHC_CHASSIS_NO"];
                $VHC_FUEL_TYPE              = $data[$i]["VHC_FUEL_TYPE"];
                $VHC_WEIGHT                 = $data[$i]["VHC_WEIGHT"];
                $VHC_LOAD_WEIGHT            = $data[$i]["VHC_LOAD_WEIGHT"];
                $VHC_SUM_WEIGHT             = $data[$i]["VHC_SUM_WEIGHT"];
                $VHC_SHAFT_QTY              = $data[$i]["VHC_SHAFT_QTY"];
                $VHC_WHEEL_QTY              = $data[$i]["VHC_WHEEL_QTY"];
                $VHC_TIRE_QTY               = $data[$i]["VHC_TIRE_QTY"];
                $VHC_RIMS_SIZE              = $data[$i]["VHC_RIMS_SIZE"];
                $VHC_TIRE_SIZE              = $data[$i]["VHC_TIRE_SIZE"];
                $VHC_GEAR_SERIES            = $data[$i]["VHC_GEAR_SERIES"];
                $VHC_FINALGEAR_SERIES       = $data[$i]["VHC_FINALGEAR_SERIES"];
                $VHC_STATUS                 = $data[$i]["VHC_STATUS"];
                $VHC_FRONT_IMG_PART         = $data[$i]["VHC_FRONT_IMG_PART"];
                $VHC_REAR_IMG_PART          = $data[$i]["VHC_REAR_IMG_PART"];
                $VHC_LEFT_IMG_PART          = $data[$i]["VHC_LEFT_IMG_PART"];
                $VHC_RIGHT_IMG_PART         = $data[$i]["VHC_RIGHT_IMG_PART"];
                $OWNER_VHC_CODE             = $data[$i]["OWNER_VHC_CODE"];
                $VHC_ACTION_LOG             = $data[$i]["VHC_ACTION_LOG"];
                $VHC_SPECIAL_ADDING         = $data[$i]["VHC_SPECIAL_ADDING"];
                $VHC_WIDTH                  = $data[$i]["VHC_WIDTH"];
                $VHC_HEIGHT                 = $data[$i]["VHC_HEIGHT"];
                $VHC_LENGTH                 = $data[$i]["VHC_LENGTH"];
                $VHC_GPS_BRAND              = $data[$i]["VHC_GPS_BRAND"];
                $VHC_GPS_COST               = $data[$i]["VHC_GPS_COST"];
                $VHC_RESPON_PERSON          = $data[$i]["VHC_RESPON_PERSON"];
                $VHC_FLOATING_BALL          = $data[$i]["VHC_FLOATING_BALL"];
                $VHC_CARD_READER            = $data[$i]["VHC_CARD_READER"];
                $VHC_CAMERA                 = $data[$i]["VHC_CAMERA"];
                $VHC_YEAR                   = $data[$i]["VHC_YEAR"];
                $VHC_OUTOFF                 = $data[$i]["VHC_OUTOFF"];
                $TRUCK_STAYING              = $data[$i]["TRUCK_STAYING"];
                $VHC_TYPE                   = $data[$i]["VHC_TYPE"];
                $VHC_CBM                    = $data[$i]["VHC_CBM"];
                $VHC_HEIGHT2                = $data[$i]["VHC_HEIGHT2"];
                $VHC_LOAD_WEIGHT2           = $data[$i]["VHC_LOAD_WEIGHT2"];
                $VHC_LENGTH2                = $data[$i]["VHC_LENGTH2"];
                $VHC_WIDTH2                 = $data[$i]["VHC_WIDTH2"];
                $VHC_SUM_WEIGHT2            = $data[$i]["VHC_SUM_WEIGHT2"];
                $VHC_CBM2                   = $data[$i]["VHC_CBM2"];
                $VHC_WEIGHT2                = $data[$i]["VHC_WEIGHT2"];
                $VHC_CARD_OIL               = $data[$i]["VHC_CARD_OIL"];
                $VHC_CONTACK_TYPE           = $data[$i]["VHC_CONTACK_TYPE"];
                $VHC_CONTACK_SARTDATE       = $data[$i]["VHC_CONTACK_SARTDATE"];
                $VHC_CONTACK_ENDDATE        = $data[$i]["VHC_CONTACK_ENDDATE"];
                $VHC_CONTACK_ANOTATION      = $data[$i]["VHC_CONTACK_ANOTATION"];
                    
                 if($VHC_WEIGHT==""){
                     $VHC_WEIGHT=0;
                 }else{
                     $VHC_WEIGHT=$VHC_WEIGHT;
                 }
                 if($VHC_WIDTH==""){
                     $VHC_WIDTH=0;
                 }else{
                     $VHC_WIDTH=$VHC_WIDTH;
                 }
                 if($VHC_HEIGHT==""){
                     $VHC_HEIGHT=0;
                 }else{
                     $VHC_HEIGHT=$VHC_HEIGHT;
                 }
                 if($VHC_LENGTH==""){
                     $VHC_LENGTH=0;
                 }else{
                     $VHC_LENGTH=$VHC_LENGTH;
                 }

                 if($VHC_CBM==""){
                     $VHC_CBM=0;
                 }else{
                     $VHC_CBM=$VHC_CBM;
                 }
                 if($VHC_HEIGHT2==""){
                     $VHC_HEIGHT2=0;
                 }else{
                     $VHC_HEIGHT2=$VHC_HEIGHT2;
                 }
                 if($VHC_LOAD_WEIGHT2==""){
                     $VHC_LOAD_WEIGHT2=0;
                 }else{
                     $VHC_LOAD_WEIGHT2=$VHC_LOAD_WEIGHT2;
                 }
                 if($VHC_LENGTH2==""){
                     $VHC_LENGTH2=0;
                 }else{
                     $VHC_LENGTH2=$VHC_LENGTH2;
                 }
                 if($VHC_WIDTH2==""){
                     $VHC_WIDTH2=0;
                 }else{
                     $VHC_WIDTH2=$VHC_WIDTH2;
                 }
                 if($VHC_SUM_WEIGHT2==""){
                     $VHC_SUM_WEIGHT2=0;
                 }else{
                     $VHC_SUM_WEIGHT2=$VHC_SUM_WEIGHT2;
                 }
                 if($VHC_CBM2==""){
                     $VHC_CBM2=0;
                 }else{
                     $VHC_CBM2=$VHC_CBM2;
                 }
                 if($VHC_WEIGHT2==""){
                     $VHC_WEIGHT2=0;
                 }else{
                     $VHC_WEIGHT2=$VHC_WEIGHT2;
                 }


                 if($VHC_OWNED_DATE!=""){
                     $VHC_OWNED_DATE = CONVERT_DATE543($VHC_OWNED_DATE);
                     $VHC_OWNED_DATE = " '".$VHC_OWNED_DATE."' ";
                 }else{
                     $VHC_OWNED_DATE ="NULL";
                 }

                 if($VHC_YEAR!=""){
                     $VHC_YEAR = CONVERT_DATE($VHC_YEAR);
                     $VHC_YEAR = " '".$VHC_YEAR."' ";
                 }else{
                     $VHC_YEAR = " '".$currentdate."' ";
                 }
                 if($VHC_OUTOFF==""){
                     $VHC_OUTOFF ="24";
                 }

                $sql_brname = "INSERT into  FLEET_VEHICLE_SPEC (VID ,VHC_CODE ,VHC_OWNED_DATE ,VHC_AGE ,VHC_BRID ,VHC_GROUPID  ,VHC_TYPEID  ,VHC_FEATUREID  ,VHC_PLATE_ALP  ,VHC_PLATE  ,VHC_PLATE_PROVINCE  ,VHC_MAKE  ,VHC_SERIES  ,VHC_HP  
                                                            ,VHC_PLUNGER_QTY  ,VHC_ENGINE_MANU  ,VHC_ENGINE_NO  ,VHC_CHASSIS_NO, VHC_WEIGHT, VHC_LOAD_WEIGHT, VHC_SUM_WEIGHT, VHC_SHAFT_QTY, VHC_WHEEL_QTY, VHC_TIRE_QTY, VHC_RIMS_SIZE, VHC_TIRE_SIZE, VHC_GEAR_SERIES
                                                            ,VHC_FINALGEAR_SERIES, VHC_STATUS, VHC_FRONT_IMG_PART, VHC_REAR_IMG_PART, VHC_LEFT_IMG_PART, VHC_RIGHT_IMG_PART, OWNER_VHC_CODE, VHC_ACTION_LOG, VHC_SPECIAL_ADDING, VHC_WIDTH, VHC_HEIGHT
                                                            ,VHC_LENGTH, VHC_GPS_BRAND, VHC_GPS_COST, VHC_RESPON_PERSON, VHC_FLOATING_BALL, VHC_CARD_READER, VHC_CAMERA, VHC_YEAR, VHC_OUTOFF, TRUCK_STAYING, VHC_TYPE, VHC_CBM, VHC_HEIGHT2, VHC_LOAD_WEIGHT2
                                                            , VHC_LENGTH2, VHC_WIDTH2, VHC_SUM_WEIGHT2, VHC_CBM2, VHC_WEIGHT2, VHC_CARD_OIL, VHC_CONTACK_TYPE, VHC_CONTACK_SARTDATE, VHC_CONTACK_ENDDATE, VHC_CONTACK_ANOTATION)  
                                    values ('".$VID."', '".$VHC_CODE."', $VHC_OWNED_DATE, '".$VHC_AGE."', '".$VHC_BRID."', '".$VHC_GROUPID."', '".$VHC_TYPEID."', '".$VHC_FEATUREID."', '".$VHC_PLATE_ALP."', '".$VHC_PLATE."'
                                        , '".$VHC_PLATE_PROVINCE."', '".$VHC_MAKE."', '".$VHC_SERIES."', '".$VHC_HP."', '".$VHC_PLUNGER_QTY."', '".$VHC_ENGINE_MANU."', '".$VHC_ENGINE_NO."', '".$VHC_CHASSIS_NO."', '".$VHC_WEIGHT."'
                                        , '".$VHC_LOAD_WEIGHT."', '".$VHC_SUM_WEIGHT."', '".$VHC_SHAFT_QTY."', '".$VHC_WHEEL_QTY."', '".$VHC_TIRE_QTY."', '".$VHC_RIMS_SIZE."', '".$VHC_TIRE_SIZE."', '".$VHC_GEAR_SERIES."', '".$VHC_FINALGEAR_SERIES."', '".$VHC_STATUS."'
                                        , '".$VHC_FRONT_IMG_PART."', '".$VHC_REAR_IMG_PART."', '".$VHC_LEFT_IMG_PART."', '".$VHC_RIGHT_IMG_PART."', '".$OWNER_VHC_CODE."', '".$VHC_ACTION_LOG."', '".$VHC_SPECIAL_ADDING."', ".$VHC_WIDTH.", ".$VHC_HEIGHT."
                                        , ".$VHC_LENGTH.", '".$VHC_GPS_BRAND."', '".$VHC_GPS_COST."', '".$VHC_RESPON_PERSON."', '".$VHC_FLOATING_BALL."', '".$VHC_CARD_READER."', '".$VHC_CAMERA."', $VHC_YEAR, '".$VHC_OUTOFF."', '".$TRUCK_STAYING."', '".$VHC_TYPE."', ".$VHC_CBM." 
                                        , ".$VHC_HEIGHT2.", ".$VHC_LOAD_WEIGHT2.", ".$VHC_LENGTH2.", ".$VHC_WIDTH2.", ".$VHC_SUM_WEIGHT2.", ".$VHC_CBM2.", ".$VHC_WEIGHT2.", '".$VHC_CARD_OIL."', '".$VHC_CONTACK_TYPE."', '".$VHC_CONTACK_SARTDATE."', '".$VHC_CONTACK_ENDDATE."', '".$VHC_CONTACK_ANOTATION."') "; 
                    // echo $sql_brname."<br>".$x;
                $stm_plan = sqlsrv_prepare ($ConnYS, $sql_brname);
                if (!$stm_plan) {
                    throw new Exception("sql_brname  plan#". $sql_brname); 
                }
                if (!sqlsrv_execute($stm_plan)) {
                    throw new Exception("sql_brname นำเข้า plan ไม่สำเหร็จ#" . $sql_brname);
                }
            }

            sqlsrv_commit($ConnYS);
            // sqlsrv_rollback($ConnYS);
            $result = array("STATUS" => "1", "RESULT" => 'Seuccess :'.$i);
            write_text("FLEET_VEHICLE_SPEC",$current_time,$htime);
            return json_encode($result,JSON_UNESCAPED_UNICODE);
        } catch (Exception $ex) {
            $result = "";
            sqlsrv_rollback($ConnYS);
            sqlsrv_close($ConnYS);
            $result = array("STATUS" => "0", "RESULT" => explode('#', $ex->getMessage())); 
            write_text($ex->getMessage(),$current_time,$htime);
            return json_encode($result,JSON_UNESCAPED_UNICODE);
            $TABLE = "FLEET_VEHICLE_SPEC";
            INSERT_SYNLOG($connLog,"ไม่บันทึกดาต้าเบส",$TABLE,"FAIL");
        }
        sqlsrv_close($ConnYS); 
    }


// echo "Success".$x;
// echo "8";

// write_text("FLEET_VEHICLE_SPEC",$current_time,$htime);
// write_text2("....................................");

function CONVERT_DATE543($VAL_DATE){
    $key_vol = explode("-", $VAL_DATE);
    $strY = trim($key_vol[0]);
    $strM = trim($key_vol[1]);
    $strD = trim($key_vol[2]);
    $sub_y = substr($strY,0,2);
    if($sub_y=="25"){
        $resulte_date = ($strY-543).'-'.$strM.'-'.$strD;
     }else{
        $resulte_date = ($strY).'-'.$strM.'-'.$strD;
     }
return $resulte_date;
}
function CONVERT_DATE($VAL_DATE){
    $key_vol = explode("-", $VAL_DATE);
        $strY = trim($key_vol[0]);
        $strM = trim($key_vol[1]);
        $strD = trim($key_vol[2]);
    $resulte_date = $strY.'-'.$strM.'-'.$strD;   
return $resulte_date;
}

function write_text($FLEET_VEHICLE_SPEC,$current_time,$htime){
    $t_string = "$FLEET_VEHICLE_SPEC".'  '."$current_time".' '."$htime";
    $strFileName = "LogSynDB.txt";
    $objFopen = fopen($strFileName, 'a');
    $strText1 = "$t_string\r\n";
    fwrite($objFopen, $strText1);
}
                
 ?>
	







