<?php require('includes/head.php');
  require 'connection/conn.php';
  if(isset($_POST['add']))
  {
	  $n=$_POST['note'];
	  $d=$_POST['date'];
	  $p=$_POST['person'];
	  $a=$_POST['amount'];
	  $q="insert into `masruf3`(`masruf_amount`, `masruf_date`, `masruf_person`, `masruf_note`, `masruf_user`)  values('$a','$d','$p','$n','$login_user')";
	  $conn->query($q);
		echo "<script type='text/javascript'>
		window.location.href='masruf_list3.php'
		</script>";
  }
  elseif(isset($_GET['del_id']))
  {
	  $id=$_GET['del_id'];
	  $conn->query("delete from `masruf3` where `masruf_id`=$id");
  }
  $employe="select * from `masruf3` ";
  $employe_r=$conn->query($employe);
?>
<div class="container">
          <div class="page-inner">
            <div class="page-header">
              <h3 class="fw-bold mb-3">مصروف</h3>
              <ul class="breadcrumbs mb-3">
                <li class="nav-home">
                  <a href="home.php">
                    <i class="icon-home"></i>
                  </a>
                </li>
                <li class="separator">
                  <i class="icon-arrow-right"></i>
                </li>
                <li class="nav-item">
                  <a href="#"></a>
                </li>
                <li class="separator">
                  <i class="icon-arrow-right"></i>
                </li>
                <li class="nav-item">
                  <a href="#"></a>
                </li>
              </ul>
            </div>
            <div class="row">
              <div class="col-md-12">
                <div class="card">
                  
                  <div class="card-body">
                    <div class="table-responsive">
                      <table id="basic-datatables"  class="display table table-striped table-hover"  >
<thead>
<tr>
	<form action="" method="post">
		<th><input type="text" name="person" required></th>
		<th><input type="number" name="amount" required></th>
		<th><input type="date" name="date" required></th>
		<th><textarea name="note" required></textarea></th>
		<th><input type="submit" name="add" value="زیادکردن"></th>
		</form></tr>
  <tr bgcolor="skyblue">
     
     <th>ناو</th>
     <th>بڕی پارە</th>
	 
     <th>بەروار</th><th>تێبینی</th>
     <th colspan=2></th>
  </tr>
  </thead>
  <tbody>
  <?php while($row=mysqli_fetch_array($employe_r)) { ?>
    <tr>
		<td><?php echo $row['masruf_person'];?></td>
		<td><?php echo number_format($row['masruf_amount'],0);?></td>
		<td><?php echo $row['masruf_date'];?></td>
		<td><?php echo $row['masruf_note'];?></td>
		<th  width=65px><a onclick='return confirm("are you sure?");' href="masruf_list3.php?del_id=<?php echo $row['masruf_id'];?>"><img src="icon/delete.png" width=25px></a></th>
	</tr>
  <?php } ?>
  </tbody>
</table>
</div>
                  </div>
                </div>
              </div>
			  
			  </div>
          </div>
        </div>
<?php require'includes/foot.php';?>