

<?php

 include('include/headscript.php'); ?>



<?php

   // pickup the get variable

   if (isset($_GET["idstandards"])) {

       $idstandards=$_GET["idstandards"];

   }

   if (isset($_POST["idstandards"])) {

       $idstandards=$_POST["idstandards"];

   }

   



?>

<?php

if (isset($_POST["formnameedit"])) {

	$idprotcheck=$_POST["protcat"];

	$protcheck = new WA_MySQLi_RS("protcheck",$cmctrfdb,1);

$protcheck->setQuery("SELECT * FROM stdprotectioncat WHERE stdprotectioncat.idprotectioncategory='$idprotcheck'  AND stdprotectioncat.idstandards='$idstandards'");

$protcheck->execute();

	

	if (empty($protcheck->getColumnVal("idstdprotectioncat"))) {

	

  $InsertQuery = new WA_MySQLi_Query($cmctrfdb);

  $InsertQuery->Action = "insert";

  $InsertQuery->Table = "stdprotectioncat";

  $InsertQuery->bindColumn("idstandards", "i", "$idstandards", "WA_DEFAULT");

  $InsertQuery->bindColumn("idprotectioncategory", "i", "".((isset($_POST["protcat"]))?$_POST["protcat"]:"")  ."", "WA_DEFAULT");

  $InsertQuery->saveInSession("");

  $InsertQuery->execute();

  $InsertGoTo = "";

  if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";

  $InsertQuery->redirect($InsertGoTo);

}}

?>



<?php

$standarddetail = new WA_MySQLi_RS("standarddetail",$cmctrfdb,0);

$standarddetail->setQuery("SELECT * FROM standards WHERE standards.idstandards='$idstandards'");

$standarddetail->execute();

$idarttypen=$standarddetail->getColumnVal("idarticletype"); 



echo $idarttypen; ?>



<?php

$protectioncategorylist = new WA_MySQLi_RS("protectioncategorylist",$cmctrfdb,0);

$protectioncategorylist->setQuery("SELECT * FROM protectioncategory ORDER BY protectioncategory.name_protectioncategory ");

$protectioncategorylist->execute();

?>

<?php

$selectprotcatstd = new WA_MySQLi_RS("selectprotcatstd",$cmctrfdb,0);

$selectprotcatstd->setQuery("SELECT * FROM stdprotectioncat LEFT JOIN standards ON stdprotectioncat.idstandards=standards.idstandards LEFT JOIN protectioncategory ON protectioncategory.idprotectioncategory=stdprotectioncat.idprotectioncategory WHERE stdprotectioncat.idstandards='$idstandards' ");

$selectprotcatstd->execute();?>



<!DOCTYPE html>

<html lang="en">

	

<head>

        <meta charset="utf-8" />

        <title>TRF CIMAC </title>

        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

        <meta content="CIMAC TRF Portal" name="description" />

        <meta content="" name="author" />

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



        <!-- App favicon -->

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

	

		<!--Form Wizard-->

        <link href="../plugins/jquery-steps/jquery.steps.css" rel="stylesheet" type="text/css">



        <!-- App css -->

        <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

        <link href="assets/css/jquery-ui.min.css" rel="stylesheet">

        <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />

        <link href="assets/css/metisMenu.min.css" rel="stylesheet" type="text/css" />

        <link href="assets/css/app.min.css" rel="stylesheet" type="text/css" />



	

	<!-- submit form with button -->

<script>

function formSubmit() {

    document.forms["myForm"].submit();

}

</script>





</head>



    <body>

        

         <!-- Top Bar Start -->

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

        <!-- Top Bar End -->



        

        <!-- Left Sidenav -->

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

    <!-- end left-sidenav-->



        <div class="page-wrapper">

            <!-- Page Content-->

            <div class="page-content">



                <div class="container-fluid">

                    <!-- Page-Title -->

                    <div class="row">

                        <div class="col-sm-12">

                            <div class="page-title-box">

                                <div class="float-right">

                                    <ol class="breadcrumb">

                                        <li class="breadcrumb-item"><a href="javascript:void(0);">TRF</a></li>

                                        <li class="breadcrumb-item active">Starter</li>

                                    </ol>

                                </div>

                                <h4 class="page-title"><?php echo $titlewb; ?></h4>

                            </div><!--end page-title-box-->

                        </div><!--end col-->

                    </div>

					<div class="row">

                        <div class="col-sm-12">

							

							

							

						  <!-- card for additional info gloves -->

							

                          <!--end card-body-->

							

						  <!-- card for show requirements -->

							<div class="card">

                              <div class="card-body">

                                    <h4 class="mt-0 header-title">Standards: <?php echo($standarddetail->getColumnVal("standardcode")); ?> - <?php echo($standarddetail->getColumnVal("standardname")); ?></h4>

                                <p class="text-muted mb-3">Aggiungi le categorie di protezione per questo standard</p> 

                             

								  <div class="table-responsive">

                                        <table class="table table-bordered mb-0 table-centered">

                                            <thead>

                                            <tr>

                                                <th>Protection Category</th>

                                                <th>Action</th>

                                            </tr>

                                            </thead>

                                            <tbody>

                                              <?php

