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

<?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("-60 day");

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



}

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="20%" align="left" >Service / 
              Income Type </th>

            <th width="12%" align="center" >Opening</th>

            <th width="16%" align="center" >This Range </th>
            <th width="16%" align="center" >Total Amount</th>
            </tr>



          <?php 



 

			if($_POST[cost_type]!=""){$c="and cost_type='$_POST[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="";}

 
 
		  $dresult=mysql_query("select sum(amount)as amount,cost_type from income WHERE amount!='0'  $c $status2 $d group by cost_type order by cost_type asc");

          $drow=mysql_fetch_array($dresult);



		  $total=0;



		  do{
			  
$opening=0;
if($ds!=""){	  
$d="and cdate<'$ds' ";
$rresult=mysql_query("select sum(amount)as amount from income WHERE cost_type='$drow[cost_type]' $d");
$rrow=mysql_fetch_array($rresult);
	
$opening=$rrow[amount];

}else{$opening=0;}
			  
		  ?>



          <tr>
            <td align="left"  class="link"><a href="income_view.php?cost_type=<?php echo $drow[cost_type]; ?>&amp;ds=<?php echo dtformat($ds); ?>&amp;de=<?php echo dtformat($de); ?>" target="_blank">
              <?php 

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

			

			echo $arow[cost]; ?>
            </a></td>
            <td align="center"  class="link"><a href="income_view.php?cost_type=<?php echo $drow[cost_type]; ?>&ds=<?php echo dtformat($ds); ?>&de=<?php echo dtformat($de); ?>" target="new"><?php echo $opening;  $totalop=$totalop+$opening;?></a></td>
            <td align="center"  class="link"><a href="income_view.php?cost_type=<?php echo $drow[cost_type]; ?>&amp;ds=<?php echo dtformat($ds); ?>&amp;de=<?php echo dtformat($de); ?>" target="new">
              <?php 


			 echo $drow[amount];

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

			?></a></td>
            <td align="center"  class="link"><a href="income_view.php?cost_type=<?php echo $drow[cost_type]; ?>&amp;ds=<?php echo dtformat($ds); ?>&amp;de=<?php echo dtformat($de); ?>" target="new">
              <?php   $sgt=$drow[amount]+$opening; $gt=$gt+$drow[amount]+$opening; echo number_format($sgt); ?></a></td>
            </tr>



          <?php 



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



		 



		  ?>



          <tr>

            <td align="right"  class="link"><strong>Total :</strong></td>
            <td align="center"  class="link"><?php echo $totalop; ?></td>
            <td align="center"  class="link"><strong><?php echo $total; ?></strong></td>
            <td align="center"  class="link"><?php echo $gt; ?></td>
            </tr>



        </table></td>



      </tr>



    </table></td>



  </tr>



  <tr>



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



  </tr>



</table>



</body>



</html>



<?php }?>