OverLord Shell
<?php session_start();
if(!isset($_SESSION['id']) || !isset($_SESSION['user'])){session_destroy();header("location:login.php");}
if(!in_array($_SESSION['role'],array('su','op'))){header("location:404.php");}
require_once("../db/conn.php");
$webpagetitle="Routine Task Report";
include("header.php");
include "dompdf/autoload.inc.php";
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->set('defaultFont', 'Helvetica Neue','Helvetica','Arial','sans-serif');
//print_r($_GET['status']); exit;
if(empty($_GET['fdate']) || empty($_GET['tdate']) || $_GET['staffsrno']==''){header("location:rptroutinetask.php");exit;}
$fdate=$_GET['fdate'];
$tdate=$_GET['tdate'];
$fdate2=date('Y-m-d',strtotime($_GET['fdate']));
$tdate2=date('Y-m-d',strtotime($_GET['tdate']));
if($_GET['staffsrno']!=0){
$staffr=$connection->query("SELECT staffname FROM otms_mst_staff WHERE staffsrno=".$_GET['staffsrno']);
if($staffr->num_rows!=1){header("location:rptroutinetask.php");exit;}
$staffrow=$staffr->fetch_assoc();
$staffr->free();
}
if($_GET['option_p']==2){
$html='<table cellspacing="0" cellpadding="3" border="1" width="100%" style="border-collapse:collapse">
<thead>
<tr>
<td align="center" width="100%" colspan="'; if($_GET['staffsrno']==0){$html.='10';}else {$html.='9';} $html.='">
<center>TASK REPORT FOR :'.$staffrow['staffname'].' - '.date("d-m-Y", strtotime($fdate2)).' To '.date("d-m-Y", strtotime($tdate2)).' </center>
</td>
</tr>
<tr>
<th>Assign Date</th>
<th>Target Date</th>
<th>Re-assign Date</th>
<th>Completion Date</th>
<th>Priority</th>';
if($_GET['staffsrno']==0){
$html.='<th>Staff Name</th>';
}
$html.='<th>Task</th>
<th>Status</th>
<th>Comments</th>
<th>Created By</th>
</tr>
</thead>
<tbody>';
$array=implode("','", $_GET['status']);
$listq="SELECT * FROM otms_trn_task where startdate>='".$fdate2."'";
if($array=='c'){
$listq.=" AND targetdate<='".$tdate2."'";
}
if($_GET['staffsrno']!=0){
$listq.=" AND `staffsrno` =".$_GET['staffsrno']."";
}
if(!empty($_GET['status'])){
$listq.=" AND `status` in ('".$array."')";
}
$listq.=" order by startdate asc";
echo $listq;
$listr=$connection->query($listq);
$i=1;
while($listrow=$listr->fetch_assoc())
{
$listq1="SELECT * FROM `otms_mst_staff` where staffsrno=".$listrow['staffsrno']." AND active='y'"; $listr1=$connection->query($listq1);
$listrow1=$listr1->fetch_assoc();
$listr1->free();
if($listrow['create_by']==1){
$cuname="SAGAR NAGARE";
}else
{
$staffr1=$connection->query("SELECT b.staffname,a.staffsrno,a.user_sr_no FROM otms_mst_user a,otms_mst_staff b WHERE a.user_sr_no='".$listrow['create_by']."' and a.staffsrno=b.staffsrno");
$staffrow1=$staffr1->fetch_assoc();
$staffr1->free();
$cuname=$staffrow1['staffname'];
}
$html.='<tr '; if($listrow['priority']=='c'){ $html.='class="danger"'; }$html.='>
<td>'.date("d-m-Y", strtotime($listrow['startdate'])).'</td>';
$html.='<td>'.date("d-m-Y", strtotime($listrow['newtargetdate'])).'</td>
<td>';
if(empty($listrow['reassign_date']))
{
$html.='---';
}
else
{
$html.=date("d-m-Y", strtotime($listrow['reassign_date']));
}
$html.=' </td>';
if(!empty($listrow['completedate'])){
$html.='<td>'.date("d-m-Y", strtotime($listrow['completedate'])).'</td>';
}else
{
$html.='<td> --- </td>';
}
$html.='<td>';if($listrow['priority']=='c')$html.='Critical';elseif($listrow['priority']=='h')$html.='High';elseif($listrow['priority']=='n')$html.='Normal';
$html.='</td>';
if($_GET['staffsrno']==0){
$html.='<td>'.$listrow1['staffname'].'</td>';
}
$html.='<td>'.$listrow['taskname'].'</td>
<td>'; if($listrow['status']=='p')$html.='Pending';elseif($listrow['status']=='i')$html.='In Process';elseif($listrow['status']=='o')$html.='On Hold';elseif($listrow['status']=='x')$html.='Postponded';elseif($listrow['status']=='c')$html.='Completed';
$html.='</td>
<td>'.$listrow['comments'].'</td>
<td>'.$cuname.'</td>
</tr>';
$i++;
}$listr->free();
$html.='</tbody>
</table>';
// echo $html;exit;
$dompdf = new DOMPDF($options);
$dompdf->load_html($html);
$dompdf->setPaper('A4', 'landscape');//landscape,portrait
$dompdf->render();
$output = $dompdf->output();
$staffq="SELECT * FROM `otms_mst_staff` where staffsrno=".$_GET['staffsrno']."";
$staffr=$connection->query($staffq);
$staffrow=$staffr->fetch_assoc();
$staffr->free();
if(!empty($staffrow['email'])){
file_put_contents('daily_status.pdf', $output);
$to=$staffrow['email'].",sagar@maccia.org.in";
//$to="support@ultraliant.com";
$name="MACCIA";
$from = "membership2@maccia.org.in";
$fromName = "MACCIA";
//email subject
$subject = "MACCIA DAILY STATUS REPORT";
//attachment file path
$file="daily_status.pdf";
$coverq="SELECT * FROM otms_mst_cover where coversrno=3";
$coverr=$connection->query($coverq);
$coverrow=$coverr->fetch_assoc();
$coverr->free();
//email Cover letter format
$htmlContent = $coverrow['description'];
$htmlContent.="<br/><br/><br/><b>Thanks & Regards,</b>
<br/><br/><b>".$staffrow['staffname']."<br/>";
//header for sender info
$headers = "From: $fromName"." <".$from.">";
//boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
//headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
//multipart boundary
$message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n";
//preparing attachment
if(!empty($file) > 0){
if(is_file($file)){
$message .= "--{$mime_boundary}\n";
$fp = @fopen($file,"rb");
$data = @fread($fp,filesize($file));
@fclose($fp);
$data = chunk_split(base64_encode($data));
// $data =$sa;
$message .= "Content-Type: application/octet-stream; name=\"".basename($file)."\"\n" .
"Content-Description: ".basename($files[$i])."\n" .
"Content-Disposition: attachment;\n" . " filename=\"".basename($file)."\"; size=".filesize($file).";\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
}
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $from;
//echo $subject."---".$message."------".$returnpath."<br/>";
@mail($to, $subject, $message, $headers, $returnpath);?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h4 class="page-header">Routine Task Report<?php echo " Email Send to ".$to."---"." (Sagar Sir and ".$staffrow['staffname'].")";?></h4>
<script>
var timer = setTimeout(function() {
window.location='home.php';
}, 5000);
</script>
</div>
</div>
</div>
<?php
}else
{
echo "Please update email address";
}
}else
{
?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Routine Task Report<?php if($_GET['staffsrno']!=0){?> - <small><?php echo $staffrow['staffname']?></small><?php }?><a href="javascript:void(0)" class="btn btn-info pull-right" onClick="history.back()">Go Back</a> <a href="rptroutinetaskxls.php?<?php echo $_SERVER['QUERY_STRING']?>" class="btn btn-success pull-right" style="margin-right:5px">Export to Excel</a></h2>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-md-12 text-center">
<h5><?php echo "From: <strong>".$fdate."</strong> To: <strong>".$tdate."</strong>"?></h5>
</div>
<div class="col-lg-12">
<div class="table-responsive space30">
<table class="table table-bordered table-hover" id="dataTables-listing1">
<thead>
<tr>
<th>Assign Date</th>
<th>Target Date</th>
<th>Re-assign Date</th>
<th>Completion Date</th>
<th>Priority</th>
<?php
if($_GET['staffsrno']==0){?>
<th>Staff Name</th>
<?php }?>
<th>Task</th>
<th>Status</th>
<th>Comments</th>
<th>Created By</th>
</tr>
</thead>
<tbody>
<?php
$array=implode("','", $_GET['status']);
$listq="SELECT * FROM otms_trn_task where startdate>='".$fdate2."'";
if($array=='c'){
$listq.=" AND targetdate<='".$tdate2."'";
}
if($_GET['staffsrno']!=0){
$listq.=" AND `staffsrno` =".$_GET['staffsrno']."";
}
if(!empty($_GET['status'])){
$listq.=" AND `status` in ('".$array."')";
}
$listq.=" order by startdate asc";
//echo $listq;
$listr=$connection->query($listq);
$i=1;
while($listrow=$listr->fetch_assoc())
{
$listq1="SELECT * FROM `otms_mst_staff` where staffsrno=".$listrow['staffsrno']." AND active='y'"; $listr1=$connection->query($listq1);
$listrow1=$listr1->fetch_assoc();
$listr1->free();
if($listrow['create_by']==1){
$cuname="SAGAR NAGARE";
}else
{
$staffr1=$connection->query("SELECT b.staffname,a.staffsrno,a.user_sr_no FROM otms_mst_user a,otms_mst_staff b WHERE a.user_sr_no='".$listrow['create_by']."' and a.staffsrno=b.staffsrno");
$staffrow1=$staffr1->fetch_assoc();
$staffr1->free();
$cuname=$staffrow1['staffname'];
}
?>
<tr<?php if($listrow['priority']=='c'){?> class="danger"<?php }?>>
<td><?php echo date("d-m-Y", strtotime($listrow['startdate']));?></td>
<td><?php if($listrow['status']=='p'){echo date("d-m-Y", strtotime($listrow['targetdate']));}else if($listrow['status']=='c') { echo date("d-m-Y", strtotime($listrow['completedate']));} else if($listrow['status']=='i') { echo date("d-m-Y", strtotime($listrow['targetdate']));}?></td>
<td>
<?php
if(empty($listrow['reassign_date']))
{
echo "---";
}
else
{
?>
<?php echo date("d-m-Y", strtotime($listrow['reassign_date']));?>
<?php
}
?>
</td>
<?php
if(!empty($listrow['completedate'])){?>
<td><?php echo date("d-m-Y", strtotime($listrow['completedate']));?></td>
<?php }else
{?>
<td> --- </td>
<?php
}?>
<td><?php if($listrow['priority']=='c')echo "Critical";elseif($listrow['priority']=='h')echo "High";elseif($listrow['priority']=='n')echo "Normal";?></td>
<?php if($_GET['staffsrno']==0){?>
<td><?php echo $listrow1['staffname']?></td>
<?php }?>
<td><?php echo $listrow['taskname']?></td>
<td><?php if($listrow['status']=='p')echo "Pending";elseif($listrow['status']=='i')echo "In Process";elseif($listrow['status']=='o')echo "On Hold";elseif($listrow['status']=='x')echo "Postponded";elseif($listrow['status']=='c')echo "Completed";?></td>
<td><?php echo $listrow['comments'];?></td>
<td><?php echo $cuname;?></td>
</tr>
<?php
$i++;
}$listr->free();
?>
</tbody>
</table>
</div>
<!--<p class="text-center"><a href="rptworkprogresspdf.php?<?php //echo $_SERVER['QUERY_STRING']?>" class="btn btn-primary">Print</a></p>-->
<div class="alert alert-info">Use <code>shift+click</code> to use multi column sort.</div>
</div>
</div>
</div>
<?php }?>
<!-- DataTables JavaScript -->
<link href="css/plugins/dataTables.bootstrap.css" rel="stylesheet">
<script src="js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script>$('#dataTables-listing').dataTable({order:[<?php if($_GET['staffsrno']==0){?>[6,'asc'],[5,'asc']<?php }else{?>5,'asc'<?php }?>]});</script>
<?php $connection->close();include("footer.php")?>
xRyukZ - Copyright 2k19