<?php require_once('../Connections/cmctrfdb.php'); ?>

<?php require_once('../webassist/mysqli/rsobj.php'); ?>

<?php

 include('include/headscript.php');

include('db-connect.php');

?>

<?php 

// pickup the get variable

// pickup the get variable

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

	$idtrf=$_POST["idtrf"]; }

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

	$idtrf=$_GET["idtrf"]; }

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

	$photoname=$_POST["photoname"]; }

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

	$description=$_POST["description"]; }

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

	$model=$_POST["model"]; }

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

	$rangemeasuremin=$_POST["rangemeasuremin"]; }

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

	$rangemeasuremax=$_POST["rangemeasuremax"]; }

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

	$registeredmark=$_POST["registeredmark"]; }

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

	$articletype=$_POST["articletype"]; }

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

	$articlecharacteristic=$_POST["articlecharacteristic"]; }

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

	$formupdtrfdetails=$_POST["formupdtrfdetails"]; }

if (isset($_POST['stdselected'])) 

{

    $stds = $_POST['stdselected'];

}

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

	$updstdform=$_POST["updstdform"]; }



    if (isset($articlecharacteristic)) {

        $listartchar = implode(',', $articlecharacteristic);

    }else{

        $listartchar = "";

    }





//echo $listartchar;

?>



<?php

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

<?php if (isset($articlecharacteristic)) {

    

    foreach ($articlecharacteristic as $ac) {

        

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

$stdfromartchar->setQuery("SELECT * FROM standards WHERE standards.idarticlecharacteristic='$ac'");

$stdfromartchar->execute();

        $value=$stdfromartchar->getColumnVal("idstandards");

        $dpicatsel=$stdfromartchar->getColumnVal("iddpicategory");



								//foreach ($stds as $hobys=>$value) {

             				

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

$stdcheckpresent->setQuery("SELECT * FROM trfstandards WHERE trfstandards.idtrfdetails='$idtrf' AND trfstandards.idstandards='$value'");

$stdcheckpresent->execute();



        // insert for glovces EN 420 if not present

        if ($articletype==2) {

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

$stdcheckpresent420->setQuery("SELECT * FROM trfstandards WHERE trfstandards.idtrfdetails='$idtrf' AND trfstandards.idstandards='129'");

$stdcheckpresent420->execute();

            if (empty($stdcheckpresent420->getColumnVal("idtrfstandards"))) {

             $InsertQuery = new WA_MySQLi_Query($cmctrfdb);

  $InsertQuery->Action = "insert";

  $InsertQuery->Table = "trfstandards";

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

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

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

  $InsertQuery->saveInSession("");

  $InsertQuery->execute();

  $InsertGoTo = "";

 

  $InsertQuery->redirect($InsertGoTo);

        }}

        

	if (empty($stdcheckpresent->getColumnVal("idtrfstandards"))) {



  $InsertQuery = new WA_MySQLi_Query($cmctrfdb);

  $InsertQuery->Action = "insert";

  $InsertQuery->Table = "trfstandards";

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

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

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

  $InsertQuery->saveInSession("");

  $InsertQuery->execute();

  $InsertGoTo = "";

 

  $InsertQuery->redirect($InsertGoTo);



        }}}//}

								

								

								?>

<?php

if (isset($formupdtrfdetails)) {

  $UpdateQuery = new WA_MySQLi_Query($cmctrfdb);

  $UpdateQuery->Action = "update";

  $UpdateQuery->Table = "`trf-details`";

  $UpdateQuery->bindColumn("sample_description", "s", "$description", "WA_DEFAULT");

  $UpdateQuery->bindColumn("measurefrom", "s", "$rangemeasuremin", "WA_DEFAULT");

  $UpdateQuery->bindColumn("measureto", "s", "$rangemeasuremax", "WA_DEFAULT");

  $UpdateQuery->bindColumn("model", "s", "$model", "WA_DEFAULT");

  $UpdateQuery->bindColumn("idarticletype", "i", "$articletype", "WA_DEFAULT");

  $UpdateQuery->bindColumn("idarticle_characteristics", "s", "$listartchar", "WA_DEFAULT");

  $UpdateQuery->bindColumn("registeredmark", "s", "$registeredmark", "WA_DEFAULT");

  $UpdateQuery->addFilter("idtrfdetails", "=", "i", "".($idtrf)  ."");

  $UpdateQuery->execute();

  $UpdateGoTo = "";

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

  $UpdateQuery->redirect($UpdateGoTo);

	

	  $code="3";	

  $InsertQuery2 = new WA_MySQLi_Query($cmctrfdb);

  $InsertQuery2->Action = "insert";

  $InsertQuery2->Table = "wheretrfstep";

  $InsertQuery2->bindColumn("idtrf", "i", "$idtrf", "WA_DEFAULT");

  $InsertQuery2->bindColumn("code", "s", "$code", "WA_DEFAULT");

  $InsertQuery2->saveInSession("");

  $InsertQuery2->execute();

  $InsertGoTo = "";



  $InsertQuery2->redirect($InsertGoTo);

}

