Receptionist / Inquiry Management system in Codeigniter.

Receptionist / Inquiry Management system in Codeigniter.

 

A receptionist is an operator who has to take calls, enter record than make calls to all those. Some companies have more than one computer operator as receptionist. They have to mention their names who took the call or added the name of client or inquiry in the table or sheet on which they keep record.

For Starting this application we will first create the database for this application. We need two tables, users and clients. We will store credentials of users who will login to this application in users table and will store record of inquiries in clients table.

Creating Database

First of all we create a database. I leave the choice of local testing server on you. I am using WAMP you can choose whatever you feel comfortable.

db1

Alright in the above image you can see my phpmyadmin in which I have created a database by the name of dms and have created two tables in it users and clients. Following are their structure

Codeigniter

E-Office system in Codeigniter

You can see the field names, data types and their length value. You can choose to change them at your will it’s up to you.

Installing Codeigniter

Now is the time to setup our working environment. We require a Codeigniter installation along with bootstrap for a little styling and page layout. So I have downloaded and uncompressed codeigniter from its website. Created three folders css, js and img respectively. Following is my folder structure

ci

The .idea folder on the top of the list is because I work in PHPStorm. The applicaton, system and user_guide folders are basic codeigniter folders and the rest is bootstrap folder structure. Now experience Codeigniter developers, after installing the framework set the environment first but we are not going to do that as it can confuse you. So I will go to some basic configurations. The initial configurations are all made from the config folder in the application folder. We will stay in the application folder for rest of our development except for bootstrap folders. Alright the first thing we need to do is to go to the config folder and open the autoload.php in our editor

ci2

Watch closely, in your autoload file when you open it first time the array index libraries and helpers would be empty. I have changed it and have autoloaded some libraries and helpers. Now to use session library I have to provide an encryption key which is in config.php. Let’s open that

E-Office in PHP Codeigniter

You can see I have updated the security key. You can put any kind of crap here, Make it complex make it dirty that’s all up to you.

The next thing which is very important is to remove index.php from the url which codeigniter uses by default and we can do it by create an .htaccess file and putting the following it. The .htaccess file is created on root

 

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

 

Now there is only one last entry you need to change and that is in routes.php which is default controller at the end of the file. But we have to create a controller first

What is a Controller? You need to learn about MVC or google it.

Because it is a very small application so I have created only one controller, but in normal practice there is a different controller for every entity or module like search, items, products, pages, blog and admin. I have created only Admin Controller, Following is my Admin Controller Code.

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/1/2016
* Time: 2:53 PM
*/

class Admin extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->model(‘admin_model’);
$this->load->library(‘form_validation’);

}

public function index()
{
if(empty($this->session->userdata[‘id’])){
redirect(base_url().‘admin/signin’);

}
if($_POST)
{
$config=array(
array(
‘field’ => ‘fullname’,
‘label’ => ‘Full Name’,
‘rules’ => ‘trim|required’
),
array(
‘field’ => ‘username’,
‘label’ => ‘User Name’,
‘rules’ => ‘trim|required’
),
array(
‘field’ => ‘password’,
‘label’ => ‘Password’,
‘rules’ => ‘trim|required’
)
);
$this->form_validation->set_rules($config);
if($this->form_validation->run()==FALSE){
$data[‘errors’]=validation_errors();
$data[‘title’]=‘Admin Panel’;
$data[‘users’]=$this->admin_model->getUsers();
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/add_user’);
}
else
{
$this->admin_model->addUser($_POST);
$data[‘title’]=‘Admin Panel’;
$data[‘success’]=‘User Added’;
$data[‘users’]=$this->admin_model->getUsers();
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/add_user’);
}
}
else
{
$data[‘users’]=$this->admin_model->getUsers();
$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/add_user’);
}

}
public function add_clients()
{
if(empty($this->session->userdata[‘id’])){
redirect(base_url().‘admin/signin’);
}
if($_POST)
{
$st=$this->admin_model->add_client($_POST);
if($st)
{
redirect(base_url().‘admin/clients’);
}
}
else
{
//

$data[‘title’]=‘Admin Panel’;
$data[‘users’]=$this->admin_model->getUsers();
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/add_client’,$data);
}

}

