<?php include('../config.php');
include('inc.session-create.php');
$PageTitle = "Form";
$FileName = 'formdata.php';
$validate = new Validation();
if ($_SESSION['success'] != "") {
    $stat['success'] = $_SESSION['success'];
    unset($_SESSION['success']);
}

if (isset($_POST['addnewrecord'])) {
    $validate->addRule($_POST['title'], '', 'Title', true);
    if ($validate->validate() && count($stat) == 0) {
        if (isset($_FILES["thumbnail"]["name"]) && !empty($_FILES["thumbnail"]["name"])) {
            $filename = basename($_FILES['thumbnail']['name']);
            $ext1 = strtolower(substr($filename, strrpos($filename, '.') + 1));
            if (in_array($ext1, array('jpg', 'JPG', 'JPEG', 'jpeg', 'png', 'PNG', 'gif', 'svg', 'webp', 'pdf', 'docx', 'doc'))) {
                $newfile = date("d-m-Y-h-i-s") . rand(1000, 9999) . "." . $ext1;
                move_uploaded_file($_FILES['thumbnail']['tmp_name'], "../uploads/" . $newfile);
            }
        }

        $aryData = array(
            'token'                     =>     token('formdata'),
            'title'                     =>     $_POST['title'],
            'title_one'                     =>     $_POST['title_one'],
            'description'           =>       $_POST['description'],
            'description_one'           =>       $_POST['description_one'],
            'date'           =>       date("Y-m-d"),
            'category'           =>       $_POST['category'],
            'location'           =>       $_POST['location'],
            'thumbnail'                  =>     $newfile,
            'thumbnail_one'                  =>     $newfile1,
            'status'                    =>     $_POST['status'],
        );
        $flgIn1 = $db->insertAry("formdata", $aryData);
        //echo $db->getLastQuery();exit;
        $_SESSION['success'] = "Submited Successfully";
        redirect($FileName);
        unset($_POST);
    } else {
        $stat['error'] = $validate->errors();
    }
} elseif (isset($_POST['updaterecord'])) {
    $validate->addRule($_POST['title'], '', 'Title', true);
    if ($validate->validate() && count($stat) == 0) {
        if (isset($_FILES["image"]["name"]) && !empty($_FILES["image"]["name"])) {
            $filename = basename($_FILES['image']['name']);
            $ext1 = strtolower(substr($filename, strrpos($filename, '.') + 1));
            if (in_array($ext1, array('jpg', 'JPG', 'JPEG', 'jpeg', 'png', 'PNG', 'gif', 'svg', 'webp'))) {
                $newfile = date("d-m-Y-h-i-s") . rand(1000, 9999) . "." . $ext1;
                move_uploaded_file($_FILES['image']['tmp_name'], "../uploads/" . $newfile);
            }
        } else {
            $newfile = $_POST['image_old'];
        }

        $aryData = array(
            'title'                     =>     $_POST['title'],
            'thumbnail'                  =>     $newfile,
            'status'                    =>     $_POST['status'],
        );
        $flgIn = $db->updateAry("formdata", $aryData, "where id='" . $_GET['id'] . "' ");
        //		echo $db->getLastQuery();	exit;
        $_SESSION['success'] = "Update Successfully";
        unset($_POST);
        redirect($FileName);
    } else {
        $stat['error'] = $validate->errors();
    }
} elseif (($_REQUEST['action'] == 'delete')) {
    $aryData = array(
        'status'                     => 2,
    );
    $flgIn = $db->updateAry("formdata", $aryData, "where id='" . $_GET['id'] . "' ");
    //	echo $db->getLastQuery();	exit;
    $_SESSION['success'] = 'Deleted Successfully';
    redirect($FileName);
}
?>
<!DOCTYPE html>
<html>

<head>
    <?php include('inc.meta.php'); ?>
    <style>
        div.scrollmenu {
            background-color: #fff;
            overflow: auto;
            white-space: nowrap;
        }

        div.scrollmenu a {
            display: inline-block;
            color: white;
            text-align: center;
            padding: 14px;
            text-decoration: none;
        }

        div.scrollmenu a:hover {
            background-color: #777;
        }
    </style>

</head>