?>

<?php

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

<?php

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

$trfnumberfinal->setQuery("SELECT * FROM `trf-details` WHERE `trf-details`.idtrfdetails='$idtrf'");

$trfnumberfinal->execute(); 

$idcertn=$trfnumberfinal->getColumnVal("idcertification");

$articletype=$trfnumberfinal->getColumnVal("idarticletype");

$articlecharact=$trfnumberfinal->getColumnVal("idarticle_characteristics");

?>

<?php $idcert=$trfnumberfinal->getColumnVal("idcertification") ?>

<?php

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

$certname->setQuery("SELECT * FROM certificationtype WHERE certificationtype.idcertificationtype='$idcert'");

$certname->execute();?>

<?php // if all the standards of articletype

// $stdcheck = new WA_MySQLi_RS("stdcheck",$cmctrfdb,0);

// $stdcheck->setQuery("SELECT * FROM standards WHERE standards.idarticletype='$articletype'");

// $stdcheck->execute(); ?>

<?php // preselection based on article characteristic

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

$stdcheck->setQuery("SELECT * FROM standards WHERE standards.idarticlecharacteristic='$articlecharact' ");

$stdcheck->execute();

$idstselect=$stdcheck->getColumnVal("idstandards");

?>

<?php //  inline edit query

$idtrfdetails=$idtrf;

$row1 = mysqli_query($con,"SELECT *,trfstandards.iddpicategory as iddpicategoryid,trfstandards.idprotectioncategory as idprotectioncategoryid,trfstandards.idstandards as idstandardsid FROM trfstandards LEFT JOIN standards ON trfstandards.idstandards=standards.idstandards LEFT JOIN dpicategory ON trfstandards.iddpicategory=dpicategory.iddpicategory LEFT JOIN protectioncategory ON trfstandards.idprotectioncategory=protectioncategory.idprotectioncategory WHERE trfstandards.idtrfdetails='$idtrf'");

//$rows = mysqli_fetch_assoc($row1);

//print_r($rows);

//exit;

$idstandards=mysqli_query($con,"SELECT idstandards ,standardname FROM standards");



//query list protectioncategory

// $proteccategorylist=mysqli_query($con,"SELECT idprotectioncategory ,name_protectioncategory FROM protectioncategory");



// $idproteccategorylistRecord=array();       

// while($idprotectioncategoryrow = mysqli_fetch_assoc($proteccategorylist)) {

//     $idproteccategorylistRecord[$idprotectioncategoryrow['idprotectioncategory']]=utf8_encode($idprotectioncategoryrow['name_protectioncategory']);

// }

// $idprotectioncategoryJson=json_encode($idproteccategorylistRecord);



/* GET OPTIONS FOR Categoria di protezione per standard */

$idprotectioncategoryJson = json_encode(array());

