<?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=iso-8859-1" />



<title>Arnim Holidays Accounting Software</title>



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



<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>

<style type="text/css">

<!--

.style2 {color: #DC147B;

	font-weight: bold;

}

.style3 {color: #000000}

-->

</style>
<?php include("calendar.php"); ?>
</head>







<body>



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



  <tr>



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



  </tr>



  <tr>



    <td>&nbsp;</td>



  </tr>



  <tr>



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



      <tr>



        <td valign="top"><br />



          <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 Income  </strong></td>



                <td width="84%">&nbsp;</td>



              </tr>



              <tr>



                <td>Search on Income type: </td>



                <td><select name="cost_type" id="cost_type">



				 <option value="">Select Income Type</option>



                  <?php 



		  $result=mysql_query("select * from income_type order by id asc");



		  $row=mysql_fetch_array($result);



		  do{



		  ?>



                  <option value="<?php echo $row[id]; ?>"><?php echo $row[cost]; ?></option>



                  <?php 



		  }while($row=mysql_fetch_array($result));



		  ?>



                </select></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 == ""){



//$dddez = strtotime("-1 day");

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



}

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



 ?>

              <tr>



                <td>Search by date :                  </td>



                <td><table width="500" border="0" cellspacing="1" cellpadding="2">
                  <tbody>
                      <tr>
                        <td>From</td>
                        <td><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><input name="p" type="hidden" id="p" value="y" /></td>
                        <td>To</td>
                        <td><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>
                      </tr>
                    </tbody>
                </table>
                  </td>



              </tr>

              <tr>
                
                
                
                <td>&nbsp;</td>
                
                
                
                <td><input type="submit" name="Submit" value="Search" /></td>
                
                
                
              </tr>



            </table>



            </form>



          </td>



      </tr>



      <tr>



        <td height="30">&nbsp;</td>



      </tr>



      <tr>



        <td class="round_box"><table width="100%" border="0" cellpadding="3" cellspacing="1" class="list_table">

          <tr>

            <th width="11%" align="left" >Date</th>

            <th width="5%" align="left" >ID</th>

            <th width="20%" align="left" >Service / <br />
              Income Type </th>

            <th width="12%" >Recieve from</th>

            <th width="16%" >Amount</th>

            <th width="12%" >Comments</th>
            <th width="12%" >Pay Methode</th>
            <th >User</th>
            <th width="12%" >&nbsp;</th>
            </tr>



          <?php  

			if($_POST[cost_type]!=""){$c="and cost_type='$_POST[cost_type]'";}else{$c="";}
		    if($_GET[cost_type]!=""){$c="and cost_type='$_GET[cost_type]'";}else{$c="";}



		  if($ds!=""){



$ds=dtformat($ds);
 $de=dtformat($de);



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

		  

		  if($_POST[status2]!=""){$status2="and status1='$_POST[status2]'";}else{$status2="";}

		   if($_GET[status2]!=""){$status2="and status1='$_GET[status2]'";}else{$status2="";}





		  



		  



		 



		  $dresult=mysql_query("select * from income WHERE amount!='0' $c $status2 $d order by cdate desc");

          $drow=mysql_fetch_array($dresult);



		  $total=0;



		  do{



		  ?>



          <tr>
            <td align="left"  class="link"><?php 

			 echo dtformat($drow[cdate]);

			?></td>
            <td align="left"  class="link"><a href="javascript:void(0);" onclick="popUp('show_income.php?id=<?php echo $drow[id]; ?>')"><?php echo $drow[id]; ?></a></td>
            <td align="left"  class="link"><?php 

		  $aresult=mysql_query("select * from income_type WHERE id='$drow[cost_type]' limit 1");
		  $arow=mysql_fetch_array($aresult);

			

			echo $arow[cost]; ?></td>
            <td align="left"  class="link"><?php echo $drow[pt]; ?></td>
            <td align="left"  class="link"><?php 


			 echo $drow[amount];

			 $total=$total+$drow[amount];

			?></td>
            <td  class="link"><?php 

			 echo $drow[comments];

			?></td>
            <td  class="link"><?php 

			 echo $drow[pay_methode];

			?></td>
            <td width="6%" align="center" class="link"><?php  
			  
$eresult=mysql_query("SELECT  userid FROM user WHERE id = '$drow[suser]'  limit 1");
$erow=mysql_fetch_array($eresult);
				
			  echo $erow[userid];
				?>
                <span class="info-icon" onclick="openPopup('show_ip_info.php?ip=<?php echo $drow[user_ip]; ?>&amp;time=<?php $date = "$drow[datetime1]";
echo date("d-m-Y H:i:s", strtotime($date));?>')">i</span></td>
            <td align="center"  class="link"><?php 
if($drow[status] == '0'){ 

if($drow[cdate] == $date1ah){

//-----------------
if($_SESSION[invcox] == "$drow[suser]"){ ?>
              <a href="edit_incom.php?id=<?php echo $drow[id];?>">Edit</a>
              <?php }else{
$result=mysql_query("select * from user WHERE userid='$_SESSION[invcox]' and status='1'");
$row=mysql_fetch_array($result);

if($row[income_type] == '1'){
			?>
              <a href="edit_incom.php?id=<?php echo $drow[id];?>">Edit</a>
              <?php 	

}
}

//-----------------------

}else{

$result=mysql_query("select * from user WHERE userid='$_SESSION[invcox]' and status='1'");
$row=mysql_fetch_array($result);

if($row[income_type] == '1'){
			?>
              <a href="edit_incom.php?id=<?php echo $drow[id];?>">Edit</a>
              <?php } }


}else{

	$result=mysql_query("select * from user WHERE userid='$_SESSION[invcox]' and status='1'");
$row=mysql_fetch_array($result);

if($row[income_type] == '1'){
			?>
              <a href="edit_incom.php?id=<?php echo $drow[id];?>">Edit</a>
              <?php } }?></td>
          </tr>



          <?php 



		  }while($drow=mysql_fetch_array($dresult));



		 



		  ?>



          <tr>

            <td colspan="4" align="right"  class="link"><strong>Total :</strong></td>
            <td  class="link"><strong><?php echo $total; ?></strong></td>



            <td  class="link">&nbsp;</td>
            <td  class="link">&nbsp;</td>
            <td  class="link">&nbsp;</td>
            <td  class="link">&nbsp;</td>
            </tr>



        </table></td>



      </tr>



    </table></td>



  </tr>



  <tr>



    <td><?php include("bot.php")?></td>



  </tr>



</table>



</body>



</html>



<?php }?>