public function clients()
{
if(empty($this->session->userdata[‘id’])){
redirect(base_url().‘admin/signin’);

}
$data[‘clients’]=$this->admin_model->getClients();
$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/clients’);
}

public function signin()
{
if($_POST){
$config=array(
array(
‘field’ => ‘username’,
‘label’ => ‘Username’,
‘rules’ => ‘trim|required’
),
array(
‘field’ => ‘password’,
‘label’ => ‘Password’,
‘rules’ => ‘trim|required’
)
);
$this->form_validation->set_rules($config);
if($this->form_validation->run()==FALSE){
$data[‘errors’]=validation_errors();
$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘content/login’);
}
else {
$user=$this->admin_model->checkUser($_POST);
if(!empty($user))
{
$this->session->set_userdata($user);
redirect(base_url().‘admin’);
}
else
{
$data[‘errors’]=‘Sorry, Incorrect Credentials or User does not exist’;
$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘content/login’);
}
}
}
else
{
$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘content/login’);
}
}

public function call_clients()
{
if(empty($this->session->userdata[‘id’])){
redirect(base_url().‘admin/signin’);

}
$data[‘clients’]=$this->admin_model->getAllClients();
$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/call_clients’);
}
public function edit_client()
{
if(empty($this->session->userdata[‘id’])){
redirect(base_url().‘admin/signin’);

}
$clientId=$this->uri->segment(3);
if($_POST)
{
$st=$this->admin_model->update_client($_POST,$clientId);
if($st)
{
redirect(base_url().‘admin/clients’);
}
}
else
{
$data[‘client’]=$this->admin_model->getClientById($clientId);
$data[‘users’]=$this->admin_model->getUsers();
$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/edit_client’);
}
}

public function client_detail()
{
if(empty($this->session->userdata[‘id’])){
redirect(base_url().‘admin/signin’);

}
$clientId=$this->uri->segment(3);
$data[‘client’]=$this->admin_model->getClientById($clientId);

$data[‘title’]=‘Admin Panel’;
$this->load->view(‘static/head’,$data);
$this->load->view(‘static/header’);
$this->load->view(‘content/client_details’);
}

public function client_called(){
$clientId=$this->uri->segment(3);
$this->admin_model->markClientCalled($clientId);
redirect($_SERVER[‘HTTP_REFERER’]);
}

public function logout()
{
$this->session->sess_destroy();
redirect(base_url());
}
}

 

Of course I didn’t write all this crap in the beginning, it was all step by step I created the login page, and login function, then I wrote the admin_model and its functions to screw with database and then perform rest of functions. Following is my admin model

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 9:35 AM
*/

