
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>POS </h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active">General Form</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->	
	<section class="content">
      <div class="container-fluid">
        <div class="row">
          <!-- left column -->
          <div class="col-md-8">
            
            <div class="card card-info">
              <div class="card-header">
                <h3 class="card-title">Product List</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
           
                <div class="card-body">
                  
				  
				  
				                  <table id="example1" class="table table-bordered table-striped">
                  <thead>
                  <tr>
                    <th>Product Name</th>
                    <th>Stock Size</th>
                    <th>Product Price (Tsh)</th>
                    <th>Cart size</th>
                    <th>Action</th>
                  </tr>
                  </thead>
                  <tbody>
                
				  
				    <?php
include"config.php";

$sql="select * from product order by product_id desc";
$result=mysqli_query($conn,$sql);

if(mysqli_num_rows($result)>0)
{
	while($row=mysqli_fetch_assoc($result))
	{
		
	echo"
   
     <tr>
	 <form action='cart_ship.php' method='post'>
                    <td>".$row['product_name']."</td>";
					if($row['product_size']<1)
					{
						echo"
						 <td> <font color='red'> Out of Stock </font>
                    </td>
						";
					}
					else
					{
						echo"
						 <td> ".$row['product_size']."
                    </td>
					";
					}
					
                   
					echo"
                    <td>".$row['product_price']."</td>
                    <td><input type='number' MIN='1' MAX='".$row['product_size']."' name='cart_size' required></td>
                    <td>
					";
					
					
					if($row['product_size']<1)
					{
						echo"
						<input type='submit' class='btn btn-info' value='Add to Cart' disabled>
                    </td>
						";
					}
					else
					{
						echo"
						 <input type='submit' class='btn btn-info' value='Add to Cart'>
                    </td>
					";
					}
					echo"
					
					<input type='hidden' name='product_id' value='".$row['product_id']."'>
					<input type='hidden' name='product_price' value='".$row['product_price']."'>
					<input type='hidden' name='product_name' value='".$row['product_name']."'>
					<input type='hidden' name='product_name' value='".$row['product_name']."'>
					<input type='hidden' name='purchase_price' value='".$row['purchase_price']."'>

					  </form>
					</td>
                  </tr>
 
 ";
	}
}
mysqli_close($conn);
?>
				  
				                  
                
                  </tfoot>
                </table>
				  
				  
				  
                </div>
                <!-- /.card-body -->
              
                <!-- /.card-footer -->
         
            </div>
            <!-- /.card -->

          </div>
          <!--/.col (left) -->
          <!-- right column -->
          <div class="col-md-4">
            <!-- Form Element sizes -->
            <div class="card card-info">
              <div class="card-header">
                <h3 class="card-title">Shopping Cart</h3>
              </div>
              <div class="card-body">
              
			  
			  			    <?php
include"config.php";

$sql="select * from cart where cashier_name='juma'";
$sql_sum="SELECT sum(product_price) as cart_cost FROM cart";

$result=mysqli_query($conn,$sql);
$result_sum=mysqli_query($conn,$sql_sum);

$row_sum=mysqli_fetch_assoc($result_sum);

if(mysqli_num_rows($result)>0)
{
	while($row=mysqli_fetch_assoc($result))
	{
	echo"
		 <form action='undo_cart.php' method='post'>
   ".$row['product_name']."  @".$row['product_price']."TSH X ".$row['cart_size']." = ".$row['product_amount']."TSH     &nbsp;&nbsp;
&nbsp; 
<input type='hidden' name='product_id' value='".$row['product_id']."'>
<input type='hidden' name='cart_size' value='".$row['cart_size']."'>
<input type='hidden' name='cart_id' value='".$row['cart_id']."'>
 <input type='submit' class='btn1 danger' value='Remove'>
 </form>
 <br>
 
 



 ";
	}
	
	
	
}
else
	echo"No Product selected to cart";
mysqli_close($conn);
?>
			  
			  
			  <b><h5> 
			
			  <?php
			  include"config.php";



              
           
           
$sql="select SUM(product_amount) as jumla from cart where cashier_name='juma'";
$result=mysqli_query($conn,$sql);

$sql_cart="select * from cart";
$result_cart=mysqli_query($conn,$sql_cart);



if(mysqli_num_rows($result)>0) 
{
	$row=mysqli_fetch_assoc($result);
	
	echo"</br> Tax Total: ".$row['jumla']*0.18. "/= <br>";
	echo" Grand Total: ".$row['jumla']."/=  <br>  
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
";}
if(mysqli_num_rows($result_cart)<1) 
{
	echo"	
<form action='sell_action.php'>
<input type='submit' class='btn btn-success' value='  Sell  '  disabled>
	</form>";
}
 else
 {
echo"	
<form action='sell_action.php' method='POST'>
  <div class='form-group'>
              <label for='inputName'>Customer Name</label>
              <input type='text' name='customer_name' id='customer_name' class='form-control'  />
			  <label for='inputName'>Customer TIN</label>
              <input type='text' name='customer_tin' id='inputName' class='form-control'  />
			  <label for='inputName'>Customer Address</label>
              <input type='text' name='customer_address' id='inputName' class='form-control'  />
			  <label for='inputName'>Customer Tel</label>
              <input type='text' name='customer_tel' id='inputName' class='form-control'  />
			  <label for='inputName'>Machine SN</label>
              <input type='text' name='machine_sn' id='inputName' class='form-control'  />
			  <label for='inputName'>Business Type</label>
              <input type='text' name='business_type' id='inputName' class='form-control' />
			  <label for='inputName'>Payment Type</label>
              <select type='text' name='payment_type' id='inputSubject' class='form-control' />
			  <option selected>Full Paid</option>
			  <option >Partial Payment</option>
			 
			  </select>
			  
            </div>
 <select class='form-control select2' style='width: 100%;'>
<option>Cash</option>
<option>Card</option>
<option>Check</option>

</select>
<br>

<input type='submit' class='btn btn-success toastrDefaultSuccess' value='  Sell  ' >
	</form>";	 
 }

mysqli_close($conn);
?>
			  
			  </h5></b>
              </div>
              <!-- /.card-body -->
            </div>
          
          </div>
          <!--/.col (right) -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
	    <!-- /.content -->
  </div>    