<?php

require 'lib/app.php';
require 'vendor/autoload.php';

use Checklist\Manage_Checklist;
$id=$_GET['id'];

$cat= new Manage_Checklist();
$crnt_cat=$cat->viewCategoryByChecklist($id);

$categories=$cat->view('categories');

$ck = new Manage_Checklist();
$checklists=$ck->view('checklists',$id);
foreach ($checklists as $item){
?>

        <form id="myForm2" action="update_checklist.php" method="post" class="form text-center">
                                <label for="category">Select Category:</label>
                                    <select name="category_id" id="category"  class="form-control">
                                        <?php                                        
                                        foreach($crnt_cat as $crnt_category) { ?>
                                        <option value="<?php echo $crnt_category['category_id'] ?>"><?php echo $crnt_category['category_name'] ?></option>
                                       <?php } ?>
                                       <?php foreach($categories as $category){ ?>
                                        <option value="<?php echo $category['id'] ?>"><?php echo $category['category_name'] ?></option>
                                       <?php } ?>
                                    </select>

                                <label for="item">Title:</label>
<?php
require 'lib/app.php';
require 'vendor/autoload.php';
use Checklist\Manage_Checklist;

if($_POST['title']=='' || $_POST['category_id']==''|| $_POST['modified_by']==''){
    echo '<p class="alert alert-danger">Sorry. Please Select option & insert data proberly</p>';
}else{
$id=$_POST['id'];
$ct= new Manage_Checklist();
$ct->update($id,$_POST);


echo '<p class="alert alert-success">update data Successfull</p>';
}
<?php

require 'lib/app.php';
require 'vendor/autoload.php';
use Checklist\Manage_Checklist;
if ($_POST['title'] == '' || $_POST['category_id'] == '' || $_POST['created_by'] == '') {
    echo '<p class="alert alert-danger">Sorry. Please Select option & insert data proberly</p>';
} else {
    $ct = new Manage_Checklist();
    $ct->insert('checklists', $_POST);
    echo '<p class="alert alert-success">Insert data Success</p>';
}
<?php

require 'lib/app.php';
require 'vendor/autoload.php';
use Checklist\Manage_Checklist;
$ck = new Manage_Checklist();
$data = $ck->view();
print_r($data);
//echo $ck->title;
<?php

require 'lib/app.php';
require 'vendor/autoload.php';

use Checklist\Manage_Checklist;

$cat= new Manage_Checklist();
$ck = new Manage_Checklist();
$cc = new Manage_Checklist();
$categories=$cat->view('categories');
$page_title='MANAGE CHECKLIST';
$cat_count = $cc->countChecklistByCategory();

?>

<?php include 'src/header.php' ?>
        <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
<?php include 'src/top_nav.php' ?>
        <!-- END HEADER -->
<?php include 'src/profile_sidebar.php' ?>


        <div class="col-md-9">
                            <!--main body part -->
                            <div class="profile-content"  >
                              <h4 class="page-header"><?php echo $page_title ?></h4>
                                <div class="row">

                                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Insert New Check list item</button>
<?php

require 'lib/app.php';
require 'vendor/autoload.php';
use Checklist\Manage_Checklist;
$id = $_GET['id'];
$ck = new Manage_Checklist();
$ck->delete($id);
echo '<h4 class="alert alert-danger">Data Delete Successfull</h4>';
?>