class Admin_model extends CI_Model {
function __construct() {
parent::__construct();
}

public function getUsers(){
$st=$this->db->query(‘select * from users’);
return $st->result_array();
}

public function addUser($data)
{
$user=array(
‘name’     => $data[‘fullname’],
‘username’ => $data[‘username’],
‘password’ => md5($data[‘password’])
);
$this->db->insert(‘users’,$user);
return true;
}
public function checkUser($data)
{
$st=$this->db->select(‘*’)->from(‘users’)->WHERE(‘username’,$data[‘username’])->WHERE(‘password’,md5($data[‘password’]))->get();
$data=$st->result_array();
return $data[0];

}

public function getUserById($userId){
$st=$this->db->select(‘*’)->from(‘users’)->where(‘users.id’,$userId)->get();
$data=$st->result_array();
return $data[0];
}

public function delUser($userId){
$this->db->query(‘delete from users where users.id=’.$userId);
return true;
}

public function add_client($data){
$client=array(
‘name’                 =>$data[‘name’],
‘industry’             =>$data[‘industry’],
‘website’               =>$data[‘website’],
‘phone’                 =>$data[‘phone’],
‘location’             =>$data[‘location’],
‘address’               =>$data[‘address’],
‘client_need’           =>$data[‘client_need’],
‘proposed_solution’     =>$data[‘proposed_solution’],
‘collaboration_prospect’=>$data[‘collaboration_prospect’],
‘remarks’               =>$data[‘remarks’],
‘contact_person’       =>$data[‘contact_person’],
‘assigned_to’           =>$data[‘assigned_to’],
‘added_by’             =>$this->session->userdata[‘id’]
);
$this->db->insert(‘clients’,$client);
return true;
}
public function update_client($data,$clientId){
$client=array(
‘name’                 =>$data[‘name’],
‘industry’             =>$data[‘industry’],
‘website’               =>$data[‘website’],
‘phone’                 =>$data[‘phone’],
‘location’             =>$data[‘location’],
‘address’               =>$data[‘address’],
‘client_need’           =>$data[‘client_need’],
‘proposed_solution’     =>$data[‘proposed_solution’],
‘collaboration_prospect’=>$data[‘collaboration_prospect’],
‘remarks’               =>$data[‘remarks’],
‘contact_person’       =>$data[‘contact_person’],
‘assigned_to’           =>$data[‘assigned_to’]
);

$this->db->WHERE(‘clients.id’,$clientId)->update(‘clients’,$client);
return true;
}

public function getClients()
{
$st=$this->db->query(‘SELECT clients.id, clients.name, clients.industry, clients.phone, clients.date, users.name as added_by
from clients
inner join users on users.id=clients.added_by’
);
return $st->result_array();
}
public function getAllClients()
{
$st=$this->db->query(‘SELECT * from clients ‘);
return $st->result_array();
}

public function markClientCalled($clientId)
{
$this->db->query(‘Update clients SET call_made=1, last_call_date=CURDATE() WHERE clients.id=’.$clientId);
return true;
}

public function getClientById($clientId){
$st=$this->db->query(‘SELECT clients.*, users.username as assigned_to, u.username as added_by from clients
inner join users on users.id=clients.assigned_to
inner join users u on u.id=clients.added_by
WHERE clients.id=’
.$clientId);
$data=$st->result_array();
return $data[0];
}

}

 

Now that we have the controller and the model we have to create the views. I have two folders in the view static and content I have placed head.php and header.php in static and rest of all views in content. The head.php contains links to css and js. The header.php has the navigation in it. Following is the head.php

You can see the folder structure of my view folder and the files in it. The code in them are as follow

Head.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 10:22 AM
*/
?>
<html>

<head>
<link rel=“stylesheet” type=“text/css” href=<?php echo base_url()?>css/bootstrap.min.css”>
<script src=<?php echo base_url()?>js/bootstrap.min.js”></script>
<title><?php echo $title;?></title>
</head>

 

Header.php

 
<div class=“container”>
<div >
<div class=“col-md-12” style=background: url(<?php echo base_url()?>img/header-receptionist.jpg’); height: 200px; ></div>
</div>
<div class=“clearfix”></div>
<div >
<ul class=nav nav-pills “>
<li role=“presentation” class=“active”><a href=<?php echo base_url()?>admin”>Home</a> </li>
<li role=“presentation”><a href=<?php echo base_url()?>admin/clients”>Clients</a> </li>
<li role=“presentation”><a href=<?php echo base_url()?>admin/add_clients”>Add Clients</a> </li>
<li role=“presentation”><a href=<?php echo base_url()?>admin/call_clients”>Call Clients</a> </li>
<li role=“presentation”><a href=<?php echo base_url()?>admin/logout”>Logout</a> </li>
</ul>
</div>
<div class=“clearfix”></div>

</div>

 

Content/login.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 12:11 PM
*/
?>
<div class=“container”>
<div class=“col-md-4”></div>
<div class=“col-md-4” >
<h2>Login Here</h2>
<?php
if
(isset($errors)){
?>
<div class=“alert alert-danger fade in”>
<a href=“#” class=“close” data-dismiss=“alert”>&times;</a>
<strong>Error!</strong> <?php echo ($errors);?>
</div>
<?php }?>
<form action=“” method=“post”>
<table class=“table” style=background-color: #C3C6CF>
<tr>
<td>
<input type=“text” name=“username” placeholder=“Username” class=“form-control”/>
</td>
</tr>
<tr>
<td>
<input type=“password” name=“password” placeholder=“********” class=“form-control”/>
</td>
</tr>
<tr>
<td>
<button type=“submit” class=“btn btn-danger btn-success”>LOGIN</button>
</td>
</tr>
</table>
</form>
</div>
</div>

 

