<?php
if (basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)){
echo "<p align=center><br><br><br><br><br><br><font size=\"6\" color=\"#FF0000\">ILLEGAL ACCESS !!";
echo "<meta http-equiv=\"refresh\" content=\"2; url=../index.php\">";
exit();} 
?>
  <?php
  $omsetkirine=omsetkiri($mid, "", "");
$omsetkanane=omsetkanan($mid, "", "");
if($omsetkirine > 0){
	$omsetskiri = rupiah($omsetkirine);
}else{
	$omsetskiri = "---";
}
if($omsetkanane > 0){
	$omsetskanan = rupiah($omsetkanane);
}else{
	$omsetskanan = "---";
}

  ?>
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">
                    <img src="../themes/img/house-xxl.png" alt="ico" class="header-icon" width="30">
                    Home - Dashboard
                </h1>
            </div>
        </div>

        <div class="row">
            <div class="col-md-4">
                <div class="input-group p-b-10">
                    <input id="ref_url" class="form-control" name="ref_url" type="text" value="https://<?php echo $domain; ?>/?<?php echo $reffa; ?>=<?php echo $user_session; ?>">
                    <span class="input-group-btn">
                        <button id="copy-ref-url" class="btn btn-primary" type="button">Copy</button>
                    </span>
                </div>

            </div>
           
        
 <div class="col-md-4">
            </div>
            <?php if($auto_profits == 1) { ?>
            <div class="col-md-4 text-center">
                <div class="widget widget-stats nbg-grey" style="margin-bottom: 10px;">
                    <div class="stats-info">
                        <?php
						
						$seldepo = "SELECT * FROM deposit WHERE username='$user_session' and status=1 ORDER by id desc limit 1"; 
                        $resdepo = mysql_query($seldepo);
                        $rowsdpo = mysql_fetch_array($resdepo);
                        $expdpow = $rowsdpo['tglend'];	
						$dtmiem=strtotime($expdpow);
						$dtmiemx=strtotime($clientdate);
						if($dtmiem > $dtmiemx){
						?>
                       
                       
                        <h4>DAYS &nbsp; &nbsp; HRS &nbsp; &nbsp; &nbsp;MINS &nbsp; &nbsp; SEC</h4>
                        <p>
                            <strong>
                                <span id="ico-in-dd">00</span>
                                :
                                <span id="ico-in-hh">00</span>
                                :
                                <span id="ico-in-mm">00</span>
                                :
                                <span id="ico-in-ss">00</span>
                            </strong>
                        </p>
                       

                        <script>
                          var end_in = <?php echo $dtmiem; ?>;
                          setInterval(function() {
                            var d = new Date();
                            var current_timestamp = Math.floor(d.getTime() / 1000);
                            var ico_end_diff_timestamp = end_in - current_timestamp;
                            if (ico_end_diff_timestamp > 0) {
                              document.getElementById('ico-in-dd').innerHTML = pad(Math.floor((ico_end_diff_timestamp / 86400)), 2);
                              document.getElementById('ico-in-hh').innerHTML = pad(Math.floor((ico_end_diff_timestamp % 86400) /
                                3600), 2);
                              document.getElementById('ico-in-mm').innerHTML = pad(Math.floor((ico_end_diff_timestamp % 3600) / 60), 2);
                              document.getElementById('ico-in-ss').innerHTML = pad(Math.floor(ico_end_diff_timestamp % 60), 2);
                            }
                          }, 1000);
                        </script>
                        <?php } else { ?>
                         <h4>DAYS &nbsp; &nbsp; HRS &nbsp; &nbsp; &nbsp;MINS &nbsp; &nbsp; SEC</h4>
                        
                        <p>
                            <strong>
                                <span id="ico-in-dd">00</span>
                                :
                                <span id="ico-in-hh">00</span>
                                :
                                <span id="ico-in-mm">00</span>
                                :
                                <span id="ico-in-ss">00</span>
                            </strong>
                        <div class='alert alert-danger'>timer not available, please add deposit first</div>
                        </p>
                        
                        
                       
                        <?php } ?>
                    </div>
                </div>
            </div>
              <?php } ?>
            
            </div>
        <div class="row m-t-10">
            <div class="col-md-6">
                
                <div class="col-md-12 p-0">
                    <div class="widget widget-stats nbg-blue" style="margin-bottom: 10px;">
                        <div class="stats-info">
                            <h4>Total Deposite
                                
                            </h4>
                            <p class="text-center"><strong><?php	   
						  $totdps = total_deposit_memberx($user_session);
						   if ($totdps > 0){ echo rupiah($totdps); }else { echo rupiah(0); }
						   ?>   </strong></p>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 p-0">
                    
                </div>
               <div class="col-md-12 p-0">
                    <div class="widget widget-stats nbg-green" style="margin-bottom: 10px;">
                        <div class="stats-info">
                            <h4>Wallet Balance
                                
                            </h4>
                            <p class="text-center"><strong> <?  $saldocwalete = $db->myewalet($user_session);
			 $pendingcwalete = $db->myewaletpending($user_session);
			 $totalcwalete = $saldocwalete-$pendingcwalete; 
			 if($totalcwalete > 0){ echo rupiah($totalcwalete); }else{ echo rupiah(0);} ?>   </strong></p>
                        </div>
                    </div>
                </div>
                
                </div>
            <div class="col-md-6">
                <div class="col-md-12 p-0">
                    <div class="widget widget-stats nbg-orange" style="margin-bottom: 10px;">
                        <div class="stats-info">
                            <h4>Total Profits:</h4>
                            <p class="text-center"><strong><?php	   
						  $totpvt = total_profit_member($user_session);
						   if ($totpvt > 0){ echo rupiah($totpvt); }else { echo rupiah(0); }
						   ?>     </strong></p>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 p-0">
                    <div class="widget widget-stats nbg-purple" style="margin-bottom: 10px;">
                        <div class="stats-info">
                            <h4>Total Bonus:</h4>
                            <p class="text-center"><strong><?php	   
						  $ttbns = total_komisi_memberx($user_session);
						   if ($ttbns > 0){ echo rupiah(total_komisi_memberx($user_session)); }else { echo rupiah(0); }
						   ?>  </strong></p>
                        </div>
                    </div>
                </div>
                
              
                
                  
                
                
                
                
                            </div>
        </div>

          <?php
				$db->select("id, title, maintext", "content", "published=1 and catid=5");
