<?php

	include "library.php";

	$cxn = start_code();
	
    $account_id = val( $_SESSION, "account_id" );
    
	
			/* get variables */

	$listing_id = val( $_GET, "listing_id" );

	$show = val( $_GET, "show" );


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


	page_header( "Listing Contact Details", $cxn );

/*
    if ($show == "no")
    {
        echo "<br>Contact details display cancelled.<br><br><br>";
        
        echo show_home_link();
    }
    else
    {
		$show_continue = false;

    	if ($account_id != "")
    	{
    		$query = "SELECT * FROM contact_details_shown WHERE account_id = ".$account_id." AND listing_id = ".$listing_id;
    
    		$result = run_query( $query, $cxn );
    
            if (query_num_rows( $result ) >= 1)
    			$show_continue = true;
    	}

        if (! $show_continue)
        {
    		$query2 = "SELECT * FROM account WHERE id = ".$account_id;
        
    		$result2 = run_query( $query2, $cxn );
    	
        	$data2 = get_row( $result2 );
    
            if ($data2['credits_balance'] >= 1)
            {
                $query3 = "UPDATE account SET credits_balance = credits_balance - 1 WHERE id = ".$account_id;
                
        		$result3 = run_query( $query3, $cxn );

                
    		    $query5 = "INSERT INTO contact_details_shown (account_id, listing_id, date_shown) VALUES (".$account_id.", '".$listing_id."', '".$date_shown."' )";

        		$result5 = run_query( $query5, $cxn );

                echo "<br>1 cedit was deducted to view this business' contact details.<br><br>";
                
                echo "Your credits balance is: ".($data2['credits_balance']-1)."<br><br><br>";

    			$show_continue = true;
            }
        }
        
        if (! $show_continue)
        {
            echo "<br>You must purchase credits to see the contact details for this business.<br><br><br>";
            
            echo show_link( "Buy credits", "buy_credits.php" );
            
            exit();
        }
        
*/
        $query4 = "SELECT * FROM listing WHERE id = ".$listing_id;
                
		$result4 = run_query( $query4, $cxn );

    	$data4 = get_row( $result4 );
        


		echo "<table>";

		echo "<tr><td valign='top'><span class='dprompt'>Listing ID</span></td><td align='left'><span class='gwatermark''>".convert_to_html( $data4['id'] )."</span></td></tr>";

		show_field( "Headline", $data4['headline_title'] );

		show_field( "Short Description", $data4['short_description'] );
		
		show_field( "Contact details", $data4['contact_details'] );
		
		echo "</table>";
		
		
//    }

    
?>