$proteccategorylist=mysqli_query($con,"select s.idstandards, p.idprotectioncategory, p.name_protectioncategory

                                        from stdprotectioncat s

                                        left join protectioncategory p

                                        on s.idprotectioncategory = p.idprotectioncategory

                                        where 1");

$idproteccategorylistRecord=array();       

while($idprotectioncategoryrow = mysqli_fetch_assoc($proteccategorylist)) {

    $idproteccategorylistRecord[$idprotectioncategoryrow['idstandards']][$idprotectioncategoryrow['idprotectioncategory']] = utf8_encode($idprotectioncategoryrow['name_protectioncategory']);

}

$idprotectioncategoryperStdJson = json_encode($idproteccategorylistRecord);

/* END GET OPTIONS FOR Categoria di protezione per standard */



// //Impermeabilità

// //query list protectioncategory

// $dpicategroylist=mysqli_query($con,"SELECT iddpicategory ,value_dpicategory FROM dpicategory");



// $iddpicategorylistRecord=array();       

// while($iddpicategoryrow = mysqli_fetch_assoc($dpicategroylist)) {

//     $iddpicategorylistRecord[$iddpicategoryrow['iddpicategory']]=utf8_encode($iddpicategoryrow['value_dpicategory']);

// }

// $iddpicategoryJson=json_encode($iddpicategorylistRecord);



/* GET OPTIONS FOR Categoria DPI per standard */

$iddpicategoryJson = json_encode(array());

$dpicategroylist=mysqli_query($con,"select s.idstandards, d.iddpicategory, d.value_dpicategory

                                    from stddpicategory s

                                    left join dpicategory d

                                    on s.iddpicategory = d.iddpicategory

                                    where 1");

$iddpicategorylistRecord=array();       

while($iddpicategoryrow = mysqli_fetch_assoc($dpicategroylist)) {

    $iddpicategorylistRecord[$iddpicategoryrow['idstandards']][$iddpicategoryrow['iddpicategory']] = utf8_encode($iddpicategoryrow['value_dpicategory']);

}

$iddpicategoryperStdJson=json_encode($iddpicategorylistRecord);

/* END GET OPTIONS FOR Categoria DPI per standard */

?>

<!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" />



	<!-- inline edit -->

	

	<!-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

  <script src="https://kit.fontawesome.com/f13e61f9bf.js" crossorigin="anonymous"></script>

	<script src="jquery.tabledit.js"></script>

	<!-- submit form with button -->

<script>

function formSubmit() {

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

}

</script>



<script type="text/javascript">



$(document).ready(function(){

	populate_cat_tbl();

	

	$("#add").click(function(e){

        var table = $(this).attr('for-table');  //get the target table selector

        var $tr = $(table + ">tbody>tr:last-child").clone(true, true);  //clone the last row

        var nextID = parseInt($tr.find("input.tabledit-identifier").val()) + 1; //get the ID and add one.

        $tr.find("input.tabledit-identifier").val(nextID);  //set the row identifier

        $tr.find("span.tabledit-identifier").text(nextID);  //set the row identifier

        $(table + ">tbody").append($tr);    //add the row to the table

        $tr.find(".tabledit-edit-button").click();  //pretend to click the edit button

        $tr.find("input:not([type=hidden]), select").val("");   //wipe out the inputs.

        $(this).prop('disabled', true);

        $('select[name=idprotectioncategoryid]').prepend("<option value='' selected='selected'>Please Select</option>");

        $('select[name=iddpicategoryid]').prepend("<option value='' selected='selected'>Please Select</option>");

    });

/*$('#example1').Tabledit({

    url: 'logic-edit-delete.php',

    columns: {

        identifier: [0, 'id'],

        editable: [[2, 'idprotectioncategory','<?php echo $idprotectioncategoryJson; ?>'], [3, 'iddpicategory','<?php echo $iddpicategoryJson; ?>']]

    },

    onDraw: function() {

        console.log('onDraw()');

    },

    onSuccess: function(data, textStatus, jqXHR) {

        console.log('onSuccess(data, textStatus, jqXHR)');

        console.log(data);

        console.log(textStatus);

        console.log(jqXHR);

        $("#add").prop('disabled', false);

		//location.reload();

    },

    onFail: function(jqXHR, textStatus, errorThrown) {

        console.log('onFail(jqXHR, textStatus, errorThrown)');

        console.log(jqXHR);

        console.log(textStatus);

        console.log(errorThrown);

    },

    onAlways: function() {

        console.log('onAlways()');

    },

    onAjax: function(action, serialize) {

        console.log('onAjax(action, serialize)');

        console.log(action);

        console.log(serialize);

    }

	});*/





});



function populate_cat_tbl(){

	$.get('cat-table.php', {idtrf:'<?php echo $idtrf;?>', standardcodetitle:'<?php echo $standardcodetitle?>', protectioncategorytitle:'<?php echo $protectioncategorytitle;?>', dpicategorytitle:'<?php echo $dpicategorytitle;?>', pleaseselectstd:'<?php echo $pleaseselectstd;?>'}, function(data){

		$('#cat_table_cont').html(data);

		

		$('#example1').Tabledit({

			url: 'logic-edit-delete.php',

            autoFocus: true,

			columns: {

				identifier: [0, 'id'],

				editable: [[2, 'idprotectioncategory','<?php echo $idprotectioncategoryJson; ?>'], [3, 'iddpicategory','<?php echo $iddpicategoryJson; ?>']]

			},

            editButton: false,

			onDraw: function() {

				// console.log('onDraw()');

			},

			onSuccess: function(data, textStatus, jqXHR) {

				// console.log('onSuccess(data, textStatus, jqXHR)');

				// console.log(data);

				// console.log(textStatus);

				// console.log(jqXHR);

				$("#add").prop('disabled', false);

				populate_cat_tbl();



                /* HIGHLIGHT TR */

                let trID = "#"+data['id'];

                let defBGColor = $(trID).css("background-color");

                let defTxtColor = $(trID).css("color");



                setTimeout(function(){

                    $(trID).css({'background-color':'#228B22', 'color':'#F0F8FF'});

                    $(trID).fadeOut(300, function(){ $(trID).css({'background-color':defBGColor, 'color':defTxtColor}) }).fadeIn(100);

                } ,200);

			}

		});

	});

}



</script>

<style>



.table.user-select-none {

    -webkit-touch-callout: none;

    -webkit-user-select: none;

    -khtml-user-select: none;

    -moz-user-select: none;

    -ms-user-select: none;

    user-select: none;

}

</style>

</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);">CIMAC 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">

							<div class="card">

                                <div class="card-body">

                                    <div class="media">

							

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

                                    </div><!--end media-->

                                                                          

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

								

								

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

							<div id="accordion">

  <div class="card">

    <div class="card-2" id="headingThree">

      <h5 class="mb-0">

        <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">

          <?php echo $descriptionstep; ?>

        </button>

      </h5>

    </div>

    <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">

      <div class="card-body">



                  <div class="table-responsive">

                    <table class="table table-success mb-0">

                                            <thead>

                                            <tr>

												<th></th>

											    <th><?php echo $typearticletitle; ?></th>

                                                <th><?php echo $descriptiontitle; ?></th>

                                                <th><?php echo $modeltitle; ?></th>

                                                <th><?php echo $rangemeasuremintitle; ?></th>

												<th><?php echo $rangemeasuremaxtitle; ?></th>

												<th><?php echo $articlecharacteristictitle; ?></th>

												<th><?php echo $registeredmarktitle; ?></th>

 

                                            </tr>

                                            </thead>

                                            <tbody>

                                            <tr>

												<td><img src="uploadimages/<?php echo $sphotofilename; ?>" height="100" alt=""/></td>

                                                <td><span class="badge badge-soft-primary"><?php echo $sname_articletype; ?></span></td>

												<td><?php echo $sdescription; ?></td>

                                                <td><?php echo $smodel; ?></td>

                                                <td><?php echo $smeasuremin; ?></td>

												<td><?php echo $smeasuremax; ?></td>

                                                

												<td><span class="badge badge-soft-primary"><?php echo $sname_articlecharacteristic; ?></span></td>

												<td><?php echo $sregisteredmark; ?></td>



                                            </tr>

                                           

  

                                            </tbody>

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

										<br>



					  <a href="trfdetails.php?idtrf=<?php echo $idtrf; ?>"><button type="button" class="btn btn-success waves-effect waves-light"><?php echo $edittitle; ?></button> </a> 

					 </div><!--end /tableresponsive-->

		  

                                </div>

      

    </div>

  </div>

</div>

							

							

							

							<div class="progress mb-4">

                              <div class="progress-bar" role="progressbar" style="width: 50%;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">50%</div>

                          </div>

							

                           <!-- <div class="card">

                              <div class="card-body">

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

                                    <h5><?php echo $standardlink; ?></h5>

                                <p class="text-muted mb-3"><?php echo $standardlink_help; ?></p> 

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

								

								

						      <?php

$wa_startindex = 0;

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

  $wa_startindex = $stdcheck->Index;

?>

								

							

								

					

								      <?php

  $stdcheck->moveNext();

}

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

