<?
include('_functions2.php');
$JSON=json_decode($_POST['JSON'],true);

// printRecords( $JSON );

$i = 0;
foreach($JSON as $item) {

	$dex = $item['dex'];
	$guid = $item['guid'];
	$used = $item['used'];
	$del = $item['del'];
	$undel = $item['undel'];

	echo "\n";
	echo "____________________\n";
	echo " dex: $dex \n ";
	echo " guid: $guid \n ";
	echo " used: $used \n ";
	echo " del: $del \n ";
	echo "\n";


	if ( $undel ) {

		if ( !$del ) {
			undeleteCertificate( $guid );
			echo " do: undelete";
		}


	} else {

		if ( $del ) {
			deleteCertificate( $guid );
			echo " do: delete";
		} else {
			toggleCertificate( $guid , $used );
			echo " do: toggle";
		}

	}









	$i++;

}
?>