

<?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($_POST["tokensignatureon"])) {

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

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

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

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

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

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

	$sndrpt=$_POST["sndrpt"]; } else { $sndrpt="N"; }



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

	$code=$_GET["codestep"]; 



  $InsertQuery = new WA_MySQLi_Query($cmctrfdb);

  $InsertQuery->Action = "insert";

  $InsertQuery->Table = "wheretrfstep";

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

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

  $InsertQuery->saveInSession("");

  $InsertQuery->execute();

  $InsertGoTo = "";



  $InsertQuery->redirect($InsertGoTo);

	}



?>

<?php

$tokenid=$user->present()->signaturecode;



if ($tokenid!=$tokensignatureon) {

	header("Location: declaration.php?idtrf=$idtrf&tokenresult=ko");

	

} else {





// update trf details`

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

  if ($sndrpt=='N') {

  $UpdateQuery = new WA_MySQLi_Query($cmctrfdb);

  $UpdateQuery->Action = "update";

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

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

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

  $UpdateQuery->execute();

  $UpdateGoTo = "";

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

  $UpdateQuery->redirect($UpdateGoTo);

      

      } else {



  $UpdateQuery = new WA_MySQLi_Query($cmctrfdb);

  $UpdateQuery->Action = "update";

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

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

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

  $UpdateQuery->execute();

  $UpdateGoTo = "";

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

  $UpdateQuery->redirect($UpdateGoTo);   

      

      

  }

}





?>



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

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

$appformn=$trfnumberfinal->getColumnVal("trfnumber");

?>

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

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

$chemicalagentlist->setQuery("SELECT * FROM chemicalagent ORDER BY chemicalagent.name_chemicalagent");

$chemicalagentlist->execute();

?>







<style>

#loading_spinner { display:none; }

</style>

</head>



    <body>

<img id="loading_spinner" src="loading-spinner.gif">



<div class="my_update_panel"></div>

         </body>

	<script>	

        $('#loading_spinner').show();



var post_data = "my_variable="+my_variable;

$.ajax({

    url: 'ajax/my_php_page.php',

    type: 'POST',

    data: post_data,

    dataType: 'html',

    success: function(data) {

        $('.my_update_panel').html(data);

//Moved the hide event so it waits to run until the prior event completes

//It hide the spinner immediately, without waiting, until I moved it here

        $('#loading_spinner').hide();

    },

    error: function() {

        alert("Something went wrong!");

    }

});		</script>			

</html>