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



<body>

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1">

  <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 <a href="all_cost.php">Cost </a></strong></td>

      </tr>

    </table></td>

  </tr>

  <tr>

    <td><?php include("cost_top.php");?></td>

  </tr>

  <tr>

    <td align="center" valign="top"><form action="cost_gen_insert.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="2" cellspacing="1" bgcolor="#CCCCCC">

        <tr>

          <td width="92" bgcolor="#999999"><strong>Cost</strong></td>

          <td width="139" bgcolor="#999999">&nbsp;</td>

          <td colspan="2" bgcolor="#999999">&nbsp;</td>

          <td width="139" bgcolor="#999999">&nbsp;</td>

          <td width="134" bgcolor="#999999">&nbsp;</td>

          <td width="364" bgcolor="#999999">&nbsp;</td>

          <td width="241" bgcolor="#999999">&nbsp;</td>

          <td width="335" bgcolor="#999999">&nbsp;</td>
        </tr>

        <tr>
          <td width="92">Date</td>
          <td width="139">Paid To </td>
          <td width="89">Amount</td>
          <td width="215">On against of</td>
          <td width="139">Cost Type </td>
          <td width="134">Voucher No/ <br />
M.Rec / Ref.</td>
          <td> Comments</td>
          <td width="241">Pay Method</td>
          <td width="335" bgcolor="#CCCCCC">&nbsp;</td>
        </tr>

        <tr>
          <td height="30" bgcolor="#FFFFFF"><input name="cdate" type="text" id="cdate" value="<?php echo date("d-m-Y");?>" size="12" /></td>
          <td width="139" height="0" bgcolor="#FFFFFF"><input name="pt" type="text" id="pt" size="15" /></td>
          <td bgcolor="#FFFFFF"><input name="amount" type="text" id="amount" size="8" /></td>
          <td bgcolor="#FFFFFF"><input name="onagof" type="text" id="onagof" size="15" /></td>
          <td bgcolor="#FFFFFF"><select name="cost_type" id="cost_type">
            <?php 

		  $result=mysql_query("select * from cost_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>
          <td bgcolor="#FFFFFF"><input name="voucher" type="text" id="voucher" size="10" /></td>
          <td width="364" bgcolor="#FFFFFF"><input name="comments" type="text" id="comments" size="15" /></td>
          <td width="241" bgcolor="#FFFFFF"><input name="pay_methode" type="text" id="pay_methode" size="15" /></td>
          <td width="335" rowspan="2" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="Submit" /></td>
        </tr>

        <tr>

          <td height="30" colspan="8" bgcolor="#FFFFFF"><div id="Paid By" style="display: block">

			      <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#DEDFDE">

                    <tr>

                      <td width="86%" align="right" bgcolor="#FFFFFF">Pay From Acc : </td>

                      <td width="14%" bgcolor="#FFFFFF"><select name="acc_no" id="acc_no">

                        <option value="">Select Account</option>

                        <?php 

		  $gresult=mysql_query("select * from bank_acc ORDER BY id asc");

		  $grow=mysql_fetch_array($gresult);

		  do{

		  ?>

                        <option value="<?php echo $drow[id];?>"><?php echo $drow[accname]."($drow[accno])";?></option>

                        <?php }while($drow=mysql_fetch_array($gresult));?>

                      </select></td>
                    </tr>
                  </table>

			      </div>
            <span class="style2">M.Rec = Money Receipt <span class="style3">|</span> Ref = Reference <span class="style3">|</span> PP = Passport <span class="style3">|</span> VF = Visa Fee <span class="style3">|</span> C = Conveyance <span class="style3">|</span> O = Others Cost </span></td>
          </tr>
      </table>

    </form></td>

  </tr>

  <tr>

    <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#999999">

          <tr>

            <td colspan="14" align="left" bgcolor="#999999"><strong>All cost  of today

                <?php 

			  echo date("d-M-Y");

			  

			  //echo $row[month];

			

	/*		  if($mon == '01'){echo "January (".$year.")";}

			  if($mon == '02'){echo "February (".$year.")";}

			  if($mon == '03'){echo "March (".$year.")";}

			  if($mon == '04'){echo "April (".$year.")";}

			  if($mon == '05'){echo "May (".$year.")";}

			  if($mon == '06'){echo "Jun (".$year.")";}

			  if($mon == '07'){echo "July (".$year.")";}

			  if($mon == '08'){echo "August (".$year.")";}

			  if($mon == '09'){echo "September (".$year.")";}

			  if($mon == '10'){echo "October (".$year.")";}

			  if($mon == '11'){echo "November (".$year.")";}

			  if($mon == '12'){echo "December (".$year.")";}*/

			  

			   ?>

            </strong></td>
          </tr>

          <tr>
            <td align="left" > Date<br /></td>
            <td align="left" >Paid To</td>
            <td align="left" >Amount</td>
            <td align="left" >On against of</td>
            <td align="left" >Cost Type </td>
            <td >Voucher No/ <br />
M.Rec / Ref.</td>
            <td > Comments</td>
            <td >Pay Methode</td>
            <td >Pay From Acc</td>
            <td align="center" >Debited<br />
Trx ID</td>

            <td align="center" >Entry time </td>
            <td align="center" >Entry By </td>
            <td align="center" >Edit</td>
            <td width="130" align="center" >Approve ID </td>
        </tr>

		  <?php 

		   $m=date("m");

			$y=date("Y");

			  

		  $dt=$y.$m;

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

		  $dresult=mysql_query("select * from cost order by id desc limit 50");

		  $drow=mysql_fetch_array($dresult);

		  $total=0;

		  do{

		  ?>

          <tr>

          <td width="60" align="left" bgcolor="#FFFFFF" class="link"><?php 

			 echo dtformat($drow[cdate]);

			?></td>

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



            <td width="60" align="left" bgcolor="#FFFFFF" 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="150" align="left" bgcolor="#FFFFFF" class="link"><?php 

			 echo $drow[onagof];

			?></td>

            <td width="100" align="left" bgcolor="#FFFFFF" class="link"><?php 

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

		  $arow=mysql_fetch_array($aresult);

			

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

            <td width="60" bgcolor="#FFFFFF" class="link"><?php echo $drow[voucher]; ?></td>

            <td width="100" bgcolor="#FFFFFF" class="link"><?php 

			 echo $drow[comments];

			?></td>

            <td width="100" bgcolor="#FFFFFF" class="link"><?php 

			 echo $drow[pay_methode];

			?>&nbsp;</td>
            <td width="100" bgcolor="#FFFFFF" class="link"><?php  

			if($drow[pay_methode] == 'Paid By'){

			$wresult=mysql_query("select * from bank_widrow WHERE id='$drow[chid]'");
		    $wrow=mysql_fetch_array($wresult);

			

			$gresult=mysql_query("select * from bank_acc WHERE id='$drow[acc_no]'");
		    $grow=mysql_fetch_array($gresult);
		    echo $grow[accname]." ($grow[accno])";

			}

			?></td>

            <td width="80" align="center" bgcolor="#FFFFFF" class="link"><a href="payment_voucher_print.php?id=<?php echo $drow[id];?>" target="_blank">P-<?php echo $drow[id];?></a></td>

            <td width="60" align="center" bgcolor="#FFFFFF" class="link"><?php
			
if($drow[datetime1]!='0000-00-00 00:00:00'){
$newDate = date("d-m-Y H:i:s", strtotime($drow[datetime1]));
echo $newDate;
			}
			?></td>
            <td width="75" align="center" bgcolor="#FFFFFF" class="link"><?php 

			 echo $drow[suser];

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

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

//-----------------
if($_SESSION[invcox] == "$drow[suser]"){ ?>
              <a href="edit_cost.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_cost.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_cost.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_cost.php?id=<?php echo $drow[id];?>">Edit</a>
              <?php } }?></td>
            <td align="center" bgcolor="#FFFFFF" class="link"><?php 
			
$result=mysql_query("select * from user WHERE userid='$_SESSION[invcox]' and status='1'");
$row=mysql_fetch_array($result);

if($row[income_type] == '1'){
			?>
              <form id="form2" name="form2" method="post" action="cost_approve.php">
                <table width="100%" border="0" cellspacing="2" cellpadding="0">
                  <tr>
                    <td><input name="id" type="hidden" id="id" value="<?php echo $drow[id];?>" />
                      <input name="activecode" type="text" id="activecode" size="5"  value="<?php echo $drow[activecode];?>"/></td>
                    <td><input type="submit" name="Submit2" value="Go" /></td>
                  </tr>
                </table>
              </form>
            
              <?php }else{echo $drow[activecode];} ?></td>
        </tr>

         

          <?php 

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

		  ?> <tr>

            <td colspan="4" align="right"  class="link"><strong>Total : </strong></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>

            <td colspan="3"  class="link">&nbsp;</td>

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

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

</table>

</body>

</html>

<?php }?>