Issue Tracker

From FiFormsWiki

Jump to: navigation, search

- This tutorial is designed for someone who has a good understanding of the principles of interactive development using PHP, Apache, and MySQL. (A decent understanding of the principles of Object oriented programming couldn't hurt either).

- An issue tracking database could be used by a company maintenance department for tracking broken equipment and service calls.


- PHP 5 or later

- Apache 2 or later

- MySQL 5 or later

- and Fiforms


- xampp

- SciTE (free text editor)


- Create a new database called "tutorials", and add a table to it called "issues".

CREATE TABLE `issues` (
`status` varchar(20) NOT NULL ,
`description` VARCHAR( 50 ) NOT NULL ,
`assignedTo` VARCHAR(15) NOT NULL ,
`workLog` TEXT NULL ,
`department` VARCHAR(20) NOT NULL ,
`startDate` DATE NOT NULL ,
`dueDate` DATE NUll ,
`endDate` DATE NULL

- Now create a file called issues.php and place it into your apache root folder. And put this inside it:

 require_once(""); //include FiForms
 $frm = new FiForm("Issue Tracker"); // issue tracker constructor declaration
 $frm->dataServer = "localhost"; // the server the data is on
 $frm->dataDB = "tutorials"; // the database you are going to connect to
 $frm->dataTable = "issues"; // the name of the table.
 $frm->autoinputs(); // method used for automatically generating iInputs
 echo $frm->drawFormPage(); //the method used to create the form.

- Go to http://localhost/issues.php
- Enter a user and password that has the access rights in your MySQL database to view/edit the tutorials database.
- Once you are logged in, you should see a form that looks something like this:


Final Code

/*All manual additions to the ‘$_GET’ array are kept by FiForms automatically. 
I am adding “I” as an element to the $_GET array for the purpose of redirection 
to a path with the proper $_GET elements if they are not present.
if($_GET['I'] != 1)
header('Location: issues.php?sheetView=YES&currentRec=0&I=1');

require_once(""); //include FiForms
 $frm = new FiForm("Issue Tracker"); // issue tracker constructor declaration
 $frm->dataServer = "localhost"; // the server the data is on
 $frm->dataDB = "tutorials"; // the database you are going to connect to
 $frm->dataTable = "issues"; // the name of the table.
 $frm->name = "Issue Tracker"; // Setting the name of the form

// For creating the proper where clause depending on which link is clicked.

 	switch ($_GET['status'])
		case null:
		case 'OPEN':
		        //Add assignedTo value if, for example, "Jared's issues" is clicked 
			$frm->where = 'status != "CLOSED" and assignedTo = "'.$_GET['assignedTo'].'"'; 
		case 'CLOSED':
			$frm->where = 'status = "CLOSED" assignedTo = "'.$_GET['assignedTo'].'"';
	} // end of first switch statement

} else {
	switch ($_GET['status'])
		case null:
		case 'OPEN':
			$frm->where = 'status != "CLOSED"';
		case 'CLOSED':
			$frm->where = 'status = "CLOSED"';
} // end of second switch statement
} // end of   if($_GET['assignedTo'])
  //Set the data-member orderBy equal to the ORDER BY sql syntax 'ORDER BY startDate' is a part of the MySQL query.
$frm->orderBy = 'ORDER BY startDate';
 // add in an object that will give me the edit option for each record in sheetView.
  // Add in an the object iROText that links to the 'id' column in the 'issues' table, and Assigning it the caption of 'ID' 
 $frm->addIn('iROText', 'id', 'ID');
  // same as the id column, but with no caption
 $frm->addIn('iText', 'description');
  // add an 'iDBSelect object thats value is linked to the 'issues' table column 'assignedTo'
 $frm->addIn('iDBSelect', 'assignedTo', 'Assigned To:');
 /*This if statement assigns the default value of the 'assignedTo' depending on what link is pressed */
 $frm->inputs['assignedTo']->value = $_GET['assignedTo'];
} else{
	$frm->inputs['assignedTo']->value = 'IT';

 //create the array of values for the 'assignedTo' iDBSelect object
 $frm->inputs['assignedTo']->rowQuery = array('IT','Eddie', 'Jared', 'Daniel');
 //add, set the default value, and array values of the iDBSelect object 'status'
 $frm->addIn('iDBSelect', 'status');
 $frm->inputs['status']->value = 'OPEN';
 $frm->inputs['status']->rowQuery = array('OPEN', 'CLOSED', 'PENDING', 'IN PROGRESS');
 //Add iDateText objects 'startDate' and 'dueDate'
 $frm->addIn('iDateText', 'startDate');
 $frm->addIn('iDateText', 'dueDate');

 // An if statement that adds the workLog text area when in edit mode.
  if($_GET['sheetView'] != 'YES')
 	//setting the size of the text area for workLog
 	$frm->inputs['workLog']->rows = 10; 
	$frm->inputs['workLog']->cols = 50;
  //Add an iDBSelect object called department, set the default value, and create an array of values for the drop-down selection
  $frm->addIn('iDBSelect', 'department');
  $frm->inputs['department']->value = 'Company';
  $frm->inputs['department']->rowQuery = array('Company', 'Accounting','plant', 'warehouse', 'Executive office');
 // set the startDate default value to 'today' when in edit mode
 if($_GET['currentRec'] == 'new')
 	$frm->inputs['startDate']->value = date("Y-m-d");
if($_GET['status'] == 'CLOSED')
// if you click on Closed Issues, the endDate field is shown
$frm->addIn('iDateText', 'endDate');
//and when in Closed Issues edit mode the default value for status is 'CLOSED'
$frm->inputs['status']->value = 'CLOSED';

//if in edit mode show the field endDate
} elseif ($_GET['sheetView'] != 'YES') {
	$frm->addIn('iDateText', 'endDate');

//if you select the CLOSED value in form edit mode
 if ($frm->inputs['status']->valueToSave == 'CLOSED')
	//and if I don't set the value for the field endDate
	//then set the value of endDate to today's date
	$frm->inputs['endDate']->valueToSave = date("Y-m-d");

//Add the html links at the bottum of the page, with the proper $_GET array values 
//(remember the period means Concatenate in PHP)
$frm->wrapper->pageFooter .= "<p><hr />
<a href=\"issues.php?sheetView=YES&status=OPEN&currentRec=0&I=1\">Open Issues</a> | 
<a href=\"issues.php?sheetView=YES&status=OPEN&assignedTo=Jared&currentRec=0&I=1\">Jared's Issues</a> |
<a href=\"issues.php?sheetView=YES&status=OPEN&assignedTo=Eddie&currentRec=0&I=1\">Eddie's Issues</a> |
<a href=\"issues.php?sheetView=YES&status=CLOSED&currentRec=0&I=1\">Closed Issues</a>";

//If the form is in sheetView, then center the form on the page
if($_GET['sheetView'] == 'YES')
	$frm->wrapper->pageHeader .= '<center>';	
	$frm->wrapper->pageFooter .= "</center></p>";
} else {
	//else do not center
	$frm->wrapper->pageFooter .= "</p>";

  echo $frm->drawFormPage(); //the method used to create the form.

- Copy the above code into the file called issues.php. The code is commented, so reading it shouldn't be that difficult.

- If you followed the steps correctly, you should have a page that looks something like this:


- That's it! With a little modification, this code can be tailored for your own uses.

Personal tools
This is a cached copy of the requested page, and may not be up to date.

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.

(Can't contact the database server: The server requested authentication method unknown to the client (localhost))

You can try searching via Google in the meantime.
Note that their indexes of our content may be out of date.