unset($wa_startindex);

unset($wa_repeatcount);

?>

				

								  	

                              

							  </form>

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

                       

							

							

                       

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

						<?php

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

$standardselectedlist->setQuery("SELECT * FROM trfstandards LEFT JOIN standards ON trfstandards.idstandards=standards.idstandards WHERE trfstandards.idtrfdetails='$idtrf'");

$standardselectedlist->execute();?>

						



		

						

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

                            <div class="card">

                                <div class="card-body">

    

                                    <h5><?php echo $assignedstd; ?></h4>

                                    <p class="text-muted mb-3">

                                        <?php echo $assignedstd_help; ?>.

                                    </p>

    

                                    <div class="table-responsive">

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



										<div id="cat_table_cont"></div>

										 <!--<table class="table table-striped mb-0" id="example1" style="border:1px solide red">

    	<tr><th style="display:none;">id</th><th><?php echo $standardcodetitle; ?></th><th><?php echo $protectioncategorytitle; ?></th><th><?php echo $dpicategorytitle; ?></th></tr>

    	<?php while($rowquery = mysqli_fetch_assoc($row1)) {?>

    	<tr>

    		<td style="display:none;"><?php echo $rowquery['idtrfstandards'];?></td>



    		<td><?php echo $rowquery['standardcode']; ?></td>

            <td><?php if(isset($rowquery['name_protectioncategory'])){echo $rowquery['name_protectioncategory'];} else { ?><p style="color:red;"><?php echo $pleaseselectstd;} ?></p></td>

            <td><?php if(isset($rowquery['value_dpicategory'])){echo $rowquery['value_dpicategory'];} else { echo $pleaseselectstd;} ?></td>



    	</tr>

    	<?php } ?>

        </table>-->

										

										

										<?php include('include/virusquerycheck.php'); ?><br>



										<?php if (($articletype==1) || (!empty($virusstep))) { ?>

                                            <a href="additionalinfo.php?idtrf=<?php echo $idtrf; ?>&codestep=<?php echo '3'; ?>"><button type="button" class="btn btn-success waves-effect waves-light"><?php echo $nextsteptitle; ?></button> </a> 

										<?php } else { ?>

											<a href="addrequirements.php?idtrf=<?php echo $idtrf; ?>&codestep=<?php echo '3'; ?>"><button type="button" class="btn btn-success waves-effect waves-light"><?php echo $nextsteptitle; ?></button> </a> 

										<?php } ?>

										<button type="button" class="btn btn-dark waves-effect waves-light" onclick="history.back()"><?php echo $backstep; ?></button> 

