-- Table structure for table `quantity`
--

CREATE TABLE `quantity` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `quantity_value` int(11) NOT NULL,
  `status` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

--
-- Table structure for table `quick_call_history`
--

CREATE TABLE `quick_call_history` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `CallerID` int(11) DEFAULT NULL,
  `NewCall` varchar(50) DEFAULT NULL,
  `PhoneID` varchar(50) DEFAULT NULL,
  `PhoneNo` varchar(50) DEFAULT NULL,
  `CallDateTime` varchar(50) DEFAULT NULL,
  `CallEndDateTime` varchar(50) DEFAULT NULL,
  `identifier` varchar(50) DEFAULT NULL,
  `Attempt` varchar(50) DEFAULT NULL,
  `ForCompaignID` varchar(50) DEFAULT NULL,
  `StatusID` varchar(50) DEFAULT NULL,
  `AreaTimeGap` varchar(50) DEFAULT NULL,
  `SmdrRunning` varchar(50) DEFAULT NULL,
  `Priority` varchar(50) DEFAULT NULL,
  KEY `ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `quick_login_history`
--

CREATE TABLE `quick_login_history` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `LoginID` int(11) DEFAULT NULL,
  `QAgentID` varchar(50) DEFAULT NULL,
  `QAgentName` varchar(50) DEFAULT NULL,
  `QCompaignName` varchar(50) DEFAULT NULL,
  `QLoginDateTime` varchar(50) DEFAULT NULL,
  KEY `ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `recently_viewed`
--

CREATE TABLE `recently_viewed` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_stage` varchar(255) DEFAULT NULL,
  `booking_data` text,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Table structure for table `referral_discount_amount`
--

CREATE TABLE `referral_discount_amount` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(50) DEFAULT NULL,
  `user_type` int(11) NOT NULL COMMENT '1-N User,2-UNReg User,3-Driver,4-Vendor,5-Guide,6-Corporate,7-Agent',
  `installation_amount_user` int(11) NOT NULL,
  `installation_amount_referer` int(11) NOT NULL,
  `booking_amount_percent` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

--
-- Table structure for table `referral_signup_history`
--

CREATE TABLE `referral_signup_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `referer_id` int(11) NOT NULL,
  `user_amount` int(11) NOT NULL,
  `referer_amount` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=latin1;

--
-- Table structure for table `region_text`
--

CREATE TABLE `region_text` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `page_type` int(11) NOT NULL,
  `text` text NOT NULL,
  `text_id` varchar(110) NOT NULL,
  `text_status` int(11) NOT NULL,
  `page_title` varchar(11) NOT NULL,
  `lang` int(11) NOT NULL,
  `page` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=255 DEFAULT CHARSET=latin1;

--
-- Table structure for table `related_tours`
--

CREATE TABLE `related_tours` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mapping_id` int(11) NOT NULL,
  `bkg_type_id` int(11) NOT NULL,
  `tour_id` int(11) NOT NULL,
  `related_tour_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `road_tax`
--

