Commit 56c0da32 by Jansa Jose

webservice for service provider and mechanic data in admin panel

parent 31deb365
......@@ -37,7 +37,7 @@ class Bookings extends CI_Controller {
$template['smenu'] = "View Bookings";
$template['mechanic_id'] = ($this->session->userdata('user_type')==1 &&
empty($mechanic_id))?'1':$mechanic_id;
empty($mechanic_id))?'':$mechanic_id;
$template['mechanic_data'] = $mechanic_data;
$template['bookingData'] = $this->Booking_model->getMechBookings($mechanic_id,'','0,1,3,4');
$this->load->view('template',$template);
......@@ -45,9 +45,11 @@ class Bookings extends CI_Controller {
public function changeBookingStatus($booking_id = '', $status = '', $mechanic_id = ''){
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
$mechanic_id = ($this->session->userdata('user_type') == 1 && !empty($mechanic_id))?$mechanic_id:'';
if(empty($booking_id) || $status == ''){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Bookings/listBookings'));
redirect(base_url('Bookings/listBookings/'.$mechanic_id));
}
$booking_id = decode_param($booking_id);
......
......@@ -186,6 +186,60 @@
echo json_encode($respArr); exit;
}
// customer_registration
public function service_provider_registration(){
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'0','message'=>'Something went wrong.');
if(empty($postData)){
echo json_encode($respArr);exit;
}
$err = 0;
$msg = '';
if(!isset($postData['email']) || empty($postData['email'])){
$err = 1;
$msg = 'Provide a valid Email ID';
}
else if(!isset($postData['password']) || empty($postData['password'] = md5($postData['password']))){
$err = 1;
$msg = 'Provide a Password';
}
else if(!isset($postData['first_name']) || empty($postData['first_name'])){
$err = 1;
$msg = 'Provide valid Name';
}
else if(!isset($postData['last_name']) || empty($postData['last_name'])){
$err = 1;
$msg = 'Provide valid Name';
}
else if(!isset($postData['phone']) || empty($postData['phone'])){
$err = 1;
$msg = 'Provide valid Phone Number';
}
if($err == 1){
$respArr['message'] = $msg;
echo json_encode($respArr);exit;
}
$custResp = $this->Webservice_model->createServiceProvider($postData);
if($custResp == '0'){
$respArr['message'] = 'Something went wrong.';
} else if($custResp == '1'){
$respArr['status'] = '1';
$respArr['message'] = 'Success';
} else if($custResp == '2'){
$respArr['message'] = 'Email Address already in use';
} else if($custResp == '3'){
$respArr['message'] = 'Phone already in use';
}
echo json_encode($respArr); exit;
}
// getGeneralIssues
public function getGeneralIssues(){
header('Content-type: application/json');
......
......@@ -47,6 +47,54 @@ class Webservice_model extends CI_Model {
return $respArr;
}
function createServiceProvider($provider_data = array()){
if(empty($provider_data))
return 0;
if(isset($provider_data['email']) && !empty($provider_data['email'])){
$emailChk = $this->db->get_where('admin_users',array('username'=>$provider_data['email'],'status !='=>'2'));
if(!empty($emailChk) && $emailChk->num_rows() > 0){
return 2;
}
}
if(isset($provider_data['phone']) && !empty($provider_data['phone'])){
$phoneChk = $this->db->get_where('mechanic',array('phone'=>$provider_data['phone']));
if(!empty($phoneChk) && $phoneChk->num_rows() > 0){
return 3;
}
}
$status = $this->db->insert('admin_users',
array('username'=>$provider_data['email'],
'password'=>md5($provider_data['password']),
'display_name'=>$provider_data['first_name'].' '.$provider_data['last_name'],
'user_type'=>'2','status'=>'1'));
if(!$status){
return 0;
}
$mechanic_id = $this->db->insert_id();
$status = $this->db->insert('mechanic',
array('mechanic_id'=>$mechanic_id,
'city'=>'',
'phone'=>$provider_data['phone'],
'state'=>'',
'shop_id'=>'',
'address'=>'',
'licence'=>'',
'location'=>'',
'email_id'=>$provider_data['email'],
'end_time'=>'',
'last_name'=>$provider_data['last_name'],
'start_time'=>'',
'first_name'=>$provider_data['first_name'],
'location_lat'=>'',
'location_lng'=>'',
'licence_number'=>'',
'licence_exp_date'=>''));
return ($status)?1:0;
}
public function insert_auth($id){
$static_string = time();
$authToken = 'Dcarfixs'.sha1($static_string);
......
......@@ -60,7 +60,7 @@
</div>
</div>
<?php }
if($this->session->userdata['user_type'] != 1 || ($this->session->userdata['user_type'] == 1 && !empty($mechanic_id))){ ?>
if($this->session->userdata['user_type'] != 1 || ($this->session->userdata['user_type'] == 1)){ ?>
<div class="col-xs-12">
<div class="box box-warning">
<div class="box-body">
......@@ -105,11 +105,11 @@
<i class="fa fa-fw fa-edit"></i>View Quote
</button>
<?php if($bookData->status == 1){ ?>
<a class="btn btn-sm btn-success" style="background-color:#ac2925" href="<?= base_url("Bookings/changeBookingStatus/".encode_param($bookData->booking_id)."/3/".encode_param($mechanic_id)) ?>">
<a class="btn btn-sm btn-success" style="background-color:#ac2925" href="<?= base_url("Bookings/changeBookingStatus/".encode_param($bookData->booking_id)."/4/".encode_param($mechanic_id)) ?>">
<i class="fa fa-cog"></i> Cancel
</a>
<?php } ?>
<?php if($bookData->status == 0 || $bookData->status == 3){ ?>
<?php if($bookData->status == 0 || $bookData->status == 4){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url("Bookings/changeBookingStatus/".encode_param($bookData->booking_id)."/1/".encode_param($mechanic_id)) ?>">
<i class="fa fa-cog"></i> Accept
</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment