<?php
include("connect.php");
$min_cid = 50000;
$max_cid = 59999;

$min_autoid = 0;
$max_autoid = 27;

$min_date = 1;
$max_date = 9;

$month = "04";


for($x=$min_autoid; $x<=$max_autoid; $x++){
$yy=date("Y"); $fyy=substr($yy,2,2); $mm=date("m"); 
$dd=date("d"); $hi=date("h"); $mi=date("i");
$sa=date("sa"); $sa=date("s");
if(strlen(rand($min_date,$max_date))==1){$d="0".rand($min_date,$max_date);}
else{$d=rand($min_date,$max_date);}

$transid="tr".$fyy.$mm.$dd.$hi.$mi.$x;
$cid=rand($min_cid,$max_cid);
$autodate_time=date("Y")."-".$month."-".$d." ".date('H').":".date("i").":".date("s");


echo "Transaction : ".$transid."<br>
CID : ".$cid."<br>
Date : ".$autodate_time."<br>";

$result_children = $dbh->query("select * from children where cid='$cid'");
$row_children = $result_children->fetchObject(); $count_children = $result_children->rowCount();

if($count_children>0){
    $result_trans = $dbh->query("select * from transactions where autoid='$x'");
    $row_trans = $result_trans->fetchObject(); $count_trans = $result_trans->rowCount();
    if($count_trans>0){
        $insert_trans=$dbh->query("insert into transactions (autodate,date_received,cid,paymethod,transactionid,externalid,amount,ouruser) values('$autodate_time','$row_trans->date_received','$cid','$row_trans->paymethod','$transid','$row_trans->externalid','$row_trans->amount','$row_trans->ouruser')");
        if($insert_trans){
            echo "<div style='background-color:green;color:white;'>Insert Successfully</div><br>";
        }
    }
}
echo "<br>";}
?>