$wa_startindex = 0;

while(!$selectprotcatstd->atEnd()) {

  $wa_startindex = $selectprotcatstd->Index;

?>

  <tr>

    <td><?php echo($selectprotcatstd->getColumnVal("name_protectioncategory")); ?></td>

    

    <td>                                                       

      

      <a href="deleteprotcat.php?idstandards=<?php echo $idstandards; ?>&idstdprotectioncat=<?php echo($selectprotcatstd->getColumnVal("idstdprotectioncat")); ?>"><i class="fas fa-trash-alt text-danger font-16"></i></a>

    </td>

  </tr>

  <?php

  $selectprotcatstd->moveNext();

}

$selectprotcatstd->moveFirst(); //return RS to first record

unset($wa_startindex);

unset($wa_repeatcount);

?>

                                          </tbody>

                                        </table><!--end /table-->

                                </div>

								  

									   

								

                              </div><!--end card-body-->

								

								

							

							

                      </div><!--end card-->

                       

					<div class="card">

                              <div class="card-body">

                                    <h4 class="mt-0 header-title">Standards: <?php echo($standarddetail->getColumnVal("standardcode")); ?> - <?php echo($standarddetail->getColumnVal("standardname")); ?></h4>

                                <p class="text-muted mb-3">Aggiungi le categorie di protezione per questo standard</p> 

                              <form class="was-validated" action="" method="post" name="myForm">

					<div class="form-group row">

                                                <label class="col-sm-2 col-form-label text-right">Select</label>

                                                <div class="col-sm-10">

                                                    <select class="form-control" name="protcat" id="protcat">

                                                      <option value="">Seleziona</option>

                                                      <?php

while(!$protectioncategorylist->atEnd()) { //dyn select

?>

                                                      <option value="<?php echo($protectioncategorylist->getColumnVal("idprotectioncategory")); ?>"><?php echo($protectioncategorylist->getColumnVal("name_protectioncategory")); ?></option>

                                                      <?php

  $protectioncategorylist->moveNext();

} //dyn select

$protectioncategorylist->moveFirst();

?>

                                                  </select>

                                                </div>

                                            </div>



					<input type="hidden" name="idstandards" id="idstandards" value="<?php echo $idstandards; ?>">

					<input type="hidden" name="formnameedit" id="formnameedit" value="proteditlist">

					<input type="button" onclick="formSubmit()" class="btn btn-gradient-success waves-effect waves-light" value="Aggiungi"><br>



							    </form>

								  

									   

								

                              </div><!--end card-body-->

								

								

							

							

                      </div><!--end card-->		

							

                       

                  </div><!--end col-->

              </div>

                    <!-- end page title end breadcrumb -->

                    



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

<!-- footer start -->

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

                </footer><!--end footer-->

    </div>

            <!-- end page content -->

        </div>

        <!-- end page-wrapper -->



        





        <!-- jQuery  -->

        <script src="assets/js/jquery.min.js"></script>

        <script src="assets/js/bootstrap.bundle.min.js"></script>

        <script src="assets/js/metismenu.min.js"></script>

        <script src="assets/js/waves.js"></script>

        <script src="assets/js/feather.min.js"></script>

        <script src="assets/js/jquery.slimscroll.min.js"></script>

        <script src="assets/js/jquery-ui.min.js"></script>

	

	        <script src="../plugins/jquery-steps/jquery.steps.min.js"></script>

        <script src="assets/pages/jquery.form-wizard.init.js"></script>



        <!-- App js -->

        <script src="assets/js/app.js"></script>

        

    </body>



</html>