File: /home/psquar12ology1/public_html/dashboard-table-view.php
Search in File Save
<?php require_once 'lib/config.php'; session_start(); if( isset($_SESSION["id"]) ) { // if login then do nothing } elseif( isset($_SESSION["user"]) ) { // if login then do nothing } else { header("location:index.php"); die(); } date_default_timezone_set("Asia/Kolkata"); $currentdate=date("Y-m-d"); $lastday = date('Y-m-d',(strtotime ('-1 day',strtotime($currentdate)))); $currentday = date('Y-m-d'); $admin_query = "SELECT * FROM admin_tbl WHERE id = '".$_SESSION['id']."'"; $query_run = mysqli_query($conn,$admin_query); $admin_row = mysqli_fetch_array($query_run); $msg=''; $err=''; $setting_query = "SELECT * FROM setting"; $query_run = mysqli_query($conn,$setting_query); $setting_row = mysqli_fetch_array($query_run); $why_why_query = "SELECT * FROM why_why"; $query_run = mysqli_query($conn,$why_why_query); $why_why_row = mysqli_fetch_array($query_run); function convertToHoursMins($time, $format = '%02d:%02d') { if ($time < 1) { return; } $hours = floor($time / 60); $minutes = ($time % 60); return sprintf($format, $hours, $minutes); } $manpower_query = "SELECT * FROM manpower"; $query_run = mysqli_query($conn,$manpower_query); $manpower_row = mysqli_fetch_array($query_run); $time_query = "SELECT * FROM last_day_time"; $query_run_time = mysqli_query($conn,$time_query); $time_row = mysqli_fetch_array($query_run_time); $g_w_l_f=$time_row['g_form_time']; $g_w_l_t=$time_row['g_to_time']; $b_d_l_f=$time_row['b_form_time']; $b_d_l_t=$time_row['b_to_time']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="images/favicon.html"> <title>Maintenance Management System Software</title> <!--Core CSS --> <link href="bs3/css/bootstrap.min.css" rel="stylesheet"> <link href="css/bootstrap-reset.css" rel="stylesheet"> <link href="font-awesome/css/font-awesome.css" rel="stylesheet" /> <!--dynamic table--> <link href="js/advanced-datatable/css/demo_page.css" rel="stylesheet" /> <link href="js/advanced-datatable/css/demo_table.css" rel="stylesheet" /> <link rel="stylesheet" href="js/data-tables/DT_bootstrap.css" /> <!-- Custom styles for this template --> <link href="css/style.css" rel="stylesheet"> <link href="css/style-responsive.css" rel="stylesheet" /> <!-- Just for debugging purposes. Don't actually copy this line! --> <!--[if lt IE 9]> <script src="js/ie8-responsive-file-warning.js"></script><![endif]--> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> <![endif]--> </head> <body> <section id="container"> <!--header start--> <header class="header fixed-top clearfix" style="background:<?=$setting_row['bgcolor'];?>;"> <!--logo start--> <div class="brand"> <a href="dashboard.php" class="logo"> <img src="logo/<?=$setting_row['logo'];?>" style="height:70px" alt=""> </a> </div> <!--logo end--> <div class="top-nav clearfix"> <p style="font-size:<?=$setting_row['font_size'];?>px;color:<?=$setting_row['textcolor'];?>;"><?=$setting_row['name'];?></p> <!--search & user info start--> <ul class="nav pull-right top-menu"> <!-- user login dropdown start--> <li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#"> <img alt="" src="images/logo-1.png"> <span class="username"><?=$admin_row['name'];?></span> <b class="caret"></b> </a> <ul class="dropdown-menu extended logout"> <?php if($admin_row['type']=='admin'){?><li><a href="profile.php"><i class=" fa fa-suitcase"></i>Profile</a></li> <li><a href="setting.php"><i class="fa fa-cog"></i> Settings</a></li><?php }?> <li><a href="logout.php"><i class="fa fa-key"></i> Log Out</a></li> </ul> </li> <!-- user login dropdown end --> <li> <div class="sidebar-toggle-box"> <div class="fa fa-bars"></div> </div> </li> </ul> <!--search & user info end--> </div> </header> <!--header end--> <!--sidebar start--> <aside> <div id="sidebar" class="nav-collapse"> <!-- sidebar menu start--> <div class="leftside-navigation"> <ul class="sidebar-menu" id="nav-accordion"> <?php if($admin_row['dashboard']=='1'){?><li><a class="active" href="dashboard.php"><i class="fa fa-dashboard"></i> <span>Dashboard</span></a></li><?php }?> <?php if($admin_row['daillog']=='1'){?><li><a href="daily-log-book.php"><i class="fa fa-circle-o"></i> <span>Daily Log Book</span></a></li><?php }?> <?php if($admin_row['breakdown']=='1'){?><li><a href="breakdown.php"><i class="fa fa-circle-o"></i> <span>Breakdown</span></a></li><?php }?> <?php if($admin_row['document']=='1'){?><li><a href="machine-master-list.php"><i class="fa fa-circle-o"></i> <span>Document</span></a></li><?php }?> <?php if($admin_row['spare_parts']=='1'){?><li><a href="spare-part-management.php"><i class="fa fa-circle-o"></i> <span>Spare Part Management</span></a></li><?php }?> <?php if($admin_row['machime_backup']=='1'){?><li><a href="machine-manual.php"><i class="fa fa-circle-o"></i> <span>Machine Manual/Backup</span></a></li><?php }?> <?php if($admin_row['history_card']=='1'){?><li><a href="history-card.php"><i class="fa fa-circle-o"></i> <span>History Card</span></a></li><?php }?> <?php if($admin_row['tranning']=='1'){?><li><a href="study/study-material.php"><i class="fa fa-circle-o"></i> <span>Tranning</span></a></li><?php }?> <?php if($admin_row['activity_plan']=='1'){?><li><a href="activity-plan.php"><i class="fa fa-circle-o"></i> <span>Activity Plan</span></a></li><?php }?> <?php if($admin_row['budget']=='1'){?><li><a href="budget-vs-actual.php"><i class="fa fa-circle-o"></i> <span>Budget vs Actual</span></a></li><?php }?> </ul> </div> <!-- sidebar menu end--> </div> </aside> <!--sidebar end--> <!--main content start--> <section id="main-content"> <section class="wrapper pb-0"> <div class="row"> <div class="col-sm-12 p-l-r"> <section class="panel"> <header class="panel-heading p-0"> <a href="dashboard.php" class="bd-link">Notification</a> <a href="dashboard-graph-view.php" class="bd-link">Activity/Pending Graph</a> <a href="dashboard-table-view.php" class="bd-link activebd">Activity/Pending Table</a> </header> </section> </div> </div> <style> .dataTables_info{width:30%;} </style> <div class="row"> <div class="col-sm-5 p-l-r"> <section class="panel"> <header class="panel-heading" style="background:#558ed5!important;text-align:center;font-size:16px;"> Breakdown Pending Work </header> <div class="panel-body"> <div class="adv-table x-scroll" style="min-height:310px;"> <table class="display table table-bordered table-striped" id="dynamic-table"> <thead> <tr> <th>S.&nbsp;No.</th> <th style="display:none">#</th> <th>Status</th> <th>Category</th> <th width="15%">BD No.</th> <th>Problem</th> <th>From Date</th> </tr> </thead> <tbody> <?php $min = $why_why_row['min']; $breakdown_list_query = "SELECT * FROM breakdown where total_tym_min >= '$min' AND flag='1' AND status='' ORDER by date DESC, breakdown_no DESC"; $query_run = mysqli_query($conn,$breakdown_list_query); $i=1; while($breakdown_list_row = mysqli_fetch_array($query_run)){ if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="text-align:center;background:red!important;color:#fff;">Pending</td> <td>Why-Why</td> <td>BD<?=$breakdown_list_row['breakdown_no'];?></td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> </tr> <?php } else {?> <tr class="gradeX" style="background:#eee!important;"> <td><?=$i;?></td> <td style="display:none"></td> <td style="text-align:center;background:red!important;color:#fff;">Pending</td> <td>Why-Why</td> <td>BD<?=$breakdown_list_row['breakdown_no'];?></td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> </tr> <?php } $i++; } ?> <?php $breakdown_list_query = "SELECT * FROM breakdown where flag='1' AND status='' group by problem having count(*) >= 2 ORDER by status ASC, count(problem) DESC"; $query_run = mysqli_query($conn,$breakdown_list_query); while($breakdown_list_row = mysqli_fetch_array($query_run)){ if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="text-align:center;background:red!important;color:#fff;">Pending</td> <td>Repeted&nbsp;Breakdown</td> <td><?php $breakdown_link_query = "SELECT * FROM breakdown where flag='1' AND problem ='".$breakdown_list_row['problem']."'"; $query_run_link = mysqli_query($conn,$breakdown_link_query); while($breakdown_link_row = mysqli_fetch_array($query_run_link)){ echo "BD".$breakdown_link_row['breakdown_no'].', '; }?> </td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> </tr> <?php } else {?> <tr class="gradeX" style="background:#eee!important;"> <td><?=$i;?></td> <td style="display:none"></td> <td style="text-align:center;background:red!important;color:#fff;">Pending</td> <td>Repeted&nbsp;Breakdown</td> <td><?php $breakdown_link_query = "SELECT * FROM breakdown where flag='1' AND problem ='".$breakdown_list_row['problem']."'"; $query_run_link = mysqli_query($conn,$breakdown_link_query); while($breakdown_link_row = mysqli_fetch_array($query_run_link)){ echo "BD".$breakdown_link_row['breakdown_no'].', '; }?> </td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> </tr> <?php } $i++; }?> </tfoot> </table> </div> </div> </section> </div> <div class="col-sm-7 p-l-r"> <section class="panel"> <header class="panel-heading" style="background:#77933c!important;text-align:center;font-size:16px;"> Activity Notifications </header> <div class="panel-body"> <div class="adv-table x-scroll" style="min-height:310px;"> <table class="display table table-bordered table-striped" id="dynamic-table"> <thead> <tr> <th>S.&nbsp;No.</th> <th style="display:none">#</th> <th width="15%;">Location</th> <th width="20%;">Sub Location</th> <th width="21%;">Activity</th> <th style="text-align:center;" width="14%;">Target Date</th> <th style="text-align:center;" width="10%;">Priority</th> <th style="text-align:center;" width="10%;">Responsibility</th> </tr> </thead> <tbody> <?php $current_month = date('M-y'); $pm_plan_month = "SELECT * FROM pm_plan where flag='1' AND status!='Done'"; $query_run_month = mysqli_query($conn,$pm_plan_month); $i=0; while($pm_plan_month_row = mysqli_fetch_array($query_run_month)){ if($pm_plan_month_row['month_1']==$current_month){ $c_month = "month_1"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_2']==$current_month){ $c_month = "month_2"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_3']==$current_month){ $c_month = "month_3"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_4']==$current_month){ $c_month = "month_4"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_5']==$current_month){ $c_month = "month_5"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_6']==$current_month){ $c_month = "month_6"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_7']==$current_month){ $c_month = "month_7"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_8']==$current_month){ $c_month = "month_8"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_9']==$current_month){ $c_month = "month_9"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_10']==$current_month){ $c_month = "month_10"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_11']==$current_month){ $c_month = "month_11"; $line_name=$pm_plan_month_row['line_name'];} if($pm_plan_month_row['month_11']==$current_month){ $c_month = "month_12"; $line_name=$pm_plan_month_row['line_name'];} $pm_plan_query = "SELECT * FROM pm_plan where flag='1' AND status!='Done' AND ".$c_month."='".$current_month."' AND line_name='".$line_name."'"; $query_run = mysqli_query($conn,$pm_plan_query); while($pm_plan_row = mysqli_fetch_array($query_run)){ $t_date = str_replace("month","target",$c_month); $pmnotificationdate = date('Y-m-d',(strtotime ('-'.$pm_plan_row['n_day'].' day',strtotime($pm_plan_row[$t_date])))); if($pmnotificationdate >= $currentdate || $currentdate <= $pm_plan_row[$t_date]){ if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td><?=$pm_plan_row['line_name'];?></td> <td><?=$pm_plan_row['machine_name'];?></td> <td>PM</td> <td style="text-align:center;"><?=date("d/m/Y", strtotime($pm_plan_row[$t_date]));?></td> <td style="text-align:center;<?php if($pm_plan_row['priority']=='Medium'){ echo 'background:#1fb5ad;color:#fff;';} elseif($pm_plan_row['priority']=='Low'){ echo 'background:#FCD12A;color:#333;';} else { echo 'background:red;color:#fff;border';}?>"><?=$pm_plan_row['priority'];?></td> <td style="text-align:center;"><?=ucwords($pm_plan_row['responsibility']);?></td> </tr> <?php } else { ?> <tr class="gradeX" style="background:#eee!important;"> <td><?=$i;?></td> <td style="display:none"></td> <td><?=$pm_plan_row['line_name'];?></td> <td><?=$pm_plan_row['machine_name'];?></td> <td>PM</td> <td style="text-align:center;"><?=date("d/m/Y", strtotime($pm_plan_row[$t_date]));?></td> <td style="text-align:center;<?php if($pm_plan_row['priority']=='Medium'){ echo 'background:#1fb5ad;color:#fff;';} elseif($pm_plan_row['priority']=='Low'){ echo 'background:#FCD12A;color:#333;';} else { echo 'background:red;color:#fff;border';}?>"><?=$pm_plan_row['priority'];?></td> <td style="text-align:center;"><?=ucwords($pm_plan_row['responsibility']);?></td> </tr> <?php } } $i++; } }?> <?php $activity_plan_query = "SELECT * FROM activity_plan where flag='1' AND status!='Done' order by target_date DESC"; $query_run = mysqli_query($conn,$activity_plan_query); while($activity_plan_row = mysqli_fetch_array($query_run)){ if($activity_plan_row['n_day'] >= $currentdate || $activity_plan_row['n_day'] <= $activity_plan_row['target_date'] ){ if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td><?=$activity_plan_row['location'];?></td> <td><?=$activity_plan_row['sub_location'];?></td> <td><?=$activity_plan_row['activity'];?></td> <td style="text-align:center;"><?=date("d/m/Y", strtotime($activity_plan_row['target_date']));?></td> <td style="text-align:center;<?php if($activity_plan_row['priority']=='Medium'){ echo 'background:#1fb5ad;color:#fff;';} elseif($activity_plan_row['priority']=='Low'){ echo 'background:#FCD12A;color:#333;';} else { echo 'background:red;color:#fff;border';}?>"><?=$activity_plan_row['priority'];?></td> <td style="text-align:center;"><?=ucwords($activity_plan_row['responsibility']);?></td> </tr> <?php } else {?> <tr class="gradeX" style="background:#eee!important;"> <td><?=$i;?></td> <td style="display:none"></td> <td><?=$activity_plan_row['location'];?></td> <td><?=$activity_plan_row['sub_location'];?></td> <td><?=$activity_plan_row['activity'];?></td> <td style="text-align:center;"><?=date("d/m/Y", strtotime($activity_plan_row['target_date']));?></td> <td style="text-align:center;<?php if($activity_plan_row['priority']=='Medium'){ echo 'background:#1fb5ad;color:#fff;';} elseif($activity_plan_row['priority']=='Low'){ echo 'background:#FCD12A;color:#333;';} else { echo 'background:red;color:#fff;border';}?>"><?=$activity_plan_row['priority'];?></td> <td style="text-align:center;"><?=ucwords($activity_plan_row['responsibility']);?></td> </tr> <?php } } $i++; }?> </tfoot> </table> </div> </div> </section> </div> </div> <div class="row"> <div class="col-sm-12 p-l-r"> <section class="panel"> <header class="panel-heading" style="background:#e46c0a!important;text-align:center;font-size:16px;"> Last Day Breakdown </header> <div class="panel-body"> <div class="adv-table x-scroll"> <table class="display table table-bordered table-striped" id="dynamic-table1"> <thead> <tr> <th rowspan="2">S. No.</th> <th rowspan="2" class="noExl" width="2%;" style="text-align:center;display:none;">#</th> <th rowspan="2">Status</th> <th rowspan="2">BD&nbsp;No.</th> <th rowspan="2">Date</th> <th rowspan="2">Line&nbsp;Name</th> <th rowspan="2">MC Name</th> <th rowspan="2">MC No.</th> <th rowspan="2">From Time</th> <th rowspan="2">To Time</th> <th rowspan="2" style="text-align:center;">Total&nbsp;Time<br>(Min)</th> <th rowspan="2">Type</th> <th rowspan="2">Problem</th> <th rowspan="2">Cause</th> <th rowspan="2">Action</th> <th rowspan="2">Spare Used</th> <th rowspan="2">Spare Name</th> <th rowspan="2">Spare Qty.</th> <th rowspan="2">UOM</th> <th rowspan="2">Spare Cost</th> <th rowspan="2">Department</th> <th rowspan="2">Created&nbsp;By</th> <th rowspan="2">Attended&nbsp;By</th> <th colspan="2">Staff Manpower</th> <th colspan="2">Casual Manpower</th> <th rowspan="2">Total Cost</th> </tr> <tr> <th>Qty.</th> <th>Cost</th> <th>Qty.</th> <th>Cost</th> </tr> </thead> <tbody> <?php $breakdown_list_query = "SELECT * FROM breakdown where flag='1' AND date='".$currentday."' AND from_time <= '".$b_d_l_t."' order by date DESC, breakdown_no DESC"; $query_run = mysqli_query($conn,$breakdown_list_query); $i=1; while($breakdown_list_row = mysqli_fetch_array($query_run)){ if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($breakdown_list_row['b_status']=='Pending'){ echo "red;color:#fff;";}elseif($breakdown_list_row['b_status']=='Done'){ echo "green;color:#fff;";}else{ echo "yellow;color:red;";}?>"><?=$breakdown_list_row['b_status'];?></td> <td>BD<?=$breakdown_list_row['breakdown_no'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> <td><?=$breakdown_list_row['line_name'];?></td> <td><?=$breakdown_list_row['machine_name'];?></td> <td><?=$breakdown_list_row['machine_no'];?></td> <td><?=$breakdown_list_row['from_time'];?></td> <td><?=$breakdown_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($breakdown_list_row['total_tym_min'], '%02d:%02d');?></td> <td><?=$breakdown_list_row['type'];?></td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=$breakdown_list_row['cause'];?></td> <td><?=$breakdown_list_row['action'];?></td> <td><?=$breakdown_list_row['spare_consumption'];?></td> <td><?=$breakdown_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$breakdown_list_row['spare_qty'];?></td> <td><?=$breakdown_list_row['uom'];?></td> <td style="text-align:center;"><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost']);?></td> <td><?=$breakdown_list_row['department'];?></td> <td><?=$breakdown_list_row['created_by'];?></td> <td><?=$breakdown_list_row['attended_by'];?></td> <td><?=$breakdown_list_row['staff'];?></td> <td><?=($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']);?></td> <td><?=$breakdown_list_row['casual'];?></td> <td><?=($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']);?></td> <td><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost'])+(($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']))+(($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']));?></td> </tr> <?php } else {?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($breakdown_list_row['b_status']=='Pending'){ echo "red;color:#fff;";}elseif($breakdown_list_row['b_status']=='Done'){ echo "green;color:#fff;";}else{ echo "yellow;color:red;";}?>"><?=$breakdown_list_row['b_status'];?></td> <td>BD<?=$breakdown_list_row['breakdown_no'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> <td><?=$breakdown_list_row['line_name'];?></td> <td><?=$breakdown_list_row['machine_name'];?></td> <td><?=$breakdown_list_row['machine_no'];?></td> <td><?=$breakdown_list_row['from_time'];?></td> <td><?=$breakdown_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($breakdown_list_row['total_tym_min'], '%02d:%02d');?></td> <td><?=$breakdown_list_row['type'];?></td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=$breakdown_list_row['cause'];?></td> <td><?=$breakdown_list_row['action'];?></td> <td><?=$breakdown_list_row['spare_consumption'];?></td> <td><?=$breakdown_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$breakdown_list_row['spare_qty'];?></td> <td><?=$breakdown_list_row['uom'];?></td> <td style="text-align:center;"><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost']);?></td> <td><?=$breakdown_list_row['department'];?></td> <td><?=$breakdown_list_row['created_by'];?></td> <td><?=$breakdown_list_row['attended_by'];?></td> <td><?=$breakdown_list_row['staff'];?></td> <td><?=($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']);?></td> <td><?=$breakdown_list_row['casual'];?></td> <td><?=($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']);?></td> <td><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost'])+(($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']))+(($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']));?></td> </tr> <?php } $i++; }?> <?php $breakdown_list_query = "SELECT * FROM breakdown where flag='1' AND date='".$lastday."' AND from_time >= '".$b_d_l_f."' order by date DESC, breakdown_no DESC"; $query_run = mysqli_query($conn,$breakdown_list_query); while($breakdown_list_row = mysqli_fetch_array($query_run)){ if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($breakdown_list_row['b_status']=='Pending'){ echo "red;color:#fff;";}elseif($breakdown_list_row['b_status']=='Done'){ echo "green;color:#fff;";}else{ echo "yellow;color:red;";}?>"><?=$breakdown_list_row['b_status'];?></td> <td>BD<?=$breakdown_list_row['breakdown_no'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> <td><?=$breakdown_list_row['line_name'];?></td> <td><?=$breakdown_list_row['machine_name'];?></td> <td><?=$breakdown_list_row['machine_no'];?></td> <td><?=$breakdown_list_row['from_time'];?></td> <td><?=$breakdown_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($breakdown_list_row['total_tym_min'], '%02d:%02d');?></td> <td><?=$breakdown_list_row['type'];?></td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=$breakdown_list_row['cause'];?></td> <td><?=$breakdown_list_row['action'];?></td> <td><?=$breakdown_list_row['spare_consumption'];?></td> <td><?=$breakdown_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$breakdown_list_row['spare_qty'];?></td> <td><?=$breakdown_list_row['uom'];?></td> <td style="text-align:center;"><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost']);?></td> <td><?=$breakdown_list_row['department'];?></td> <td><?=$breakdown_list_row['created_by'];?></td> <td><?=$breakdown_list_row['attended_by'];?></td> <td><?=$breakdown_list_row['staff'];?></td> <td><?=($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']);?></td> <td><?=$breakdown_list_row['casual'];?></td> <td><?=($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']);?></td> <td><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost'])+(($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']))+(($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']));?></td> </tr> <?php } else {?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($breakdown_list_row['b_status']=='Pending'){ echo "red;color:#fff;";}elseif($breakdown_list_row['b_status']=='Done'){ echo "green;color:#fff;";}else{ echo "yellow;color:red;";}?>"><?=$breakdown_list_row['b_status'];?></td> <td>BD<?=$breakdown_list_row['breakdown_no'];?></td> <td><?=date("d/m/Y", strtotime($breakdown_list_row['date']));?></td> <td><?=$breakdown_list_row['line_name'];?></td> <td><?=$breakdown_list_row['machine_name'];?></td> <td><?=$breakdown_list_row['machine_no'];?></td> <td><?=$breakdown_list_row['from_time'];?></td> <td><?=$breakdown_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($breakdown_list_row['total_tym_min'], '%02d:%02d');?></td> <td><?=$breakdown_list_row['type'];?></td> <td><?=$breakdown_list_row['problem'];?></td> <td><?=$breakdown_list_row['cause'];?></td> <td><?=$breakdown_list_row['action'];?></td> <td><?=$breakdown_list_row['spare_consumption'];?></td> <td><?=$breakdown_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$breakdown_list_row['spare_qty'];?></td> <td><?=$breakdown_list_row['uom'];?></td> <td style="text-align:center;"><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost']);?></td> <td><?=$breakdown_list_row['department'];?></td> <td><?=$breakdown_list_row['created_by'];?></td> <td><?=$breakdown_list_row['attended_by'];?></td> <td><?=$breakdown_list_row['staff'];?></td> <td><?=($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']);?></td> <td><?=$breakdown_list_row['casual'];?></td> <td><?=($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']);?></td> <td><?=($breakdown_list_row['spare_qty']*$breakdown_list_row['spare_cost'])+(($breakdown_list_row['staff']*$manpower_row['staff']*$breakdown_list_row['total_tym_min']))+(($breakdown_list_row['casual']*$manpower_row['casual']*$breakdown_list_row['total_tym_min']));?></td> </tr> <?php } $i++; }?> </tfoot> </table> </div> </div> </section> </div> </div> <div class="row"> <div class="col-sm-12 p-l-r"> <section class="panel"> <header class="panel-heading" style="background:#31859c!important;text-align:center;font-size:16px;"> Last Day General Work </header> <div class="panel-body"> <div class="adv-table x-scroll"> <table class="display table table-bordered table-striped" id="dynamic-table"> <thead> <tr> <th rowspan="2">S. No.</th> <th rowspan="2" class="noExl" width="2%;" style="text-align:center;display:none;">#</th> <th rowspan="2">Status</th> <th rowspan="2">Priority</th> <th rowspan="2">Work Order No.</th> <th rowspan="2">Date</th> <th rowspan="2">From</th> <th rowspan="2">To</th> <th rowspan="2">Total&nbsp;Time<br>(Min)</th> <th rowspan="2">Location</th> <th rowspan="2">Sub Location</th> <th rowspan="2">Work Detail</th> <th rowspan="2">Created By</th> <th rowspan="2">Attended By</th> <th rowspan="2">Spare Used</th> <th rowspan="2">Spare Name</th> <th rowspan="2">Spare Qty.</th> <th rowspan="2">UOM</th> <th rowspan="2">Spare Cost</th> <th colspan="2">Staff Manpower</th> <th colspan="2">Casual Manpower</th> <th rowspan="2">Total Cost</th> <th rowspan="2">Remark</th> </tr> <tr> <th>Qty.</th> <th>Cost</th> <th>Qty.</th> <th>Cost</th> </tr> </thead> <tbody> <?php $gernalwork_list_query = "SELECT * FROM gernalwork where flag='1' AND date='".$currentday."' AND from_time <= '".$g_w_l_t."' order by date DESC, work_order DESC"; $query_run = mysqli_query($conn,$gernalwork_list_query); $i=1; while($gernalwork_list_row = mysqli_fetch_array($query_run)){if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($gernalwork_list_row['status']=='Pending'){ echo "red;color:#fff;";}else if($gernalwork_list_row['status']=='Done'){ echo "green;color:#fff;";} else{ echo "yellow;color:red;";}?>"><?=$gernalwork_list_row['status'];?></td> <td><?=$gernalwork_list_row['priority'];?></td> <td>GW<?=$gernalwork_list_row['work_order'];?></td> <td><?=date("d/m/Y", strtotime($gernalwork_list_row['date']));?></td> <td><?=$gernalwork_list_row['from_time'];?></td> <td><?=$gernalwork_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($gernalwork_list_row['total_time_min'], '%02d:%02d');?></td> <td><?=$gernalwork_list_row['location'];?></td> <td><?=$gernalwork_list_row['sub_location'];?></td> <td><?=$gernalwork_list_row['detail'];?></td> <td><?=$gernalwork_list_row['created_by'];?></td> <td><?=$gernalwork_list_row['attended_by'];?></td> <td><?=$gernalwork_list_row['spare_used'];?></td> <td><?=$gernalwork_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$gernalwork_list_row['spare_qty'];?></td> <td><?=$gernalwork_list_row['uom'];?></td> <td style="text-align:center;"><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost']);?></td> <td><?=$gernalwork_list_row['staff'];?></td> <td><?=($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']);?></td> <td><?=$gernalwork_list_row['casual'];?></td> <td><?=($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']);?></td> <td><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost'])+(($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']))+(($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']));?></td> <td><?=$gernalwork_list_row['remark'];?></td> </tr> <?php } else{?> <tr class="gradeX" style="background:#eee!important;"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($gernalwork_list_row['status']=='Pending'){ echo "red;color:#fff;";}else if($gernalwork_list_row['status']=='Done'){ echo "green;color:#fff;";} else{ echo "yellow;color:red;";}?>"><?=$gernalwork_list_row['status'];?></td> <td><?=$gernalwork_list_row['priority'];?></td> <td>GW<?=$gernalwork_list_row['work_order'];?></td> <td><?=date("d/m/Y", strtotime($gernalwork_list_row['date']));?></td> <td><?=$gernalwork_list_row['from_time'];?></td> <td><?=$gernalwork_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($gernalwork_list_row['total_time_min'], '%02d:%02d');?></td> <td><?=$gernalwork_list_row['location'];?></td> <td><?=$gernalwork_list_row['sub_location'];?></td> <td><?=$gernalwork_list_row['detail'];?></td> <td><?=$gernalwork_list_row['created_by'];?></td> <td><?=$gernalwork_list_row['attended_by'];?></td> <td><?=$gernalwork_list_row['spare_used'];?></td> <td><?=$gernalwork_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$gernalwork_list_row['spare_qty'];?></td> <td><?=$gernalwork_list_row['uom'];?></td> <td style="text-align:center;"><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost']);?></td> <td><?=$gernalwork_list_row['staff'];?></td> <td><?=($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']);?></td> <td><?=$gernalwork_list_row['casual'];?></td> <td><?=($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']);?></td> <td><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost'])+(($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']))+(($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']));?></td> <td><?=$gernalwork_list_row['remark'];?></td> </tr> <?php } $i++; }?> <?php $gernalwork_list_query = "SELECT * FROM gernalwork where flag='1' AND date='".$lastday."' AND from_time >= '".$g_w_l_f."' order by date DESC, work_order DESC"; $query_run = mysqli_query($conn,$gernalwork_list_query); while($gernalwork_list_row = mysqli_fetch_array($query_run)){if($i%2==0){?> <tr class="gradeX"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($gernalwork_list_row['status']=='Pending'){ echo "red;color:#fff;";}else if($gernalwork_list_row['status']=='Done'){ echo "green;color:#fff;";} else{ echo "yellow;color:red;";}?>"><?=$gernalwork_list_row['status'];?></td> <td><?=$gernalwork_list_row['priority'];?></td> <td>GW<?=$gernalwork_list_row['work_order'];?></td> <td><?=date("d/m/Y", strtotime($gernalwork_list_row['date']));?></td> <td><?=$gernalwork_list_row['from_time'];?></td> <td><?=$gernalwork_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($gernalwork_list_row['total_time_min'], '%02d:%02d');?></td> <td><?=$gernalwork_list_row['location'];?></td> <td><?=$gernalwork_list_row['sub_location'];?></td> <td><?=$gernalwork_list_row['detail'];?></td> <td><?=$gernalwork_list_row['created_by'];?></td> <td><?=$gernalwork_list_row['attended_by'];?></td> <td><?=$gernalwork_list_row['spare_used'];?></td> <td><?=$gernalwork_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$gernalwork_list_row['spare_qty'];?></td> <td><?=$gernalwork_list_row['uom'];?></td> <td style="text-align:center;"><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost']);?></td> <td><?=$gernalwork_list_row['staff'];?></td> <td><?=($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']);?></td> <td><?=$gernalwork_list_row['casual'];?></td> <td><?=($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']);?></td> <td><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost'])+(($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']))+(($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']));?></td> <td><?=$gernalwork_list_row['remark'];?></td> </tr> <?php } else{?> <tr class="gradeX" style="background:#eee!important;"> <td><?=$i;?></td> <td style="display:none"></td> <td style="background:<?php if($gernalwork_list_row['status']=='Pending'){ echo "red;color:#fff;";}else if($gernalwork_list_row['status']=='Done'){ echo "green;color:#fff;";} else{ echo "yellow;color:red;";}?>"><?=$gernalwork_list_row['status'];?></td> <td><?=$gernalwork_list_row['priority'];?></td> <td>GW<?=$gernalwork_list_row['work_order'];?></td> <td><?=date("d/m/Y", strtotime($gernalwork_list_row['date']));?></td> <td><?=$gernalwork_list_row['from_time'];?></td> <td><?=$gernalwork_list_row['to_time'];?></td> <td style="text-align:center;"><?=convertToHoursMins($gernalwork_list_row['total_time_min'], '%02d:%02d');?></td> <td><?=$gernalwork_list_row['location'];?></td> <td><?=$gernalwork_list_row['sub_location'];?></td> <td><?=$gernalwork_list_row['detail'];?></td> <td><?=$gernalwork_list_row['created_by'];?></td> <td><?=$gernalwork_list_row['attended_by'];?></td> <td><?=$gernalwork_list_row['spare_used'];?></td> <td><?=$gernalwork_list_row['spare_name'];?></td> <td style="text-align:center;"><?=$gernalwork_list_row['spare_qty'];?></td> <td><?=$gernalwork_list_row['uom'];?></td> <td style="text-align:center;"><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost']);?></td> <td><?=$gernalwork_list_row['staff'];?></td> <td><?=($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']);?></td> <td><?=$gernalwork_list_row['casual'];?></td> <td><?=($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']);?></td> <td><?=($gernalwork_list_row['spare_qty']*$gernalwork_list_row['spare_cost'])+(($gernalwork_list_row['staff']*$manpower_row['staff']*$gernalwork_list_row['total_time_min']))+(($gernalwork_list_row['casual']*$manpower_row['casual']*$gernalwork_list_row['total_time_min']));?></td> <td><?=$gernalwork_list_row['remark'];?></td> </tr> <?php } $i++; }?> </tfoot> </table> </div> </div> </section> </div> </div> </section> </section> <!--main content end--> </section> <script src="js/jquery.min.js"></script> <!--Core js--> <script src="bs3/js/bootstrap.min.js"></script> <script class="include" type="text/javascript" src="js/jquery.dcjqaccordion.2.7.js"></script> <script src="js/jquery.scrollTo.min.js"></script> <script src="js/jQuery-slimScroll-1.3.0/jquery.slimscroll.js"></script> <script src="js/jquery.nicescroll.js"></script> <!--dynamic table--> <script type="text/javascript" language="javascript" src="js/advanced-datatable/js/jquery.dataTables1.js"></script> <script type="text/javascript" src="js/data-tables/DT_bootstrap.js"></script> <!--common script init for all pages--> <script src="js/scripts.js"></script> <!--dynamic table initialization --> <script src="js/dynamic_table_init.js"></script> </body> </html>

    xxxxxxxxxx

758
1

    <?php

2

    require_once 'lib/config.php';

3

    session_start();

4

    if( isset($_SESSION["id"]) )

5

    {

6

        // if login then do nothing

7

    }

8

    elseif( isset($_SESSION["user"]) )

9

    {

10

       // if login then do nothing

11

    }

12

    else

13

    {

14

        header("location:index.php");

15

        die();

16

    }

17

    ​

18

    date_default_timezone_set("Asia/Kolkata");

19

    $currentdate=date("Y-m-d");

20

    $lastday = date('Y-m-d',(strtotime ('-1 day',strtotime($currentdate))));

21

    $currentday = date('Y-m-d');

22

    ​

23

    $admin_query = "SELECT * FROM admin_tbl WHERE id = '".$_SESSION['id']."'";

24

    $query_run = mysqli_query($conn,$admin_query);

25

    $admin_row = mysqli_fetch_array($query_run);

26

    $msg='';

27

    $err='';

28

29

    $setting_query = "SELECT * FROM setting";

30

    $query_run = mysqli_query($conn,$setting_query);

31

    $setting_row = mysqli_fetch_array($query_run);

32

    ​

33

    $why_why_query = "SELECT * FROM why_why";

34

    $query_run = mysqli_query($conn,$why_why_query);

35

    $why_why_row = mysqli_fetch_array($query_run);

36

    ​

37

    function convertToHoursMins($time, $format = '%02d:%02d') {

38

        if ($time < 1) {

39

            return;

40

        }

41

        $hours = floor($time / 60);

42

        $minutes = ($time % 60);

43

        return sprintf($format, $hours, $minutes);

44

    }

45

    $manpower_query = "SELECT * FROM manpower";

46

    $query_run = mysqli_query($conn,$manpower_query);

47

    $manpower_row = mysqli_fetch_array($query_run);

48

    ​

File Saved