<!--end /table-->

                                    </div><!--end /tableresponsive-->

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

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

                      </div>

						

              </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>



        <script>

            function getSelectOptions(standardId, selectName, currentValue){

                let thisOptions = [];

                let totalOptionsCount = 0;



                if(selectName == 'iddpicategory'){

                    thisOptions = JSON.parse('<?php echo $iddpicategoryperStdJson;?>');         /* GET LIST OF dpi category PER STANDARD */

                }else if(selectName == 'idprotectioncategory'){

                    thisOptions = JSON.parse('<?php echo $idprotectioncategoryperStdJson;?>');  /* GET LIST OF protection category PER STANDARD */

                }



                totalOptionsCount = Object.keys(thisOptions[standardId]).length;



                $("[name='"+selectName+"']").empty(); /* CLEAR SELECT OPTIONS */

                $("[name='"+selectName+"']").append('<option value=\'\'><?php echo $pleaseselectstd;?></option>');  /* ADD EMPTY OPTION */



                Object.keys(thisOptions[standardId]).forEach(function(key) {

                    if(totalOptionsCount == 1){

                        /* IF SELECT HAS ONLY 1 OPTION, SET AS "SELECTED" */

                        currentValue = key;

                        $("[name='"+selectName+"']").empty(); /* REMOVE EMPTY OPTION */

                    }



                    /* POPULATE SELECT OPTIONS BASED ON STANDARD*/

                    if(currentValue == key){

                        $("[name='"+selectName+"']").append('<option value='+key+' selected=\'selected\'>'+thisOptions[standardId][key]+'</option>');

                    }else{

                        $("[name='"+selectName+"']").append('<option value='+key+'>'+thisOptions[standardId][key]+'</option>');

                    }

                });



                if(totalOptionsCount == 1){

                    /* TRIGGER ONCHANGE EVENT */

                    $("[name='"+selectName+"']").change();

                }

            }

        </script>

        

    </body>



</html>