<?php
	//find user id
	$userId = $_GET['user'];
?>
<div class="right_col" role="main">
    <div class="">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
					<div class="x_title">
						<h2>Bill Details</h2>
						<div class="clearfix"></div>
					</div>
					<div class="x_content">

						<form class="form-horizontal form-label-left" method="post">

							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="roomno">Bill Title <span class="required">*</span></label>
							  <div class="col-md-4 col-sm-3 col-xs-12">
									<input id="roomno" class="form-control col-md-7 col-xs-12" name="billTitle" type="text">
							  </div>
							</div>
							
							<div class="ln_solid"></div>
							<div class="form-group">
								<div class="col-md-6 col-md-offset-3">
									<button id="send" type="submit" name="submit" class="btn btn-success">Submit</button>
									<button type="submit" class="btn btn-primary" onclick="javascript:window.location='index.php?pagecontent=dashboard'">Cancel</button>
								</div>
							</div>
						</form>
					</div>
                </div>
            </div>
			
              <div class="clearfix"></div>

              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Table design <small>Custom design</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>

                  <div class="x_content">

                    <p>Add class <code>bulk_action</code> to table for bulk actions options on row select</p>

                    <div class="table-responsive">
                      <table class="table table-striped jambo_table bulk_action">
                        <thead>
                          <tr class="headings">
                            <th>
                              <input type="checkbox" id="check-all" class="flat">
                            </th>
                            <th class="column-title">Invoice </th>
                            <th class="column-title">Invoice Date </th>
                            <th class="column-title">Order </th>
                            <th class="column-title">Bill to Name </th>
                            <th class="column-title">Status </th>
                            <th class="column-title">Amount </th>
                            <th class="column-title no-link last"><span class="nobr">Action</span>
                            </th>
                            <th class="bulk-actions" colspan="7">
                              <a class="antoo" style="color:#fff; font-weight:500;">Bulk Actions ( <span class="action-cnt"> </span> ) <i class="fa fa-chevron-down"></i></a>
                            </th>
                          </tr>
                        </thead>

                        <tbody>
							<?php
								$result=mysqli_query($conn, "SELECT * FROM bills") or die (mysql_error());
								while($row = mysqli_fetch_array($result)){
							?>
                          <tr class="even pointer">
                            <td class="a-center ">
                              <input type="checkbox" class="flat" name="table_records">
                            </td>
                            <td class=" ">121000040</td>
                            <td class=" "><?php echo $row['bl_title']; ?></td>
                            <td class=" ">121000210 <i class="success fa fa-long-arrow-up"></i></td>
                            <td class=" ">John Blank L</td>
                            <td class=" ">Paid</td>
                            <td class="a-right a-right ">$7.45</td>
                            <td class=" last"><a href="?pagecontent=bills&remove=<?php echo $row['bl_id']; ?>">Delete</a>
                            </td>
                          </tr>
							<?php } ?>
                        </tbody>
                      </table>
                    </div>
							
						
                  </div>
                </div>
              </div>
        </div>
    </div>
</div>

<?php
	if(isset($_REQUEST['remove'])){
		
		$id = $_REQUEST['remove'];
		
		mysqli_query($conn,"DELETE FROM bills WHERE bl_id=$id") or die (mysql_error());
		
		header('Location: index.php?pagecontent=bills');  
	}

	if(isset($_POST['submit']))
	{
		$billTitle = $_POST['billTitle'];
		
		mysqli_query($conn, "INSERT INTO bills (bl_title)
		VALUES ('$billTitle')") or die (mysql_error());
		
		header('Location: index.php?pagecontent=bills');
	}

	function select($a, $b){
		if($a == $b){ echo " SELECTED"; }
	}
?>