<?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=700,height=500,left = 100,top = 100');");

}

// End -->



function cash(i){

document.getElementById('Paid By').style.display = 'none';

document.getElementById(i).style.display = 'block';

}

</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><table width="100%" border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td height="30" background="images/place_bg.jpg" class="link2"><strong>&nbsp;&nbsp;<a href="index.php">Home</a> &gt; <a href="accounts.php">Accounts &gt; </a><a href="all_cost.php">Invest View</a></strong></td>

      </tr>

    </table></td>

  </tr>

  <tr>

    <td>&nbsp;</td>

  </tr>
  <tr>
    <td align="center" valign="top" class="round_box"><form id="form1" name="form1" method="post" action="">
      <table width="100%" border="0" cellpadding="3" cellspacing="1"  class="round_box">
        <tr>
          <td width="23%"><strong>Search Invest </strong></td>
          <td width="77%">&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("-1 day");

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



}

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



 ?>
        <tr>
          <td>Search by date :
            <input name="p" type="hidden" id="p" value="y" /></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="p2" type="hidden" id="p2" 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 align="center" valign="top">&nbsp;</td>

  </tr>

  <tr>

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

          <tr>

            <td height="30" colspan="2" align="left" ><strong>All Invest</strong></td>
            <td height="30" align="left" >&nbsp;</td>
            <td height="30" align="left" >&nbsp;</td>
            <td height="30" colspan="2" align="left" >&nbsp;</td>
          </tr>

          <tr>
            <th align="left" > Date</th>
            <th align="left" >ID</th>
            <th align="left" >Paid To</th>
            <th align="left" >Amount</th>
            <th > Comments</th>
            <th >User</th>
        </tr>

		  <?php 

		   $m=date("m");

			$y=date("Y");

			  

		  $dt=$y.$m;

		  $date=date("Y-m-d");
	
	

		$page_name="invest_view.php?id=$_GET[id]"; 

			$limit=$_GET['limit'];

			$start=$_GET['start'];								

			if(!($start > 0)) {                  

			$start = 0;

			}

			$eu = ($start - 0); 

			$limit = '50';              

			$this1 = $eu + $limit; 

			$back = $eu - $limit; 

			$next = $eu + $limit;

		

		  if($ds!=""){



		  $ds=dtformat($ds);



		  $de=dtformat($de);
 

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

	
		$ant=mysql_query("select * from invest $d ");
		$nume=mysql_num_rows($ant);

 
		  $dresult=mysql_query("select * from invest  $d order by id desc limit $eu, $limit");
		  $drow=mysql_fetch_array($dresult);

		  $total=0;

		  do{

		  ?>

          <tr>

          <td width="159" align="left"  class="link"><?php 

			 echo dtformat($drow[cdate]);

			?></td>
          <td width="155" align="left"  class="link"><?php echo $drow[id]; ?></td>

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



            <td width="255" align="left"  class="link"><?php 

			 /*$bresult=mysql_query("select SUM(amount) as amount from cost WHERE cost_type='$drow[cost_type]' and dt='$dt'");

		 	 $brow=mysql_fetch_array($bresult);*/

			 echo $drow[amount];

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

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

			 echo $drow[comments];

			?></td>
            <td width="135" 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>
        </tr>

         

          <?php 

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

		  ?> <tr>

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

            </tr>

    </table></td>

  </tr>

  <tr>
    <td><table border="0" align = "center" cellpadding="0" cellspacing="2">
      <tr>
        <?php // if our variable $back is equal to 0 or more then only we will display the link to move back //

			

			

		

		

			if($back >=0) { 

			echo  "<td  align='left' class='paiging' width='60px'><a href='$page_name&start=$back&limit=$limit'><< PREV</a></td>"; 

			} 

			//// Let us display the page links at  center. We will not display the current page as a link //

			?>
        <?php 

				$i=0;

				$l=1;

				for($i=0;$i < $nume;

				$i=$i+$limit){

				if($i <> $eu){

			?>
        <td width="25px" align="center" class="paiging"><?php 

				echo " <a href='$page_name&start=$i&limit=$limit'>$l</a>";

			?></td>
        <?php 

			}else{echo "<td align='center' width='25px'><span class='paiging_red'>$l</span></td>";}

			/// Current page is not displayed as link and given font color red

			$l=$l+1;

			}

			

		?>
        <?php ///////////// If we are not in the last page then Next link will be displayed. Here we check that /////

if($this1 < $nume) { 

echo "<td  align='right' class='paiging' width='60px'><a href='$page_name&start=$next&limit=$limit'>NEXT >></a></td>";} 

?>
      </tr>
    </table></td>
  </tr>
  <tr>

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

  </tr>

</table>

</body>

</html>

<?php }?>