$title = $db->result(0, "title");
$data = $db->result(0, "maintext");
$data = preg_replace("/{NAMAMEMBER}/", $db->dataku("nama", $user_session), $data);
$data = preg_replace("/{USERNAME}/", $user_session, $data);
$data = preg_replace("/{REFFA}/", $reffa, $data);
$data = preg_replace("/{BISNISNAME}/", $bisnisname, $data);
$data = preg_replace("/{DOMAIN}/", $domain, $data);

				?> 
        <div id="recent-transactions" class="row">
            <div class="col-md-12">
                <div class="panel panel-inverse">
                    <div class="panel-heading bg-grey">
                        <h4 class="text-white"><?php echo $title;?></h4>
                    </div>
                    <div class="panel-body">
                    <?php echo $data;?>
                                            </div>
                </div>
            </div>
        </div>
        
        
        
<div class="row">
            	<div class="col-md-6">
                	
                    
                   <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Latest News</h4>
                        </div>
                        
                        <div class="panel-body">
                        
                        
                        
                        
                        
                                                          
                                    <table id="basic-table" class="table table-bordered" cellspacing="0" width="100%">
                    
                    
              <thead>
                <tr>
              <th>Date</th>
                                    <th>News</th>
                </tr>
              </thead>
              <tbody>
	<?php

$db->select("id_berita, id_user, judul, isi_berita, gambar, tanggal, counter, published", "berita", "published=1", "id_berita desc LIMIT 5");

	while($row = $db->fetch_row()) {
	$judul = $row[2];
	$tgl = formatgl($row[5]);
	$idne = anti_injection($row[0]);
   
	
	?>  
                     <tr> 
                            <td><?php echo $tgl; ?></td>
                            <td><a href='?go=news&page=detail&nid=<?php echo $idne; ?>' title='<?php echo $judul; ?>'><?php echo $judul; ?></a></td>
                            
                        </tr>
                                                                    
        
	<?
		}
	?>
              </tbody>
            </table>
                        </div>
                    </div>
                </div>
                
                
                
                
                
     <div class="col-md-6">
                	
                    
                   <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Latest Notification</h4>
                        </div>
                        
                        <div class="panel-body">
                        
                        
                        
                        
                        
                                                          
                                    <table id="basic-table" class="table table-bordered" cellspacing="0" width="100%">
                    
                    
              <thead>
                <tr>
                <th>#</th>
              <th>Date</th>
                                    <th>News</th>
                </tr>
              </thead>
              <tbody>
	<?php
            $querymnmg = "SELECT * FROM notifikasi WHERE username ='$user_session' order by tgl desc limit 4"; 
            $resultmnmg = mysql_query($querymnmg) or die(mysql_error());
            while($rowmnmg = mysql_fetch_array($resultmnmg)){
			$kd88 = $rowmnmg['kode'];
			$judulnotif = $rowmnmg['judul'];
			$badgene = $rowmnmg['badge'];
			$fawesom = $rowmnmg['jn'];
			$tglen = formatgl($rowmnmg['tgl']);
			$srttglmmg = strtotime($rowmnmg['tgl']);
            $srttglendg = strtotime($clientdate);
			$jlneeg = floor(abs($srttglendg - $srttglmmg));
			
			if($jlneeg < 60){
			$jlnxg = "just now";
			
			}else if($jlneeg > 60 && $jlneeg < 3600){
			$jlnxg = floor(abs($jlneeg/60))." minutes";
			
			}else if($jlneeg > 3600 && $jlneeg < 86400){
			$jlnxg = floor(abs($jlneeg/3600))." hours";
			
			}else if($jlneeg > 86400 && $jlneeg < 604800){
			$jlnxg = floor(abs($jlneeg/86400))." days";
			
			}else if($jlneeg > 604800 && $jlneeg < 2592000){
			$jlnxg = floor(abs($jlneeg/604800))." week";
			
			}else if($jlneeg > 2592000){
			$jlnxg = floor(abs($jlneeg/2592000))." month";
			
			}else{}
		
?> 
                     <tr> 
                            <td><div class="<?php echo $badgene; ?>">
														<i class="<?php echo $fawesom; ?>"></i>
													</div></td>
                            <td><?php echo $tglen; ?></td>
                            <td><a href='index.php?go=notif&page=view&kode=<?php echo $kd88; ?>' title='<?php echo $judulnotif; ?>'><?php echo $judulnotif; ?></a></td>
                            
                        </tr>
                                                                    
        
	<?
		}
	?>
              </tbody>
            </table>
                        </div>
                    </div>
                </div>           
                
                
                
                
			</div>
			<!-- END PAGE CONTENT -->                     
        
        
        