<?php

session_name("SIGNADMAUTH");
session_start();

include "common/config/config.php";
include "common/config/dbconfig.php";
include "common/functions/funcconnect.php";
openDB();

include "common/functions/funcauthen.php";

if (!authen())
{ header ("location: login.php");
		}
else
{ $drawchart="";
		$qar="SELECT *
								FROM $db_program a
								WHERE tglhapus IS NULL
								GROUP BY idprogram
								ORDER BY idprogram ASC
								";
		$rar=mysqli_query($dbConnection, $qar);
		if (mysqli_num_rows($rar)>0)
		{ $programlist="";
				while ($dar=mysqli_fetch_array($rar))
				{	$qju="SELECT COUNT(idcustomer) AS jumlahpeserta
												FROM $db_customer
												WHERE idprogram='".$dar['idprogram']."'
												";
						$rju=mysqli_query($dbConnection, $qju);
						$dju=mysqli_fetch_array($rju);
						$programlist.="<tr>
																						<td align='left' valign='top' nowrap>
																							".strtoupper($dar['namaprogram'])."
																						</td>
																						<td align='left' valign='top' nowrap>
																							".date("d-m-Y", strtotime($dar['tglmulai']))."
																						</td>
																						<td align='center' valign='top'>
																							".date("d-m-Y", strtotime($dar['tglselesai']))."
																						</td>
																						<td align='center' valign='top' nowrap>
																							<a href='peserta_list.php?idprogram=".$dar['idprogram']."'>".$dju['jumlahpeserta']."</a>
																						</td>
																					</tr>
																					";
						}															
				}
		else
		{ $programlist="<tr>
																			<td align='center' valign='middle' colspan='6'>
																				<br>Tidak ada iklan aktif saat ini.<br><br>
																			</td>
																		</tr>
																		";
				}		
		$content="<table border='0' cellpadding='6px' cellspacing='0' width='100%'>
													<tr>
														<td align='left' valign='top' width='100%'>
															<b class='title'>CUSTOMER</b>
															<br><hr size='1' color='#000000'><br>
															<table border='0' cellpadding='8px' cellspacing='0' width='100%'>
																<tr>
																	<td align='left' valign='top' width='100%'>
																		<table id='' class='display3'>
																			<thead>
																				<tr>
																					<th align='center' valign='middle' width='50%' nowrap>
																						<b>Nama Program</b>
																					</th>
																					<th align='center' valign='middle' nowrap>
																						<b>Mulai</b>
																					</th>
																					<th align='center' valign='middle' nowrap>
																						<b>Selesai</b>
																					</th>
																					<th align='center' valign='middle' nowrap>
																						<b>Peserta</b>
																					</th>
																				</tr>
																			</thead>
																			<tbody>		
																				".$programlist."
																			</tbody>	
																		</table>
																	</td>
																</tr>
															</table>
														</td>
													</tr>
												</table>
												";
		}

include "webmenu.php";
include "common/include/template.php";
$temp=new template;
$temp->define_theme("themes/theme1.html");
$temp->define_tag("{PAGETITLE}", $namaaplikasi);
$temp->define_tag("{NAMAUSER}", strtoupper($_SESSION['SES_FULLNAME']));
$temp->define_tag("{APPMENU}", $webmenu);
$temp->define_tag("{DRAWCHART}", $drawchart);
$temp->define_tag("{APPCONTENT}", $content);
$temp->parse();
$temp->printproses();

closeDB();

?>