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


function load_data(i){
	
document.getElementById('pt').value= i;
	}

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



function cash(i){


}

</script>
<?php include("calendar.php");?>
<style type="text/css">
<!--
.style2 {color: #DC147B;
	font-weight: bold;
}
.style3 {color: #000000}
-->
</style>
</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>  Add Receivable</strong></td>

      </tr>

    </table></td>

  </tr>

  <tr>

    <td>&nbsp;</td>

  </tr>

  <tr>

    <td align="center" valign="top" class="round_box"><form action="pr_insert2.php" method="post" enctype="multipart/form-data" name="form1" id="form1">

      <span class="red"><strong><?php if($_GET[info] == 'y'){echo 'Added Successfully';}?></strong></span>

      <table width="100%" border="0" cellpadding="3" cellspacing="2" bordercolor="#999999">

        <tr>

          <td colspan="2" ><strong> Receivable  </strong></td>
          </tr>

        <tr>
          <td >Date</td>
          <td ><table width="180" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="70%"><input name="cdate" type="text" id="cdate" size="15"  value="<?php echo date("d-m-Y");?>" required="required"/></td>
                <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('cdate', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
              </tr>
          </table></td>
          </tr>
        <tr>
          <td width="171" >            Receivable Type </td>
          <td  class="input200"><select name="cost_type" required="required" id="cost_type">
            <?php 

		  $result=mysql_query("select * from pr_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>
        <tr>
          <td height="30" > Receivable  from * </td>
          <td height="30"  class="input200"><input name="pt" type="text" required="required" id="pt" size="80" /></td>
        </tr>
        <tr>
          <td height="30" >Amount</td>
          <td width="1453"  class="input200"><input name="amount2" type="number" required="required" id="amount2" size="10" /></td>
          </tr>

        <tr>
          
          <td height="30" >Comments </td>
          <td height="30"  class="input200"><input name="comments" type="text" id="comments" /></td>
        </tr>
        <tr>
          <td height="30" align="center" > Received Date</td>
          <td height="30" align="left" ><table width="180" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="70%"><input name="cdate2" type="text" id="cdate2" size="15"  value="<?php //echo date("d-m-Y");?>"/></td>
              <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('cdate2', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td height="30" align="center" > Received Comments</td>
          <td height="30" align="left" ><textarea name="npcom" id="npcom" cols="45" rows="5"></textarea></td>
        </tr>
        <tr>
          <td height="30" align="center" >&nbsp;</td>
          <td height="30" align="left" ><input type="submit" name="submit" id="submit" value="Submit"  style=" padding:
          10px"/></td>
        </tr>
      </table>

    </form></td>

  </tr>

  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>

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

          <tr>

            <td colspan="9" align="left"  ><strong>Last Transection</strong></td>
          </tr>

          <tr>
            <th align="left" >Date<br /></th>
            <th align="left" >ID</th>
            <th width="10%" align="left" >Payable  Type </th>
            <th width="10%" align="left" > Receivable  from</th>
            <th width="10%" align="left" >Amount</th>
            <th width="10%" > Comments</th>
            <th width="10%" > Received Date</th>
            <th width="10%" > Received Comments</th>
            <th align="center" >Edit</th>
        </tr>

		  <?php 

		   $m=date("m");

			$y=date("Y");

			  

		  $dt=$y.$m;

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



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

			$limit=$_GET['limit'];

			$start=$_GET['start'];								

			if(!($start > 0)) {                  

			$start = 0;

			}

			$eu = ($start - 0); 

			$limit = '100';               

			$this1 = $eu + $limit; 

			$back = $eu - $limit; 

			$next = $eu + $limit;

		

		$ant=mysql_query("select * from pr where amount2>'0'");
		$nume=mysql_num_rows($ant);

	

		  $dresult=mysql_query("select * from pr where amount2>'0' order by id desc limit $eu, $limit");
		  $drow=mysql_fetch_array($dresult);

		  $total=0;
		  do{

		  ?>

          <tr>

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

			 echo dtformat($drow[cdate]);

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

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

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

			

			echo $arow[cost]; ?></td>

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

			<?php 


			 echo $drow[amount2];

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

			?>			</td>

            <td width="137"  class="link"><?php 

			 echo $drow[comments];

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

			 echo dtformat($drow[cdate2]);

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

			 echo $drow[npcom];

			?></td>
            <td width="74" align="center"  class="link">
              <?php 
if($drow[status] == '0'){ 

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

//-----------------
if($_SESSION[invcox] == "$drow[suser]"){ ?>
              <a href="edit_pr.php?id=<?php echo $drow[id];?>&t=2">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_pr.php?id=<?php echo $drow[id];?>&t=2">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_pr.php?id=<?php echo $drow[id];?>&t=2">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_pr.php?id=<?php echo $drow[id];?>&t=2">Edit</a>
            <?php } }?>		</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="right"  class="link">&nbsp;</td>
            <td align="left"  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>

  <tr>

    <td align="center"><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>

</table>

</body>

</html>

<?php }?>