<?php

	include "library.php";

	$cxn = start_code();
	
	
    $id = val( $_GET, "id" );
  

    page_header( "", $cxn );
    
    
	echo "<style> html, body {";
	echo "margin:0;";
	echo "padding:0;";
	echo "}";
	echo "</style>";
    
//	echo "<table width='100%' style='border-collapse: collapse;'><tr><td width='100%' style='line-height: 6px; background: #007500;'>&nbsp;</td></tr></table>";
 
//    echo "<table width='100%' style='border-collapse: collapse;'><tr><td width='100%' valign='top' style='font-family: Calibri; font-size: 20pt; color: #ffffff; background-color: #007500;'>&nbsp;&nbspMelbourne Paraplanning</td></tr></table>";


    echo "<br><br>";
    
//    echo blue( "&nbsp;&nbsp;Melbourne Paraplanning<br><br><br>" );

    if ($id == "")
    {
        echo red( "&nbsp;&nbsp;Parameter error, please contact Melbourne Paraplanning directly.<br><br>" );
    }
    else
    {
        $query = "SELECT * FROM quote WHERE id = ".$id;

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

        if (query_num_rows( $result ) == 0)
            echo red( "&nbsp;&nbsp;Error: Quote not found, please contact Melbourne Paraplanning directly.<br><br>" );
        else
        {
            $data = get_row( $result );
            
            if ($data['status'] == "accepted")
                echo black( "&nbsp;&nbsp;You have already accepted this quote.<br><br>" );
            else
            {
                $query2 = "UPDATE quote SET status = 'accepted' WHERE id = ".$id;
    
                $result2 = run_query( $query2, $cxn );
                
                echo black( "&nbsp;&nbsp;Thank you for accepting quote number ".$id." for clients ".$data['client_names']." for $".$data['amount_ex_gst']." plus GST.<br><br>" );

        		send_external( manager_email_address, "Quote ".$id." for clients ".$data['client_names']." accepted", "..", "..", $cxn, "live" );
            }
        }
    }

    echo "<br>";
    
    echo "<br>";
    
    echo show_home_link();
    

    echo "<br>";
    echo "<br>";
    echo "<br>";

?>