Skip to content

Commit

Permalink
Prisoners and Criminal Cases tabs are finished
Browse files Browse the repository at this point in the history
Photo upload part of prisoners are remaining.
  • Loading branch information
hpardess committed Mar 20, 2016
1 parent f23ba6c commit 9a8a4f0
Show file tree
Hide file tree
Showing 23 changed files with 10,153 additions and 214 deletions.
83 changes: 73 additions & 10 deletions application/controllers/Crime.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ public function __construct()
redirect('/login');
}
$this->load->model('crime_model');
$this->load->model("province_model");
$this->load->model('district_model');
}

public function index()
{
$this->load->view('crime_list');
$data['provincesList'] = $this->province_model->get_all();
$data['districtsList'] = $this->district_model->get_all();
$this->load->view('crime_list', $data);
}

public function crime_list()
Expand All @@ -25,13 +29,13 @@ public function crime_list()
$aColumns = array(
'id',
'crime_date',
'crime_location',
'arrist_location',
'police_custody',
'crime_province_id',
'crime_location',
'crime_district_id',
'arrist_province_id',
'arrist_district_id');
'crime_province_id',
'arrest_location',
'arrest_district_id',
'arrest_province_id');

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
Expand All @@ -52,10 +56,69 @@ public function crime_list()
echo json_encode($results);
}

public function new_crime()
// public function new_crime()
// {
// $provinceList = $this->province_model->get_all();
// echo json_encode($provinceList);
// }

public function view($id)
{
$this->load->model('province_model');
$provinceList = $this->province_model->get_all();
echo json_encode($provinceList);
$result = $this->crime_model->get_by_id($id);
echo json_encode($result);
}

public function edit($id)
{
$crime = $this->crime_model->get_by_id($id);

$result = array();
$result['crime'] = $crime;
$result['crimeDistricts'] = $this->district_model->get_by_province_id($crime->crime_province_id);
$result['arrestDistricts'] = $this->district_model->get_by_province_id($crime->arrest_province_id);

echo json_encode($result);
}

public function delete($id)
{
$this->crime_model->delete_by_id($id);
echo json_encode(array("status" => TRUE));
}

// add new record
public function add()
{
$data = array(
'crime_date' => $this->input->post('crimeDate'),
'police_custody' => $this->input->post('policeCustody'),
'crime_province_id' => $this->input->post('crimeProvince'),
'crime_district_id' => $this->input->post('crimeDistrict'),
'crime_location' => $this->input->post('crimeLocation'),
'arrest_province_id' => $this->input->post('arrestProvince'),
'arrest_district_id' => $this->input->post('arrestDistrict'),
'arrest_location' => $this->input->post('arrestLocation')
);
$insert = $this->crime_model->create($data);
// log_message('debug', 'insert: ' . $insert);
echo json_encode(array("status" => TRUE));
}

// update exisitn record
public function update()
{
$data = array(
'crime_date' => $this->input->post('crimeDate'),
'police_custody' => $this->input->post('policeCustody'),
'crime_province_id' => $this->input->post('crimeProvince'),
'crime_district_id' => $this->input->post('crimeDistrict'),
'crime_location' => $this->input->post('crimeLocation'),
'arrest_province_id' => $this->input->post('arrestProvince'),
'arrest_district_id' => $this->input->post('arrestDistrict'),
'arrest_location' => $this->input->post('arrestLocation')
);
$affected_rows = $this->crime_model->update(array('id' => $this->input->post('id')), $data);
// log_message('debug', 'affected rows: ' . $affected_rows);
echo json_encode(array("status" => TRUE));
}
}
108 changes: 97 additions & 11 deletions application/controllers/Prisoner.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ public function __construct()
redirect('/login');
}
$this->load->model('prisoner_model');
$this->load->model("province_model");
$this->load->model('district_model');
$this->load->model('marital_status_model');

// File upload config
$config['upload_path'] = './photos/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
}

public function index()
{
$this->load->view('prisoner_list');
$data['provincesList'] = $this->province_model->get_all();
$data['districtsList'] = $this->district_model->get_all();
$data['maritalStatusList'] = $this->marital_status_model->get_all();
$this->load->view('prisoner_list', $data);
}

public function prisoner_list()
Expand All @@ -24,17 +38,17 @@ public function prisoner_list()

