#!/usr/bin/perl # -*- Mode: cperl; mode: folding; -*- ############################################################################## # Nigel Hamilton # # Copyright Nigel Hamilton 2005 # All Rights Reserved # # Author: Nigel Hamilton # Filename: edittask.pl # Description: Add a new task to the goo database # # Date Change # ----------------------------------------------------------------------------- # 24/10/2005 Version 1 # ############################################################################### use strict; use lib "$ENV{GOOBASE}/shared/bin"; use CGIScript; use GooEmailer; use GooDatabase; my $cgi = CGIScript->new(); my $taskid = $cgi->{taskid}; my $title = $cgi->{title}; print "Content-type: text/html\n\n"; print getForm(GooDatabase::getRow("task", "taskid", $taskid)); ############################################################################### # # getForm - return the form to show the task in detail # ############################################################################### sub getForm { my ($task) = @_; my $requested_by_list = getSelectList("requestedby", $task->{requestedby}, qw(nigel megan sven rena)); my $finished_by_list = getSelectList("finishedby", $task->{finishedby}, qw(nobody nigel megan sven rena)); my $company_list = getSelectList("company", $task->{company}, qw(turbo10 trexy)); my $importance_list = getSelectList("importance", $task->{importance}, 1 .. 10); my $status_list = getSelectList("status", $task->{status}, qw(pending finished)); my $FormID; if ($task->{taskid}) { $FormID = "Form TaskID " . $task->{taskid}; } else { $FormID = "Form to enter a new Task"; } my $form = < Edit Task



$FormID

$task->{title}

Requested by $requested_by_list
Finished by $finished_by_list
Company $company_list
Status $status_list
Task Title
Importance $importance_list
Description
(why/what/where/how/when?)
<< Go Back  
FORM return $form; } ############################################################################### # # getSelectList - return a select list with something selected # ############################################################################### sub getSelectList { my ($name, $selected_value, @options) = @_; my $list = ""; } ############################################################################### # # addTaskToDatabase - return a select list with something selected # ############################################################################### sub addTaskToDatabase { my ($cgi) = @_; my $query = GooDatabase::prepareSQL(<{taskid}); GooDatabase::bindParam($query, 2, $cgi->{title}); GooDatabase::bindParam($query, 3, $cgi->{description}); GooDatabase::bindParam($query, 4, $cgi->{requestedby}); GooDatabase::bindParam($query, 5, $cgi->{status}); GooDatabase::bindParam($query, 6, $cgi->{importance}); GooDatabase::bindParam($query, 7, $cgi->{finishedby}); GooDatabase::bindParam($query, 8, $cgi->{company}); # what is the pain associated with this task??? GooDatabase::execute($query); # default to the taskid or get last inserted taskid return $cgi->{taskid} || GooDatabase::getMax("taskid", "task"); } __END__ =head1 NAME edittask.pl - Add a new task to the goo database =head1 SYNOPSIS edittask.pl =head1 DESCRIPTION =head1 METHODS =over =item getForm return the form to show the task in detail =item getSelectList return a select list with something selected =item addTaskToDatabase return a select list with something selected =back =head1 AUTHOR Nigel Hamilton =head1 SEE ALSO