Creating Customer Support Time Tracking Application Daikon with Codeigniter Part 3

Adding Profiles

So far we created Cutomer Admin page. In this article we are going to add profiles. Then support_details table to DB. We also modify userlib.php, members.php. and form_member.php as well.

In our profile, we are going to add Company name, Full name, Web address, Phone number, Address, City and Post code. You can add more if your application needs them.

Please read this backendpro manual, http://www.kaydoo.co.uk/backendpro/user_guide/features/userauth.html for the reference.

 

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

Update the database be_user_profiles

Run the following sql to alter the table be_user_profiles.

ALTER TABLE `be_user_profiles`
 ADD COLUMN `company_name` varchar(100) NOT NULL,
 ADD COLUMN `full_name` varchar(50) NOT NULL,
 ADD COLUMN `web_address` varchar(100) NOT NULL,
 ADD COLUMN `phone_number` varchar(50) NOT NULL,
 ADD COLUMN `address` varchar(50) NOT NULL,
 ADD COLUMN `city` varchar(30) NOT NULL,
 ADD COLUMN `post_code` int(10) NOT NULL

You now have the following structure.

 

Adding support_details table to DB

Run the following sql in phpMyAdmin to create table ‘support_details.

CREATE TABLE IF NOT EXISTS `support_details` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `customer_id` int(10) NOT NULL,
  `date` date NOT NULL,
  `time` int(10) NOT NULL,
  `point_credit` int(10) NOT NULL,
  `note` text NOT NULL,
  `details` text NOT NULL,
  `by` varchar(40) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;

You should have structure as in the following image.

 

Update the Userlib config file.

Open modules/auth/config/userlib.php and replace with the following.


<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Userlib Configurations
 *
 * Contains all config settings for the Userlib class
 *
 * @package		BackendPro
 * @subpackage 	Configurations
 * @author		Adam Price
 * @copyright	Copyright (c) 2008, Adam Price
 * @license		http://www.gnu.org/licenses/lgpl.html
 * @link		http://www.kaydoo.co.uk/projects/backendpro
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * Authentication Actions
 *
 * These are all the actions performed when an auth process
 * has been completed DO NOT SEND THE LOGIN ACTIONS BACK TO
 * THE LOGIN CONTROLLER, IT WILL CAUSE AN INFINITE LOOP
 */
$config['userlib_action_login'] = '';
$config['userlib_action_logout'] = '';
$config['userlib_action_register'] ='';
$config['userlib_action_activation'] ='';
$config['userlib_action_forgotten_password'] = 'auth/login';
$config['userlib_action_admin_login'] = 'admin';
$config['userlib_action_admin_logout'] = '';

/**
 * User Profile Fields
 *
 * Define here all custom user profile fields and their respective rules.
 * To define a new custom profile field, you must specify an
 * associative array from the database column name => Full Name/Rule.
 * If no rule is given for a specific field it will not be validated.
 */

$config['userlib_profile_fields'] = array('company_name' => 'Company Name');
$config['userlib_profile_rules'] = array('company_name' => 'required|alpha_numeric'); 

$config['userlib_profile_fields'] = array('full_name' => 'full name');
$config['userlib_profile_rules'] = array('full_name' => 'required|alpha');

$config['userlib_profile_fields'] = array('web_address' => 'Web Address');
$config['userlib_profile_rules'] = array('web_address' => 'required|alpha_numeric');

$config['userlib_profile_fields'] = array('company_name' => 'Company Name');
$config['userlib_profile_rules'] = array('company_name' => 'required|alpha_numeric');

$config['userlib_profile_fields'] = array('phone_number' => 'Phone Number');
$config['userlib_profile_rules'] = array('phone_number' => 'alpha_numeric');

$config['userlib_profile_fields'] = array('address' => 'Address');
$config['userlib_profile_rules'] = array('address' => 'alpha_numeric');

$config['userlib_profile_fields'] = array('city' => 'City');
$config['userlib_profile_rules'] = array('city' => 'alpha');

$config['userlib_profile_fields'] = array('post_code' => 'Post Code');
$config['userlib_profile_rules'] = array('post_code' => 'numeric');

/* End of file userlib.php */
/* Location: ./modules/auth/config/userlib.php */

Allow User Profiles

Log into the control panel and go to the Settings -> Member Settings page.
Then Yes to ‘Allow User Profile’ and save.

Update the Member area in the Control Panel

We have done this in the previous article. It allows administrators to manage these new fields. We have modified the file modules/auth/controllers/admin/members.php.

Update form_member.php

The last thing we must do is update the form which data can be entered into, locate and open the file modules/auth/views/admin/members/form_member.php

Replace the file with the following code.


<div id="generatePasswordWindow">
	<table>
		<tr><th width="50%"><?php print $this->lang->line('userlib_generate_password'); ?></th><th class="right"><a href="javascript:void(0);" id="gpCloseWindow"><?php print $this->bep_assets->icon('cross') ?></a></th></tr>
		<tr><td rowspan="3"><?php print $this->lang->line('userlib_password'); ?>:<br/>&nbsp;&nbsp;&nbsp;<b id="gpPassword">PASSWORD</b></td><td class="right"><?php print $this->lang->line('general_uppercase'); ?> <?php print form_checkbox('uppercase','1',TRUE); ?></td></tr>
		<tr><td class="right"><?php print $this->lang->line('general_numeric'); ?> <?php print form_checkbox('numeric','1',TRUE); ?></td></tr>
		<tr><td class="right"><?php print $this->lang->line('general_symbols'); ?> <?php print form_checkbox('symbols','1',FALSE); ?></td></tr>
		<tr><td colspan="2"><a href="javascript:void(0);" class="icon_arrow_refresh" id="gpGenerateNew"><?php print $this->lang->line('general_generate'); ?></a></td></tr>
		<tr><td><a href="javascript:void(0);" class="icon_tick" id="gpApply"><?php print $this->lang->line('general_apply'); ?></a></td><td class="right"><?php print $this->lang->line('general_length'); ?> <input type="text" name="length" value="12" maxlength="2" size="4" /></td></tr>
	</table>
