RedJumpsuit

jobberBase custom development and support

 

Code School

Add Salary Range When Posting Jobs

job-post

job-details

LET’S BEGIN!

on your jobberbase “jobs” table, run this sql script

ALTER TABLE `jobs` ADD `salaryfrom` INT( 4 ) NULL ,
ADD `salaryto` INT( 4 ) NULL ,
ADD `salaryper` VARCHAR( 10 ) NULL

in /_includes/translations.ini, under [publish] add

salary_range = "Salary Range"
currency = "USD"
currency_warning = "Please use numbers only"

on /_templates/publish-write.tpl, under

<!-- #textile-suggestions -->
</td>
</tr>

add beneath it:

<!-- Salary Range -->
<tr>
	<td class="publish-label" valign="top">{$translations.publish.salary_range}:</td>
	<td>{$translations.publish.currency} <input type="text" name="salaryfrom" id="salaryfrom" tabindex="5" size="5" maxlength="10" value="{if $job.salaryfrom}{$job.salaryfrom}{else}{$smarty.post.salaryfrom}{/if}" /> to
	<input type="text" name="salaryto" id="salaryto" tabindex="6" size="5" maxlength="10" value="{if $job.salaryto}{$job.salaryto}{else}{$smarty.post.salaryto}{/if}" /> per
	<select name="salaryper" tabindex="7">
		<option value=""></option>
		<option value="Hour"{if $job.salaryper == "Hour" || $smarty.post.salaryper == "Hour"} selected{/if}>Hour</option>
		<option value="Week"{if $job.salaryper == "Week" || $smarty.post.salaryper == "Week"} selected{/if}>Week</option>
		<option value="Month"{if $job.salaryper == "Month" || $smarty.post.salaryper == "Month"} selected{/if}>Month</option>
		<option value="Year"{if $job.salaryper == "Year" || $smarty.post.salaryper == "Year"} selected{/if}>Year</option>
	</select><br />
	<div class="suggestion">
	{$translations.publish.currency_warning}
	</div>
	</td>
</tr>
<!-- /Salary Range -->

on /_includes/class.Job.php, add on the vars list

var $mSalaryFrom = false;
var $mSalaryTo = false;
var $mSalaryPer = false;

under the first SELECT statement after this line:

a.is_temp AS is_temp, a.is_active AS is_active, a.spotlight AS spotlight,

add this line:

 a.salaryfrom AS salaryfrom, a.salaryto AS salaryto, a.salaryper AS salaryper,

on the $this-> list after the SELECT statement, add after $this->mIsSpotlight = $row[‘spotlight’];

$this->mSalaryFrom = $row['salaryfrom'];
$this->mSalaryTo = $row['salaryto'];
$this->mSalaryPer = $row['salaryper'];

add on public function GetInfo() and public function GetBasicInfo() and public function GetBasicInfoAdmin(), before the line ‘is_spotlight’ => $this->mIsSpotlight);

'salaryfrom' => $this->mSalaryFrom,
'salaryto' => $this->mSalaryTo,
'salaryper' => $this->mSalaryPer,

on public function Create($params), before the INSERT INTO jobs block:

if (($params['salaryfrom']) == '')
{
	$params['salaryfrom'] = 0;
}
 
if (($params['salaryto']) == '')
{
	$params['salaryto'] = 0;
}
 
if (($params['salaryper']) == '')
{
	$params['salaryper'] = "Hour";
}

