<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h5 class="m-0">Imprest Manager</h5>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">Dashboard</li>
              <li class="breadcrumb-item ">Expenses</li>
              <li class="breadcrumb-item active">Imprest</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-4 col-sm-4 col-4">
            <div class="info-box">
              <div class="info-box-content">
                  <button class="btn btn-info" id="openimprestmodal">Manage Imprest <i class="fa fa-gear"></i></button>
              </div>
    
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
          
           <div class="col-md-3 col-sm-3 col-12">
            <div class="info-box">
              <div class="info-box-content">
                  <button class="btn btn-success" id="addimpitems">Manage Expenses Categories <i class="fa fa-plus"></i></button>
              </div>
    
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
         
          </div>
         </div>
    </section>
          
    
    <section class="content" style="text-decoration:none;font-weight:normal;font-family:Times;font-size:12px">
           <div class="row">
              <div class="col-md-4" style="background-color:#b3e0ff"> 
              <h5 class="m-0 text-success">Add new Expenses</h5>
                <div class="modal-body">
                  <form action="" method="POST" onsubmit="return false">
                      
                    <div class="form-group">
                    <label for="inputStatus">Expense Category <span class="requireds">*</span></label>
                      <select id="expecat" class="form-control custom-select">
                            <option selected value="">Select ---</option>
                            <?php
                            $sql = "SELECT * FROM expenses order by Item ASC";
                            $result = $con->query($sql);
                            while($row = $result->fetch_assoc()) 
                            {
                            ?>
                            <option value="<?php echo $row['Count']; ?>"><?php echo $row['Item']; ?>
                            </option>
                            <?php
                            }
                            ?>
                     </select>
                    </div>
                      
                      <div class="form-group">
                      <label for="inputProjectLeader">Expenditure Date <span class="requireds">*</span></label>
                      <input type="date" style="font-weight:bold" class="form-control" name="" id="expedates" required />
                     </div>
                     
                     <div class="form-group">
                      <label for="inputProjectLeader">Particular<span class="requireds">*</span></label>
                      <input type="text" style="" class="form-control" name="" id="parti" required />
                     </div>
                     
                     <div class="form-group">
                      <label for="inputProjectLeader"><Strong>Amount Spent (KES)</Strong> <span class="requireds">*</span></label>
                      <input type="text" style="font-weight:1000" class="form-control text-danger" name="" id="expeamount" required  />
                     </div>
                     
                     <div class="form-group">
                    <label for="inputStatus">Mode of Payment <span class="requireds">*</span></label>
                    <select id="paymode" class="form-control custom-select" required>
                    <option selected disabled value="">Select ---</option>
                    <option value="Cash">Cash</option>
                    <option value="Mpesa">Mpesa</option>
                    </select>
                    </div>
                     
                     
                      <div class="form-group">
                      <label for="inputProjectLeader">Imprest Debited</label>
                       <select id="impdebited" class="form-control custom-select">
                            <option selected value="">Select ---</option>
                            <?php
                            $sql = "SELECT * FROM Imprest";
                            $result = $con->query($sql);
                            while($row = $result->fetch_assoc()) 
                            {
                            ?>
                            <option value="<?php echo $row['id']; ?>"><?php echo $row['Title']; ?>
                            </option>
                            <?php
                            }
                            ?>
                     </select>
                       </div>
                   
                      <div class="form-group">
                      <label for="inputProjectLeader">Any Description</label>
                      <textarea class="form-control" id="expemoredetails"> </textarea>
                      </div>
                  
                       <div class="form-group">
                         <label id="mes" style="color:#FFF">.</label> <br />
                        <button style="position:relative;margin-bottom:10px" class="btn btn-success btn-sm pull-right btn-block" id="saveexpenses">Save <i class="fa fa-save"></i>
                        </button>
                       </div>
                  </form>
                </div>
              </div>
               
             <div class="col-md-8">  
             <center><label id="impdeletelabel"></label></center>
             
               <table class="table">
                     <tr class="alert-warning">
                         <td>Filter By Month</td>
                         <td>
                            <div class="form-group">
                            <input type="Month" id="monn1" class="form-control" />
                            </div>
                         </td>
                         <td>
                             <button class="btn btn-success btn-sm" id="filtersasa"><i class="fa fa-refresh"></i></button>
                         </td>
                     </tr>
                 </table>
             
             <div class="table-responsive" id="divbus">
                 <table class="table table-bordered" id="tableexpenditure" >
                     <thead>
                         <tr>
                             <th>#</th>
                             <th>Particular</th>
                             <th>Amount</th>
                             <th>Category</th>
                             <th>Expense Date</th>
                             <th>Imprest Debited</th>
                             <th>Entry date</th>
                             <th>Action</th>
                         </tr>
                     </thead>
                     <tbody>
                        <?php
                        //include('../include/config.php');
                        if(isset($_SESSION['manimp']))
                        {
                            $ma=$_SESSION['manimp'];
                            $yrr=substr($ma, 0, 4);
                            $mm=substr($ma, 5, 2);
                            
                            if($mm=='01'){$mm='January';}
                            if($mm=='02'){$mm='February';}
                            if($mm=='03'){$mm='March';}
                            if($mm=='04'){$mm='April';}
                            if($mm=='05'){$mm='May';}
                            if($mm=='06'){$mm='June';}
                            if($mm=='07'){$mm='July';}
                            if($mm=='08'){$mm='August';}
                            if($mm=='09'){$mm='September';}
                            if($mm=='10'){$mm='October';}
                            if($mm=='11'){$mm='November';}
                            if($mm=='12'){$mm='December';}   
                            
                        $sql = "select Imprest2.*,Imprest.Title as imp,expenses.Item as ite from Imprest2 left join Imprest ON Imprest.id=Imprest2.Imprest left join expenses ON expenses.Count=Imprest2.Cate where Imprest2.Month='$mm' AND Imprest2.Year='$yrr'  order by ExpDate DESC";    
                        }else
                        {
                        $sql = "select Imprest2.*,Imprest.Title as imp,expenses.Item as ite from Imprest2 left join Imprest ON Imprest.id=Imprest2.Imprest left join expenses ON expenses.Count=Imprest2.Cate order by ExpDate DESC LIMIT 200";
                        }
                        $result = $con->query($sql);
                        if ($result->num_rows > 0) 
                        {
                            $cnt='1';
                            while($row = $result->fetch_assoc()) 
                            {
                            ?>	
                       <tr>
                        <td><?php echo $cnt; ?></td>
                        <td><?php echo $row["Particular"]; ?></td>
                        <td class="alert-success"><?php echo $row["Amount"]; ?>
                        </td>
                        <td><?php echo $row["ite"]; ?></td>
                        <td><strong><?php echo $row["ExpDate"]; ?></strong></td>
                        <td class="alert-warning"><?php echo $row["imp"]; ?>
                        </td>
                        <td><?php echo $row["EntryDate"]; ?>
                        </td>
                        <td>
                         <input type="hidden" name="bid" class="impdatacount" value="<?php echo $row["count"]; ?>" />
                         <i class="fa fa-eye btn-xs text-info btnview btn" id="">
                         </i>
                        |
                        <i class="fa fa-trash btn-xs text-danger btn deleteimpdata" ></i>
                        </td>
                            </tr>
                            <?php
                            $cnt=$cnt+1;
                            }
                        }
                            ?>
                     </tbody>
                 </table> 
              </div>
        <hr />   
        <form method="POST" target="_blank" action="Imprest_Report.php" >
        <div class="row">
             <div class="col-md-3">
               <div class="form-group">
                <label for="inputProjectLeader" class="pull-right">Generate Report for: </label>
              </div>
              </div>
               <div class="col-md-4">
                <div class="form-group">
                       <select id="" name="impres" class="form-control custom-select" required>
                            <option selected value="">Select ---</option>
                            <?php
                            $sql = "SELECT * FROM Imprest order by id DESC";
                            $result = $con->query($sql);
                            while($row = $result->fetch_assoc()) 
                            {
                            ?>
                            <option value="<?php echo $row['id']; ?>">Equity <?php echo $row['Title']; ?>
                            </option>
                            <?php
                            }
                            ?>
                     </select>
                </div>
            </div>
            <div class="col-md-2"> 
             <div class="form-group">
                    <button style="position:relative;margin-bottom:10px" class="btn btn-success btn-sm pull-right" id="">Filter <i class="fa fa-filter"></i>
                    </button>
            </div>
            </div>
        </div>
        </form>
              
              </div>
              
            </div>
    </section>
</div>