<body class="fixed-left">
    <div id="wrapper"><?php include('inc.header.php'); ?><?php include('inc.sideleft.php'); ?><div class="content-page">
            <div class="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12">
                            <h4 class="page-title"><?php echo $PageTitle; ?></h4>
                            <ol class="breadcrumb">
                                <li><a href="<?php echo $iClassName; ?>">Home</a></li>
                                <li class="active"><?php echo $PageTitle; ?></li>
                            </ol>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card-box">
                                <div class="row">
                                    <div class="col-md-9"><?php echo msg($stat); ?></div>
                                </div>
                            </div>
                            <div class="card-box  scrollmenu">
                                <table id="datatable" class="table table-striped table-bordered">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Full Name</th>
                                            <th>Father’s/Husband Name</th>
                                            <th>Date of Birth</th>
                                            <th>Gender</th>
                                            <th>Mobile No</th>
                                            <th>Email Id</th>
                                            <th>Address</th>
                                            <th>Job Selection</th>
                                            <th>10th Institute/University</th>
                                            <th>10th Passing Year</th>
                                            <th>10th Marks/Percentage</th>
                                            <th>10th Marksheet</th>
                                            <th>12th Institute/University</th>
                                            <th>12th Passing Year</th>
                                            <th>12th Marks/Percentage</th>
                                            <th>12th Marksheet</th>
                                            <th>Graduation Institute/University</th>
                                            <th>Graduation Passing Year</th>
                                            <th>Graduation Marks/Percentage</th>
                                            <th>Graduation Marksheet</th>
                                            <th>Post-graduation Institute/University</th>
                                            <th>Post-graduation Passing Year</th>
                                            <th>Post-graduation Marks/Percentage</th>
                                            <th>Post-graduation Marksheet</th>
                                            <th>P.hD Institute/University</th>
                                            <th>P.hD Passing Year</th>
                                            <th>P.hD Marks/Percentage</th>
                                            <th>P.hD Marksheet</th>
                                            <th>Other Institute/University</th>
                                            <th>Other Passing Year</th>
                                            <th>Other Marks/Percentage</th>
                                            <th>Other Marksheet</th>
                                            <th>Work Experience - Organization</th>
                                            <th>Work Experience - Position</th>
                                            <th>Work Experience - Duration</th>
                                            <th>Work Experience - Years</th>
                                            <th>Work Experience - Certificate</th>
                                            <th>Passport Size Photograph</th>
                                            <th>Signature</th>
                                            <th>ID Proof</th>
                                            <th>Payment Receipt</th>
                                            <th>Education Marks</th>
                                            <th>Work Marks</th>
                                            <th>Skills Marks</th>
                                            <th>Achievements Marks</th>
                                            <th>Total Marks</th>
                                            <th>Transcation ID</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $i = 0;
                                        $aryList = $db->getRows("select * from formdata");
                                        foreach ($aryList as $iList) {
                                            $i = $i + 1;  ?>
                                            <tr>
                                                <td><?php echo $iList['id']; ?></td>
                                                <td><?php echo $iList['fullname']; ?></td>
                                                <td><?php echo $iList['husname']; ?></td>
                                                <td><?php echo $iList['dob']; ?></td>
                                                <td><?php echo $iList['gender']; ?></td>
                                                <td><?php echo $iList['mobileno']; ?></td>
                                                <td><?php echo $iList['emailid']; ?></td>
                                                <td><?php echo $iList['addr']; ?></td>
                                                <td><?php echo $iList['job']; ?></td>
                                                <td><?php echo $iList['tenuni']; ?></td>
                                                <td><?php echo $iList['tenpass']; ?></td>
                                                <td><?php echo $iList['tenper']; ?></td>
                                                <td><img src="../uploads/<?php echo $iList['tenthum']; ?>"></td>
                                                <td><?php echo $iList['tweuni']; ?></td>
                                                <td><?php echo $iList['twepass']; ?></td>
                                                <td><?php echo $iList['tweper']; ?></td>
                                                <td><img src="../uploads/<?php echo $iList['tewthumb']; ?>"></td>
                                                <td><?php echo $iList['grauni']; ?></td>
                                                <td><?php echo $iList['grapas']; ?></td>
                                                <td><?php echo $iList['graper']; ?></td>
                                                <td><img src="../uploads/<?php echo $iList['grathumb']; ?>"></td>
                                                <td><?php echo $iList['posuni']; ?></td>
                                                <td><?php echo $iList['pospass']; ?></td>
                                                <td><?php echo $iList['posper']; ?></td>
                                                <td><img src="../uploads/<?php echo $iList['posthumb']; ?>"></td>
                                                <td><?php echo $iList['puni']; ?></td>
                                                <td><?php echo $iList['ppass']; ?></td>
                                                <td><?php echo $iList['pper']; ?></td>
                                                <td><img src="../uploads/<?php echo $iList['pthumb']; ?>"></td>
                                                <td><?php echo $iList['otuni']; ?></td>
                                                <td><?php echo $iList['otpass']; ?></td>
                                                <td><?php echo $iList['otper']; ?></td>
                                                <td><img src="../uploads/<?php echo $iList['othumb']; ?>"></td>
                                                <td><?php echo $iList['organization']; ?></td>
                                                <td><?php echo $iList['position']; ?></td>
                                                <td><?php echo $iList['workdur']; ?></td>
                                                <td><?php echo $iList['yearexp']; ?></td>
                                                <td><img src="../uploads/<?php echo $iList['thumb']; ?>"></td>
                                                <td><img src="../uploads/<?php echo $iList['thumbnail']; ?>"></td>
                                                <td><img src="../uploads/<?php echo $iList['signthumb']; ?>"></td>
                                                <td><img src="../uploads/<?php echo $iList['idthumb']; ?>"></td>
                                                <td><img src="../uploads/<?php echo $iList['paythumb']; ?>"></td>
                                                <td><?php echo $iList['edumark']; ?></td>
                                                <td><?php echo $iList['workmark']; ?></td>
                                                <td><?php echo $iList['skimark']; ?></td>
                                                <td><?php echo $iList['achimark']; ?></td>
                                                <td><?php echo $iList['total']; ?></td>
                                                <td><?php echo $iList['transaction']; ?></td>
                                                <!--<td><a href="javascript:del('<?php echo $FileName; ?>?action=delete&id=<?php echo $iList['id']; ?>')" class="btn-view"><i class="ti-trash"></i>Delete</a></td>--->
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div><?php include('inc.footer.php'); ?>
        </div>
    </div><?php include('inc.js.php'); ?>
</body>

</html>