<?php include('includes/config/config.php'); header('Content-Type: application/force-download'); header('Content-disposition: attachment; filename=excel_csr_program_report.xls'); ?> <html> <link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" /> <body> <table width="100%"> <tr> <div style="font-size:12px"> <td width="25%" align="left"> Run Date : <?php echo date("d-M-Y"); ?> </td> <td width="50%" align="center" style="font-size:18px"><strong> <?php if ($_REQUEST['program_name'] && $_REQUEST['csr_date1'] && $_REQUEST['csr_date2'] ) { echo "CSR PROGRAM REPORT"; }else{ echo "CSR PROGRAM"; } ?> </strong></td> <td width="25%" align="left"> User : <?php echo $username ?> </td> </tr> </table> <?php if ($_REQUEST['program_name'] && $_REQUEST['csr_date1'] && $_REQUEST['csr_date2'] ) { echo "<h6>Date From : ". $_REQUEST['csr_date1']. " To : " . $_REQUEST['csr_date2'] . "</h6>";} ?> <table border="1" style="text-align: center;"> <?php $i=1; error_log($_REQUEST['program_name']); if ($_REQUEST['program_name'] && $_REQUEST['csr_date1'] && $_REQUEST['csr_date2'] ) { error_log($_REQUEST['csr_date1'] . " DATE DD"); $sql = "SELECT * from csr_program where program_name = '".$_REQUEST['program_name']."' AND date_format(date(start_date_time),'%d-%m-%Y') between '".$_REQUEST['csr_date1']."' AND '".$_REQUEST['csr_date2']."'"; }else{ $sql="SELECT * from csr_program"; } error_log("PDF ". $sql); $result = mysqli_query($conn,$sql); //echo $result; ?> <tr bgcolor="#eeeeee"> <th width="5%" ;>Sr No.</th> <th width="10%" ;>Program Name</th> <th width="10%" ;>Program Details</th> <th width="10%" ;>Program Location</th> <th width="12%" ;>Start date time</th> <th width="12%" ;>End date time</th> <th width="10%" ;>Coordinator Name</th> <th width="10%" ;>Sub - Coordinator Name</th> <th width="10%" ;>Total Participate</th> <th width="10%" ;> Amount</th> </tr> <?php $total_cost=0; while($fetchData=mysqli_fetch_array($result)){?> <tr style="text-align: center;"> <td><?php echo $i ?></td> <td><?php echo $fetchData['program_name']?></td> <td><?php echo $fetchData['program_details']?></td> <td><?php echo $fetchData['location']?></td> <td><?php $date=date_create($fetchData['start_date_time']); echo date_format($date,"d-M-Y h:i A"); ?></td> <td><?php $date=date_create($fetchData['end_date_time']); echo date_format($date,"d-M-Y h:i A"); ?></td> <td><?php echo $fetchData['coordinator_name']?></td> <td><?php echo $fetchData['sub_coordinator_name']?></td> <td><?php echo $fetchData['total_participate']?></td> <td><?php $sql_cost="SELECT sum(total_cost) as total_cost from participate_csr_program where csr_id = '".$fetchData["csr_id"]."'"; $result_cost = mysqli_query($conn,$sql_cost); $participate=mysqli_fetch_array($result_cost); $total_cost+=number_format((float)$participate["total_cost"], 2, '.', ''); echo number_format((float)$participate["total_cost"], 2, '.', '') ;?> </td> </tr> <?php $i++; } ?><tr> <td align="right" colspan="9">Total Amount</td> <td align="left"><?=number_format((float)$total_cost, 2, '.', '')?></td> </tr> </table> </body> </html>