<?php
	/* 
	############################[  <about> ] #######################
		S Name   ::       Inv-X Primadesain
		Update   ::       2013 © Primadesain.Com
		Author   ::       Agus Susanto S.kom
		Website  ::		  http://primadesain.com
		Contact  ::		  <primapc57@gmail.com> // +62 85228657360
	
	Primadesain melayani pembuatan website MLM dan Investasi
	( dengan sistem binary, trinary atau matrix dan matahari )
	juga menerima pembuatan website Iklan Baris, Website Profile,
	Reseller, Hyip, dll.
	############################[ </about> ] #######################
	*/
?>
<?php
date_default_timezone_set('Asia/Jakarta');

include("common.php");
include("classMySQL.php");
$db = new db_mysql($server_name, $userdb, $passdb, $databasename,"");
include("function.php");
require_once('class.phpmailer.php');
include("class.smtp.php");

mysql_connect($server_name, $userdb, $passdb) or die ("Could not connect to database");
mysql_select_db($databasename);
?>

<?php


$sqljam="SELECT * FROM deposit WHERE status=1"; 
$dtjam=mysql_query($sqljam);
//--------------------------------------tglend <= '$today'

if($dtjam === FALSE) {
    die(mysql_error()); // TODO: better error handling
}
 
 while($rowjam = mysql_fetch_array($dtjam)){
  $usernamekujam = $rowjam['username'];
  $kodekujam = $rowjam['kode'];
  $paketkujam = $rowjam['planame'];
  $tglend = $rowjam['tglend']; 
  $tglendx = date('Y-m-d', strtotime($tglend));
  $tanggalex = date ("Y-m-d");
  $day1 = strtotime($tglendx);
  $day2 = strtotime($tanggalex);
  $interval = round(abs($day1 - $day2) / (60*60*24));
  $reinv= $db->config("reinv");
  $tanggale=date("Y-m-d H:i:s");
  
if($interval <= $reinv){
	
	$sqlo = mysql_query("SELECT * FROM reinv WHERE username='$usernamekujam' and kode='$kodekujam'");
$numo = mysql_num_rows($sqlo);
if(!$numo) {
	mysql_query("insert into reinv values('','$kodekujam', '$usernamekujam', '$paketkujam', '$tanggale', '')");
	$db->insert("notifikasi", "", "'', '$usernamekujam', 'Re-Invest', '', '', 'Re-invest', '$tanggale', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kodekujam'");
	
	
  $nama = $db->dataku("nama", $usernamekujam);
  $email = $db->dataku("email", $usernamekujam);
  $hp = $db->dataku("hp", $usernamekujam);
  
$isimailexp="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Hello ".$nama." (".$usernamekujam."),</p>
<p>Please do re-invest back in ".$bisnisname.",</p>
<p><strong>No: ".$kodekujam."<br>
Currently Package: ".$paketkujam."<br>
Running: ".$interval." days<br>
Date of Deposit: ".formatgl($tgldepo)."<br>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3a = new PHPMailer;
		$mail3a->IsSMTP(); // telling the class to use SMTP
        $mail3a->Host       = $smtphost; // SMTP server
        $mail3a->SMTPAuth   = true;                  // enable SMTP authentication
        $mail3a->Host       = $smtphost; // sets the SMTP server
        $mail3a->Port       = $smtport;                    // set the SMTP port for the GMAIL server
        $mail3a->Username   = $smtpuser; // SMTP account username
        $mail3a->Password   = $smtpass;        // SMTP account password
        $mail3a->setFrom($emailadmin, $bisnisname);
        $mail3a->addAddress($email, $nama);
	    $mail3a->IsHTML(true);       
        $mail3a->Subject = ''.$nama.', re-invest';
        $mail3a->msgHTML($isimailexp);
        $mail3a->send();	
	
	

}
}

}
?>
<?php
mysql_close();
?>