CREATE TABLE `road_tax` (
  `road_tax_id` int(11) NOT NULL AUTO_INCREMENT,
  `state_id` int(11) NOT NULL,
  `duration_type_id` int(11) NOT NULL,
  `vehicle_type_id` int(11) NOT NULL,
  `amount` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `is_active` int(5) DEFAULT '1',
  `ip` varchar(50) NOT NULL,
  PRIMARY KEY (`road_tax_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `role`
--

CREATE TABLE `role` (
  `role_id` int(11) NOT NULL AUTO_INCREMENT,
  `region_id` int(11) DEFAULT NULL,
  `role_name` varchar(255) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1;

--
-- Table structure for table `role_rule`
--

CREATE TABLE `role_rule` (
  `rule_id` int(11) NOT NULL AUTO_INCREMENT,
  `role_id` int(11) NOT NULL,
  `module_id` int(11) NOT NULL,
  `is_read` tinyint(2) DEFAULT NULL,
  `is_write` tinyint(2) DEFAULT NULL,
  `is_delete` int(11) NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`rule_id`)
) ENGINE=InnoDB AUTO_INCREMENT=520 DEFAULT CHARSET=latin1;

--
-- Table structure for table `role_type`
--

CREATE TABLE `role_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(15) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Table structure for table `route_knowledge`
--

CREATE TABLE `route_knowledge` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `route_id` int(5) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `rt_cabmanager_cabs`
--

CREATE TABLE `rt_cabmanager_cabs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `image` varchar(255) NOT NULL,
  `capacity` int(2) NOT NULL,
  `no_of_cabs` int(11) NOT NULL,
  `min_cov_km_day_os` int(11) NOT NULL,
  `min_cov_hours_local` int(11) NOT NULL,
  `min_cov_km_local` int(11) NOT NULL,
  `per_hour_extra_charge` int(11) NOT NULL,
  `per_km_extra_charge` int(11) NOT NULL,
  `per_day_extra_charge_os` int(11) NOT NULL,
  `airport_pickup_charge` int(11) NOT NULL,
  `airport_drop_charge` int(11) NOT NULL,
  `placard_charge` int(11) NOT NULL,
  `parking_charge` int(11) NOT NULL,
  `driver_allowance` int(11) NOT NULL,
  `helper_charge` int(11) NOT NULL,
  `published` tinyint(4) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `services` varchar(255) NOT NULL,
  `corder` int(11) NOT NULL,
  `min_charge_localhire_404` int(11) NOT NULL,
  `min_charge_localhire_808` int(11) NOT NULL,
  `per_km_charge_os` int(11) NOT NULL,
  `per_km_charge_p2p` int(11) NOT NULL,
  `per_km_charge_airport` int(11) NOT NULL,
  `min_cov_km_p2p` int(11) NOT NULL,
  `min_cov_km_airport` int(11) NOT NULL,
  `background_km_outstation` int(11) NOT NULL,
  `background_km_airport` int(11) NOT NULL,
  `background_km_ptp` int(11) NOT NULL,
  `background_km_localhire` int(11) NOT NULL,
  `city` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

--
-- Table structure for table `rto_state_taxes`
--

CREATE TABLE `rto_state_taxes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `state_id` int(11) NOT NULL DEFAULT '0',
  `vehicle_type_id` int(11) NOT NULL DEFAULT '0',
  `period_id` int(11) NOT NULL DEFAULT '0',
  `amount` varchar(10) DEFAULT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=177 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sass_company_vendor`
--

CREATE TABLE `sass_company_vendor` (
  `sass_comp_id` int(11) NOT NULL AUTO_INCREMENT,
  `company_setup_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`sass_comp_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COMMENT='Map Domain''s Vendor';

--
-- Table structure for table `season`
--

CREATE TABLE `season` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mapping_id` int(11) NOT NULL,
  `bkg_type_id` int(11) NOT NULL,
  `season_type_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=latin1;

--
-- Table structure for table `seasonal_discount`
--

CREATE TABLE `seasonal_discount` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mapping_id` int(11) NOT NULL COMMENT 'Foreign Key For All Booking Types',
  `bkg_type_id` int(11) NOT NULL,
  `season_name` varchar(255) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `season_discount_type` tinyint(2) NOT NULL DEFAULT '0',
  `season_discount_amount` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=latin1;

--
-- Table structure for table `seasonal_discount_log`
--

CREATE TABLE `seasonal_discount_log` (
  `id` int(11) NOT NULL,
  `mapping_id` int(11) NOT NULL COMMENT 'Foreign Key For All Booking Types',
  `bkg_type_id` int(11) NOT NULL,
  `season_name` varchar(255) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `season_discount_type` tinyint(2) NOT NULL DEFAULT '0',
  `season_discount_amount` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `shows`
--

CREATE TABLE `shows` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `show_name` varchar(50) NOT NULL,
  `country_id` int(11) NOT NULL,
  `state_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `image` text NOT NULL,
  `desc` text NOT NULL,
  `time_in` varchar(20) NOT NULL,
  `time_out` varchar(20) NOT NULL,
  `week_off` varchar(50) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` enum('0','1') NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing`
--

CREATE TABLE `sightseeing` (
  `s_id` int(11) NOT NULL AUTO_INCREMENT,
  `company_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `name` varchar(100) DEFAULT NULL,
  `sightseeing_cover` varchar(100) NOT NULL,
  `latitude` varchar(100) NOT NULL DEFAULT '0',
  `longitude` varchar(100) NOT NULL DEFAULT '0',
  `address` varchar(255) DEFAULT NULL,
  `coverage_km` varchar(10) NOT NULL,
  `coverage_hrs` varchar(10) NOT NULL,
  `difficulty_level` varchar(50) NOT NULL,
  `is_unique` tinyint(2) NOT NULL DEFAULT '0',
  `popularity` varchar(100) NOT NULL,
  `youtube_url` varchar(255) NOT NULL,
  `description` text,
  `meeting_point` varchar(255) NOT NULL,
  `highlights` text,
  `related_tours` varchar(255) NOT NULL,
  `brochure_title` varchar(100) NOT NULL,
  `brochure_desc` text NOT NULL,
  `meta_keywords` varchar(100) NOT NULL,
  `meta_title` text NOT NULL,
  `meta_desc` text NOT NULL,
  `payment_structure` text NOT NULL,
  `payment_documentation` text NOT NULL,
  `cancellation_policy` text NOT NULL,
  `refund_policy` text NOT NULL,
  `terms_condition_policy` text NOT NULL,
  `payment_structure_content` text NOT NULL,
  `documentation_content` text NOT NULL,
  `cancellation_policy_content` text NOT NULL,
  `refund_policy_content` text NOT NULL,
  `term_policy_content` text NOT NULL,
  `cost_inclusive` text NOT NULL,
  `cost_exclusive` text NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`s_id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_booking_details`
--

CREATE TABLE `sightseeing_booking_details` (
  `s_booking_id` int(11) NOT NULL AUTO_INCREMENT,
  `booking_id` int(11) NOT NULL,
  `sightseeing_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `ip` varchar(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`s_booking_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_cancellation_fees`
--

CREATE TABLE `sightseeing_cancellation_fees` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `s_id` int(11) NOT NULL,
  `currency_id` int(11) NOT NULL,
  `vendor_type` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `cancel_date_from` date NOT NULL,
  `cancel_date_to` date NOT NULL,
  `cancellation_master_id` int(11) NOT NULL,
  `cancellation_type` varchar(10) NOT NULL,
  `cancellation_value` float NOT NULL DEFAULT '0',
  `days` varchar(20) NOT NULL,
  `hours` varchar(20) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_cancellation_fees_logs`
--

CREATE TABLE `sightseeing_cancellation_fees_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `s_id` int(11) NOT NULL,
  `currency_id` int(11) NOT NULL,
  `vendor_type` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `cancel_date_from` date NOT NULL,
  `cancel_date_to` date NOT NULL,
  `cancellation_master_id` int(11) NOT NULL,
  `cancellation_type` varchar(10) NOT NULL,
  `cancellation_value` float NOT NULL DEFAULT '0',
  `days` varchar(20) NOT NULL,
  `hours` varchar(20) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_details`
--

CREATE TABLE `sightseeing_details` (
  `s_detail_id` int(11) NOT NULL AUTO_INCREMENT,
  `s_id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `tour_type` tinyint(2) NOT NULL DEFAULT '0',
  `passenger` varchar(10) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `rate_type` tinyint(2) NOT NULL DEFAULT '0',
  `rate_per_fixed` tinyint(2) NOT NULL DEFAULT '0',
  `rate_value` int(11) NOT NULL,
  `tax_type` tinyint(2) NOT NULL DEFAULT '0',
  `tax_per_fixed` tinyint(2) NOT NULL DEFAULT '0',
  `tax_value` int(11) NOT NULL,
  `service_charge` varchar(50) NOT NULL,
  `service_charge_type` varchar(50) NOT NULL,
  `service_charge_value` varchar(50) NOT NULL,
  `discount_netrate_commissionrate` varchar(50) NOT NULL,
  `discount_commission_rate_type` varchar(50) NOT NULL,
  `discount_commission_rate_value` varchar(50) NOT NULL,
  `discount_valid_from` varchar(50) NOT NULL,
  `discount_valid_to` varchar(50) NOT NULL,
  `week_off` text NOT NULL,
  `opening_time` varchar(20) NOT NULL,
  `closing_time` varchar(20) NOT NULL,
  `estimated_time` varchar(50) NOT NULL,
  `age_from` int(11) NOT NULL,
  `age_to` int(11) NOT NULL,
  `transfer` tinyint(2) NOT NULL,
  `pickup_point` varchar(255) NOT NULL,
  `allocation` varchar(255) NOT NULL,
  `cut_off_days` varchar(255) NOT NULL,
  `price_plan_name` varchar(255) NOT NULL,
  `stay_more_status` tinyint(2) NOT NULL DEFAULT '0',
  `seasonal_discount_status` tinyint(2) NOT NULL DEFAULT '0',
  `last_min_booking_status` tinyint(2) NOT NULL DEFAULT '0',
  `early_booking_status` tinyint(2) NOT NULL DEFAULT '0',
  `daywise_discount_status` tinyint(2) NOT NULL DEFAULT '0',
  `related_tours` varchar(255) DEFAULT NULL,
  `brochure_title` varchar(100) NOT NULL,
  `brochure_desc` text NOT NULL,
  `meta_keywords` varchar(100) NOT NULL,
  `meta_title` varchar(100) NOT NULL,
  `meta_desc` text NOT NULL,
  `payment_structure` text NOT NULL,
  `payment_documentation` text NOT NULL,
  `cancellation_policy` text NOT NULL,
  `refund_policy` text NOT NULL,
  `terms_condition_policy` text NOT NULL,
  `payment_structure_content` text NOT NULL,
  `documentation_content` text NOT NULL,
  `cancellation_policy_content` text NOT NULL,
  `refund_policy_content` text NOT NULL,
  `term_policy_content` text NOT NULL,
  `cost_inclusive` text NOT NULL,
  `cost_exclusive` text NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`s_detail_id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_details_log`
--

CREATE TABLE `sightseeing_details_log` (
  `s_detail_id` int(11) NOT NULL,
  `s_id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `tour_type` tinyint(2) NOT NULL DEFAULT '0',
  `passenger` varchar(10) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `rate_type` tinyint(2) NOT NULL DEFAULT '0',
  `rate_per_fixed` tinyint(2) NOT NULL DEFAULT '0',
  `rate_value` int(11) NOT NULL,
  `tax_type` tinyint(2) NOT NULL DEFAULT '0',
  `tax_per_fixed` tinyint(2) NOT NULL DEFAULT '0',
  `tax_value` int(11) NOT NULL,
  `service_charge` varchar(50) DEFAULT NULL,
  `service_charge_type` varchar(50) DEFAULT NULL,
  `service_charge_value` varchar(50) DEFAULT NULL,
  `discount_netrate_commissionrate` varchar(50) DEFAULT NULL,
  `discount_commission_rate_type` varchar(50) DEFAULT NULL,
  `discount_commission_rate_value` varchar(50) DEFAULT NULL,
  `discount_valid_from` varchar(50) DEFAULT NULL,
  `discount_valid_to` varchar(50) DEFAULT NULL,
  `week_off` text,
  `opening_time` varchar(20) DEFAULT NULL,
  `closing_time` varchar(20) DEFAULT NULL,
  `estimated_time` varchar(50) DEFAULT NULL,
  `age_from` int(11) NOT NULL,
  `age_to` int(11) NOT NULL,
  `transfer` tinyint(2) NOT NULL,
  `pickup_point` varchar(255) DEFAULT NULL,
  `allocation` varchar(255) DEFAULT NULL,
  `cut_off_days` varchar(255) DEFAULT NULL,
  `price_plan_name` varchar(255) DEFAULT NULL,
  `stay_more_status` tinyint(2) NOT NULL DEFAULT '0',
  `seasonal_discount_status` tinyint(2) NOT NULL DEFAULT '0',
  `last_min_booking_status` tinyint(2) NOT NULL DEFAULT '0',
  `early_booking_status` tinyint(2) NOT NULL DEFAULT '0',
  `daywise_discount_status` tinyint(2) NOT NULL DEFAULT '0',
  `related_tours` varchar(255) DEFAULT NULL,
  `brochure_title` varchar(100) DEFAULT NULL,
  `brochure_desc` text,
  `meta_keywords` varchar(100) DEFAULT NULL,
  `meta_title` varchar(100) DEFAULT NULL,
  `meta_desc` text,
  `payment_structure` text,
  `payment_documentation` text,
  `cancellation_policy` text,
  `refund_policy` text,
  `terms_condition_policy` text,
  `payment_structure_content` text,
  `documentation_content` text,
  `cancellation_policy_content` text,
  `refund_policy_content` text,
  `term_policy_content` text,
  `cost_inclusive` text,
  `cost_exclusive` text,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `ip` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_fair`
--

CREATE TABLE `sightseeing_fair` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `s_id` int(11) NOT NULL,
  `nationality` varchar(30) NOT NULL,
  `age_id` int(11) NOT NULL,
  `fair` int(11) NOT NULL,
  `taxes` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_language`
--

CREATE TABLE `sightseeing_language` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `s_id` int(11) NOT NULL,
  `language_id` int(11) NOT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active,2-Delete',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sightseeing_type`
--

CREATE TABLE `sightseeing_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `s_id` int(11) NOT NULL,
  `sightseeing_type_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=latin1;

--
-- Table structure for table `signup_status`
--

CREATE TABLE `signup_status` (
  `signup_status_id` int(11) NOT NULL AUTO_INCREMENT,
  `status_name` varchar(50) NOT NULL,
  `signup_status_class` varchar(50) NOT NULL,
  `is_active` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`signup_status_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sms_api`
--

CREATE TABLE `sms_api` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `api_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `api_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `api_username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `api_password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `api_sender_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `api_base_uri` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `api_ts_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `active` enum('1','0') COLLATE utf8_unicode_ci NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `ip` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `sms_status`
--

CREATE TABLE `sms_status` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL,
  `mesg` longtext NOT NULL,
  `contact_no` varchar(50) NOT NULL,
  `cost` int(50) NOT NULL,
  `status` int(11) NOT NULL,
  `sent_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `UID` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sms_template`
--

CREATE TABLE `sms_template` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `company_id` int(11) NOT NULL,
  `message` text,
  `msg_type` text,
  `msg_sku` text,
  `variables` text,
  `text_limit` int(11) DEFAULT NULL,
  `is_active` int(11) DEFAULT NULL,
  `status_done` int(11) NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=latin1 COMMENT='Contains SMS template';

--
-- Table structure for table `specialization`
--

CREATE TABLE `specialization` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `specialization_name` varchar(255) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `status`
--

CREATE TABLE `status` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `status` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `stay_more_discount`
--

CREATE TABLE `stay_more_discount` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mapping_id` int(11) NOT NULL COMMENT 'Foreign Key For All Booking Types',
  `bkg_type_id` int(11) NOT NULL,
  `staying_days` varchar(255) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `staying_discount_type` tinyint(2) NOT NULL DEFAULT '0',
  `staying_discount_amount` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=89 DEFAULT CHARSET=latin1;

--
-- Table structure for table `stay_more_discount_log`
--

CREATE TABLE `stay_more_discount_log` (
  `id` int(11) NOT NULL,
  `mapping_id` int(11) NOT NULL COMMENT 'Foreign Key For All Booking Types',
  `bkg_type_id` int(11) NOT NULL,
  `staying_days` varchar(255) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `staying_discount_type` tinyint(2) NOT NULL DEFAULT '0',
  `staying_discount_amount` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sub_complaint`
--

CREATE TABLE `sub_complaint` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `complaint_type` int(11) NOT NULL,
  `sub_complaint` varchar(200) NOT NULL,
  `created_by` int(11) NOT NULL,
  `date` datetime NOT NULL,
  `updated_by` int(11) NOT NULL,
  `updated_on` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tax_detail`
--

CREATE TABLE `tax_detail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT '0',
  `master_booking_type_id` int(11) DEFAULT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `tax_type` varchar(10) DEFAULT NULL,
  `sgst` float DEFAULT '0',
  `cgst` float NOT NULL DEFAULT '0',
  `igst` float NOT NULL DEFAULT '0',
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tblcity`
--

CREATE TABLE `tblcity` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `state` varchar(255) NOT NULL,
  `city_radius` int(11) NOT NULL,
  `vicinity` longtext NOT NULL,
  `locations` longtext NOT NULL,
  `published` tinyint(4) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `ncr` int(11) unsigned DEFAULT '0',
  `local` int(11) DEFAULT '1',
  `point` int(11) DEFAULT '1',
  `airport` int(11) DEFAULT '1',
  `outstation` int(11) DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=163 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tbo_city_list`
--

CREATE TABLE `tbo_city_list` (
  `CITYID` varchar(10) NOT NULL,
  `DESTINATION` varchar(30) NOT NULL,
  `STATEPROVINCE` varchar(50) NOT NULL,
  `STATEPROVINCECODE` varchar(30) NOT NULL,
  `COUNTRY` varchar(30) NOT NULL,
  `COUNTRYCODE` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Table structure for table `tboauthuser`
--

CREATE TABLE `tboauthuser` (
  `id` int(2) NOT NULL AUTO_INCREMENT,
  `status` int(10) NOT NULL,
  `tokenid` varchar(50) NOT NULL,
  `FirstName` varchar(50) NOT NULL,
  `LastName` varchar(50) NOT NULL,
  `Email` varchar(50) NOT NULL,
  `MemberId` int(10) NOT NULL,
  `AgencyId` int(10) NOT NULL,
  `LoginName` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;

--
-- Table structure for table `temp_outstation_city_details`
--

CREATE TABLE `temp_outstation_city_details` (
  `temp_city_id` int(11) NOT NULL AUTO_INCREMENT,
  `temp_id` int(11) DEFAULT NULL,
  `from_city_id` int(11) DEFAULT NULL,
  `from_city_name` varchar(100) DEFAULT NULL,
  `to_city_id` int(11) DEFAULT NULL,
  `to_city_name` varchar(11) DEFAULT NULL,
  `departure_date` date DEFAULT NULL,
  `destination_date` date DEFAULT NULL,
  `departure_time` time DEFAULT NULL,
  `destination_time` time DEFAULT NULL,
  `estimate_time` time DEFAULT NULL,
  `distance_km` varchar(20) DEFAULT NULL,
  `no_of_days` tinyint(2) DEFAULT NULL,
  `guide_id` int(11) DEFAULT NULL,
  `guide_alldays_status` varchar(10) DEFAULT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`temp_city_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `temp_outstation_user_details`
--

CREATE TABLE `temp_outstation_user_details` (
  `temp_id` int(11) NOT NULL,
  `user_session_id` varchar(255) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `first_name` varchar(225) DEFAULT NULL,
  `last_name` varchar(225) DEFAULT NULL,
  `user_email` varchar(50) NOT NULL,
  `user_mobile` varchar(20) NOT NULL,
  `user_alternate_mobile` varchar(255) DEFAULT NULL,
  `outstation_type` varchar(10) NOT NULL,
  `base_comb_id` int(11) DEFAULT NULL,
  `no_adult` tinyint(2) NOT NULL,
  `no_child` tinyint(2) NOT NULL,
  `no_luggages` tinyint(2) NOT NULL,
  `no_cars` tinyint(1) NOT NULL,
  `flight_mode_status` enum('No','Yes') DEFAULT NULL,
  `flight_no` varchar(100) DEFAULT NULL,
  `flight_time` time DEFAULT NULL,
  `pick_up_address` varchar(255) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `temp_sightseeing`
--

CREATE TABLE `temp_sightseeing` (
  `sightseeing_auto_id` int(11) NOT NULL,
  `temp_city_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `sight_seeing_id` int(11) NOT NULL,
  `date` date DEFAULT NULL,
  `time` time DEFAULT NULL,
  `days` tinyint(2) DEFAULT NULL,
  `distance` double(6,2) DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `testimonial`
--

CREATE TABLE `testimonial` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `company_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `description` varchar(255) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `status` int(11) NOT NULL DEFAULT '1',
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `ip` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=latin1;

--
-- Table structure for table `things_carry`
--

CREATE TABLE `things_carry` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mapping_id` int(11) NOT NULL,
  `bkg_type_id` int(11) NOT NULL,
  `things_carry_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_category`
--

CREATE TABLE `tour_category` (
  `tour_category_id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`tour_category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail`
--

CREATE TABLE `tour_detail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `company_id` int(11) NOT NULL,
  `tours_type` int(11) DEFAULT NULL,
  `country_id` int(11) DEFAULT '0',
  `city_id` int(11) DEFAULT '0',
  `post_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_operator` int(11) DEFAULT NULL,
  `starting_city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ending_city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `destination_cover` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `no_of_traveller` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `package_validity_from` date DEFAULT NULL,
  `package_validity_to` date DEFAULT NULL,
  `booking_validity_from` date DEFAULT NULL,
  `booking_validity_to` date DEFAULT NULL,
  `tours_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `rating` int(11) DEFAULT NULL,
  `num_of_nights` int(11) DEFAULT NULL,
  `num_of_days` int(11) DEFAULT NULL,
  `tour_type` tinyint(2) NOT NULL COMMENT '1-Private,2-Group Type',
  `package_specification` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `short_desc` longtext COLLATE utf8_unicode_ci,
  `inclusions` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `exclusions` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `package_category` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_image_primary` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_image` text COLLATE utf8_unicode_ci,
  `tours_price` double DEFAULT NULL,
  `infant_price` double NOT NULL DEFAULT '0',
  `price_type` enum('person','package') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'package',
  `tours_date` datetime DEFAULT NULL,
  `tours_order` int(11) DEFAULT '0',
  `visiting_cities` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `related_items` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `featured` enum('0','1') COLLATE utf8_unicode_ci DEFAULT '0',
  `active` enum('1','0') COLLATE utf8_unicode_ci DEFAULT '1',
  `meta_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_desc` text COLLATE utf8_unicode_ci,
  `duration` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `costs_of_children` double DEFAULT NULL,
  `location_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `accommodates` int(11) DEFAULT NULL,
  `transportation` text COLLATE utf8_unicode_ci,
  `tour_policy` text COLLATE utf8_unicode_ci,
  `sightseeing` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Pickup_service` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `supplementary_room` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `drop_off_service` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `terms_and_condition` text COLLATE utf8_unicode_ci,
  `scheduled_on` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `spots_photo_gallery_primary` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `spots_photo_gallery` text COLLATE utf8_unicode_ci,
  `feature_google_map` text COLLATE utf8_unicode_ci,
  `tour_highlights` longtext COLLATE utf8_unicode_ci,
  `itinerary_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `itinerary_desc` longtext COLLATE utf8_unicode_ci,
  `tours_package_available_from` date NOT NULL DEFAULT '0000-00-00',
  `available_expire_date` date DEFAULT '0000-00-00',
  `journey_start_date` date DEFAULT '0000-00-00',
  `entertainments` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `multilingual_guide` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `payment_desc` longtext COLLATE utf8_unicode_ci,
  `lang_flag` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `availability_country` int(11) NOT NULL,
  `availability_city` int(11) NOT NULL,
  `payment_structure_id` int(11) DEFAULT NULL,
  `document_id` int(11) NOT NULL,
  `cancellation_policy` int(11) NOT NULL,
  `refund_policy` int(11) NOT NULL,
  `term_policy` int(11) DEFAULT NULL,
  `payment_structure_content` text COLLATE utf8_unicode_ci,
  `documentation_content` text COLLATE utf8_unicode_ci,
  `cancellation_policy_content` text COLLATE utf8_unicode_ci,
  `refund_policy_content` text COLLATE utf8_unicode_ci,
  `term_policy_content` text COLLATE utf8_unicode_ci,
  `created_date` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `ip` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tours_page_category_id` (`package_category`) USING BTREE,
  KEY `tours_page_active` (`active`) USING BTREE,
  KEY `tours_page_featured` (`featured`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tour_detail_deals`
--

CREATE TABLE `tour_detail_deals` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `adult_discount` varchar(5) NOT NULL,
  `child_discount` varchar(5) NOT NULL,
  `infant_discount` varchar(5) NOT NULL,
  `percentage_amount` varchar(5) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_itinerary`
--

CREATE TABLE `tour_detail_itinerary` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `day` int(11) NOT NULL,
  `hotel_city` int(11) NOT NULL,
  `no_of_night` int(11) NOT NULL,
  `introduction` varchar(255) NOT NULL,
  `introduction_detail` text NOT NULL,
  `transfer` varchar(255) NOT NULL,
  `transfer_description` varchar(255) NOT NULL,
  `itinerary_title` varchar(255) NOT NULL,
  `detailed_itinerary` text NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_itinerary_flight`
--

CREATE TABLE `tour_detail_itinerary_flight` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_itinerary_id` int(11) NOT NULL,
  `from_sector` varchar(255) NOT NULL,
  `to_sector` varchar(255) NOT NULL,
  `airline_id` int(11) NOT NULL,
  `departure` text NOT NULL,
  `arrival` text NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_itinerary_sightseeing`
--

CREATE TABLE `tour_detail_itinerary_sightseeing` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_itinerary_id` int(11) NOT NULL,
  `sightseeing_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_itinerary_to_hotel`
--

CREATE TABLE `tour_detail_itinerary_to_hotel` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_itinerary_id` int(11) NOT NULL,
  `hotel_id` int(11) NOT NULL,
  `room_category` int(11) NOT NULL,
  `no_of_nights` int(11) NOT NULL,
  `price_single` varchar(5) NOT NULL,
  `price_twin_sharing` varchar(5) NOT NULL,
  `price_extra_bed` varchar(5) NOT NULL,
  `price_child_no_bed` varchar(5) NOT NULL,
  `transport_type` int(11) NOT NULL,
  `transport_price` varchar(5) NOT NULL,
  `adult_occupancy_cost_price` varchar(5) NOT NULL,
  `adult_occupancy_selling_price` varchar(5) NOT NULL,
  `extra_bed_cost_price` varchar(5) NOT NULL,
  `extra_bed_selling_price` varchar(5) NOT NULL,
  `adult_twin_sharing_cost_price` varchar(5) NOT NULL,
  `adult_twin_sharing_selling_price` varchar(5) NOT NULL,
  `child_no_bed_cost_price` varchar(5) NOT NULL,
  `child_no_bed_selling_price` varchar(5) NOT NULL,
  `price_type` int(11) NOT NULL,
  `payment_description` text NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_itinerary_to_transport`
--

CREATE TABLE `tour_detail_itinerary_to_transport` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_itinerary_id` int(11) NOT NULL,
  `vehicle_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_category`
--

CREATE TABLE `tour_detail_to_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `package_category_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_departure`
--

CREATE TABLE `tour_detail_to_departure` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `departure_date` date DEFAULT NULL,
  `departure_time` time DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_destinations`
--

CREATE TABLE `tour_detail_to_destinations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_end_city`
--

CREATE TABLE `tour_detail_to_end_city` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_exclusions`
--

CREATE TABLE `tour_detail_to_exclusions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `exclusion_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_inclusion`
--

CREATE TABLE `tour_detail_to_inclusion` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `inclusion_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_inclusions`
--

CREATE TABLE `tour_detail_to_inclusions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `inclusion_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_start_city`
--

CREATE TABLE `tour_detail_to_start_city` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_theme`
--

CREATE TABLE `tour_detail_to_theme` (
  `tour_theme_id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `theme_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`tour_theme_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_detail_to_type`
--

CREATE TABLE `tour_detail_to_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `tour_type_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_fare`
--

CREATE TABLE `tour_fare` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mapping_id` int(11) NOT NULL,
  `bkg_type_id` int(11) NOT NULL,
  `currency_type_id` int(11) NOT NULL,
  `adult_price` varchar(5) NOT NULL,
  `child_price` varchar(5) NOT NULL,
  `infant_price` varchar(5) NOT NULL,
  `senior_citizen_price` varchar(5) NOT NULL,
  `is_guide_available` int(11) NOT NULL,
  `guide_lang` int(11) NOT NULL,
  `guide_cost` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_fare_log`
--

CREATE TABLE `tour_fare_log` (
  `id` int(11) NOT NULL,
  `mapping_id` int(11) NOT NULL,
  `bkg_type_id` int(11) NOT NULL,
  `currency_type_id` int(11) NOT NULL,
  `adult_price` varchar(5) NOT NULL,
  `child_price` varchar(5) NOT NULL,
  `infant_price` varchar(5) NOT NULL,
  `senior_citizen_price` varchar(5) NOT NULL,
  `is_guide_available` int(11) NOT NULL,
  `guide_lang` int(11) NOT NULL,
  `guide_cost` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_inclusion`
--

CREATE TABLE `tour_inclusion` (
  `tour_inclusion_id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_id` int(11) NOT NULL,
  `inclusion_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`tour_inclusion_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_page`
--

CREATE TABLE `tour_page` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created_by` int(11) DEFAULT NULL,
  `package_type` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `tours_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_desc` longtext COLLATE utf8_unicode_ci,
  `tours_operator` int(11) DEFAULT NULL,
  `tours_type` int(11) DEFAULT NULL,
  `country_id` int(11) DEFAULT '0',
  `state_id` int(11) DEFAULT '0',
  `area_id` int(11) DEFAULT '0',
  `post_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `starting_city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ending_city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `destination_cover` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `traveler_person` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `package_validity_from` date DEFAULT NULL,
  `package_validity_to` date DEFAULT NULL,
  `booking_validity_from` date DEFAULT NULL,
  `booking_validity_to` date DEFAULT NULL,
  `tour_type` tinyint(2) NOT NULL COMMENT '1-Private,2-Group Type',
  `tours_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `num_of_days` int(11) DEFAULT NULL,
  `num_of_nights` int(11) DEFAULT NULL,
  `rating` int(11) DEFAULT NULL,
  `inclusions` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `exclusions` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `package_category` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `package_specification` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_image_primary` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_image` text COLLATE utf8_unicode_ci,
  `tours_price` double DEFAULT NULL,
  `infant_price` double NOT NULL DEFAULT '0',
  `price_type` enum('person','package') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'package',
  `tours_date` datetime DEFAULT NULL,
  `tours_order` int(11) DEFAULT '0',
  `visiting_cities` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `related_items` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `featured` enum('0','1') COLLATE utf8_unicode_ci DEFAULT '0',
  `active` enum('1','0') COLLATE utf8_unicode_ci DEFAULT '1',
  `meta_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_desc` text COLLATE utf8_unicode_ci,
  `duration` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `costs_of_children` double DEFAULT NULL,
  `location_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `accommodates` int(11) DEFAULT NULL,
  `transportation` text COLLATE utf8_unicode_ci,
  `tour_policy` text COLLATE utf8_unicode_ci,
  `sightseeing` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Pickup_service` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `supplementary_room` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `drop_off_service` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `terms_and_condition` text COLLATE utf8_unicode_ci,
  `scheduled_on` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `spots_photo_gallery_primary` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `spots_photo_gallery` text COLLATE utf8_unicode_ci,
  `feature_google_map` text COLLATE utf8_unicode_ci,
  `tour_highlights` longtext COLLATE utf8_unicode_ci,
  `itinerary_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `itinerary_desc` longtext COLLATE utf8_unicode_ci,
  `available_expire_date` date DEFAULT '0000-00-00',
  `journey_start_date` date DEFAULT '0000-00-00',
  `entertainments` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `multilingual_guide` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `payment_desc` longtext COLLATE utf8_unicode_ci,
  `lang_flag` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `modify_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tours_page_title` (`tours_title`) USING BTREE,
  KEY `tours_page_category_id` (`package_category`) USING BTREE,
  KEY `tours_page_active` (`active`) USING BTREE,
  KEY `tours_page_featured` (`featured`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tour_related_item`
--

CREATE TABLE `tour_related_item` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_detail_id` int(11) NOT NULL,
  `related_tour_detail_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_share`
--

CREATE TABLE `tour_share` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_id` int(11) NOT NULL,
  `trip_start_date` date NOT NULL,
  `trip_end_date` date NOT NULL,
  `sac_code_id` int(11) NOT NULL,
  `base_prices_per_person` varchar(5) NOT NULL,
  `base_total_price` varchar(5) NOT NULL,
  `base_grand_total` varchar(5) NOT NULL,
  `currency_id` int(11) NOT NULL,
  `conversion_rate` varchar(5) NOT NULL,
  `prices_per_person` varchar(5) NOT NULL,
  `total_price` varchar(5) NOT NULL,
  `grand_total` varchar(5) NOT NULL,
  `gst_type` varchar(5) NOT NULL,
  `gst_rate` varchar(5) NOT NULL,
  `extra_markup` varchar(5) NOT NULL,
  `extra_discount` varchar(5) NOT NULL,
  `is_gst_included` tinyint(4) NOT NULL DEFAULT '0',
  `email_subject` varchar(255) NOT NULL,
  `customer_email` varchar(100) NOT NULL,
  `customer_firstname` varchar(100) NOT NULL,
  `customer_lastname` varchar(100) NOT NULL,
  `customer_mobile` varchar(50) NOT NULL,
  `email_cc` varchar(50) NOT NULL,
  `message` text NOT NULL,
  `is_share_with_price` tinyint(4) NOT NULL DEFAULT '0',
  `share_with_price_type` varchar(5) NOT NULL,
  `sent_date` date NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_share_flight`
--

CREATE TABLE `tour_share_flight` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_share_id` int(11) NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `is_refundable` tinyint(4) NOT NULL DEFAULT '0',
  `may_flight_rate_change` tinyint(4) NOT NULL DEFAULT '0',
  `message` text NOT NULL,
  `total_cost` varchar(5) NOT NULL,
  `total_markup` varchar(5) NOT NULL,
  `total_gst` varchar(5) NOT NULL,
  `final_price` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_share_flight_person`
--

CREATE TABLE `tour_share_flight_person` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_share_flight_id` int(11) NOT NULL,
  `person_type_id` int(11) NOT NULL,
  `no_of_persons` varchar(5) NOT NULL,
  `cost_pp` varchar(5) NOT NULL,
  `markup_pp` varchar(5) NOT NULL,
  `gst` varchar(5) NOT NULL,
  `total` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_share_room`
--

CREATE TABLE `tour_share_room` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_share_id` int(11) NOT NULL,
  `no_of_adults` varchar(5) NOT NULL,
  `no_of_children` varchar(5) NOT NULL,
  `no_of_infants` varchar(5) NOT NULL,
  `extra_single_occupancy_adult` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_share_room_children`
--

CREATE TABLE `tour_share_room_children` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_share_room_id` int(11) NOT NULL,
  `child_age` varchar(5) NOT NULL,
  `extra_single_occupancy_adult` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_theme`
--

CREATE TABLE `tour_theme` (
  `tour_theme_id` int(11) NOT NULL AUTO_INCREMENT,
  `tour_id` int(11) NOT NULL,
  `theme_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`tour_theme_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tour_type`
--

CREATE TABLE `tour_type` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tour_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) CHARACTER SET latin1 NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tours_type_business_type` (`tour_type`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tours_calendar`
--

CREATE TABLE `tours_calendar` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tours_id` int(11) NOT NULL,
  `start_date` datetime NOT NULL,
  `end_date` datetime NOT NULL,
  `available_status` int(11) NOT NULL,
  `entry_by` int(11) NOT NULL,
  `entry_date` datetime DEFAULT NULL,
  `modify_by` int(11) DEFAULT NULL,
  `modify_date` datetime DEFAULT NULL,
  `lang_flag` varchar(50) COLLATE utf8_unicode_ci DEFAULT 'en_US',
  PRIMARY KEY (`id`),
  KEY `tours_calendar_tour_id` (`tours_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tours_category`
--

CREATE TABLE `tours_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created_by` int(11) DEFAULT NULL,
  `tour_category_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `category_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `category_thumb` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `category_desc` text COLLATE utf8_unicode_ci,
  `category_order` int(11) DEFAULT '0',
  `cat_date` datetime DEFAULT NULL,
  `modify_date` datetime DEFAULT '0000-00-00 00:00:00',
  `meta_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_desc` text COLLATE utf8_unicode_ci,
  `lang_flag` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tours_category_category_title` (`category_title`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tours_package_type`
--

CREATE TABLE `tours_package_type` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tour_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) CHARACTER SET latin1 NOT NULL,
  `lang_flag` varchar(250) COLLATE utf8_unicode_ci DEFAULT 'en_US',
  PRIMARY KEY (`id`),
  KEY `tours_type_business_type` (`tour_type`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tours_page`
--

CREATE TABLE `tours_page` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category_id` int(11) DEFAULT '0',
  `created_by` int(11) DEFAULT NULL,
  `tours_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_operator` int(11) DEFAULT NULL,
  `tours_type` int(11) DEFAULT NULL,
  `country_id` int(11) DEFAULT '0',
  `state_id` int(11) DEFAULT '0',
  `area_id` int(11) DEFAULT '0',
  `post_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `destination_cover` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `traveler_person` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `package_validity_from` date DEFAULT NULL,
  `package_validity_to` date DEFAULT NULL,
  `booking_validity_from` date DEFAULT NULL,
  `booking_validity_to` date DEFAULT NULL,
  `tour_type` tinyint(2) NOT NULL COMMENT '1-Private,2-Group Type',
  `tours_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `num_of_days` int(11) DEFAULT NULL,
  `num_of_nights` int(11) DEFAULT NULL,
  `rating` int(11) DEFAULT NULL,
  `tours_image_primary` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tours_image` text COLLATE utf8_unicode_ci,
  `tours_price` double DEFAULT NULL,
  `infant_price` double NOT NULL DEFAULT '0',
  `price_type` enum('person','package') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'package',
  `tours_desc` longtext COLLATE utf8_unicode_ci,
  `tours_date` datetime DEFAULT NULL,
  `tours_order` int(11) DEFAULT '0',
  `related_items` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `featured` enum('0','1') COLLATE utf8_unicode_ci DEFAULT '0',
  `active` enum('1','0') COLLATE utf8_unicode_ci DEFAULT '1',
  `meta_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `meta_desc` text COLLATE utf8_unicode_ci,
  `duration` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `costs_of_children` double DEFAULT NULL,
  `location_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `accommodates` int(11) DEFAULT NULL,
  `transportation` text COLLATE utf8_unicode_ci,
  `inclusions` text COLLATE utf8_unicode_ci,
  `exclusions` text COLLATE utf8_unicode_ci,
  `ending_city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `visiting_cities` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tour_policy` text COLLATE utf8_unicode_ci,
  `sightseeing` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Pickup_service` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `supplementary_room` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `drop_off_service` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `terms_and_condition` text COLLATE utf8_unicode_ci,
  `scheduled_on` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `spots_photo_gallery_primary` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `spots_photo_gallery` text COLLATE utf8_unicode_ci,
  `feature_google_map` text COLLATE utf8_unicode_ci,
  `tour_highlights` longtext COLLATE utf8_unicode_ci,
  `itinerary_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `itinerary_desc` longtext COLLATE utf8_unicode_ci,
  `available_expire_date` date DEFAULT '0000-00-00',
  `journey_start_date` date DEFAULT '0000-00-00',
  `entertainments` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `starting_city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `multilingual_guide` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `payment_desc` longtext COLLATE utf8_unicode_ci,
  `lang_flag` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `modify_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tours_page_title` (`tours_title`) USING BTREE,
  KEY `tours_page_category_id` (`category_id`) USING BTREE,
  KEY `tours_page_active` (`active`) USING BTREE,
  KEY `tours_page_featured` (`featured`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tours_preferences`
--

CREATE TABLE `tours_preferences` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `field_name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `field_value` text COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tours_preference_name` (`field_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tours_saved`
--

CREATE TABLE `tours_saved` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tours_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tours_type`
--

CREATE TABLE `tours_type` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tour_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) CHARACTER SET latin1 NOT NULL,
  `lang_flag` varchar(250) COLLATE utf8_unicode_ci DEFAULT 'en_US',
  PRIMARY KEY (`id`),
  KEY `tours_type_business_type` (`tour_type`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `transport_routes_city`
--

CREATE TABLE `transport_routes_city` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `transport_route_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `no_of_nights` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `transport_routes_vehicles`
--

CREATE TABLE `transport_routes_vehicles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `transport_route_id` int(11) NOT NULL,
  `vehicle_type_id` int(11) NOT NULL,
  `vehicle_master_id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `currency_id` int(11) NOT NULL,
  `cost` varchar(5) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `traveller`
--

CREATE TABLE `traveller` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `UID` int(11) NOT NULL,
  `Booking_Id` int(11) NOT NULL,
  `Name` varchar(50) NOT NULL,
  `Mobile` int(11) NOT NULL,
  `Note` text NOT NULL,
  `CarType` varchar(50) NOT NULL,
  `BookingType` varchar(50) NOT NULL,
  `BookingDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `traveller_details`
--

CREATE TABLE `traveller_details` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `booking_id` int(11) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_type_id` int(11) NOT NULL,
  `user_grade` varchar(5) DEFAULT NULL,
  `username` varchar(255) DEFAULT NULL,
  `company_id` int(11) DEFAULT NULL,
  `parent_id` int(11) NOT NULL DEFAULT '0',
  `first_name` varchar(20) NOT NULL,
  `last_name` varchar(20) NOT NULL,
  `email` varchar(100) NOT NULL,
  `mobile_prefix` varchar(10) DEFAULT NULL,
  `mobile` varchar(50) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `gender` enum('Male','Female') DEFAULT NULL,
  `nationality` int(11) DEFAULT '0',
  `wallet_amount` double(10,2) DEFAULT '0.00',
  `gcm_id` text,
  `login_status` int(11) NOT NULL DEFAULT '0',
  `login_time` datetime DEFAULT NULL,
  `logout_time` datetime DEFAULT NULL,
  `login_otp_status` tinyint(2) DEFAULT '1' COMMENT '0-Off otp winodow, 1- On otp window',
  `email_verified` int(11) NOT NULL DEFAULT '0',
  `phone_verified` int(11) NOT NULL DEFAULT '0',
  `referral_key` varchar(50) DEFAULT NULL,
  `refer_by` varchar(50) DEFAULT NULL,
  `is_active` tinyint(2) DEFAULT '4' COMMENT '4-Inactive,1-Active,2-OnHold,3-Blacklist,5-unapproved',
  `duty_status` tinyint(2) NOT NULL DEFAULT '0',
  `newsletter_subscription` tinyint(2) NOT NULL DEFAULT '0',
  `mobile_promotion` tinyint(2) NOT NULL DEFAULT '0',
  `accept_fare` tinyint(4) NOT NULL DEFAULT '0',
  `modified_by` int(11) DEFAULT '0',
  `signup_status` tinyint(2) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL DEFAULT '0',
  `updated_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1025 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_altno_tracking`
--

CREATE TABLE `user_altno_tracking` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `alt_no` varchar(15) NOT NULL,
  `status` varchar(5) NOT NULL DEFAULT 'false',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_id` (`user_id`,`alt_no`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_assign_module`
--

CREATE TABLE `user_assign_module` (
  `assign_module_id` int(11) NOT NULL AUTO_INCREMENT,
  `assign_role_id` int(11) NOT NULL,
  `module_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`assign_module_id`)
) ENGINE=InnoDB AUTO_INCREMENT=203 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_assign_role`
--

CREATE TABLE `user_assign_role` (
  `assign_role_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  `department_id` int(11) DEFAULT NULL,
  `created_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`assign_role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_assigned_role`
--

CREATE TABLE `user_assigned_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active,2-Deleted',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=168 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_basic_fare_settings`
--

CREATE TABLE `user_basic_fare_settings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT '0',
  `rounding` tinyint(4) NOT NULL COMMENT '1-Cash,2-Account / Credit Card',
  `level` tinyint(4) NOT NULL COMMENT '1-Normal,2-Decimal,3-Unit',
  `direction` tinyint(4) NOT NULL COMMENT '1-Nearest,2-Upward,3-Downward',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_booking_type_mapping`
--

CREATE TABLE `user_booking_type_mapping` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `city_id` int(11) NOT NULL,
  `master_package_id` int(11) DEFAULT NULL COMMENT 'company table auto id',
  `master_package_mode_id` int(11) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active',
  `ip` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1 COMMENT='need to be delete, Duplicate enty add in company table';

--
-- Table structure for table `user_cancellation_fare`
--

CREATE TABLE `user_cancellation_fare` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `master_booking_type_id` int(11) DEFAULT NULL,
  `booking_type` int(11) NOT NULL,
  `cancellation_master_id` int(11) NOT NULL,
  `currency_id` int(11) NOT NULL,
  `cancellation_type` varchar(10) NOT NULL,
  `cancellation_value` float NOT NULL DEFAULT '0',
  `round_off` int(11) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `days` varchar(10) NOT NULL DEFAULT '0',
  `hours` varchar(10) NOT NULL DEFAULT '0',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active,2-Deleted',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_cancellation_fare_logs`
--

CREATE TABLE `user_cancellation_fare_logs` (
  `log_id` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  `master_booking_type_id` int(11) DEFAULT NULL,
  `booking_type` int(11) NOT NULL,
  `cancellation_master_id` int(11) NOT NULL,
  `cancellation_type` varchar(10) NOT NULL,
  `cancellation_value` float NOT NULL DEFAULT '0',
  `round_off` int(11) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active,2-Deleted',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_company_mapping`
--

CREATE TABLE `user_company_mapping` (
  `user_company_mapp_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `company_info_id` int(11) NOT NULL COMMENT 'company table auto id',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active',
  PRIMARY KEY (`user_company_mapp_id`)
) ENGINE=InnoDB AUTO_INCREMENT=74 DEFAULT CHARSET=latin1 COMMENT='need to be delete, Duplicate enty add in company table';

--
-- Table structure for table `user_company_share`
--

CREATE TABLE `user_company_share` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL,
  `share_type_id` tinyint(4) NOT NULL COMMENT '1-company,2-Partner,3-Driver',
  `share_value_type` tinyint(4) NOT NULL COMMENT '1-%,2-Rs',
  `share_value` varchar(10) NOT NULL,
  `company_share_type` tinyint(4) DEFAULT NULL,
  `company_share_value` varchar(10) NOT NULL,
  `partner_share_type` tinyint(4) DEFAULT NULL,
  `partner_share_value` varchar(10) NOT NULL,
  `driver_share_type` tinyint(4) DEFAULT NULL,
  `driver_share_value` varchar(10) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_company_share_logs`
--

CREATE TABLE `user_company_share_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `share_type_id` tinyint(4) NOT NULL COMMENT '1-company,2-Partner,3-Driver',
  `share_value_type` tinyint(4) NOT NULL COMMENT '1-%,2-Rs',
  `share_value` varchar(10) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Temporary table structure for view `user_credit_balance`
--

/*!50001 DROP VIEW IF EXISTS `user_credit_balance`*/;
/*!50001 CREATE VIEW `user_credit_balance` AS SELECT 
 1 AS `id`,
 1 AS `username`,
 1 AS `email`,
 1 AS `mobile`,
 1 AS `is_active`,
 1 AS `user_type_id`,
 1 AS `user_type`,
 1 AS `from_date`,
 1 AS `to_date`,
 1 AS `credit_limit_amount`,
 1 AS `booking_amount`,
 1 AS `credit_balance`*/;

--
-- Table structure for table `user_credit_limit`
--

CREATE TABLE `user_credit_limit` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `credit_limit_amount` double(11,2) NOT NULL,
  `from_date` date DEFAULT NULL,
  `to_date` date DEFAULT NULL,
  `created_date` date NOT NULL,
  `modifed_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `approved_by` int(11) NOT NULL DEFAULT '0',
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `modified_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `approved_status` tinyint(2) NOT NULL DEFAULT '0',
  `ip` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_current_location`
--

CREATE TABLE `user_current_location` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT '0',
  `current_latitude` varchar(100) DEFAULT '0',
  `current_longitude` varchar(100) DEFAULT '0',
  `distance` float NOT NULL DEFAULT '0',
  `datetime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4030732 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_domain_package`
--

CREATE TABLE `user_domain_package` (
  `domain_package_id` int(11) NOT NULL AUTO_INCREMENT,
  `domain_register_id` int(11) NOT NULL,
  `package_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `ip` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`domain_package_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;

--
-- Table structure for table `user_domain_register`
--

CREATE TABLE `user_domain_register` (
  `domain_register_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_license_id` int(11) NOT NULL,
  `domain_name` varchar(255) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`domain_register_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4;

--
-- Table structure for table `user_duty_pref`
--

CREATE TABLE `user_duty_pref` (
  `user_duty_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `package_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active,2-Deleted',
  PRIMARY KEY (`user_duty_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1567 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_extras`
--

CREATE TABLE `user_extras` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `extras_master_id` varchar(100) NOT NULL,
  `extra_value_type` varchar(10) DEFAULT NULL COMMENT '%, Rs',
  `extra_value` int(11) DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_extras_logs`
--

CREATE TABLE `user_extras_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `extras_master_id` varchar(100) NOT NULL,
  `extra_value_type` varchar(10) DEFAULT NULL COMMENT '%, Rs',
  `extra_value` int(11) DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_fix_route`
--

CREATE TABLE `user_fix_route` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `frequent_location` varchar(30) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_fix_route_logs`
--

CREATE TABLE `user_fix_route_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `frequent_location` varchar(30) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_grade`
--

CREATE TABLE `user_grade` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `grade_name` varchar(255) DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_info`
--

CREATE TABLE `user_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `alternate_mobile` varchar(20) COLLATE latin1_general_cs DEFAULT NULL,
  `alternate_email` varchar(111) COLLATE latin1_general_cs DEFAULT NULL,
  `country_id` int(11) DEFAULT NULL,
  `state_id` int(11) DEFAULT NULL,
  `city_id` int(11) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `father_name` varchar(100) COLLATE latin1_general_cs DEFAULT NULL,
  `address` text COLLATE latin1_general_cs,
  `address2` varchar(100) COLLATE latin1_general_cs DEFAULT NULL,
  `pincode` int(11) DEFAULT NULL,
  `landline_number` varchar(111) COLLATE latin1_general_cs DEFAULT NULL,
  `gst_registration_number` varchar(100) COLLATE latin1_general_cs DEFAULT NULL,
  `kyc_type` int(11) DEFAULT NULL,
  `kyc` varchar(25) COLLATE latin1_general_cs DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1027 DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

--
-- Table structure for table `user_ip_location`
--

CREATE TABLE `user_ip_location` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ip_address` varchar(50) DEFAULT NULL,
  `city` varchar(50) DEFAULT NULL,
  `region` varchar(50) DEFAULT NULL,
  `country` varchar(50) DEFAULT NULL,
  `lat` varchar(50) DEFAULT NULL,
  `log` varchar(50) NOT NULL,
  `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COMMENT='User Ip address get location and store ';

--
-- Table structure for table `user_language`
--

CREATE TABLE `user_language` (
  `user_lang_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `language_id` int(11) NOT NULL,
  `language_type` enum('Read','Write','Speak') DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` int(11) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active',
  PRIMARY KEY (`user_lang_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1380 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_license`
--

CREATE TABLE `user_license` (
  `user_license_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `owner_name` varchar(255) NOT NULL,
  `owner_email` varchar(225) NOT NULL,
  `owner_mobile` varchar(15) NOT NULL,
  `owner_address` text,
  `license_key` varchar(255) NOT NULL,
  `license_start_date` date NOT NULL,
  `license_end_date` date NOT NULL,
  `no_of_domain` int(11) NOT NULL,
  `package_id` int(11) NOT NULL,
  `license_option` varchar(50) NOT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) DEFAULT NULL,
  `ip` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`user_license_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4;

--
-- Table structure for table `user_location`
--

CREATE TABLE `user_location` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT '0',
  `lat` varchar(100) DEFAULT '0',
  `longi` varchar(100) DEFAULT '0',
  `datetime` timestamp NULL DEFAULT NULL,
  `distance` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_markup`
--

CREATE TABLE `user_markup` (
  `user_markup_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `country_id` int(11) NOT NULL,
  `state_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `booking_type_id` int(11) NOT NULL,
  `vehicle_type_id` int(3) NOT NULL,
  `basic_amt` int(5) NOT NULL,
  `per_km_rate` int(2) NOT NULL,
  `per_hr_rate` int(2) NOT NULL,
  `markup_type_id` int(11) NOT NULL,
  `markup_amount` varchar(255) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`user_markup_id`),
  KEY `user_id` (`state_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_membership`
--

CREATE TABLE `user_membership` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `subpackage_id` int(11) NOT NULL DEFAULT '1',
  `membership_status` int(11) NOT NULL,
  `package_start_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `package_end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `profile_view` int(11) NOT NULL DEFAULT '0',
  `contact_view` int(11) NOT NULL DEFAULT '0',
  `send_request` int(11) NOT NULL DEFAULT '0',
  `is_active` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_night_charge`
--

CREATE TABLE `user_night_charge` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT '0',
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `night_rate_begins` time NOT NULL DEFAULT '00:00:00',
  `night_rate_ends` time NOT NULL DEFAULT '00:00:00',
  `night_rate_type` varchar(10) DEFAULT NULL COMMENT '1-%,2-Rs',
  `night_rate_value` varchar(10) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_date` date NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_night_charge_logs`
--

CREATE TABLE `user_night_charge_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `base_vehicle_id` int(11) NOT NULL COMMENT 'base_vehicle_type(table Auto id)',
  `vendor_id` int(11) NOT NULL DEFAULT '0',
  `night_rate_begins` time NOT NULL DEFAULT '00:00:00',
  `night_rate_ends` time NOT NULL DEFAULT '00:00:00',
  `night_rate_type` varchar(10) DEFAULT NULL COMMENT '1-%,2-Rs',
  `night_rate_value` varchar(10) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_date` date NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_old`
--

CREATE TABLE `user_old` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_type_id` int(11) NOT NULL,
  `user_grade` varchar(5) DEFAULT NULL,
  `username` varchar(255) DEFAULT NULL,
  `company_id` int(11) DEFAULT NULL,
  `parent_id` int(11) NOT NULL DEFAULT '0',
  `first_name` varchar(20) NOT NULL,
  `last_name` varchar(20) NOT NULL,
  `email` varchar(100) NOT NULL,
  `mobile_prefix` varchar(10) DEFAULT NULL,
  `mobile` varchar(50) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `gender` enum('Male','Female') DEFAULT NULL,
  `nationality` int(11) DEFAULT '0',
  `wallet_amount` double(10,2) DEFAULT '0.00',
  `gcm_id` text,
  `login_status` int(11) NOT NULL DEFAULT '0',
  `login_time` datetime DEFAULT NULL,
  `logout_time` datetime DEFAULT NULL,
  `login_otp_status` tinyint(2) DEFAULT '1' COMMENT '0-Off otp winodow, 1- On otp window',
  `email_verified` int(11) NOT NULL DEFAULT '0',
  `phone_verified` int(11) NOT NULL DEFAULT '0',
  `referral_key` varchar(50) DEFAULT NULL,
  `refer_by` varchar(50) DEFAULT NULL,
  `is_active` tinyint(2) DEFAULT '4' COMMENT '4-Inactive,1-Active,2-OnHold,3-Blacklist,5-unapproved',
  `duty_status` tinyint(2) NOT NULL DEFAULT '0',
  `newsletter_subscription` tinyint(2) NOT NULL DEFAULT '0',
  `mobile_promotion` tinyint(2) NOT NULL DEFAULT '0',
  `modified_by` int(11) DEFAULT '0',
  `signup_status` tinyint(2) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL DEFAULT '0',
  `updated_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=972 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_payment_type`
--

CREATE TABLE `user_payment_type` (
  `user_payment_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `payment_type_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active',
  PRIMARY KEY (`user_payment_id`)
) ENGINE=InnoDB AUTO_INCREMENT=784 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_peak_time_charge`
--

CREATE TABLE `user_peak_time_charge` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `peaktime_type` varchar(10) NOT NULL DEFAULT '%',
  `peaktime_value` int(5) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` enum('1','0') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_peak_time_charge_logs`
--

CREATE TABLE `user_peak_time_charge_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `peaktime_type` varchar(10) NOT NULL DEFAULT '%',
  `peaktime_value` int(5) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` enum('1','0') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_postalcode_fare`
--

CREATE TABLE `user_postalcode_fare` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `pickup_postcode` text NOT NULL,
  `drop_postcode` text NOT NULL,
  `price` varchar(10) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_postalcode_fare_logs`
--

CREATE TABLE `user_postalcode_fare_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `pickup_postcode` text NOT NULL,
  `drop_postcode` text NOT NULL,
  `price` varchar(10) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_pre_waiting_charge`
--

CREATE TABLE `user_pre_waiting_charge` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `pre_waiting_upto_minutes` text NOT NULL,
  `pre_waiting_fees` varchar(5) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_pre_waiting_charge_logs`
--

CREATE TABLE `user_pre_waiting_charge_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `pre_waiting_upto_minutes` text NOT NULL,
  `pre_waiting_fees` varchar(5) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_pref_drive_city`
--

CREATE TABLE `user_pref_drive_city` (
  `user_drive_city_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `city_id` int(11) NOT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active',
  PRIMARY KEY (`user_drive_city_id`)
) ENGINE=InnoDB AUTO_INCREMENT=947 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_premiums_fare`
--

CREATE TABLE `user_premiums_fare` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `premiums_type` varchar(10) NOT NULL COMMENT '1-%,2-Rs',
  `premiums_value` varchar(5) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_premiums_fare_logs`
--

CREATE TABLE `user_premiums_fare_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `base_vehicle_id` int(11) NOT NULL,
  `premiums_type` varchar(10) NOT NULL COMMENT '1-%,2-Rs',
  `premiums_value` varchar(5) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` enum('1','0') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_rating`
--

CREATE TABLE `user_rating` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `BookingId` int(11) DEFAULT NULL,
  `DriverId` int(11) DEFAULT NULL,
  `UserId` int(11) DEFAULT NULL,
  `Rating` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `BookingId` (`BookingId`)
) ENGINE=InnoDB AUTO_INCREMENT=134 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_relation_manager`
--

CREATE TABLE `user_relation_manager` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `staff_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_role`
--

CREATE TABLE `user_role` (
  `Role_ID` int(11) NOT NULL AUTO_INCREMENT,
  `role_type` int(11) NOT NULL,
  `RoleName` varchar(50) NOT NULL,
  `CreatedBy` int(11) NOT NULL DEFAULT '0' COMMENT 'User ID from User Table',
  `ModifiedDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `IsDeleted` tinyint(1) NOT NULL DEFAULT '0',
  `IsApproved` tinyint(1) NOT NULL DEFAULT '0',
  `IsActive` int(11) NOT NULL DEFAULT '1' COMMENT '1=Active,2=InActive',
  `ApprovedBy` int(11) NOT NULL DEFAULT '0' COMMENT 'UID',
  `RoleDescription` varchar(200) NOT NULL,
  `created_date` datetime NOT NULL,
  PRIMARY KEY (`Role_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_role_vendor`
--

CREATE TABLE `user_role_vendor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `booking_type_id` int(11) NOT NULL,
  `user_role_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_signature`
--

CREATE TABLE `user_signature` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `signature` longtext NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `ip` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_transaction`
--

CREATE TABLE `user_transaction` (
  `booking_trans_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_id` int(11) NOT NULL,
  `payment_upload_id` int(11) DEFAULT '0',
  `payment_response_id` int(11) DEFAULT NULL COMMENT 'payment_transaction_response auto id',
  `booking_transaction_no` varchar(150) DEFAULT NULL COMMENT 'comnpany generated tranasction no',
  `action_type` varchar(50) DEFAULT NULL,
  `amount` double(10,2) NOT NULL,
  `current_balance` double(10,2) DEFAULT '0.00',
  `payment_type_id` tinyint(1) DEFAULT NULL COMMENT 'Cash,Credit,Cheque etc...',
  `payment_status` tinyint(2) DEFAULT NULL COMMENT '1-Success,2-Failed',
  `created_date` date NOT NULL,
  `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `status` varchar(50) DEFAULT NULL,
  `reason` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`booking_trans_id`)
) ENGINE=InnoDB AUTO_INCREMENT=149 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_type_role`
--

CREATE TABLE `user_type_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `booking_type_id` int(11) NOT NULL,
  `user_role_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_upload_document`
--

CREATE TABLE `user_upload_document` (
  `upload_doc_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `document_type_id` int(11) NOT NULL,
  `doc_file_upload` text NOT NULL,
  `doc_approval_status` tinyint(2) NOT NULL DEFAULT '0',
  `doc_default_status` tinyint(2) NOT NULL DEFAULT '0',
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`upload_doc_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1935 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_vehicle_mapping`
--

CREATE TABLE `user_vehicle_mapping` (
  `user_vehicle_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `vehicle_master_id` int(11) DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active',
  PRIMARY KEY (`user_vehicle_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=347 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_waiting_charge`
--

CREATE TABLE `user_waiting_charge` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `booking_type` int(11) NOT NULL DEFAULT '0',
  `waiting_minute_upto` varchar(5) NOT NULL,
  `waiting_fees` varchar(5) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_waiting_charge_logs`
--

CREATE TABLE `user_waiting_charge_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `waiting_minute_upto` varchar(5) NOT NULL,
  `waiting_fees` varchar(5) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_wallet_transaction`
--

CREATE TABLE `user_wallet_transaction` (
  `wallet_trans_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `amount` double(10,2) NOT NULL,
  `expiry_date` date NOT NULL,
  `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(4) NOT NULL,
  PRIMARY KEY (`wallet_trans_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `user_wallet_transaction_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=107 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_weekoff_mapping`
--

CREATE TABLE `user_weekoff_mapping` (
  `user_weekoff_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `week_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modify_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`user_weekoff_id`)
) ENGINE=InnoDB AUTO_INCREMENT=239 DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_workingshift_mapping`
--

CREATE TABLE `user_workingshift_mapping` (
  `user_workingshift_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `working_shift_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL DEFAULT '0',
  `modify_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`user_workingshift_id`)
) ENGINE=InnoDB AUTO_INCREMENT=629 DEFAULT CHARSET=latin1;

--
-- Table structure for table `usertype_module`
--

CREATE TABLE `usertype_module` (
  `rule_id` int(11) NOT NULL AUTO_INCREMENT,
  `usertype_id` int(11) NOT NULL,
  `module_id` int(11) NOT NULL,
  `is_read` tinyint(4) DEFAULT NULL,
  `is_write` tinyint(4) DEFAULT NULL,
  `is_delete` int(11) NOT NULL,
  `order_menu` int(11) DEFAULT '0',
  `created_by` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`rule_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1419 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vehicle_amenities`
--

CREATE TABLE `vehicle_amenities` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `vehicle_master_id` int(11) NOT NULL,
  `amenities_id` int(11) NOT NULL,
  `created_date` date NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=334 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vehicle_master`
--

CREATE TABLE `vehicle_master` (
  `vehicle_master_id` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) NOT NULL,
  `image` varchar(255) DEFAULT NULL,
  `model` varchar(255) DEFAULT NULL,
  `ignition_type_id` int(11) DEFAULT NULL,
  `permit_exp_date` date DEFAULT NULL,
  `color` varchar(255) DEFAULT NULL,
  `vehicle_no` varchar(50) DEFAULT NULL,
  `rc_no` varchar(50) DEFAULT NULL,
  `vehicle_owner_type` enum('Owned','Attached') DEFAULT 'Owned',
  `vehicle_owner_name` varchar(100) DEFAULT NULL,
  `vehicle_owner_mobile` varchar(15) DEFAULT NULL,
  `passenger` tinyint(4) DEFAULT '0',
  `large_suitcase` tinyint(2) DEFAULT '0',
  `small_suitcase` tinyint(2) DEFAULT '0',
  `insurance_validity` date DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `created_by` int(11) NOT NULL DEFAULT '0',
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0-unpublish,1-publish,2-delete',
  PRIMARY KEY (`vehicle_master_id`)
) ENGINE=InnoDB AUTO_INCREMENT=360 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vendor`
--

CREATE TABLE `vendor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `UID` int(11) NOT NULL,
  `vendor_name` varchar(50) NOT NULL,
  `vendor_email` varchar(50) NOT NULL,
  `group_name` varchar(50) NOT NULL,
  `status` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=130 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vendor_bill`
--

CREATE TABLE `vendor_bill` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `BookingID` int(11) NOT NULL COMMENT 'Reference for Booking Register',
  `waitingCharge` varchar(50) NOT NULL COMMENT 'Charges to be paid',
  `tripCharge` float NOT NULL COMMENT 'Reason for charge',
  `minimumCharge` int(11) NOT NULL COMMENT 'Driver/csr',
  `totalBill` double NOT NULL,
  `AddedTime` datetime NOT NULL COMMENT 'Server Time',
  `is_paid` int(11) NOT NULL,
  `balance_amt` double(10,2) NOT NULL DEFAULT '0.00',
  `paid_at` datetime NOT NULL,
  `currency` varchar(11) NOT NULL,
  `invoice_number` varchar(100) DEFAULT NULL,
  `payment_type` varchar(20) NOT NULL,
  `fees` int(11) NOT NULL,
  `total_price` int(11) NOT NULL,
  `total_tax_price` int(11) NOT NULL,
  `distance_rate` int(11) NOT NULL,
  `duration_rate` int(11) NOT NULL,
  `starting_rate` int(11) NOT NULL,
  `base_price` int(11) NOT NULL,
  `tax_price` int(11) NOT NULL,
  `starting_charge` int(11) NOT NULL,
  `distance_charge` int(11) NOT NULL,
  `duration_charge` int(11) NOT NULL,
  `minimum_distance` int(11) NOT NULL,
  `cancellation_price` int(11) NOT NULL,
  `companyshare` int(11) NOT NULL,
  `drivershare` int(11) NOT NULL,
  `partnershare` int(50) NOT NULL,
  `minimum_price` int(11) DEFAULT NULL,
  `extracharges` int(11) NOT NULL,
  `nightcharge_unit` varchar(10) NOT NULL,
  `nightcharge` varchar(5) NOT NULL,
  `nightcharge_price` varchar(5) NOT NULL,
  `night_rate_begins` varchar(5) NOT NULL,
  `night_rate_ends` varchar(5) NOT NULL,
  `extras` text NOT NULL,
  `extraPrice` int(11) NOT NULL,
  `peakTimePrice` int(11) NOT NULL,
  `peaktimeFrom` time NOT NULL,
  `peaktimeTo` time NOT NULL,
  `peaktimepercentage` varchar(3) NOT NULL,
  `basic_tax` varchar(5) NOT NULL,
  `basic_tax_type` varchar(10) NOT NULL,
  `basic_tax_price` varchar(5) NOT NULL,
  `pre_waiting_time` time NOT NULL,
  `pre_waiting_charge` int(11) NOT NULL,
  `waiting_time` time NOT NULL,
  `waiting_charge` int(11) NOT NULL,
  `krishikalyan_tax` int(11) NOT NULL,
  `swachhbharat_tax` int(11) NOT NULL,
  `krishikalyan_tax_price` int(11) NOT NULL,
  `swachhbharat_tax_price` int(11) NOT NULL,
  `estimated_price_before_markup` int(11) NOT NULL,
  `markup_type` varchar(5) NOT NULL,
  `markup_value` int(11) NOT NULL,
  `markup_price` int(11) NOT NULL,
  `driver_share_amt` int(11) NOT NULL,
  `comp_share_amt` int(11) NOT NULL,
  `partner_share_amt` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `BookingID` (`BookingID`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vendor_charges`
--

CREATE TABLE `vendor_charges` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `BookingID` int(11) NOT NULL COMMENT 'Reference for Booking Register',
  `waitingCharge` varchar(50) NOT NULL COMMENT 'Charges to be paid',
  `tripCharge` float NOT NULL COMMENT 'Reason for charge',
  `minimumCharge` int(11) NOT NULL COMMENT 'Driver/csr',
  `totalBill` double NOT NULL,
  `AddedTime` datetime NOT NULL COMMENT 'Server Time',
  `is_paid` int(11) NOT NULL,
  `balance_amt` double(10,2) NOT NULL DEFAULT '0.00',
  `paid_at` datetime NOT NULL,
  `currency` varchar(11) NOT NULL,
  `invoice_number` varchar(100) DEFAULT NULL,
  `payment_type` varchar(20) NOT NULL,
  `fees` int(11) NOT NULL,
  `total_price` int(11) NOT NULL,
  `total_tax_price` int(11) NOT NULL,
  `distance_rate` int(11) NOT NULL,
  `duration_rate` int(11) NOT NULL,
  `starting_rate` int(11) NOT NULL,
  `base_price` int(11) NOT NULL,
  `tax_price` int(11) NOT NULL,
  `starting_charge` int(11) NOT NULL,
  `distance_charge` int(11) NOT NULL,
  `duration_charge` int(11) NOT NULL,
  `minimum_distance` int(11) NOT NULL,
  `cancellation_price` int(11) NOT NULL,
  `minimum_price` int(11) DEFAULT NULL,
  `extracharges` int(11) NOT NULL,
  `nightcharge_unit` varchar(10) NOT NULL,
  `nightcharge` varchar(5) NOT NULL,
  `nightcharge_price` varchar(5) NOT NULL,
  `night_rate_begins` varchar(5) NOT NULL,
  `night_rate_ends` varchar(5) NOT NULL,
  `extras` text NOT NULL,
  `extraPrice` int(11) NOT NULL,
  `peakTimePrice` int(11) NOT NULL,
  `peaktimeFrom` time NOT NULL,
  `peaktimeTo` time NOT NULL,
  `peaktimepercentage` varchar(3) NOT NULL,
  `basic_tax` varchar(5) NOT NULL,
  `basic_tax_type` varchar(10) NOT NULL,
  `basic_tax_price` varchar(5) NOT NULL,
  `pre_waiting_time` time NOT NULL,
  `pre_waiting_charge` int(11) NOT NULL,
  `waiting_time` time NOT NULL,
  `waiting_charge` int(11) NOT NULL,
  `estimated_price_before_markup` int(11) NOT NULL,
  `markup_type` varchar(5) NOT NULL,
  `markup_value` int(11) NOT NULL,
  `markup_price` int(11) NOT NULL,
  `driver_share_amt` int(11) NOT NULL,
  `comp_share_amt` int(11) NOT NULL,
  `partner_share_amt` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `BookingID` (`BookingID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vendor_markup`
--

CREATE TABLE `vendor_markup` (
  `vendor_markup_id` int(11) NOT NULL AUTO_INCREMENT,
  `company_id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `base_comb_id` int(11) DEFAULT NULL,
  `markup_category` int(11) DEFAULT NULL COMMENT '1-user,2-Booking Type,3-Country,4-City',
  `mark_amt_type` varchar(10) DEFAULT NULL COMMENT '''%'',''Rs''',
  `basic_amt` int(5) NOT NULL,
  `per_km_rate` int(2) NOT NULL,
  `per_hr_rate` int(2) NOT NULL,
  `markup_type_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  `status` enum('0','1') NOT NULL,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`vendor_markup_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vendor_status`
--

CREATE TABLE `vendor_status` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT '0',
  `booking_id` int(11) NOT NULL DEFAULT '0',
  `vendor_status` int(11) NOT NULL DEFAULT '0',
  `start_date` datetime DEFAULT NULL,
  `end_date` datetime DEFAULT NULL,
  `started_time` time DEFAULT NULL,
  `estimated_end_time` time DEFAULT NULL,
  `created_by` int(11) NOT NULL DEFAULT '0',
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Temporary table structure for view `view_booking_charge`
--

/*!50001 DROP VIEW IF EXISTS `view_booking_charge`*/;
/*!50001 CREATE VIEW `view_booking_charge` AS SELECT 
 1 AS `id`,
 1 AS `BookingID`,
 1 AS `waitingCharge`,
 1 AS `tripCharge`,
 1 AS `minimumCharge`,
 1 AS `totalBill`,
 1 AS `AddedTime`,
 1 AS `is_paid`,
 1 AS `billing_status`,
 1 AS `paid_at`,
 1 AS `currency`,
 1 AS `booking_invoice_id`,
 1 AS `invoice_number`,
 1 AS `payment_type`,
 1 AS `fees`,
 1 AS `total_price`,
 1 AS `total_tax_price`,
 1 AS `distance_rate`,
 1 AS `duration_rate`,
 1 AS `starting_rate`,
 1 AS `base_price`,
 1 AS `tax_price`,
 1 AS `starting_charge`,
 1 AS `distance_charge`,
 1 AS `duration_charge`,
 1 AS `minimum_distance`,
 1 AS `cancellation_price`,
 1 AS `companyshare`,
 1 AS `drivershare`,
 1 AS `partnershare`,
 1 AS `minimum_price`,
 1 AS `extracharges`,
 1 AS `nightcharge_unit`,
 1 AS `nightcharge`,
 1 AS `nightcharge_price`,
 1 AS `night_rate_begins`,
 1 AS `night_rate_ends`,
 1 AS `extras`,
 1 AS `extraPrice`,
 1 AS `peakTimePrice`,
 1 AS `peak_time_value`,
 1 AS `basic_tax`,
 1 AS `basic_tax_type`,
 1 AS `basic_tax_price`,
 1 AS `pre_waiting_time`,
 1 AS `pre_waiting_charge`,
 1 AS `waiting_time`,
 1 AS `waiting_charge`,
 1 AS `igst_tax`,
 1 AS `cgst_tax`,
 1 AS `sgst_tax`,
 1 AS `estimated_price_before_markup`,
 1 AS `markup_type`,
 1 AS `markup_value`,
 1 AS `markup_price`,
 1 AS `driver_share_amt`,
 1 AS `comp_share_amt`,
 1 AS `partner_share_amt`,
 1 AS `reference_number`,
 1 AS `user_id`,
 1 AS `user_type_id`,
 1 AS `email`,
 1 AS `mobile`,
 1 AS `address`,
 1 AS `pincode`,
 1 AS `landline_number`,
 1 AS `gst_registration_number`,
 1 AS `pancard_no`,
 1 AS `user_type`,
 1 AS `username`,
 1 AS `client_id`,
 1 AS `client_name`,
 1 AS `package_name`,
 1 AS `package_mode`,
 1 AS `outstation_module_type`,
 1 AS `estimateprice_before_discount`,
 1 AS `discount_price`,
 1 AS `estimated_final_price`,
 1 AS `approx_distance_charge`,
 1 AS `approx_after_km`,
 1 AS `approx_waiting_charge`,
 1 AS `approx_waiting_minute`,
 1 AS `vehicle_name`,
 1 AS `vehicle_type`,
 1 AS `actual_distance`,
 1 AS `actual_time`,
 1 AS `booking_amt_paid`,
 1 AS `booking_amt_balance`*/;

--
-- Temporary table structure for view `view_company_vendor_driver`
--

/*!50001 DROP VIEW IF EXISTS `view_company_vendor_driver`*/;
/*!50001 CREATE VIEW `view_company_vendor_driver` AS SELECT 
 1 AS `id`,
 1 AS `user_type_id`,
 1 AS `user_type`,
 1 AS `first_name`,
 1 AS `last_name`,
 1 AS `email`,
 1 AS `mobile`,
 1 AS `parent_id`,
 1 AS `company_id`,
 1 AS `is_active`,
 1 AS `com_name`,
 1 AS `child_user_id`,
 1 AS `child_name`,
 1 AS `child_email`,
 1 AS `child_mobile`,
 1 AS `child_usertype_id`,
 1 AS `child_user_type`*/;

--
-- Temporary table structure for view `view_driver_vehicle_map`
--

/*!50001 DROP VIEW IF EXISTS `view_driver_vehicle_map`*/;
/*!50001 CREATE VIEW `view_driver_vehicle_map` AS SELECT 
 1 AS `user_id`,
 1 AS `gcm_id`,
 1 AS `driver_name`,
 1 AS `company_id`,
 1 AS `vendor_id`,
 1 AS `mobile`,
 1 AS `email`,
 1 AS `state_name`,
 1 AS `state_id`,
 1 AS `city_name`,
 1 AS `city_id`,
 1 AS `driver_status`,
 1 AS `mapping_id`,
 1 AS `vehicle_type`,
 1 AS `vehicle_type_color`,
 1 AS `vehicle_type_id`,
 1 AS `vehicle_name`,
 1 AS `vehicle_model_id`,
 1 AS `vehicle_color`,
 1 AS `vehicle_master_id`,
 1 AS `created_by`,
 1 AS `vehicle_no`,
 1 AS `model_year`,
 1 AS `color`,
 1 AS `vehicle_owner_type`,
 1 AS `owner_name`,
 1 AS `owner_mobile`,
 1 AS `permit_expiry_date`,
 1 AS `passenger`,
 1 AS `large_suitcase`,
 1 AS `small_suitcase`,
 1 AS `fuel_type`*/;

--
-- Temporary table structure for view `view_vehicle_fare_details`
--

/*!50001 DROP VIEW IF EXISTS `view_vehicle_fare_details`*/;
/*!50001 CREATE VIEW `view_vehicle_fare_details` AS SELECT 
 1 AS `base_combination_id`,
 1 AS `bs_status`,
 1 AS `company_id`,
 1 AS `vendor_id`,
 1 AS `company_setup_name`,
 1 AS `country_id`,
 1 AS `country_name`,
 1 AS `state_id`,
 1 AS `state_name`,
 1 AS `city_id`,
 1 AS `city_name`,
 1 AS `master_package_id`,
 1 AS `package_name`,
 1 AS `master_package_mode_id`,
 1 AS `package_mode`,
 1 AS `date_from`,
 1 AS `date_to`,
 1 AS `rate_type`,
 1 AS `rate_value`,
 1 AS `week_days`,
 1 AS `vendor_name`,
 1 AS `client_name`,
 1 AS `vehicle_type`,
 1 AS `dispatch_location_id`,
 1 AS `user_id`,
 1 AS `base_comb_id`,
 1 AS `type_of_dispatch`,
 1 AS `garage_type`,
 1 AS `address`,
 1 AS `city`,
 1 AS `pincode`,
 1 AS `created_date`,
 1 AS `created_by`,
 1 AS `status`,
 1 AS `distance_minimum_charge`,
 1 AS `distance_minimum_distance`,
 1 AS `distance_per_km_charge`,
 1 AS `hourly_minimum_charge`,
 1 AS `hourly_minimum_hrs`,
 1 AS `hourly_per_hr_charge`,
 1 AS `dist_waiting_minimum_charge`,
 1 AS `dist_waiting_minimum_distance`,
 1 AS `dist_waiting_per_km_charge`,
 1 AS `dist_waiting_waiting_fees`,
 1 AS `dist_hour_minimum_charge`,
 1 AS `dist_hour_minimum_distance`,
 1 AS `dist_hour_minimum_hrs`,
 1 AS `dist_hour_per_km_charge`,
 1 AS `dist_hour_per_hr_charge`,
 1 AS `company_share_type`,
 1 AS `company_share`*/;

--
-- Temporary table structure for view `view_wallet_point`
--

/*!50001 DROP VIEW IF EXISTS `view_wallet_point`*/;
/*!50001 CREATE VIEW `view_wallet_point` AS SELECT 
 1 AS `user_id`,
 1 AS `username`,
 1 AS `referral_key`,
 1 AS `referal_id`,
 1 AS `referal_by`,
 1 AS `user_amount`,
 1 AS `referer_amount`,
 1 AS `created`*/;

--
-- Table structure for table `voucher`
--

CREATE TABLE `voucher` (
  `voucher_id` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(11) NOT NULL,
  `voucher_type` int(11) NOT NULL,
  `voucher_no_auto` varchar(50) NOT NULL,
  `voucher_no` varchar(50) NOT NULL COMMENT 'Manual voucher id ',
  `voucher_date` date NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  PRIMARY KEY (`voucher_id`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=latin1;

--
-- Table structure for table `voucher_detail`
--

CREATE TABLE `voucher_detail` (
  `voucher_detail_id` int(11) NOT NULL AUTO_INCREMENT,
  `voucher_id` int(11) NOT NULL,
  `booking_charge_id` int(11) NOT NULL,
  `amount` int(11) NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  PRIMARY KEY (`voucher_detail_id`)
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1;

--
-- Table structure for table `waiting_charge`
--

CREATE TABLE `waiting_charge` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `base_vehicle_id` int(11) NOT NULL,
  `waiting_minute_upto` varchar(5) NOT NULL,
  `waiting_fees` varchar(5) NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(2) NOT NULL DEFAULT '1',
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `base_vehicle_id` (`base_vehicle_id`),
  CONSTRAINT `waiting_charge_ibfk_1` FOREIGN KEY (`base_vehicle_id`) REFERENCES `base_vehicle_type` (`base_vehicle_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;

--
-- Table structure for table `wallet_point_conversion`
--

CREATE TABLE `wallet_point_conversion` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `master_package_id` int(11) DEFAULT NULL,
  `user_type_id` int(11) DEFAULT NULL,
  `user_grade_id` int(11) DEFAULT NULL,
  `points` int(11) DEFAULT NULL,
  `conversion_rate` int(11) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` int(11) DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive,1-Active,2-Deleted',
  `ip` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Table structure for table `web_admin`
--

CREATE TABLE `web_admin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password` varchar(200) NOT NULL,
  `full_name` varchar(255) NOT NULL,
  `mobile_no` varchar(15) NOT NULL,
  `email` varchar(100) NOT NULL,
  `address` text NOT NULL,
  `country` int(11) NOT NULL,
  `state` int(11) NOT NULL,
  `city` int(11) NOT NULL,
  `pincode` varchar(6) NOT NULL,
  `role_type` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  `IsActive` int(11) NOT NULL DEFAULT '1' COMMENT '1=Active,2=InActive',
  `region` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `manage_jobs` tinyint(4) NOT NULL,
  `manage_client` tinyint(4) NOT NULL,
  `manage_driver` tinyint(4) NOT NULL,
  `manage_driver_groups` tinyint(4) NOT NULL,
  `manage_tracking` tinyint(4) NOT NULL,
  `manage_complaint` tinyint(4) NOT NULL,
  `manage_fair` tinyint(4) NOT NULL,
  `manage_reports` tinyint(4) NOT NULL,
  `manage_promotion` tinyint(4) NOT NULL,
  `manage_device` tinyint(4) NOT NULL,
  `manage_vehicle` tinyint(4) NOT NULL,
  `manage_enquiry` tinyint(4) NOT NULL,
  `manage_role` tinyint(4) NOT NULL,
  `manage_user` tinyint(4) NOT NULL,
  `mange_driver_payment` tinyint(4) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=100019 DEFAULT CHARSET=latin1;

--
-- Table structure for table `wishlist`
--

CREATE TABLE `wishlist` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `city_id` int(11) DEFAULT NULL,
  `mapping_id` int(11) NOT NULL,
  `bkg_type_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ip` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=latin1;

--
-- Table structure for table `wrong_address`
--

CREATE TABLE `wrong_address` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `address` varchar(50) DEFAULT NULL,
  `area` varchar(50) DEFAULT NULL,
  `zone` varchar(50) DEFAULT NULL,
  `city` varchar(50) DEFAULT NULL,
  `state` varchar(50) DEFAULT NULL,
  `country` varchar(50) DEFAULT NULL,
  `latitude` varchar(50) DEFAULT NULL,
  `longitude` varchar(50) DEFAULT NULL,
  `status` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=latin1;

--
-- Dumping events for database 'bookingcabs_demo2'
--

--
-- Dumping routines for database 'bookingcabs_demo2'
--
/*!50003 DROP PROCEDURE IF EXISTS `accept_booking_status` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `accept_booking_status`(IN `booking_id` INT, IN `id` INT)
    NO SQL
BEGIN
update booking_stack SET booking_stack.`status`='A',last_try = Now() WHERE booking_id=booking_id;
INSERT INTO `booking_register`(`bookingid`,`driverId`,`updateOn`,`status`,`type`) VALUES(booking_id,id,Now(),'A','By Un-Assigned Booking');
UPDATE driver SET `status`=1 WHERE user_id = id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `booking_travel_detail` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `booking_travel_detail`(IN `booking_id` INT)
BEGIN
SELECT driver_location.booking_id as bookingId,
(SELECT DATE_FORMAT(time,'%Y-%m-%d %H:%i:%s') as time FROM booking_logs WHERE status = 7 AND bookingid = booking_id) as strtTime,
(SELECT DATE_FORMAT(datetime,'%Y-%m-%d %H:%i:%s') as time FROM driver_location WHERE booking_id = booking_id order by booking_id desc limit 0,1 ) as endTime,
(Select distance from driver_location where booking_id = booking_id order by driver_location.id desc limit 0,1) as distance,
driver_location.duration,   
driver_location.pre_Waiting_time,
driver_location.WaitingTime,
driver_location.start_latitude,
driver_location.start_longitude,
TIMEDIFF( DATE_FORMAT(booking_estimation.estimated_time,"%H:%i:%s"),TIMEDIFF(
    (SELECT DATE_FORMAT(time,'%H:%i:%s') as time FROM booking_logs WHERE status = 8 AND bookingid = booking_id),
    (SELECT DATE_FORMAT(time,'%H:%i:%s') as time FROM booking_logs WHERE status = 7 AND bookingid = booking_id)
)) as delay_time,
DATE_FORMAT(booking_pickdrop_details.pickup_date,'%Y-%m-%d') as pickup_date ,
DATE_FORMAT(booking_pickdrop_details.pickup_time,"%H:%i:%s") as pickup_time,
booking_estimation.*
from driver_location
left join booking_estimation ON driver_location.booking_id =booking_estimation.booking_id 
left join booking_pickdrop_details ON booking_estimation.booking_id  = booking_pickdrop_details.booking_id
where driver_location.booking_id = booking_id
order by driver_location.id desc limit 0,1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_agent_work_history` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_agent_work_history`(IN `user_id` INT, IN `driver_id` INT, IN `mobile` VARCHAR(50), IN `booking_ref` VARCHAR(50), IN `reason_text` VARCHAR(100))
BEGIN
INSERT INTO `agent_work_history`(`AgentID`,`CallerId`,`BookingID`,`ActionType`,`Date`,`ActionDesc`) VALUES(user_id,mobile,booking_ref,'Cancellation',Now(),reason_text);
UPDATE driver SET `status`= 0 WHERE `user_id` = driver_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_assign_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_assign_booking`(IN `driver` INT, IN `booking` TEXT)
BEGIN
DECLARE dno int;
DECLARE bno int;
DECLARE lno int;
DECLARE tno int;
SELECT COUNT(*) into lno FROM user WHERE id=driver and loginstatus=1;
SELECT COUNT(*) into tno FROM cab_booking WHERE CONCAT(pickupdate,' ',pickuptime)>NOW();
IF dno>0 and bno>0 and lno>0 and tno>0
THEN 
UPDATE cab_booking SET pickup=driver WHERE booking_reference=booking;
END IF;
SELECT dno,bno,lno,tno;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_a_client_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_a_client_booking`(IN `client_id` INT)
BEGIN
SELECT booking_charges.totalBill AS amount,(booking_charges.totalBill*booking_charges.companyshare/100) 
AS cAmount,(booking_charges.totalBill*booking_charges.drivershare/100) AS dAmount,
(booking_charges.totalBill*booking_charges.partnershare/100) AS pAmount,
booking_charges.companyshare AS cshare,booking_charges.drivershare AS dshare,
booking_charges.partnershare AS pshare,complaint.ID as com_id,
complaint.StatusID as com_status, cab_booking.csr_id as emp,
CONCAT(cab_booking.drop_address,cab_booking.drop_area) as drop_area,cab_booking.id as id,
booking_charges.totalBill, cab_booking.booking_reference as ref,
master_package.master_package as booking_type,
CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as ordertime,
vehicle_type.vehicle_type as vehicle, 
CONCAT(user_info.first_name," ",user_info.last_name) as clientname,
CONCAT(driver.first_name," ",driver.last_name) as driver_name, 
user_info.mobile_no as mob_no,user_info.uid as client_id,driver.uid as driver_id,
CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,
driver.vehicle_reg_no as reg,cab_status.`status` as `status`
 FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` 
 JOIN master_package ON cab_booking.booking_type=master_package.package_id 
 JOIN user_info ON cab_booking.client_id=user_info.uid
 LEFT JOIN driver ON cab_booking.pickup=driver.uid 
 LEFT JOIN vehicle_type ON driver.vehicle_type=vehicle_type.id 
 LEFT JOIN booking_charges ON cab_booking.id=booking_charges.BookingID 
 LEFT JOIN complaint ON cab_booking.booking_reference=complaint.BookingID 
 WHERE cab_status.`type`='cab' AND cab_booking.client_id=client_id order by cab_booking.id desc;   
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_a_driver_order_history` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_a_driver_order_history`(IN `ids` INT, IN `from_i` DATETIME, IN `to_i` DATETIME)
BEGIN
SELECT CONCAT(cab_booking.DropAddress,cab_booking.DropArea) as drop_area,cab_booking.ID as id,cab_booking.booking_reference as book_ref, 
cab_list_mgmt.name,booking_charges.totalBill,
user_info.vehicleimg,master_package.Master_Package as booking_type,CONCAT(cab_booking.PickupDate," ",cab_booking.PickupTime) as ordertime,
concat(client.clientName,'<br>(',appid.`type`,')') as partner,
CONCAT(user_info.FirstName," ",user_info.LastName) as clientname,
CONCAT(cab_booking.PickupAddress,' ',cab_booking.PickupArea) as departure,driver.VehicleRegistrationNo as reg,cab_status.`status` as `status`
 FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` INNER JOIN user_info ON user_info.UID=cab_booking.pickup 
 JOIN master_package ON cab_booking.BookingType=master_package.Package_Id INNER JOIN driver ON cab_booking.pickup=driver.uid 
  JOIN appid ON appid.id=cab_booking.partner INNER JOIN user ON cab_booking.pickup = user.ID
 JOIN client ON appid.clientId=client.id INNER JOIN booking_charges ON cab_booking.ID=booking_charges.BookingID 
 LEFT JOIN complaint ON cab_booking.booking_reference=complaint.BookingID INNER JOIN cab_list_mgmt ON cab_list_mgmt.id = driver.vehicleId
 WHERE  cab_status.`type`='cab' AND user.token = ids AND DATE(cab_booking.BookingDate) BETWEEN from_i and to_i order by cab_booking.ID desc;   
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_a_user_order_history` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_a_user_order_history`(IN `id` INT)
BEGIN
SELECT CONCAT(cab_booking.DropAddress,cab_booking.DropArea) as drop_area,cab_booking.ID as id,cab_booking.booking_reference as book_ref, 
cab_list_mgmt.name as veh_name,master_package.Master_Package as booking_type,CONCAT(cab_booking.PickupDate," ",cab_booking.PickupTime) as ordertime,
concat(client.clientName,'<br>(',appid.`type`,')') as partner,
CONCAT(user_info.FirstName," ",user_info.LastName) as clientname,
CONCAT(cab_booking.PickupAddress,' ',cab_booking.PickupArea) as departure,cab_status.`status` as `status`
 FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` 
INNER JOIN user_info ON user_info.UID=cab_booking.ClientID
INNER JOIN master_package ON cab_booking.BookingType=master_package.Package_Id 
LEFT JOIN driver ON cab_booking.pickup=driver.uid 
INNER JOIN appid ON appid.id=cab_booking.partner 
LEFT JOIN user ON cab_booking.pickup = user.ID
INNER JOIN client ON appid.clientId=client.id 
LEFT JOIN cab_list_mgmt ON cab_list_mgmt.id = driver.vehicleId
 WHERE cab_status.`type`='cab' AND cab_booking.ClientID = id order by cab_booking.ID desc;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_a_user_total_bill` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_a_user_total_bill`(IN `booking_id` INT)
BEGIN
SELECT booking_charges.totalBill, cab_booking.actual_distance from booking_charges inner join cab_booking on booking_charges.BookingID = cab_booking.ID where booking_charges.BookingID = booking_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_booking_action` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_booking_action`(IN `booking_id` INT)
BEGIN
SELECT booking.client_id as client,booking.driver_id as pickup,booking.reference_number as ref,booking.status as stat,CONCAT(booking_pickdrop_details.pickup_date,' ',booking_pickdrop_details.pickup_time) as date FROM booking
LEFT JOIN booking_pickdrop_details ON booking_pickdrop_details.booking_id=booking.booking_id
WHERE booking.booking_id=booking_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_booking_action_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_booking_action_old`(IN `booking_id` INT)
BEGIN
SELECT cab_booking.client_id as client,cab_booking.pickup,cab_booking.booking_reference as ref,cab_booking.status as stat,CONCAT(cab_booking.pickup_date,' ',cab_booking.pickup_time) as date FROM cab_booking WHERE id=booking_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_booking_distance` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_booking_distance`(IN `user_id` INT, IN `book_id` INT, IN `from_a` VARCHAR(200), IN `to_a` VARCHAR(200), IN `date_time` DATETIME, IN `distance` DOUBLE, IN `waiting_time` VARCHAR(50))
BEGIN
INSERT INTO booking_distance  (user_id,booking_id,`to`,`from`,device_time,distance, WaitingTime)
VALUES (user_id,book_id,to_a,from_a,date_time,distance,waiting_time);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_book_fetch_info` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_book_fetch_info`(IN `book_id` INT(4))
BEGIN
SELECT bk.booking_id as id,bk.driver_id,bk.reference_number as ref,us2.id as client_id,
	CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
  us.mobile,
  us.email as user_email,
  CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
 CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
mpm.package_mode,
mp.name  as booking_type,
mp.id as booking_type_id,
payty.pay_type_mode as charge_type,
mvt.vehicle_type as vehicle,
bk.base_vehicle_id,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date,
bk.master_package_mode_id,
cs.status,
bkest.*,
bkest.estimated_final_price as amount,
bpd.pickup_date,
bpd.pickup_time,
bpd.pickup_address,
bpd.pickup_area,
bpd.drop_address,
bpd.drop_area,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone,
location.api_time,
location.api_distance,
dispatch.type_of_dispatch,
if(dispatch.type_of_dispatch=1,'Point To Point','Garage To garage') As type_of_dispatch_name,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.city as garage_city,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude
from booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN base_vehicle_type AS bvt ON bk.base_vehicle_id = bvt.base_vehicle_id
LEFT JOIN dispatch_location AS dispatch ON bvt.base_comb_id = dispatch.base_comb_id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package_fare AS lpf ON bk.package_id = lpf.local_pkg_fare_id
LEFT JOIN local_package as lp ON lpf.local_pkg_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
LEFT JOIN 
	api_call_timeinterval as location ON bk.company_id = location.company_id AND bk.master_package_id = location.package_id
WHERE
   bk.booking_id = book_id AND bk.booking_status = 1
ORDER BY
  bk.booking_id DESC;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_book_fetch_info_current_notification` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_book_fetch_info_current_notification`(IN `book_id` INT, IN `bookingType` INT, IN `calculationType` INT, IN `driver_id` INT)
BEGIN
DECLARE currency_n varchar(50);
DECLARE distance_n varchar(50);
SELECT tblcountry.currency ,tblcountry.distance_unit into currency_n,distance_n 
FROM tblcountry 
WHERE tblcountry.CountryName='India';
IF calculationType=1 THEN
IF bookingType=101 THEN
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		 distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,		 
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 cab_list_mgmt.Min_Distance,
	    cab_list_mgmt.NightCharges,
		cab_list_mgmt.nightCharge_unit,
	    cab_list_mgmt.waitingfee_upto_minutes,
	    cab_list_mgmt.MinimumCharge, 
	    cab_list_mgmt.night_rate_begins,
	    cab_list_mgmt.night_rate_ends,
	    cab_list_mgmt.basic_tax,
	    cab_list_mgmt.tripCharge_per_minute,
		 cab_list_mgmt.Per_Km_Charge,
		 cab_list_mgmt.rate_per_km_dh,
		 cab_list_mgmt.minimum_fare_dh,
		 cab_list_mgmt.minimum_distance_dh,
		 cab_list_mgmt.rate_per_km_dw,
		 cab_list_mgmt.minimum_fare_dw,
		 cab_list_mgmt.minimum_distance_dw,
		 cab_list_mgmt.rate_per_hour_dh,
		 cab_list_mgmt.CabId,		
		 cab_list_mgmt.waiting_fees,
		 tblcity.state,
		 tbllocalpackage.Price
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN driver ON driver.UID = driver_id
INNER JOIN cab_list_mgmt ON driver.vehicleId = cab_list_mgmt.CabId AND cab_booking.BookingType = cab_list_mgmt.BookingType AND cab_booking.CarType = cab_list_mgmt.CabType
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN tbllocalpackage ON tbllocalpackage.Package = cab_booking.local_subpackage AND tbllocalpackage.cabType = cab_booking.CarType AND tbllocalpackage.Sub_Package_Id = master_package.Sub_Package_Id AND tbllocalpackage.City_ID = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
ELSE
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		 distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 cab_list_mgmt.Min_Distance,
	    cab_list_mgmt.NightCharges,
		cab_list_mgmt.nightCharge_unit,
	    cab_list_mgmt.waitingfee_upto_minutes,
	    cab_list_mgmt.MinimumCharge, 
	    cab_list_mgmt.night_rate_begins,
	    cab_list_mgmt.night_rate_ends,
	    cab_list_mgmt.basic_tax,
	    cab_list_mgmt.tripCharge_per_minute,
		 cab_list_mgmt.Per_Km_Charge,
		 cab_list_mgmt.rate_per_km_dh,
		 cab_list_mgmt.minimum_fare_dh,
		 cab_list_mgmt.minimum_distance_dh,
		 cab_list_mgmt.rate_per_km_dw,
		 cab_list_mgmt.minimum_fare_dw,
		 cab_list_mgmt.minimum_distance_dw,
		 cab_list_mgmt.rate_per_hour_dh,
		 cab_list_mgmt.CabId,		
		 cab_list_mgmt.waiting_fees
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN driver ON driver.UID = driver_id
INNER JOIN cab_list_mgmt ON driver.vehicleId = cab_list_mgmt.CabId AND cab_booking.BookingType = cab_list_mgmt.BookingType AND cab_booking.CarType = cab_list_mgmt.CabType
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
END IF;
ELSE
IF bookingType=101 THEN
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		  distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 booking_bill.Min_Distance,
	    booking_bill.NightCharges,
		booking_bill.nightCharge_unit,
	    booking_bill.waitingfee_upto_minutes,
	    booking_bill.MinimumCharge, 
	    booking_bill.night_rate_begins,
	    booking_bill.night_rate_ends,
	    booking_bill.basic_tax,
	    booking_bill.tripCharge_per_minute,
		 booking_bill.Per_Km_Charge,
		 booking_bill.rate_per_km_dh,
		 booking_bill.minimum_fare_dh,
		 booking_bill.minimum_distance_dh,
		 booking_bill.rate_per_km_dw,
		 booking_bill.minimum_fare_dw,
		 booking_bill.minimum_distance_dw,
		 booking_bill.rate_per_hour_dh,	
		 booking_bill.waiting_fees,
		 tblcity.state,
		 tbllocalpackage.Price
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN booking_bill ON cab_booking.BookingType = booking_bill.BookingTypeId AND cab_booking.CarType = booking_bill.CabType AND booking_bill.CityId = tblcity.state
INNER JOIN tbllocalpackage ON tbllocalpackage.Package = cab_booking.local_subpackage AND tbllocalpackage.cabType = cab_booking.CarType AND tbllocalpackage.Sub_Package_Id = master_package.Sub_Package_Id AND tbllocalpackage.City_ID = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
ELSE
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		  distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 booking_bill.Min_Distance,
	    booking_bill.NightCharges,
		booking_bill.nightCharge_unit,
	    booking_bill.waitingfee_upto_minutes,
	    booking_bill.MinimumCharge, 
	    booking_bill.night_rate_begins,
	    booking_bill.night_rate_ends,
	    booking_bill.basic_tax,
	    booking_bill.tripCharge_per_minute,
		 booking_bill.Per_Km_Charge,
		 booking_bill.rate_per_km_dh,
		 booking_bill.minimum_fare_dh,
		 booking_bill.minimum_distance_dh,
		 booking_bill.rate_per_km_dw,
		 booking_bill.minimum_fare_dw,
		 booking_bill.minimum_distance_dw,
		 booking_bill.rate_per_hour_dh,	
		 booking_bill.waiting_fees
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN booking_bill ON cab_booking.BookingType = booking_bill.BookingTypeId AND cab_booking.CarType = booking_bill.CabType AND booking_bill.CityId = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
END IF;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_book_fetch_info_notification` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_book_fetch_info_notification`(IN `book_id` INT, IN `bookingType` VARCHAR(50), IN `calculationType` VARCHAR(50))
BEGIN
DECLARE currency_n varchar(50);
DECLARE distance_n varchar(50);
SELECT tblcountry.currency ,tblcountry.distance_unit into currency_n,distance_n 
FROM tblcountry 
WHERE tblcountry.CountryName='India';
IF calculationType=1 THEN
IF bookingType=101 THEN
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		 distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 cab_list_mgmt.Min_Distance,
	    cab_list_mgmt.NightCharges,
		cab_list_mgmt.nightCharge_unit,
	    cab_list_mgmt.waitingfee_upto_minutes,
	    cab_list_mgmt.MinimumCharge, 
	    cab_list_mgmt.night_rate_begins,
	    cab_list_mgmt.night_rate_ends,
	    cab_list_mgmt.basic_tax,
	    cab_list_mgmt.tripCharge_per_minute,
		 cab_list_mgmt.Per_Km_Charge,
		 cab_list_mgmt.rate_per_km_dh,
		 cab_list_mgmt.minimum_fare_dh,
		 cab_list_mgmt.minimum_distance_dh,
		 cab_list_mgmt.rate_per_km_dw,
		 cab_list_mgmt.minimum_fare_dw,
		 cab_list_mgmt.minimum_distance_dw,
		 cab_list_mgmt.rate_per_hour_dh,
		 cab_list_mgmt.CabId,		
		 cab_list_mgmt.waiting_fees,
		 tblcity.state,
		 tbllocalpackage.Price,user.gcm_id,user.Latitude as lat,user.Longtitude1 as lon
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN driver ON cab_booking.pickup = driver.UID
JOIN user ON cab_booking.pickup=user.id
INNER JOIN cab_list_mgmt ON driver.vehicleId = cab_list_mgmt.CabId AND cab_booking.BookingType = cab_list_mgmt.BookingType AND cab_booking.CarType = cab_list_mgmt.CabType
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN tbllocalpackage ON tbllocalpackage.Package = cab_booking.local_subpackage AND tbllocalpackage.Sub_Package_Id = master_package.Sub_Package_Id AND tbllocalpackage.City_ID = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
ELSE
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		 distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 cab_list_mgmt.Min_Distance,
	    cab_list_mgmt.NightCharges,
		cab_list_mgmt.nightCharge_unit,
	    cab_list_mgmt.waitingfee_upto_minutes,
	    cab_list_mgmt.MinimumCharge, 
	    cab_list_mgmt.night_rate_begins,
	    cab_list_mgmt.night_rate_ends,
	    cab_list_mgmt.basic_tax,
	    cab_list_mgmt.tripCharge_per_minute,
		 cab_list_mgmt.Per_Km_Charge,
		 cab_list_mgmt.rate_per_km_dh,
		 cab_list_mgmt.minimum_fare_dh,
		 cab_list_mgmt.minimum_distance_dh,
		 cab_list_mgmt.rate_per_km_dw,
		 cab_list_mgmt.minimum_fare_dw,
		 cab_list_mgmt.minimum_distance_dw,
		 cab_list_mgmt.rate_per_hour_dh,
		 cab_list_mgmt.CabId,		
		 cab_list_mgmt.waiting_fees,user.gcm_id,user.Latitude as lat,user.Longtitude1 as lon
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN driver ON cab_booking.pickup = driver.UID
JOIN user ON cab_booking.pickup=user.id
INNER JOIN cab_list_mgmt ON driver.vehicleId = cab_list_mgmt.CabId AND cab_booking.BookingType = cab_list_mgmt.BookingType AND cab_booking.CarType = cab_list_mgmt.CabType
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
END IF;
ELSE
IF bookingType=101 THEN
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		  distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 booking_bill.Min_Distance,
	    booking_bill.NightCharges,
		booking_bill.nightCharge_unit,
	    booking_bill.waitingfee_upto_minutes,
	    booking_bill.MinimumCharge, 
	    booking_bill.night_rate_begins,
	    booking_bill.night_rate_ends,
	    booking_bill.basic_tax,
	    booking_bill.tripCharge_per_minute,
		 booking_bill.Per_Km_Charge,
		 booking_bill.rate_per_km_dh,
		 booking_bill.minimum_fare_dh,
		 booking_bill.minimum_distance_dh,
		 booking_bill.rate_per_km_dw,
		 booking_bill.minimum_fare_dw,
		 booking_bill.minimum_distance_dw,
		 booking_bill.rate_per_hour_dh,	
		 booking_bill.waiting_fees,
		 tblcity.state,
		 tbllocalpackage.Price,user.gcm_id,user.Latitude as lat,user.Longtitude1 as lon
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
JOIN user ON cab_booking.pickup=user.id
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN booking_bill ON cab_booking.BookingType = booking_bill.BookingTypeId AND cab_booking.CarType = booking_bill.CabType AND booking_bill.CityId = tblcity.state
INNER JOIN tbllocalpackage ON tbllocalpackage.Package = cab_booking.local_subpackage AND tbllocalpackage.cabType = cab_booking.CarType AND tbllocalpackage.Sub_Package_Id = master_package.Sub_Package_Id AND tbllocalpackage.City_ID = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
ELSE
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		  distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName,
		 cab_booking.EmailId,
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 booking_bill.Min_Distance,
	    booking_bill.NightCharges,
		booking_bill.nightCharge_unit,
	    booking_bill.waitingfee_upto_minutes,
	    booking_bill.MinimumCharge, 
	    booking_bill.night_rate_begins,
	    booking_bill.night_rate_ends,
	    booking_bill.basic_tax,
	    booking_bill.tripCharge_per_minute,
		 booking_bill.Per_Km_Charge,
		 booking_bill.rate_per_km_dh,
		 booking_bill.minimum_fare_dh,
		 booking_bill.minimum_distance_dh,
		 booking_bill.rate_per_km_dw,
		 booking_bill.minimum_fare_dw,
		 booking_bill.minimum_distance_dw,
		 booking_bill.rate_per_hour_dh,	
		 booking_bill.waiting_fees,user.gcm_id,user.Latitude as lat,user.Longtitude1 as lon
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
JOIN user ON cab_booking.pickup=user.id
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN booking_bill ON cab_booking.BookingType = booking_bill.BookingTypeId AND cab_booking.CarType = booking_bill.CabType AND booking_bill.CityId = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
END IF;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_book_fetch_info_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_book_fetch_info_old`(IN `book_id` INT, IN `bookingType` VARCHAR(50), IN `calculationType` VARCHAR(50))
BEGIN
DECLARE currency_n varchar(50);
DECLARE distance_n varchar(50);
SELECT tblcountry.currency ,tblcountry.distance_unit into currency_n,distance_n 
FROM tblcountry 
WHERE tblcountry.CountryName='India';
IF calculationType=1 THEN
IF bookingType=101 THEN
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		 distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName, 
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.EmailId,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 cab_list_mgmt.Min_Distance,
	    cab_list_mgmt.NightCharges,
		cab_list_mgmt.nightCharge_unit,
	    cab_list_mgmt.waitingfee_upto_minutes,
	    cab_list_mgmt.MinimumCharge, 
	    cab_list_mgmt.night_rate_begins,
	    cab_list_mgmt.night_rate_ends,
	    cab_list_mgmt.basic_tax,
	    cab_list_mgmt.tripCharge_per_minute,
		 cab_list_mgmt.Per_Km_Charge,
		 cab_list_mgmt.rate_per_km_dh,
		 cab_list_mgmt.minimum_fare_dh,
		 cab_list_mgmt.minimum_distance_dh,
		 cab_list_mgmt.rate_per_km_dw,
		 cab_list_mgmt.minimum_fare_dw,
		 cab_list_mgmt.minimum_distance_dw,
		 cab_list_mgmt.rate_per_hour_dh,
		 cab_list_mgmt.CabId,		
		 cab_list_mgmt.waiting_fees,
		 tblcity.state,
		 tbllocalpackage.Price
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN driver ON cab_booking.pickup = driver.UID
INNER JOIN cab_list_mgmt ON driver.vehicleId = cab_list_mgmt.CabId AND cab_booking.BookingType = cab_list_mgmt.BookingType AND cab_booking.CarType = cab_list_mgmt.CabType
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN tbllocalpackage ON tbllocalpackage.Package = cab_booking.local_subpackage AND tbllocalpackage.Sub_Package_Id = master_package.Sub_Package_Id AND tbllocalpackage.City_ID = tblcity.state AND tbllocalpackage.cabType = cab_booking.CarType 
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
ELSE
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		 distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName, 
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.EmailId,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 cab_list_mgmt.Min_Distance,
	    cab_list_mgmt.NightCharges,
		cab_list_mgmt.nightCharge_unit,
	    cab_list_mgmt.waitingfee_upto_minutes,
	    cab_list_mgmt.MinimumCharge, 
	    cab_list_mgmt.night_rate_begins,
	    cab_list_mgmt.night_rate_ends,
	    cab_list_mgmt.basic_tax,
	    cab_list_mgmt.tripCharge_per_minute,
		 cab_list_mgmt.Per_Km_Charge,
		 cab_list_mgmt.rate_per_km_dh,
		 cab_list_mgmt.minimum_fare_dh,
		 cab_list_mgmt.minimum_distance_dh,
		 cab_list_mgmt.rate_per_km_dw,
		 cab_list_mgmt.minimum_fare_dw,
		 cab_list_mgmt.minimum_distance_dw,
		 cab_list_mgmt.rate_per_hour_dh,
		 cab_list_mgmt.CabId,		
		 cab_list_mgmt.waiting_fees,
		 tblcity.state
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN driver ON cab_booking.pickup = driver.UID
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN cab_list_mgmt ON driver.vehicleId = cab_list_mgmt.CabId AND cab_booking.BookingType = cab_list_mgmt.BookingType AND cab_booking.CarType = cab_list_mgmt.CabType
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
END IF;
ELSE
IF bookingType=101 THEN
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		  distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName, 
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.CabIn,
		 cab_booking.EmailId,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 booking_bill.Min_Distance,
	    booking_bill.NightCharges,
		booking_bill.nightCharge_unit,
	    booking_bill.waitingfee_upto_minutes,
	    booking_bill.MinimumCharge, 
	    booking_bill.night_rate_begins,
	    booking_bill.night_rate_ends,
	    booking_bill.basic_tax,
	    booking_bill.tripCharge_per_minute,
		 booking_bill.Per_Km_Charge,
		 booking_bill.rate_per_km_dh,
		 booking_bill.minimum_fare_dh,
		 booking_bill.minimum_distance_dh,
		 booking_bill.rate_per_km_dw,
		 booking_bill.minimum_fare_dw,
		 booking_bill.minimum_distance_dw,
		 booking_bill.rate_per_hour_dh,	
		 booking_bill.waiting_fees,
		 tblcity.state,
		 tbllocalpackage.Price
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN booking_bill ON cab_booking.BookingType = booking_bill.BookingTypeId AND cab_booking.CarType = booking_bill.CabType AND booking_bill.CityId = tblcity.state
INNER JOIN tbllocalpackage ON tbllocalpackage.Package = cab_booking.local_subpackage AND tbllocalpackage.cabType = cab_booking.CarType AND tbllocalpackage.Sub_Package_Id = master_package.Sub_Package_Id AND tbllocalpackage.City_ID = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
ELSE
SELECT cab_booking.ID,
		 cab_booking.booking_reference,
		 cab_booking.CarType,
		  distance_n as measure,
		 currency_n as currency, 
		 cab_booking.UserName, 
		 cab_booking.BookingType,
		 master_package.Sub_Package_Id,
		 cab_booking.CabFor,
		 cab_booking.CabFor AS CabForHrs,
		 cab_booking.min_Distance AS CabForKm,
		 cab_booking.PickupArea, 
		 cab_booking.PickupAddress,
		 cab_booking.PickupArea as pickup_location,
		 cab_booking.DropAddress,
		 cab_booking.DropArea as drop_location,
		 cab_booking.PickupLatitude,
		 cab_booking.PickupLongtitude,
		 cab_booking.DestinationLatitude,
		 cab_booking.DestinationLongtitude,
		 cab_booking.PickupDate,
		 cab_booking.PickupTime,
		 cab_booking.approx_distance_charge,
		 cab_booking.MobileNo,
		 cab_booking.EstimatedDistance,
		 cab_booking.estimated_price,
		 cab_booking.EstimatedTime,
		 cab_booking.local_subpackage,
		 cab_booking.CabIn,
		 cab_booking.peakTimePrice,
		 cab_booking.peaktimeFrom,
         cab_booking.peaktimeTo,
         cab_booking.peaktimepercentage,
		 cab_booking.extraPrice,
		 cab_booking.EmailId,
		 cab_booking.charge_type,
		 NOW() as send_time,
		 booking_bill.Min_Distance,
	    booking_bill.NightCharges,
		booking_bill.nightCharge_unit,
	    booking_bill.waitingfee_upto_minutes,
	    booking_bill.MinimumCharge, 
	    booking_bill.night_rate_begins,
	    booking_bill.night_rate_ends,
	    booking_bill.basic_tax,
	    booking_bill.tripCharge_per_minute,
		 booking_bill.Per_Km_Charge,
		 booking_bill.rate_per_km_dh,
		 booking_bill.minimum_fare_dh,
		 booking_bill.minimum_distance_dh,
		 booking_bill.rate_per_km_dw,
		 booking_bill.minimum_fare_dw,
		 booking_bill.minimum_distance_dw,
		 booking_bill.rate_per_hour_dh,	
		 booking_bill.waiting_fees,
		 tblcity.state
FROM cab_booking
INNER JOIN master_package ON cab_booking.BookingType = master_package.Package_Id
INNER JOIN tblcity ON tblcity.name = cab_booking.CabIn
INNER JOIN booking_bill ON cab_booking.BookingType = booking_bill.BookingTypeId AND cab_booking.CarType = booking_bill.CabType AND booking_bill.CityId = tblcity.state
WHERE cab_booking.ID = book_id
AND cab_booking.BookingStatus = 1;
END IF;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_calculate_point` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_calculate_point`(IN `id_s` INT, IN `lat` DOUBLE, IN `long1` DOUBLE)
BEGIN
DECLARE time_interval datetime;
DECLARE check_time int;
DECLARE amount int;
DECLARE distance double;
DECLARE last_booking datetime;
DECLARE check_idle int;
DECLARE total_booking int;
DECLARE `point` int;
DECLARE distance_out DOUBLE;
DECLARE time2 int;
SELECT user.loginTime,`driver`.`SecurityAmt`,`user`.`last_booking` INTO time_interval, amount,last_booking FROM user INNER JOIN driver ON user.id=driver.UID WHERE user.userType=3 and user.id=id_s;
SELECT (((acos( sin ( (lat * pi()/180)) * sin((`latitude`*pi()/180))+cos((lat*pi()/180)) * cos((`latitude`*pi()/180)) * cos(((long1- `longtitude1`)*  pi()/180))))*180/pi())*60*1.1515) INTO distance  FROM user WHERE id=id_s;
SET distance_out=distance;
SET check_time=TIMESTAMPDIFF(HOUR,time_interval,NOW());
SET point=5;
IF check_time<=3 THEN 
SET point=1;
ELSEIF check_time<=6 THEN 
SET point =2;
ELSEIF check_time<=9 THEN
SET point=3;
ELSEIF check_time<=12 THEN
SET point=4;
ELSEIF check_time<=15 THEN
SET point=5;
END IF;
IF amount<=1000 THEN
SET point=point+0;
ELSEIF amount<=2000 THEN
SET point=point+1;
ELSEIF amount<=3000 THEN
SET point=point+2;
ELSEIF amount<=4000 THEN
SET point=point+3;
ELSEIF amount<=5000 THEN
SET point=point+4;
ELSEIF amount>5000 THEN
SET point=point+5;
END IF;
IF distance<=1 THEN
SET point=point+5;
ELSEIF distance<=2 THEN
SET point=point+4;
ELSEIF distance<=3 THEN
SET point=point+3;
ELSEIF amount<=4 THEN
SET point=point+2;
ELSEIF amount<=5 THEN
SET point=point+1;
ELSEIF distance>5 THEN
SET point=point+0;
END IF;
IF time_interval>last_booking THEN
SET check_idle=TIMESTAMPDIFF(MiNUTE,time_interval,NOW());
ELSE
SET check_idle=TIMESTAMPDIFF(MiNUTE,last_booking,NOW());
END IF;
IF check_idle<=30 THEN
SET point=point+0;
ELSEIF check_idle<=60 THEN
SET point=point+1;
ELSEIF check_idle<=90 THEN
SET point=point+2;
ELSEIF check_idle<=120 THEN
SET point=point+3;
ELSEIF check_idle<=150 THEN
SET point=point+4;
ELSEIF check_idle>150 THEN
SET point=point+5;
END IF;
SET time2=check_idle;
SELECT count(*) INTO total_booking FROM `cab_booking` WHERE pickup=id_s;
SET point = point + (5-total_booking);
SELECT point;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_check_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_check_booking`(IN `bookid` INT, IN `user_id` INT)
BEGIN
DECLARE  checked INT ; 
DECLARE latitude_id INT ; 
DECLARE longitude_id INT ; 
DECLARE update_id INT ; 
DECLARE driver TEXT ; 
DECLARE vehicle TEXT ;
DECLARE cname TEXT ; 
DECLARE ref TEXT ; 
DECLARE pdate TEXT ;
  SELECT
    COUNT(*),
    `lat`,
    `long`
  INTO
    checked,
    latitude_id,
    longitude_id
  FROM
    booking_stack
  JOIN
    booking ON booking_stack.booking_id = booking.booking_id
  WHERE
    booking_stack.booking_id = bookid AND(
      booking_stack.`status` = 'W' OR booking_stack.`status` = ''
    ) ; 
IF checked = 1 THEN
  UPDATE
    booking_stack
  SET
    `status` = 'A'
  WHERE
    booking_id = bookid ;
  UPDATE
    booking
  SET
    driver = user_id,
    `status` = 3,
    is_updation_allow = 'FALSE'
  WHERE
    booking_id = bookid AND is_updation_allow = 'TRUE' ;
  SELECT
    CONCAT(
      driver.first_name,
      ' ',
      driver.last_name,
      ' ',
      driver.mobile
    ),
    vm.registration_number as VehicleRegistrationNo
  INTO
    driver,
    vehicle
  FROM
    user as driver
left join user_vehicle_mapping as vmap ON driver.id = vmap.user_id
left join vehicle_master as vm ON vmap.vehicle_master_id = vm.vehicle_master_id
  WHERE
    driver.id = user_id ;
  SELECT
   CONCAT(
      user.first_name,
      ' ',
      user.last_name,
      ' ',
      driver.mobile
    ) as UserName,
    booking.reference_number as booking_reference,
    CONCAT(
      bpick.pickup_date,
      " ",
      bpick.pickup_time
    )
  INTO
    cname,
    ref,
    pdate
  FROM
    booking
LEFT JOIN user ON booking.user_id = user.id
LEFT JOIN booking_pickdrop_details AS bpick ON booking.booking_id = bpick.booking_id
  WHERE
    booking.booking_id = bookid ;
  SELECT
    booking_register.id
  INTO
    update_id
  FROM
    booking_register
  WHERE
    booking_register.driverId = user_id AND booking_register.bookingid = bookid
  ORDER BY
    id DESC
  LIMIT 0, 1 ;
UPDATE
  booking_register
SET
  `status` = 'A',
  `type` = 'By Notification'
WHERE
  id = update_id ;
UPDATE
  `driver`
SET
  `status` = '1'
WHERE
  `user_id` = user_id ;
INSERT
INTO
  `booking_tracker`(
    `BookingID`,
    `DriverId`,
    `Latitutude`,
    `Logitude`,
    `Date_Time`,
    `CabStatus`
  )
VALUES(
  bookid,
  user_id,
  latitude_id,
  longitude_id,
  NOW(), '3') ;
INSERT
INTO
  `booking_logs`(`bookingid`,
  `status`,
  `message`,
  `time`)
VALUES(bookid, '3', 'Accepted', NOW()) ;
END IF ;
SELECT
  checked,
  driver,
  vehicle,
  cname,
  ref,
  pdate ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_check_booking_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_check_booking_old`(IN `bookid` INT, IN `user_id` INT)
BEGIN
  DECLARE checked int;
  DECLARE latitude_id int;
  DECLARE longitude_id int;
  DECLARE update_id INT;
  DECLARE driver TEXT;
  DECLARE vehicle TEXT;
  DECLARE cname TEXT;
  DECLARE ref TEXT;
  DECLARE pdate TEXT;
  SELECT count(*) ,`lat`,`long` INTO checked,latitude_id,longitude_id FROM booking_stack JOIN cab_booking ON booking_stack.booking_id=cab_booking.ID WHERE booking_stack.booking_id=bookid and (booking_stack.`status`='W' or booking_stack.`status`='');
  IF checked=1 THEN
   UPDATE booking_stack SET `status`='A' WHERE booking_id=bookid;
  UPDATE cab_booking SET pickup=user_id,`status`=3,is_updation_allow='FALSE' WHERE id=bookid AND is_updation_allow='TRUE';
  SELECT CONCAT(driver.FirstName,' ',driver.LastName,' ',driver.ContactNo),driver.VehicleRegistrationNo INTO driver,vehicle FROM driver WHERE driver.UID=user_id;
SELECT cab_booking.UserName,cab_booking.booking_reference,CONCAT(cab_booking.PickupDate," ",cab_booking.PickupTime) INTO cname,ref,pdate FROM cab_booking WHERE cab_booking.ID=bookid;
  SELECT booking_register.id into update_id FROM booking_register WHERE booking_register.driverId=user_id and booking_register.bookingid=bookid order by id desc LIMIT 0,1;
  UPDATE booking_register SET `status`='A',`type`='By Notification' WHERE id=update_id ;
   UPDATE `driver` SET `status`='1' WHERE `UID`=user_id;
  INSERT INTO `booking_tracker` (`BookingID`,`DriverId`,`Latitutude`,`Logitude`,`Date_Time`,`CabStatus`) VALUES (bookid,user_id,latitude_id,longitude_id,NOW(),'3');
  INSERT INTO `booking_logs` (`bookingid`,`status`,`message`,`time`) VALUES (bookid,'3','Accepted',NOW());
  END IF;
   SELECT checked,driver,vehicle,cname,ref,pdate;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_customer_care_text` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_customer_care_text`()
    NO SQL
Begin
Select text,text_id from region_text where page_title='customer_ca' and lang=2;
end ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_driver_acc_balance` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_driver_acc_balance`(IN `id` INT, IN `since` DATETIME, IN `to_i` DATETIME)
BEGIN
SELECT driver_transaction.user_id,driver_transaction.amount,driver_transaction.currentbalance,date(driver_transaction.time) as date,
driver_transaction.`status`,driver_transaction.reason, master_package.Master_Package,driver_transaction.booking_ref 
FROM driver_transaction left JOIN cab_booking ON driver_transaction.booking_ref = cab_booking.booking_reference 
left join master_package on cab_booking.BookingType = master_package.Package_Id
where driver_transaction.user_id = id and  DATE(driver_transaction.time) BETWEEN since and to_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_driver_alloc` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_driver_alloc`(IN `book_id` INT)
BEGIN
SELECT
  CONCAT(
    user.first_name,
    ' ',
    user.last_name
  ) AS driver_name,
  mvm.name AS vehicle,
  booking_register.updateOn AS created,
  booking_register.`status`
FROM
  booking_register
JOIN
  driver ON booking_register.driverId = driver.user_id
JOIN
  user ON booking_register.driverId = user.id
LEFT JOIN
  user_vehicle_mapping AS uvm ON driver.user_id = uvm.user_id
LEFT JOIN
 vehicle_master AS vm ON uvm.vehicle_master_id = vm.vehicle_master_id
LEFT JOIN 
 master_vehicle_model AS mvm ON  vm.id = mvm.id
WHERE
  booking_register.bookingid = book_id
ORDER BY
  booking_register.id DESC
LIMIT 0, 7; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_driver_info` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_driver_info`(IN `driver_id` INT)
BEGIN
SELECT complaint.CSRID as csre,complaint.ClosureDescription as sub_type, complaint.ComplaintType as com_type,complaint.ID as com_id,complaint.ComplaintDescription as com_desc,complaint.ComplaintDate as com_date,complaint.StatusID as com_status, complaint.CallerName as com_caller,driver.uid, CONCAT(driver.first_name," ",driver.last_name)  as driver_name,driver.contact_no,driver.lang_speak,vendor.vendor_name,vendor.group_name,driver.`status`,driver.account_no,driver.rtgs_neft,driver.operational_company_name,cab_master.CabRegistrationNumber,cab_master.CabName,cab_master.CabColor,driver.vehicle_make as make,cab_master.CabModel as model,driver.vehicle_type as v_type FROM cab_booking JOIN driver ON cab_booking.pickup=driver.uid LEFT JOIN vendor ON driver.vendor_id=vendor.id JOIN cab_master ON driver.vehicle_id=cab_master.CabId LEFT JOIN complaint ON cab_booking.booking_reference = complaint.BookingID WHERE cab_booking.ID=driver_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_driver_on_off` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_driver_on_off`(IN `driver_id` INT)
    NO SQL
BEGIN
DECLARE is_on int;
SELECT is_active into is_on FROM user WHERE id=driver_id and loginstatus=1;
IF is_on = 1 THEN
UPDATE user SET is_active=0 WHERE id=driver_id;
ELSEIF is_on=0 THEN 
UPDATE user SET is_active=1 WHERE id=driver_id;
END IF;
SELECT is_active FROM user WHERE id=driver_id and loginstatus=0 ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_driver_tracking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_driver_tracking`()
BEGIN
DECLARE total_driver int;
DECLARE OnDuty int;
DECLARE available_driver int;
DECLARE hired int;
DECLARE accepted int;
DECLARE log_out int;
DECLARE reported int;
DECLARE free_moving int;
DECLARE logout_moving int;
DECLARE on_call int;
SELECT COUNT(DISTINCT(user.ID)) INTO reported FROM user INNER JOIN user_info ON user.ID = user_info.UID INNER JOIN driver ON user.ID = driver.UID INNER JOIN cab_master ON driver.vehicleId = cab_master.CabId INNER JOIN cab_booking ON user.ID = cab_booking.pickup WHERE cab_booking.`Status`=5 AND user.loginStatus=1 AND user.Latitude != '' AND user.Longtitude1 != '' AND driver.`status`=1;
SELECT COUNT(*) INTO log_out FROM user INNER JOIN user_info ON user.ID = user_info.UID INNER JOIN driver ON user.ID = driver.UID INNER JOIN cab_master ON driver.vehicleId = cab_master.CabId WHERE user.UserType = 3 AND user.isVerified = 1 AND user.Latitude != '' AND user.Longtitude1 != '' AND user.loginStatus=0; 
SELECT hired,free_moving,logout_moving,reported,on_call;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_driver_tracking_list` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_driver_tracking_list`()
BEGIN
SELECT DISTINCT(driver.ID),
		 driver.uid,
		 driver.`status`,
		 user.loginStatus,
		 cab_booking.`Status` 
FROM driver 
JOIN cab_master ON driver.vehicleId = cab_master.CabId
WHERE user.isVerified = 1
GROUP BY driver.UID 
ORDER BY driver.ID desc; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_fare_details` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_fare_details`(IN `city_id` INT, IN `master_package_id` INT, IN `local_pkg_id` INT, IN `seating_capacity` INT, IN `luggage` INT, IN `pickup_date_time` VARCHAR(50))
BEGIN
IF local_pkg_id>0
THEN
SELECT
  bc.id AS base_comb_id,
  bc.date_from,
  bc.date_to,
  pat.start_time,
  pat.end_time,
  bc.city_id,
  mp.id AS master_package_id,
  mp.name AS package_name,
  mp.image,
  mpm.id AS master_package_mode_id,
  mpm.package_mode,
  nc.night_rate_begins,
  nc.night_rate_ends,
  nc.night_rate_type,
  nc.night_rate_value,
  bvt.base_vehicle_id,
  mvt.id AS master_vehicle_type_id,
  mvt.category_id as vehicle_category_id,
  mvt.vehicle_type,
  GROUP_CONCAT(DISTINCT vmodel.name SEPARATOR ', ') as vehicle_name,
  GROUP_CONCAT(DISTINCT vm.model SEPARATOR ', ') as vehicle_model,
  GROUP_CONCAT(DISTINCT vcolour.colour_name SEPARATOR ', ') as vehicle_color,
    GROUP_CONCAT(DISTINCT fuel.fuel_type SEPARATOR ', ') as ignition_type,

  mvt.vehicle_image,
  mvt.seating_capacity,
  mvt.amenities,
  mvt.luggage,
  tax.sgst,
  tax.cgst,
  tax.igst,
  bc.vendor_id,
  concat(vendor.first_name,' ',vendor.last_name) as vendor_name,
  vendor.email as vendor_email,
  vendor.mobile as vendor_mobile,
  premium.premiums_type,
  premium.premiums_value,
  dispatch.type_of_dispatch ,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude,
user_rating.Rating as rating,
umap.vehicle_master_id,
mva.amenities_name as amenities_name,
vm.model,vm.color,vm.ignition_type_id,
vcolour.colour_name as vehicle_color_name,fuel.fuel_type as ignition_type_name,
vmodel.id as vehicle_id,vmodel.name as vehicle_model_name
FROM
  base_combination AS bc
INNER JOIN
  base_vehicle_type AS bvt ON bc.id = bvt.base_comb_id 
INNER JOIN 
 local_package_fare AS lpf ON bvt.base_vehicle_id = lpf.base_vehicle_id
INNER join 
 local_package AS lp ON lpf.local_pkg_id = lp.id
LEFT JOIN
  master_package_mode AS mpm ON lp.booking_mode = mpm.id
LEFT JOIN
  master_package AS mp ON bc.master_package_id = mp.id 
LEFT JOIN
  master_vehicle_type AS mvt ON bvt.vehicle_type_id = mvt.id 
LEFT JOIN
master_vehicle_model as vmodel ON mvt.id =vmodel.vehicle_type_id
INNER JOIN 
	vehicle_master AS vm ON mvt.id = vm.id
INNER join 
 	master_fuel_type as fuel ON vm.ignition_type_id= fuel.id
INNER JOIN 
	master_colour AS vcolour ON vm.color  = vcolour.colour_id
LEFT JOIN
  night_charge AS nc ON bvt.base_vehicle_id = nc.base_vehicle_id AND nc.status = "1"
LEFT JOIN
  basic_tax AS tax ON bvt.base_vehicle_id = tax.base_vehicle_id
Left join 
 package_active_timeslot as pat ON bvt.base_vehicle_id = pat.base_vehicle_id
LEFT JOIN 
 user as vendor ON bc.vendor_id = vendor.id
LEFT JOIN 
premiums_fare AS premium ON bvt.base_vehicle_id = premium.base_vehicle_id
LEFT JOIN 
 dispatch_location as dispatch ON bc.id = dispatch.base_comb_id
LEFT JOIN 
 user_rating ON bc.vendor_id = user_rating.UserId

LEFT JOIN user_vehicle_mapping AS umap ON bc.vendor_id = umap.user_id AND umap.vehicle_master_id!=''
LEFT join vehicle_amenities as va ON umap.vehicle_master_id = va.vehicle_master_id and va.status=1
LEFT JOIN master_amenities mva ON va.amenities_id = mva.id
WHERE
bc.city_id  = city_id AND bc.master_package_id = master_package_id  
AND mvt.seating_capacity >= seating_capacity
AND mvt.luggage >=luggage
AND bc.status = '1'
AND bc.vendor_id NOT IN (Select user_id from vendor_status where end_date > pickup_date_time and start_date < pickup_date_time)
group by bvt.base_vehicle_id,vm.id
;
ELSE 

SELECT
  bc.id AS base_comb_id,
  bc.date_from,
  bc.date_to,
  pat.start_time,
  pat.end_time,
  bc.city_id,
  mp.id AS master_package_id,
  mp.name AS package_name,
  mp.image,
  mpm.id AS master_package_mode_id,
  mpm.package_mode,
  nc.night_rate_begins,
  nc.night_rate_ends,
  nc.night_rate_type,
  nc.night_rate_value,
  bvt.base_vehicle_id,
  mvt.id AS master_vehicle_type_id,
  mvt.vehicle_type,
  GROUP_CONCAT(DISTINCT vmodel.name SEPARATOR ', ') as vehicle_name,
   GROUP_CONCAT(DISTINCT vm.model SEPARATOR ', ') as vehicle_model,
  GROUP_CONCAT(DISTINCT vcolour.colour_name SEPARATOR ', ') as vehicle_color,
   GROUP_CONCAT(DISTINCT fuel.fuel_type SEPARATOR ', ') as ignition_type,
  mvt.vehicle_image, 
  mvt.seating_capacity,
  mvt.amenities,
  mvt.luggage,
  tax.sgst,
  tax.cgst,
  tax.igst,
  bc.vendor_id,
  concat(vendor.first_name,' ',vendor.last_name) as vendor_name,
  vendor.email as vendor_email,
  vendor.mobile as vendor_mobile,
  premium.premiums_type,
  premium.premiums_value,
  dispatch.type_of_dispatch ,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude,
user_rating.Rating as rating
FROM
  base_combination AS bc
LEFT JOIN
  master_package_mode AS mpm ON bc.master_package_mode_id = mpm.id
LEFT JOIN
  master_package AS mp ON bc.master_package_id = mp.id
LEFT JOIN
  base_vehicle_type AS bvt ON bc.id = bvt.base_comb_id 
LEFT JOIN
  master_vehicle_type AS mvt ON bvt.vehicle_type_id = mvt.id
LEFT JOIN
master_vehicle_model as vmodel ON mvt.id =vmodel.vehicle_type_id
INNER JOIN 
	vehicle_master AS vm ON mvt.id = vm.id
INNER join 
 	master_fuel_type as fuel ON vm.ignition_type_id= fuel.id
INNER JOIN 
	master_colour AS vcolour ON vm.color  = vcolour.colour_id
LEFT JOIN
  night_charge AS nc ON bvt.base_vehicle_id = nc.base_vehicle_id AND nc.status = "1"
LEFT JOIN
  basic_tax AS tax ON bvt.base_vehicle_id = tax.base_vehicle_id
Left join 
 package_active_timeslot as pat ON bvt.base_vehicle_id = pat.base_vehicle_id
 LEFT JOIN 
 user as vendor ON bc.vendor_id = vendor.id
LEFT JOIN 
	premiums_fare AS premium ON bvt.base_vehicle_id = premium.base_vehicle_id 
LEFT JOIN 
 dispatch_location as dispatch ON bc.id = dispatch.base_comb_id
 LEFT JOIN 
 user_rating ON bc.vendor_id = user_rating.UserId
WHERE
  bc.city_id  = city_id AND bc.master_package_id = master_package_id 
AND bc.status = '1'
AND mvt.seating_capacity >= seating_capacity
AND mvt.luggage >=luggage
group by bvt.base_vehicle_id,vm.id
;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_fare_details_15-aug-20` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_fare_details_15-aug-20`(IN `city_id` INT, IN `master_package_id` INT, IN `local_pkg_id` INT, IN `seating_capacity` INT, IN `luggage` INT)
BEGIN
IF local_pkg_id>0
THEN
SELECT
  bc.id AS base_comb_id,
  bc.date_from,
  bc.date_to,
  pat.start_time,
  pat.end_time,
  bc.city_id,
  mp.id AS master_package_id,
  mp.name AS package_name,
  mp.image,
  mpm.id AS master_package_mode_id,
  mpm.package_mode,
  nc.night_rate_begins,
  nc.night_rate_ends,
  nc.night_rate_type,
  nc.night_rate_value,
  bvt.base_vehicle_id,
  mvt.id AS master_vehicle_type_id,
  mvt.category_id as vehicle_category_id,
  mvt.vehicle_type,
  GROUP_CONCAT(vmodel.name SEPARATOR ', ') as vehicle_name,
  mvt.vehicle_image,
  mvt.seating_capacity,
  mvt.amenities,
  mvt.luggage,
  tax.sgst,
  tax.cgst,
  tax.igst,
  concat(vendor.first_name,' ',vendor.last_name) as vendor_name,
  vendor.email as vendor_email,
  vendor.mobile as vendor_mobile,
  premium.premiums_type,
  premium.premiums_value,
  dispatch.type_of_dispatch ,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude
FROM
  base_combination AS bc
INNER JOIN
  base_vehicle_type AS bvt ON bc.id = bvt.base_comb_id 
INNER JOIN 
 local_package_fare AS lpf ON bvt.base_vehicle_id = lpf.base_vehicle_id
INNER join 
 local_package AS lp ON lpf.local_pkg_id = lp.id
LEFT JOIN
  master_package_mode AS mpm ON lp.booking_mode = mpm.id
LEFT JOIN
  master_package AS mp ON lp.id = mp.id 
LEFT JOIN
  master_vehicle_type AS mvt ON bvt.vehicle_type_id = mvt.id 
LEFT JOIN
master_vehicle_model as vmodel ON mvt.id =vmodel.vehicle_type_id
LEFT JOIN
  night_charge AS nc ON bvt.base_vehicle_id = nc.base_vehicle_id AND nc.status = "1"
LEFT JOIN
  basic_tax AS tax ON bvt.base_vehicle_id = tax.base_vehicle_id
Left join 
 package_active_timeslot as pat ON bvt.base_vehicle_id = pat.base_vehicle_id
LEFT JOIN 
 user as vendor ON bc.vendor_id = vendor.id
LEFT JOIN 
premiums_fare AS premium ON bvt.base_vehicle_id = premium.base_vehicle_id
LEFT JOIN 
 dispatch_location as dispatch ON bc.id = dispatch.base_comb_id
WHERE
  bc.city_id  = city_id AND bc.master_package_id = master_package_id  AND lpf.local_pkg_id = local_pkg_id
AND mvt.seating_capacity >= seating_capacity
AND mvt.luggage >=luggage
AND bc.status = '1'
group by bvt.base_vehicle_id
;
ELSE 
SELECT
  bc.id AS base_comb_id,
  bc.date_from,
  bc.date_to,
  pat.start_time,
  pat.end_time,
  bc.city_id,
  mp.id AS master_package_id,
  mp.name AS package_name,
  mp.image,
  mpm.id AS master_package_mode_id,
  mpm.package_mode,
  nc.night_rate_begins,
  nc.night_rate_ends,
  nc.night_rate_type,
  nc.night_rate_value,
  bvt.base_vehicle_id,
  mvt.id AS master_vehicle_type_id,
  mvt.vehicle_type,
  GROUP_CONCAT(vmodel.name SEPARATOR ', ') as vehicle_name,
  mvt.vehicle_image, 
  mvt.seating_capacity,
  mvt.amenities,
  mvt.luggage,
  tax.sgst,
  tax.cgst,
  tax.igst,
  concat(vendor.first_name,' ',vendor.last_name) as vendor_name,
  vendor.email as vendor_email,
  vendor.mobile as vendor_mobile,
  premium.premiums_type,
  premium.premiums_value,
  dispatch.type_of_dispatch ,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude
FROM
  base_combination AS bc
LEFT JOIN
  master_package_mode AS mpm ON bc.master_package_mode_id = mpm.id
LEFT JOIN
  master_package AS mp ON bc.master_package_id = mp.id
LEFT JOIN
  base_vehicle_type AS bvt ON bc.id = bvt.base_comb_id 
LEFT JOIN
  master_vehicle_type AS mvt ON bvt.vehicle_type_id = mvt.id
LEFT JOIN
master_vehicle_model as vmodel ON mvt.id =vmodel.vehicle_type_id
LEFT JOIN
  night_charge AS nc ON bvt.base_vehicle_id = nc.base_vehicle_id AND nc.status = "1"
LEFT JOIN
  basic_tax AS tax ON bvt.base_vehicle_id = tax.base_vehicle_id
Left join 
 package_active_timeslot as pat ON bvt.base_vehicle_id = pat.base_vehicle_id
 LEFT JOIN 
 user as vendor ON bc.vendor_id = vendor.id
LEFT JOIN 
	premiums_fare AS premium ON bvt.base_vehicle_id = premium.base_vehicle_id 
LEFT JOIN 
 dispatch_location as dispatch ON bc.id = dispatch.base_comb_id
WHERE
  bc.city_id  = city_id AND bc.master_package_id = master_package_id 
AND bc.status = '1'
AND mvt.seating_capacity >= seating_capacity
AND mvt.luggage >=luggage
group by bvt.base_vehicle_id
;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_fare_details_old_18-feb-20` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_fare_details_old_18-feb-20`(IN `city_id` INT, IN `master_package_id` INT, IN `local_pkg_id` INT, IN `seating_capacity` INT, IN `luggage` INT)
BEGIN
IF local_pkg_id>0
THEN
SELECT
  bc.id AS base_comb_id,
  bc.date_from,
  bc.date_to,
  pat.start_time,
  pat.end_time,
  bc.city_id,
  mp.id AS master_package_id,
  mp.name AS package_name,
  mp.image,
  mpm.id AS master_package_mode_id,
  mpm.package_mode,
  nc.night_rate_begins,
  nc.night_rate_ends,
  nc.night_rate_type,
  nc.night_rate_value,
  bvt.base_vehicle_id,
  mvt.id AS master_vehicle_type_id,
  mvt.vehicle_type,
  mvt.vehicle_image,
  mvt.seating_capacity,
  mvt.amenities,
  mvt.luggage,
  tax.sgst,
  tax.cgst,
  tax.igst,
  concat(vendor.first_name,' ',vendor.last_name) as vendor_name,
  vendor.email as vendor_email,
  vendor.mobile as vendor_mobile,
  premium.premiums_type,
  premium.premiums_value,
  dispatch.type_of_dispatch ,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude
FROM
  base_combination AS bc
INNER JOIN
  base_vehicle_type AS bvt ON bc.id = bvt.base_comb_id 
INNER JOIN 
 local_package_fare AS lpf ON bvt.base_vehicle_id = lpf.base_vehicle_id
INNER join 
 local_package AS lp ON lpf.local_pkg_id = lp.id
LEFT JOIN
  master_package_mode AS mpm ON lp.booking_mode = mpm.id
LEFT JOIN
  master_package AS mp ON lp.id = mp.id 
LEFT JOIN
  master_vehicle_type AS mvt ON bvt.vehicle_type_id = mvt.id 
LEFT JOIN
  night_charge AS nc ON bvt.base_vehicle_id = nc.base_vehicle_id AND nc.status = "1"
LEFT JOIN
  basic_tax AS tax ON bvt.base_vehicle_id = tax.base_vehicle_id
Left join 
 package_active_timeslot as pat ON bvt.base_vehicle_id = pat.base_vehicle_id
  LEFT JOIN 
 user as vendor ON bc.vendor_id = vendor.id
LEFT JOIN 
	premiums_fare AS premium ON bvt.base_vehicle_id = premium.base_vehicle_id
LEFT JOIN 
 dispatch_location as dispatch ON bc.id = dispatch.base_comb_id  
WHERE
  bc.city_id  = city_id AND bc.master_package_id = master_package_id  AND lpf.local_pkg_id = local_pkg_id
AND mvt.seating_capacity >= seating_capacity
AND mvt.luggage >=luggage
AND bc.status = '1'
;
ELSE 
SELECT
  bc.id AS base_comb_id,
  bc.date_from,
  bc.date_to,
  pat.start_time,
  pat.end_time,
  bc.city_id,
  mp.id AS master_package_id,
  mp.name AS package_name,
  mp.image,
  mpm.id AS master_package_mode_id,
  mpm.package_mode,
  nc.night_rate_begins,
  nc.night_rate_ends,
  nc.night_rate_type,
  nc.night_rate_value,
  bvt.base_vehicle_id,
  mvt.id AS master_vehicle_type_id,
  mvt.vehicle_type,
  mvt.vehicle_image,
  mvt.seating_capacity,
  mvt.amenities,
  mvt.luggage,
  tax.sgst,
  tax.cgst,
  tax.igst,
  concat(vendor.first_name,' ',vendor.last_name) as vendor_name,
  vendor.email as vendor_email,
  vendor.mobile as vendor_mobile,
  premium.premiums_type,
  premium.premiums_value,
  dispatch.type_of_dispatch ,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude
FROM
  base_combination AS bc
LEFT JOIN
  master_package_mode AS mpm ON bc.master_package_mode_id = mpm.id
LEFT JOIN
  master_package AS mp ON bc.master_package_id = mp.id
LEFT JOIN
  base_vehicle_type AS bvt ON bc.id = bvt.base_comb_id 
LEFT JOIN
  master_vehicle_type AS mvt ON bvt.vehicle_type_id = mvt.id 
LEFT JOIN
  night_charge AS nc ON bvt.base_vehicle_id = nc.base_vehicle_id AND nc.status = "1"
LEFT JOIN
  basic_tax AS tax ON bvt.base_vehicle_id = tax.base_vehicle_id
Left join 
 package_active_timeslot as pat ON bvt.base_vehicle_id = pat.base_vehicle_id
 LEFT JOIN 
 user as vendor ON bc.vendor_id = vendor.id
LEFT JOIN 
	premiums_fare AS premium ON bvt.base_vehicle_id = premium.base_vehicle_id 
LEFT JOIN 
 dispatch_location as dispatch ON bc.id = dispatch.base_comb_id
WHERE
  bc.city_id  = city_id AND bc.master_package_id = master_package_id 
AND bc.status = '1'
AND mvt.seating_capacity >= seating_capacity
AND mvt.luggage >=luggage
;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_get_all_complaint_by_id` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_get_all_complaint_by_id`(IN `complaint_id_i` INT)
BEGIN
SELECT * FROM complaint WHERE ID = complaint_id_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_get_all_enquiry_by_id` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_get_all_enquiry_by_id`(IN `enquiry_id` INT)
BEGIN
SELECT * FROM enquiry WHERE id = enquiry_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_get_booking_filter_new` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_get_booking_filter_new`(IN `CallerID` VARCHAR(50), IN `book_ref` VARCHAR(50), IN `Todate` DATETIME, IN `FromDate` DATETIME, IN `vehicle_number` VARCHAR(50), IN `vehicle_Driver` VARCHAR(50))
BEGIN
SELECT CONCAT(cab_status.`status`,' ',IFNULL(CONCAT("(INR ",booking_charges.totalBill,")"),'')) as `status`,
complaint.ID as com_id,complaint.StatusID as com_status,
 cab_booking.CSR_ID as emp,
 CONCAT(cab_booking.DropAddress,cab_booking.DropArea) as drop_area,
 cab_booking.ID as id,booking_charges.totalBill,
  cab_booking.booking_reference as ref,
  master_package.Master_Package as booking_type,
  CONCAT(cab_booking.PickupDate," ",cab_booking.PickupTime) as ordertime,
  concat(client.clientName," ",appid.`type`)   as partner,
  CONCAT(cab_list_mgmt.name,', ',driver.FirstName,"(",driver.ContactNo,")") as vehicle,
  CONCAT(user_info.FirstName,"(",user_info.MobNo,")") as clientname,
  CONCAT(driver.FirstName," ",driver.ContactNo) as driver_name, 
  cab_booking.MobileNo as mob_no,
  user_info.UID as client_id,
  driver.UID as driver_id,
  CONCAT(cab_booking.PickupAddress,' ',cab_booking.PickupArea) as departure,
  driver.VehicleRegistrationNo as reg 
  FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` 
  LEFT JOIN driver ON cab_booking.pickup=driver.uid 
  LEFT JOIN cab_list_mgmt ON driver.TypeOfvehicle=cab_list_mgmt.id 
  JOIN appid ON appid.id=cab_booking.partner 
  JOIN client ON appid.clientId=client.id 
  LEFT JOIN booking_charges ON cab_booking.ID=booking_charges.BookingID 
  WHERE cab_status.`type`='cab' 
    and cab_booking.Bookingdate >= FromDate 
	 AND cab_booking.Bookingdate <= Todate and cab_booking.MobileNo=IFNULL(CallerID,cab_booking.MobileNo) 
	 and  cab_booking.Booking_reference=IFNULL(book_ref, cab_booking.Booking_reference)  
	 and  driver.VehicleRegistrationNo=IFNULL(vehicle_number, driver.VehicleRegistrationNo) 
	 and  driver.FirstName=IFNULL(vehicle_Driver, driver.FirstName) order by cab_booking.ID desc ;   
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_get_land_mark_address` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_get_land_mark_address`(IN `PiCity` VARCHAR(50), IN `PiZone` VARCHAR(50), IN `PiArea` VARCHAR(50))
BEGIN
select distinct Address from rt_locations where city=PiCity and zone=PiZone and area=PiArea order by id desc limit 1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_get_lat_lot_address` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_get_lat_lot_address`(IN `PiCity` INT, IN `PiZone` INT, IN `PiArea` INT, IN `PiAddress` INT)
BEGIN
select lat ,lon  from rt_locations where city=PiCity and zone=PiZone and area=PiArea and Address=PiAddress order by id desc limit 1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_homepage_text` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_homepage_text`()
    NO SQL
Begin
Select text,text_id from region_text where page_title='home' and lang=2;
end ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_locate_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_locate_booking`(IN `bookid` VARCHAR(50), IN `driverid` VARCHAR(50), IN `latitide` VARCHAR(50), IN `longitude` VARCHAR(50))
BEGIN
DECLARE lastid INT;
UPDATE booking SET `status`=4 WHERE booking_id=bookid;
INSERT INTO `booking_tracker` (`BookingID`,`DriverId`,`Latitutude`,`Logitude`,`Date_Time`,`CabStatus`) VALUES (bookid,driverid,latitide,longitude,NOW(),'4');
INSERT INTO `booking_logs` (`bookingid`,`user_id`,`status`,`message`,`time`) VALUES (bookid,driverid,'4','Located',NOW());
SELECT LAST_INSERT_ID() INTO lastid;
SELECT lastid;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_locate_booking_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_locate_booking_old`(IN `bookid` VARCHAR(50), IN `driverid` VARCHAR(50), IN `latitide` VARCHAR(50), IN `longitude` VARCHAR(50))
BEGIN
DECLARE lastid INT;
UPDATE booking SET `status`=4 WHERE booking_id=bookid;
INSERT INTO `booking_tracker` (`BookingID`,`DriverId`,`Latitutude`,`Logitude`,`Date_Time`,`CabStatus`) VALUES (bookid,driverid,latitide,longitude,NOW(),'4');
INSERT INTO `booking_logs` (`bookingid`,`status`,`message`,`time`) VALUES (bookid,'4','Located',NOW()); 
SELECT LAST_INSERT_ID() INTO lastid;
SELECT lastid;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_login_text` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_login_text`()
    NO SQL
Begin
Select text,text_id from region_text where page_title='login' and lang=2;
end ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_logout` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_logout`(IN `login_id` INT, IN `token` VARCHAR(200), IN `logout_location` VARCHAR(200))
    NO SQL
BEGIN
UPDATE user SET login_status = 0, gcm_id = '',logout_time = NOW() WHERE `id` = login_id;
UPDATE driver SET `status`=0 WHERE user_id = login_id;
UPDATE log_in_log SET logout_time=NOW(),logout_location =logout_location WHERE userId = login_id and status=token;
UPDATE log_in_log SET `logout_date`= DATE(log_in_log.logout_time), login_diff=TIMEDIFF(log_in_log.logout_time,log_in_log.login_time) where userID=login_id and status=token;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_mohit_logout` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_mohit_logout`(IN `login_id` INT, IN `token` VARCHAR(200))
    NO SQL
BEGIN
UPDATE user SET loginStatus = 0,
						 gcm_id = '',
						 is_active = 0,
						 logoutTime = NOW()
WHERE `ID` = login_id;
UPDATE driver SET `status`=0 WHERE UID = login_id and status=token;
UPDATE log_in_log SET logout_time=NOW() WHERE userId = login_id and status=token;
UPDATE log_in_log SET `logout_date`= DATE(log_in_log.logout_time), login_diff=TIMEDIFF(log_in_log.logout_time,log_in_log.login_time) where userID=login_id and status=token;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_new_check` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_new_check`(IN `val` INT, IN `initial` TEXT)
BEGIN
DECLARE divide INT;
DECLARE neww VARCHAR(50);
DECLARE next INT;
DECLARE generated_ref TEXT;
IF val>=10000 THEN
SET divide=floor(val/10000);
SET next=val-(divide*10000);
SET neww=CHAR(64+divide);
SELECT neww,lpad(next,4,0), CONCAT(initial,DATE_FORMAT(NOW(), '%y') 
,DATE_FORMAT(NOW(), '%m'),neww,lpad(next,4,0)) into generated_ref;
ELSE
SELECT CONCAT(initial,DATE_FORMAT(NOW(), '%y') ,DATE_FORMAT(NOW(), 
'%m'),lpad(val,4,0)) into generated_ref;
END IF;
UPDATE cab_booking SET booking_reference=xyz WHERE id=val;
SELECT generated_ref;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_new_filter_search` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_new_filter_search`(IN `status_i` INT(10), IN `check_val` INT(10), IN `s_val` VARCHAR(50))
    NO SQL
BEGIN
DECLARE checklogin VARCHAR(50);
SET checklogin=s_val;
IF  check_val = 0 THEN
SELECT cab_booking.charge_type,cab_booking.pickup_date,complaint.ID as com_id,complaint.StatusID as com_status, cab_booking.CSR_ID as
emp,CONCAT(cab_booking.drop_address,cab_booking.drop_area)
as drop_area,cab_booking.ID as id,booking_charges.totalBill, cab_booking.booking_reference as ref,master_package.master_package
as booking_type,
CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as
ordertime,concat(client.clientName,'<br>(',appid.`type`,')') as partner,
REPLACE(cab_master.CabName,'•','') as vehicle,CONCAT(user_info.first_name," ",user_info.last_name) as clientname, user_info.alternate_contact_no as alt_no, CONCAT(driver.first_name," ",driver.last_name) as driver_name, user_info.mobile_no as mob_no,user_info.uid as client_id,driver.UID as driver_id, CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,driver.vehicle_reg_no as reg,cab_status.`status` as `status` FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` JOIN user_info ON user_info.uid=cab_booking.client_id
JOIN master_package ON
cab_booking.booking_type=master_package.package_id LEFT JOIN driver ON cab_booking.pickup=driver.uid
LEFT JOIN cab_master ON
driver.vehicle_id=cab_master.CabId JOIN appid ON appid.id=cab_booking.partner JOIN client ON appid.clientId=client.id LEFT JOIN booking_charges ON cab_booking.id=booking_charges.BookingID
LEFT JOIN complaint ON
cab_booking.booking_reference=complaint.BookingID WHERE cab_status.`type`='cab'  and cab_status.status_id = status_i;
END if;
IF  check_val = 1 THEN
SELECT cab_booking.charge_type,cab_booking.pickup_date,IFNULL ( complaint.ID,'Not Available') as com_id, IFNULL ( complaint.StatusID,'Not Available') as com_status, cab_booking.csr_id as emp,CONCAT(cab_booking.drop_address,cab_booking.drop_area) as drop_area,cab_booking.id as id,
IFNULL(booking_charges.totalBill, 0) as totalBill, cab_booking.booking_reference as ref,master_package.master_package as booking_type,
CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as ordertime,concat(client.clientName,'<br>(',appid.`type`,')') as partner,
IFNULL (REPLACE(cab_master.CabName,'•','') ,'Not Available') as vehicle,CONCAT(user_info.first_name," ",user_info.last_name) as clientname, user_info.alternate_contact_no as alt_no, IFNULL ( CONCAT(driver.first_name," ",driver.last_name),'Not Available') as driver_name, user_info.mobile_no as mob_no,user_info.uid as client_id, IFNULL ( driver.uid,0) as driver_id, CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,IFNULL ( driver.vehicle_reg_no ,'Not Available') as reg, CONCAT(cab_status.status ," ", "") as status 
FROM cab_booking JOIN cab_status ON cab_booking.status_c=cab_status.`status_id`
JOIN user_info ON user_info.uid=cab_booking.client_id
JOIN master_package ON
cab_booking.booking_type=master_package.package_id LEFT JOIN driver ON cab_booking.pickup=driver.uid
LEFT JOIN cab_master ON
driver.vehicle_id=cab_master.CabId JOIN appid ON appid.id=cab_booking.partner JOIN client ON appid.clientId=client.id LEFT JOIN booking_charges ON cab_booking.ID=booking_charges.BookingID
LEFT JOIN complaint ON
cab_booking.booking_reference=complaint.BookingID WHERE cab_status.`type`='cab'  and cab_status.status_id = status_i;
END if;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_oneway_fare_details` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_oneway_fare_details`(IN `city_id` INT, IN `dropcity_id` INT, IN `master_package_id` INT, IN `local_pkg_id` INT, IN `seating_capacity` INT, IN `luggage` INT, IN `pickup_date` VARCHAR(50))
BEGIN
SELECT
  bc.id AS base_comb_id,
  bc.date_from,
  bc.date_to,
  pat.start_time,
  pat.end_time,
  bc.city_id,
  mp.id AS master_package_id,
  mp.name AS package_name,
  mp.image,
  mpm.id AS master_package_mode_id,
  mpm.package_mode,
  nc.night_rate_begins,
  nc.night_rate_ends,
  nc.night_rate_type,
  nc.night_rate_value,
  bvt.base_vehicle_id,
  mvt.id AS master_vehicle_type_id,
  mvt.vehicle_type,
  GROUP_CONCAT(DISTINCT vmodel.name SEPARATOR ', ') as vehicle_name,
   GROUP_CONCAT(DISTINCT vm.model SEPARATOR ', ') as vehicle_model,
  GROUP_CONCAT(DISTINCT vcolour.colour_name SEPARATOR ', ') as vehicle_color,
   GROUP_CONCAT(DISTINCT fuel.fuel_type SEPARATOR ', ') as ignition_type,
  mvt.vehicle_image, 
  mvt.seating_capacity,
  mvt.amenities,
  mvt.luggage,
  tax.sgst,
  tax.cgst,
  tax.igst,
  bc.vendor_id,
  concat(vendor.first_name,' ',vendor.last_name) as vendor_name,
  vendor.email as vendor_email,
  vendor.mobile as vendor_mobile,
  premium.premiums_type,
  premium.premiums_value,
  dispatch.type_of_dispatch ,
dispatch.garage_type,
dispatch.address as garage_address,
dispatch.pincode as garage_pincode,
dispatch.latitude as garage_latitude,
dispatch.longitude as garage_longitude,
user_rating.Rating as rating,
oneway.city_distance_id,
citylist.source_city as source_city_id,citylist.destination_city as destination_city_id,
sourcecity.name as source_city_name,destinationcity.name as destination_city_name,
nc.night_rate_value as driver_allowance,ctt.toll as toll_tax,ctt.parking as parking_charge,ctt.city_tax as city_tax 
FROM
  base_combination AS bc
LEFT JOIN
  master_package_mode AS mpm ON bc.master_package_mode_id = mpm.id
LEFT JOIN
  master_package AS mp ON bc.master_package_id = mp.id
LEFT JOIN
  base_vehicle_type AS bvt ON bc.id = bvt.base_comb_id 
LEFT JOIN
  master_vehicle_type AS mvt ON bvt.vehicle_type_id = mvt.id
LEFT JOIN
master_vehicle_model as vmodel ON mvt.id =vmodel.vehicle_type_id
INNER JOIN 
	vehicle_master AS vm ON mvt.id = vm.id
INNER join 
 	master_fuel_type as fuel ON vm.ignition_type_id= fuel.id
INNER JOIN 
	master_colour AS vcolour ON vm.color  = vcolour.colour_id
LEFT JOIN
  basic_tax AS tax ON bvt.base_vehicle_id = tax.base_vehicle_id
Left join 
 package_active_timeslot as pat ON bvt.base_vehicle_id = pat.base_vehicle_id
 LEFT JOIN 
 user as vendor ON bc.vendor_id = vendor.id
LEFT JOIN 
	premiums_fare AS premium ON bvt.base_vehicle_id = premium.base_vehicle_id 
LEFT JOIN 
 dispatch_location as dispatch ON bc.id = dispatch.base_comb_id
 LEFT JOIN 
 user_rating ON bc.vendor_id = user_rating.UserId
 LEFT JOIN 
 oneway_city_route_package AS oneway ON bvt.base_vehicle_id = oneway.base_vehicle_id
 LEFT JOIN 
 city_distance_list as citylist ON oneway.city_distance_id = citylist.id AND citylist.source_city = city_id AND citylist.destination_city= dropcity_id
  LEFT JOIN master_city as sourcecity ON  citylist.source_city = sourcecity.id 
LEFT JOIN master_city as destinationcity ON citylist.destination_city = destinationcity.id 
 LEFT JOIN bidding_fare  ON bvt.base_vehicle_id =  bidding_fare.base_vehicle_id 
 LEFT JOIN night_charge as nc ON bvt.base_vehicle_id =  nc.base_vehicle_id 
LEFT JOIN city_toll_tax as ctt ON bvt.base_vehicle_id =  ctt.base_vehicle_id
WHERE
  bc.city_id  = city_id AND bc.master_package_id = master_package_id 

AND bc.status = '1'
AND bc.date_from <= pickup_date AND bc.date_to >=pickup_date 
AND mvt.seating_capacity >= seating_capacity
AND mvt.luggage >=luggage
group by bvt.base_vehicle_id,vm.id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_vehicle_filter` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_vehicle_filter`(IN `stauts_id` INT)
BEGIN
SELECT  DISTINCT(driver.id),driver.uid,cab_booking.booking_reference,cab_booking.drop_area,cab_list_mgmt.vehicleNumber,CONCAT(driver.first_name,' ',driver.last_name) as name,driver.contact_no,driver.`status`,user.login_status,cab_booking.`Status` FROM driver JOIN cab_list_mgmt ON driver.vehicle_id=cab_list_mgmt.id JOIN user ON driver.uid=user.id inner join cab_booking ON driver.uid=cab_booking.pickup and cab_booking.`Status`=stauts_id GROUP BY driver.uid ORDER BY cab_booking.`Status` DESC ; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_accept_fetch_job` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_accept_fetch_job`(IN `bookid` INT, IN `driver_id` INT)
BEGIN
DECLARE is_stack int;
DECLARE BookingTypeVal varchar(50);
DECLARE unsuccess int;
DECLARE vehicleType varchar(50);
SELECT COUNT(*),master_package.name,master_vehicle_type.vehicle_type  into is_stack,BookingTypeVal,vehicleType FROM booking left join master_package ON booking.master_package_id = master_package.id LEFT JOIN master_vehicle_type  ON booking.master_vehicle_type_id =master_vehicle_type.id WHERE booking.booking_id=bookid and booking.driver_id=0 and booking.booking_status='1'; 
IF is_stack=1 THEN
UPDATE booking SET driver_id=driver_id, `status` = '3', is_updation_allow='FALSE'  WHERE booking_id=bookid and booking_status='1' and is_updation_allow='TRUE'; 
   END IF;
   SELECT is_stack,BookingTypeVal,vehicleType;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_accept_fetch_job_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_accept_fetch_job_old`(IN `bookid` INT, IN `driver_id` INT)
BEGIN
DECLARE is_stack int;
DECLARE BookingTypeVal int;
DECLARE unsuccess int;
SELECT COUNT(*),BookingType into is_stack,BookingTypeVal FROM cab_booking WHERE id=bookid and pickup=0 and BookingStatus='1'; 
IF is_stack=1 THEN
UPDATE cab_booking SET pickup=driver_id, `Status` = '3', is_updation_allow='FALSE'  WHERE id=bookid and BookingStatus='1' and is_updation_allow='TRUE'; 
   END IF;
   SELECT is_stack,BookingTypeVal;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_admin_driver` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_admin_driver`(IN `state_in` INT)
    NO SQL
BEGIN
DECLARE taxis_reg INT;
DECLARE taxis_road INT;
DECLARE taxis_logged_in INT;
DECLARE taxis_logged_off INT;
DECLARE driver_blocked INT;
DECLARE taxis_not_functional INT;
DECLARE taxis_available INT;
DECLARE total_jobs INT;
DECLARE delhi_jobs INT;
DECLARE gurgaon_jobs INT;
DECLARE faridabad_jobs INT;
DECLARE noida_jobs INT;
DECLARE state_new text;
DECLARE outstation_jobs INT;
DECLARE railway_jobs INT;
DECLARE cancel_jobs INT;
DECLARE airport_jobs INT;
DECLARE taxis_busy INT;
DECLARE job_1 text;
DECLARE job_2 text;
DECLARE job_3 text;
DECLARE job_4 text;
DECLARE taxis_free INT;
DECLARE job_in_progress INT;
DECLARE job_advance INT;
DECLARE cash_duty_val INT DEFAULT 0;
DECLARE credit_duty_val INT DEFAULT 0;
DECLARE total_revenue_val INT DEFAULT 0;
DECLARE point_val INT DEFAULT 0;
DECLARE air_val INT DEFAULT 0;
DECLARE outstation_val INT DEFAULT 0;
DECLARE local_val INT DEFAULT 0;
DECLARE currency VARCHAR(50);
DECLARE job_completed int;
DECLARE cash_val int;
DECLARE credit_val int;
DECLARE local_book int;
DECLARE point_book int;
DECLARE airport_book int;
DECLARE outstation_book int;
DECLARE railway_book int;
DECLARE web_app int;
declare call_center int;
declare user_app int;
declare company_sh int;
declare driver_sh int;
declare partner_sh int;
SELECT COUNT(*) INTO taxis_free FROM driver JOIN user ON driver.uid=user.id WHERE user.login_status='1' and driver.`status`=0 and `state`=state_in;
SELECT COUNT(*) INTO job_in_progress FROM cab_booking WHERE pickup_date=CURDATE() and `status` >3 and `status`< 8;
SELECT value INTO job_1 FROM admin_text WHERE type=state_in and `field`='jobs_1';
SELECT value INTO job_2 FROM admin_text WHERE type=state_in and `field`='jobs_2';
SELECT value INTO job_3 FROM admin_text WHERE type=state_in and `field`='jobs_3';
SELECT value INTO job_4 FROM admin_text WHERE type=state_in and `field`='jobs_4';
SELECT COUNT(*) INTO taxis_reg FROM driver;
SELECT COUNT(*) INTO taxis_road FROM driver WHERE status='1';
SELECT COUNT(*) INTO taxis_busy FROM driver WHERE status='1';
SELECT COUNT(*) INTO taxis_logged_in FROM driver JOIN user ON driver.uid=user.id WHERE user.login_status='1';
SELECT COUNT(*) INTO taxis_logged_off FROM driver JOIN user ON driver.uid=user.id WHERE user.login_status!='1';
SELECT COUNT(*) INTO driver_blocked FROM driver WHERE is_active=0 and state=state_in;
SELECT COUNT(*) INTO taxis_not_functional FROM driver WHERE is_functional=0 and state=state_in;
SELECT COUNT(*) INTO taxis_available FROM driver JOIN user ON driver.uid=user.id WHERE driver.`status`=0 and user.login_status=1;
SELECT `state` INTO state_new FROM states WHERE id=state_in;
SELECT COUNT(*) INTO total_jobs FROM cab_booking WHERE DATE(pickup_date)=CURDATE();
SELECT COUNT(*) INTO delhi_jobs FROM cab_booking WHERE cab_booking.pickup_area LIKE CONCAT('%', job_1, '%') AND DATE(pickup_date)=CURDATE() ;
SELECT COUNT(*) INTO noida_jobs FROM cab_booking WHERE cab_booking.pickup_area LIKE CONCAT('%', job_2, '%') AND DATE(pickup_date)=CURDATE() ;
SELECT COUNT(*) INTO faridabad_jobs FROM cab_booking WHERE cab_booking.pickup_area LIKE CONCAT('%', job_3, '%') AND DATE(pickup_date)=CURDATE();
SELECT COUNT(*) INTO gurgaon_jobs FROM cab_booking WHERE cab_booking.pickup_area LIKE CONCAT('%', job_4, '%') AND DATE(pickup_date)=CURDATE();
SELECT COUNT(*) INTO outstation_jobs FROM cab_booking WHERE DATE(pickup_date)=CURDATE() AND booking_type=104;
SELECT COUNT(*) INTO railway_jobs FROM cab_booking WHERE drop_area LIKE '%railway%' AND DATE(pickup_date)=CURDATE();
SELECT COUNT(*) INTO cancel_jobs FROM cab_booking WHERE `status`=10 AND DATE(pickup_date)=CURDATE();
SELECT COUNT(*) INTO airport_jobs FROM cab_booking WHERE `booking_type`=103 AND DATE(pickup_date)=CURDATE();
SELECT COUNT(*) INTO job_advance FROM cab_booking WHERE pickup_date>CURDATE();
SELECT SUM(booking_charges.totalBill) into cash_duty_val FROM booking_charges WHERE date(booking_charges.AddedTime)=CURDATE() and payment_type='CASH';
SELECT SUM(booking_charges.totalBill) into credit_duty_val FROM booking_charges WHERE date(booking_charges.AddedTime)=CURDATE() and payment_type='CREDIT';
SELECT SUM(booking_charges.totalBill) into total_revenue_val FROM booking_charges WHERE date(booking_charges.AddedTime)=CURDATE();
SELECT SUM(booking_charges.totalBill) into local_val FROM booking_charges JOIN cab_booking ON booking_charges.BookingID=cab_booking.ID WHERE date(booking_charges.AddedTime)=CURDATE() and cab_booking.booking_type=101;
SELECT SUM(booking_charges.totalBill) into point_val FROM booking_charges JOIN cab_booking ON booking_charges.BookingID=cab_booking.ID WHERE date(booking_charges.AddedTime)=CURDATE() and cab_booking.booking_type=102;
SELECT SUM(booking_charges.totalBill) into air_val FROM booking_charges JOIN cab_booking ON booking_charges.BookingID=cab_booking.ID WHERE date(booking_charges.AddedTime)=CURDATE() and cab_booking.booking_type=103;
SELECT SUM(booking_charges.totalBill) into outstation_val FROM booking_charges JOIN cab_booking ON booking_charges.BookingID=cab_booking.ID WHERE date(booking_charges.AddedTime)=CURDATE() and cab_booking.booking_type=104;
SELECT COUNT(*) into job_completed FROM cab_booking WHERE cab_booking.`Status` IN (8,11,12) and pickup_date=CURDATE();
SELECT country.currency into currency fROM country WHERE country.country_name='India';
SELECT COUNT(*) into cash_val FROM cab_booking WHERE cab_booking.`Status`=11 and pickup_date=CURDATE();
SELECT COUNT(*) into credit_val FROM cab_booking WHERE cab_booking.`Status`=12 and pickup_date=CURDATE();
SELECT COUNT(*) into local_book FROM cab_booking WHERE cab_booking.booking_type=101 and pickup_date=CURDATE();
SELECT COUNT(*) into point_book FROM cab_booking WHERE cab_booking.booking_type=102 and pickup_date=CURDATE();
SELECT COUNT(*) into airport_book FROM cab_booking WHERE cab_booking.booking_type=103 and pickup_date=CURDATE();
SELECT COUNT(*) into outstation_book FROM cab_booking WHERE cab_booking.booking_type=104 and pickup_date=CURDATE();
SELECT COUNT(*) into web_app FROM cab_booking WHERE partner=1 and pickup_date=CURDATE();
SELECT COUNT(*) into call_center FROM cab_booking WHERE partner=3 and pickup_date=CURDATE();
SELECT COUNT(*) into user_app FROM cab_booking WHERE partner=2 and pickup_date=CURDATE();
SELECT SUM((booking_charges.totalBill*booking_charges.drivershare)/100) into driver_sh FROM booking_charges WHERE date(booking_charges.AddedTime)=CURDATE();
SELECT SUM((booking_charges.totalBill*booking_charges.companyshare)/100) into company_sh FROM booking_charges WHERE date(booking_charges.AddedTime)=CURDATE();
SELECT SUM((booking_charges.totalBill*booking_charges.partnershare)/100) into partner_sh FROM booking_charges WHERE date(booking_charges.AddedTime)=CURDATE();
SELECT partner_sh,company_sh,driver_sh,web_app,call_center,user_app,local_book,point_book,airport_book,outstation_book,cash_val,credit_val,job_completed,CONCAT(currency,' ',local_val) as local_val,CONCAT(currency,' ',point_val) as point_val,CONCAT(currency,' ',air_val) as air_val,CONCAT(currency,' ',total_revenue_val) as total_revenue_val,CONCAT(currency,' ',cash_duty_val) as cash_duty_val, CONCAT(currency,' ',credit_duty_val) as credit_duty_val,taxis_reg,taxis_road,taxis_logged_in,taxis_logged_off,driver_blocked,taxis_not_functional,taxis_available,total_jobs,delhi_jobs,noida_jobs,faridabad_jobs,gurgaon_jobs,outstation_jobs,railway_jobs,cancel_jobs,airport_jobs,taxis_busy,taxis_free,job_in_progress,job_advance;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_admin_login` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_admin_login`(IN `username_i` VARCHAR(50), IN `password_i` VARCHAR(100), IN `ipaddress` TEXT)
    NO SQL
BEGIN
DECLARE check_login INT;
DECLARE id_s INT;
SELECT COUNT(*),id INTO check_login,id_s FROM web_admin WHERE `email`=username_i and `password` = password_i 
 and IsActive=1;
IF check_login>0 THEN
SELECT *,check_login FROM web_admin WHERE `email`=username_i;
INSERT INTO admin_log (adminId,`login_time`,login_date,lat,`log`,ipaddress) VALUES (id_s,NOW(),CURDATE(),'','',ipaddress);
ELSE
SELECT check_login;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_admin_text` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_admin_text`(IN `id` INT, IN `type_in` INT)
BEGIN
SELECT * FROM admin_text WHERE page=`id` and (`type`=type_in or `type`='0');
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_admin_text_module` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_admin_text_module`(IN `module_i` VARCHAR(50), IN `type_in` INT)
BEGIN
SELECT * FROM admin_text WHERE admin_text.module = module_i and (`type`=type_in or `type`='0');
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_auth` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_auth`(IN `api_key` VARCHAR(200))
    NO SQL
BEGIN
DECLARE check_auth int;
SELECT COUNT(*) INTO check_auth FROM client WHERE clientKey=api_key;
SELECT check_auth;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_a_booking_information` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_a_booking_information`(IN `booking_id` INT)
BEGIN SELECT
  cab_status.status_id,
  cab_status.`status` AS `status`,
  IF(
    booking.`status` IN(10,
    17,
    20,
    21),
    1,
    0
  ) AS `cancel_status`,
  DATE_FORMAT(
    booking_logs.`time`,
    '%Y-%m-%d %H:%i:%s'
  ) AS `time`,
  `message`,
  apitime.api_time,
  apitime.api_distance
FROM
  booking
JOIN
  cab_status ON booking.`status` = cab_status.`status_id`
LEFT JOIN
  booking_logs ON booking_logs.`Status` = cab_status.`status_id` AND booking_logs.bookingid = booking_id
LEFT JOIN 
 api_call_timeinterval AS apitime ON booking.master_package_id = apitime.package_id
WHERE
  booking.booking_id = booking_id AND cab_status.`type` = 'cab';
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_a_booking_information_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_a_booking_information_old`(IN `booking_id` INT, IN `token_val` VARCHAR(50))
BEGIN
SELECT cab_status.`status` as `status`,`time`,`message` FROM booking_logs JOIN cab_status ON booking_logs.`Status`=cab_status.`status_id`
INNER JOIN cab_booking ON booking_logs.bookingid = cab_booking.ID INNER JOIN user ON cab_booking.pickup = user.ID
WHERE booking_logs.bookingid=booking_id and user.token = token_val and cab_status.`type`='cab';
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_a_payment_information` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_a_payment_information`(IN `booking_id` INT, IN `token_val` VARCHAR(50))
BEGIN
SELECT booking_bill.CabName as cab_name,addedtime,cancellation_price,waitingCharge,tripCharge,total_tax_price,totalBill,is_paid,paid_at,currency,invoice_number,payment_type,fees,total_price,total_tax_price,duration_rate,starting_rate,base_price,tax_price,starting_charge,distance_charge,duration_charge,minimum_price,cab_booking.*
FROM cab_booking
LEFT JOIN booking_charges ON cab_booking.id=booking_charges.bookingid
LEFT JOIN booking_bill ON cab_booking.CarType=booking_bill.Id 
INNER JOIN driver ON cab_booking.pickup = driver.UID INNER JOIN user ON  driver.UID = user.ID
WHERE cab_booking.id=booking_id and user.token = token_val; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_booking_details` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_booking_details`()
BEGIN
SELECT bk.booking_id as id,bk.driver_id,bk.reference_number as ref,us2.id as client_id,
	CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
  CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
 CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
mpm.package_mode,
mp.name  as booking_type,
payty.pay_type_mode as charge_type,
mvt.vehicle_type as vehicle,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date,
cs.status,
bkest.*,
bkest.estimated_final_price as amount,
 CONCAT(
    bpd.pickup_date,
    " ",
    bpd.pickup_time
  ) AS ordertime,
  CONCAT(
    bpd.pickup_address,
    ' ',
    bpd.pickup_area
  ) AS departure,
  CONCAT(
    bpd.drop_address,
    bpd.drop_area
  ) AS drop_area,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_landmark,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_landmark,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone
from booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package as lp ON bk.package_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
WHERE
   bpd.pickup_date >= CURDATE() AND bk.status <= 8
ORDER BY
  bk.booking_id DESC;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_booking_details_date` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_booking_details_date`(IN `date_n` DATE, IN `hour_n` INT)
BEGIN
IF hour_n=0
THEN
SELECT bk.booking_id as id,bk.driver_id,bk.reference_number as ref,us2.id as client_id,
	CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
  CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
 CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
mpm.package_mode,
mp.name  as booking_type,
payty.pay_type_mode as charge_type,
mvt.vehicle_type as vehicle,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date,
cs.status,
bkest.*,
bkest.estimated_final_price as amount,
hour(bpd.pickup_time),
 CONCAT(
    bpd.pickup_date,
    " ",
    bpd.pickup_time
  ) AS ordertime,
  CONCAT(
    bpd.pickup_address,
    ' ',
    bpd.pickup_area
  ) AS departure,
  CONCAT(
    bpd.drop_address,
    ' ',
    bpd.drop_area
  ) AS drop_area,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_landmark,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_landmark,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone
from booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package as lp ON bk.package_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
WHERE
   bpd.pickup_date = date_n AND bk.status <= 8   
ORDER BY
  bk.booking_id DESC;
ELSE
SELECT bk.booking_id as id,bk.driver_id,bk.reference_number as ref,us2.id as client_id,
	CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
  CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
 CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
lp.price as local_package_price,
mpm.package_mode,
mp.name  as booking_type,
payty.pay_type_mode as charge_type,
mvt.vehicle_type as vehicle,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date,
cs.status,
bkest.*,
bkest.estimated_final_price as amount,
hour(bpd.pickup_time),
 CONCAT(
    bpd.pickup_date,
    " ",
    bpd.pickup_time
  ) AS ordertime,
  CONCAT(
    bpd.pickup_address,
    ' ',
    bpd.pickup_area
  ) AS departure,
  CONCAT(
    bpd.drop_address,
    ' ',
    bpd.drop_area
  ) AS drop_area,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_landmark,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_landmark,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone
from booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package as lp ON bk.package_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
WHERE
   bpd.pickup_date = date_n AND hour(bpd.pickup_time) = hour_n AND bk.status <= 8   
ORDER BY
  bk.booking_id DESC;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_booking_details_date_bookingtype` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_booking_details_date_bookingtype`(IN `date_n` DATE, IN `btype` INT)
BEGIN
SELECT bk.booking_id as id,bk.driver_id,bk.reference_number as ref,us2.id as client_id,
	CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
  CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
 CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
mpm.package_mode,
mp.name  as booking_type,
payty.pay_type_mode as charge_type,
mvt.vehicle_type as vehicle,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date,
cs.status,
bkest.*,
bkest.estimated_final_price as amount,
hour(bpd.pickup_time),
 CONCAT(
    bpd.pickup_date,
    " ",
    bpd.pickup_time
  ) AS ordertime,
  CONCAT(
    bpd.pickup_address,
    ' ',
    bpd.pickup_area
  ) AS departure,
  CONCAT(
    bpd.drop_address,
    ' ',
    bpd.drop_area
  ) AS drop_area,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_landmark,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_landmark,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone
from booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package as lp ON bk.package_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
WHERE
   bpd.pickup_date = date_n AND bk.master_package_id = btype AND bk.status <= 8   
ORDER BY
  bk.booking_id DESC;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_booking_details_date_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_booking_details_date_old`(IN `date_n` DATE, IN `hour_n` INT)
BEGIN
IF hour_n=0
THEN
SELECT hour(cab_booking.pickup_time),booking_charges.totalBill AS amount,master_package.icon_image,(booking_charges.totalBill*booking_charges.companyshare/100) 
AS cAmount,(booking_charges.totalBill*booking_charges.drivershare/100) AS dAmount,
(booking_charges.totalBill*booking_charges.partnershare/100) AS pAmount,
booking_charges.companyshare AS cshare,booking_charges.drivershare AS dshare,
booking_charges.partnershare AS pshare,complaint.ID as com_id,
complaint.StatusID as com_status, cab_booking.CSR_ID as emp,
CONCAT(cab_booking.drop_address,cab_booking.drop_area) as drop_area,cab_booking.ID as id,
booking_charges.totalBill, cab_booking.booking_reference as ref,
master_package.Master_Package as booking_type,
CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as ordertime,
concat(client.clientName,'<br>(',appid.`type`,')') as partner,
REPLACE(cab_master.CabName,'·','') as vehicle,
CONCAT(user_info.first_name," ",user_info.last_name) as clientname,user_info.alternate_contact_no as alt_no,
CONCAT(driver.first_name," ",driver.last_name) as driver_name, 
user_info.mobile_no as mob_no,user_info.uid as client_id,driver.UID as driver_id,
CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,
driver.vehicle_reg_no as reg,cab_status.`status` as `status`
 FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` 
 JOIN user_info ON user_info.uid=cab_booking.client_id 
 JOIN master_package ON cab_booking.booking_type=master_package.package_id 
 LEFT JOIN driver ON cab_booking.pickup=driver.uid 
 LEFT JOIN cab_master ON driver.vehicle_id=cab_master.CabId 
 JOIN appid ON appid.id=cab_booking.partner 
 JOIN client ON appid.clientId=client.id 
 LEFT JOIN booking_charges ON cab_booking.ID=booking_charges.BookingID 
 LEFT JOIN complaint ON cab_booking.booking_reference=complaint.BookingID 
 WHERE cab_status.`type`='cab' and cab_booking.pickup_date=date_n and cab_booking.status<=8 order by cab_booking.ID desc;   
ELSE
SELECT booking_charges.totalBill AS amount,master_package.icon_image,(booking_charges.totalBill*booking_charges.companyshare/100) 
AS cAmount,(booking_charges.totalBill*booking_charges.drivershare/100) AS dAmount,
(booking_charges.totalBill*booking_charges.partnershare/100) AS pAmount,
booking_charges.companyshare AS cshare,booking_charges.drivershare AS dshare,
booking_charges.partnershare AS pshare,complaint.ID as com_id,
complaint.StatusID as com_status, cab_booking.CSR_ID as emp,
CONCAT(cab_booking.drop_address,cab_booking.drop_area) as drop_area,cab_booking.ID as id,
booking_charges.totalBill, cab_booking.booking_reference as ref,
master_package.Master_Package as booking_type,
CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as ordertime,
concat(client.clientName,'<br>(',appid.`type`,')') as partner,
REPLACE(cab_master.CabName,'·','') as vehicle,
CONCAT(user_info.first_name," ",user_info.last_name) as clientname,user_info.alternate_contact_no as alt_no,
CONCAT(driver.first_name," ",driver.last_name) as driver_name, 
user_info.mobile_no as mob_no,user_info.uid as client_id,driver.UID as driver_id,
CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,
driver.vehicle_reg_no as reg,cab_status.`status` as `status`
 FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` 
 JOIN user_info ON user_info.uid=cab_booking.client_id 
 JOIN master_package ON cab_booking.booking_type=master_package.package_id 
 LEFT JOIN driver ON cab_booking.pickup=driver.uid 
 LEFT JOIN cab_master ON driver.vehicle_id=cab_master.CabId
 JOIN appid ON appid.id=cab_booking.partner 
 JOIN client ON appid.clientId=client.id 
 LEFT JOIN booking_charges ON cab_booking.ID=booking_charges.BookingID 
 LEFT JOIN complaint ON cab_booking.booking_reference=complaint.BookingID 
 WHERE cab_status.`type`='cab' and cab_booking.pickup_date=date_n and hour(cab_booking.pickup_time)=hour_n and cab_booking.status<=8 order by cab_booking.ID desc;   
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_booking_details_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_booking_details_old`()
BEGIN
SELECT master_package.icon_image,booking_charges.totalBill AS amount,(booking_charges.totalBill*booking_charges.companyshare/100) 
AS cAmount,(booking_charges.totalBill*booking_charges.drivershare/100) AS dAmount,
(booking_charges.totalBill*booking_charges.partnershare/100) AS pAmount,
booking_charges.companyshare AS cshare,booking_charges.drivershare AS dshare,
booking_charges.partnershare AS pshare,complaint.ID as com_id,
complaint.StatusID as com_status, cab_booking.csr_id as emp,
CONCAT(cab_booking.drop_address,cab_booking.drop_area) as drop_area,cab_booking.id as id,
booking_charges.totalBill, cab_booking.booking_reference as ref,
master_package.master_package as booking_type,
CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as ordertime,
concat(client.clientName,'<br>(',appid.`type`,')') as partner,
REPLACE(cab_master.CabName,'·','') as vehicle,
CONCAT(user_info.first_name," ",user_info.last_name) as clientname,user_info.alternate_contact_no as alt_no,
CONCAT(driver.first_name," ",driver.last_name) as driver_name, 
user_info.mobile_no as mob_no,cab_booking.charge_type,user_info.uid as client_id,driver.uid as driver_id,
CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,
driver.vehicle_reg_no as reg,cab_status.`status` as `status`
 FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` 
 JOIN user_info ON user_info.uid=cab_booking.client_id 
 JOIN master_package ON cab_booking.booking_type=master_package.package_id 
 LEFT JOIN driver ON cab_booking.pickup=driver.uid 
 LEFT JOIN cab_master ON driver.vehicle_id=cab_master.CabId
 JOIN appid ON appid.id=cab_booking.partner 
 JOIN client ON appid.clientId=client.id 
 LEFT JOIN booking_charges ON cab_booking.id=booking_charges.BookingID 
 LEFT JOIN complaint ON cab_booking.booking_reference=complaint.BookingID 
 WHERE cab_status.`type`='cab' and cab_booking.`pickup_date`>=CURDATE() and cab_booking.`status` <=8 order by cab_booking.id desc; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_booking_information` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_booking_information`(IN `booking_id` INT)
    NO SQL
BEGIN
SELECT
bk.booking_id as id,bk.reference_number as ref,
CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
mpm.package_mode,
mp.name  as booking_type,
payty.pay_type_mode as payment_type,
mvt.vehicle_type as vehicle,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date,
cs.status,
bkest.*,
bkest.estimated_final_price as amount,
CONCAT(
    bpd.pickup_date,
    " ",
    bpd.pickup_time
  ) AS ordertime,
CONCAT(
    bpd.pickup_address,
    ' ',
    bpd.pickup_area
  ) AS departure,
CONCAT(
    bpd.drop_address,
    ' ',
    bpd.drop_area
  ) AS drop_area,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_landmark,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_landmark,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone
FROM booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package as lp ON bk.package_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
WHERE
  bk.booking_id = booking_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_client_info` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_client_info`(IN `user_id` INT)
BEGIN
SELECT 
user.create_date,
user.id,
user.referral_key,
user.login_name,
user_info.email,
user_info.first_name,
user_info.last_name,
user_info.mobile_no,
user_info.image,
	user_info.alt_email,
	user_info.alternate_contact_no,
	user_info.country,
	user_info.state,
	user_info.city,
	user_info.address1,
	user_info.address2,
	user_info.pincode,
	user_info.bank_account_name,
	user_info.acount_holder,
	user_info.bank_adds,
	user_info.account_no,
	user_info.rtgs_neft,
	user_info.ibn,
user_info.`language`  FROM user JOIN user_info ON user.id=user_info.uid WHERE user.id=user_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_client_information` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_client_information`(IN `client_id` INT)
BEGIN
SELECT * FROM user_info WHERE user_id=client_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_client_list` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_client_list`()
BEGIN
SELECT user.id,
		 CONCAT(user_info.first_name,' ',user_info.last_name) as name,
		 user.login_name AS Email,
		 user.user_no AS ContactNumber,
		 user.create_date,
		 user.user_type,
		 Count(user.id) as booking 
FROM user 
JOIN user_info ON user.id=user_info.uid 
LEFT JOIN cab_booking ON user.id=cab_booking.client_id 
WHERE user.is_verified=1 and user.user_type IN (1,2) 
GROUP BY (user.id);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_driver_confirm` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_driver_confirm`(IN `driver_id` INT, IN `stat` INT)
BEGIN
IF stat!=3 THEN
SELECT booking.*,vt.vehicle_type,pd.pickup_time,pd.pickup_date,pd.pickup_area,pd.drop_address FROM booking join master_vehicle_type as vt ON booking.master_vehicle_type_id = vt.id JOIN booking_pickdrop_details as pd ON booking.booking_id=pd.booking_id WHERE booking.driver_id=driver_id and booking.`status`=stat order by booking.booking_id desc;
END IF;
IF stat=3 THEN
SELECT booking.*,vt.vehicle_type,pd.pickup_time,pd.pickup_date,pd.pickup_area,pd.drop_address FROM booking JOIN booking_pickdrop_details as pd ON booking.booking_id=pd.booking_id join master_vehicle_type as vt ON booking.master_vehicle_type_id = vt.id  WHERE booking.driver_id=driver_id and booking.`status`<6 and CONCAT(pd.pickup_date,' ',pd.pickup_time)>NOW() order by booking.booking_id desc;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_driver_confirm_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_driver_confirm_old`(IN `driver_id` INT, IN `stat` INT)
BEGIN
IF stat!=3 THEN
SELECT * FROM cab_booking WHERE pickup=driver_id and `status`=stat order by id desc;
END IF;
IF stat=3 THEN
SELECT * FROM cab_booking WHERE pickup=driver_id and `status`<6 and CONCAT(cab_booking.PickupDate,' ',cab_booking.PickupTime)>NOW() order by id desc;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_latest_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_latest_booking`(IN `lim` INT)
    NO SQL
BEGIN
SELECT cab_booking.ID as id,cab_booking.bookingdate as ordertime,"dfdfdfd",CONCAT(user_info.FirstName," ",user_info.LastName) as clientname,cab_booking.Departure as departure,booking_status.`status` as `status` FROM cab_booking JOIN booking_status ON cab_booking.`status`=booking_status.`id` JOIN user_info ON user_info.UID=cab_booking.ClientID LEFT JOIN driver ON cab_booking.pickup=driver.uid order by cab_booking.id desc LIMIT 0,lim ;   
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_list_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_list_booking`(IN `datea` DATE)
BEGIN
SELECT
  bk.booking_id as id,
  bk.driver_id,
  CONCAT(
    CLIENT.first_name,
    '(',
    appid.`type`,
    ')'
  ) AS partner,
  bk.reference_number AS ref,
  HOUR(bk.booking_date) AS HOUR,
  mp.name  AS booking_type,
  CONCAT(
    driver.`first_name`,
    " ",
    driver.`last_name`
  ) AS driver,
  CONCAT(
    user_info.`first_name`,
    " ",
    user_info.`last_name`
  ) AS clientname,
  user_info.mobile AS ContactNo,
  cs.`status` AS `status`,
  bk.booking_date,
  bpd.pickup_address as pickup_location,
  bpd.pickup_area
FROM
  booking as bk
JOIN
  user as user_info ON bk.user_id = user_info.id
LEFT JOIN 
  user as driver ON bk.driver_id=driver.id
JOIN 
  master_package as mp ON bk.master_package_id = mp.id
JOIN  
  cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
LEFT join 
  booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
JOIN
  appid ON bk.partner = appid.id
JOIN 
  user as CLIENT ON bk.client_id = CLIENT.id
WHERE
  DATE(bk.booking_date) = datea AND bpd.`pickup_date` >= CURDATE()
ORDER BY
  bk.booking_id DESC;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_list_booking_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_list_booking_old`(IN `datea` DATE)
BEGIN
SELECT `cab_booking`.id as id,concat(client.clientName,'(',appid.`type`,')') as partner,cab_booking.booking_reference as ref,HOUR(`booking_date`) as hour,cab_booking.booking_type as booking_type,CONCAT(driver.`first_name`," ",driver.`last_name`) as driver,CONCAT(user_info.`first_name`," ",user_info.`last_name`) as clientname, user_info.mobile_no as ContactNo,cab_status.`status` as `status`,`booking_date`,`pickup_location`,`pickup_area` FROM cab_booking JOIN user_info ON cab_booking.client_id=user_info.uid JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` JOIN appid ON cab_booking.partner=appid.id JOIN client ON client.id=appid.clientId LEFT JOIN driver on cab_booking.pickup=driver.UID WHERE date(cab_booking.booking_date)=datea and cab_booking.`pickup_date`>=CURDATE() and cab_status.`type`='cab' order by cab_booking.id desc;    
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_list_date_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_list_date_booking`(IN `i_date` DATE)
BEGIN
SELECT COUNT(*) AS no_of,DATE(`pickup_date`) as `date` FROM booking_pickdrop_details WHERE i_date<=DATE(`pickup_date`) and DATE(`pickup_date`)<=DATE(DATE_ADD(i_date,INTERVAL 14 DAY)) GROUP BY DATE(`pickup_date`);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_list_hour_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_list_hour_booking`(IN `i_date` DATE, IN `i_time` INT)
BEGIN
IF i_time=0 THEN
SELECT COUNT(*) as no_of,HOUR(`pickup_time`) as `hour` FROM booking_pickdrop_details WHERE pickup_date=i_date GROUP BY HOUR(`pickup_time`);
ELSE
SELECT COUNT(*) as no_of,HOUR(`pickup_time`) as `hour` FROM booking_pickdrop_details WHERE pickup_date=i_date and hour(`pickup_time`)=i_time;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_list_hour_booking_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_list_hour_booking_old`(IN `i_date` DATE, IN `i_time` INT)
BEGIN
IF i_time=0 THEN
SELECT COUNT(*) as no_of,HOUR(`pickup_time`) as `hour` FROM cab_booking WHERE pickup_date=i_date GROUP BY HOUR(`pickup_time`);
ELSE
SELECT COUNT(*) as no_of,HOUR(`pickup_time`) as `hour` FROM cab_booking WHERE pickup_date=i_date and hour(`pickup_time`)=i_time;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_list_package_wise_booking` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_list_package_wise_booking`(IN `i_date` DATE, IN `i_time` INT)
BEGIN
IF i_time=0 THEN
SELECT COUNT(*) as no,bk.master_package_id AS booking_type FROM booking_pickdrop_details as bpd
join booking AS bk ON bk.booking_id = bpd.booking_id
WHERE bpd.pickup_date=i_date GROUP BY (bk.master_package_id);
ELSE
SELECT COUNT(*) as no,bk.master_package_id AS booking_type FROM booking_pickdrop_details as bpd
join booking AS bk ON bk.booking_id = bpd.booking_id
WHERE bpd.pickup_date=i_date and hour(bpd.`pickup_time`)=i_time GROUP BY (bk.master_package_id);
END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_login_logs` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_login_logs`(IN `driver_id` INT)
    NO SQL
BEGIN
SELECT login_time,logout_time,login_diff,DATE(log_in_log.login_time) as `date`,TIMEDIFF(logout_time,login_time) as diff from log_in_log WHERE userid=driver_id ORDER by id DESC;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_login_logs_2` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_login_logs_2`(IN `driver_id` INT, IN `log_time` DATE)
BEGIN
SELECT login_time,logout_time,DATE(log_in_log.login_time) as `date`,TIMEDIFF(logout_time,login_time) as diff from log_in_log WHERE userid=driver_id and date(login_time)=log_time ORDER by id desc;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_login_logs_week` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_login_logs_week`(IN `driver_id` INT, IN `since` DATE, IN `too` DATE)
BEGIN
SELECT login_time,logout_time,DATE(log_in_log.login_time) as `date`,TIMESTAMPDIFF(second,login_time,logout_time) as diff from log_in_log 
WHERE userid=driver_id and date(login_time) BETWEEN date(since) AND date(too);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_payment_information` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_payment_information`(IN `booking_id` INT)
    NO SQL
BEGIN
SELECT
bk.booking_id as ID,bk.reference_number as booking_reference,
CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
bk.is_corportate,
bk.is_account,
mpm.package_mode,
mp.name  as booking_type,
payty.pay_type_mode as payment_type,
mvt.vehicle_type as vehicle,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date as BookingDate,
bk.created_date as addedtime,
cs.status,
bkest.*,
bkest.estimateprice_before_discount as total_price,
bkest.discount_price as total_discount,
bkest.estimated_final_price as final_price,
bkest.booking_amt_percentage as paid_amt_percentage,
bkest.booking_amt_paid as paid_amount,
bkest.booking_amt_balance as balance_amount,
bkest.estimated_distance as EstimatedDistance,
bkest.estimated_time as EstimatedTime,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_date as PickupDate,
bpd.pickup_time as PickupTime,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_area as PickupArea,
bpd.pickup_address as PickupAddress,
bpd.pickup_landmark,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_address as DropAddress,
bpd.drop_area as DropArea,
bpd.drop_landmark,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone
FROM
   booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package as lp ON bk.package_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
WHERE
  bk.booking_id = booking_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_payment_information_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_payment_information_old`(IN `booking_id` INT)
    NO SQL
BEGIN
SELECT cab_master.CabName as cab_name,driver.vehicle_id,addedtime,cancellation_price,waitingCharge,tripCharge,total_tax_price,totalBill,is_paid,paid_at,currency,invoice_number,payment_type,fees,total_price,total_tax_price,duration_rate,starting_rate,base_price,tax_price,starting_charge,distance_charge,duration_charge,minimum_price,cab_booking.*
FROM cab_booking 
LEFT JOIN booking_charges ON cab_booking.id=booking_charges.bookingid 
LEFT JOIN driver ON cab_booking.pickup=driver.uid
LEFT JOIN cab_master ON driver.vehicle_id=cab_master.CabId
WHERE cab_booking.id=booking_id; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sp_w_user_edit_profile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_w_user_edit_profile`(IN `fname` VARCHAR(50), IN `lname` VARCHAR(50), IN `mob` BIGINT, IN `landline` VARCHAR(50), IN `email` VARCHAR(50), IN `altemail` VARCHAR(50), IN `company` VARCHAR(50), IN `address` VARCHAR(50), IN `res_addr` VARCHAR(50), IN `id_i` INT, IN `altMobile` INT)
BEGIN
Declare com_id INT;
SELECT company.ID as com_id from company
 INNER JOIN user_info ON user_info.CompanyID = company.ID
 where user_info.UID = id_i;
UPDATE user SET LoginName = email, UserNo = mob WHERE ID = id_i;
UPDATE user_info SET FirstName = fname, LastName = lname, MobNo = mob, LandNo = landline, Email = email,
AltEmail = altemail,Address1 = address,Address2 = res_addr,AlternateContactNo=altMobile WHERE UID = id_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_activation_user` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_activation_user`(IN `verify` VARCHAR(210), IN `token` VARCHAR(150))
BEGIN
DECLARE verifyTotal INT;
DECLARE uerrid VARCHAR(50);
SELECT COUNT(*) ,UID INTO verifyTotal,uerrid FROM `tblactivation` WHERE `Verification_code` = verify AND `isUsed`=0 LIMIT 0,1;
IF verifyTotal=1 THEN
UPDATE `tblactivation` SET `isUsed` =  '1' WHERE `UID` = uerrid;
UPDATE `user` SET `isVerified` =  '1' WHERE `ID` = uerrid;
UPDATE `user` SET `token`= token WHERE `ID` = uerrid;
END IF;
SELECT verifyTotal,uerrid;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_app_chat_list` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_app_chat_list`(IN `driver_id` INT)
BEGIN
SELECT distinct bookingid,CONCAT (user_info.Firstname," ",user_info.LastName) as name,user_info.UID as userid from booking_msg JOIN cab_booking ON booking_msg.bookingid=cab_booking.ID JOIN user_info ON user_info.UID=cab_booking.ClientID WHERE booking_msg.sender=driver_id or booking_msg.receiver=driver_id order by booking_msg.id desc;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_action_type_info_by_id` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_action_type_info_by_id`(IN `action_Id_i` INT)
BEGIN
SELECT * FROM tblactiontype WHERE id = action_Id_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_add_device` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_add_device`(IN `dUnit` INT, IN `dpickDate` VARCHAR(50), IN `dactiveDate` VARCHAR(50), IN `dSim` INT, IN `dPort` INT, IN `taxiId` VARCHAR(50))
BEGIN
DECLARE untid INT;
SELECT COUNT(`unit_no`) INTO untid FROM `device` WHERE `unit_no` = dUnit;
IF untid < 1 THEN  
INSERT INTO `device` (`unit_no`,`purchase_date`,`activation_date`,`sim_no`,`port`,`taxiNoId`,`status`) VALUES (dUnit,dpickDate,dactiveDate,dSim,dPort,taxiId,1);
END IF;
SELECT LAST_INSERT_ID() AS devicesId,untid;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_add_vehicle` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_add_vehicle`(IN `cabtype_i` INT(10), IN `vehicle_model_i` VARCHAR(100), IN `external_reference_i` VARCHAR(100), IN `year_i` INT(20), IN `license_plate_i` VARCHAR(100), IN `colour_i` VARCHAR(100), IN `engine_no_i` VARCHAR(100), IN `fueltype_i` VARCHAR(100), IN `capacity_i` INT(10), IN `status_i` INT(10))
    NO SQL
BEGIN
DECLARE vehicle_exists int;
SELECT COUNT(*) INTO vehicle_exists FROM `cab_list_mgmt` WHERE `Engine_No`  =engine_no_i OR `license_plate`  =license_plate_i;
IF vehicle_exists =0 THEN
INSERT INTO `cab_list_mgmt` (`CabType`,`VehicleModel`,`external_reference`,`year`,`license_plate`,`colour`,`Engine_No`,`fuelType`,`capacity`,`status`) values(cabtype_i,vehicle_model_i,external_reference_i,year_i,license_plate_i,colour_i,engine_no_i,fueltype_i,capacity_i,status_i);
END IF;
SELECT vehicle_exists;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_add_vehicle_type` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_add_vehicle_type`(IN `cabname_i` TEXT, IN `city_i` TEXT)
    NO SQL
BEGIN
DECLARE id_s int;
DECLARE cabtype_exists int;
SELECT COUNT(*) INTO cabtype_exists FROM `booking_bill` WHERE `CabName` COLLATE latin1_general_ci =cabname_i AND `CityId`=city_i;
IF cabtype_exists =0 THEN
INSERT INTO `booking_bill` (`CabName`,`cityId`) values(cabname_i,city_i);
SET id_s=LAST_INSERT_ID();
UPDATE `booking_bill` SET `cabType`=id_s WHERE id=id_S;
END IF;
SELECT cabtype_exists;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_bank_update` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_bank_update`(IN `dids` INT, IN `bankName` VARCHAR(50), IN `holderName` VARCHAR(50), IN `bAdds` VARCHAR(50), IN `anos` VARCHAR(50), IN `neft` VARCHAR(50), IN `ibnos` VARCHAR(50))
BEGIN
UPDATE `driver` SET `bank_account_name`=bankName,`acount_holder`=holderName,`bank_adds`=bAdds,`account_no`=anos,`rtgs_neft`=neft,`ibn`=ibnos WHERE `UID`=dids;
SELECT ROW_COUNT() AS count;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_booking_complaint_list` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_booking_complaint_list`()
BEGIN
SELECT complaint.ID as com_id,complaint.StatusID as com_status, cab_booking.csr_id as emp,CONCAT(cab_booking.drop_address,cab_booking.drop_area) as drop_area,cab_booking.id as id,booking_charges.totalBill, cab_booking.booking_reference as ref,master_package.master_package as booking_type,CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as ordertime,concat(client.clientName,'<br>(',appid.`type`,')') as partner,REPLACE(vehicle_type.vehicle_type,'·','') as vehicle,CONCAT(user_info.first_name," ",user_info.last_name) as clientname,CONCAT(driver.first_name," ",driver.last_name) as driver_name, user_info.mobile_no as mob_no,user_info.uid as client_id,driver.uid as driver_id,CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,driver.vehicle_reg_no as reg,cab_status.`status` as `status` FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` JOIN user_info ON user_info.uid=cab_booking.client_id JOIN master_package ON cab_booking.booking_type=master_package.package_id LEFT JOIN driver ON cab_booking.pickup=driver.uid LEFT JOIN vehicle_type ON driver.vehicle_type=vehicle_type.id JOIN appid ON appid.id=cab_booking.partner JOIN client ON appid.clientId=client.id LEFT JOIN booking_charges ON cab_booking.id = booking_charges.BookingID INNER JOIN complaint ON cab_booking.booking_reference = complaint.BookingID WHERE cab_status.`type`='cab' order by cab_booking.id desc;   
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_cab_package_calculation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_cab_package_calculation`(IN `local_package` VARCHAR(50), IN `point_to_point_package` VARCHAR(50), IN `airport_package` VARCHAR(50), IN `outstation_package` VARCHAR(50))
BEGIN
DECLARE localPackage varchar(50);
DECLARE pointToPointPackage varchar(50);
DECLARE airportPackage varchar(50);
DECLARE outstationPackage varchar(50);
SELECT tblsubpackage.Sub_Package_Id INTO localPackage FROM tblsubpackage WHERE tblsubpackage.Sub_Package_Name = local_package;
SELECT tblsubpackage.Sub_Package_Id INTO pointToPointPackage FROM tblsubpackage WHERE tblsubpackage.Sub_Package_Name = point_to_point_package;
SELECT tblsubpackage.Sub_Package_Id INTO airportPackage FROM tblsubpackage WHERE tblsubpackage.Sub_Package_Name = airport_package;
SELECT tblsubpackage.Sub_Package_Id INTO outstationPackage FROM tblsubpackage WHERE tblsubpackage.Sub_Package_Name = outstation_package;
UPDATE master_package SET master_package.Sub_Package_Id = localPackage where master_package.Master_Package = 'Local';
UPDATE master_package SET master_package.Sub_Package_Id = pointToPointPackage where master_package.Master_Package = 'Point To Point';
UPDATE master_package SET master_package.Sub_Package_Id = airportPackage where master_package.Master_Package = 'Airport Terminal';
UPDATE master_package SET master_package.Sub_Package_Id = outstationPackage where master_package.Master_Package = 'Outstation';
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_client_bank_update` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_client_bank_update`(IN `cids` INT, IN `bankName` VARCHAR(50), IN `holderName` VARCHAR(50), IN `bAdds` VARCHAR(50), IN `anos` VARCHAR(50), IN `neft` VARCHAR(50), IN `ibnos` VARCHAR(50))
BEGIN
UPDATE `user_info` SET `bank_account_name`=bankName,`acount_holder`=holderName,`bank_adds`=bAdds,`account_no`=anos,`rtgs_neft`=neft,`ibn`=ibnos WHERE `uid`=cids;
SELECT ROW_COUNT() AS count;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_client_update_profile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_client_update_profile`(IN `cids` INT, IN `fname` VARCHAR(50), IN `lname` VARCHAR(50), IN `lang` INT, IN `email` VARCHAR(50), IN `cnt_no` VARCHAR(50), IN `alt_email` VARCHAR(50), IN `alt_cnt_no` VARCHAR(50), IN `country` INT, IN `state` INT, IN `city` INT, IN `address1` TEXT, IN `address2` TEXT, IN `pin_code` VARCHAR(10))
BEGIN
DECLARE tablecount INT;
DECLARE usercount INT;
UPDATE `user_info` SET `first_name`=fname,`last_name`=lname,`alt_email`=alt_email,`country`=country,`state`=state,`city`=city,`address1`=address1,`address2`=address2,`pincode`=pin_code,`mobile_no`=cnt_no,`alternate_contact_no`=alt_cnt_no WHERE `uid`=cids;
SELECT ROW_COUNT() INTO tablecount;
UPDATE `user` SET `login_name`=email WHERE `id`=cids;
SELECT ROW_COUNT() as tablecountuser, tablecount;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_complaint_type_info_by_id` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_complaint_type_info_by_id`(IN `complaint_id_i` INT)
BEGIN
SELECT sub_complaint.id, enquiry_type.enquiry_type, sub_complaint.sub_complaint FROM enquiry_type INNER JOIN sub_complaint ON enquiry_type.id = sub_complaint.complaint_type WHERE sub_complaint.id = complaint_id_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_delete_action_type` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_delete_action_type`(IN `id_i` INT)
BEGIN
DELETE FROM tblactiontype WHERE id = id_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_delete_complaint_type` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_delete_complaint_type`(IN `id_i` INT)
BEGIN
DELETE FROM sub_complaint WHERE id = id_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_delete_enquiry_type` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_delete_enquiry_type`(IN `id_i` INT)
BEGIN
DELETE FROM enquiry_type WHERE id = id_i;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_device_delete` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_device_delete`(IN `deviceid` INT)
BEGIN
UPDATE `device` SET `status` = 0 WHERE `unit_no` = deviceid;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_device_edit` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_device_edit`(IN `idDevice` INT)
BEGIN
SELECT a.*,b.vehicleNumber FROM `device` a INNER JOIN `cab_list_mgmt` b ON a.taxiNoId = b.id WHERE a.unit_no=idDevice;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_device_list` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_device_list`()
BEGIN
SELECT a.unit_no,a.purchase_date,a.activation_date,a.sim_no,a.port,b.vehicleNumber FROM `device` a LEFT JOIN `cab_list_mgmt` b ON a.taxiNoId = b.id WHERE a.status=1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_device_taxi_nos` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_device_taxi_nos`(IN `data` VARCHAR(50))
BEGIN
SELECT `id`,`vehicleNumber` FROM `cab_list_mgmt` WHERE `vehicleNumber` LIKE CONCAT('%', data , '%');
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_device_update` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_device_update`(IN `dunit` INT, IN `devicepdate` VARCHAR(50), IN `deviceadate` VARCHAR(50), IN `dsim` INT, IN `dport` INT, IN `taxiNos` VARCHAR(50))
BEGIN
UPDATE `device` SET `purchase_date`=devicepdate,`activation_date`=deviceadate,`sim_no`=dsim,`port`=dport,`taxiNoId`=taxiNos WHERE `unit_no` = dunit;
SELECT ROW_COUNT() AS ids;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_a_history` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_a_history`(IN `dids` INT)
BEGIN
SELECT * FROM `booking_register` WHERE driverId=dids; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_b_history` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_b_history`(IN `dids` INT)
BEGIN
SELECT bk.booking_id as id,bk.reference_number as ref,
	CONCAT(
    us.first_name,
    " ",
    us.last_name
  ) AS user_name,
  CONCAT(
    us2.first_name,
    " ",
    us2.last_name
  ) AS clientname,
 CONCAT(
    driver.first_name,
    " ",
    driver.last_name
  ) AS driver_name,
lp.name as local_package_id,
lp.hrs as local_package_hrs,
lp.km as local_package_km,
mpm.package_mode,
mp.name  as booking_type,
payty.pay_type_mode as charge_type,
mvt.vehicle_type as vehicle,
bk.no_of_vehicles,
mcoup.name as coupon_name,
bk.booking_date,
cs.status,
bkest.*,
bkest.estimated_final_price as amount,
 CONCAT(
    bpd.pickup_date,
    " ",
    bpd.pickup_time
  ) AS ordertime,
  CONCAT(
    bpd.pickup_address,
    ' ',
    bpd.pickup_area
  ) AS departure,
  CONCAT(
    bpd.drop_address,
    ' ',
    bpd.drop_area
  ) AS drop_area,
bpd.adults,
bpd.childs,
bpd.luggages,
bpd.pickup_country,
bpd.pickup_state,
bpd.pickup_city,
bpd.pickup_landmark,
bpd.pickup_latitude,
bpd.pickup_longitude,
bpd.pickup_zone,
bpd.drop_date,
bpd.drop_time,
bpd.drop_country,
bpd.drop_state,
bpd.drop_city,
bpd.drop_landmark,
bpd.drop_latitude,
bpd.drop_longitude,
bpd.drop_zone
from booking as bk
JOIN user as us ON bk.user_id=us.id
JOIN user as us2 ON bk.client_id=us2.id
LEFT JOIN user as driver ON bk.driver_id=driver.id
JOIN master_package_mode as mpm ON bk.master_package_mode_id = mpm.id 
JOIN master_package as mp ON bk.master_package_id = mp.id 
JOIN master_vehicle_type as mvt ON bk.master_vehicle_type_id = mvt.id
LEFT JOIN master_coupon as mcoup ON bk.coupon_id = mcoup.id
LEFT JOIN local_package as lp ON bk.package_id = lp.id
JOIN cab_status as cs ON bk.status = cs.status_id AND cs.type = 'cab'
JOIN payment_type as payty ON bk.charge_type = payty.payment_type_id
LEFT join 
	booking_estimation as bkest ON bk.booking_id = bkest.booking_id
LEFT join 
	booking_pickdrop_details as bpd ON bk.booking_id=bpd.booking_id
LEFT JOIN
  booking_tracker ON bk.booking_id = booking_tracker.BookingID AND booking_tracker.CabStatus = 3
WHERE
    bk.driver_id = dids
ORDER BY
  bk.booking_id DESC;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_b_history_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_b_history_old`(IN `dids` INT)
SELECT complaint.ID as com_id,complaint.StatusID as com_status, cab_booking.csr_id as emp,booking_charges.totalBill AS amount,(booking_charges.totalBill*booking_charges.companyshare/100) AS cAmount,(booking_charges.totalBill*booking_charges.drivershare/100) AS dAmount,(booking_charges.totalBill*booking_charges.partnershare/100) AS pAmount,booking_charges.companyshare AS cshare,booking_charges.drivershare AS dshare,booking_charges.partnershare AS pshare,
CONCAT(cab_booking.drop_address,cab_booking.drop_area) as drop_area,cab_booking.id as id,
booking_charges.totalBill, cab_booking.booking_reference as ref,master_package.master_package as booking_type,
CONCAT(cab_booking.pickup_date," ",cab_booking.pickup_time) as ordertime,concat(client.clientName,'<br>(',appid.`type`,')') as partner,
CONCAT(user_info.first_name," ",user_info.last_name) as clientname,
CONCAT(driver.first_name," ",driver.last_name) as driver_name, user_info.mobile_no as mob_no,user_info.uid as client_id,cab_master.CabName,cab_booking.basic_tax_price,
driver.uid as driver_id,CONCAT(cab_booking.pickup_address,' ',cab_booking.pickup_area) as departure,driver.vehicle_reg_no as reg,
cab_status.`status` as `status` 
FROM cab_booking JOIN cab_status ON cab_booking.`status`=cab_status.`status_id` 
JOIN user_info ON user_info.uid=cab_booking.client_id 
JOIN master_package ON cab_booking.booking_type=master_package.package_id 
LEFT JOIN driver ON cab_booking.pickup=driver.uid 
LEFT JOIN cab_master ON cab_master.CabId=driver.vehicle_id  
JOIN appid ON appid.id=cab_booking.partner 
JOIN client ON appid.clientId=client.id 
LEFT JOIN booking_charges ON cab_booking.ID=booking_charges.BookingID 
LEFT JOIN complaint ON cab_booking.ID=complaint.BookingID
INNER JOIN booking_tracker ON cab_booking.id=booking_tracker.BookingID WHERE 
cab_status.`type`='cab' AND booking_tracker.CabStatus =3 AND cab_booking.pickup=dids order by cab_booking.id desc ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_cer_down` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_cer_down`(IN `dids` INT)
BEGIN
SELECT mdt.doc_level_name,uud.doc_file_upload,mdt.doc_type_id
from master_document_type AS mdt LEFT JOIN user_upload_document AS uud ON mdt.doc_type_id = uud.document_type_id where mdt.type = 'driverC' AND uud.user_id =dids and uud.status=1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_cer_down_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_cer_down_old`(IN `dids` INT)
BEGIN
SELECT `residential_proof`,`office_proof`,`pancard_proof`,`vehicle_proof`,`license_proof`,`police_proof`,`audit_proof`,`rc_proof` FROM `driver` WHERE `user_id`=dids;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_cer_update` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_cer_update`(IN `dids` INT, IN `resProof` TEXT, IN `ofcProof` TEXT, IN `panProof` TEXT, IN `vproof` TEXT, IN `badgeProof` TEXT, IN `pProof` TEXT, IN `auditproof` TEXT, IN `rcproof` TEXT)
BEGIN
UPDATE `driver` SET `residential_proof`=resProof,`office_proof`=ofcProof,`pancard_proof`=panProof,`vehicle_proof`=vproof,`license_proof`=badgeProof,`police_proof`=pProof,`audit_proof`=auditproof,`rc_proof`=rcproof WHERE `UID`=dids;
SELECT ROW_COUNT() as count;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_contacts` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_contacts`(IN `dids` INT)
BEGIN
SELECT `ContactNo` FROM `driver` WHERE `UID`=dids;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_data` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_data`()
BEGIN
SELECT a.UID,a.FirstName,a.Email,a.status,a.ContactNo,a.VehicleRegistrationNo,a.DrivingLicenceNo,a.is_active,a.created_date,b.name as vehicleName,f.status as approvedStatus,
count(pickup) as booking, e.isVerified FROM `driver` a INNER JOIN `cab_list_mgmt` b ON a.vehicleId = b.id LEFT JOIN `cab_booking` d ON a.UID=d.pickup INNER JOIN `user` e ON a.UID = e.ID INNER JOIN `active` f ON  
 e.isVerified=f.status_id group by(UID) ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_edit_group` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_edit_group`(IN `gids` INT, IN `dids` INT)
BEGIN
UPDATE `driver` SET `vendor_id`=gids WHERE `UID`=dids;
SELECT ROW_COUNT() AS gedit;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_edit_profile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_edit_profile`(IN `driverId` INT)
BEGIN
SELECT
userInfo.id AS ID_user_info,
driver.*,
driver.id AS uid,
  driver.is_verified AS isVerifY,
  driver.email AS userName,
  driver.password AS loginPass,
  driver2.status AS driverStatus, 
  driver2.pancard_no AS pan_card_no,
  driver2.driving_license_no,
  driver2.total_fleet_no,
  driver2.license_validity AS license_validity,
  driver2.operational_company_name,
  driver2.imei,
  driver2.gps,
  driver2.eye_test,
  driver2.photo_verify,
  driver2.zone,
  driver2.route_know,
  mvm.name AS CabName,
  vm.permit_exp_date AS expiry,
  vm.vehicle_no AS vehicle_reg_no,
  vm.vehicle_owner_type AS vehicle_owned,
  vm.vehicle_owner_name,
  vm.vehicle_owner_mobile AS vehicle_owner_cnt_no,
  vm.model AS CabModel,
  vm.registration_number AS CabRegistrationNumber,
  vm.ignition_type_id AS CabIgnitionTypeId,
  vm.rc_no,
  vm.insurance_validity,
  mvt.vehicle_type,
  licenceState.name AS licence_state,
  ignition_type.fuel_type as CabIgnitionType,
  role.RoleName,
  userInfo.image,
  vm.image AS vehicle_image,
  company.company_name as operational_company_name,
  company.company_address AS office_address,
  company.pincode AS company_pincode,
  city.name AS v_city,
  state.name AS v_state,
  country.name AS v_country,
  userInfo.pincode AS v_pin,
  driver.mobile AS contact_no,
  userInfo.father_name,
  userInfo.dob,
  userInfo.address AS Address,
  city.name AS cn,
  state.name AS sn
FROM
    user AS driver
Left JOIN 
      driver AS driver2 on driver.id =  driver2.user_id
Left JOIN 
      master_state AS licenceState ON driver2.license_state =  licenceState.id
LEFT JOIN
  user_info AS userInfo ON driver.id = userInfo.user_id
LEFT JOIN 
 user_role AS role ON driver.user_type_id = role.Role_ID 
LEFT JOIN 
  master_city AS city ON userInfo.city_id = city.id
LEFT JOIN 
  master_state AS state ON userInfo.state_id = state.id
LEFT JOIN
 master_country AS country ON userInfo.country_id = country.id 
LEFT JOIN
  user_vehicle_mapping AS uvm ON driver.id = uvm.user_id
LEFT JOIN
 vehicle_master AS vm ON uvm.vehicle_master_id = vm.vehicle_master_id
LEFT JOIN 
 master_fuel_type AS ignition_type ON vm.ignition_type_id = ignition_type.id
LEFT JOIN 
 master_vehicle_model AS mvm ON  vm.id = mvm.id
LEFT JOIN 
 master_vehicle_type AS mvt ON  mvm.vehicle_type_id = mvt.id
LEFT JOIN
  booking AS bk ON driver.id = bk.driver_id
LEFT JOIN 
  company ON driver.id = company.user_id
LEFT JOIN
  active ON driver2.is_active = active.status_id
WHERE
  driver.id = driverId;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `wp_a_driver_edit_profile_old` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `wp_a_driver_edit_profile_old`(IN `driverId` INT)
BEGIN
DECLARE isVerifY INT;
DECLARE userName VARCHAR(50);
DECLARE loginPass VARCHAR(50);
DECLARE driverStatus INT;
DECLARE ref_Key VARCHAR(50);
SELECT `is_verified`,`login_name`,`password`,`login_status`,`referral_key` into isVerifY,userName,loginPass,driverStatus,ref_Key FROM `user` WHERE `id`= driverId;
SELECT user_info.id as ID_user_info,driver.*,isVerifY,userName,loginPass,driverStatus,ref_Key,cab_master.CabName,cab_master.CabPermitExpDate as expiry, vehicle_type.vehicle_type,driver.licence_state,cab_master.CabModel,cab_master.CabRegistrationNumber, cab_master.CabIgnitionTypeId,ignition_type.CabIgnitionType,vendor.vendor_name, user_info.image,user_info.vehicle_image, 
user.user_type, vendor.group_name,vendor.UID as v_id, vendor.vendor_name, vendor.vendor_email,user_info.city as v_city, user_info.state as v_state, 
user_info.country as v_country, user_info.pincode as v_pin, user_info.mobile_no as v_mob, user_info.address1 as v_address, cities.city_name as cn, states.state as sn,states.state as licence_state, country.country_name as countryName 
FROM `driver` 
INNER JOIN `cab_master` ON driver.vehicle_id = cab_master.CabId 
INNER JOIN `ignition_type` ON ignition_type.id = cab_master.CabIgnitionTypeId
INNER JOIN `vehicle_type` ON vehicle_type.id = cab_master.CabType
LEFT JOIN  `vendor` ON driver.vendor_id=vendor.id 
INNER JOIN user_info ON driver.uid = user_info.uid
LEFT JOIN `cities` ON driver.city = cities.id
LEFT JOIN `states` ON driver.state = states.id AND driver.licence_state = states.id
LEFT JOIN `country` ON driver.country = country.id
INNER JOIN user ON driver.uid = user.id 
WHERE driver.uid=driverId;
END ;;
