Commit 6e432117 by Jansa Jose

change webservice name

parent c5a2b6d4
...@@ -34,18 +34,20 @@ class ImportData extends CI_Controller { ...@@ -34,18 +34,20 @@ class ImportData extends CI_Controller {
$this->load->model('Mechanic_model'); $this->load->model('Mechanic_model');
if(isset($files) && !empty($files)){ if(isset($files) && !empty($files)){
$filename=$_FILES["file"]["name"]; $filename=$_FILES["file"]["name"];
$ext=pathinfo($filename, PATHINFO_EXTENSION); $ext=pathinfo($filename, PATHINFO_EXTENSION);
if($ext=="csv")
{ if($ext=="csv"){
$file = fopen($filename, "r");
$err = 0;
$errMsg = '';
$count = 0; $count = 0;
$new = array(); $respMsg = '';
$respError = 0;
$respSuccess = 0;
$file = fopen($filename, "r");
while (($mechData = fgetcsv($file, 10000, ",")) !== FALSE){ while (($mechData = fgetcsv($file, 10000, ",")) !== FALSE){
$err = 0;
$count++; $count++;
$errMsg = '';
$new = array();
if($count == 1){ if($count == 1){
continue; continue;
} }
...@@ -100,6 +102,11 @@ class ImportData extends CI_Controller { ...@@ -100,6 +102,11 @@ class ImportData extends CI_Controller {
$errMsg = 'Provide a Valid Functional Area'; $errMsg = 'Provide a Valid Functional Area';
} }
if($err == 1){
$respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', '.$errMsg;
}
$mechData[2] = md5($mechData[2]); $mechData[2] = md5($mechData[2]);
$new = array( $new = array(
'first_name'=>$mechData[0], 'first_name'=>$mechData[0],
...@@ -123,11 +130,28 @@ class ImportData extends CI_Controller { ...@@ -123,11 +130,28 @@ class ImportData extends CI_Controller {
'profile_image'=>'', 'profile_image'=>'',
'shop_id'=>0 'shop_id'=>0
); );
$status = $this->Mechanic_model->addMechanic($new); $status = $this->Mechanic_model->addMechanic($new);
if($status == '1'){
$respSuccess++;
} else if($status == 2){
$respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', Email ID already exist.';
} else if($status == 3){
$respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', Phone Number already exist.';
} else if($status == 4){
$respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', User Name already exist.';
} else {
$respError++;
$respMsg .= '<br>ERROR : Row-'.($count-1).', Data Error.';
}
} }
if($count > 0){ if($count > 0){
$flashMsg = array('message'=>($count -1).' Data Inserted Successfully','class'=>'success'); $respMsg = "Successfully Uploaded File with, ".
$respSuccess.": Success & ".$respError.": Errors.<br>".$respMsg;
$flashMsg = array('message'=>$respMsg,'class'=>'success');
$this->session->set_flashdata('message', $flashMsg); $this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data')); redirect(base_url('ImportData/import_data'));
} }
...@@ -137,23 +161,5 @@ class ImportData extends CI_Controller { ...@@ -137,23 +161,5 @@ class ImportData extends CI_Controller {
// $filename=$_FILES["brand_logo"]["name"];
// $ext=pathinfo($filename, PATHINFO_EXTENSION);
// if($ext=="csv")
// {
// $file = fopen($filename, "r");
// while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
// {
// $sql = "INSERT into import(product_id,name,brand_name,short_description,part_id,vehicle_model,amount,status) values('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]','$emapData[7]')";
// $this->db->query($sql);
// }
// fclose($file);
// echo "CSV File has been successfully Imported.";
// }
} }
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
!isset($postData['password']) || empty($postData['password'] = md5($postData['password']))){ !isset($postData['password']) || empty($postData['password'] = md5($postData['password']))){
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$respArr = $this->Webservice_driver_model->checkMechanicLogin($postData); $respArr = $this->Webservice_mechanic_model->checkMechanicLogin($postData);
echo json_encode($respArr); exit; echo json_encode($respArr); exit;
} }
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_driver_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
...@@ -83,9 +83,9 @@ ...@@ -83,9 +83,9 @@
$start = ($page - 1) * $per_page; $start = ($page - 1) * $per_page;
$postData['mechanic_id'] = $authRes['data']['mechanic_id']; $postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_driver_model->getBookedService($postData,0,0,1); $bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,1);
$bookDataResult = $this->Webservice_driver_model->getBookedService($postData,$start,$per_page,1); $bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,1);
$total = 0; $total = 0;
if($bookDataCount['status'] == 'success'){ if($bookDataCount['status'] == 'success'){
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_driver_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
return $respArr; return $respArr;
} }
$respArr = $this->Webservice_driver_model->getBookedService($postData); $respArr = $this->Webservice_mechanic_model->getBookedService($postData);
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_driver_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
...@@ -180,8 +180,8 @@ ...@@ -180,8 +180,8 @@
$postData = json_decode($post, true); $postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id']; $postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_driver_model->getBookedService($postData,0,0,2); $bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,2);
$bookDataResult = $this->Webservice_driver_model->getBookedService($postData,$start,$per_page,2); $bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,2);
$total = 0; $total = 0;
if($bookDataCount['status'] == 'success'){ if($bookDataCount['status'] == 'success'){
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_driver_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
...@@ -247,8 +247,8 @@ ...@@ -247,8 +247,8 @@
$postData = json_decode($post, true); $postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id']; $postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_driver_model->getBookedService($postData,0,0,3); $bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,3);
$bookDataResult = $this->Webservice_driver_model->getBookedService($postData,$start,$per_page,0,3); $bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,0,3);
$total = 0; $total = 0;
if($bookDataCount['status'] == 'success'){ if($bookDataCount['status'] == 'success'){
......
...@@ -5,42 +5,5 @@ class Import_model extends CI_Model { ...@@ -5,42 +5,5 @@ class Import_model extends CI_Model {
parent::_construct(); parent::_construct();
} }
public function addShop($shop_data = array()){
if(empty($shop_data)){
return 0;
}
$status = $this->db->insert('mechanic_shop',$shop_data);
return ($status)?1:0;
}
function getShop($shop_id = '',$view_all = 0){
$cond = ($view_all != 0)?' status IN (0,1) ':' status IN (1) ';
$cond .= (!empty($shop_id))?" AND shop_id = '$shop_id'":"";
$result = $this->db->query("SELECT * FROM mechanic_shop WHERE $cond");
if(empty($result)){
return;
}
return (empty($shop_id))?$result->result():$result->row();
}
function changeStatus($shop_id = '', $status = '0'){
if(empty($shop_id)){
return 0;
}
$status = $this->db->update('mechanic_shop',array('status'=>$status), array('shop_id'=>$shop_id));
return $status;
}
function updateShop($shop_id = '', $shop_data = array()){
if(empty($shop_id) || empty($shop_data)){
return 0;
}
$status = $this->db->update('mechanic_shop',$shop_data,array('shop_id'=>$shop_id));
return ($status)?1:0;
}
} }
?> ?>
\ No newline at end of file
<div class="content-wrapper">
<section class="content-header">
<h1>
<?= $pTitle ?>
<small><?= $pDescription ?></small>
</h1>
<ol class="breadcrumb">
<li><a href="<?= base_url() ?>"><i class="fa fa-star-o" aria-hidden="true"></i>Home</a></li>
<li><?= $menu ?></li>
<li class="active"><?= $smenu ?></li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="col-md-12">
<?php
$url = (!isset($import_id) || empty($import_id))?'ImportData/importCsvData':'';
if($this->session->flashdata('message')) {
$flashdata = $this->session->flashdata('message'); ?>
<div class="alert alert-<?= $flashdata['class'] ?>">
<button class="close" data-dismiss="alert" type="button">×</button>
<div><?= $flashdata['message'] ?></div>
</div>
<?php } ?>
</div>
<div class="col-md-12">
<div class="box box-warning">
<div class="box-body">
<form role="form" action="<?= base_url($url) ?>" method="post"
class="validate" data-parsley-validate="" enctype="multipart/form-data">
<div class="col-md-12">
<div class="col-md-6">
<div class="form-group">
<label>Select Import Type</label>
<select name="import_id" id="import_id" class="form-control required" placeholder="Select Brand" required="">
<option selected disabled>Uploaded Type</option>
<option value = "1">Mechanic Details</option>
<option value = "2">Customer Details</option>
<option value = "3">Product Details</option>
</select>
</div>
</div>
<div class="col-md-6 hide" id="import_file">
<div class="form-group">
<label>Import File</label>
<div class="col-md-12" style="padding-bottom:10px;">
<div class="col-md-3">
<img id="brand_image" src="<?= (isset($brand_data->brand_logo))?base_url($brand_data->brand_logo):'' ?>" onerror="this.src='<?=base_url("assets/images/no_image.png")?>';" height="75" width="75" />
</div>
<div class="col-md-9" style="padding-top: 25px;">
<input name="file" type="file" accept=".csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
onchange="setImg(this,'brand_image');" />
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="box-footer textCenterAlign">
<button type="submit" class="btn btn-primary">Submit</button>
<a href="<?= base_url('Brand/viewbrands') ?>" class="btn btn-primary">Cancel</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
\ No newline at end of file
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