<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">Farm Income</h5>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">Dashboard</li>
              <li class="breadcrumb-item ">Income</li>
              <li class="breadcrumb-item active">Farm Income</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-5 col-sm-5 col-5">
            <div class="info-box">
              <span class="info-box-icon bg-info"><i class="far fa-dollar"></i></span>
              <?php
                //include('../include/config.php');
                $result = mysqli_query($con,"SELECT SUM(Amount) as ama FROM farminput where Month='$month'");
                while($row = $result->fetch_assoc()) 
                {
                  $totincome=$row["ama"];
                }
                ?>
              <div class="info-box-content">
                <span class="info-box-text">Income from the farm this month (<small><?php echo $month;?></small>)</span>
            <h4 class="info-box-number budge"><?php echo $totincome.' Ksh'; ?></h4>
              </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-3"> 
              <h5 class="m-0 text-success">Add new Income</h5>
                <div class="modal-body">
                  <form action="" method="POST" onsubmit="return false">
               
                      <div class="form-group">
                      <label for="inputProjectLeader">Particular <span class="requireds">*</span></label>
                      <input type="text" class="form-control" name="" id="farmitem" required />
                      </div>
                      
                      <div class="form-group">
                      <label for="inputProjectLeader">Date <span class="requireds">*</span></label>
                      <input type="date" class="form-control" name="" id="farmdate" required />
                      </div>
                      
                      <div class="form-group">
                      <label for="inputProjectLeader">Amount earned (Ksh) <span class="requireds">*</span></label>
                      <input type="text"  onkeypress="return /[0-9]/i.test(event.key)" class="form-control farmamount" max-length="6" name="" id="farmamount" required />
                      </div>
                      
                      
                      <div class="form-group">
                      <label for="inputProjectLeader">Mode of payment <span class="requireds">*</span></label>
                      <select class="form-control" id="farmmod">
                          <option value="">---</option>
                          <option value="Cash">Cash</option>
                          <option value="Mpesa">Mpesa</option>
                          <option value="Bank">Bank</option>
                      </select>
                      </div>
        
                      <div class="form-group">
                      <label for="inputProjectLeader">Account Credited</label>
                       <select id="farmbnk" class="form-control custom-select">
                            <option selected value="">Select ---</option>
                            <?php
                            $sql = "SELECT * FROM bankdata";
                            $result = $con->query($sql);
                            while($row = $result->fetch_assoc()) 
                            {
                            ?>
                            <option value="<?php echo $row['id']; ?>"> <?php echo $row['Bname'].'->'; ?> <small><?php echo $row['Account']; ?> </small>
                            </option>
                            <?php
                            }
                            ?>
                     </select>
                       </div>
                       
                     <div class="form-group">
                      <label for="inputProjectLeader">Transaction Details </label>
                      <input type="text" class="form-control" name="" id="ftd" />
                     </div>
         
                     <div class="form-group">
                         <label id="farmmessage" style="color:#FFF">.</label> <br />
                         <button style="margin-right:0px;position:relative" class="btn btn-info btn-sm pull-right" id="btnsavefarminput">Save <i class="fa fa-save"></i>
                        </button>
                     </div>
                  </form>
                </div>
              </div>
               
             <div class="col-md-9">  
             <div class="table-responsive" id="divbus">
                 <table class="table table-bordered" id="tablefarmincome" >
                     <thead>
                         <tr>
                             <th>#</th>
                             <th>Particular</th>
                             <th>Income Date</th>
                             <th>Amount Earned (Ksh)</th>
                             <th>Paid Via</th>
                              <th>Bank Credited</th>
                             <th>Entry Date</th>
                             <th>Action</th>
                         </tr>
                     </thead>
                     <tbody>
                        <?php
                        //include('../include/config.php');
                        $sql = "select farminput.*,bankdata.Bname as bnk, bankdata.Account as act from farminput left join bankdata ON bankdata.id=farminput.Bank order by id DESC";
                        $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["Item"]; ?></td>
                        <td class="alert-success"><?php echo $row["Date"]; ?>
                        </td>
                        <td class="alert-danger" ><strong class="bigger"><?php echo $row["Amount"]; ?></strong>
                        </td>
                        <td><strong><?php echo $row["Paymode"]; ?></strong></td>
                        <td><?php echo $row["bnk"]; ?> <small><?php echo $row["act"]; ?> </small>
                        </td>
                        <td>
                           <?php echo $row["EntryDate"]; ?>
                        </td>
                        <td>
                        <input type="hidden" name="faid" class="faid" value="<?php echo $row["id"]; ?>" />
                         <i class="fa fa-pen btn-xs text-info farmedit btn" id="farmedit"></i>
                        |
                        <i class="fa fa-trash btn-xs text-danger btnfarmdelete btn" id="farmdelete"></i>
                        </td>
                            </tr>
                            <?php
                            $cnt=$cnt+1;
                            }
                        }
                            ?>
                     </tbody>
                 </table> 
              </div>
              </div>
              
            </div>
    </section>
</div>

