<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php"); ?>
<?php if (isset($_POST['name_component'])) {
    $name_component = $_POST['name_component'];
}
if (isset($_POST['description_component'])) {
    $description_component = $_POST['description_component'];
}
if (isset($_POST['cas_component'])) {
    $cas_component = $_POST['cas_component'];
}
if (isset($_POST['formula_component'])) {
    $formula_component = $_POST['formula_component'];
}
if (isset($_POST['component_family_id'])) {
    $component_family_id = $_POST['component_family_id'];
}
if (isset($_POST['maincat'])) {
    $component_family_type = $_POST['maincat'];
}
if (isset($_POST['company_id'])) {
    $company_id = $_POST['company_id'];
}
if (isset($_POST['insertcompform'])) {
    $insertcompform = $_POST['insertcompform'];
}
if (isset($_POST['preset'])) {
    $presetcomponent = $_POST['preset'];
}
?>
<?php
if (isset($_POST['insertcompform'])) {
    $InsertQuery = new WA_MySQLi_Query($repnew);
    $InsertQuery->Action = "insert";
    $InsertQuery->Table = "component";
    $InsertQuery->bindColumn("name_component", "s", "$name_component", "WA_DEFAULT");
    $InsertQuery->bindColumn("description_component", "s", "$description_component", "WA_DEFAULT");
    $InsertQuery->bindColumn("cas_component", "s", "$cas_component", "WA_DEFAULT");
    $InsertQuery->bindColumn("formula_component", "s", "$formula_component", "WA_DEFAULT");
    $InsertQuery->bindColumn("component_family_id", "i", "$component_family_id", "WA_DEFAULT");
    $InsertQuery->bindColumn("component_family_type", "i", "$component_family_type", "WA_DEFAULT");
    $InsertQuery->bindColumn("company_id", "i", "$company_id", "WA_DEFAULT");
    $InsertQuery->bindColumn("preset", "s", "$presetcomponent", "WA_DEFAULT");
    $InsertQuery->saveInSession("");
    $InsertQuery->execute();
    $InsertGoTo = "";
    if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo ? rel2abs($InsertGoTo, dirname(__FILE__)) : "";
    $InsertQuery->redirect($InsertGoTo);
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <?php include('../include/seo.php'); ?>

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <link rel="shortcut icon" href="../assets/images/favicon.ico">

    <link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="../assets/css/icons.css" rel="stylesheet" type="text/css">
    <link href="../assets/css/style.css" rel="stylesheet" type="text/css">
    <link href="https://cdn.jsdelivr.net/npm/boxicons@2.0.7/css/boxicons.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.css">

</head>


<body class="fixed-left">

    <!-- Loader -->
    <div id="preloader">
        <div id="status">
            <div class="spinner"></div>
        </div>
    </div>

    <!-- Begin page -->
    <div id="wrapper">

        <?php include('../include/navigationbar.php'); ?>

        <!-- Start right Content here -->

        <div class="content-page">
            <!-- Start content -->
            <div class="content">

                <?php include('../include/topbar.php'); ?>

                <div class="page-content-wrapper ">

                    <div class="container-fluid">
                        <?php
                        $fanilycatquery = new WA_MySQLi_RS("fanilycatquery", $repnew, 0);
                        $fanilycatquery->setQuery("SELECT * FROM component_family ORDER BY component_family.name_componentfamily");
                        $fanilycatquery->execute();
                        ?>
                        <?php
                        $maincatquery = new WA_MySQLi_RS("maincatquery", $repnew, 0);
                        $maincatquery->setQuery("SELECT * FROM component_family_type ORDER BY component_family_type.name_componentfamilytype");
                        $maincatquery->execute(); ?>
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="page-title-box">
                                    <div class="btn-group float-right">
                                        <ol class="breadcrumb hide-phone p-0 m-0">
                                            <li class="breadcrumb-item"><a href="#">Reportify</a></li>
                                            <li class="breadcrumb-item active">EasySpec</li>
                                        </ol>
                                    </div>
                                    <h4 class="page-title">EasySpec</h4>
                                </div>
                            </div>
                        </div>
                        <!-- end page title end breadcrumb -->
                        <div class="alert alert-warning" role="alert">
                            <?php echo $newanalysistitle; ?>
                            <?php echo $insertanalysisalert; ?>
                        </div>
                        <div class="row">
                            <div class="col-xl-12">
                                <div class="card">
                                    <div class="card-body">
                                        <h5 class="header-title pb-3 mt-0">EasySpec: <?php echo $insertcomponenttitle; ?></h5>

                                        <div>
                                            <form method="post" class="form-horizontal p-t-20" id="updatebeach">

                                                <div class="mb-3 row">
                                                    <label for="exampleInputuname3" class="col-sm-3 control-label"><?php echo $name_component_lang; ?></label>
                                                    <div class="col-sm-9">
                                                        <div class="input-group">

                                                            <input name="name_component" type="text" class="form-control" id="name_component">
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="mb-3 row">
                                                    <label for="exampleInputuname3" class="col-sm-3 control-label"><?php echo $description_component_lang; ?></label>
                                                    <div class="col-sm-9">
                                                        <div class="input-group">

                                                            <input name="description_component" type="text" class="form-control" id="description_component">
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="mb-3 row">
                                                    <label for="exampleInputuname3" class="col-sm-3 control-label"><?php echo $cas_component_lang; ?></label>
                                                    <div class="col-sm-9">
                                                        <div class="input-group">

                                                            <input name="cas_component" type="text" class="form-control" id="cas_component">
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="mb-3 row">
                                                    <label for="exampleInputuname3" class="col-sm-3 control-label"><?php echo $formula_component_lang; ?></label>
                                                    <div class="col-sm-9">
                                                        <div class="input-group">

                                                            <input name="formula_component" type="text" class="form-control" id="formula_component">
                                                        </div>
                                                    </div>
                                                </div>
                                                <input name="company_id" type="hidden" id="company_id" value="<?php echo $idcompany; ?>">
                                                <?php if ($kindofrole == '3') { ?>
                                                    <input name="preset" type="hidden" id="preset" value="Y"><?php } else { ?>
                                                    <input name="preset" type="hidden" id="preset" value="N"><?php } ?>
                                                <input name="insertcompform" type="hidden" id="insertcompform" value="insertcompform">

                                                <div class="mb-3 row">
                                                    <label class="col-md-2 col-form-label"><?php echo $family_component_lang; ?></label>
                                                    <div class="col-md-10">
                                                        <select class="form-select" id="component_family_id" name="component_family_id">
                                                            <option value=""><?php echo $selecttitle; ?></option>
                                                            <?php
                                                            while (!$fanilycatquery->atEnd()) { //dyn select
                                                            ?>
                                                                <option value="<?php echo ($fanilycatquery->getColumnVal("idcomponentfamily")); ?>"><?php echo ($fanilycatquery->getColumnVal("name_componentfamily")); ?></option>
                                                            <?php
                                                                $fanilycatquery->moveNext();
                                                            } //dyn select
                                                            $fanilycatquery->moveFirst();
                                                            ?>
                                                        </select>
                                                    </div>
                                                </div>



                                                <div class="mb-3 row">
                                                    <label class="col-md-2 col-form-label"><?php echo $labfamily_component_lang; ?></label>
                                                    <div class="col-md-10">
                                                        <select class="form-select" id="maincat" name="maincat">
                                                            <option value=""><?php echo $selecttitle; ?></option>
                                                            <?php
                                                            while (!$maincatquery->atEnd()) { //dyn select
                                                            ?>
                                                                <option value="<?php echo ($maincatquery->getColumnVal("idcomponentfamilytype")); ?>"><?php echo ($maincatquery->getColumnVal("name_componentfamilytype")); ?></option>
                                                            <?php
                                                                $maincatquery->moveNext();
                                                            } //dyn select
                                                            $maincatquery->moveFirst();
                                                            ?>
                                                        </select>
                                                    </div>
                                                </div>

                                                <td><input name="created_at" type="hidden" id="created_at"></td>
                                                <td><input name="updated_at" type="hidden" id="updated_at"></td>
                                                <div class="form-group row m-b-0">
                                                    <div class="offset-sm-3 col-sm-9">
                                                        <button type="submit" class="btn btn-success waves-effect waves-light"><?php echo $inserttitle; ?></button>
                                                    </div>
                                                </div>
                                                <div class="card-body collapse show">
                                                    <button type="button" onclick="goBack()" class="btn btn-dark waves-effect waves-light"><i class="fa fa-backward"></i> <?php echo $back; ?></button>
                                                    <script>
                                                        function goBack() {
                                                            window.history.back();
                                                        }
                                                    </script>
                                                </div>
                                        </div>
                                        </form>
                                    </div><!--end table-responsive-->

                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- end row -->


                </div><!-- container -->

            </div> <!-- Page content Wrapper -->

        </div> <!-- content -->

        <?php include('../include/footer.php'); ?>

    </div>
    <!-- End Right content here -->

    </div>
    <!-- END wrapper -->
    <script>
        $(document).ready(function() {
            $('[data-toggle="tooltip"]').tooltip();
        });
    </script>

    <!-- plugin JS  -->
    <script src="../assets/js/jquery.min.js"></script>
    <script src="../assets/js/popper.min.js"></script>
    <script src="../assets/js/bootstrap.min.js"></script>
    <script src="../assets/js/modernizr.min.js"></script>
    <script src="../assets/js/detect.js"></script>
    <script src="../assets/js/fastclick.js"></script>
    <script src="../assets/js/jquery.slimscroll.js"></script>
    <script src="../assets/js/jquery.blockUI.js"></script>
    <script src="../assets/js/waves.js"></script>
    <script src="../assets/js/jquery.nicescroll.js"></script>
    <script src="../assets/js/jquery.scrollTo.min.js"></script>

    <script src="../assets/plugins/chart.js/chart.min.js"></script>
    <script src="../assets/pages/dashboard.js"></script>

    <!-- App js -->
    <script src="../assets/js/app.js"></script>


</body>

</html>