How to add the pricing plan to another page on your site in WebJobs
Problem: The dynamic list of prices for posting jobs is only viewable to employers who are logged in.
Solution:
In your new page in engine/pages/new_page.php , make sure the following is included near the top:
require_once ’smartway/lib/table.lib’;
Then add the following two classes, which originate in the engine/pages/employer_home.php file:
class employer_job_plans_table_renderer extends sql_table_renderer{
function employer_job_plans_table_renderer(){
$application =& application();
parent::sql_table_renderer();
$this->table_class = ’seeker_search_res_wide’;
$this->header_class = $this->footer_class = ’seeker_search_ends_wide’;
$this->row_1_class = ’seeker_search_row1_wide’;
$this->row_2_class = ’seeker_search_row2_wide’;
$this->header_navbar_class = ‘narrow_navbar_top’;
$this->footer_navbar_class = ‘narrow_navbar_bottom’;
}function handle_duration($f){
$application =& application();
return $f[’duration’] .’ ‘.$application->text(’days’);
}
function handle_quantity($f){
$application =& application();
return $f[’quantity’];
}function handle_price($f){
$application =& application();
if(ceil($f[’price’])==0){
return $application->text(’Free’);
}
else{
return $application->config(’currency_symbol’) . util_funcs::number_format($f[’price’], 2);
}
}
function handle_type($f){
$application =& application();
return $application->text($f[’type’]);
}
function handle_controls($row)
{
$application =& application();
$text = $application->text();
$service = $application->input(’service’);
$PHP_SELF = $application->server(’PHP_SELF’);if($row[’type’]==’job_postings’){
if(ceil($row[’price’]) != 0){
$output = ” <a href=’$PHP_SELF?page=post_single_job1&job_post_type={$row[’name’]}’>\n{$text[’purchase’]}</a> \n ” ;
}
else{ // User is getting a free plan
$output = ” <a href=’$PHP_SELF?page=employer_home&action=free_plan&plan_id={$row[’id’]}’>\n{$text[’purchase’]}</a> \n ” ;
}
}
else{ // Resume View
if(ceil($row[’price’])!=0){
$output = ” <a href=’$PHP_SELF?page=resume_searches&searches_type={$row[’name’]}’>\n {$text[’purchase’]}</a> \n ” ;
}
else{ // User is getting a free plan
$output = ” <a href=’$PHP_SELF?page=employer_home&action=free_plan&plan_id={$row[’id’]}’>\n{$text[’purchase’]}</a> \n ” ;
}
}
return $output;
} // handle_controls
} // employer_job_plans_table_rendererclass employer_combo_plans_table_renderer extends sql_table_renderer{
function employer_combo_plans_table_renderer(){
$application =& application();
parent::sql_table_renderer();
$this->table_class = ’seeker_search_res_wide’;
$this->header_class = $this->footer_class = ’seeker_search_ends_wide’;
$this->row_1_class = ’seeker_search_row1_wide’;
$this->row_2_class = ’seeker_search_row2_wide’;
$this->header_navbar_class = ‘narrow_navbar_top’;
$this->footer_navbar_class = ‘narrow_navbar_bottom’;
}function handle_price($f){
$application =& application();
if(ceil($f[’price’])==0){
return $application->text(’Free’);
}
else{
return $application->config(’currency_symbol’) . util_funcs::number_format($f[’price’], 2);
}
}function handle_posting_plan($f){
return $f[’posting_plan_name’];
}function handle_resume_plan($f){
return $f[’resume_plan_name’];
}function handle_name($f){
return $f[’name’];
}function handle_controls($row)
{
$application =& application();
$text = $application->text();
$service = $application->input(’service’);
$PHP_SELF = $application->server(’PHP_SELF’);if(ceil($row[’price’])!=0){
return ” <a href=’$PHP_SELF?page=combo_package&plan_id={$row[’id’]}’>\n {$text[’purchase’]}</a> \n ” ;
}
else{ // User is getting a free plan
return ” <a href=’$PHP_SELF?page=employer_home&action=free_combo&plan_id={$row[’id’]}’>\n{$text[’purchase’]}</a> \n ” ;
}
} // handle_controls
} // class employer_combo_plans_table_renderer
Next, in the class that displays your page,
class new_page extends _page
add the following above the parent::default_action(); line
$plans_table_renderer =& new employer_job_plans_table_renderer();
$application->output[’plan_info’] = $plans_table_renderer->make_table_from_query(”SELECT id, name, duration, quantity, type, price FROM jb_billing WHERE type = ‘resume_views’ OR type = ‘job_postings’ ORDER BY type, price DESC “,array(’name’, ‘quantity’, ‘duration’, ‘type’, ‘price’, ‘controls’), array(’controls’=>’100px’));$combo_table_renderer =& new employer_combo_plans_table_renderer();
$application->output[’combo_plans’] = $combo_table_renderer->make_table_from_query(’SELECT c.id, c.name, c.price, c.posting_plan, c.resume_plan, b_r.name AS resume_plan_name, b_p.name AS posting_plan_name FROM `jb_billing_combo` AS c INNER JOIN `jb_billing` AS b_r ON (c.resume_plan = b_r.id) INNER JOIN `jb_billing` AS b_p ON (c.posting_plan = b_p.id)’,
array(’name’, ‘posting_plan’, ‘resume_plan’, ‘price’, ‘controls’));
Finally, in templates/new_page.html, add the following code where you want the pricing plan table to appear.
For the regular pricing plan:
<?php echo “<p>”.$text[’plan_info’].”</p>”;
echo $output[’plan_info’]; ?>
For the combo plans:
<?php if(isset($output[’combo_plans’])){ ?>
<?php echo $text[’combo_image’]; ?> Â<?php
echo “”.$text[’combo_info’].”";
echo $output[’combo_plans’];
?>
April 7th, 2009 at 1:52 am
Hi,
I’m a bit lost with second and third parts of this instruction. I’m not sure I quite understand where you say the following:
“Next, in the class that displays your page,
class new_page extends _page
add the following above the parent::default_action(); line”
Where can I find this class that displays my page? And, where is the “parent::default_action(); line” found that you mention above?
Sorry, I’m just perhaps green at this. I appreciate the helpful hints you’ve provided on this site, and I’ve been following them to work on my Webjobs script.
Please help.
Thanks.
April 8th, 2009 at 2:19 pm
Oh, sorry - you need to correctly make a new page first. The “new_page” class goes into the new page when you create it. There used to be a pdf on WebScribble’s Knowledgebase, but it looks like they have removed it. I will email the pdf to you.