Hi…
I need a condition in my webpage that if the LOGIN fields is [B]NULL
That row will be highlighted in RED.
i try this code but it did not work…
[code]
$LOGIN = $DTR->fields[‘LOGIN’];
if($LOGIN == NULL){
“<td style=’background-color:RED’>”;
//echo ‘<style = background-color: RED;>’.$DTR.'</style>’;
}
I have this code:
[code]
<?php
include ‘config.php’;
$currentEmpID = $_SESSION[’empID’];
if(!isset($_POST[‘Regsubmit_’])){
$DATE1 = $_GET[‘Regfirstinput’];
$DATE2 = $_GET[‘Regsecondinput’];
$sql = “SELECT a.EMP_NO, CONCAT(LNAME, ‘, ‘ , FNAME, ‘ ‘, MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN ‘$DATE1’ AND ‘$DATE2’
AND em.STATUS IN (‘Reg Operatives’, ‘Reg Staff ‘) OR LOGIN IS NULL”;
$DTR = $conn3->GetAll($sql);
$LOGIN = $DTR->fields[‘LOGIN’];
if($LOGIN == NULL){
“<td style=’background-color:RED’>”;
//echo ‘<style = background-color: RED;>’.$DTR.'</style>’;
}
$smarty->assign(‘attendance’, $DTR);
}
$smarty->display(‘header_att.tpl’);
$smarty->display(‘RegAttendance.tpl’);
$smarty->display(‘footer.tpl’);
?>
[code]
<div id=”attendance” style=”width: 580px; height: 420px; overflow: auto; padding: 5px; top:95px”>
<fieldset>
<legend>Employee Attendance</legend>
<table border=”1″>
<tr>
<td colspan=”2″ style=”text-align:center”>Employee No</td>
<td colspan=”2″ style=”text-align:center”>Employee Name</td>
<td colspan=”2″ style=”text-align:center”>Time In</td>
<td colspan=”2″ style=”text-align:center”>Time Out</td>
</tr>
{section name=att loop=$attendance}
<tr>
<td colspan=”2″>{$attendance[att].EMP_NO}</td>
<td colspan=”2″>{$attendance[att].FULLNAME}</td>
<td colspan=”2″>{$attendance[att].LOGIN|date_format:”%d-%m-%Y %I:%M %p”}</td>
<td colspan=”2″>{$attendance[att].LOGOUT|date_format:”%d-%m-%Y %I:%M %p”}</td>
</tr>
{sectionelse}
<tr><td colspan=”1″>No DATA</td></tr>
{/section}
</table>
</fieldset>
</div>
Thank you
[CODE]<style type="text/css">
.rdc {background-color:#ff0000;}
</style> [/CODE]
<i>
</i>
$LOGIN = $DTR->fields['LOGIN'];
if($LOGIN == NULL){
echo "<td style='background-color:RED'>$DTR</td>";
}
else
{
echo "<td>$DTR</td>";
}
[code=php]$LOGIN = $DTR->fields['LOGIN'];
if($LOGIN == NULL){
echo "<td style='background-color:red;'>$DTR</td>";
}
else
{
echo "<td style='background-color:green;'>$DTR</td>";
}[/code]
[code=php]$LOGIN = $DTR->fields['LOGIN'];
if($LOGIN == NULL){
echo "<td class='rdc'>$DTR</td>";
}
else
{
echo "<td>$DTR</td>";
}[/code]
[code=php]if (!$DTR->fields['LOGIN']){
echo '<div style="background-color: red;">' . $DTR . '</div>';
} else {
echo '<div style="background-color: green;">' . $DTR . '</div>';
}[/code]
<i>
</i><div id="attendance" style="width: 580px; height: 420px; overflow: auto; padding: 5px; top:95px">
<fieldset>
<legend>Employee Attendance</legend>
<table border="1">
<tr>
<td colspan="2" style="text-align:center">Employee No</td>
<td colspan="2" style="text-align:center">Employee Name</td>
<td colspan="2" style="text-align:center">Time In</td>
<td colspan="2" style="text-align:center">Time Out</td>
</tr>
{section name=att loop=$attendance}
<tr>
<td colspan="2">{$attendance[att].EMP_NO}</td>
<td colspan="2">{$attendance[att].FULLNAME}</td> <br/>
<!--<td colspan="2">{$attendance[att].TimeIn}</td> -->
<td colspan="2">{$attendance[att].LOGIN|date_format:"&#37;d-%m-%Y %I:%M %p"}</td>
<td colspan="2">{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}</td>
<!--<td colspan="2">{$attendance[att].TimeOut|date_format:"%d-%m-%Y %I:%M %p"}</td>-->
<!-- <td colspan="2">{$attendance[att].TimeOut}</td> -->
</tr>
{sectionelse}
<tr><td colspan="1">No DATA</td></tr>
{/section}
</table>
</fieldset>
</div>
<i>
</i> if (!$DTR->fields['LOGIN']){
echo '<div style="background-color: red;">' . $DTR . '</div>';
} else {
echo '<div style="background-color: green;">' . $DTR . '</div>';
}
[code=php]if (!$DTR->fields['LOGIN']){
$DTR->fields['LOGIN'] = '<div style="background-color: red;">No Login Date</div>';
}[/code]
<i>
</i>if (!$DTR->fields['LOGIN']){
echo '<div style="background-color: red;">' . $DTR . '</div>';
} else {
echo '<div style="background-color: green;">' . $DTR . '</div>';
}
<i>
</i> if ($DTR->fields['LOGIN'] == 'NULL'){
echo '<div style="background-color: red;">' . $DTR . '</div>';
} else {
echo '<div style="background-color: green;">' . $DTR . '</div>';
}
[code=php]if ($DTR->fields['LOGIN'] == NULL){
echo '<div style="background-color: red;">' . $DTR . '</div>';
} else {
echo '<div style="background-color: green;">' . $DTR . '</div>';
}[/code]
[CODE]<div id="attendance" style="width: 580px; height: 420px; overflow: auto; padding: 5px; top:95px">
<fieldset>
<legend>Employee Attendance</legend>
<table border="1">
<tr>
<td colspan="2" style="text-align:center">Employee No</td>
<td colspan="2" style="text-align:center">Employee Name</td>
<td colspan="2" style="text-align:center">Time In</td>
<td colspan="2" style="text-align:center">Time Out</td>
</tr>
{section name=att loop=$attendance}
<tr>
<td colspan="2">{$attendance[att].EMP_NO}</td>
<td colspan="2">{$attendance[att].FULLNAME}</td>
<!--<td colspan="2">{$attendance[att].TimeIn}</td> -->
<td colspan="2"[COLOR="Red"] class="{$attendance[att].LOGIN_CLASS}"[/COLOR]>{$attendance[att].LOGIN|date_format:"%d-%m-%Y %I:%M %p"}</td>
<td colspan="2">{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}</td>
<!--<td colspan="2">{$attendance[att].TimeOut|date_format:"%d-%m-%Y %I:%M %p"}</td>-->
<!-- <td colspan="2">{$attendance[att].TimeOut}</td> -->
</tr>
{sectionelse}
<tr><td colspan="1">No DATA</td></tr>
{/section}
</table>
</fieldset>
</div>[/CODE]
[CODE]$sql = "SELECT [COLOR="red"]IF(ISNULL(a.LOGIN), 'rdc', '') AS LOGIN_CLASS, [/COLOR]a.EMP_NO, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2'
AND em.STATUS IN ('Reg Operatives', 'Reg Staff ') OR LOGIN IS NULL";[/CODE]
[CODE]<style type="text/css">
.rdc {background-color: #f00;}
</style>[/CODE]
<i>
</i><?php
include 'config.php';
$currentEmpID = $_SESSION['empID'];
if(!isset($_POST['Regsubmit_'])){
<i> </i>$DATE1 = $_GET['Regfirstinput'];
<i> </i>$DATE2 = $_GET['Regsecondinput'];
$sql = "SELECT IF(ISNULL(a.LOGIN), 'rdc', '') AS LOGIN_CLASS, a.EMP_NO, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2'
AND em.STATUS IN ('Reg Operatives', 'Reg Staff ') OR LOGIN IS NULL";
<i> </i>$DTR = $conn3->GetAll($sql);
<i> </i>$smarty->assign('attendance', $DTR);
}
$smarty->display('header_att.tpl');
$smarty->display('RegAttendance.tpl');
$smarty->display('footer.tpl');
?>
<i>
</i><style type="text/css">
.rdc {background-color:#ff0000;}
</style>
<div class="NavAtt">
<p>
<input type="button" name="UPLOAD" value="UPLOAD ATTENDANCE" onclick="uploadregularattendance()">
<input type="button" name="REGULAR" value="DISPLAY ATTENDANCE" onclick="regularattendance()">
<input type="button" name="approve" value="APPROVE" onclick="ApproveAttendance()"> <br/>
</p>
</div>
<div id="calendar">
<fieldset>
<legend>Calendar</legend>
<input type="text" name="Regfirstinput" id="Regfirstinput" size="10" > <small><a href="Javascript:showCal('RegCalendar1')">Select Date</a></small>
<p><input type="text" name="Regsecondinput" id="Regsecondinput" size="10" > <small><a href="Javascript:showCal('RegCalendar2')">Select Date</a></small>
<p><input type="button" name="Regsubmit_" value="Submit" onclick="regulardisplayattendance()"/></p>
</fieldset>
</div>
<div id="attendance" style="width: auto; height: 420px; overflow: auto; padding: 5px; top:95px;">
<fieldset>
<legend>Employee Attendance</legend>
<table border="1" style="font-family:"Times New Roman",Times,serif; font-size:10px">
<tr>
<td colspan="2" style="text-align:center">Employee No</td>
<td colspan="2" style="text-align:center">Employee Name</td>
<td colspan="2" style="text-align:center">Time In</td>
<td colspan="2" style="text-align:center">Time Out</td>
</tr>
{section name=att loop=$attendance}
<tr>
<td colspan="2">{$attendance[att].EMP_NO}</td>
<td colspan="2">{$attendance[att].FULLNAME}</td> <br/>
<td colspan="2" class="{$attendance[att].LOGIN_CLASS}">{$attendance[att].LOGIN|date_format:"%d-%m-%Y %I:%M %p"}</td>
<td colspan="2">{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}</td>
</tr>
{sectionelse}
<tr><td colspan="1">No DATA</td></tr>
{/section}
</table>
</fieldset>
</div>
<i>
</i><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -->
<!--<html xmlns="http://www.w3.org/1999/xhtml"> -->
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<!--<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />-->
<title>DSPI Payroll System</title>
<link rel="stylesheet" type="text/css" href="paycss.css" />
<script type="text/javascript" src="reg_cal2.js">
</script>
<script type="text/javascript" src="reg_cal_conf2.js"></script>
<script type="text/javascript">
function attendanceemp(){
document.sampleform.action="displayDate.php";
document.sampleform.submit();
}
function attendance(){
document.sampleform.action="Attendance.php";
document.sampleform.submit();
}
function casualattendance(){
document.sampleform.action="displayDate.php";
document.sampleform.submit();
}
function regularattendance(){
document.sampleform.action="RegAttendance.php";
document.sampleform.submit();
}
function uploadregularattendance(){
document.sampleform.action="upload_reg_att.php";
document.sampleform.submit();
}
function uploadcasualattendance(){
document.sampleform.action="upload_att.php";
document.sampleform.submit();
}
function regulardisplayattendance(){
var Regfirstinput = document.getElementById('Regfirstinput').value;
var Regsecondinput = document.getElementById('Regsecondinput').value
<i> </i>document.sampleform.action="DisplayRegAttendance.php?Regfirstinput="+Regfirstinput+"&Regsecondinput="+Regsecondinput;
<i> </i>document.sampleform.submit();
}
function importregularattendance(){
document.sampleform.action="import_reg_att.php";
document.sampleform.submit();
}
function importcasualattendance(){
document.sampleform.action="import_att.php";
document.sampleform.submit();
}
function payOut(){
document.sampleform.action="payroll_category.php";
document.sampleform.submit();
}
function AttendancePayroll(){
document.sampleform.action="Attendance.php";
document.sampleform.submit();
}
function ApproveAttendance(){
var Regfirstinput = document.getElementById('Regfirstinput').value;
var Regsecondinput = document.getElementById('Regsecondinput').value
<i> </i>document.sampleform.action="ApproveAttendance.php?Regfirstinput="+Regfirstinput+"&Regsecondinput="+Regsecondinput;
<i> </i>document.sampleform.submit();
}
</script>
<body onload="document.forms[0].reset()">
<form name="sampleform" method="post" enctype="multipart/form-data">
<h2 class="sysname"> Payroll System </h2>
<!--<input type="button" name="logout" value="Log Out" onclick="payOut()">-->
<!--<input type="button" name="loan" value= "Loan Form" class="loan" onclick="">
<img src="logout70x70.png" onclick="payOut()" class="a">-->
<div class="btn_header_attendance_1">
<!--<input type="button" name="General" value="General" onclick="displaygeneral()">
<!--<input type="button" name="Attendance" value="Attendance" onclick="attendance()">
<input type="button" name="OT" value= "OT Form" onclick="OtFrm()">
<input type="button" name="loan" value= "Loan Form" onclick="loanFrm()">
<input type="button" name="otherded" value= "Deductions" onclick="Deductions()"> -->
<input type="button" name="Back" value="Back" onclick="AttendancePayroll()"> <br/>
<input type="button" name="logout" value="Main" onclick="payOut()">
</div>
<!--<div id="header_line">
<hr style="border: 1px solid #000; border-color:#666666;" />
</div> -->
<!--<div class="a" onclick="payOut()">Log Out</div>-->
<!--End of Header--><div class="NavAtt">
<p>
<input type="button" name="UPLOAD" value="UPLOAD ATTENDANCE" onclick="uploadregularattendance()">
<input type="button" name="REGULAR" value="DISPLAY ATTENDANCE" onclick="regularattendance()">
<input type="button" name="approve" value="APPROVE" onclick="ApproveAttendance()"> <br/>
</p>
</div>
<!--<div class="NavAtt">
<p>
<input type="button" name="CASUAL" value="CASUAL ATTENDANCE" onclick="casualattendance()">
<input type="button" name="OP_STAFF" value="REGULAR ATTENDANCE" onclick="regularattendance()"> <br/>
<input type="button" name="UPLOAD_REG" value="UPLOAD REGULAR ATTENDANCE" onclick="uploadregularattendance()">
</p>
</div>-->
<div id="calendar">
<fieldset>
<legend>Calendar</legend>
<input type="text" name="Regfirstinput" id="Regfirstinput" size="10" > <small><a href="Javascript:showCal('RegCalendar1')">Select Date</a></small>
<p><input type="text" name="Regsecondinput" id="Regsecondinput" size="10" > <small><a href="Javascript:showCal('RegCalendar2')">Select Date</a></small>
<p><input type="button" name="Regsubmit_" value="Submit" onclick="regulardisplayattendance()"/></p>
</fieldset>
</div>
<!--<div id="calendar_nrs">
<fieldset>
<legend>NRS</legend>
<input type="text" name="firstinput" size="10" > <small><a href="Javascript:showCal('Calendar1')">Select Date</a></small>
<p><input type="text" name="secondinput" size="10" > <small><a href="Javascript:showCal('Calendar2')">Select Date</a></small>
<p><input type="button" name="submit_" value="Submit" onclick="attendanceemp();"/></p>
</fieldset>
</div> -->
<div id="attendance" style="width: auto; height: 420px; overflow: auto; padding: 5px; top:95px;">
<fieldset>
<legend>Employee Attendance</legend>
<table border="1" style="font-family:"Times New Roman",Times,serif; font-size:10px">
<tr>
<td colspan="2" style="text-align:center">Employee No</td>
<td colspan="2" style="text-align:center">Employee Name</td>
<td colspan="2" style="text-align:center">Time In</td>
<td colspan="2" style="text-align:center">Time Out</td>
</tr>
<tr>
<td colspan="2">00300395</td>
<td colspan="2">Employee Name 3</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">16-12-2011 08:30 AM</td>
<td colspan="2">16-12-2011 05:15 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09300127</td>
<td colspan="2">Employee Name 4</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">17-12-2011 07:36 AM</td>
<td colspan="2">17-12-2011 06:00 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09300127</td>
<td colspan="2">Employee Name 4</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">18-12-2011 08:25 AM</td>
<td colspan="2">18-12-2011 05:35 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09300127</td>
<td colspan="2">Employee Name 4</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">19-12-2011 07:49 AM</td>
<td colspan="2">19-12-2011 04:00 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09300127</td>
<td colspan="2">Employee Name 4</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">20-12-2011 08:40 AM</td>
<td colspan="2">20-12-2011 04:35 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09900215</td>
<td colspan="2">Employee Name 5</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">21-12-2011 06:30 AM</td>
<td colspan="2">21-12-2011 04:40 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09900215</td>
<td colspan="2">Employee Name 5</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">22-12-2011 07:25 AM</td>
<td colspan="2">22-12-2011 04:26 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09900215</td>
<td colspan="2">Employee Name 5</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">23-12-2011 06:42 AM</td>
<td colspan="2">23-12-2011 03:45 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">09900215</td>
<td colspan="2">Employee Name 5</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2">24-12-2011 07:36 AM</td>
<td colspan="2">24-12-2011 03:00 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">00000221</td>
<td colspan="2">Employee Name 6</td> <br/>
<!--<td colspan="2"></td> -->
<td colspan="2"></td>
<td colspan="2"></td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
</table>
</fieldset>
</div>
<div id="footer" >
<hr style="border: 1px solid #000; border-color:#666666;" />
</div>
</body>
</form>
</head>
</html>
[code=html] <tr>
<td colspan="2">09900215</td>
<td colspan="2">Employee Name 5</td>
<!--<td colspan="2"></td> -->
<td colspan="2">24-12-2011 07:36 AM</td>
<td colspan="2">24-12-2011 03:00 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">00000221</td>
<td colspan="2">Employee Name 6</td>
<!--<td colspan="2"></td> -->
<td colspan="2"></td>
<td colspan="2"></td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>[/code]
[CODE]$sql = "SELECT [COLOR="Red"]IF(ISNULL(a.LOGIN), 'rdc', '') AS LOGIN_CLASS, IF(ISNULL(a.LOGOUT), 'rdc', '') AS LOGOUT_CLASS,[/COLOR] a.EMP_NO, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2'
AND em.STATUS IN ('Reg Operatives', 'Reg Staff ') OR LOGIN IS NULL";[/CODE]
[CODE] ...
{section name=att loop=$attendance}
<tr>
<td colspan="2">{$attendance[att].EMP_NO}</td>
<td colspan="2">{$attendance[att].FULLNAME}</td>
<!--<td colspan="2">{$attendance[att].TimeIn}</td> -->
<td colspan="2" [COLOR="red"]class="{$attendance[att].LOGIN_CLASS}"[/COLOR]>{$attendance[att].LOGIN|date_format:"%d-%m-%Y %I:%M %p"}</td>
<td colspan="2" [COLOR="red"]class="{$attendance[att].LOGOUT_CLASS}"[/COLOR]>{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}</td>
<!--<td colspan="2">{$attendance[att].TimeOut|date_format:"%d-%m-%Y %I:%M %p"}</td>-->
<!-- <td colspan="2">{$attendance[att].TimeOut}</td> -->
</tr>
{sectionelse}
<tr><td colspan="1">No DATA</td></tr>
{/section}
...[/CODE]
0.1.9 — BETA 5.4