<div class="content-wrapper" id="mainprojdiv">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h4 class="m-0">School Projects</h4>
          </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">Projects</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-3 col-sm-6 col-12">
            <div class="info-box">
              <span class="info-box-icon bg-info"><i class="far fa-envelope"></i></span>
              <?php
                include('../include/config.php');
                $result = mysqli_query($con,"SELECT * FROM projects");
                $num_rows1 = mysqli_num_rows($result);
                {
                    $sts=htmlentities($num_rows1); 
                }
                ?>
                                  
              <div class="info-box-content">
                <span class="info-box-text">Total Projects</span>
                <h4 class="info-box-number budge"><?php echo $sts; ?></h4>
              </div>
                
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
          
          <div class="col-md-3 col-sm-6 col-12">
            <div class="info-box alert-success">
  
              <div class="info-box-content">
                <center>
                    <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#modalprojects" id="openprojectmodal">
                  <i class="fa fa-plus"></i> Add new project
                </button>
                </center>
              </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 col-sm-6 col-12">
            
            </div>
             <div class="table-responsive" id="table-responsive">
                 <table class="table table-bordered" id="tableprojects">
                     <thead>
                         <tr>
                             <th>#</th>
                             <th>Project ID</th>
                             <th>Project Name</th>
                             <th>Contractor/Supervisor</th>
                             <th>Start Date</th>
                             <th>Estimated Comp' Date</th>
                             <th>Date Completed</th>
                             <th>Project status</th>
                             <th>Cost (KES)</th>
                             <th>Last Update</th>
                             <th>Add Expense</th>
                             <th>Action</th>
                         </tr>
                     </thead>
                     <tbody>
                            <?php
                        $sql = "select projects.*, (SELECT SUM(Amount) FROM prodata where proid=projects.id) as toto from projects left join prodata ON prodata.proid=projects.id group by id";
                        $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["ProCode"]; ?></td>
                            <td><?php echo $row["Pname"]; ?></td>
                            <td><?php echo $row["Contractor"]; ?></td>
                            <td><?php echo $row["SDate"]; ?></td>
                            <td><?php echo $row["EDate"]; ?></td>
                            <td><?php echo $row["CompDate"]; ?></td>
                            <td><?php echo $row["Status"]; ?></td>
                             <td><label class='text-danger' style="font-size:16px;font-family:Impact;font-weight:bold"><?php echo $row["toto"]; ?></label></td>
                            <td><?php echo $row["LastUpdate"]; ?></td>
                            <td><center><i class="fa fa-plus btn text-green btnadddata btn-xs" id="bed"></i> </center></td>
                
                            <td>
                                <input type="hidden" name="proidh" class="proidh" value="<?php echo $row["id"]; ?>" />
                                <a href="Expenditure.php?page=Project_data&proid=<?php echo $row["ProCode"]; ?>"><i class="fa fa-eye btn text-green btn-xs"></i>
                                </a>
                                
                                |
                                <i class="fa fa-edit btn text-green btnfeeeditpro btn-xs" id="bed"></i> |
                                
                                <i class="fa fa-trash btn-xs text-danger prodelete" id="prodelete"></i>
                            </td>
                            </tr>
                            <?php
                            $cnt=$cnt+1;
                            }
                        }
                            ?>
                     </tbody>
                 </table> 
              </div>
            </div>
    </section>
</div>

