Your IP : 216.73.216.26


Current Path : /home2/wtmwscom/public_html/admin/cronjob/
Upload File :
Current File : /home2/wtmwscom/public_html/admin/cronjob/cron_invest_income.php

<?php

include '../../connection.php';
include '../../function_lib.php';


//$date = "2018-11-19";
//$datetime = $date." 23:59:59";

$datetime = date('Y-m-d H:i:s');
$date = date('Y-m-d');
$today_datetime = new DateTime($date);
//$income_rate_array = array(0 => 0, 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1, 7 => 1, 8 => 1, 9 => 1);
//$income_rate_by_type_array = array(0 => 1, 1 => 1.2, 2 => 1.2,);
$income_amount_array = array(2 => 200, 3 => 400, 4 => 600, 5 => 1000, 6 => 2000, 7 => 4000, 8 => 6000, 9 => 8000, 10 => 10000, 11 => 20000);
//$today_day = date('l');
//$today_day = date('l', strtotime('tomorrow'));
//echo "today day ".$today_day;
//$counter=0;
//if ($today_day == "Monday" || $today_day == "Tuesday" || $today_day == "Wednesday" || $today_day == "Thursday" || $today_day == "Friday") {
//echo "SELECT t2.uid as uid, t2.plan_type as plan_type, t2.type AS type FROM user t2 WHERE t2.status = 0 AND t2.is_paid = 1  AND DATE(t2.reg_date) <= '$date' " . "<br>";
$result = mysqli_query($connection, "SELECT t2.uid as uid, t2.plan_type as plan_type, t2.type AS type FROM user t2 WHERE t2.status = 0 AND t2.is_paid = 1  AND DATE(t2.topup_datetime) <= '$date' ");
//$result = mysqli_query($connection, "SELECT t2.uid as uid, t2.plan_type as plan_type, t2.type AS type FROM user t2 WHERE t2.status = 0 AND t2.is_paid = 1  AND DATE(t2.reg_date)<= '$date' ");
while ($row_user = mysqli_fetch_object($result)) {

    $uid = $row_user->uid;
//        $type_update_date = $row_user->type_update_date;
    $plan_type = $row_user->plan_type;


    $sql_invest_1 = mysqli_fetch_object(mysqli_query($connection, "SELECT count(id) AS count FROM `income` WHERE `uid`='$uid' AND income_type = 7 "))->count;
    if ($sql_invest_1 <= 8) {
        $is_growth = TRUE;
    }
    if ($is_growth) {
        $amount = $income_amount_array[$plan_type];
        if ($amount != 0) {
            mysqli_query($connection, "INSERT INTO `income` (`uid`, `amount`, `income_type`, `datetime`, `status`) VALUES "
                    . "('$uid', '$amount', '7', '" . $datetime . "', '0');");

            mysqli_query($connection, "INSERT INTO `transaction` (`uid`, `amount`, `remaining_amount`, `txn_type`, `txn_mode`, `datetime`, `status`) VALUES "
                    . "('$uid', '$amount', '$amount', '7', '0', '$datetime', '0');");
//     echo "INSERT INTO `transaction` (`uid`, `amount`, `remaining_amount`, `txn_type`, `txn_mode`, `datetime`, `status`) VALUES "
//                    . "('$uid', '$amount', '$amount', '7', '0', '$datetime', '0')";
        }
    }
}
?>