$aColumns = array(
'id',
'marital_status_id',
'present_province_id',
'present_district_id',
'permanent_province_id',
'permanent_district_id',
'name',
'father_name',
'grand_father_name',
'age',
'criminal_history',
'marital_status_id',
'num_of_children',
'criminal_history',
'permanent_province_id',
'permanent_district_id',
'present_province_id',
'present_district_id',
'profile_pic');

/* Indexed column (used for fast and accurate table cardinality) */
Expand All @@ -56,10 +70,82 @@ public function prisoner_list()
echo json_encode($results);
}

public function new_prisoner()
// public function new_prisoner()
// {
// $this->load->model('province_model');
// $provinceList = $this->province_model->get_all();
// echo json_encode($provinceList);
// }

public function view($id)
{
$this->load->model('province_model');
$provinceList = $this->province_model->get_all();
echo json_encode($provinceList);
$result = $this->prisoner_model->get_by_id($id);
echo json_encode($result);
}

public function edit($id)
{
$prisoner = $this->prisoner_model->get_by_id($id);

$result = array();
$result['prisoner'] = $prisoner;
$result['permanentDistricts'] = $this->district_model->get_by_province_id($prisoner->permanent_province_id);
$result['presentDistricts'] = $this->district_model->get_by_province_id($prisoner->present_province_id);

echo json_encode($result);
}

public function delete($id)
{
$this->prisoner_model->delete_by_id($id);
echo json_encode(array("status" => TRUE));
}

// add new record
public function add()
{
$criminal_history = $this->input->post('criminalHistory');

$data = array(
'name' => $this->input->post('name'),
'father_name' => $this->input->post('fatherName'),
'grand_father_name' => $this->input->post('grandFatherName'),
'age' => $this->input->post('age'),
'marital_status_id' => $this->input->post('maritalStatus'),
'num_of_children' => $this->input->post('numOfChildren'),
'criminal_history' => isset($criminal_history)? 1: 0,
'permanent_province_id' => $this->input->post('permanentProvince'),
'permanent_district_id' => $this->input->post('permanentDistrict'),
'present_province_id' => $this->input->post('presentProvince'),
'present_district_id' => $this->input->post('presentDistrict'),
'profile_pic' => $this->input->post('profilePic')
);
$insert = $this->prisoner_model->create($data);
// log_message('debug', 'insert: ' . $insert);
echo json_encode(array("status" => TRUE));
}

// update exisitn record
public function update()
{
$criminal_history = $this->input->post('criminalHistory');

$data = array(
'name' => $this->input->post('name'),
'father_name' => $this->input->post('fatherName'),
'grand_father_name' => $this->input->post('grandFatherName'),
'age' => $this->input->post('age'),
'marital_status_id' => $this->input->post('maritalStatus'),
'num_of_children' => $this->input->post('numOfChildren'),
'criminal_history' => isset($criminal_history)? 1: 0,
'permanent_province_id' => $this->input->post('permanentProvince'),
'permanent_district_id' => $this->input->post('permanentDistrict'),
'present_province_id' => $this->input->post('presentProvince'),
'present_district_id' => $this->input->post('presentDistrict'),
'profile_pic' => $this->input->post('profilePic')
);
$affected_rows = $this->prisoner_model->update(array('id' => $this->input->post('id')), $data);
// log_message('debug', 'affected rows: ' . $affected_rows);
echo json_encode(array("status" => TRUE));
}
}
22 changes: 22 additions & 0 deletions application/controllers/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,26 @@ public function update()
// log_message('debug', 'affected rows: ' . $affected_rows);
echo json_encode(array("status" => TRUE));
}

public function change_password()
{
$username = $this->session->userdata('username');
$currentPass = $this->input->post("curPsw");
$newPass = $this->input->post("newPsw");
$confirmNewPass = $this->input->post("confNewPsw");

if ($newPass == $confirmNewPass && $this->user_model->check_user($username, $currentPass))
{

$data = array(
'password' => md5($newPass)
);
$affected_rows = $this->user_model->update(array('id' => $this->session->userdata('id')), $data);
echo json_encode(array("status" => TRUE));
}
else
{
return false;
}
}
}
2 changes: 2 additions & 0 deletions application/language/dari/dari_lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$lang['hello'] = 'سلام';
2 changes: 2 additions & 0 deletions application/language/english/english_lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$lang['hello'] = 'Hello';
2 changes: 2 additions & 0 deletions application/language/pashto/pashto_lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$lang['hello'] = 'سلام';
Loading

0 comments on commit 9a8a4f0

Please sign in to comment.