<?php
session_start();
require_once('includes/functions.php');
$show_form=1;$mess="";$error=null;
# check for existance of prior started job ad
if (isset($_SESSION['job_ad_id_for_job_board'])) {
$id = $_SESSION['job_ad_id_for_job_board'];
} else {
header('Location: post.php');
}
# validate id is still in need of previewing, then pull data
if ($id && !isset($_POST['submit'])) {
$select = "SELECT * FROM ".TB_JOBS." WHERE form_id='".clean($id)."' AND preview IS NOT NULL AND completed IS NULL";
$result = mysql_query($select);
$count = mysql_num_rows($result);
# check to verify it was already previewed, but not yet completed
if($count == 1) {
$row = mysql_fetch_assoc($result);
} else {
$error.= 'That job ID does not exist';
header('Location: post.php');
}
}
# bypass this page if it is a free ad
$job_price = trim(str_replace('$', '', meta('job_price')));
if ($job_price == '0' || $job_price == '' ) {
$job_price = 'FREE';
}
if ($job_price == 'FREE') {
header('Location: '. $script_location.'?action=success&id='.$id);
exit;
}
# when someone pushes the button to approve their job ad
if (isset($_POST["submit"])) {
# start the paypal transaction
require_once('paypal/paypal.class.php');
$paypal = new paypal_class;
$paypal->add_field('business', meta('paypal_email'));
$paypal->add_field('return', $script_location.'?action=success&id='.$id);
$paypal->add_field('cancel_return', $script_location.'?action=cancel&id='.$id);
$paypal->add_field('notify_url', $script_location.'?action=ipn&id='.$id);
$paypal->add_field('item_name_1', meta('paypal_desc'));
$paypal->add_field('amount_1', clean($_POST['total_price']));
$paypal->add_field('item_number_1', meta('paypal_item_id'));
$paypal->add_field('quantity_1', '1');
$paypal->add_field('custom', $_SERVER['REMOTE_ADDR']);
$paypal->add_field('upload', 1);
$paypal->add_field('cmd', '_cart');
$paypal->add_field('txn_type', 'cart');
$paypal->add_field('num_cart_items', 1);
$paypal->add_field('payment_gross', clean($_POST['total_price']));
$paypal->add_field('currency_code', meta('paypal_currency'));
$paypal->submit_paypal_post(); # submit purchase request to paypal
exit;
}
# get total payment price based on selections
$total_amount = trim(str_replace('$', '', meta('job_price')));
if ($row['highlight'] == 'Y') {
$total_amount = $total_amount + trim(str_replace('$', '', meta('highlight_price')));
}
?>
<?php get_template('header', 'Purchase Your Ad'); ?>
<div id="main">
<!-- main content data -->
<h3><span>Step 3:</span> Confirm Your Purchase</h3>
<p>You are about to purchase a job ad for <b>$<?php echo $total_amount; ?></b>, which will run for <b><?php echo meta('job_duration_days'); ?></b> days.</p>
<table class="datalist" >
<tr><th>Description</th><th style="width:55px;" >Price</th></tr>
<tr><td class="label" >Job Ad</td><td>$<?php echo trim(str_replace('$', '', meta('job_price'))); ?></td></tr>
<?php if($row['highlight'] == 'Y') {?>
<tr><td class="label" >Highlighting</td><td>$<?php echo trim(str_replace('$', '', meta('highlight_price'))); ?></td></tr>
<?php } ?>
<tr class="total" ><td class="label" >TOTAL</td><td>$<?php echo $total_amount; ?></td></tr>
</table>
<p><img src="assets/images/paypal.gif" alt="We Use PayPal" /></p>
<form action="<?php echo get_filename(); ?>" method="post" enctype="multipart/form-data" >
<input type="hidden" name="total_price" value="<?php echo $total_amount; ?>" />
<p class="submitline"><span><input type="submit" class="submit" name="submit" id="submit" value="Purchase this ad" /></span></p>
</form>
</div>
<div id="sidebar">
<div class="inner">
<h2>Hint</h2>
Your job will be made active as soon as the purchase transaction is complete.
</div>
</div>
<?php get_template('footer'); ?>