</div>

<h2><?php print $header?></h2>
<p><?php print $this->lang->line('userlib_password_info')?></p>

<?php print form_open('auth/admin/members/form/'.$this->validation->id,array('class'=>'horizontal'))?>
    <fieldset>
        <ol>
            <li>
                <?php print form_label($this->lang->line('userlib_username'),'username')?>
                <?php print form_input('username',$this->validation->username,'id="username" class="text"')?>
            </li>
            <li>
                <?php print form_label($this->lang->line('userlib_email'),'email')?>
                <?php print form_input('email',$this->validation->email,'id="email" class="text"')?>
            </li>
            <li>
                <?php print form_label($this->lang->line('userlib_password'),'password')?>
                <?php print form_password('password','','id="password" class="text"')?>
            </li>
            <li>
                <?php print form_label($this->lang->line('userlib_confirm_password'),'confirm_password')?>
                <?php print form_password('confirm_password','','id="confirm_password" class="text"')?>
            </li>
            <li>
                <?php print form_label($this->lang->line('userlib_group'),'group')?>
                <?php print form_dropdown('group',$groups,$this->validation->group,'id="group" size="10" style="width:20.3em;"')?>
            </li>
            <li>
                <?php print form_label($this->lang->line('userlib_active'),'active')?>
                <?php print $this->lang->line('general_yes')?> <?php print form_radio('active','1',$this->validation->set_radio('active','1'),'id="active"')?>
                <?php print $this->lang->line('general_no')?> <?php print form_radio('active','0',$this->validation->set_radio('active','0'))?>
            </li>
            <li class="submit">
                <?php print form_hidden('id',$this->validation->id)?>
                <div class="buttons">
	                <button type="submit" class="positive" name="submit" value="submit">
	                	<?php print  $this->bep_assets->icon('disk');?>
	                	<?php print $this->lang->line('general_save')?>
	                </button>

	                <a href="<?php print  site_url('auth/admin/members')?>" class="negative">
	                	<?php print  $this->bep_assets->icon('cross');?>
	                	<?php print $this->lang->line('general_cancel')?>
	                </a>

	                <a href="javascript:void(0);" id="generate_password">
	                	<?php print  $this->bep_assets->icon('key');?>
	                	<?php print $this->lang->line('userlib_generate_password'); ?>
	                </a>
	            </div>
            </li>
        </ol>
    </fieldset>
<h2><?php print $this->lang->line('userlib_user_profile')?></h2>
<?php
    if( ! $this->preference->item('allow_user_profiles')):
        print "<p>".$this->lang->line('userlib_profile_disabled')."</p>";
    else:

?>
<fieldset>
        <ol>
        	<li>
                <?php print form_label('Company Name','company_name')?>
                <?php $value = (empty($profiles['company_name']))? '' : $profiles['company_name'];  ?>
                <?php print form_input('company_name',$value,'id="company_name" class="text"')?>

            </li>
            <li>
                <?php print form_label('Full Name','full_name')?>
                 <?php $value = (empty($profiles['full_name']))? '' : $profiles['full_name'];  ?>
                <?php print form_input('full_name',$value,'id="full_name" class="text"')?>
            </li>
            <li>
                <?php print form_label('Web Address','web_address')?>
                 <?php $value = (empty($profiles['web_address']))? '' : $profiles['web_address'];  ?>
                <?php print form_input('web_address',$value,'id="web_address" class="text"')?>
            </li>
            <li>
                <?php print form_label('Phone Number','phone_number')?>
                 <?php $value = (empty($profiles['phone_number']))? '' : $profiles['phone_number'];  ?>
                <?php print form_input('phone_number',$value,'id="phone_number" class="text"')?>
            </li>
            <li>
                <?php print form_label('Address','address')?>
                 <?php $value = (empty($profiles['address']))? '' : $profiles['address'];  ?>
                <?php print form_input('address',$value,'id="address" class="text"')?>
            </li>
            <li>
                <?php print form_label('City','city')?>
                 <?php $value = (empty($profiles['city']))? '' : $profiles['city'];  ?>
                <?php print form_input('city',$value,'id="city" class="text"')?>
            </li>
            <li>
                <?php print form_label('Post Code','post_code')?>
                 <?php $value = (empty($profiles['post_code']))? '' : $profiles['post_code'];  ?>
                <?php print form_input('post_code',$value,'id="post_code" class="text"')?>
            </li>

            <li class="submit">
                <div class="buttons">
	                <button type="submit" class="positive" name="submit" value="submit">
	                	<?php print  $this->bep_assets->icon('disk');?>
	                	<?php print $this->lang->line('general_save')?>
	                </button>

	                <a href="<?php print  site_url('auth/admin/members')?>" class="negative">
	                	<?php print  $this->bep_assets->icon('cross');?>
	                	<?php print $this->lang->line('general_cancel')?>
	                </a>
	            </div>
            </li>

        </ol>
    </fieldset>
<?php endif;?>
<?php print form_close()?>

Test Drive

You should be able to create, edit, enter new credit and enter work done at this stage.

Customer Page

 

Customer Record

 

Enter Credit

 

Enter Work Done

 

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>