<?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>Profit and loss</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("d-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 height="30">&nbsp;</td>



      </tr>



      <tr>



        <td class="round_box"><table width="100%" border="0" cellspacing="3" cellpadding="2">
          <tbody>
            <tr>
              <td width="50%" height="30" bgcolor="#518289" class="white_color"><strong>Income</strong></td>
              <td width="50%" bgcolor="#518289" class="white_color"><strong>Expense</strong></td>
            </tr>
            <tr>
              <td valign="top"><table width="100%" border="0" cellpadding="3" cellspacing="1" class="list_table">
                <tr>
                  <th align="center" >Sr</th>
                  <th align="center" >Source</th>
                  <th align="center" >Amount</th>
                  </tr>
                <?php 



		    



		 

		  if($ds!=""){

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

		  
 


		  $dresult=mysql_query("select sum(total_payeble)as total_payeble from bill WHERE total_payeble!='0'  $d");
          $drow=mysql_fetch_array($dresult);
		  $total=0;



		  ?>
                <tr>
                  <td width="8%" align="center" class="link">1</td>
                  <td width="50%" align="center" class="link">Room Rent</td>
                  <td width="25%" align="center" class="link"><?php 



			 echo number_format($drow[total_payeble]);

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

			?></td>
                  </tr>
<?php 
	
		 
	  if($ds!=""){

	 
		$d="and income.cdate>='$ds' and income.cdate<='$de' ";}else{$d="";}
 
		  $dresult=mysql_query("SELECT 
    income_type.cost, 
    SUM(income.amount) AS amount,
	income.cost_type
FROM income 
JOIN income_type 
    ON income.cost_type = income_type.id
WHERE income.amount != 0  and  income.invest = '0'
    $d
GROUP BY income_type.cost
ORDER BY income_type.cost ASC");
          $drow=mysql_fetch_array($dresult);
$sr=1;
	do{
		$sr=$sr+1;		  ?>
				  
                <tr>
                  <td align="center"  class="link"><?php echo $sr; ?></td>
                  <td align="center"  class="link"><?php echo $drow[cost];?></td>
                  <td align="center"  class="link"><?php echo number_format($drow[amount]);?></td>
                </tr>
<?php 
$total=$total+$drow[amount];
		
}while($drow=mysql_fetch_array($dresult));
	


				  ?>
                <tr>
                  <td colspan="2" align="right"  class="link"><strong>Total :</strong></td>
                  <td align="center"  class="link"><strong><?php echo number_format($total); ?></strong></td>
                  </tr>
              </table></td>
              <td valign="top"><table width="100%" border="0" cellpadding="3" cellspacing="1" class="list_table">
                <tr>
                  <th width="8%" align="center" >Sr</th>
                  <th width="50%" align="center" >Source</th>
                  <th width="25%" align="center" >Amount</th>
                </tr>
                <?php 



		    



		 
	  if($ds!=""){

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



		  $ctotal=0;


 
 

	
		  $dresult=mysql_query("SELECT 
    cost_type.cost, 
    SUM(cost.amount) AS amount,
	cost.cost_type
FROM cost 
JOIN cost_type 
    ON cost.cost_type = cost_type.id
WHERE cost.amount != 0  and  cost.invest = '0'
    $d
GROUP BY cost.cost_type
ORDER BY cost.cost_type ASC");
          $drow=mysql_fetch_array($dresult);
$sr=0;
	do{
		$sr=$sr+1;		  ?>
                <tr>
                  <td align="center"  class="link"><?php echo $sr; ?></td>
                  <td align="center"  class="link"><?php echo $drow[cost];?></td>
                  <td align="center"  class="link"><?php echo number_format($drow[amount]);?></td>
                </tr>
                <?php 
$ctotal=$ctotal+$drow[amount];
		
}while($drow=mysql_fetch_array($dresult));
	
		
$d="and hr_salary.cdate>='$ds' and hr_salary.cdate<='$de' ";
	
$dresult=mysql_query("select 
hr_employee.customer_name, hr_salary.salary, hr_salary.cdate 
from hr_salary 
JOIN hr_employee 
    ON hr_employee.id = hr_salary.employee

WHERE hr_salary.salary!='0'  $d 
 
	
");
	
	 
	 
          $drow=mysql_fetch_array($dresult);
	if($drow!=""){
	do{
			 $sr=$sr+1;	  ?>			  
                <tr>
                  <td width="4%" align="center" class="link"><?php echo $sr; ?></td>
                
                  <td width="50%" align="center" class="link">Salary  - <?php echo $drow[customer_name];?></td>
                  <td width="25%" align="center" class="link"><?php 


echo number_format($drow[salary]);
$ctotal=$ctotal+$drow[salary];
 

			?></td>
                  </tr>
<?php 
	
	 }while($drow=mysql_fetch_array($dresult));
	}
				  ?>
                <tr>
                  <td colspan="2" align="right"  class="link"><strong>Total Expense :</strong></td>
                  <td align="center"  class="link"><strong><?php echo number_format($ctotal); ?></strong></td>
                </tr>
                <tr>
                  <td colspan="2" align="right"  class="link">Total Income :</td>
                  <td align="center"  class="link"><?php echo number_format($total); ?></td>
                </tr>
                <tr>
                  <td colspan="2" align="right" bgcolor="#BBD9DC"  class="link"><strong>Profit / Loss :</strong></td>
                  <td align="center" bgcolor="#BBD9DC"  class="link"><strong><?php 
					  
	$profit_loss=$total-$ctotal;  echo number_format($profit_loss);
					  ?></strong></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </tbody>
        </table></td>



      </tr>



    </table></td>



  </tr>



  <tr>



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



  </tr>



</table>



</body>



</html>



<?php }?>