Content/add_client.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 10:26 AM
*/
?>
<div class=“container”>
<div class=“col-md-12”>
<h3>Add Client</h3>

</div>
<div class=“clearfix”>

</div>
<div class=“col-md-6”>
<?php
if
(isset($errors)){
?>
<div class=“alert alert-danger fade in”>
<a href=“#” class=“close” data-dismiss=“alert”>&times;</a>
<strong>Error!</strong> <?php echo ($errors);?>
</div>
<?php }?>
<form action=“” method=“post”>
<table class=“table table-responsive table-bordered table-striped table-hover”>
<tr>
<td>Name</td>
<td>
<input type=“text” class=“form-control” name=“name” required=“required” />
</td>
</tr>
<tr>
<td>Industry</td>
<td>
<input type=“text” class=“form-control” name=“industry” required=“required” />
</td>
</tr>
<tr>
<td>Website</td>
<td>
<input type=“text” class=“form-control” name=“website” required=“required” />
</td>
</tr>
<tr>
<td>Phone</td>
<td>
<input type=“text” class=“form-control” name=“phone” required=“required” />
</td>
</tr>
<tr>
<td>Location</td>
<td>
<input type=“text” class=“form-control” name=“location” required=“required” />
</td>
</tr>
<tr>
<td>Address</td>
<td>
<textarea name=“address” rows=“2” class=“form-control” required=“required”></textarea>
</td>
</tr>
<tr>
<td>Client Needs</td>
<td>
<textarea name=“client_need” rows=“2” class=“form-control” required></textarea>
</td>
</tr>
<tr>
<td>Proposed Solution</td>
<td>
<textarea name=“proposed_solution” rows=“2” class=“form-control” required></textarea>
</td>
</tr>
<tr>
<td>Collaboration Prospects</td>
<td>
<textarea name=“collaboration_prospect” rows=“2” class=“form-control” required></textarea>
</td>
</tr>
<tr>
<td>Remarks</td>
<td>
<textarea name=“remarks” rows=“2” class=“form-control” required></textarea>
</td>
</tr>
<tr>
<td>Contact Person</td>
<td>
<input type=“text” class=“form-control” name=“contact_person” required=“required” />
</td>
</tr>
<tr>
<td>Assigned to</td>
<td>
<select name=“assigned_to” class=“form-control” required>
<option value=“”>Assign User</option>
<?php
for
($i=0;$i<count($users);$i++){
?>
<option value=<?php echo $users[$i][‘id’]?>><?php echo $users[$i][‘name’]?></option>
<?php }?>
</select>
</td>
</tr>

</table>
<button type=“submit” class=“btn btn-success”>ADD CLIENT</button>
<a href=<?php echo base_url()?>class=“btn btn-danger”>CANCEL</a>
</form>
</div>

</div>

 

Content/add_user.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 10:26 AM
*/
?>
<div class=“container”>
<div class=“col-md-12”>
<h3>Add User</h3>

</div>
<div class=“clearfix”>

