Apply to job

In this section, you will create a page that allows registered users see complete details regarding a job. This is the job_detail page and it should display data regarding the actual job and the company that posted it.

To retrieve the data, you will use a filtered recordset that will retrieve only information about the job whose identifier has been passed through the id_job URL parameter. In the same recordset you will retrieve information from the companies table, in order to display the job and the company that posted it. All data will be displayed in a dynamic table, and a button will allow the user apply for the job.

To create this page, follow the next steps:

  1. Open the user/job_detail page in Dreamweaver.
  2. The first thing to do is create the filtered recordset. To open the new recordset dialog box, click on the Plus (+) button of the Bindings tab, and select the Recordset (Query) option from the pop-up menu. If the Bindings tab is not visible, open it from Window -> Bindings.
  3. The recordset to create will retrieve data from several tables that are related to the job_job table (e.g. the domains, locations or company description tables). To build the query in a visual and intuitive way, you will use MX Query Builder. To start it, click on the QuB3 button in the recordset dialog box. The Dreamweaver MX Query Builder user interface will open. It provides options for re-using already created (and saved to the MX Query Builder repository) queries.

  4. To create a new query, click on the New Query button. In the dialog box that appears, enter a name for the query, and click OK.
  5. In the MX Query Builder interface that is loaded, you can visually add tables, columns and relations. To define the tables the query will retrieve data from, click on their names in the Tables area (on the left side of your screen). Check the following tables: company_com, domain_dom, job_job, location_loc.


                            
  6. Next you must define the relations between tables. To define a relation and also generate the JOIN code, simply drag and drop the corresponding field one on top of the other. Link the tables accordingly to their foreign keys in the job_job table. The relations are visually displayed as arrows:

  7. The next step is to decide on the columns to retrieve from these tables. To add a column to the query, click on the checkbox in front of its name. Since the page is meant to display job details, select all columns relevant for the applicant: the job title, type, salary, deadline, detail, the domain and location, the company name and address. Also check the job ID column (id_job).

  8. At this point, the recordset retrieves all necessary data regarding all jobs in the database. But the detail page must display details only for the job selected in the openings list. Therefore, the recordset must filter out all other jobs. The criteria for the record to keep is to have its ID equal to the one passed as an URL parameter. To add a condition on a column, click on the ... button next to the column name in the columns section.
  9. In the Edit SQL Condition dialog box, select the variable type to use (URL parameter), enter the run-time value (the URL parameter's name) and a default value (to be used when no parameter is passed to the page - use -1 to make sure no job details are retrieved).

  10. Now the query is completely defined, and you can save it and return to Dreamweaver. Click on the save icon to store the query in the repository for later use, and then from the Query menu, select Close.
  11. Back in Dreamweaver, in order to display the created query, you have to click on the Refresh button next to the Query name drop-down menu. Then the query will be displayed in the SQL text area:

  12. Click OK to close the recordset dialog box and add it to the page..
 

Next you have to display the data. You can do this in two ways:

In both cases, some of the fields do not have to show up on the page (e.g. the job and company id fields). To make the page more aesthetic, you will use the first option. Follow the next steps:

  1. Manually create a table with 9 rows and 2 columns. In the first column, you will have to enter the field names, slightly modified, to be more readable. In the second column, you will drag and drop the fields of the rsDetails recordset from the Bindings panel. Set the cell padding and cell space so that fields are easily distinguished. The table should look like this:

  2. Next you'll implement the Apply to job feature. This is actually an Insert operation on the job_user_jbu table. If you take a look at its structure, you will notice that it requires only ID's and a date: the job ID, the resume ID and the date when the user applied. The job ID and the current date are already covered, but the user's resume ID is not retrieved anywhere on the page. Therefore, the first step into building the Apply to job feature is to retrieve the user's resume.

  3. Users cannot visit the job_details page without being logged in. And when the user logs in, his unique identifier is stored into the kt_login_id session variable. Based on this, you can build a simple filtered recordset that retrieves data from the resume table for the currently logged in user. Simply open the new recordset dialog box from the Plus (+) button of the Bindings panel, and configure it as shown below:


                  

  4. The last step into creating the job details page is to add the actual insert operation. To do this in an easy manner, you will use the Insert Record Form Wizard, accessible either from the MX Kollection tab of the Insert panel, or from Server behaviors -> MX Kollection -> Forms.

  5. In the wizard's first step, select the database Connection you've created for this tutorial, and in the Table drop-down menu select job_user_jbu. For the redirect page, use the Browse button to select the user/index file.


                                   
  6. In the wizard's second step you will have to configure what fields will be used in the transaction. As the only thing to show is the Apply to job button, you will have to set each field to be displayed as text (not text field). To do so, select each one of them in the form fields grid, and use the Display as drop-down menu to set the property.  You will delete them later on, so they will not appear on page.
  7. Each column to insert into will use default values from the recordsets created earlier (rsDetails for the job ID, and rsResume for the resume ID). To use a dynamic default value, you can either directly enter the correct mark-up, or use the InterAKT Dynamic Data to select the source (recordsets, variables, etc.) and it will generate the mark-up automatically.
  8. Set the grid fields as follows (for each, click on the InterAKT Dynamic Data and select the appropriate options):
    · The idrsm_jbu field will take as value the id_rsm field of the rsResume recordset.
    · The idjob_jbu field will take as value the id_job field of the rsDetails recordset.
    · For the date_jbu field you will enter the mark-up that returns the current date: {NOW}. All mark-ups are replaced at runtime by their dynamic values. For more information regarding the InterAKT mark-up language, consult the user manual.
    · When you've set the options for all three fields, you can directly click the Finish button:


              
  9. The wizard added on page a table row for each of the fields in the grid, with label and value. The value is displayed as text, but is not necessary.

  10. To remove the unnecessary data, select the three rows, and delete them. This will leave only the submit button in the form.
  11. Now change the submit button's generic label, namely Insert Record, into Apply for job, from the Property Inspector, the Label text-box.
  12. After this last step, you can save the page and open it in the browser, by clicking on the See more details link for a job in the view_jobs page. If you hit the Apply for job button, and then check out the job_user_jbu table content in your database management software, you will see that it really works.

 

This was the last tutorial page dedicated to the user section. In what follows, you will face the other side of the problem: the companies and their needs. So check out the next topic.