<?php   session_start();



if ( $_SESSION[ invcox ] == "" ) { header( "location:login.php?action=need" );} else { include( "config.php" );

   	?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      

      <title>employee Entry</title>

      <link href="style.css" rel="stylesheet" type="text/css"/>

      <?php include("calendar.php");

?>   
		<style type="text/css">
			<!-- .style2 {
				color: #DC147B;
				font-weight: bold;
			}
			
			.style3 {
				color: #000000
			}
			
			    .print-btn {
        background-color: #007bff;
        color: white;
        padding: 10px 18px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-size: 16px;
        transition: 0.3s;
    }

    .print-btn:hover {
        background-color: #0056b3;
    }
			-->

		</style>
		<SCRIPT LANGUAGE="JavaScript">







<!-- Begin



function popUp(URL) {

day = new Date();
id = day.getTime();



eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=yes,width=950,height=650,left = 100,top = 100');");



}



// End -->



</script>
   </head>

   <body>

      <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="box-wrap">

         <tr>

            <td>   <?php include("top.php");

?></td>

         </tr>

         <tr>

            <td>

               <table width="100%" border="0" cellspacing="1" cellpadding="0">

                  <tr>

                     <td align="left" class="link2">&nbsp;

</td>

                  </tr>

                  

                  <tr>

                     <td align="center">&nbsp;

</td>

                  </tr>

                  <tr>

                     <td><form id="form1" name="form1" method="post" action="">
                       <table width="100%" border="0" cellpadding="3" cellspacing="1"  class="round_box">
                         <tr>
                           <td width="16%"><strong>Search Salary </strong></td>
                           <td width="84%">&nbsp;</td>
                         </tr>
                         <?php 



if($_POST[ds]!=""){$ds=$_POST[ds];}



if($_POST[de]!=""){$de=$_POST[de];}







if($_GET[ds]!=""){$ds=$_GET[ds];}



if($_GET[de]!=""){$de=$_GET[de];}







if($ds == ""){







 


$ds=date('01-m-Y');



}



if($de == ""){$de=date("t-m-Y");}







 ?>
                         <tr>
                           <td>Search by date : </td>
                           <td><table width="703" border="0" cellspacing="1" cellpadding="2">
                             <tbody>
                               <tr>
                                 <td width="69">From
                                   <input name="p" type="hidden" id="p" value="y" /></td>
                                 <td width="233"><table width="180" border="0" cellspacing="0" cellpadding="0">
                                   <tr>
                                     <td width="70%"><input name="ds" type="text" id="ds" size="15"  value="<?php echo $ds;?>" required="required"/></td>
                                     <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('ds', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
                                   </tr>
                                 </table></td>
                                 <td width="22"><input name="p2" type="hidden" id="p2" value="y" /></td>
                                 <td width="23">To</td>
                                 <td width="233"><table width="180" border="0" cellspacing="0" cellpadding="0">
                                   <tr>
                                     <td width="70%"><input name="de" type="text" id="de" size="15"  value="<?php echo $de;?>" required="required"/></td>
                                     <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('de', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
                                   </tr>
                                 </table></td>
                                 <td width="92"><input type="submit" name="Submit" value="Search" /></td>
                               </tr>
                             </tbody>
                           </table></td>
                         </tr>
                         <tr>
                           <td>&nbsp;</td>
                           <td>&nbsp;</td>
                         </tr>
                       </table>
                     </form></td>

                  </tr>

                  <tr>

                     <td><button class="print-btn" onclick="popUp('hr_salary_register_print.php?ds=<?php echo $ds; ?>&de=<?php echo $de; ?>');">🖨 Print</button>

</td>

                  </tr>

                  <tr>

                     <td align="center" class="round_box">

                        <table width="100%" border="0" align="center" cellpadding="3" cellspacing="0" class="list_table">

                           <tr>

                              <th height="30">SL</th>
                              <th>ID</th>

							   <th height="30">Employee  Name </th>

                              <th width="205" height="30" align="center"> Salary (Monthly)</th>
                              <th align="center">Previous Due/Advance </th>

                              <th height="30" align="left">Total Salary (This Month)</th>

                              <th height="30" align="left">Salary Paid (This Month)</th>

                              <th height="30" align="left">Salary Due  (Total)</th>

                              <th height="30" align="center">Salary Advance  (Total)</th>
                              <th align="center">Leave</th>

                           </tr>

   <?php 
$ds=dtformat($ds);
$de=dtformat($de);
 

 
$today=date("Y-m-d");
 
 $result=mysql_query("select * from hr_employee where date1<='$today' and date2='0000-00-00' or date1<='$today' and date2>='$today'  order by id asc");
//$result=mysql_query("select * from hr_employee order by id desc");

$row=mysql_fetch_array($result);

$sr=0;

																					  
																					  
		  if($ds!=""){

 
		  $d="and cdate>='$ds' and cdate<='$de' ";}else{$d="";}
																					  
do{

							

							$sr++;?>   

                           <tr>

							   <td width="21" align="center" valign="top" class="link"><?php echo $sr; ?></td>
						     <td width="21" align="center" valign="top" class="link"><a href="hr_employee_profile.php?refr_id=<?php    echo $row[id];?>">
                             <?php    echo $row[id];?>
						     </a></td>

                              <td width="309" align="center" valign="top" class="link"><?php    echo $row[customer_name];

            ?>   </td>

                              <td align="center" valign="top" class="link "><?php echo $row[contact_person];
$salary_total=$salary_total+$row[contact_person];
   ?></td>
                              <td width="179" align="center" valign="top">
							   
<?php 
 
$bresult=mysql_query("select sum(salary)as salary from hr_salary where employee='$row[id]' and   cdate<'$ds'  ");
$brow=mysql_fetch_array($bresult);
$cresult=mysql_query("select sum(salary)as salary from hr_salary_paid where employee='$row[id]' and   cdate<'$ds' ");
$crow=mysql_fetch_array($cresult);			 

$opening=$brow[salary]-$crow[salary]; 

echo $opening; 
	$opening_total=$opening_total+$opening;	  
								  ?></td>
                              <td width="230" align="left" valign="top" class="link "><?php 
 

	
$bresult=mysql_query("select sum(salary)as salary from hr_salary where employee='$row[id]' $d ");
$brow=mysql_fetch_array($bresult);
$cresult=mysql_query("select sum(salary)as salary from hr_salary_paid where employee='$row[id]' $d");
$crow=mysql_fetch_array($cresult);	
	
echo $brow[salary]; 

$this_salary=$this_salary+$brow[salary]; 
?></td>

                              <td width="268" align="left" valign="top" class="link "><?php 
	
 echo $crow[salary]; 
	$this_salaryp=$this_salaryp+$crow[salary]; 
 ?></td>

                              <td width="212" align="left" valign="top" class="link "><?php
$balance=($opening+$brow[salary])-$crow[salary];  	if($balance>"0"){echo $balance;  $total_due=$total_due+$balance;  }
?></td>

                              <td width="285" align="center" valign="top" class="link "><?php  
		if($balance<"0"){echo $balance; $total_adv=$total_adv+$balance;  }


 ?></td>
                              <td width="285" align="center" valign="top" class="link "><?php 
							  
$qresult=mysql_query("select sum(leave_days)as leave_days from hr_leave where employee='$row[id]' $d");
$qrow=mysql_fetch_array($qresult);	
echo $qrow[leave_days];
							  ?></td>

                           </tr>
                           

                           <?php }while($row=mysql_fetch_array($result));

?><tr>
                             <td align="center" valign="top" class="link">&nbsp;</td>
                             <td align="center" valign="top" class="link">&nbsp;</td>
                             <td align="center" valign="top" class="link">Total</td>
                             <td align="center" valign="top" class="link "><?php echo number_format($salary_total);?></td>
                             <td align="center" valign="top" class="link "><?php echo number_format($opening_total);?></td>
                             <td align="left" valign="top" class="link "><?php echo number_format($this_salary);?></td>
                             <td align="left" valign="top" class="link "><?php echo number_format($this_salaryp);?></td>
                             <td align="left" valign="top" class="link "><?php echo number_format($total_due);?></td>
                             <td align="center" valign="top" class="link "><?php echo number_format($total_adv);?></td>
                             <td align="center" valign="top" class="link ">&nbsp; </td>
                           </tr>
 
                        </table>

                    <td width="25" align="center" class="paiging">&nbsp;

</td>

                  </tr>

               </table>

            </td>

         </tr>

         <tr>

            <td height="28" align="center">&nbsp;</td>

         </tr>

         <tr>

            <td height="28"><?php include("bot.php");

?></td>

         </tr>

      </table>

   </body>

</html>

<?php }?>