</div>
<div class=“col-md-5”>
<?php
if
(isset($errors)){
?>
<div class=“alert alert-danger fade in”>
<a href=“#” class=“close” data-dismiss=“alert”>&times;</a>
<strong>Error!</strong> <?php echo ($errors);?>
</div>
<?php }?>
<form action=“” method=“post”>
<input type=“text” class=“form-control” name=“fullname” placeholder=“Full Name”><br>
<input type=“text” class=“form-control” name=“username” placeholder=“Username”><br>
<input type=“password” class=“form-control” name=“password” placeholder=“********”><br>
<button type=“submit” class=“btn btn-block btn-primary”>ADD USER</button>
<a href=<?php echo base_url()?>class=“btn btn-block btn-danger”>CANCEL</a>
</form>
</div>
<div class=“col-md-7”>
<table class=table ta”>
<tr style=background-color: #C3C6CF>
<td>User</td>
<td>Username</td>
<td>
Action
</td>
</tr>
<?php
for
($i=0;$i<count($users);$i++)
{?>
<tr>
<td><?php echo $users[$i][‘name’]?></td>
<td><?php echo $users[$i][‘username’]?></td>
<td>
<a href=“” class=“glyphicon glyphicon-edit” data=“Edit” title=“Edit”></a> |
<a style=color: red;href=“” class=“glyphicon glyphicon-remove-circle” data=“Delete” title=“Delete”> </a>
</td>
</tr>
<?php
}?>
</table>
</div>
</div>

 

Content/call_client.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 11:58 AM
*/

?>
<div class=“container”>

