<?php

	include "library.php";

	$cxn = start_code();

    exit_if_search_bot();

    exit_if_session_expired( $cxn );



    $submit = val( $_GET, "submit" );
    
	$request_id = val( $_GET, "requestid" );


	$date_today = date( "Y-m-d H:i:s" );


			/* start page */

	page_header( "", $cxn );


		/* check parameters */

	crash_if_missing( $request_id, "request id missing in submit_request_go", $cxn );



	if ($submit == "no")
		echo black( "<br>Request submission cancelled<br><br><br>" );
	else
	{
	    $query = "SELECT * FROM request WHERE id = ".$request_id;

    	$result = run_query( $query, $cxn );

		$data = get_row( $result );
	    
		$query2 = "INSERT INTO task (request_id, date_received, task_type, practice, client_names, status, date_created, date_modified) VALUES ( ".$request_id.", '".$date_today."', '".$data['document_type']."', '".$data['practice']."', '".$data['client_names']."', 'received', '".$date_today."', '".$date_today."')";

		$result2 = run_query( $query2, $cxn );

        send_email( "Melbourne Paraplanning", "mark.mcilroy@outlook.com", "mark.mcilroy@outlook.com", "Melbourne Paraplanning", "mark.mcilroy@outlook.com", "New ".$data['document_type']." request from ".$data['practice']." for clients ".$data['client_names'], "..", "..", $cxn, "live" );

		echo black( "<br>Request submitted successfully<br><br><br>" );
	}
	
    echo show_home_link();
    
    
    echo "</body>";
    echo "</html>";
    
?>