<?php

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

<?php

// pickup the get variable

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

  $idtrf = $_POST["idtrf"];

}

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

  $idtrf = $_GET["idtrf"];

}

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

  $issuebycimac = $_GET["issuebycimac"];

}

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

  $manufnamevalue = $_POST["manufnamevalue"];

}

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

  $manufform = $_POST["manufform"];

} else {

  $manufform = "N";

}



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

  $code = $_GET["codestep"];

}



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

  $idauditdpi = $_GET["idauditdpi"];

}

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

  $idauditdpi = $_POST["idauditdpi"];

}



?>



<?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");

$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 ($manufform == "Y") {





  $InsertQuery = new WA_MySQLi_Query($cmctrfdb);

  $InsertQuery->Action = "insert";

  $InsertQuery->Table = "auditmanufacturer";

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

  $InsertQuery->bindColumn("nameauditmanufacturer", "s", "$manufnamevalue", "WA_DEFAULT");

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

  $InsertQuery->saveInSession("");

  $InsertQuery->execute();

  $InsertGoTo = "";



  $InsertQuery->redirect($InsertGoTo);

}

?>

<?php

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

$manufactlist->setQuery("SELECT * FROM auditmanufacturer WHERE auditmanufacturer.idauditdpi='$idauditdpi'");

$manufactlist->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>

  <!-- upload image script -->





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



</head>



<body>



  <div class="card">

    <div class="card">

      <div class="card-body">

        <h4 class="mt-0 header-title"><?php echo $manufacturernameaudit; ?> - <?php echo $dpireportnumbertitle; ?> <?php echo $idtrf; ?></h4>

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

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

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





          <div class="form-group">

            <label for="manufnamevalue" class="col-form-label"><?php echo $manufnametitle; ?> - (Max 50 caratteri / chars)</label>

            <input class="form-control" type="text" value="" id="manufnamevalue" name="manufnamevalue" maxlength="50">

          </div>







          <input type="hidden" name="manufform" id="manufform" value="Y">

          <input type="hidden" name="idtrf" id="idtrf" value="<?php echo ($trfnumberfinal->getColumnVal("idtrfdetails")); ?>">



          <br><br>

          <input type="button" onclick="formSubmit()" class="btn btn-gradient-success waves-effect waves-light" value="<?php echo $addtitle; ?>">



      </div>

      </form>



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

  </div>



  <!-- section file already uploaded -->



  <div class="card">

    <div class="card-body">

      <h4 class="mt-0 header-title"><?php echo $manufnametitleselected; ?></h4>







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

        <thead>

          <tr>

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



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

          </tr>

        </thead>

        <tbody>

          <?php

          $wa_startindex = 0;

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

            $wa_startindex = $manufactlist->Index;

          ?>

            <tr>

              <td><?php echo ($manufactlist->getColumnVal("nameauditmanufacturer")); ?></td>



              <td>



                <a href="deleteproducer.php?idtrf=<?php echo $idtrf; ?>&idauditdpi=<?php echo $idauditdpi; ?>&idauditmanufacturer=<?php echo ($manufactlist->getColumnVal("idauditmanufacturer")); ?>"><i class="fas fa-trash-alt text-danger font-16"></i></a>

              </td>

            </tr>

          <?php

            $manufactlist->moveNext();

          }

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

          unset($wa_startindex);

          unset($wa_repeatcount);

          ?>

        </tbody>

      </table><br>



      <button onclick="self.close()" type="button" class="btn btn-success waves-effect waves-light"><?php echo $closewindow; ?></button>





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





  </div>









  <!-- end of page -->





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