<table class=“table”>
<tr style=background-color: #9cacc2; color:#fff>
<td>Name</td>
<td>Industry</td>
<td>Phone</td>
<td>Added Date</td>
<td>Action</td>
</tr>
<?php
for
($i=0;$i<count($clients);$i++) {
?>
<tr >
<td><?php echo $clients[$i][‘name’]?></td>
<td><?php echo $clients[$i][‘industry’]?></td>
<td><?php echo $clients[$i][‘phone’]?></td>
<td><?php echo date(‘jS F, Y’,strtotime($clients[$i][‘date’]))?></td>
<td>
<?php
if
($clients[$i][‘call_made’]==0) {
?>
<a href=<?php echo base_url().‘admin/client_called/’.$clients[$i][‘id’]?>class=“btn btn-xs btn-success”>Call Client</a>
<?php
}else {
?>
Called on <?php echo date(‘jS F, Y’,strtotime($clients[$i][‘last_call_date’])) ?>
<a href=<?php echo base_url().‘admin/client_called/’.$clients[$i][‘id’]?>class=“btn btn-xs btn-danger”>Call Again</a>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</table>

</div>

 

Content/client_details.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/3/2016
* Time: 10:23 AM
*/

?>
<div class=“container”>
<div style=background-color: #005580; color: #fff; text-transform: uppercase; height: 90px; padding: 10px;>
<h3><?php echo $client[‘name’]?></h3>
</div>

<table class=“table table-striped table-hover”>
<tr>
<td>Industry</td>
<td>
<?php echo $client[‘industry’]?>
</td>
</tr>
<tr>
<td>Website</td>
<td>
<?php echo $client[‘website’]?>
</td>
</tr>
<tr>
<td>Phone</td>
<td>
<?php echo $client[‘phone’]?>
</td>
</tr>
<tr>
<td>Date Added</td>
<td>
<?php echo $client[‘date’]?>
</td>
</tr>
<tr>
<td>Location </td>
<td>
<?php echo $client[‘location’]?>
</td>
</tr>
<tr>
<td>Address</td>
<td>
<?php echo $client[‘address’]?>
</td>
</tr>
<tr>
<td>Client Needs</td>
<td>
<?php echo $client[‘client_need’]?>
</td>
</tr>
<tr>
<td>Proposed Solution</td>
<td>
<?php echo $client[‘proposed_solution’]?>
</td>
</tr>
<tr>
<td>Collaboration Prospect</td>
<td>
<?php echo $client[‘collaboration_prospect’]?>
</td>
</tr>
<tr>
<td>Call Made</td>
<td>
<?php if($client[‘call_made’]==0){
echo ‘No’;
}else{
echo ‘Yes’;
}?>
</td>
</tr>
<tr>
<td>Last Called on</td>
<td>
<?php if($client[‘call_made’]==0){
echo ‘Not Called Yet’;
}else{
echo $client[‘last_call_date’];
}?>
</td>
</tr>
<tr>
<td>Remarks</td>
<td>
<?php echo $client[‘remarks’]?>
</td>
</tr>
<tr>
<td>Contact Person</td>
<td>
<?php echo $client[‘contact_person’]?>
</td>
</tr>
<tr>
<td>Assigned to</td>
<td>
<?php echo $client[‘assigned_to’]?>
</td>
</tr>
<tr>
<td>Added By</td>
<td>
<?php echo $client[‘added_by’]?>
</td>
</tr>

</table>
</div>

 

Content / clients.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 11:58 AM
*/

?>
<div class=“container”>

<table class=“table”>
<tr style=background-color: #9cacc2; color:#fff>
<td>Name</td>
<td>Industry</td>
<td>Phone</td>
<td>Added Date</td>
<td>Added By</td>
<td>Action</td>
</tr>
<?php
for
($i=0;$i<count($clients);$i++) {
?>
<tr >
<td><?php echo $clients[$i][‘name’]?></td>
<td><?php echo $clients[$i][‘industry’]?></td>
<td><?php echo $clients[$i][‘phone’]?></td>
<td><?php echo date(‘jS F, Y’,strtotime($clients[$i][‘date’]))?></td>
<td><?php echo $clients[$i][‘added_by’]?></td>
<td>
<a href=<?php echo base_url().‘admin/client_detail/’.$clients[$i][‘id’].‘/’.implode(‘-‘,explode(‘ ‘,$clients[$i][‘name’]))?>>View</a> //
<a href=<?php echo base_url().‘admin/edit_client/’.$clients[$i][‘id’].‘/’.implode(‘-‘,explode(‘ ‘,$clients[$i][‘name’]))?>>Edit</a> //
<a href=“” >Delete</a>
</td>
</tr>
<?php
}
?>
</table>

</div>

 

Content/edit_client.php

<?php
/**
* Created by PhpStorm.
* User: Mudassar
* Date: 3/2/2016
* Time: 10:26 AM
*/

?>
<div class=“container”>
<div class=“col-md-12”>
<h3>Edit Client</h3>

</div>
<div class=“clearfix”>

</div>
<div class=“col-md-6”>
<?php
if
(isset($errors)){
?>
<div class=“alert alert-danger fade in”>
<a href=“#” class=“close” data-dismiss=“alert”>&times;</a>
<strong>Error!</strong> <?php echo ($errors);?>
</div>
<?php }?>
<form action=“” method=“post”>
<table class=“table table-responsive table-bordered table-striped table-hover”>
<tr>
<td>Name</td>
<td>
<input type=“text” class=“form-control” name=“name” required=“required” value=<?php echo $client[‘name’]?>/>
</td>
</tr>
<tr>
<td>Industry</td>
<td>
<input type=“text” class=“form-control” name=“industry” required=“required” value=<?php echo $client[‘industry’]?>/>
</td>
</tr>
<tr>
<td>Website</td>
<td>
<input type=“text” class=“form-control” name=“website” required=“required” value=<?php echo $client[‘website’]?>/>
</td>
</tr>
<tr>
<td>Phone</td>
<td>
<input type=“text” class=“form-control” name=“phone” value=<?php echo $client[‘phone’]?>required=“required” />
</td>
</tr>
<tr>
<td>Location</td>
<td>
<input type=“text” class=“form-control” name=“location” value=<?php echo $client[‘location’]?>required=“required” />
</td>
</tr>
<tr>
<td>Address</td>
<td>
<textarea name=“address” rows=“2” class=“form-control” value=“” required=“required”><?php echo $client[‘address’]?></textarea>
</td>
</tr>
<tr>
<td>Client Needs</td>
<td>
<textarea name=“client_need” rows=“2” class=“form-control” value=“” required><?php echo $client[‘client_need’]?></textarea>
</td>
</tr>
<tr>
<td>Proposed Solution</td>
<td>
<textarea name=“proposed_solution” rows=“2” class=“form-control” value=“” required><?php echo $client[‘proposed_solution’]?></textarea>
</td>
</tr>
<tr>
<td>Collaboration Prospects</td>
<td>
<textarea name=“collaboration_prospect” rows=“2” class=“form-control” required value=“”><?php echo $client[‘collaboration_prospect’]?></textarea>
</td>
</tr>
<tr>
<td>Remarks</td>
<td>
<textarea name=“remarks” rows=“2” class=“form-control” required><?php echo $client[‘remarks’]?></textarea>
</td>
</tr>
<tr>
<td>Contact Person</td>
<td>
<input type=“text” class=“form-control” name=“contact_person” value=<?php echo $client[‘contact_person’]?>required=“required” />
</td>
</tr>
<tr>
<td>Assigned to</td>
<td>
<select name=“assigned_to” class=“form-control” required>
<option value=“”>Assign User</option>
<?php
for
($i=0;$i<count($users);$i++){
?>
<option <?php
if
($users[$i][‘name’]==$client[‘assigned_to’]){
echo ‘selected’;
}
?> value=<?php echo $users[$i][‘id’]?>><?php echo $users[$i][‘name’]?></option>
<?php }?>
</select>
</td>
</tr>

</table>
<button type=“submit” class=“btn btn-primary>UPDATE CLIENT</button>
<a href=<?php echo base_url()?>class=“btn btn-danger”>CANCEL</a>
</form>
</div>

</div>

 

Alright Folks! Your basic application is complete, you can copy paste all the code in your codeigniter, if you get stuck call me on skype malik_cozmuler or mail me malikmudassar@gmail.com . The only stunt here is that if you have empty database you can’t login because to login you require username and password, I can give you a solution, create an empty database and in your SQL editor paste the following

 

 

CREATE TABLE IF NOT EXISTS `clients` (

`id` int(10) NOT NULL AUTO_INCREMENT,

`name` varchar(55) NOT NULL,

`industry` varchar(100) NOT NULL,

`website` varchar(100) NOT NULL,

`phone` varchar(18) NOT NULL,

`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

`location` varchar(150) NOT NULL,

`address` varchar(250) NOT NULL,

`client_need` text NOT NULL,

`proposed_solution` text NOT NULL,

`collaboration_prospect` text NOT NULL,

`call_made` int(1) NOT NULL,

`last_call_date` date NOT NULL,

`remarks` text NOT NULL,

`contact_person` varchar(50) NOT NULL,

`assigned_to` int(11) NOT NULL,

`added_by` int(3) NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

 

— Dumping data for table `clients`

 

INSERT INTO `clients` (`id`, `name`, `industry`, `website`, `phone`, `date`, `location`, `address`, `client_need`, `proposed_solution`, `collaboration_prospect`, `call_made`, `last_call_date`, `remarks`, `contact_person`, `assigned_to`, `added_by`) VALUES

(1, ‘Ali Raza Shah’, ‘Information Technology’, ‘www.getrishta.com’, ‘54654654’, ‘2016-03-02 09:57:54’, ‘islamabad, pakistan’, ‘Blue Area’, ‘Website’, ‘Web Portal’, ‘somethign’, 1, ‘2016-03-03’, ‘something’, ‘ali paracha’, 1, 2),

(2, ‘mudassar’, ‘IT’, ‘website’, ‘564654654’, ‘2016-03-02 11:36:47’, ‘Sargodah’, ‘Pakistan’, ‘proposal’, ‘not probided’, ‘not yet decided’, 1, ‘2016-03-02’, ‘asdlfjasdkfj’, ‘mudassar’, 2, 1);

 

— ——————————————————–

 

— Table structure for table `users`

 

CREATE TABLE IF NOT EXISTS `users` (

`id` int(3) NOT NULL AUTO_INCREMENT,

`name` varchar(50) NOT NULL,

`username` varchar(50) NOT NULL,

`password` varchar(128) NOT NULL,

`status` int(1) NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

 

— Dumping data for table `users`

 

INSERT INTO `users` (`id`, `name`, `username`, `password`, `status`) VALUES

(1, ‘Malik Mudassar’, ‘malikmudassar’, ‘a7777999e260290f68a1455cacdabf6c’, 0),

(2, ‘Nouman’, ‘nouman’, ‘a7777999e260290f68a1455cacdabf6c’, 0);

 

Alright, this will give you basic two tables and will dump some data in it you can login by username malikmudassar and password Muhammad rest you can add as many users you can

 

Best of Luck Folks