Administrator Recipe: Add Project

In addition to the ability to add new jobs, the administrator must also be able to add new projects. The Add Project page allows the creation of a new project and the assigning of a manager, an hours budget, and a method to track the timeline. The hours budget is an estimate of how long the project is expected to take. As the time cards related to the project are submitted, the time reported is subtracted from the hours budget. With these figures, actual time spent on the project can be compared to the initial estimate. The final element on the Add Project page is a list that allows the administrator to establish an estimated timeline for the project.

As with the Add Job Code recipe, the Insert Record server behavior is used to implement the server-side logic for this page.

Step 1: Implement Add Project Design

The Add Project layout is only slightly more complex than the preceding recipe. In addition to three text fields (one each for the project name, manager, and hours budget), a drop-down list with static values displaying the number of weeks for a project is used. Our snippet example creates a list element from 1 to 20 weeks as well as an extra option for 1/2 week. You should, of course, create names and values that reflect your own project timelines.

  1. Create a dynamic page for your server model.

    graphics/book.gif In the TimeCards folder, locate the folder for your server model and open the add_project page from there.

  2. Insert a table into the content region of your page to hold the needed form elements.

    graphics/book.gif From the Snippets panel, drag the Recipes > TimeCards > Wireframes > Add Project - Wireframe snippet into the Content editable region.

  3. Insert the form and, within it, a two-column table. The table should include form text fields and labels for a project name, project manager, and hours budget. A select list displaying a number of week options should also be included. Finally, a form button is required to insert the new record.

    graphics/book.gif Place your cursor in the row below the words ADD PROJECT and insert the Recipes > TimeCards > Forms > Add Project - Form snippet.

  4. Save the file [r6-2].


    Figure r6-2.

    graphics/08fig02.jpg


Step 2: Insert Record Add Project

Because we're creating a new record, the Insert Record server behavior is the natural choice for our server-side code. To be consistent with the Add Job Code recipe, we'll set the server behavior to redirect the user to the same page the Project Summary page after the insert operation is complete.

Note

To enhance this recipe, you might create a drop-down list that displays all the managers in your company. To do this, you'll need to add a recordset of the Employee table filtered to shown only the Manager position and attach that recordset to the values and labels of the list.


For ASP
  1. From the Server Behaviors panel, choose Add (+) and select Insert Record from the list.

  2. In the Insert Record dialog, choose your data source.

    graphics/book.gif Choose Recipes from the Connection list.

  3. Select the table you want to insert the record into.

    graphics/book.gif From the Insert Into Table list, choose Projects.

  4. Set the page that you want to appear after the record is inserted.

    graphics/book.gif Choose the report_projectsummary.asp file from your server model's folder for the After Inserting, Go To field.

  5. Select the form on the current page from which to gather the record values.

    graphics/book.gif From the Get Values From list, make sure AddNewProject is selected.

  6. In the Form Elements area, match the form elements on the page to the fields in the data source table.

    graphics/book.gif Set ProjectName to insert into the ProjectName column as Text type.

    Set ProjectManager to insert into the ProjectManager column as Text type.

    Set TaskHours to insert into the ProjectHours column as Numeric type.

    Set ProjectWeek to insert into the Weeks column as Numeric type.

  7. When you're sure your choices are correct, click OK to close the dialog and add the behavior.

For ColdFusion and PHP
  1. From the Server Behaviors panel, choose Add (+) and select Insert Record.

  2. In the Insert Record dialog, choose the current form.

    graphics/book.gif Select AddNewProject from the Submit Values From list.

  3. Select your data source from the list.

    graphics/book.gif Choose Recipes from the Data Source list.

  4. Enter your username and password, if needed.

  5. Select the table in the data source to insert into from the list.

    graphics/book.gif Choose Projects (projects in PHP) from the Insert Into Table list.

  6. Set the data source fields to their corresponding form elements.

    graphics/book.gif Make sure the ProjectID data column is set to be an unused Primary Key.

    Set ProjectName to the FORM.ProjectName form element and submit as Text type.

    Set ProjectManager to the FORM.ProjectManager form element and submit as Text type.

    Set TaskHours to the FORM.ProjectHours form element and submit as Numeric type (Double in PHP).

    Set Weeks to the FORM.ProjectWeek form element and submit as Numeric type (Double in PHP).

  7. In the After Inserting, Go To field, enter report_projectsummary.cfm or report_projectsummary.php as appropriate and click OK to close the dialog.

  8. Save your page.



Macromedia Dreamweaver MX 2004 Web Application Recipes
Macromedia Dreamweaver MX 2004 Web Application Recipes
ISBN: 0735713200
EAN: 2147483647
Year: 2003
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net