Creating Customer Support Time Tracking Application ‘Daikon’ with Codeigniter Part 1

This time we are going to develop a customer time tracking application with Codeigniter. This allows admin to enter tickets purchased by customers and work done for customers. Customer can see the details of support including tickets purchase, work done and its time, total remaining tickets in minutes.

 

Demo

Note: Demo is available for Customer Pages Only.

Login details
email 1: cus7(a)gmail.com and pw: anneanne

email 2: cus2(a)gmail.com and pw: tonjetonje

Download page


This article is for myself. However if you are interested in developing an application with Codeigniter, reading or following these steps may help you.
Note: I used to develop on Windows, but recently I am using Ubuntu/Linux. And I love it.

Installing CodeIgniter

Download Codeigniter, unzip, rename is as daikon and move to var/www folder. If you are using XAMPP, then in htdocs.

Preparing BackendPro

Download BackendPro and unzip it to var/www/daikon folder.
As we have done in our Portfolio CMS. we update BeP for php5.3.

If you want to use BeP for PHP5.3 environment such as XAMPP 1.7.3, you need to modify BeP.

1. remove the ‘&’ sign from line 414 in system/application/libraries/loader.php

2. Change line 100 of /modules/preferences/libraries/Preference_form.php

$this->field[$field]['label'] = ucwords(preg_replace('/_/',' ',$field));

3. Line 42 modules/auth/views/admin/access_control/resources.php
Change to

$offset = $this->access_control_model->buildPrettyOffset($obj,$tree);

3. If you are using LINUX, then you need to change chmod of BeP. Windows user ignore this.
I guess the author of Bep created it with Windows. So all the directory has chmod of drwx——.
You need to change this to drwxr-xr-x by the following in shell.

sudo find /var/www/daikon/ -type f -print0 | xargs -0 sudo chmod 644
sudo find /var/www/daikon/ -type d -print0 | xargs -0 sudo chmod 755
chmod -R a+w /var/www/daikon/install
chmod -R a+w /var/www/daikon/system/logs
chmod -R a+w /var/www/daikon/assets/cache
chmod -R a+w /var/www/daikon/system/cache
chmod  a+w /var/www/daikon/system/application/config/config.php
chmod  a+w /var/www/daikon/system/application/config/database.php
chmod  a+w /var/www/daikon/modules/recaptcha/config/recaptcha.php

The first line changes all files in daikon folder to 644. The second line changes all directory to 755.
install directory need to be writeable for installation which coming to next.

Installing BeP on Codeigniter

Go to http://localhost/daikon/install and enter necessary information.
Use this website to create an encryption key. http://www.ideaspace.net/misc/hash/.
Keep all the field of System Folder, Application Folder, Modules Folder, Log Folder and Cache folder as they are.
Since we are not using Recaptcha in this app, leave it blank.
After a successful installation, delete the /install directory.

Open application/config.php and check your $config['base_url'].

$config['base_url']= "http://localhost/daikon/";

By now you should be able to login to the backend. Login page is http://localhost/daikon/index.php/auth/login

Use your login email and password which you input during the installation.

Now you need to change file permission of config.php, database.php and recaptcha.php.

chmod /var/www/daikon/system/application/config/config.php 644
chmod  /var/www/daikon/system/application/config/database.php 644
chmod  /var/www/daikon/modules/recaptcha/config/recaptcha.php 644

or with two lines like this.

sudo find /var/www/daikon/system/application/config -type f -print0 | xargs -0 sudo chmod 644
chmod  /var/www/daikon/modules/recaptcha/config/recaptcha.php 644

Adding autoload files

Modify system/application/config/autoload.php and set up autoload files.


$autoload['libraries'] = array('form_validation','validation');

$autoload['helper'] = array('form','security','language');

$autoload['language'] = array('customer');

Creating customer.php

We are going add system/application/language/english/customer_lang.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/* Strings used on Customer Support page */
$lang['customer_support_admin'] = 'Customer Admin';
$lang['customer_customers_admin'] = 'Customers Admin';
$lang['customer_customer_record'] = 'Customer Record';
$lang['customer_purchase_support'] = 'Purchase Support';

$lang['customer_support'] = 'Customer Support';
$lang['customer_customers'] = 'Customers';
$lang['customer_record'] = 'Support Details';
$lang['customer_support_record'] = 'Customer Support Records';

/* For breadcrumb */
$lang['customer_support_admin'] = 'Customer Support Admin';
$lang['customer_support_admin_create'] = 'Create Customer';
$lang['customer_support_admin_edit'] = 'Edit Customer';
$lang['customer_support_customer'] = 'Customer Support Details';
$lang['customer_support_record'] = 'Customer Record';
$lang['customer_enter_credit'] = 'Enter Credits';
$lang['customer_work_done'] = 'Work Done';
$lang['customer_edit_record'] = 'Edit Record';

