Commit b42023fe by Tobin

daily commit

parent 2e54f5ca
......@@ -41,7 +41,7 @@ class Webservices extends CI_Controller {
// $this->last_id = set_log($class, $method, $postdata, $auth);
}
// login
// customer_login
public function customer_login(){
header('Content-type: application/json');
$post = file_get_contents("php://input");
......@@ -79,5 +79,107 @@ class Webservices extends CI_Controller {
}
echo json_encode($respArr); exit;
}
// customer_forgot_password
public function customer_forgot_password(){
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$this->load->model('Customer_model');
$respArr = array('status'=>'0','message'=>'Required Fields are empty.');
if(empty($postData) || !isset($postData['email']) || empty($postData['email'])){
echo json_encode($respArr);exit;
}
$custResp = $this->Customer_model->genCustForgotPassLink($postData);
if(empty($custResp) || !isset($custResp['status']) || empty($custResp['status'])){
echo json_encode($respArr);exit;
}
if($custResp['status'] == '2'){
$respArr['status'] = '2';
$respArr['message'] = 'Invalid Email Address';
echo json_encode($respArr);exit;
}
if($custResp['status'] == '1'){
/*
MAIL SENT CONFIGARATION
*/
$respArr['status'] = '1';
$respArr['message'] = 'Password Reset Email has been sent';
}
echo json_encode($respArr); exit;
}
// customer_registration
public function customer_registration(){
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$this->load->model('Customer_model');
$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'])){
$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';
}
if($err == 1){
$respArr['message'] = $msg;
echo json_encode($respArr);exit;
}
if(isset($postData['phone']) && empty($postData['phone'])){
unset($postData['phone']);
}
unset($postData['promocode']);
$custResp = $this->Customer_model->customer_registration($postData);
if(empty($custResp) || !isset($custResp['status']) || empty($custResp['status'])){
echo json_encode($respArr);exit;
}
if($custResp['status'] == '2'){
$respArr['status'] = '2';
$respArr['message'] = 'Email Address already in use';
echo json_encode($respArr);exit;
}
if($custResp['status'] == '1'){
$custResp = $this->Customer_model->checkCustomerLogin($postData);
if(empty($custResp) || !isset($custResp['status']) || empty($custResp['status'])){
echo json_encode($respArr);exit;
}
if($custResp['status'] == '1'){
$respArr['data'] = $custResp['data'];
$respArr['status'] = '1';
$respArr['message'] = 'Success';
echo json_encode($respArr);exit;
}
}
echo json_encode($respArr); exit;
}
}
?>
......@@ -67,27 +67,32 @@
return $decode;
}
function getLocationLatLng($location = ''){
$settings = getSettings();
function getLocationLatLng($location = ''){
$settings = getSettings();
if(empty($location) || empty($settings) || !isset($settings['google_api_key']) ||
empty($gKey = $settings['google_api_key'])){
return 0;
}
$thisObj = & get_instance();
$locData = file_get_contents("https://maps.google.com/maps/api/geocode/json?address=".
urlencode($location)."&sensor=false&key=".$gKey);
if(empty($locData))
return 0;
$loc_data = json_decode($locData);
if(empty($loc_data) || !isset($loc_data->status) || $loc_data->status != 'OK')
return 0;
if(empty($location) || empty($settings) || !isset($settings['google_api_key']) ||
empty($gKey = $settings['google_api_key'])){
return 0;
}
$thisObj = & get_instance();
$locData = file_get_contents("https://maps.google.com/maps/api/geocode/json?address=".
urlencode($location)."&sensor=false&key=".$gKey);
if(empty($locData))
return 0;
$loc_data = json_decode($locData);
if(empty($loc_data) || !isset($loc_data->status) || $loc_data->status != 'OK')
return 0;
$locArr['lat'] = $loc_data->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$locArr['lng'] = $loc_data->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
$locArr['lat'] = $loc_data->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$locArr['lng'] = $loc_data->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
if(empty($locArr['lat']) || empty($locArr['lng']))
return 0;
return $locArr;
}
if(empty($locArr['lat']) || empty($locArr['lng']))
return 0;
return $locArr;
}
function generate_unique() {
$unique = md5(uniqid(time().mt_rand(), true));
return $unique;
}
?>
\ No newline at end of file
......@@ -108,5 +108,46 @@ class Customer_model extends CI_Model {
}
return $respArr;
}
function genCustForgotPassLink($userLogData = array()){
$respArr = array('status'=>0);
if(empty($userLogData)){
return $respArr;
}
$result = $this->db->get_where('customers',array('email'=>$userLogData['email'],'status'=>'1'));
if(empty($result) || $result->num_rows() < 1 || empty($custData = $result->row())){
$respArr['status'] = 2;
return $respArr;
}
$mail_id = $custData->email;
$cust_id = $custData->customer_id;
$unique_id = generate_unique();
$status = $this->db->insert('forgot_password_link',array('user_type'=>'1','user_id'=>$cust_id,
'token'=>$unique_id));
if($status){
$respArr['status'] = 1;
}
return $respArr;
}
function customer_registration($userData = array()){
$respArr = array('status'=>0);
if(empty($userData)){
return $respArr;
}
$result = $this->db->get_where('customers',array('email'=>$userData['email'],'status'=>'1'));
if(!empty($result) && $result->num_rows() >= 1){
$respArr['status'] = 2;
return $respArr;
}
$userData['password'] = md5($userData['password']);
$status = $this->db->insert('customers',$userData);
if($status){
$respArr['status'] = 1;
}
return $respArr;
}
}
?>
\ No newline at end of file
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Host: db
-- Generation Time: Dec 28, 2018 at 12:21 PM
-- Server version: 5.6.41
-- PHP Version: 7.2.8
-- Host: 127.0.0.1:3306
-- Generation Time: Dec 30, 2018 at 07:28 PM
-- Server version: 5.7.21
-- PHP Version: 5.6.35
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
......@@ -28,15 +28,17 @@ SET time_zone = "+00:00";
-- Table structure for table `admin_users`
--
CREATE TABLE `admin_users` (
`id` int(11) NOT NULL,
DROP TABLE IF EXISTS `admin_users`;
CREATE TABLE IF NOT EXISTS `admin_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`user_type` tinyint(3) NOT NULL COMMENT '1 => Super Admin, 2 => Mechanic',
`display_name` varchar(200) NOT NULL,
`profile_image` varchar(500) NOT NULL,
`status` tinyint(4) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`status` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin_users`
......@@ -54,8 +56,9 @@ INSERT INTO `admin_users` (`id`, `username`, `password`, `user_type`, `display_n
-- Table structure for table `customers`
--
CREATE TABLE `customers` (
`customer_id` int(20) NOT NULL,
DROP TABLE IF EXISTS `customers`;
CREATE TABLE IF NOT EXISTS `customers` (
`customer_id` int(20) NOT NULL AUTO_INCREMENT,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`phone` varchar(20) DEFAULT NULL,
......@@ -64,8 +67,9 @@ CREATE TABLE `customers` (
`profile_image` varchar(500) DEFAULT NULL,
`password` varchar(50) DEFAULT NULL,
`date_of_birth` varchar(200) DEFAULT NULL,
`status` tinyint(3) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`status` tinyint(3) NOT NULL DEFAULT '1',
PRIMARY KEY (`customer_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `customers`
......@@ -74,7 +78,8 @@ CREATE TABLE `customers` (
INSERT INTO `customers` (`customer_id`, `first_name`, `last_name`, `phone`, `email`, `address`, `profile_image`, `password`, `date_of_birth`, `status`) VALUES
(1, 'Tobin', 'Thomas', '9995559194', '[email protected]', 'Techware', 'assets/uploads/services/1544417044_sniper.jpg', NULL, '05/05/1994', 1),
(2, 'Tobin', 'Thomas', '99955752194', '[email protected]', 'Techware', 'assets/uploads/services/1545036793_car1.jpg', NULL, '12/20/2018', 1),
(3, 'Tobin', 'Thomas', '9993242394', '[email protected]', 'Techware', 'assets/uploads/services/1545037023_images.jpg', 'e10adc3949ba59abbe56e057f20f883e', '12/11/2018', 1);
(3, 'Tobin', 'Thomas', '9993242394', '[email protected]', 'Techware', 'assets/uploads/services/1545037023_images.jpg', 'e10adc3949ba59abbe56e057f20f883e', '12/11/2018', 1),
(7, 'tobin', 'thomas', '9995559194', '[email protected]', NULL, NULL, 'e10adc3949ba59abbe56e057f20f883e', NULL, 1);
-- --------------------------------------------------------
......@@ -82,8 +87,9 @@ INSERT INTO `customers` (`customer_id`, `first_name`, `last_name`, `phone`, `ema
-- Table structure for table `customer_vehicle`
--
CREATE TABLE `customer_vehicle` (
`customer_veh_id` int(11) NOT NULL,
DROP TABLE IF EXISTS `customer_vehicle`;
CREATE TABLE IF NOT EXISTS `customer_vehicle` (
`customer_veh_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) DEFAULT NULL,
`car_name` varchar(250) DEFAULT NULL,
`car_model` varchar(150) DEFAULT NULL,
......@@ -95,8 +101,9 @@ CREATE TABLE `customer_vehicle` (
`car_loc_lat` varchar(150) DEFAULT NULL,
`car_loc_lng` varchar(150) DEFAULT NULL,
`created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` tinyint(3) NOT NULL DEFAULT '3'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
`status` tinyint(3) NOT NULL DEFAULT '3',
PRIMARY KEY (`customer_veh_id`)
) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `customer_vehicle`
......@@ -119,15 +126,43 @@ INSERT INTO `customer_vehicle` (`customer_veh_id`, `customer_id`, `car_name`, `c
-- --------------------------------------------------------
--
-- Table structure for table `forgot_password_link`
--
DROP TABLE IF EXISTS `forgot_password_link`;
CREATE TABLE IF NOT EXISTS `forgot_password_link` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_type` tinyint(3) DEFAULT NULL COMMENT '1=>Customer 2=>Mechanic',
`user_id` int(11) DEFAULT NULL,
`token` varchar(500) DEFAULT NULL,
`created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`status` tinyint(3) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `forgot_password_link`
--
INSERT INTO `forgot_password_link` (`id`, `user_type`, `user_id`, `token`, `created_date`, `status`) VALUES
(1, 1, NULL, '7e07594058e29d84ce3ff26e4b283fc3', '2018-12-30 13:12:20', 1),
(2, 1, 3, '747e195179012d145766f9ea9ee1f4aa', '2018-12-30 13:12:49', 1),
(3, 1, 3, '08be0c60b807ba994ca520d4c4f2d083', '2018-12-30 14:55:25', 1);
-- --------------------------------------------------------
--
-- Table structure for table `issues`
--
CREATE TABLE `issues` (
`issue_id` int(11) NOT NULL,
DROP TABLE IF EXISTS `issues`;
CREATE TABLE IF NOT EXISTS `issues` (
`issue_id` int(11) NOT NULL AUTO_INCREMENT,
`issue` varchar(500) NOT NULL,
`issue_image` varchar(500) DEFAULT NULL,
`status` tinyint(3) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`status` tinyint(3) NOT NULL DEFAULT '1',
PRIMARY KEY (`issue_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `issues`
......@@ -145,15 +180,17 @@ INSERT INTO `issues` (`issue_id`, `issue`, `issue_image`, `status`) VALUES
-- Table structure for table `issues_category`
--
CREATE TABLE `issues_category` (
`issue_cat_id` int(11) NOT NULL,
DROP TABLE IF EXISTS `issues_category`;
CREATE TABLE IF NOT EXISTS `issues_category` (
`issue_cat_id` int(11) NOT NULL AUTO_INCREMENT,
`issue_id` int(11) DEFAULT NULL,
`issue_category` varchar(500) DEFAULT NULL,
`issue_cat_image` varchar(500) DEFAULT NULL,
`default_service_fee` double DEFAULT NULL,
`default_description` longtext,
`status` tinyint(3) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`status` tinyint(3) NOT NULL DEFAULT '1',
PRIMARY KEY (`issue_cat_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `issues_category`
......@@ -171,8 +208,9 @@ INSERT INTO `issues_category` (`issue_cat_id`, `issue_id`, `issue_category`, `is
-- Table structure for table `mechanic`
--
CREATE TABLE `mechanic` (
`id` int(11) NOT NULL,
DROP TABLE IF EXISTS `mechanic`;
CREATE TABLE IF NOT EXISTS `mechanic` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mechanic_id` int(11) NOT NULL,
`shop_id` int(11) NOT NULL DEFAULT '0',
`first_name` varchar(50) NOT NULL,
......@@ -186,8 +224,9 @@ CREATE TABLE `mechanic` (
`licence_number` varchar(250) DEFAULT NULL,
`licence_exp_date` varchar(250) DEFAULT NULL,
`location_lat` varchar(30) DEFAULT NULL,
`location_lng` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`location_lng` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `mechanic`
......@@ -204,15 +243,17 @@ INSERT INTO `mechanic` (`id`, `mechanic_id`, `shop_id`, `first_name`, `last_name
-- Table structure for table `mechanic_issues`
--
CREATE TABLE `mechanic_issues` (
`id` int(11) NOT NULL,
DROP TABLE IF EXISTS `mechanic_issues`;
CREATE TABLE IF NOT EXISTS `mechanic_issues` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`issue_id` int(11) DEFAULT NULL,
`issue_cat_id` int(11) DEFAULT NULL,
`mechanic_id` int(11) DEFAULT NULL,
`custom_description` longtext,
`custom_service_fee` double NOT NULL DEFAULT '0',
`status` tinyint(3) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`status` tinyint(3) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `mechanic_issues`
......@@ -233,14 +274,16 @@ INSERT INTO `mechanic_issues` (`id`, `issue_id`, `issue_cat_id`, `mechanic_id`,
-- Table structure for table `mechanic_shop`
--
CREATE TABLE `mechanic_shop` (
`shop_id` int(11) NOT NULL,
DROP TABLE IF EXISTS `mechanic_shop`;
CREATE TABLE IF NOT EXISTS `mechanic_shop` (
`shop_id` int(11) NOT NULL AUTO_INCREMENT,
`shop_name` varchar(250) NOT NULL,
`address` varchar(500) NOT NULL,
`phone` varchar(15) NOT NULL,
`email_id` varchar(150) NOT NULL,
`status` tinyint(3) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
`status` tinyint(3) NOT NULL DEFAULT '1',
PRIMARY KEY (`shop_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `mechanic_shop`
......@@ -256,8 +299,9 @@ INSERT INTO `mechanic_shop` (`shop_id`, `shop_name`, `address`, `phone`, `email_
-- Table structure for table `setting`
--
CREATE TABLE `setting` (
`id` int(11) NOT NULL,
DROP TABLE IF EXISTS `setting`;
CREATE TABLE IF NOT EXISTS `setting` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(250) NOT NULL,
`title_short` varchar(250) NOT NULL,
`site_logo` varchar(150) NOT NULL,
......@@ -269,8 +313,9 @@ CREATE TABLE `setting` (
`smtp_password` varchar(150) NOT NULL,
`google_api_key` varchar(500) DEFAULT NULL,
`vin_audit_url` varchar(500) DEFAULT NULL,
`vin_audit_api` varchar(500) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
`vin_audit_api` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `setting`
......@@ -278,122 +323,6 @@ CREATE TABLE `setting` (
INSERT INTO `setting` (`id`, `title`, `title_short`, `site_logo`, `fav_icon`, `country_flag`, `currency`, `smtp_host`, `smtp_username`, `smtp_password`, `google_api_key`, `vin_audit_url`, `vin_audit_api`) VALUES
(1, 'd-Car Fixers', 'd-CarFixers', 'assets/uploads/services/1539680946_1523012036_hj.jpg', 'assets/uploads/services/1539680946_1523540473_guenstig_reifen.png', 'US', 'USD', '[email protected]', 'AIzaSyC9JX3BZZfx2S6GQieC_PqjuJdUbZ7_wyM1', 'Golden_1234', 'AIzaSyCcc-YDSJyDpehNE6qfntfWpEQ4uS4aq6A', 'https://specifications.vinaudit.com/getspecifications.php', 'VA_DEMO_KEY');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin_users`
--
ALTER TABLE `admin_users`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
ADD PRIMARY KEY (`customer_id`);
--
-- Indexes for table `customer_vehicle`
--
ALTER TABLE `customer_vehicle`
ADD PRIMARY KEY (`customer_veh_id`);
--
-- Indexes for table `issues`
--
ALTER TABLE `issues`
ADD PRIMARY KEY (`issue_id`);
--
-- Indexes for table `issues_category`
--
ALTER TABLE `issues_category`
ADD PRIMARY KEY (`issue_cat_id`);
--
-- Indexes for table `mechanic`
--
ALTER TABLE `mechanic`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `mechanic_issues`
--
ALTER TABLE `mechanic_issues`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `mechanic_shop`
--
ALTER TABLE `mechanic_shop`
ADD PRIMARY KEY (`shop_id`);
--
-- Indexes for table `setting`
--
ALTER TABLE `setting`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin_users`
--
ALTER TABLE `admin_users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
MODIFY `customer_id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `customer_vehicle`
--
ALTER TABLE `customer_vehicle`
MODIFY `customer_veh_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
--
-- AUTO_INCREMENT for table `issues`
--
ALTER TABLE `issues`
MODIFY `issue_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT for table `issues_category`
--
ALTER TABLE `issues_category`
MODIFY `issue_cat_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `mechanic`
--
ALTER TABLE `mechanic`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `mechanic_issues`
--
ALTER TABLE `mechanic_issues`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27;
--
-- AUTO_INCREMENT for table `mechanic_shop`
--
ALTER TABLE `mechanic_shop`
MODIFY `shop_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `setting`
--
ALTER TABLE `setting`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
......
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