then add after INSERT INTO jobs (type_id, category_id, title, description, company, city_id, url, apply,:

salaryfrom, salaryto, salaryper,

and on the same block, add before the line NOW(), 1, 0, 0, “‘ . $this->GenerateAuthCode() . ‘”,

' . $params['salaryfrom'] . ',
' . $params['salaryto'] . ',
"' . $params['salaryper'] . '",

to allow editing, on public function Edit($params), before the UPDATE jobs SET block:

if (($params['salaryfrom']) == '')
{
	$params['salaryfrom'] = 0;
}
 
if (($params['salaryto']) == '')
{
	$params['salaryto'] = 0;
}
 
if (($params['salaryper']) == '')
{
	$params['salaryper'] = "Hour";
}

then add after UPDATE jobs SET after the apply = “‘ . $params[‘apply’] . ‘”,:

salaryfrom = ' . $params['salaryfrom'] . ',
salaryto = ' . $params['salaryto'] . ',
salaryper = "' . $params['salaryper'] . '",

now on page_write.php on the root folder, find the blocks (there are 2) which starts with $data = array( and add the following before the line ‘apply_online’ => $apply_online);

'salaryfrom' => $salaryfrom,
'salaryto' => $salaryto,
'salaryper' => $salaryper,

second to the last, on /_templates/job-details.tpl, after the line {$job.description}, under it add:

{if ($job.salaryfrom != "" && $job.salaryto != "") && ($job.salaryfrom > 0 && $job.salaryto > 0)}
<p><br />
{$translations.publish.salary_range} <strong>{$translations.publish.currency} {$job.salaryfrom}</strong> to <strong>{$job.salaryto}</strong> per <strong>{$job.salaryper}</strong>
</p>
{/if}

I added the if statement so that it wouldn’t display when the salary range is not indicated.

And finally, if you need help adding this to your jobberBase website, feel free to contact me!

UPDATE!!!
To enable editing job ads on your admin panel, see this follow-up tutorial:

http://www.redjumpsuit.net/2009/06/05/editing-salary-range-in-admin/

27 Comments

Code School

  1. Redjumpsuit,
    I’m going to implement your “add a salary field” to my customized V1.5 of Jobberbase but have 2 questions before I start.

    My SQL skills are very low so before I run the below command

    ALTER TABLE `jobs` ADD `salaryfrom` INT( 4 ) NULL ,
    ADD `salaryto` INT( 4 ) NULL ,
    ADD `salaryper` VARCHAR( 10 ) NULL

    1. If I screwup the process with SQL jobs table (how) is it reversible? I’m looking how to back up the SQL jobs table but am not sure. (I backup the all the site files (tpl, php, etc..) but databases are my weak spot.

    2. As you know I’ve customized V1.5. I can handle tweaking the .tpl .php files but to be sure, there doesn’t seem any special tweaking to make it work with V1.5, correct?

    Thank you.
    TokyoJ

  2. hi, you should backup your “jobs” table first (can do this on your phpmyadmin) so that if something goes wrong you can just restore from your backup. but it shouldn’t mess anything up.

    not sure about v1.5, you should check whether the files affected are the same in v1.6, i’ve only tested it on the current version.

  3. Also, to enable the later editing of salary info via the e-mail link find “public function Edit” in class.job.php and add to params under:
    apply = “‘ . $params[‘apply’] . ‘”,

    add:

    salaryfrom = ‘ . $params[‘salaryfrom’] . ‘,
    salaryto = ‘ . $params[‘salaryto’] . ‘,
    salaryper = “‘ . $params[‘salaryper’] . ‘”,

    Next…

    I find that when no salary info is entered by job poster the blank page shows up right after submitting the ad, and the ad is not submitted -before step 2.
    To resolve this I added default zeroes in the salaryfrom and salaryto fields and also, to avoid having (after applying zeroes) “Salary range USD 0 to 0 per” showing on the ads I removed the first blank select option, so now when no salary info is entered the ad will say “Salary range USD 0 to 0 per week”. This might remind the poster to go back and update salary info via email link :).
    This was done by adding the following to translations.ini right under [publish] :

    salaryfrom = “0”
    salaryto = “0”

    and in publish-write.tpl the I replaced the code {$smarty.post.salaryfrom}

    with:

    {$translations.publish.salaryfrom}

    and
    {$smarty.post.salaryto}

    with:
    {$translations.publish.salaryto}

    Also on the same page below I removed the blank option

    Still have to make salary data to show in the e-mails.

    Also is there a reason why not to do this (what does $smarty.post.salaryfrom and $smarty.post.salaryto that I replaced normally do?

  4. hi, i’m updating the tutorial to allow the editing :)

    “$smarty.post.salaryfrom” and “$smarty.post.salaryto” is the form post value. if you change this, it will not capture the actual value of the form when you edit it, so best to leave it and modify the class instead.

  5. Hello love your work. It’s truly easy to follow. But in case of this tutorial I was wondering if it is possible to edit the $ mark to a

  6. you can change it from the translations.ini file

  7. Hi redjump, i had updated salary , everything works fine.
    but in the admin ,if i try to edit the post, the whole block was empty, no detail will be showed in the admin edit page. do you know why?

    thanks

  8. oh, my problem solved :)
    coz i didnt replace assign_by_ref by assign in /admin/page_edit_post.php
    sorry about this :)

  9. hi, you can change this on the translations.ini file if you followed the tutorial.

  10. Hi there,

    Really love your scripts; have been able to add some nice little touches to my site. Ok, so here’s an idea; what if I wanted to add a tick box in addition to the salary from and to ranges that allows th poster to simly list ‘competitive’ as the salary?

    Thanks,

    Paul

  11. you should be able to easily add this by following the tutorial, adding new field, adding it to the array, etc.

  12. All the instructions worked flawlessly, until I got to the last one…

    second to the last, on /_includes/job-details.tpl, after the line {$job.description}, under it add:

    I couldn’t find the file. There is no job-details.tpl in the root _includes folder, at least not in my 1.7 install.

  13. hi, all tpl files are in the /_templates folder. let me update the tutorial!

  14. How to modify the script so that Salary is included in all mails sent from system and rss feeds too?

  15. Ok got it for the feedpart which needs a line:

    $properties[‘description’] .= ‘Salary: Rs. ‘. $job[‘salaryfrom’] . ‘to’ . $job[‘salaryto’] . ‘per ‘. $job[‘salaryper’] . ”; after the line:

    $properties[‘description’] .= ‘Description:‘ . $job[‘description’] . ”;

    in class.Feed.php

    Still looking for Email Inclusion.

  16. Awesome tutorial even I got it right first time.. pheww..

  17. I’ve installed the mod but just noticed two things

    In the admin the range entered is not displayed in the fields

    In the preview the fields aren’t displayed

    please help..

  18. hi, at the end of this post (before the donate button) there is a follow up tutorial for the admin panel, make sure you follow it. to display the details on the admin preview, just follow the code you added on the file /_templates/job-details.tpl in this tutorial. hope this helps!

  19. Hi I have added the Salary mods. When previewing a new job the salary from field displays 2000 and the salary to field displays 1, also the Salary per field show 0 so its displays as “2009 to 1 per 0” i can’t figure out why. Can you help?

  20. hi, are you having problems in the admin or the whole mod in general?

  21. The admin ranges displayed what was set in the db. So i gues admin works.. So must be a prob somowhere within Posting.. I’ve checked this mod three times to isolate this problem… I’m Stuck.

  22. is that mod compatible with jobber 1.8? or may be 1.9 ?

  23. this is for 1.8, you can try it for 1.9 but no guarantees that lines are the same as mentioned in the tutorial

  24. I’m trying to get it working on 1.9. But the only problem right now seems to be that it doens’t get right in de database… i always get:

    Salary Euro 2011 to 1 per 0

    Has someone tried this for 1.9?

    Nice hack though…

  25. Hi admin
    I tried your script on jobber 1.9 , it worked partially well ………..actually i am not able to insert the record in database but if i insert a record through backend (means manually in database) it shows up in USD textbox.

    Can u guide me where i went wrong.

Trackbacks

  1. RedJumpsuit (Non-Apparatus) » Blog Archive » Editing Salary Range in Admin (Part 2)
  2. Editing Salary Range in Admin | RedJumpsuit

Leave a Response