We are going to use it in our modules later.

Creating Support_Controller.php

We will create different menus for members.
I have two reasons. 1. it will make it simpler for members without other menus. 2. We don’t want to show admin links.

In order to do that we are going to create system/application/libraries/Support_controller.php. We will extend this in modules/customersupport/controllers/admin/admin.php. Please copy and paste it.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Support_Controller
 *
 * Extends the Site_Controller class so I can declare special Support Admin controllers
 *
 */
class Support_Controller extends Site_Controller
{
	function Support_Controller()
	{
		parent::Site_Controller();

		// Set base crumb
		$this->bep_site->set_crumb('Support Home','customersupport/admin');

		// Set container variable
               // here we set which container to use so that it will be different from admin container.
		$this->_container = $this->config->item('backendpro_template_support') . "container.php";

		// Set Pop container variable
		$this->_popup_container = $this->config->item('backendpro_template_support') . "popup.php";

		// Make sure user is logged in
		// check('Control Panel');

		// Check to see if the install path still exists
		if( is_dir('install'))
		{
			flashMsg('warning',$this->lang->line('backendpro_remove_install'));
		}

		// Set private meta tags
		//$this->bep_site->set_metatag('name','content',TRUE/FALSE);
		$this->bep_site->set_metatag('robots','nofollow, noindex');
		$this->bep_site->set_metatag('pragma','nocache',TRUE);

		// Load the ADMIN asset group
		$this->bep_assets->load_asset_group('ADMIN');

		log_message('debug','BackendPro : Admin_Controller class loaded');
	}
}

/* End of Admin_controller.php */
/* Location: ./system/application/libraries/Admin_controller.php */

We will extend this in a future article.

Adding Support_Controller.php to MY_Controller.php

Since we extended Site_Controller. We need to register in MY_Controller.php so that we can use it. Site_Controller’s file name is actually MY_Controller.php.
So we need to add the following line to the end of system/application/libraries/MY_Controller.php

include_once("Support_controller.php");

Modifying BeP

We are going to modify system/application/controllers/admin/settings.php. The reason is that we need to check the permission of ‘Settings’, otherwise member can see the Setting pages and the member can change the Settings. We don’t want it to happen. Even though we are not showing the link to members, we need to avoid this.


class Settings extends Admin_Controller
{
	function Settings()
	{
		parent::Admin_Controller();

		$this->lang->module_load('preferences','preferences');

		// Check for access permission
		check('Settings');

		log_message('debug','BackendPro : Settings class loaded');
	}

Creating Permissions for Member

Login to the backend and go to system > Access Control > Permissions.
Click ‘Create Permissions’, and select ‘Members’ under Groups, ‘Settings’ under Resources and ‘Deny’ under Access at the bottom, then save.

We are going to create more Resources and Permissions in future article.

CSS change

We modify line 16 in assets/css/forms.css for a bigger form area.

form input.text, form textarea {/* width: 20em;*/ }

Adding method to Bep members.php

Modify following functions in modules/auth/controllers/admin/members.php and add function _pull_profile_details().

We are going to use the method in our module later.


function _set_profile_defaults()
	{
		$this->validation->set_default_value('company_name','Company Name');
		$this->validation->set_default_value('full_name','Full Name');
		$this->validation->set_default_value('web_address','Web Address');
		$this->validation->set_default_value('phone_number','Phone Number');
		$this->validation->set_default_value('address','Address');
		$this->validation->set_default_value('city','City');
		$this->validation->set_default_value('post_code','Post Code');

	}
...
...
function _get_profile_details()
	{
		$data = array();
		$data['company_name'] = $this->input->post('company_name');
		$data['full_name'] = $this->input->post('full_name');
		$data['web_address'] = $this->input->post('web_address');
		$data['phone_number'] = $this->input->post('phone_number');
		$data['address'] = $this->input->post('address');
		$data['city'] = $this->input->post('city');
		$data['post_code'] = $this->input->post('post_code');
		return $data;
	}

...
...

function _pull_profile_details($id){

		$query=$this->user_model->fetch('UserProfiles','*','',array('user_id'=>$id));
		$row = $query->row_array();
		return $row;
	}

...
...
// Construct Groups dropdown
			$this->load->model('access_control_model');
			$data['groups'] = $this->access_control_model->buildAClDropdown('group','id');
// after the above line, add the following lines.
// get profile details
			$data['profiles']= $this->_pull_profile_details($id);

Adding icons

You can download icons from here and add user_green.png and user_orange.png icons in assets/icons

Now we are finished the basic preparation. We proceed to creating admin area in the next article.

4 comments to Creating Customer Support Time Tracking Application ‘Daikon’ with Codeigniter Part 1

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>